SASC-NG
DVBSoftCAM

cEmu Class Reference

Inheritance diagram for cEmu:

List of all members.

Public Member Functions

 cEmu (void)
virtual ~cEmu ()
bool Init (int RomNr, int Id)
bool GetOpKeys (const unsigned char *Emm, unsigned char *id, unsigned char *key0, unsigned char *key1)
bool GetPkKeys (const unsigned char *select, unsigned char *pkset)
bool Matches (int RomNr, int Id)

Protected Member Functions

bool AddRom (unsigned short addr, unsigned short size, const char *name)
bool AddEeprom (unsigned short addr, unsigned short size, unsigned short otpSize, const char *name)
virtual bool InitSetup (void)
virtual bool UpdateSetup (const unsigned char *emm)
virtual bool MathMapHandler (void)

Protected Attributes

int romNr
int id
char * romName
char * romExtName
char * eepromName
int InitStart
int InitEnd
int EmmStart
int EmmEnd
int EmmKey0
int EmmKey1
int FindKeyStart
int FindKeyEnd
int MapAddr
int Rc1H
int Rc1L
int EnsIrdChk
int Cmd83Chk
int SoftInt
int StackHigh

Detailed Description

Definition at line 40 of file nagra1.c.


Constructor & Destructor Documentation

cEmu::cEmu ( void  )

Definition at line 68 of file nagra1.c.

References eepromName, romExtName, and romName.

cEmu::~cEmu ( ) [virtual]

Definition at line 73 of file nagra1.c.

References eepromName, free, romExtName, and romName.


Member Function Documentation

bool cEmu::AddEeprom ( unsigned short  addr,
unsigned short  size,
unsigned short  otpSize,
const char *  name 
) [protected]

Definition at line 86 of file nagra1.c.

References c6805::AddMapper().

Referenced by cEmuRom10Core::DoMaps(), and cEmuRom3Core::DoMaps().

{
  cMap *map=new cMapEeprom(addr,name,otpSize);
  return AddMapper(map,addr,size);
}
bool cEmu::AddRom ( unsigned short  addr,
unsigned short  size,
const char *  name 
) [protected]

Definition at line 80 of file nagra1.c.

References c6805::AddMapper().

Referenced by cEmuRom10Core::DoMaps(), and cEmuRom3Core::DoMaps().

{
  cMap *map=new cMapRom(addr,name);
  return AddMapper(map,addr,size);
}
bool cEmu::GetOpKeys ( const unsigned char *  Emm,
unsigned char *  id,
unsigned char *  key0,
unsigned char *  key1 
)

Definition at line 120 of file nagra1.c.

References c6805::AddBreakpoint(), c6805::ClearBreakpoints(), EmmEnd, EmmKey0, EmmKey1, EmmStart, c6805::GetMem(), c6805::GetPc(), keys, MapAddr, MathMapHandler(), MAX_COUNT, c6805::PopPc(), c6805::Run(), c6805::SetMem(), c6805::SetPc(), and UpdateSetup().

Referenced by cTestNagra::Process(), and cSystemNagra::ProcessEMM().

{
  int keys=0;
  if(UpdateSetup(Emm)) {
    SetMem(0x0080,&Emm[0],64);
    SetMem(0x00F8,&Emm[1],2);
    SetPc(EmmStart);
    ClearBreakpoints();
    AddBreakpoint(EmmEnd);
    AddBreakpoint(MapAddr);
    AddBreakpoint(EmmKey0);
    AddBreakpoint(EmmKey1);
    while(!Run(MAX_COUNT)) {
      unsigned short pc=GetPc();
      if(pc==EmmKey0) {
        GetMem(0x82,key0,8);
        keys++;
        }
      if(pc==EmmKey1) {
        GetMem(0x82,key1,8);
        keys++;
        }
      if(pc==MapAddr) {
        if(!MathMapHandler()) break;
        PopPc(); // remove return address from stack
        }
      if(pc==EmmEnd) {
        GetMem(0x00F8,id,2);
        break;
        }
      }
    }
  return (keys==2);
}
bool cEmu::GetPkKeys ( const unsigned char *  select,
unsigned char *  pkset 
)

Definition at line 155 of file nagra1.c.

References c6805::AddBreakpoint(), c6805::CC::c, c6805::cc, c6805::ClearBreakpoints(), FindKeyEnd, FindKeyStart, c6805::Get(), c6805::GetMem(), c6805::GetPc(), i, L_SYS_EMU, MAX_COUNT, PRINTF, Rc1H, Rc1L, c6805::Run(), c6805::Set(), c6805::SetMem(), and c6805::SetPc().

Referenced by cTestNagra::Process(), and cSystemNagra::ProcessEMM().

