SASC-NG
DVBSoftCAM

cN2Prov0501 Class Reference

Inheritance diagram for cN2Prov0501:

List of all members.

Public Member Functions

 cN2Prov0501 (int Id, int Flags)
virtual int ProcessBx (unsigned char *data, int len, int pos)
virtual int RunEmu (unsigned char *data, int len, unsigned short load, unsigned short run, unsigned short stop, unsigned short fetch, int fetch_len)
virtual void PostDecrypt (bool ecm)

Protected Member Functions

virtual bool Algo (int algo, const unsigned char *hd, unsigned char *hw)
virtual bool NeedsCwSwap (void)
virtual bool RomInit (void)
virtual void TimerHandler (unsigned int num)
virtual void AddMapCycles (unsigned int num)
virtual unsigned int CpuCycles (void)

Detailed Description

Definition at line 49 of file nagra2-0501.c.


Constructor & Destructor Documentation

cN2Prov0501::cN2Prov0501 ( int  Id,
int  Flags 
)

Definition at line 73 of file nagra2-0501.c.

References cMapCore::SetMapIdent().

:cN2Prov(Id,Flags)
{
  hwMapper=0; hasMaprom=false;
  SetMapIdent(Id);
}

Member Function Documentation

virtual void cN2Prov0501::AddMapCycles ( unsigned int  num) [inline, protected, virtual]

Reimplemented from cMapCore.

Definition at line 62 of file nagra2-0501.c.

References c6805::AddCycles().

{ AddCycles(num); }
bool cN2Prov0501::Algo ( int  algo,
const unsigned char *  hd,
unsigned char *  hw 
) [protected, virtual]

Reimplemented from cN2Prov.

Definition at line 80 of file nagra2-0501.c.

References cMapCore::DoMap(), cN2Prov::ExpandInput(), EXPORT_B, EXPORT_C, IMPORT_A, IMPORT_B, IMPORT_D, IMPORT_J, L_SYS_ECM, PRINTF, and SETSIZE.

{
  if(algo==0x60) {
    hw[0]=hd[0];
    hw[1]=hd[1];
    hw[2]=hd[2]&0xF8;
    ExpandInput(hw);
    hw[63]|=0x80;
    hw[95]=hw[127]=hw[95]&0x7F;
    DoMap(SETSIZE,0,4);
    DoMap(IMPORT_J,hw+0x18);
    DoMap(IMPORT_D,hw+0x20);
    DoMap(IMPORT_B,hw+0x60);
    DoMap(0x37,hw+0x40);
    DoMap(EXPORT_C,hw);
    DoMap(IMPORT_A,hw+0x60);
    DoMap(0x3a);
    DoMap(EXPORT_C,hw+0x20);
    DoMap(0x43);
    DoMap(0x44,hw);
    memcpy(hw,hw+64,20);
    hw[0]&=7;
    DoMap(EXPORT_B,hw+3);
    memset(hw+3+0x20,0,128-(3+0x20));
    return true;
    }

  PRINTF(L_SYS_ECM,"%04X: unknown MECM algo %02x",id,algo);
  return false;
}
virtual unsigned int cN2Prov0501::CpuCycles ( void  ) [inline, protected, virtual]

Reimplemented from cMapCore.

Definition at line 63 of file nagra2-0501.c.

References c6805::Cycles().

{ return Cycles(); }
virtual bool cN2Prov0501::NeedsCwSwap ( void  ) [inline, protected, virtual]

Reimplemented from cN2Prov.

Definition at line 59 of file nagra2-0501.c.

{ return true; }
virtual void cN2Prov0501::PostDecrypt ( bool  ecm) [inline, virtual]

Reimplemented from cN2Prov.

Definition at line 68 of file nagra2-0501.c.

References cMapCore::PostDecryptSetup().

{ PostDecryptSetup(ecm); }
int cN2Prov0501::ProcessBx ( unsigned char *  data,
int  len,
int  pos 
) [virtual]

Reimplemented from cN2Prov.

Definition at line 215 of file nagra2-0501.c.

References c6805::a, c6805::AddBreakpoint(), c6805::ClearBreakpoints(), c6805::GetMem(), c6805::GetPc(), cN2Emu::Init(), L_SYS_EMU, PRINTF, c6805::Run(), c6805::Set(), c6805::SetMem(), c6805::SetPc(), and c6805::SetSp().

{
  if(data[pos-1]!=0xBC) {
    PRINTF(L_SYS_EMU,"%04X: bad nano %02X for ROM 120",id,data[pos-1]);
    return -1;
    }
  if(pos!=(0x93-0x80)) { // maybe exploitable
    PRINTF(L_SYS_EMU,"%04X: refuse to execute from %04x",id,0x80+pos);
    return -1;
    }
  if(Init(id,120)) {
    SetMem(0x80,data,len);
    SetPc(0x80+pos);
    SetSp(0x0FFF,0x0FE0);
    Set(0x0001,0xFF);
    Set(0x000E,0xFF);
    Set(0x0000,0x04);
    ClearBreakpoints();
    AddBreakpoint(0x821f);
    AddBreakpoint(0x0000);
    AddRomCallbacks();
    while(!Run(hasMaprom ? 20000:5000)) {
      if(GetPc()==0x821f) {
        GetMem(0x80,data,len);
        return a;
        }
      else if(GetPc()==0x0000) break;
      else if(!RomCallbacks()) break;
      }
    }
  return -1;
}
bool cN2Prov0501::RomInit ( void  ) [protected, virtual]

Reimplemented from cN2Emu.

Definition at line 111 of file nagra2-0501.c.

References c6805::AddMapper(), HW_OFFSET, HW_REGS, L_SYS_EMU, and PRINTF.

{
  if(!AddMapper(hwMapper=new cMapMemHW(),HW_OFFSET,HW_REGS,0x00)) return false;
  if(   AddMapper(new cMapRom(0x3800,"Rom120_003800-003FFF.bin",0x00000),0x3800,0x0800,0x00)
     && AddMapper(new cMapRom(0x8000,"Rom120_408000-40CFFF.bin",0x00000),0x8000,0x5000,0x40)) {
    hasMaprom=true;
    PRINTF(L_SYS_EMU,"%04x: using native MAP rom",id);
    }
  return true;
}
int cN2Prov0501::RunEmu ( unsigned char *  data,
int  len,
unsigned short  load,
unsigned short  run,
unsigned short  stop,
unsigned short  fetch,
int  fetch_len 
) [virtual]

Reimplemented from cN2Prov.

Definition at line 248 of file nagra2-0501.c.

References c6805::AddBreakpoint(), c6805::ClearBreakpoints(), c6805::GetMem(), c6805::GetPc(), cN2Emu::Init(), c6805::Run(), c6805::SetMem(), c6805::SetPc(), and c6805::SetSp().

{
  if(Init(id,120)) {
    SetSp(0x0FFF,0x0EF8);
    SetMem(load,data,len);
    SetPc(run);
    ClearBreakpoints();
    AddBreakpoint(stop);
    if(stop!=0x0000) AddBreakpoint(0x0000);
    AddRomCallbacks();
    while(!Run(100000)) {
      if(GetPc()==0x0000 || GetPc()==stop) {
        GetMem(fetch,data,fetch_len);
        return 1;
        }
      else if(!RomCallbacks()) break;
      }
    }
  return -1;
}
void cN2Prov0501::TimerHandler ( unsigned int  num) [protected, virtual]

Reimplemented from c6805.

Definition at line 269 of file nagra2-0501.c.

References cMapMemHW::AddCycles().

{
  if(hwMapper) hwMapper->AddCycles(num);
}

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines