From: ljsebald <ljs...@us...> - 2024-03-24 17:17:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 33acd8aee18d22d6871696e48977b68db55dd947 (commit) via e2f0c88e2e64d4b3b578456140bd6862b88be46a (commit) via ab0c189b56d5f72ec30ec91a2ec6d95343697c27 (commit) via 043b75675864d949866c903dedeffb7cc4415f49 (commit) via 3e84dead5470afe8c234a6c751b0ef3f39719005 (commit) via 15ba6fd1847cf45052a9e61a4d6a27b3f3e859bc (commit) from 6321b5edb09a89d7f90ba56927f858df981bb27a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 33acd8aee18d22d6871696e48977b68db55dd947 Merge: e2f0c88e 3e84dead Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 24 13:07:54 2024 -0400 Merge pull request #497 from pcercuei/gcc-disable-doc dc-chain: Disable GCC documentation commit e2f0c88e2e64d4b3b578456140bd6862b88be46a Merge: 043b7567 ab0c189b Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 24 13:07:24 2024 -0400 Merge pull request #496 from KallistiOS/cmake_sysroot Adding KOS_PORTS dir as sysroot for cmake to find libraries commit ab0c189b56d5f72ec30ec91a2ec6d95343697c27 Merge: 15ba6fd1 043b7567 Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 24 13:07:04 2024 -0400 Merge branch 'master' into cmake_sysroot commit 043b75675864d949866c903dedeffb7cc4415f49 Author: Paul Cercueil <pa...@cr...> Date: Sun Mar 24 07:14:08 2024 +0100 Threaded ASIC IRQ handlers (#393) * irq: Use standard stdint.h types Use the standard 'uint32_t' type instead of the custom 'uint32' one. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: irq: Pass data pointer to IRQ handlers Update the IRQ API to allow clients to register a data pointer alongside the callback. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: asic: Add function asic_evt_remove_handler() This function can be used to unregister any handler set to the given ASIC event. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: asic: Pass data pointer to IRQ handlers Allow registering a pointer alongside the IRQ handler. The pointer will be passed as argument to the callback function. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: vblank: Pass data pointer to VBLANK IRQ handler Allow registering a pointer alongside the IRQ handler. The pointer will be passed as argument to the callback function. Signed-off-by: Paul Cercueil <pa...@cr...> * maple: Pass down state pointer to IRQ callbacks Avoid global accesses to the 'maple_state' variable; instead, access it through a 'state' parameter that's passed as argument to the IRQ callbacks. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: ubc: Pass data pointer to IRQ handlers Update the UBC interrupt handler code to pass a pointer to the channel_state array. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: asic: Add support for threaded IRQ handlers Threaded IRQ handlers are functions which will be called within a thread, when a given IRQ happens. The advantage vs. regular IRQ handlers is that they are executed outside the IRQ context, and as a result, can hold locks and sleep if needed. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit 3e84dead5470afe8c234a6c751b0ef3f39719005 Author: Paul Cercueil <pa...@cr...> Date: Tue Mar 19 19:07:27 2024 +0100 dc-chain: Disable GCC documentation We do not need to build GCC's documentation; and it was a common failure point as old versions of GCC don't play well with the recent makeinfo/texinfo programs. Signed-off-by: Paul Cercueil <pa...@cr...> commit 15ba6fd1847cf45052a9e61a4d6a27b3f3e859bc Author: QuzarDC <qu...@co...> Date: Mon Mar 18 11:51:26 2024 -0400 Adding KOS_PORTS dir as sysroot for cmake to find libraries ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/fs/fs_iso9660.c | 5 +- kernel/arch/dreamcast/hardware/asic.c | 155 +++++++++++++++++++-- kernel/arch/dreamcast/hardware/g1ata.c | 15 +- kernel/arch/dreamcast/hardware/g2dma.c | 8 +- kernel/arch/dreamcast/hardware/maple/controller.c | 2 +- kernel/arch/dreamcast/hardware/maple/dreameye.c | 8 +- kernel/arch/dreamcast/hardware/maple/keyboard.c | 2 +- .../dreamcast/hardware/maple/maple_init_shutdown.c | 6 +- kernel/arch/dreamcast/hardware/maple/maple_irq.c | 90 ++++++------ kernel/arch/dreamcast/hardware/maple/mouse.c | 2 +- kernel/arch/dreamcast/hardware/maple/purupuru.c | 2 +- kernel/arch/dreamcast/hardware/maple/sip.c | 6 +- kernel/arch/dreamcast/hardware/maple/vmu.c | 10 +- kernel/arch/dreamcast/hardware/modem/mintr.c | 15 +- .../dreamcast/hardware/network/broadband_adapter.c | 9 +- .../arch/dreamcast/hardware/network/lan_adapter.c | 9 +- kernel/arch/dreamcast/hardware/pvr/pvr_dma.c | 7 +- .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 36 ++--- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 2 +- kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 4 +- kernel/arch/dreamcast/hardware/scif.c | 18 +-- kernel/arch/dreamcast/hardware/ubc.c | 19 +-- kernel/arch/dreamcast/hardware/vblank.c | 14 +- kernel/arch/dreamcast/include/arch/irq.h | 42 +++--- kernel/arch/dreamcast/include/dc/asic.h | 38 ++++- kernel/arch/dreamcast/include/dc/maple.h | 10 +- kernel/arch/dreamcast/include/dc/vblank.h | 3 +- kernel/arch/dreamcast/kernel/gdb_stub.c | 23 +-- kernel/arch/dreamcast/kernel/irq.c | 96 +++++++------ kernel/arch/dreamcast/kernel/mmu.c | 49 ++++--- kernel/arch/dreamcast/kernel/timer.c | 12 +- kernel/arch/dreamcast/kernel/wdt.c | 7 +- utils/cmake/dreamcast.toolchain.cmake | 1 + utils/dc-chain/scripts/gcc-pass1.mk | 1 + utils/dc-chain/scripts/gcc-pass2.mk | 1 + 35 files changed, 469 insertions(+), 258 deletions(-) diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index 7f72de39..20d6f766 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -928,10 +928,11 @@ int iso_reset(void) { time someone calls in it'll get reset. */ static int iso_last_status; static int iso_vblank_hnd; -static void iso_vblank(uint32 evt) { +static void iso_vblank(uint32 evt, void *data) { int status, disc_type; (void)evt; + (void)data; /* Get the status. This may fail if a CD operation is in progress in the foreground. */ @@ -1077,7 +1078,7 @@ int fs_iso9660_init(void) { iso_last_status = -1; /* Register with the vblank */ - iso_vblank_hnd = vblank_handler_add(iso_vblank); + iso_vblank_hnd = vblank_handler_add(iso_vblank, NULL); /* Register with VFS */ return nmmgr_handler_add(&vh.nmmgr); diff --git a/kernel/arch/dreamcast/hardware/asic.c b/kernel/arch/dreamcast/hardware/asic.c index ab939568..3bc486c6 100644 --- a/kernel/arch/dreamcast/hardware/asic.c +++ b/kernel/arch/dreamcast/hardware/asic.c @@ -93,12 +93,15 @@ */ +#include <stdbool.h> +#include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include <arch/irq.h> #include <dc/asic.h> #include <arch/spinlock.h> +#include <kos/genwait.h> /* XXX These based on g1ata.c and pvr.h and should be replaced by a standardized method */ #define IN32(addr) (* ( (volatile uint32_t *)(addr) ) ) @@ -110,13 +113,31 @@ #define ASIC_EVT_REGS 3 #define ASIC_EVT_REG_HNDS 32 +typedef struct { + asic_evt_handler hdl; + void *data; +} asic_evt_handler_entry_t; + +struct asic_thdata { + asic_evt_handler hdl; + uint32_t source; + kthread_t *thd; + int genwait_obj; + void *data; + volatile bool quit; + volatile bool pending; + void (*ack_and_mask)(uint16_t); + void (*unmask)(uint16_t); +}; + /* Exception table -- this table matches each potential G2 event to a function pointer. If the pointer is null, then nothing happens. Otherwise, the function will handle the exception. */ -static asic_evt_handler asic_evt_handlers[ASIC_EVT_REGS][ASIC_EVT_REG_HNDS]; +static asic_evt_handler_entry_t +asic_evt_handlers[ASIC_EVT_REGS][ASIC_EVT_REG_HNDS]; /* Set a handler, or remove a handler */ -void asic_evt_set_handler(uint16_t code, asic_evt_handler hnd) { +void asic_evt_set_handler(uint16_t code, asic_evt_handler hnd, void *data) { uint8_t evtreg, evt; evtreg = (code >> 8) & 0xff; @@ -124,12 +145,14 @@ void asic_evt_set_handler(uint16_t code, asic_evt_handler hnd) { assert((evtreg < ASIC_EVT_REGS) && (evt < ASIC_EVT_REG_HNDS)); - asic_evt_handlers[evtreg][evt] = hnd; + asic_evt_handlers[evtreg][evt] = (asic_evt_handler_entry_t){ hnd, data }; } /* The ASIC event handler; this is called from the global IRQ handler to handle external IRQ 9. */ -static void handler_irq9(irq_t source, irq_context_t *context) { +static void handler_irq9(irq_t source, irq_context_t *context, void *data) { + const asic_evt_handler_entry_t (*const handlers)[ASIC_EVT_REG_HNDS] = data; + const asic_evt_handler_entry_t *entry; uint8_t reg, i; (void)source; @@ -146,11 +169,10 @@ static void handler_irq9(irq_t source, irq_context_t *context) { /* Search for relevant handlers */ for(i = 0; i < ASIC_EVT_REG_HNDS; i++) { - if(mask & (1 << i)) { - if(asic_evt_handlers[reg][i] != NULL) { - asic_evt_handlers[reg][i]((reg << 8) | i); - } - } + entry = &handlers[reg][i]; + + if((mask & (1 << i)) && entry->hdl != NULL) + entry->hdl((reg << 8) | i, entry->data); } } } @@ -206,9 +228,9 @@ static void asic_evt_init(void) { memset(asic_evt_handlers, 0, sizeof(asic_evt_handlers)); /* Hook IRQ9,B,D */ - irq_set_handler(EXC_IRQ9, handler_irq9); - irq_set_handler(EXC_IRQB, handler_irq9); - irq_set_handler(EXC_IRQD, handler_irq9); + irq_set_handler(EXC_IRQ9, handler_irq9, asic_evt_handlers); + irq_set_handler(EXC_IRQB, handler_irq9, asic_evt_handlers); + irq_set_handler(EXC_IRQD, handler_irq9, asic_evt_handlers); } /* Shutdown events */ @@ -217,9 +239,9 @@ static void asic_evt_shutdown(void) { asic_evt_disable_all(); /* Unhook handlers */ - irq_set_handler(EXC_IRQ9, NULL); - irq_set_handler(EXC_IRQB, NULL); - irq_set_handler(EXC_IRQD, NULL); + irq_set_handler(EXC_IRQ9, NULL, NULL); + irq_set_handler(EXC_IRQB, NULL, NULL); + irq_set_handler(EXC_IRQD, NULL, NULL); } /* Init routine */ @@ -230,3 +252,106 @@ void asic_init(void) { void asic_shutdown(void) { asic_evt_shutdown(); } + +static void * asic_threaded_irq(void *data) { + struct asic_thdata *thdata = data; + int flags; + + for (;;) { + flags = irq_disable(); + + if (!thdata->pending) + genwait_wait(&thdata->genwait_obj, thdata->thd->label, 0, NULL); + + irq_restore(flags); + + if (thdata->quit) + break; + + thdata->pending = false; + thdata->hdl(thdata->source, thdata->data); + + if (thdata->unmask) + thdata->unmask(thdata->source); + } + + return NULL; +} + +static void asic_thirq_dispatch(uint32_t source, void *data) { + struct asic_thdata *thdata = data; + + if (thdata->ack_and_mask) + thdata->ack_and_mask(source); + + thdata->source = source; + + thdata->pending = true; + genwait_wake_one(&thdata->genwait_obj); +} + +int asic_evt_request_threaded_handler(uint16_t code, asic_evt_handler hnd, + void *data, + void (*ack_and_mask)(uint16_t), + void (*unmask)(uint16_t)) +{ + struct asic_thdata *thdata; + uint32_t flags; + + thdata = malloc(sizeof(*thdata)); + if (!thdata) + return -1; /* TODO: What return code? */ + + thdata->hdl = hnd; + thdata->data = data; + thdata->quit = false; + thdata->pending = false; + thdata->ack_and_mask = ack_and_mask; + thdata->unmask = unmask; + + flags = irq_disable(); + + thdata->thd = thd_create(0, asic_threaded_irq, thdata); + if (!thdata->thd) { + irq_restore(flags); + free(thdata); + return -1; /* TODO: What return code? */ + } + + /* Set a reasonable name to ID the thread */ + snprintf(thdata->thd->label, KTHREAD_LABEL_SIZE, + "Threaded IRQ code: 0x%x evt: 0x%.4x", + ((code >> 16) & 0xf), (code & 0xffff)); + + /* Highest priority */ + //thd_set_prio(thdata->thd, 0); + + asic_evt_set_handler(code, asic_thirq_dispatch, thdata); + + irq_restore(flags); + + return 0; +} + +void asic_evt_remove_handler(uint16_t code) +{ + asic_evt_handler_entry_t entry; + struct asic_thdata *thdata; + uint8_t evtreg, evt; + + evtreg = (code >> 8) & 0xff; + evt = code & 0xff; + + entry = asic_evt_handlers[evtreg][evt]; + asic_evt_set_handler(code, NULL, NULL); + + if (entry.hdl == asic_thirq_dispatch) { + thdata = entry.data; + thdata->quit = true; + + genwait_wake_one(&thdata->genwait_obj); + thd_join(thdata->thd, NULL); + + free(thdata); + } +} diff --git a/kernel/arch/dreamcast/hardware/g1ata.c b/kernel/arch/dreamcast/hardware/g1ata.c index 9de6b30a..5d4e3fcc 100644 --- a/kernel/arch/dreamcast/hardware/g1ata.c +++ b/kernel/arch/dreamcast/hardware/g1ata.c @@ -211,9 +211,10 @@ inline int g1_ata_mutex_unlock(void) { return mutex_unlock(&_g1_ata_mutex); } -static void g1_dma_irq_hnd(uint32 code) { +static void g1_dma_irq_hnd(uint32 code, void *data) { /* XXXX: Probably should look at the code to make sure it isn't an error. */ (void)code; + (void)data; if(dma_in_progress) { /* Signal the calling thread to continue, if it is blocking. */ @@ -1388,11 +1389,11 @@ int g1_ata_init(void) { } /* Hook all the DMA related events. */ - asic_evt_set_handler(ASIC_EVT_GD_DMA, g1_dma_irq_hnd); + asic_evt_set_handler(ASIC_EVT_GD_DMA, g1_dma_irq_hnd, NULL); asic_evt_enable(ASIC_EVT_GD_DMA, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_GD_DMA_OVERRUN, g1_dma_irq_hnd); + asic_evt_set_handler(ASIC_EVT_GD_DMA_OVERRUN, g1_dma_irq_hnd, NULL); asic_evt_enable(ASIC_EVT_GD_DMA_OVERRUN, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_GD_DMA_ILLADDR, g1_dma_irq_hnd); + asic_evt_set_handler(ASIC_EVT_GD_DMA_ILLADDR, g1_dma_irq_hnd, NULL); asic_evt_enable(ASIC_EVT_GD_DMA_ILLADDR, ASIC_IRQB); initted = 1; @@ -1415,9 +1416,9 @@ void g1_ata_shutdown(void) { /* Unhook the events and disable the IRQs. */ asic_evt_disable(ASIC_EVT_GD_DMA, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_GD_DMA, NULL); + asic_evt_remove_handler(ASIC_EVT_GD_DMA); asic_evt_disable(ASIC_EVT_GD_DMA_OVERRUN, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_GD_DMA_OVERRUN, NULL); + asic_evt_remove_handler(ASIC_EVT_GD_DMA_OVERRUN); asic_evt_disable(ASIC_EVT_GD_DMA_ILLADDR, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_GD_DMA_ILLADDR, NULL); + asic_evt_remove_handler(ASIC_EVT_GD_DMA_ILLADDR); } diff --git a/kernel/arch/dreamcast/hardware/g2dma.c b/kernel/arch/dreamcast/hardware/g2dma.c index 6ad85f36..829b76f0 100644 --- a/kernel/arch/dreamcast/hardware/g2dma.c +++ b/kernel/arch/dreamcast/hardware/g2dma.c @@ -128,9 +128,11 @@ inline static void dma_disable(uint32_t chn) { g2_dma->dma[chn].start = 0; } -static void g2_dma_irq_hnd(uint32_t code) { +static void g2_dma_irq_hnd(uint32_t code, void *data) { int chn = code - ASIC_EVT_G2_DMA0; + (void)data; + if(chn < G2_DMA_CHAN_SPU || chn > G2_DMA_CHAN_CH3) { dbglog(DBG_ERROR, "g2_dma: Wrong channel received in g2_dma_irq_hnd"); return; @@ -224,7 +226,7 @@ int g2_dma_init(void) { dma_cbdata[i] = 0; /* Hook the interrupt */ - asic_evt_set_handler(ASIC_EVT_G2_DMA0 + i, g2_dma_irq_hnd); + asic_evt_set_handler(ASIC_EVT_G2_DMA0 + i, g2_dma_irq_hnd, NULL); asic_evt_enable(ASIC_EVT_G2_DMA0 + i, ASIC_IRQB); } @@ -246,7 +248,7 @@ void g2_dma_shutdown(void) { for(i = 0; i < 4; i++) { /* Unhook the G2 interrupt */ asic_evt_disable(ASIC_EVT_G2_DMA0 + i, ASIC_IRQB); - asic_evt_set_handler(ASIC_EVT_G2_DMA0 + i, NULL); + asic_evt_remove_handler(ASIC_EVT_G2_DMA0 + i); /* Destroy the semaphore */ sem_destroy(&dma_done[i]); diff --git a/kernel/arch/dreamcast/hardware/maple/controller.c b/kernel/arch/dreamcast/hardware/maple/controller.c index ec2c243c..f6678c1f 100644 --- a/kernel/arch/dreamcast/hardware/maple/controller.c +++ b/kernel/arch/dreamcast/hardware/maple/controller.c @@ -49,7 +49,7 @@ void cont_btn_callback(uint8_t addr, uint32_t btns, cont_btn_callback_t cb) { } /* Response callback for the GETCOND Maple command. */ -static void cont_reply(maple_frame_t *frm) { +static void cont_reply(maple_state_t *, maple_frame_t *frm) { maple_response_t *resp; uint32_t *respbuf; cont_cond_t *raw; diff --git a/kernel/arch/dreamcast/hardware/maple/dreameye.c b/kernel/arch/dreamcast/hardware/maple/dreameye.c index 08e22655..fad5d40e 100644 --- a/kernel/arch/dreamcast/hardware/maple/dreameye.c +++ b/kernel/arch/dreamcast/hardware/maple/dreameye.c @@ -19,7 +19,7 @@ static int dreameye_send_get_image(maple_device_t *dev, static dreameye_state_t *first_state = NULL; -static void dreameye_get_image_count_cb(maple_frame_t *frame) { +static void dreameye_get_image_count_cb(maple_state_t *, maple_frame_t *frame) { dreameye_state_t *de; maple_response_t *resp; uint32 *respbuf32; @@ -59,7 +59,7 @@ static void dreameye_get_image_count_cb(maple_frame_t *frame) { genwait_wake_all(frame); } -static void dreameye_get_transfer_count_cb(maple_frame_t *frame) { +static void dreameye_get_transfer_count_cb(maple_state_t *, maple_frame_t *frame) { dreameye_state_t *de; maple_response_t *resp; uint32 *respbuf32; @@ -139,7 +139,7 @@ int dreameye_get_image_count(maple_device_t *dev, int block) { return MAPLE_EOK; } -static void dreameye_get_image_cb(maple_frame_t *frame) { +static void dreameye_get_image_cb(maple_state_t *, maple_frame_t *frame) { maple_device_t *dev; maple_response_t *resp; uint32 *respbuf32; @@ -327,7 +327,7 @@ fail: return MAPLE_EFAIL; } -static void dreameye_erase_cb(maple_frame_t *frame) { +static void dreameye_erase_cb(maple_state_t *, maple_frame_t *frame) { maple_response_t *resp; uint8 *respbuf; diff --git a/kernel/arch/dreamcast/hardware/maple/keyboard.c b/kernel/arch/dreamcast/hardware/maple/keyboard.c index 95bb091d..df184310 100644 --- a/kernel/arch/dreamcast/hardware/maple/keyboard.c +++ b/kernel/arch/dreamcast/hardware/maple/keyboard.c @@ -521,7 +521,7 @@ static void kbd_check_poll(maple_frame_t *frm) { } } -static void kbd_reply(maple_frame_t *frm) { +static void kbd_reply(maple_state_t *, maple_frame_t *frm) { maple_response_t *resp; uint32 *respbuf; kbd_state_t *state; diff --git a/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c b/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c index 1f6b64ae..488f9592 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c @@ -95,8 +95,8 @@ static void maple_hw_init(void) { maple_bus_enable(); /* Hook the necessary interrupts */ - maple_state.vbl_handle = vblank_handler_add(maple_vbl_irq_hnd); - asic_evt_set_handler(ASIC_EVT_MAPLE_DMA, maple_dma_irq_hnd); + maple_state.vbl_handle = vblank_handler_add(maple_vbl_irq_hnd, &maple_state); + asic_evt_set_handler(ASIC_EVT_MAPLE_DMA, maple_dma_irq_hnd, &maple_state); asic_evt_enable(ASIC_EVT_MAPLE_DMA, ASIC_IRQ_DEFAULT); } @@ -108,7 +108,7 @@ void maple_hw_shutdown(void) { /* Unhook interrupts */ vblank_handler_remove(maple_state.vbl_handle); - asic_evt_set_handler(ASIC_EVT_MAPLE_DMA, NULL); + asic_evt_remove_handler(ASIC_EVT_MAPLE_DMA); asic_evt_disable(ASIC_EVT_MAPLE_DMA, ASIC_IRQ_DEFAULT); /* Stop any existing maple DMA and shut down the bus */ diff --git a/kernel/arch/dreamcast/hardware/maple/maple_irq.c b/kernel/arch/dreamcast/hardware/maple/maple_irq.c index d174eb01..85a155a8 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_irq.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_irq.c @@ -19,13 +19,13 @@ /* VBlank IRQ handler */ /* Fwd declare */ -static void vbl_autodet_callback(maple_frame_t *); +static void vbl_autodet_callback(maple_state_t *state, maple_frame_t *frm); /* Send a DEVINFO command for the given port/unit */ -static void vbl_send_devinfo(int p, int u) { +static void vbl_send_devinfo(maple_state_t *state, int p, int u) { maple_device_t * dev; - dev = &maple_state.ports[p].units[u]; + dev = &state->ports[p].units[u]; /* Reserve access; if we don't get it, forget about it */ if(maple_frame_lock(&dev->frame) < 0) @@ -42,25 +42,25 @@ static void vbl_send_devinfo(int p, int u) { /* Do a potential disconnect on the named device (check to make sure it was connected first) */ -static void vbl_chk_disconnect(int p, int u) { - if(maple_state.ports[p].units[u].valid) { +static void vbl_chk_disconnect(maple_state_t *state, int p, int u) { + if(state->ports[p].units[u].valid) { #if MAPLE_IRQ_DEBUG dbglog(DBG_KDEBUG, "maple: detach on device %c%c\n", 'A' + p, '0' + u); #endif if(maple_driver_detach(p, u) >= 0) { - assert(!maple_state.ports[p].units[u].valid); + assert(!state->ports[p].units[u].valid); } } } /* Check the sub-devices for a top-level port */ -static void vbl_chk_subdevs(int p, uint8 newmask) { +static void vbl_chk_subdevs(maple_state_t *state, int p, uint8 newmask) { int oldmask, chkmask, u; /* Get the old mask */ - oldmask = maple_state.ports[p].units[0].dev_mask; + oldmask = state->ports[p].units[0].dev_mask; /* Is it different from the new mask? */ if(oldmask != newmask) { @@ -73,16 +73,16 @@ static void vbl_chk_subdevs(int p, uint8 newmask) { device. Do a driver detach on it. */ if(!(oldmask & chkmask) && (newmask & chkmask)) { /* Send a further query */ - vbl_send_devinfo(p, u); + vbl_send_devinfo(state, p, u); } else if((oldmask & chkmask) && !(newmask & chkmask)) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |