Skip to content

Commit

Permalink
Logging and ALi 1543 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed May 28, 2024
1 parent 521cb1d commit d35d298
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
25 changes: 23 additions & 2 deletions src/chipset/ali1543.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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? */
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 23 additions & 6 deletions src/usb/usb_ohci_bochs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit d35d298

Please sign in to comment.