Update ali1429.c

This commit is contained in:
rueni97
2023-01-08 19:04:40 +03:00
committed by GitHub
parent d7a2bca9d7
commit 112b60eb88

View File

@@ -11,13 +11,11 @@
* Note: This chipset has no datasheet, everything were done via * Note: This chipset has no datasheet, everything were done via
* reverse engineering the BIOS of various machines using it. * reverse engineering the BIOS of various machines using it.
* *
*
*
* Authors: Tiseno100, * Authors: Tiseno100,
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
* *
* Copyright 2020-2021 Tiseno100. * Copyright 2020,2021 Tiseno100.
* Copyright 2021-2021 Miran Grca. * Copyright 2021,2021 Miran Grca.
*/ */
/* /*
@@ -74,6 +72,7 @@
1 1 0: CLK2IN/12 1 1 0: CLK2IN/12
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@@ -97,9 +96,11 @@
#define GREEN dev->is_g /* Is G Variant */ #define GREEN dev->is_g /* Is G Variant */
#ifdef ENABLE_ALI1429_LOG #ifdef ENABLE_ALI1429_LOG
int ali1429_do_log = ENABLE_ALI1429_LOG; int ali1429_do_log = ENABLE_ALI1429_LOG;
static void static void
ali1429_log(const char *fmt, ...) ali1429_log(const char *fmt, ...)
{ {
@@ -112,15 +113,17 @@ ali1429_log(const char *fmt, ...)
} }
} }
#else #else
# define ali1429_log(fmt, ...) #define ali1429_log(fmt, ...)
#endif #endif
typedef struct typedef struct
{ {
uint8_t is_g, index, cfg_locked, reg_57h, uint8_t is_g, index, cfg_locked, reg_57h,
regs[90]; regs[90];
} ali1429_t; } ali1429_t;
static void static void
ali1429_shadow_recalc(ali1429_t *dev) ali1429_shadow_recalc(ali1429_t *dev)
{ {
@@ -144,10 +147,11 @@ ali1429_shadow_recalc(ali1429_t *dev)
flushmmucache_nopc(); flushmmucache_nopc();
} }
static void static void
ali1429_write(uint16_t addr, uint8_t val, void *priv) ali1429_write(uint16_t addr, uint8_t val, void *priv)
{ {
ali1429_t *dev = (ali1429_t *) priv; ali1429_t *dev = (ali1429_t *)priv;
switch (addr) { switch (addr) {
case 0x22: case 0x22:
@@ -161,32 +165,31 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
#endif #endif
if (dev->index == 0x03) if (dev->index == 0x03)
dev->cfg_locked = !(val == 0xc5); dev->cfg_locked = (val != 0xc5);
if (!dev->cfg_locked) { if (!dev->cfg_locked) {
pclog("M1429: dev->regs[%02x] = %02x\n", dev->index, val);
/* Common M1429 Registers */ /* Common M1429 Registers */
switch (dev->index) { switch (dev->index) {
case 0x10: case 0x10: case 0x11:
case 0x11:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
break; break;
case 0x12: case 0x12:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
if (val & 4) if(val & 4)
mem_remap_top(128); mem_remap_top(128);
else else
mem_remap_top(0); mem_remap_top(0);
break; break;
case 0x13: case 0x13: case 0x14:
case 0x14:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
ali1429_shadow_recalc(dev); ali1429_shadow_recalc(dev);
break; break;
case 0x15: case 0x15: case 0x16:
case 0x16:
case 0x17: case 0x17:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
break; break;
@@ -197,8 +200,7 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
cpu_update_waitstates(); cpu_update_waitstates();
break; break;
case 0x19: case 0x19: case 0x1a:
case 0x1a:
case 0x1e: case 0x1e:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
break; break;
@@ -206,9 +208,8 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
case 0x20: case 0x20:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
switch (val & 7) { switch(val & 7) {
case 0: case 0: case 7: /* Illegal */
case 7: /* Illegal */
cpu_set_isa_speed(7159091); cpu_set_isa_speed(7159091);
break; break;
@@ -247,8 +248,7 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
if (GREEN) { if (GREEN) {
switch (dev->index) { switch (dev->index) {
case 0x30 ... 0x41: case 0x30 ... 0x41:
case 0x43: case 0x43: case 0x45:
case 0x45:
case 0x4a: case 0x4a:
dev->regs[dev->index] = val; dev->regs[dev->index] = val;
break; break;
@@ -263,10 +263,11 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
} }
} }
static uint8_t static uint8_t
ali1429_read(uint16_t addr, void *priv) ali1429_read(uint16_t addr, void *priv)
{ {
ali1429_t *dev = (ali1429_t *) priv; ali1429_t *dev = (ali1429_t *)priv;
uint8_t ret = 0xff; uint8_t ret = 0xff;
if ((addr == 0x23) && (dev->index >= 0x10) && (dev->index <= 0x4a)) if ((addr == 0x23) && (dev->index >= 0x10) && (dev->index <= 0x4a))
@@ -279,14 +280,16 @@ ali1429_read(uint16_t addr, void *priv)
return ret; return ret;
} }
static void static void
ali1429_close(void *priv) ali1429_close(void *priv)
{ {
ali1429_t *dev = (ali1429_t *) priv; ali1429_t *dev = (ali1429_t *)priv;
free(dev); free(dev);
} }
static void static void
ali1429_defaults(ali1429_t *dev) ali1429_defaults(ali1429_t *dev)
{ {
@@ -314,10 +317,11 @@ ali1429_defaults(ali1429_t *dev)
} }
} }
static void * static void *
ali1429_init(const device_t *info) ali1429_init(const device_t *info)
{ {
ali1429_t *dev = (ali1429_t *) malloc(sizeof(ali1429_t)); ali1429_t *dev = (ali1429_t *)malloc(sizeof(ali1429_t));
memset(dev, 0, sizeof(ali1429_t)); memset(dev, 0, sizeof(ali1429_t));
dev->cfg_locked = 1; dev->cfg_locked = 1;