More linting in src/device
This commit is contained in:
@@ -90,16 +90,16 @@ cart_image_close(int drive)
|
|||||||
static void
|
static void
|
||||||
cart_image_load(int drive, char *fn)
|
cart_image_load(int drive, char *fn)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *fp;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t base = 0x00000000;
|
uint32_t base = 0x00000000;
|
||||||
|
|
||||||
cart_image_close(drive);
|
cart_image_close(drive);
|
||||||
|
|
||||||
f = fopen(fn, "rb");
|
fp = fopen(fn, "rb");
|
||||||
if (fseek(f, 0, SEEK_END) == -1)
|
if (fseek(fp, 0, SEEK_END) == -1)
|
||||||
fatal("cart_image_load(): Error seeking to the end of the file\n");
|
fatal("cart_image_load(): Error seeking to the end of the file\n");
|
||||||
size = ftell(f);
|
size = ftell(fp);
|
||||||
if (size < 0x1200) {
|
if (size < 0x1200) {
|
||||||
cartridge_log("cart_image_load(): File size %i is too small\n", size);
|
cartridge_log("cart_image_load(): File size %i is too small\n", size);
|
||||||
cart_load_error(drive, fn);
|
cart_load_error(drive, fn);
|
||||||
@@ -107,23 +107,23 @@ cart_image_load(int drive, char *fn)
|
|||||||
}
|
}
|
||||||
if (size & 0x00000fff) {
|
if (size & 0x00000fff) {
|
||||||
size -= 0x00000200;
|
size -= 0x00000200;
|
||||||
fseek(f, 0x000001ce, SEEK_SET);
|
fseek(fp, 0x000001ce, SEEK_SET);
|
||||||
(void) !fread(&base, 1, 2, f);
|
(void) !fread(&base, 1, 2, fp);
|
||||||
base <<= 4;
|
base <<= 4;
|
||||||
fseek(f, 0x00000200, SEEK_SET);
|
fseek(fp, 0x00000200, SEEK_SET);
|
||||||
carts[drive].buf = (uint8_t *) malloc(size);
|
carts[drive].buf = (uint8_t *) malloc(size);
|
||||||
memset(carts[drive].buf, 0x00, size);
|
memset(carts[drive].buf, 0x00, size);
|
||||||
(void) !fread(carts[drive].buf, 1, size, f);
|
(void) !fread(carts[drive].buf, 1, size, fp);
|
||||||
fclose(f);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
base = drive ? 0xe0000 : 0xd0000;
|
base = drive ? 0xe0000 : 0xd0000;
|
||||||
if (size == 32768)
|
if (size == 32768)
|
||||||
base += 0x8000;
|
base += 0x8000;
|
||||||
fseek(f, 0x00000000, SEEK_SET);
|
fseek(fp, 0x00000000, SEEK_SET);
|
||||||
carts[drive].buf = (uint8_t *) malloc(size);
|
carts[drive].buf = (uint8_t *) malloc(size);
|
||||||
memset(carts[drive].buf, 0x00, size);
|
memset(carts[drive].buf, 0x00, size);
|
||||||
(void) !fread(carts[drive].buf, 1, size, f);
|
(void) !fread(carts[drive].buf, 1, size, fp);
|
||||||
fclose(f);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
cartridge_log("cart_image_load(): %s at %08X-%08X\n", fn, base, base + size - 1);
|
cartridge_log("cart_image_load(): %s at %08X-%08X\n", fn, base, base + size - 1);
|
||||||
@@ -136,15 +136,15 @@ cart_image_load(int drive, char *fn)
|
|||||||
static void
|
static void
|
||||||
cart_load_common(int drive, char *fn, uint8_t hard_reset)
|
cart_load_common(int drive, char *fn, uint8_t hard_reset)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *fp;
|
||||||
|
|
||||||
cartridge_log("Cartridge: loading drive %d with '%s'\n", drive, fn);
|
cartridge_log("Cartridge: loading drive %d with '%s'\n", drive, fn);
|
||||||
|
|
||||||
if (!fn)
|
if (!fn)
|
||||||
return;
|
return;
|
||||||
f = plat_fopen(fn, "rb");
|
fp = plat_fopen(fn, "rb");
|
||||||
if (f) {
|
if (fp) {
|
||||||
fclose(f);
|
fclose(fp);
|
||||||
strcpy(cart_fns[drive], fn);
|
strcpy(cart_fns[drive], fn);
|
||||||
cart_image_load(drive, cart_fns[drive]);
|
cart_image_load(drive, cart_fns[drive]);
|
||||||
/* On the real PCjr, inserting a cartridge causes a reset
|
/* On the real PCjr, inserting a cartridge causes a reset
|
||||||
|
@@ -650,9 +650,9 @@ cassette_close(UNUSED(void *priv))
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cassette_callback(void *p)
|
cassette_callback(void *priv)
|
||||||
{
|
{
|
||||||
pc_cassette_t *cas = (pc_cassette_t *) p;
|
pc_cassette_t *cas = (pc_cassette_t *) priv;
|
||||||
|
|
||||||
pc_cas_clock(cas, 8);
|
pc_cas_clock(cas, 8);
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include <86box/timer.h>
|
#include <86box/timer.h>
|
||||||
#include <86box/machine.h>
|
#include <86box/machine.h>
|
||||||
#include <86box/nvr.h>
|
#include <86box/nvr.h>
|
||||||
|
#include <86box/plat_fallthrough.h>
|
||||||
#include <86box/plat_unused.h>
|
#include <86box/plat_unused.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include <86box/i2c.h>
|
#include <86box/i2c.h>
|
||||||
@@ -105,13 +106,13 @@ lm78_nvram(lm78_t *dev, uint8_t save)
|
|||||||
char *nvr_path = (char *) malloc(l);
|
char *nvr_path = (char *) malloc(l);
|
||||||
sprintf(nvr_path, "%s_as99127f.nvr", machine_get_internal_name_ex(machine));
|
sprintf(nvr_path, "%s_as99127f.nvr", machine_get_internal_name_ex(machine));
|
||||||
|
|
||||||
FILE *f = nvr_fopen(nvr_path, save ? "wb" : "rb");
|
FILE *fp = nvr_fopen(nvr_path, save ? "wb" : "rb");
|
||||||
if (f) {
|
if (fp) {
|
||||||
if (save)
|
if (save)
|
||||||
fwrite(&dev->as99127f.nvram, sizeof(dev->as99127f.nvram), 1, f);
|
fwrite(&dev->as99127f.nvram, sizeof(dev->as99127f.nvram), 1, fp);
|
||||||
else
|
else
|
||||||
(void) !fread(&dev->as99127f.nvram, sizeof(dev->as99127f.nvram), 1, f);
|
(void) !fread(&dev->as99127f.nvram, sizeof(dev->as99127f.nvram), 1, fp);
|
||||||
fclose(f);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(nvr_path);
|
free(nvr_path);
|
||||||
@@ -136,7 +137,7 @@ lm78_nvram_read(UNUSED(void *bus), UNUSED(uint8_t addr), void *priv)
|
|||||||
switch (dev->as99127f.nvram_i2c_state) {
|
switch (dev->as99127f.nvram_i2c_state) {
|
||||||
case 0:
|
case 0:
|
||||||
dev->as99127f.nvram_i2c_state = 1;
|
dev->as99127f.nvram_i2c_state = 1;
|
||||||
/* fall-through */
|
fallthrough;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
ret = dev->as99127f.regs[0][0x0b] & 0x3f;
|
ret = dev->as99127f.regs[0][0x0b] & 0x3f;
|
||||||
|
@@ -789,7 +789,7 @@ isartc_reset(void)
|
|||||||
device_add(boards[isartc_type].dev);
|
device_add(boards[isartc_type].dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
isartc_get_internal_name(int board)
|
isartc_get_internal_name(int board)
|
||||||
{
|
{
|
||||||
return device_get_internal_name(boards[board].dev);
|
return device_get_internal_name(boards[board].dev);
|
||||||
|
@@ -150,8 +150,8 @@ typedef struct atkbc_t {
|
|||||||
/* Local copies of the pointers to both ports for easier swapping (AMI '5' MegaKey). */
|
/* Local copies of the pointers to both ports for easier swapping (AMI '5' MegaKey). */
|
||||||
kbc_at_port_t *ports[2];
|
kbc_at_port_t *ports[2];
|
||||||
|
|
||||||
uint8_t (*write60_ven)(void *p, uint8_t val);
|
uint8_t (*write60_ven)(void *priv, uint8_t val);
|
||||||
uint8_t (*write64_ven)(void *p, uint8_t val);
|
uint8_t (*write64_ven)(void *priv, uint8_t val);
|
||||||
} atkbc_t;
|
} atkbc_t;
|
||||||
|
|
||||||
/* Keyboard controller ports. */
|
/* Keyboard controller ports. */
|
||||||
@@ -503,7 +503,6 @@ at_main_ibf:
|
|||||||
dev->state = STATE_MAIN_IBF;
|
dev->state = STATE_MAIN_IBF;
|
||||||
dev->pending = 0;
|
dev->pending = 0;
|
||||||
goto at_main_ibf;
|
goto at_main_ibf;
|
||||||
break;
|
|
||||||
case STATE_KBC_OUT:
|
case STATE_KBC_OUT:
|
||||||
/* Keyboard controller command want to output multiple bytes. */
|
/* Keyboard controller command want to output multiple bytes. */
|
||||||
if (dev->status & STAT_IFULL) {
|
if (dev->status & STAT_IFULL) {
|
||||||
@@ -647,7 +646,6 @@ ps2_main_ibf:
|
|||||||
dev->state = STATE_MAIN_IBF;
|
dev->state = STATE_MAIN_IBF;
|
||||||
dev->pending = 0;
|
dev->pending = 0;
|
||||||
goto ps2_main_ibf;
|
goto ps2_main_ibf;
|
||||||
break;
|
|
||||||
case STATE_KBC_OUT:
|
case STATE_KBC_OUT:
|
||||||
/* Keyboard controller command want to output multiple bytes. */
|
/* Keyboard controller command want to output multiple bytes. */
|
||||||
if (dev->status & STAT_IFULL) {
|
if (dev->status & STAT_IFULL) {
|
||||||
|
@@ -546,13 +546,13 @@ mouse_set_poll(int (*func)(void *), void *arg)
|
|||||||
mouse_priv = arg;
|
mouse_priv = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
mouse_get_name(int mouse)
|
mouse_get_name(int mouse)
|
||||||
{
|
{
|
||||||
return ((char *) mouse_devices[mouse].device->name);
|
return (mouse_devices[mouse].device->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
mouse_get_internal_name(int mouse)
|
mouse_get_internal_name(int mouse)
|
||||||
{
|
{
|
||||||
return device_get_internal_name(mouse_devices[mouse].device);
|
return device_get_internal_name(mouse_devices[mouse].device);
|
||||||
|
@@ -437,8 +437,10 @@ ltsermouse_set_report_period(mouse_t *dev, int rps)
|
|||||||
dev->report_period = 0.0;
|
dev->report_period = 0.0;
|
||||||
dev->continuous = 1;
|
dev->continuous = 1;
|
||||||
} else {
|
} else {
|
||||||
/* if (rps > dev->max_rps)
|
#if 0
|
||||||
rps = dev->max_rps; */
|
if (rps > dev->max_rps)
|
||||||
|
rps = dev->max_rps;
|
||||||
|
#endif
|
||||||
|
|
||||||
dev->continuous = 0;
|
dev->continuous = 0;
|
||||||
dev->report_period = 1000000.0 / ((double) rps);
|
dev->report_period = 1000000.0 / ((double) rps);
|
||||||
@@ -478,18 +480,22 @@ ltsermouse_switch_baud_rate(mouse_t *dev, int next_state)
|
|||||||
|
|
||||||
word_len += 1.0 + 2.0; /* 1 start bit + 2 stop bits */
|
word_len += 1.0 + 2.0; /* 1 start bit + 2 stop bits */
|
||||||
|
|
||||||
// dev->max_rps = (int) floor(((double) dev->bps) / (word_len * num_words));
|
#if 0
|
||||||
|
dev->max_rps = (int) floor(((double) dev->bps) / (word_len * num_words));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (next_state == STATE_BAUD_RATE)
|
if (next_state == STATE_BAUD_RATE)
|
||||||
dev->transmit_period = dev->host_transmit_period;
|
dev->transmit_period = dev->host_transmit_period;
|
||||||
else
|
else
|
||||||
dev->transmit_period = (1000000.0) / ((double) dev->bps);
|
dev->transmit_period = 1000000.0 / ((double) dev->bps);
|
||||||
|
|
||||||
dev->min_bit_period = dev->transmit_period;
|
dev->min_bit_period = dev->transmit_period;
|
||||||
|
|
||||||
dev->transmit_period *= word_len;
|
dev->transmit_period *= word_len;
|
||||||
/* The transmit period for the entire report, we're going to need this in ltsermouse_set_report_period(). */
|
/* The transmit period for the entire report, we're going to need this in ltsermouse_set_report_period(). */
|
||||||
// dev->report_transmit_period = dev->transmit_period * num_words;
|
#if 0
|
||||||
|
dev->report_transmit_period = dev->transmit_period * num_words;
|
||||||
|
#endif
|
||||||
|
|
||||||
ltsermouse_set_report_period(dev, dev->rps);
|
ltsermouse_set_report_period(dev, dev->rps);
|
||||||
|
|
||||||
@@ -531,7 +537,7 @@ ltsermouse_process_command(mouse_t *dev)
|
|||||||
[FORMAT_HEX] = 0x04,
|
[FORMAT_HEX] = 0x04,
|
||||||
[FORMAT_MS_4BYTE] = 0x08, /* Guess */
|
[FORMAT_MS_4BYTE] = 0x08, /* Guess */
|
||||||
[FORMAT_MS_WHEEL] = 0x08 }; /* Guess */
|
[FORMAT_MS_WHEEL] = 0x08 }; /* Guess */
|
||||||
char *copr = "\r\n(C) 2023 86Box, Revision 3.0";
|
const char *copr = "\r\n(C) 2023 86Box, Revision 3.0";
|
||||||
|
|
||||||
mouse_serial_log("ltsermouse_process_command(): %02X\n", dev->ib);
|
mouse_serial_log("ltsermouse_process_command(): %02X\n", dev->ib);
|
||||||
dev->command = dev->ib;
|
dev->command = dev->ib;
|
||||||
@@ -653,6 +659,9 @@ ltsermouse_process_command(mouse_t *dev)
|
|||||||
/* Buttons - 86Box-specific command. */
|
/* Buttons - 86Box-specific command. */
|
||||||
dev->state = dev->but;
|
dev->state = dev->but;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,9 +840,9 @@ static void *
|
|||||||
sermouse_init(const device_t *info)
|
sermouse_init(const device_t *info)
|
||||||
{
|
{
|
||||||
mouse_t *dev;
|
mouse_t *dev;
|
||||||
void (*rcr_callback)(struct serial_s *serial, void *p);
|
void (*rcr_callback)(struct serial_s *serial, void *priv);
|
||||||
void (*dev_write)(struct serial_s *serial, void *p, uint8_t data);
|
void (*dev_write)(struct serial_s *serial, void *priv, uint8_t data);
|
||||||
void (*transmit_period_callback)(struct serial_s *serial, void *p, double transmit_period);
|
void (*transmit_period_callback)(struct serial_s *serial, void *priv, double transmit_period);
|
||||||
|
|
||||||
dev = (mouse_t *) malloc(sizeof(mouse_t));
|
dev = (mouse_t *) malloc(sizeof(mouse_t));
|
||||||
memset(dev, 0x00, sizeof(mouse_t));
|
memset(dev, 0x00, sizeof(mouse_t));
|
||||||
|
@@ -132,11 +132,10 @@ serial_update_ints(serial_t *dev)
|
|||||||
as equal and still somehow distinguish them. */
|
as equal and still somehow distinguish them. */
|
||||||
uint8_t ier_map[7] = { 0x04, 0x01, 0x01, 0x02, 0x08, 0x40, 0x80 };
|
uint8_t ier_map[7] = { 0x04, 0x01, 0x01, 0x02, 0x08, 0x40, 0x80 };
|
||||||
uint8_t iir_map[7] = { 0x06, 0x0c, 0x04, 0x02, 0x00, 0x0e, 0x0a };
|
uint8_t iir_map[7] = { 0x06, 0x0c, 0x04, 0x02, 0x00, 0x0e, 0x0a };
|
||||||
int i;
|
|
||||||
|
|
||||||
dev->iir = (dev->iir & 0xf0) | 0x01;
|
dev->iir = (dev->iir & 0xf0) | 0x01;
|
||||||
|
|
||||||
for (i = 0; i < 7; i++) {
|
for (uint8_t i = 0; i < 7; i++) {
|
||||||
if ((dev->ier & ier_map[i]) && (dev->int_status & (1 << i))) {
|
if ((dev->ier & ier_map[i]) && (dev->int_status & (1 << i))) {
|
||||||
dev->iir = (dev->iir & 0xf0) | iir_map[i];
|
dev->iir = (dev->iir & 0xf0) | iir_map[i];
|
||||||
break;
|
break;
|
||||||
@@ -175,8 +174,10 @@ serial_receive_timer(void *priv)
|
|||||||
fifo_write_evt((uint8_t) (dev->out_new & 0xff), dev->rcvr_fifo);
|
fifo_write_evt((uint8_t) (dev->out_new & 0xff), dev->rcvr_fifo);
|
||||||
dev->out_new = 0xffff;
|
dev->out_new = 0xffff;
|
||||||
|
|
||||||
/* pclog("serial_receive_timer(): lsr = %02X, ier = %02X, iir = %02X, int_status = %02X\n",
|
#if 0
|
||||||
dev->lsr, dev->ier, dev->iir, dev->int_status); */
|
pclog("serial_receive_timer(): lsr = %02X, ier = %02X, iir = %02X, int_status = %02X\n",
|
||||||
|
dev->lsr, dev->ier, dev->iir, dev->int_status);
|
||||||
|
#endif
|
||||||
|
|
||||||
timer_on_auto(&dev->timeout_timer, 4.0 * dev->bits * dev->transmit_period);
|
timer_on_auto(&dev->timeout_timer, 4.0 * dev->bits * dev->transmit_period);
|
||||||
}
|
}
|
||||||
@@ -441,9 +442,9 @@ serial_set_clock_src(serial_t *dev, double clock_src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
serial_write(uint16_t addr, uint8_t val, void *p)
|
serial_write(uint16_t addr, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
serial_t *dev = (serial_t *) p;
|
serial_t *dev = (serial_t *) priv;
|
||||||
uint8_t new_msr;
|
uint8_t new_msr;
|
||||||
uint8_t old;
|
uint8_t old;
|
||||||
|
|
||||||
@@ -528,6 +529,9 @@ serial_write(uint16_t addr, uint8_t val, void *p)
|
|||||||
case 3:
|
case 3:
|
||||||
fifo_set_trigger_len(dev->rcvr_fifo, 14);
|
fifo_set_trigger_len(dev->rcvr_fifo, 14);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fifo_set_trigger_len(dev->xmit_fifo, 16);
|
fifo_set_trigger_len(dev->xmit_fifo, 16);
|
||||||
dev->out_new = 0xffff;
|
dev->out_new = 0xffff;
|
||||||
@@ -620,9 +624,9 @@ serial_write(uint16_t addr, uint8_t val, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
serial_read(uint16_t addr, void *p)
|
serial_read(uint16_t addr, void *priv)
|
||||||
{
|
{
|
||||||
serial_t *dev = (serial_t *) p;
|
serial_t *dev = (serial_t *) priv;
|
||||||
uint8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
cycles -= ISA_CYCLES(8);
|
cycles -= ISA_CYCLES(8);
|
||||||
@@ -773,10 +777,10 @@ serial_xmit_d_empty_evt(void *priv)
|
|||||||
|
|
||||||
serial_t *
|
serial_t *
|
||||||
serial_attach_ex(int port,
|
serial_attach_ex(int port,
|
||||||
void (*rcr_callback)(struct serial_s *serial, void *p),
|
void (*rcr_callback)(struct serial_s *serial, void *priv),
|
||||||
void (*dev_write)(struct serial_s *serial, void *p, uint8_t data),
|
void (*dev_write)(struct serial_s *serial, void *priv, uint8_t data),
|
||||||
void (*transmit_period_callback)(struct serial_s *serial, void *p, double transmit_period),
|
void (*transmit_period_callback)(struct serial_s *serial, void *priv, double transmit_period),
|
||||||
void (*lcr_callback)(struct serial_s *serial, void *p, uint8_t data_bits),
|
void (*lcr_callback)(struct serial_s *serial, void *priv, uint8_t data_bits),
|
||||||
void *priv)
|
void *priv)
|
||||||
{
|
{
|
||||||
serial_device_t *sd = &serial_devices[port];
|
serial_device_t *sd = &serial_devices[port];
|
||||||
|
Reference in New Issue
Block a user