Constification

This commit is contained in:
Jasmine Iwanek
2023-07-20 18:58:26 -04:00
parent db66543959
commit 998cfe5cc8
163 changed files with 1086 additions and 1071 deletions

View File

@@ -61,7 +61,7 @@ cartridge_log(const char *fmt, ...)
static uint8_t
cart_read(uint32_t addr, void *priv)
{
cart_t *dev = (cart_t *) priv;
const cart_t *dev = (cart_t *) priv;
return dev->buf[addr - dev->base];
}

View File

@@ -421,8 +421,8 @@ lm78_i2c_read(UNUSED(void *bus), UNUSED(uint8_t addr), void *priv)
uint8_t
lm78_as99127f_read(void *priv, uint8_t reg)
{
lm78_t *dev = (lm78_t *) priv;
uint8_t ret = dev->as99127f.regs[1][reg & 0x7f];
const lm78_t *dev = (lm78_t *) priv;
uint8_t ret = dev->as99127f.regs[1][reg & 0x7f];
lm78_log("LM78: read(%02X, AS99127F) = %02X\n", reg, ret);

View File

@@ -48,8 +48,8 @@ static void vt82c686_reset(vt82c686_t *dev, uint8_t initialization);
static uint8_t
vt82c686_read(uint16_t addr, void *priv)
{
vt82c686_t *dev = (vt82c686_t *) priv;
uint8_t ret;
const vt82c686_t *dev = (vt82c686_t *) priv;
uint8_t ret;
addr -= dev->io_base;

View File

@@ -205,9 +205,9 @@ i2c_handler(int set, void *bus_handle, uint8_t base, int size,
uint8_t
i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
{
uint8_t ret = 0;
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
uint8_t ret = 0;
const i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
if (!bus)
return ret;
@@ -230,9 +230,9 @@ i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
uint8_t
i2c_read(void *bus_handle, uint8_t addr)
{
uint8_t ret = 0;
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
uint8_t ret = 0;
const i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
if (!bus)
return ret;
@@ -256,9 +256,9 @@ i2c_read(void *bus_handle, uint8_t addr)
uint8_t
i2c_write(void *bus_handle, uint8_t addr, uint8_t data)
{
uint8_t ret = 0;
i2c_t *p;
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
uint8_t ret = 0;
i2c_t *p;
const i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
if (!bus)
return ret;
@@ -281,8 +281,8 @@ i2c_write(void *bus_handle, uint8_t addr, uint8_t data)
void
i2c_stop(void *bus_handle, uint8_t addr)
{
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
const i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
i2c_t *p;
if (!bus)
return;

View File

@@ -171,14 +171,16 @@ i2c_gpio_set(void *dev_handle, uint8_t scl, uint8_t sda)
uint8_t
i2c_gpio_get_scl(void *dev_handle)
{
i2c_gpio_t *dev = (i2c_gpio_t *) dev_handle;
const i2c_gpio_t *dev = (i2c_gpio_t *) dev_handle;
return dev->prev_scl;
}
uint8_t
i2c_gpio_get_sda(void *dev_handle)
{
i2c_gpio_t *dev = (i2c_gpio_t *) dev_handle;
const i2c_gpio_t *dev = (i2c_gpio_t *) dev_handle;
i2c_gpio_log(3, "I2C GPIO %s: read myscl=%d mysda=%d slavesda=%d\n", dev->bus_name, dev->prev_scl, dev->prev_sda, dev->slave_sda);
return dev->prev_sda && dev->slave_sda;
}

View File

@@ -45,8 +45,8 @@ ibm_5161_out(uint16_t port, uint8_t val, void *priv)
static uint8_t
ibm_5161_in(uint16_t port, void *priv)
{
ibm_5161_t *dev = (ibm_5161_t *) priv;
uint8_t ret = 0xff;
const ibm_5161_t *dev = (ibm_5161_t *) priv;
uint8_t ret = 0xff;
ret = dev->regs[port & 0x0007];

View File

@@ -288,9 +288,9 @@ ems_writew(uint32_t addr, uint16_t val, void *priv)
static uint8_t
ems_read(uint16_t port, void *priv)
{
memdev_t *dev = (memdev_t *) priv;
uint8_t ret = 0xff;
int vpage;
const memdev_t *dev = (memdev_t *) priv;
uint8_t ret = 0xff;
int vpage;
/* Get the viewport page number. */
vpage = (port / EMS_PGSIZE);

View File

@@ -259,7 +259,8 @@ isapnp_reset_ld_regs(isapnp_device_t *ld)
static uint8_t
isapnp_read_rangecheck(UNUSED(uint16_t addr), void *priv)
{
isapnp_device_t *dev = (isapnp_device_t *) priv;
const isapnp_device_t *dev = (isapnp_device_t *) priv;
return (dev->regs[0x31] & 0x01) ? 0x55 : 0xaa;
}

View File

@@ -191,11 +191,11 @@ mm67_chkalrm(nvr_t *nvr, int8_t addr)
static void
mm67_tick(nvr_t *nvr)
{
rtcdev_t *dev = (rtcdev_t *) nvr->data;
uint8_t *regs = nvr->regs;
int mon;
int year;
int f = 0;
const rtcdev_t *dev = (rtcdev_t *) nvr->data;
uint8_t *regs = nvr->regs;
int mon;
int year;
int f = 0;
/* Update and set interrupt if needed. */
regs[MM67_SEC] = RTC_BCDINC(nvr->regs[MM67_SEC], 1);
@@ -295,8 +295,8 @@ mm67_tick(nvr_t *nvr)
static void
mm67_time_get(nvr_t *nvr, struct tm *tm)
{
rtcdev_t *dev = (rtcdev_t *) nvr->data;
uint8_t *regs = nvr->regs;
const rtcdev_t *dev = (rtcdev_t *) nvr->data;
const uint8_t *regs = nvr->regs;
/* NVR is in BCD data mode. */
tm->tm_sec = RTC_DCB(regs[MM67_SEC]);
@@ -325,9 +325,9 @@ mm67_time_get(nvr_t *nvr, struct tm *tm)
static void
mm67_time_set(nvr_t *nvr, struct tm *tm)
{
rtcdev_t *dev = (rtcdev_t *) nvr->data;
uint8_t *regs = nvr->regs;
int year;
const rtcdev_t *dev = (rtcdev_t *) nvr->data;
uint8_t *regs = nvr->regs;
int year;
/* NVR is in BCD data mode. */
regs[MM67_SEC] = RTC_BCD(tm->tm_sec);

View File

@@ -1400,7 +1400,7 @@ write64_quadtel(void *priv, uint8_t val)
static uint8_t
write60_toshiba(void *priv, uint8_t val)
{
atkbc_t *dev = (atkbc_t *) priv;
const atkbc_t *dev = (atkbc_t *) priv;
switch (dev->command) {
case 0xb6: /* T3100e - set color/mono switch */

View File

@@ -87,8 +87,8 @@ fake_shift_needed(uint16_t scan)
void
key_process(uint16_t scan, int down)
{
scancode *codes = scan_table;
int c;
const scancode *codes = scan_table;
int c;
if (!codes)
return;
@@ -222,7 +222,7 @@ keyboard_input(int down, uint16_t scan)
static uint8_t
keyboard_do_break(uint16_t scan)
{
scancode *codes = scan_table;
const scancode *codes = scan_table;
/* TODO: The keyboard controller needs to report the AT flag to us here. */
if (is286 && ((keyboard_mode & 3) == 3)) {
@@ -266,7 +266,7 @@ keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl)
void
keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl)
{
scancode *codes = scan_table;
const scancode *codes = scan_table;
int i;

View File

@@ -594,8 +594,8 @@ kbd_write(uint16_t port, uint8_t val, void *priv)
static uint8_t
kbd_read(uint16_t port, void *priv)
{
xtkbd_t *kbd = (xtkbd_t *) priv;
uint8_t ret = 0xff;
const xtkbd_t *kbd = (xtkbd_t *) priv;
uint8_t ret = 0xff;
switch (port) {
case 0x60: /* Keyboard Data Register (aka Port A) */

View File

@@ -363,8 +363,8 @@ pci_bridge_write(int func, int addr, uint8_t val, void *priv)
static uint8_t
pci_bridge_read(int func, int addr, void *priv)
{
pci_bridge_t *dev = (pci_bridge_t *) priv;
uint8_t ret;
const pci_bridge_t *dev = (pci_bridge_t *) priv;
uint8_t ret;
if (func > 0)
ret = 0xff;

View File

@@ -78,7 +78,8 @@ phoenix_486_jumper_write(UNUSED(uint16_t addr), uint8_t val, void *priv)
static uint8_t
phoenix_486_jumper_read(UNUSED(uint16_t addr), void *priv)
{
phoenix_486_jumper_t *dev = (phoenix_486_jumper_t *) priv;
const phoenix_486_jumper_t *dev = (phoenix_486_jumper_t *) priv;
phoenix_486_jumper_log("Phoenix 486 Jumper: Read %02x\n", dev->jumper);
return dev->jumper;
}