{
  Set(0x0081,select[2]<<7);
  SetMem(0x00F8,select,3);
  SetPc(FindKeyStart);
  ClearBreakpoints();
  AddBreakpoint(FindKeyEnd);
  while(!Run(MAX_COUNT)) {
    unsigned short pc=GetPc();
    if(pc==FindKeyEnd) {
      if(!cc.c) {
        PRINTF(L_SYS_EMU,"Updating PK keys");
        unsigned short loc=(Get(Rc1H)<<8)+Get(Rc1L);
        for(int i=0; i<45; i+=15) GetMem(loc+4+i,pkset+i,15);
        return true;
        }
      else {
        PRINTF(L_SYS_EMU,"Updating PK keys failed. Used a correct EEPROM image for provider %04x ?",((select[0]<<8)|select[1]));
        break;
        }
      }
    }
  return false;
}
bool cEmu::Init ( int  RomNr,
int  Id 
)

Definition at line 97 of file nagra1.c.

References c6805::AddBreakpoint(), bprintf(), c6805::ClearBreakpoints(), Cmd83Chk, eepromName, EnsIrdChk, c6805::ForceSet(), InitEnd, InitSetup(), InitStart, MAX_COUNT, romExtName, romName, romNr, c6805::Run(), c6805::Set(), c6805::SetPc(), c6805::SetSp(), SoftInt, and StackHigh.

Referenced by cTestNagra::Process(), and cSystemNagra::ProcessEMM().

{
  romNr=RomNr; id=Id;
  romName=bprintf("ROM%d.bin",romNr);
  romExtName=bprintf("ROM%dext.bin",romNr);
  eepromName=bprintf("eep%i_%02x.bin",romNr,(id&0xff00)>>8);
  if(InitSetup()) {
    ForceSet(EnsIrdChk, 0x81,true);
    ForceSet(Cmd83Chk+0,0x98,true);
    ForceSet(Cmd83Chk+1,0x9d,true);
    if(SoftInt) {
      Set(0x1ffc,SoftInt>>8);
      Set(0x1ffd,SoftInt&0xff);
      }
    SetSp(StackHigh,0);
    SetPc(InitStart);
    ClearBreakpoints();
    AddBreakpoint(InitEnd);
    if(!Run(MAX_COUNT)) return true;
    }
  return false;
}
virtual bool cEmu::InitSetup ( void  ) [inline, protected, virtual]

Reimplemented in cEmuRom3, cEmuRom7, cEmuRom10, and cEmuRom11.

Definition at line 56 of file nagra1.c.

Referenced by Init().

{ return true; }
bool cEmu::Matches ( int  RomNr,
int  Id 
)

Definition at line 92 of file nagra1.c.

References romNr.

Referenced by cTestNagra::Process(), and cSystemNagra::ProcessEMM().

{
  return (romNr==RomNr && id==Id);
}
bool cEmu::MathMapHandler ( void  ) [protected, virtual]

Reimplemented in cEmuRom10.

Definition at line 180 of file nagra1.c.

References c6805::a, L_SYS_EMU, PRINTF, and romNr.

Referenced by GetOpKeys().

{
  PRINTF(L_SYS_EMU,"Unsupported math call $%02x in ROM %d, please report",a,romNr);
  return false;
}
virtual bool cEmu::UpdateSetup ( const unsigned char *  emm) [inline, protected, virtual]

Reimplemented in cEmuRom3, cEmuRom7, cEmuRom10, and cEmuRom11.

Definition at line 57 of file nagra1.c.

Referenced by GetOpKeys().

{ return true; }

Member Data Documentation

int cEmu::Cmd83Chk [protected]
char * cEmu::eepromName [protected]

Definition at line 43 of file nagra1.c.

Referenced by cEmu(), cEmuRom10Core::DoMaps(), cEmuRom3Core::DoMaps(), Init(), and ~cEmu().

int cEmu::id [protected]

Definition at line 42 of file nagra1.c.

int cEmu::InitEnd [protected]
char * cEmu::romExtName [protected]

Definition at line 43 of file nagra1.c.

Referenced by cEmu(), cEmuRom10Core::DoMaps(), cEmuRom3Core::DoMaps(), Init(), and ~cEmu().

char* cEmu::romName [protected]

Definition at line 43 of file nagra1.c.

Referenced by cEmu(), cEmuRom10Core::DoMaps(), cEmuRom3Core::DoMaps(), Init(), and ~cEmu().

int cEmu::romNr [protected]

Definition at line 42 of file nagra1.c.

Referenced by Init(), Matches(), and MathMapHandler().

int cEmu::SoftInt [protected]

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