OpenCores
URL https://opencores.org/ocsvn/zet86/zet86/trunk

Subversion Repositories zet86

[/] [zet86/] [trunk/] [src/] [bochs-diff-2.3.7/] [iodev/] [hdemu.cc] - Blame information for rev 52

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 zeus
// Define BX_PLUGGABLE in files that can be compiled into plugins.  For
2
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
3
// is used to know when we are exporting symbols and when we are importing.
4
#define BX_PLUGGABLE
5
 
6
#include "iodev.h"
7
#define LOG_THIS theHdemuDevice->
8
 
9
bx_hdemu_c *theHdemuDevice = NULL;
10
 
11
int libhdemu_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
12
{
13
  theHdemuDevice = new bx_hdemu_c();
14
  bx_devices.pluginHdemuDevice = theHdemuDevice;
15
  BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theHdemuDevice, "hdemu");
16
  return(0); // Success
17
}
18
 
19
void libhdemu_LTX_plugin_fini(void)
20
{
21
  delete theHdemuDevice;
22
}
23
 
24
bx_hdemu_c::bx_hdemu_c()
25
{
26
  put("HDEMU");
27
  settype(HDEMULOG);
28
  input = NULL;
29
}
30
 
31
bx_hdemu_c::~bx_hdemu_c()
32
{
33
  if (input != NULL) fclose(input);
34
  BX_DEBUG(("Exit"));
35
}
36
 
37
void bx_hdemu_c::init(void)
38
{
39
  char name[16];
40
 
41 52 zeus
  BX_DEBUG(("Init $Id: hdemu.cc,v 1.34 2008/01/26 22:24:02 sshwarts Exp $"));
42 39 zeus
 
43
  sprintf(name, "Hd emu");
44
  /* hdemu i/o ports */
45
  DEV_register_ioread_handler_range(this, read_handler, 0xe000, 0xe1fe, name, 2);
46
  DEV_register_iowrite_handler(this, write_handler, 0xe000, name, 2);
47
 
48
  /* internal state */
49
  BX_HDEMU_THIS base = 0x0;
50
 
51
  /* input file */
52
  input = fopen("hd.img", "rb");
53
    if (!input)
54
      BX_PANIC(("Could not open 'hd.img' to read hard disk contents"));
55
}
56
 
57
void bx_hdemu_c::reset(unsigned type)
58
{
59
}
60
 
61
void bx_hdemu_c::register_state(void)
62
{
63
  unsigned i;
64
  char name[4], pname[20];
65
  bx_list_c *base, *port;
66
 
67
  bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "hdemu", "Hard disk emulator", 1);
68
 
69
  sprintf(name, "0", i);
70
  port = new bx_list_c(list, name, 1);
71
  new bx_shadow_num_c(port, "base", &BX_HDEMU_THIS base, BASE_HEX);
72
}
73
 
74
// static IO port read callback handler
75
// redirects to non-static class handler to avoid virtual functions
76
 
77
Bit32u bx_hdemu_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
78
{
79
#if !BX_USE_PAR_SMF
80
  bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
81
  return class_ptr->read(address, io_len);
82
}
83
 
84
Bit32u bx_hdemu_c::read(Bit32u address, unsigned io_len)
85
{
86
#else
87
  UNUSED(this_ptr);
88
#endif  // !BX_USE_PAR_SMF
89
 
90
  Bit16u retval;
91
  size_t result;
92
  address = address & 0x01ff;
93
 
94
  fseek (BX_HDEMU_THIS input, address+(BX_HDEMU_THIS base)*512, SEEK_SET );
95
  result = fread (&retval, 2, 1, BX_HDEMU_THIS input);
96
 
97
  return(retval);
98
}
99
 
100
// static IO port write callback handler
101
// redirects to non-static class handler to avoid virtual functions
102
 
103
void bx_hdemu_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
104
{
105
#if !BX_USE_PAR_SMF
106
  bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
107
 
108
  class_ptr->write(address, value, io_len);
109
}
110
 
111
void bx_hdemu_c::write(Bit32u address, Bit32u value, unsigned io_len)
112
{
113
#else
114
  UNUSED(this_ptr);
115
#endif  // !BX_USE_PAR_SMF
116
 
117
  BX_HDEMU_THIS base = value;
118
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.