Previous 199869 Revisions Next

r23740 Sunday 16th June, 2013 at 22:57:42 UTC by smf
removed read_key() from ide_mass_storage_device as it's only used by ataflash and that was also reading the key in manually (nw)
[src/emu/machine]ataflash.c ataflash.h idehd.c idehd.h
[src/mame/drivers]chihiro.c

trunk/src/mame/drivers/chihiro.c
r23739r23740
26642664
26652665   virtual int  read_sector(UINT32 lba, void *buffer);
26662666   virtual int  write_sector(UINT32 lba, const void *buffer);
2667   virtual void read_key(UINT8 key[]) { }
26682667protected:
26692668   // device-level overrides
26702669   virtual void device_start();
trunk/src/emu/machine/idehd.c
r23739r23740
14241424}
14251425
14261426//-------------------------------------------------
1427//  read device key
1428//-------------------------------------------------
1429
1430void ide_hdd_device::read_key(UINT8 key[])
1431{
1432   UINT32 metalength;
1433   m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, key, 5, metalength);
1434}
1435
1436//-------------------------------------------------
14371427//  machine_config_additions - device-specific
14381428//  machine configurations
14391429//-------------------------------------------------
trunk/src/emu/machine/idehd.h
r23739r23740
100100
101101   virtual int read_sector(UINT32 lba, void *buffer) = 0;
102102   virtual int write_sector(UINT32 lba, const void *buffer) = 0;
103   virtual void read_key(UINT8 key[]) = 0;
104103
105104   bool device_selected() { return m_csel == (m_device_head & IDE_DEVICE_HEAD_DRV) >> 4; }
106105   bool single_device() { return m_csel == 0 && m_dasp == 0; }
r23739r23740
180179   // optional information overrides
181180   virtual machine_config_constructor device_mconfig_additions() const;
182181
183   virtual void read_key(UINT8 key[]);
184
185182   chd_file       *m_handle;
186183   hard_disk_file *m_disk;
187184};
trunk/src/emu/machine/ataflash.c
r23739r23740
2323{
2424   ide_hdd_device::device_reset();
2525
26   m_locked = 0x1ff;
27   m_gnetreadlock = 1;
28
2926   UINT32 metalength;
27   memset(m_key, 0, sizeof(m_key));
3028   memset(m_cis, 0xff, 512);
3129
3230   if (m_handle != NULL)
31   {
3332      m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength);
33
34      if (m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength) == CHDERR_NONE)
35      {
36         m_locked = 0x1ff;
37         m_gnetreadlock = 1;
38      }
39   }
3440}
3541
3642READ16_MEMBER( ata_flash_pccard_device::read_memory )
r23739r23740
8995{
9096   if(offset >= 0x280 && offset <= 0x288 && m_handle != NULL)
9197   {
92      dynamic_buffer key(m_handle->hunk_bytes());
93      m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, key);
94
9598      UINT8 v = data;
9699      int pos = offset - 0x280;
97      UINT8 k = pos < key.count() ? key[pos] : 0;
100      UINT8 k = pos < sizeof(m_key) ? m_key[pos] : 0;
98101
99102      if(v == k)
100103      {
r23739r23740
119122
120123bool ata_flash_pccard_device::process_command()
121124{
122   UINT8 key[5];
123
124125   switch (m_command)
125126   {
126127   case IDE_COMMAND_TAITO_GNET_UNLOCK_1:
r23739r23740
145146      //LOGPRINT(("IDE GNET Unlock 3\n"));
146147
147148      /* key check */
148      read_key(key);
149      if (m_feature == key[0] && m_sector_count == key[1] && m_sector_number == key[2] && m_cylinder_low == key[3] && m_cylinder_high == key[4])
149      if (m_feature == m_key[0] && m_sector_count == m_key[1] && m_sector_number == m_key[2] && m_cylinder_low == m_key[3] && m_cylinder_high == m_key[4])
150150      {
151151         m_gnetreadlock = 0;
152152      }
r23739r23740
175175{
176176   if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2)
177177   {
178      UINT8 key[5] = { 0 };
179178      int i, bad = 0;
180      read_key(key);
181179
182180      for (i=0; !bad && i<512; i++)
183         bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != key[i-2]);
181         bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != m_key[i-2]);
184182
185183      if (bad)
186184      {
trunk/src/emu/machine/ataflash.h
r23739r23740
2929   virtual bool is_ready();
3030
3131private:
32   unsigned char m_cis[512];
32   UINT8 m_cis[512];
33   UINT8 m_key[5];
3334   UINT8 m_gnetreadlock;
3435   int m_locked;
3536};

Previous 199869 Revisions Next


© 1997-2024 The MAME Team