1 IMPLEMENTATION[ia32,amd64]:
7 #include "jdb_module.h"
11 #include "static_init.h"
14 * Private IA32-I/O module.
16 class Io_m : public Jdb_module
47 static Input_buffer buf;
50 static Io_m io_m INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
53 Io_m::Input_buffer Io_m::buf;
57 Jdb_module::Action_code
58 Io_m::action( int cmd, void *&args, char const *&fmt, int &)
60 static char const *const port_in_fmt = " addr=%8p";
61 static char const *const port_out_fmt = " addr=%8p, val=%8x";
62 static char const *const pci_in_fmt =
63 "\b\b\b\b\b\bPCI conf: bus=%2x, dev=%2x, subdev=%2x, reg=%2x";
64 static char const *const pci_out_fmt =
65 "\b\b\b\b\b\bPCI conf: bus=%2x, dev=%2x, subdev=%2x, reg=%2x, val=%8x";
66 static char const *const ack_irq_fmt = " ack IRQ=%2x";
67 static char const *const mask_irq_fmt = " mask IRQ=%2x";
68 static char const *const unmask_irq_fmt = " unmask IRQ=%2x";
70 unsigned answer = 0xffffffff;
81 case '4': fmt = port_in_fmt; return EXTRA_INPUT;
82 case 'p': fmt = pci_in_fmt; return EXTRA_INPUT;
84 puts(" - unknown port type (must be 1,2,4 or p)");
94 case '4': fmt = port_out_fmt; return EXTRA_INPUT;
95 case 'p': fmt = pci_out_fmt; return EXTRA_INPUT;
96 case 'a': fmt = ack_irq_fmt; return EXTRA_INPUT;
97 case 'm': fmt = mask_irq_fmt; return EXTRA_INPUT;
98 case 'u': fmt = unmask_irq_fmt; return EXTRA_INPUT;
100 puts(" - unknown port type (must be 1,2,4,p,a,m or u)");
109 case '1': // in/out 8bit
110 case '2': // in/out 16bit
111 case '4': // in/out 32bit
112 if (buf.io.adr == 0xffffffff)
121 if (buf.io.adr == Pic::MASTER_OCW)
122 printf("%02x (shadow of master-PIC register)\n",
123 Jdb::pic_status & 0x0ff);
124 else if (buf.io.adr == Pic::SLAVES_OCW)
125 printf("%02x (shadow of slave-PIC register)\n",
126 Jdb::pic_status >> 8);
129 answer = Io::in8(buf.io.adr);
130 printf("%02x\n", (int)answer);
135 if (buf.io.adr == Pic::MASTER_OCW)
138 (Jdb::pic_status & 0xff00) | buf.io.val;
139 putstr(" (PIC mask will be set on \"g\")");
141 else if (buf.io.adr == Pic::SLAVES_OCW)
144 (Jdb::pic_status & 0x00ff) | (buf.io.val<<8);
145 putstr(" (PIC mask will be set on \"g\")");
148 Io::out8(buf.io.val, buf.io.adr );
154 answer = Io::in16(buf.io.adr);
155 printf("%04x\n", answer);
158 Io::out16(buf.io.val, buf.io.adr);
163 answer = Io::in32(buf.io.adr);
164 printf("%08x\n", answer);
167 Io::out32(buf.io.val, buf.io.adr );
177 Pci::read_cfg(Pci::Cfg_addr(buf.pci.bus, buf.pci.dev, buf.pci.subdev,
178 buf.pci.reg), Pci::Cfg_width::Long));
180 Pci::write_cfg(Pci::Cfg_addr(buf.pci.bus, buf.pci.dev, buf.pci.subdev,
181 buf.pci.reg), (Unsigned32)buf.pci.val);
185 case 'a': // manual acknowledge IRQ at pic
187 Io::out8(0x60 + buf.irq.irq, Pic::MASTER_ICW);
190 Io::out8(0x60 + (buf.irq.irq & 7), Pic::SLAVES_ICW);
191 Io::out8(0x60 + 2, Pic::MASTER_ICW);
196 case 'm': // manual mask IRQ
197 Jdb::pic_status |= (1 << buf.irq.irq);
198 puts(" (PIC mask will be set on \"g\")");
201 case 'u': // manual unmask IRQ
202 Jdb::pic_status &= ~(Unsigned16)(1 << buf.irq.irq);
203 puts(" (PIC mask will be set on \"g\")");
211 int Io_m::num_cmds() const
217 Jdb_module::Cmd const * Io_m::cmds() const
221 { 0, "i", "in", " type:%c",
222 "i{1|2|4|p}<num>\tin port",
224 { 1, "o", "out", " type:%c",
225 "o{1|2|4|a|u|m}<num>\tout port, ack/(un)mask/ack irq",