static unsigned hw_pal_io_read_buffer_callback(device *me, void *dest, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_pal_device *hw_pal = (hw_pal_device*)device_data(me); unsigned_1 val; switch (addr & hw_pal_address_mask) { case hw_pal_cpu_nr_register: val = cpu_nr(processor); DTRACE(pal, ("read - cpu-nr %d\n", val)); break; case hw_pal_nr_cpu_register: val = tree_find_integer_property(me, "/openprom/options/smp"); DTRACE(pal, ("read - nr-cpu %d\n", val)); break; case hw_pal_read_fifo: val = hw_pal->input.buffer; DTRACE(pal, ("read - input-fifo %d\n", val)); break; case hw_pal_read_status: scan_hw_pal(hw_pal); val = hw_pal->input.status; DTRACE(pal, ("read - input-status %d\n", val)); break; case hw_pal_write_fifo: val = hw_pal->output.buffer; DTRACE(pal, ("read - output-fifo %d\n", val)); break; case hw_pal_write_status: val = hw_pal->output.status; DTRACE(pal, ("read - output-status %d\n", val)); break; default: val = 0; DTRACE(pal, ("read - ???\n")); } memset(dest, 0, nr_bytes); *(unsigned_1*)dest = val; return nr_bytes; }
static unsigned hw_pal_io_read_buffer (struct hw *me, void *dest, int space, unsigned_word addr, unsigned nr_bytes) { hw_pal_device *hw_pal = (hw_pal_device *) hw_data (me); unsigned_1 *byte = (unsigned_1 *) dest; memset (dest, 0, nr_bytes); switch (addr & hw_pal_address_mask) { case hw_pal_cpu_nr_register: #ifdef CPU_INDEX *byte = CPU_INDEX (hw_system_cpu (me)); #else *byte = 0; #endif HW_TRACE ((me, "read - cpu-nr %d\n", *byte)); break; case hw_pal_nr_cpu_register: if (hw_tree_find_property (me, "/openprom/options/smp") == NULL) { *byte = 1; HW_TRACE ((me, "read - nr-cpu %d (not defined)\n", *byte)); } else { *byte = hw_tree_find_integer_property (me, "/openprom/options/smp"); HW_TRACE ((me, "read - nr-cpu %d\n", *byte)); } break; case hw_pal_read_fifo: *byte = hw_pal->input.buffer; HW_TRACE ((me, "read - input-fifo %d\n", *byte)); break; case hw_pal_read_status: scan_hw_pal (me); *byte = hw_pal->input.status; HW_TRACE ((me, "read - input-status %d\n", *byte)); break; case hw_pal_write_fifo: *byte = hw_pal->output.buffer; HW_TRACE ((me, "read - output-fifo %d\n", *byte)); break; case hw_pal_write_status: *byte = hw_pal->output.status; HW_TRACE ((me, "read - output-status %d\n", *byte)); break; case hw_pal_countdown: do_counter_read (me, hw_pal, "countdown", &hw_pal->countdown, dest, nr_bytes); break; case hw_pal_countdown_value: do_counter_value (me, hw_pal, "countdown-value", &hw_pal->countdown, dest, nr_bytes); break; case hw_pal_timer: do_counter_read (me, hw_pal, "timer", &hw_pal->timer, dest, nr_bytes); break; case hw_pal_timer_value: do_counter_value (me, hw_pal, "timer-value", &hw_pal->timer, dest, nr_bytes); break; default: HW_TRACE ((me, "read - ???\n")); break; } return nr_bytes; }