From d35d298fa1da0623bf98bcddc154c4b34234656c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Tue, 28 May 2024 15:42:14 +0600 Subject: [PATCH] Logging and ALi 1543 changes --- src/chipset/ali1543.c | 25 +++++++++++++++++++++++-- src/usb/usb_ohci_bochs.c | 29 +++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/chipset/ali1543.c b/src/chipset/ali1543.c index f51c4cbed8..42395b4064 100644 --- a/src/chipset/ali1543.c +++ b/src/chipset/ali1543.c @@ -60,6 +60,7 @@ typedef struct ali1543_t { uint8_t ide_dev_enable; uint8_t pmu_dev_enable; uint8_t type; + uint8_t usb_irq_state; int offset; apm_t *apm; @@ -1090,7 +1091,7 @@ ali7101_write(int func, int addr, uint8_t val, void *priv) dev->pmu_conf[addr] = val & 0x9f; break; case 0x46: - dev->pmu_conf[addr] = val & 0x18; + dev->pmu_conf[addr] = (val & 0x18) | 0x20; break; /* TODO: Is the status R/W or R/WC? */ @@ -1596,6 +1597,23 @@ ali1543_close(void *priv) free(dev); } +void +ali5237_usb_raise_smi(void *priv) +{ + ali1543_t *dev = priv; + + dev->pmu_conf[0x4A] |= 0x20; + smi_raise(); +} + +void +ali5237_usb_pci_irq(void *priv, int level) +{ + ali1543_t *dev = priv; + + pci_set_mirq(PCI_MIRQ4, level, &dev->usb_irq_state); +} + static void * ali1543_init(const device_t *info) { @@ -1643,7 +1661,10 @@ ali1543_init(const device_t *info) /* USB */ usb_param.pci_conf = dev->usb_conf; usb_param.pci_dev = &dev->usb_slot; - dev->usb = device_add(&usb_device); + usb_param.do_smi_raise = ali5237_usb_raise_smi; + usb_param.do_pci_irq = ali5237_usb_pci_irq; + usb_param.priv = dev; + dev->usb = device_add_params(&usb_device, &usb_param); ohci_register_usb(dev->usb); dev->type = info->local & 0xff; diff --git a/src/usb/usb_ohci_bochs.c b/src/usb/usb_ohci_bochs.c index c450c51c4e..ea2eb0338d 100644 --- a/src/usb/usb_ohci_bochs.c +++ b/src/usb/usb_ohci_bochs.c @@ -272,9 +272,27 @@ const char *usb_ohci_port_name[] = { " **unknown** " }; -#define BX_ERROR(x) pclog x ; pclog ("\n") -#define BX_INFO(x) pclog x ; pclog ("\n") -#define BX_DEBUG(x) pclog x ; pclog ("\n") +#ifdef ENABLE_OHCI_LOG +int ohci_do_log = ENABLE_OHCI_LOG; + +static void +ohci_log(const char *fmt, ...) +{ + va_list ap; + + if (ohci_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +# define ohci_log(fmt, ...) +#endif + +#define BX_ERROR(x) ohci_log x ; pclog ("\n") +#define BX_INFO(x) ohci_log x ; pclog ("\n") +#define BX_DEBUG(x) ohci_log x ; pclog ("\n") #define BX_PANIC(x) fatal x ; pclog ("\n") #define DEV_MEM_WRITE_PHYSICAL(addr, size, data) dma_bm_write(addr, (uint8_t*)data, size, 4); @@ -625,7 +643,6 @@ uint32_t usb_ohci_mem_read(uint32_t addr, void *priv) uint32_t val = ~0u; uint32_t p = 0; bx_ohci_core_t* hub = priv; - pclog("Register read from addr 0x%X\n", addr); if (addr & 3) return val; @@ -804,12 +821,12 @@ uint32_t usb_ohci_mem_read(uint32_t addr, void *priv) break; } + ohci_log("OHCI: Register read from addr 0x%08X, ret 0x%08X\n", addr, val); return val; } void usb_ohci_mem_writeb(uint32_t addr, uint8_t val, void *priv) { - pclog("byte write 0x%x to 0x%x\n", val, addr); } uint8_t usb_ohci_mem_readb(uint32_t addr, void *priv) @@ -831,7 +848,7 @@ void usb_ohci_mem_write(uint32_t addr, uint32_t value, void* priv) BX_INFO(("Misaligned write at 0x%08X", (Bit32u)addr)); return; } - pclog("Write to addr 0x%X val 0x%X\n", addr, value); + ohci_log("OHCI: Write to addr 0x%X val 0x%X\n", addr, value); switch (offset) { case 0x00: // HcRevision