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, ...)
{ {
@@ -115,12 +116,14 @@ ali1429_log(const char *fmt, ...)
#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,6 +147,7 @@ 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)
{ {
@@ -161,13 +165,14 @@ 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;
@@ -179,14 +184,12 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
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;
@@ -207,8 +209,7 @@ ali1429_write(uint16_t addr, uint8_t val, void *priv)
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,6 +263,7 @@ 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)
{ {
@@ -279,6 +280,7 @@ ali1429_read(uint16_t addr, void *priv)
return ret; return ret;
} }
static void static void
ali1429_close(void *priv) ali1429_close(void *priv)
{ {
@@ -287,6 +289,7 @@ ali1429_close(void *priv)
free(dev); free(dev);
} }
static void static void
ali1429_defaults(ali1429_t *dev) ali1429_defaults(ali1429_t *dev)
{ {
@@ -314,6 +317,7 @@ ali1429_defaults(ali1429_t *dev)
} }
} }
static void * static void *
ali1429_init(const device_t *info) ali1429_init(const device_t *info)
{ {