diff --git a/src/pcmcia.c b/src/pcmcia.c index 4d55a5c369..5f2bc62ffd 100644 --- a/src/pcmcia.c +++ b/src/pcmcia.c @@ -11,25 +11,29 @@ #include <86box/timer.h> #include <86box/pcmcia.h> -static pcmcia_socket_t* pcmcia_sockets[4]; -static uint8_t pcmcia_registered_sockets_num = 0; +static pcmcia_socket_t *pcmcia_sockets[4]; +static uint8_t pcmcia_registered_sockets_num = 0; -void pcmcia_reset(void) +void +pcmcia_reset(void) { pcmcia_registered_sockets_num = 0; } -void pcmcia_register_socket(pcmcia_socket_t *socket) +void +pcmcia_register_socket(pcmcia_socket_t *socket) { pcmcia_sockets[pcmcia_registered_sockets_num++] = socket; } -bool pcmcia_socket_is_free(pcmcia_socket_t *socket) +bool +pcmcia_socket_is_free(pcmcia_socket_t *socket) { return !socket->card_priv; } -pcmcia_socket_t* pcmcia_search_for_slots(void) +pcmcia_socket_t * +pcmcia_search_for_slots(void) { for (int i = 0; i < pcmcia_registered_sockets_num; i++) { if (pcmcia_sockets[i] && !pcmcia_sockets[i]->card_priv) @@ -38,7 +42,8 @@ pcmcia_socket_t* pcmcia_search_for_slots(void) return NULL; } -void pcmcia_socket_insert_card(pcmcia_socket_t* socket) +void +pcmcia_socket_insert_card(pcmcia_socket_t *socket) { if (!socket->card_inserted) fatal("No PCMCIA socket insertion function!\n"); @@ -46,4 +51,3 @@ void pcmcia_socket_insert_card(pcmcia_socket_t* socket) socket->card_priv = socket->card_priv; socket->card_inserted(true, socket); } - diff --git a/src/pcmcia/pcmcia_socket_pd6710.c b/src/pcmcia/pcmcia_socket_pd6710.c index c1580edbc9..b13e8f15c2 100644 --- a/src/pcmcia/pcmcia_socket_pd6710.c +++ b/src/pcmcia/pcmcia_socket_pd6710.c @@ -21,41 +21,35 @@ struct pcmcia_socket_pd67xx; /* We will make the mappings use it as a pointer to avoid cluttering up code. */ -typedef struct pd67xx_memory_map -{ - struct pcmcia_socket_pd67xx* main_ptr; - uint8_t map_num; - mem_mapping_t mapping; - union - { +typedef struct pd67xx_memory_map { + struct pcmcia_socket_pd67xx *main_ptr; + uint8_t map_num; + mem_mapping_t mapping; + union { uint16_t addr; - uint8_t addr_b[2]; + uint8_t addr_b[2]; } start __attribute__((packed)); - union - { + union { uint16_t addr; - uint8_t addr_b[2]; + uint8_t addr_b[2]; } end __attribute__((packed)); - union - { + union { uint16_t addr; - uint8_t addr_b[2]; + uint8_t addr_b[2]; } offset __attribute__((packed)); } pd67xx_memory_map; -typedef struct pcmcia_socket_pd67xx -{ +typedef struct pcmcia_socket_pd67xx { uint8_t index; - union - { + union { uint8_t interface_status; struct { - uint8_t bvd : 2; - uint8_t cd : 2; - uint8_t wp : 1; - uint8_t ready : 1; - uint8_t power_on : 1; + uint8_t bvd : 2; + uint8_t cd : 2; + uint8_t wp : 1; + uint8_t ready : 1; + uint8_t power_on : 1; uint8_t vpp_valid : 1; }; }; @@ -70,27 +64,28 @@ typedef struct pcmcia_socket_pd67xx uint8_t misc_control_2; uint8_t fifo_control; - io_range_t* ranges[2]; - uint16_t io_offsets[2]; + io_range_t *ranges[2]; + uint16_t io_offsets[2]; pd67xx_memory_map mem_maps[5]; uint8_t regs[0x40]; /* Only used for ignored registers. */ - bool inserted; - bool status; - bool read_seq; + bool inserted; + bool status; + bool read_seq; uint8_t irq_state, mgmt_irq_state; pcmcia_socket_t socket; } pcmcia_socket_pd67xx; -void pd67xx_mem_recalc(pd67xx_memory_map* mem_map) +void +pd67xx_mem_recalc(pd67xx_memory_map *mem_map) { mem_mapping_disable(&mem_map->mapping); if (mem_map->main_ptr->mapping_enable & (1 << mem_map->map_num)) { uint32_t start = (mem_map->start.addr & 0x3fff) << 12; - uint32_t end = (mem_map->end.addr & 0x3fff) << 12; + uint32_t end = (mem_map->end.addr & 0x3fff) << 12; if (start < (16 << 12)) { start = (16 << 12); @@ -98,12 +93,13 @@ void pd67xx_mem_recalc(pd67xx_memory_map* mem_map) if (end < start) return; - + mem_mapping_set_addr(&mem_map->mapping, start, (end - start) + 4096); } } -void pd67xx_mem_recalc_all(pcmcia_socket_pd67xx* pd67xx) +void +pd67xx_mem_recalc_all(pcmcia_socket_pd67xx *pd67xx) { int i = 0; @@ -112,7 +108,8 @@ void pd67xx_mem_recalc_all(pcmcia_socket_pd67xx* pd67xx) } } -void pd67xx_mgmt_interrupt(pcmcia_socket_pd67xx* pd67xx, int set) +void +pd67xx_mgmt_interrupt(pcmcia_socket_pd67xx *pd67xx, int set) { bool level = !!(pd67xx->misc_control_1 & (1 << 3)); if ((pd67xx->interrupt_general_control & (1 << 4)) && set) { @@ -132,10 +129,11 @@ void pd67xx_mgmt_interrupt(pcmcia_socket_pd67xx* pd67xx, int set) picint(1 << (pd67xx->management_interrupt_conf >> 4)); } -void pd67xx_card_interrupt(bool set, pcmcia_socket_t* socket) +void +pd67xx_card_interrupt(bool set, pcmcia_socket_t *socket) { - pcmcia_socket_pd67xx* pd67xx = socket->socket_priv; - bool level = !!(pd67xx->misc_control_1 & (1 << 3)); + pcmcia_socket_pd67xx *pd67xx = socket->socket_priv; + bool level = !!(pd67xx->misc_control_1 & (1 << 3)); if (set && !!(pd67xx->interrupt_general_control & 0xF)) { if (level) picintlevel(1 << (pd67xx->interrupt_general_control), &pd67xx->irq_state); @@ -145,17 +143,18 @@ void pd67xx_card_interrupt(bool set, pcmcia_socket_t* socket) picintclevel(1 << (pd67xx->interrupt_general_control), &pd67xx->irq_state); } -void pd67xx_card_inserted(bool inserted, pcmcia_socket_t* socket) +void +pd67xx_card_inserted(bool inserted, pcmcia_socket_t *socket) { - pcmcia_socket_pd67xx* pd67xx = socket->socket_priv; - bool signal_change = false; + pcmcia_socket_pd67xx *pd67xx = socket->socket_priv; + bool signal_change = false; if (pd67xx->inserted ^ inserted) { signal_change = true; } pd67xx->inserted = inserted; - pd67xx->cd = inserted ? 0b11 : 0b00; + pd67xx->cd = inserted ? 0b11 : 0b00; if (signal_change && (pd67xx->management_interrupt_conf & 8)) { pd67xx->card_status |= 0x8; @@ -163,10 +162,11 @@ void pd67xx_card_inserted(bool inserted, pcmcia_socket_t* socket) } } -void pd67xx_status_changed(bool status, pcmcia_socket_t* socket) +void +pd67xx_status_changed(bool status, pcmcia_socket_t *socket) { - pcmcia_socket_pd67xx* pd67xx = socket->socket_priv; - bool signal_change = false; + pcmcia_socket_pd67xx *pd67xx = socket->socket_priv; + bool signal_change = false; if (pd67xx->status ^ status) { signal_change = true; @@ -182,10 +182,11 @@ void pd67xx_status_changed(bool status, pcmcia_socket_t* socket) } } -void pd67xx_ready_changed(bool status, pcmcia_socket_t* socket) +void +pd67xx_ready_changed(bool status, pcmcia_socket_t *socket) { - pcmcia_socket_pd67xx* pd67xx = socket->socket_priv; - bool signal_change = false; + pcmcia_socket_pd67xx *pd67xx = socket->socket_priv; + bool signal_change = false; if (pd67xx->interrupt_general_control & (1 << 5)) { pd67xx_card_interrupt(!status, socket); @@ -204,10 +205,11 @@ void pd67xx_ready_changed(bool status, pcmcia_socket_t* socket) } } -uint8_t pd67xx_mem_read(uint32_t addr, void* priv) +uint8_t +pd67xx_mem_read(uint32_t addr, void *priv) { - pd67xx_memory_map* pd67xx_mem_map = (pd67xx_memory_map*)priv; - pcmcia_socket_pd67xx* pd67xx = pd67xx_mem_map->main_ptr; + pd67xx_memory_map *pd67xx_mem_map = (pd67xx_memory_map *) priv; + pcmcia_socket_pd67xx *pd67xx = pd67xx_mem_map->main_ptr; if (!pd67xx->socket.card_priv) return 0xFF; @@ -225,10 +227,11 @@ uint8_t pd67xx_mem_read(uint32_t addr, void* priv) return pd67xx->socket.mem_read(addr, !(pd67xx_mem_map->offset.addr & (1 << 14)), pd67xx->socket.card_priv); } -void pd67xx_mem_write(uint32_t addr, uint8_t val, void* priv) +void +pd67xx_mem_write(uint32_t addr, uint8_t val, void *priv) { - pd67xx_memory_map* pd67xx_mem_map = (pd67xx_memory_map*)priv; - pcmcia_socket_pd67xx* pd67xx = pd67xx_mem_map->main_ptr; + pd67xx_memory_map *pd67xx_mem_map = (pd67xx_memory_map *) priv; + pcmcia_socket_pd67xx *pd67xx = pd67xx_mem_map->main_ptr; if (!pd67xx->socket.card_priv) return; @@ -249,10 +252,11 @@ void pd67xx_mem_write(uint32_t addr, uint8_t val, void* priv) return pd67xx->socket.mem_write(addr, val, !(pd67xx_mem_map->offset.addr & (1 << 14)), pd67xx->socket.card_priv); } -uint16_t pd67xx_mem_readw(uint32_t addr, void* priv) +uint16_t +pd67xx_mem_readw(uint32_t addr, void *priv) { - pd67xx_memory_map* pd67xx_mem_map = (pd67xx_memory_map*)priv; - pcmcia_socket_pd67xx* pd67xx = pd67xx_mem_map->main_ptr; + pd67xx_memory_map *pd67xx_mem_map = (pd67xx_memory_map *) priv; + pcmcia_socket_pd67xx *pd67xx = pd67xx_mem_map->main_ptr; if (!pd67xx->socket.card_priv) return 0xFF; @@ -270,10 +274,11 @@ uint16_t pd67xx_mem_readw(uint32_t addr, void* priv) return pd67xx->socket.mem_readw(addr, !(pd67xx_mem_map->offset.addr & (1 << 14)), pd67xx->socket.card_priv); } -void pd67xx_mem_writew(uint32_t addr, uint16_t val, void* priv) +void +pd67xx_mem_writew(uint32_t addr, uint16_t val, void *priv) { - pd67xx_memory_map* pd67xx_mem_map = (pd67xx_memory_map*)priv; - pcmcia_socket_pd67xx* pd67xx = pd67xx_mem_map->main_ptr; + pd67xx_memory_map *pd67xx_mem_map = (pd67xx_memory_map *) priv; + pcmcia_socket_pd67xx *pd67xx = pd67xx_mem_map->main_ptr; if (!pd67xx->socket.card_priv) return; @@ -294,16 +299,17 @@ void pd67xx_mem_writew(uint32_t addr, uint16_t val, void* priv) return pd67xx->socket.mem_writew(addr, val, !(pd67xx_mem_map->offset.addr & (1 << 14)), pd67xx->socket.card_priv); } -uint8_t pd67xx_io_read_1(uint16_t port, void* priv) +uint8_t +pd67xx_io_read_1(uint16_t port, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return 0xFF; if (!pd67xx->socket.io_read) return 0xFF; - + if (!(pd67xx->power_control & (1 << 7))) { /* No outputs enabled. */ return 0xFF; @@ -313,9 +319,10 @@ uint8_t pd67xx_io_read_1(uint16_t port, void* priv) return pd67xx->socket.io_read(port, pd67xx->socket.card_priv); } -uint16_t pd67xx_io_readw_1(uint16_t port, void* priv) +uint16_t +pd67xx_io_readw_1(uint16_t port, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return 0xFF; @@ -332,9 +339,10 @@ uint16_t pd67xx_io_readw_1(uint16_t port, void* priv) return pd67xx->socket.io_readw(port, pd67xx->socket.card_priv); } -void pd67xx_io_write_1(uint16_t port, uint8_t val, void* priv) +void +pd67xx_io_write_1(uint16_t port, uint8_t val, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return; @@ -351,9 +359,10 @@ void pd67xx_io_write_1(uint16_t port, uint8_t val, void* priv) return pd67xx->socket.io_write(port, val, pd67xx->socket.card_priv); } -void pd67xx_io_writew_1(uint16_t port, uint16_t val, void* priv) +void +pd67xx_io_writew_1(uint16_t port, uint16_t val, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return; @@ -370,9 +379,10 @@ void pd67xx_io_writew_1(uint16_t port, uint16_t val, void* priv) return pd67xx->socket.io_write(port, val, pd67xx->socket.card_priv); } -uint8_t pd67xx_io_read_2(uint16_t port, void* priv) +uint8_t +pd67xx_io_read_2(uint16_t port, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return 0xFF; @@ -389,9 +399,10 @@ uint8_t pd67xx_io_read_2(uint16_t port, void* priv) return pd67xx->socket.io_read(port, pd67xx->socket.card_priv); } -uint16_t pd67xx_io_readw_2(uint16_t port, void* priv) +uint16_t +pd67xx_io_readw_2(uint16_t port, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return 0xFF; @@ -408,9 +419,10 @@ uint16_t pd67xx_io_readw_2(uint16_t port, void* priv) return pd67xx->socket.io_readw(port, pd67xx->socket.card_priv); } -void pd67xx_io_write_2(uint16_t port, uint8_t val, void* priv) +void +pd67xx_io_write_2(uint16_t port, uint8_t val, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return; @@ -427,9 +439,10 @@ void pd67xx_io_write_2(uint16_t port, uint8_t val, void* priv) return pd67xx->socket.io_write(port, val, pd67xx->socket.card_priv); } -void pd67xx_io_writew_2(uint16_t port, uint16_t val, void* priv) +void +pd67xx_io_writew_2(uint16_t port, uint16_t val, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!pd67xx->socket.card_priv) return; @@ -446,163 +459,169 @@ void pd67xx_io_writew_2(uint16_t port, uint16_t val, void* priv) return pd67xx->socket.io_write(port, val, pd67xx->socket.card_priv); } -void pd67xx_port_write(uint16_t port, uint8_t val, void* priv) +void +pd67xx_port_write(uint16_t port, uint8_t val, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!(port & 1)) pd67xx->index = val; else { switch (pd67xx->index) { case 0x02: - { - pd67xx->power_control = val; - break; - } + { + pd67xx->power_control = val; + break; + } case 0x03: - { - bool reset = !(val & (1 << 6)) && (pd67xx->interrupt_general_control & (1 << 6)); - pd67xx->interrupt_general_control = val; - if ((pd67xx->power_control & (1 << 7)) && reset) { - pd67xx->socket.reset(pd67xx->socket.card_priv); + { + bool reset = !(val & (1 << 6)) && (pd67xx->interrupt_general_control & (1 << 6)); + pd67xx->interrupt_general_control = val; + if ((pd67xx->power_control & (1 << 7)) && reset) { + pd67xx->socket.reset(pd67xx->socket.card_priv); + } + break; } - break; - } case 0x05: - { - pd67xx->management_interrupt_conf = val; - break; - } + { + pd67xx->management_interrupt_conf = val; + break; + } case 0x06: - { - pd67xx->mapping_enable = val; - pd67xx_mem_recalc_all(pd67xx); - pd67xx->ranges[0]->enable = !!(val & (1 << 6)); - pd67xx->ranges[1]->enable = !!(val & (1 << 7)); - break; - } + { + pd67xx->mapping_enable = val; + pd67xx_mem_recalc_all(pd67xx); + pd67xx->ranges[0]->enable = !!(val & (1 << 6)); + pd67xx->ranges[1]->enable = !!(val & (1 << 7)); + break; + } case 0x07: - { - pd67xx->io_window_control = val; - break; - } + { + pd67xx->io_window_control = val; + break; + } case 0x08: - { - pd67xx->ranges[0]->start = (pd67xx->ranges[0]->start & 0xFF00) | val; - break; - } + { + pd67xx->ranges[0]->start = (pd67xx->ranges[0]->start & 0xFF00) | val; + break; + } case 0x09: - { - pd67xx->ranges[0]->start = (pd67xx->ranges[0]->start & 0xFF) | (val << 8); - break; - } + { + pd67xx->ranges[0]->start = (pd67xx->ranges[0]->start & 0xFF) | (val << 8); + break; + } case 0x0a: - { - pd67xx->ranges[0]->end = (pd67xx->ranges[0]->start & 0xFF00) | val; - break; - } + { + pd67xx->ranges[0]->end = (pd67xx->ranges[0]->start & 0xFF00) | val; + break; + } case 0x0b: - { - pd67xx->ranges[0]->end = (pd67xx->ranges[0]->start & 0xFF) | (val << 8); - break; - } + { + pd67xx->ranges[0]->end = (pd67xx->ranges[0]->start & 0xFF) | (val << 8); + break; + } case 0x0c: - { - pd67xx->ranges[1]->start = (pd67xx->ranges[1]->start & 0xFF00) | val; - break; - } + { + pd67xx->ranges[1]->start = (pd67xx->ranges[1]->start & 0xFF00) | val; + break; + } case 0x0d: - { - pd67xx->ranges[1]->start = (pd67xx->ranges[1]->start & 0xFF) | (val << 8); - break; - } + { + pd67xx->ranges[1]->start = (pd67xx->ranges[1]->start & 0xFF) | (val << 8); + break; + } case 0x0e: - { - pd67xx->ranges[1]->end = (pd67xx->ranges[1]->start & 0xFF00) | val; - break; - } + { + pd67xx->ranges[1]->end = (pd67xx->ranges[1]->start & 0xFF00) | val; + break; + } case 0x0f: - { - pd67xx->ranges[1]->end = (pd67xx->ranges[1]->start & 0xFF) | (val << 8); - break; - } + { + pd67xx->ranges[1]->end = (pd67xx->ranges[1]->start & 0xFF) | (val << 8); + break; + } case 0x10 ... 0x15: case 0x18 ... 0x1D: case 0x20 ... 0x25: case 0x28 ... 0x2D: case 0x30 ... 0x35: - { - uint8_t mem_map_num = ((pd67xx->index - 0x10) >> 3); - pd67xx_memory_map *mem_map = &pd67xx->mem_maps[mem_map_num]; - - switch (pd67xx->index & 0xF) { - case 0: { - mem_map->start.addr_b[0] = val; - break; - } - case 1: { - mem_map->start.addr_b[1] = val; - break; - } - case 2: { - mem_map->end.addr_b[0] = val; - break; - } - case 3: { - mem_map->end.addr_b[1] = val; - break; - } - case 4: { - mem_map->offset.addr_b[0] = val; - break; - } - case 5: { - mem_map->offset.addr_b[1] = val; - break; + { + uint8_t mem_map_num = ((pd67xx->index - 0x10) >> 3); + pd67xx_memory_map *mem_map = &pd67xx->mem_maps[mem_map_num]; + + switch (pd67xx->index & 0xF) { + case 0: + { + mem_map->start.addr_b[0] = val; + break; + } + case 1: + { + mem_map->start.addr_b[1] = val; + break; + } + case 2: + { + mem_map->end.addr_b[0] = val; + break; + } + case 3: + { + mem_map->end.addr_b[1] = val; + break; + } + case 4: + { + mem_map->offset.addr_b[0] = val; + break; + } + case 5: + { + mem_map->offset.addr_b[1] = val; + break; + } } + pd67xx_mem_recalc(mem_map); + break; } - pd67xx_mem_recalc(mem_map); - break; - } - case 0x36: - { - pd67xx->io_offsets[0] = (pd67xx->io_offsets[0] & 0xFF00) | val; - break; - } + { + pd67xx->io_offsets[0] = (pd67xx->io_offsets[0] & 0xFF00) | val; + break; + } case 0x37: - { - pd67xx->io_offsets[0] = (pd67xx->io_offsets[0] & 0xFF) | (val << 8); - break; - } + { + pd67xx->io_offsets[0] = (pd67xx->io_offsets[0] & 0xFF) | (val << 8); + break; + } case 0x38: - { - pd67xx->io_offsets[1] = (pd67xx->io_offsets[1] & 0xFF00) | val; - break; - } + { + pd67xx->io_offsets[1] = (pd67xx->io_offsets[1] & 0xFF00) | val; + break; + } case 0x39: - { - pd67xx->io_offsets[1] = (pd67xx->io_offsets[1] & 0xFF) | (val << 8); - break; - } + { + pd67xx->io_offsets[1] = (pd67xx->io_offsets[1] & 0xFF) | (val << 8); + break; + } case 0x3A ... 0x3F: /* Timing registers. */ - case 0x27: /* Scratchpad */ + case 0x27: /* Scratchpad */ pd67xx->regs[pd67xx->index] = val; break; - + case 0x16: pd67xx->misc_control_1 = val; break; - + case 0x17: pd67xx->fifo_control = val & 0x7f; break; - + case 0x1E: pd67xx->misc_control_2 = val & ~(1 << 6); /* Bit 6 is reserved. */ break; - + case 0x1F: pd67xx->read_seq = 0; break; @@ -610,9 +629,10 @@ void pd67xx_port_write(uint16_t port, uint8_t val, void* priv) } } -uint8_t pd67xx_port_read(uint16_t port, void* priv) +uint8_t +pd67xx_port_read(uint16_t port, void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; + pcmcia_socket_pd67xx *pd67xx = priv; if (!(port & 1)) return pd67xx->index; @@ -628,7 +648,7 @@ uint8_t pd67xx_port_read(uint16_t port, void* priv) return pd67xx->interrupt_general_control; case 0x04: { - uint8_t ret = pd67xx->card_status; + uint8_t ret = pd67xx->card_status; pd67xx->card_status = 0; pd67xx_mgmt_interrupt(pd67xx, 0); return ret; @@ -638,74 +658,80 @@ uint8_t pd67xx_port_read(uint16_t port, void* priv) case 0x06: return pd67xx->mapping_enable; case 0x07: - { - return pd67xx->io_window_control; - } + { + return pd67xx->io_window_control; + } case 0x08: - { - return pd67xx->ranges[0]->start & 0xFF; - } + { + return pd67xx->ranges[0]->start & 0xFF; + } case 0x09: - { - return (pd67xx->ranges[0]->start >> 8) & 0xFF; - } + { + return (pd67xx->ranges[0]->start >> 8) & 0xFF; + } case 0x0a: - { - return pd67xx->ranges[0]->end & 0xFF; - } + { + return pd67xx->ranges[0]->end & 0xFF; + } case 0x0b: - { - return (pd67xx->ranges[0]->end >> 8) & 0xFF; - } + { + return (pd67xx->ranges[0]->end >> 8) & 0xFF; + } case 0x0c: - { - return pd67xx->ranges[1]->start & 0xFF; - } + { + return pd67xx->ranges[1]->start & 0xFF; + } case 0x0d: - { - return (pd67xx->ranges[1]->start >> 8) & 0xFF; - } + { + return (pd67xx->ranges[1]->start >> 8) & 0xFF; + } case 0x0e: - { - return pd67xx->ranges[1]->end & 0xFF; - } + { + return pd67xx->ranges[1]->end & 0xFF; + } case 0x0f: - { - return (pd67xx->ranges[1]->end >> 8) & 0xFF; - } - + { + return (pd67xx->ranges[1]->end >> 8) & 0xFF; + } + case 0x10 ... 0x15: case 0x18 ... 0x1D: case 0x20 ... 0x25: case 0x28 ... 0x2D: case 0x30 ... 0x35: - { - uint8_t mem_map_num = ((pd67xx->index - 0x10) >> 3); - pd67xx_memory_map *mem_map = &pd67xx->mem_maps[mem_map_num]; - - switch (pd67xx->index & 0xF) { - case 0: { - return mem_map->start.addr_b[0]; - } - case 1: { - return mem_map->start.addr_b[1]; - } - case 2: { - return mem_map->end.addr_b[0]; - } - case 3: { - return mem_map->end.addr_b[1]; - } - case 4: { - return mem_map->offset.addr_b[0]; - } - case 5: { - return mem_map->offset.addr_b[1]; + { + uint8_t mem_map_num = ((pd67xx->index - 0x10) >> 3); + pd67xx_memory_map *mem_map = &pd67xx->mem_maps[mem_map_num]; + + switch (pd67xx->index & 0xF) { + case 0: + { + return mem_map->start.addr_b[0]; + } + case 1: + { + return mem_map->start.addr_b[1]; + } + case 2: + { + return mem_map->end.addr_b[0]; + } + case 3: + { + return mem_map->end.addr_b[1]; + } + case 4: + { + return mem_map->offset.addr_b[0]; + } + case 5: + { + return mem_map->offset.addr_b[1]; + } } + break; } - break; - } - + case 0x36: case 0x37: return (pd67xx->io_offsets[0] >> (8 * (pd67xx->index & 1))) & 0xFF; @@ -721,7 +747,7 @@ uint8_t pd67xx_port_read(uint16_t port, void* priv) /* All cards are 5 volts for now. */ case 0x16: return pd67xx->misc_control_1 | 1; - + case 0x17: return pd67xx->fifo_control; @@ -744,10 +770,11 @@ uint8_t pd67xx_port_read(uint16_t port, void* priv) return 0xFF; } -void pd67xx_reset(void *priv) +void +pd67xx_reset(void *priv) { - pcmcia_socket_pd67xx* pd67xx = priv; - int i = 0; + pcmcia_socket_pd67xx *pd67xx = priv; + int i = 0; pd67xx_card_interrupt(false, &pd67xx->socket); pd67xx_mgmt_interrupt(pd67xx, false); @@ -755,52 +782,53 @@ void pd67xx_reset(void *priv) pd67xx->mapping_enable = 0; for (i = 0; i < 5; i++) { pd67xx->mem_maps[i].start.addr = pd67xx->mem_maps[i].end.addr = pd67xx->mem_maps[i].offset.addr = 0; - pd67xx->mem_maps[i].map_num = i; + pd67xx->mem_maps[i].map_num = i; } pd67xx_mem_recalc_all(pd67xx); - pd67xx->power_control = 0; - pd67xx->misc_control_1 = 0; - pd67xx->misc_control_2 = 0; - pd67xx->fifo_control = 0; + pd67xx->power_control = 0; + pd67xx->misc_control_1 = 0; + pd67xx->misc_control_2 = 0; + pd67xx->fifo_control = 0; pd67xx->interrupt_general_control = 0; pd67xx->management_interrupt_conf = 0; - pd67xx->io_window_control = 0; - pd67xx->power_control = 0; + pd67xx->io_window_control = 0; + pd67xx->power_control = 0; memset(pd67xx->regs, 0, sizeof(pd67xx->regs)); pd67xx->io_offsets[0] = pd67xx->io_offsets[1] = 0x0000; - pd67xx->ranges[0]->enable = 0; - pd67xx->ranges[1]->enable = 0; - pd67xx->ranges[0]->start = 0; - pd67xx->ranges[0]->end = 0; - pd67xx->ranges[1]->start = 0; - pd67xx->ranges[1]->end = 0; + pd67xx->ranges[0]->enable = 0; + pd67xx->ranges[1]->enable = 0; + pd67xx->ranges[0]->start = 0; + pd67xx->ranges[0]->end = 0; + pd67xx->ranges[1]->start = 0; + pd67xx->ranges[1]->end = 0; if (pd67xx->socket.reset && pd67xx->socket.card_priv) pd67xx->socket.reset(pd67xx->socket.card_priv); } -void* pd6710_init(const device_t* info) +void * +pd6710_init(const device_t *info) { - pcmcia_socket_pd67xx* pd67xx = calloc(1, sizeof(pcmcia_socket_pd67xx)); - int i = 0; + pcmcia_socket_pd67xx *pd67xx = calloc(1, sizeof(pcmcia_socket_pd67xx)); + int i = 0; pd67xx->ranges[0] = io_range_addhandler(0, 0, pd67xx_io_read_1, pd67xx_io_readw_1, NULL, pd67xx_io_write_1, pd67xx_io_writew_1, NULL, 0, pd67xx); pd67xx->ranges[1] = io_range_addhandler(0, 0, pd67xx_io_read_2, pd67xx_io_readw_2, NULL, pd67xx_io_write_2, pd67xx_io_writew_2, NULL, 0, pd67xx); for (i = 0; i < 5; i++) { - pd67xx->mem_maps[i].map_num = i; + pd67xx->mem_maps[i].map_num = i; pd67xx->mem_maps[i].main_ptr = pd67xx; mem_mapping_add(&pd67xx->mem_maps[i].mapping, 0, 0, pd67xx_mem_read, pd67xx_mem_readw, NULL, pd67xx_mem_write, pd67xx_mem_writew, NULL, NULL, MEM_MAPPING_EXTERNAL, &pd67xx->mem_maps[i]); } - pd67xx->socket.socket_num = 0; - pd67xx->socket.powered_on = 0; - pd67xx->socket.interrupt = pd67xx_card_interrupt; - pd67xx->socket.card_inserted = pd67xx_card_inserted; - pd67xx->socket.ready_changed = pd67xx_ready_changed; + pd67xx->socket.socket_num = 0; + pd67xx->socket.powered_on = 0; + pd67xx->socket.interrupt = pd67xx_card_interrupt; + pd67xx->socket.card_inserted = pd67xx_card_inserted; + pd67xx->socket.ready_changed = pd67xx_ready_changed; pd67xx->socket.status_changed = pd67xx_status_changed; pcmcia_register_socket(&pd67xx->socket); @@ -810,7 +838,8 @@ void* pd6710_init(const device_t* info) return pd67xx; } -void pd6710_close(void* priv) +void +pd6710_close(void *priv) { free(priv); }