Match and link dvdqueue

Former-commit-id: 8f4355881b
This commit is contained in:
Phillip Stephens 2023-01-12 17:51:32 -08:00
parent ef7c00113a
commit 4b8975fa40
3 changed files with 183 additions and 41 deletions

View File

@ -2,16 +2,15 @@
.section .bss .section .bss
.balign 8 .balign 8
.global lbl_80540BF8 .obj WaitingQueue, local
lbl_80540BF8:
.skip 0x20 .skip 0x20
.endobj WaitingQueue
.section .text, "ax" .section .text, "ax"
.global __DVDClearWaitingQueue .fn __DVDClearWaitingQueue
__DVDClearWaitingQueue: /* 803748B8 00371818 3C 60 80 54 */ lis r3, WaitingQueue@ha
/* 803748B8 00371818 3C 60 80 54 */ lis r3, lbl_80540BF8@ha /* 803748BC 0037181C 38 63 0B F8 */ addi r3, r3, WaitingQueue@l
/* 803748BC 0037181C 38 63 0B F8 */ addi r3, r3, lbl_80540BF8@l
/* 803748C0 00371820 90 63 00 00 */ stw r3, 0(r3) /* 803748C0 00371820 90 63 00 00 */ stw r3, 0(r3)
/* 803748C4 00371824 38 A3 00 08 */ addi r5, r3, 8 /* 803748C4 00371824 38 A3 00 08 */ addi r5, r3, 8
/* 803748C8 00371828 38 83 00 10 */ addi r4, r3, 0x10 /* 803748C8 00371828 38 83 00 10 */ addi r4, r3, 0x10
@ -24,9 +23,9 @@ __DVDClearWaitingQueue:
/* 803748E4 00371844 90 63 00 00 */ stw r3, 0(r3) /* 803748E4 00371844 90 63 00 00 */ stw r3, 0(r3)
/* 803748E8 00371848 90 63 00 04 */ stw r3, 4(r3) /* 803748E8 00371848 90 63 00 04 */ stw r3, 4(r3)
/* 803748EC 0037184C 4E 80 00 20 */ blr /* 803748EC 0037184C 4E 80 00 20 */ blr
.endfn __DVDClearWaitingQueue
.global __DVDPushWaitingQueue .fn __DVDPushWaitingQueue
__DVDPushWaitingQueue:
/* 803748F0 00371850 7C 08 02 A6 */ mflr r0 /* 803748F0 00371850 7C 08 02 A6 */ mflr r0
/* 803748F4 00371854 90 01 00 04 */ stw r0, 4(r1) /* 803748F4 00371854 90 01 00 04 */ stw r0, 4(r1)
/* 803748F8 00371858 94 21 FF E8 */ stwu r1, -0x18(r1) /* 803748F8 00371858 94 21 FF E8 */ stwu r1, -0x18(r1)
@ -35,9 +34,9 @@ __DVDPushWaitingQueue:
/* 80374904 00371864 93 C1 00 10 */ stw r30, 0x10(r1) /* 80374904 00371864 93 C1 00 10 */ stw r30, 0x10(r1)
/* 80374908 00371868 3B C3 00 00 */ addi r30, r3, 0 /* 80374908 00371868 3B C3 00 00 */ addi r30, r3, 0
/* 8037490C 0037186C 48 00 CD 55 */ bl OSDisableInterrupts /* 8037490C 0037186C 48 00 CD 55 */ bl OSDisableInterrupts
/* 80374910 00371870 3C 80 80 54 */ lis r4, lbl_80540BF8@ha /* 80374910 00371870 3C 80 80 54 */ lis r4, WaitingQueue@ha
/* 80374914 00371874 57 C5 18 38 */ slwi r5, r30, 3 /* 80374914 00371874 57 C5 18 38 */ slwi r5, r30, 3
/* 80374918 00371878 38 04 0B F8 */ addi r0, r4, lbl_80540BF8@l /* 80374918 00371878 38 04 0B F8 */ addi r0, r4, WaitingQueue@l
/* 8037491C 0037187C 7C A0 2A 14 */ add r5, r0, r5 /* 8037491C 0037187C 7C A0 2A 14 */ add r5, r0, r5
/* 80374920 00371880 80 85 00 04 */ lwz r4, 4(r5) /* 80374920 00371880 80 85 00 04 */ lwz r4, 4(r5)
/* 80374924 00371884 93 E4 00 00 */ stw r31, 0(r4) /* 80374924 00371884 93 E4 00 00 */ stw r31, 0(r4)
@ -53,28 +52,28 @@ __DVDPushWaitingQueue:
/* 8037494C 003718AC 38 21 00 18 */ addi r1, r1, 0x18 /* 8037494C 003718AC 38 21 00 18 */ addi r1, r1, 0x18
/* 80374950 003718B0 7C 08 03 A6 */ mtlr r0 /* 80374950 003718B0 7C 08 03 A6 */ mtlr r0
/* 80374954 003718B4 4E 80 00 20 */ blr /* 80374954 003718B4 4E 80 00 20 */ blr
.endfn __DVDPushWaitingQueue
.global __DVDPopWaitingQueue .fn __DVDPopWaitingQueue
__DVDPopWaitingQueue:
/* 80374958 003718B8 7C 08 02 A6 */ mflr r0 /* 80374958 003718B8 7C 08 02 A6 */ mflr r0
/* 8037495C 003718BC 90 01 00 04 */ stw r0, 4(r1) /* 8037495C 003718BC 90 01 00 04 */ stw r0, 4(r1)
/* 80374960 003718C0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80374960 003718C0 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80374964 003718C4 93 E1 00 0C */ stw r31, 0xc(r1) /* 80374964 003718C4 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80374968 003718C8 48 00 CC F9 */ bl OSDisableInterrupts /* 80374968 003718C8 48 00 CC F9 */ bl OSDisableInterrupts
/* 8037496C 003718CC 38 00 00 04 */ li r0, 4 /* 8037496C 003718CC 38 00 00 04 */ li r0, 4
/* 80374970 003718D0 3C 80 80 54 */ lis r4, lbl_80540BF8@ha /* 80374970 003718D0 3C 80 80 54 */ lis r4, WaitingQueue@ha
/* 80374974 003718D4 7C 09 03 A6 */ mtctr r0 /* 80374974 003718D4 7C 09 03 A6 */ mtctr r0
/* 80374978 003718D8 38 84 0B F8 */ addi r4, r4, lbl_80540BF8@l /* 80374978 003718D8 38 84 0B F8 */ addi r4, r4, WaitingQueue@l
/* 8037497C 003718DC 3B E0 00 00 */ li r31, 0 /* 8037497C 003718DC 3B E0 00 00 */ li r31, 0
lbl_80374980: .L_80374980:
/* 80374980 003718E0 80 04 00 00 */ lwz r0, 0(r4) /* 80374980 003718E0 80 04 00 00 */ lwz r0, 0(r4)
/* 80374984 003718E4 7C 00 20 40 */ cmplw r0, r4 /* 80374984 003718E4 7C 00 20 40 */ cmplw r0, r4
/* 80374988 003718E8 41 82 00 48 */ beq lbl_803749D0 /* 80374988 003718E8 41 82 00 48 */ beq .L_803749D0
/* 8037498C 003718EC 48 00 CC FD */ bl OSRestoreInterrupts /* 8037498C 003718EC 48 00 CC FD */ bl OSRestoreInterrupts
/* 80374990 003718F0 48 00 CC D1 */ bl OSDisableInterrupts /* 80374990 003718F0 48 00 CC D1 */ bl OSDisableInterrupts
/* 80374994 003718F4 3C 80 80 54 */ lis r4, lbl_80540BF8@ha /* 80374994 003718F4 3C 80 80 54 */ lis r4, WaitingQueue@ha
/* 80374998 003718F8 57 E5 18 38 */ slwi r5, r31, 3 /* 80374998 003718F8 57 E5 18 38 */ slwi r5, r31, 3
/* 8037499C 003718FC 38 04 0B F8 */ addi r0, r4, lbl_80540BF8@l /* 8037499C 003718FC 38 04 0B F8 */ addi r0, r4, WaitingQueue@l
/* 803749A0 00371900 7C A0 2A 14 */ add r5, r0, r5 /* 803749A0 00371900 7C A0 2A 14 */ add r5, r0, r5
/* 803749A4 00371904 83 E5 00 00 */ lwz r31, 0(r5) /* 803749A4 00371904 83 E5 00 00 */ lwz r31, 0(r5)
/* 803749A8 00371908 80 1F 00 00 */ lwz r0, 0(r31) /* 803749A8 00371908 80 1F 00 00 */ lwz r0, 0(r31)
@ -86,50 +85,50 @@ lbl_80374980:
/* 803749C0 00371920 90 1F 00 00 */ stw r0, 0(r31) /* 803749C0 00371920 90 1F 00 00 */ stw r0, 0(r31)
/* 803749C4 00371924 7F E3 FB 78 */ mr r3, r31 /* 803749C4 00371924 7F E3 FB 78 */ mr r3, r31
/* 803749C8 00371928 90 1F 00 04 */ stw r0, 4(r31) /* 803749C8 00371928 90 1F 00 04 */ stw r0, 4(r31)
/* 803749CC 0037192C 48 00 00 18 */ b lbl_803749E4 /* 803749CC 0037192C 48 00 00 18 */ b .L_803749E4
lbl_803749D0: .L_803749D0:
/* 803749D0 00371930 38 84 00 08 */ addi r4, r4, 8 /* 803749D0 00371930 38 84 00 08 */ addi r4, r4, 8
/* 803749D4 00371934 3B FF 00 01 */ addi r31, r31, 1 /* 803749D4 00371934 3B FF 00 01 */ addi r31, r31, 1
/* 803749D8 00371938 42 00 FF A8 */ bdnz lbl_80374980 /* 803749D8 00371938 42 00 FF A8 */ bdnz .L_80374980
/* 803749DC 0037193C 48 00 CC AD */ bl OSRestoreInterrupts /* 803749DC 0037193C 48 00 CC AD */ bl OSRestoreInterrupts
/* 803749E0 00371940 38 60 00 00 */ li r3, 0 /* 803749E0 00371940 38 60 00 00 */ li r3, 0
lbl_803749E4: .L_803749E4:
/* 803749E4 00371944 80 01 00 14 */ lwz r0, 0x14(r1) /* 803749E4 00371944 80 01 00 14 */ lwz r0, 0x14(r1)
/* 803749E8 00371948 83 E1 00 0C */ lwz r31, 0xc(r1) /* 803749E8 00371948 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 803749EC 0037194C 38 21 00 10 */ addi r1, r1, 0x10 /* 803749EC 0037194C 38 21 00 10 */ addi r1, r1, 0x10
/* 803749F0 00371950 7C 08 03 A6 */ mtlr r0 /* 803749F0 00371950 7C 08 03 A6 */ mtlr r0
/* 803749F4 00371954 4E 80 00 20 */ blr /* 803749F4 00371954 4E 80 00 20 */ blr
.endfn __DVDPopWaitingQueue
.global __DVDCheckWaitingQueue .fn __DVDCheckWaitingQueue
__DVDCheckWaitingQueue:
/* 803749F8 00371958 7C 08 02 A6 */ mflr r0 /* 803749F8 00371958 7C 08 02 A6 */ mflr r0
/* 803749FC 0037195C 90 01 00 04 */ stw r0, 4(r1) /* 803749FC 0037195C 90 01 00 04 */ stw r0, 4(r1)
/* 80374A00 00371960 94 21 FF F8 */ stwu r1, -8(r1) /* 80374A00 00371960 94 21 FF F8 */ stwu r1, -8(r1)
/* 80374A04 00371964 48 00 CC 5D */ bl OSDisableInterrupts /* 80374A04 00371964 48 00 CC 5D */ bl OSDisableInterrupts
/* 80374A08 00371968 38 00 00 04 */ li r0, 4 /* 80374A08 00371968 38 00 00 04 */ li r0, 4
/* 80374A0C 0037196C 3C 80 80 54 */ lis r4, lbl_80540BF8@ha /* 80374A0C 0037196C 3C 80 80 54 */ lis r4, WaitingQueue@ha
/* 80374A10 00371970 7C 09 03 A6 */ mtctr r0 /* 80374A10 00371970 7C 09 03 A6 */ mtctr r0
/* 80374A14 00371974 38 84 0B F8 */ addi r4, r4, lbl_80540BF8@l /* 80374A14 00371974 38 84 0B F8 */ addi r4, r4, WaitingQueue@l
lbl_80374A18: .L_80374A18:
/* 80374A18 00371978 80 04 00 00 */ lwz r0, 0(r4) /* 80374A18 00371978 80 04 00 00 */ lwz r0, 0(r4)
/* 80374A1C 0037197C 7C 00 20 40 */ cmplw r0, r4 /* 80374A1C 0037197C 7C 00 20 40 */ cmplw r0, r4
/* 80374A20 00371980 41 82 00 10 */ beq lbl_80374A30 /* 80374A20 00371980 41 82 00 10 */ beq .L_80374A30
/* 80374A24 00371984 48 00 CC 65 */ bl OSRestoreInterrupts /* 80374A24 00371984 48 00 CC 65 */ bl OSRestoreInterrupts
/* 80374A28 00371988 38 60 00 01 */ li r3, 1 /* 80374A28 00371988 38 60 00 01 */ li r3, 1
/* 80374A2C 0037198C 48 00 00 14 */ b lbl_80374A40 /* 80374A2C 0037198C 48 00 00 14 */ b .L_80374A40
lbl_80374A30: .L_80374A30:
/* 80374A30 00371990 38 84 00 08 */ addi r4, r4, 8 /* 80374A30 00371990 38 84 00 08 */ addi r4, r4, 8
/* 80374A34 00371994 42 00 FF E4 */ bdnz lbl_80374A18 /* 80374A34 00371994 42 00 FF E4 */ bdnz .L_80374A18
/* 80374A38 00371998 48 00 CC 51 */ bl OSRestoreInterrupts /* 80374A38 00371998 48 00 CC 51 */ bl OSRestoreInterrupts
/* 80374A3C 0037199C 38 60 00 00 */ li r3, 0 /* 80374A3C 0037199C 38 60 00 00 */ li r3, 0
lbl_80374A40: .L_80374A40:
/* 80374A40 003719A0 80 01 00 0C */ lwz r0, 0xc(r1) /* 80374A40 003719A0 80 01 00 0C */ lwz r0, 0xc(r1)
/* 80374A44 003719A4 38 21 00 08 */ addi r1, r1, 8 /* 80374A44 003719A4 38 21 00 08 */ addi r1, r1, 8
/* 80374A48 003719A8 7C 08 03 A6 */ mtlr r0 /* 80374A48 003719A8 7C 08 03 A6 */ mtlr r0
/* 80374A4C 003719AC 4E 80 00 20 */ blr /* 80374A4C 003719AC 4E 80 00 20 */ blr
.endfn __DVDCheckWaitingQueue
.global __DVDDequeueWaitingQueue .fn __DVDDequeueWaitingQueue
__DVDDequeueWaitingQueue:
/* 80374A50 003719B0 7C 08 02 A6 */ mflr r0 /* 80374A50 003719B0 7C 08 02 A6 */ mflr r0
/* 80374A54 003719B4 90 01 00 04 */ stw r0, 4(r1) /* 80374A54 003719B4 90 01 00 04 */ stw r0, 4(r1)
/* 80374A58 003719B8 94 21 FF E8 */ stwu r1, -0x18(r1) /* 80374A58 003719B8 94 21 FF E8 */ stwu r1, -0x18(r1)
@ -139,21 +138,22 @@ __DVDDequeueWaitingQueue:
/* 80374A68 003719C8 80 9F 00 04 */ lwz r4, 4(r31) /* 80374A68 003719C8 80 9F 00 04 */ lwz r4, 4(r31)
/* 80374A6C 003719CC 80 BF 00 00 */ lwz r5, 0(r31) /* 80374A6C 003719CC 80 BF 00 00 */ lwz r5, 0(r31)
/* 80374A70 003719D0 28 04 00 00 */ cmplwi r4, 0 /* 80374A70 003719D0 28 04 00 00 */ cmplwi r4, 0
/* 80374A74 003719D4 41 82 00 0C */ beq lbl_80374A80 /* 80374A74 003719D4 41 82 00 0C */ beq .L_80374A80
/* 80374A78 003719D8 28 05 00 00 */ cmplwi r5, 0 /* 80374A78 003719D8 28 05 00 00 */ cmplwi r5, 0
/* 80374A7C 003719DC 40 82 00 10 */ bne lbl_80374A8C /* 80374A7C 003719DC 40 82 00 10 */ bne .L_80374A8C
lbl_80374A80: .L_80374A80:
/* 80374A80 003719E0 48 00 CC 09 */ bl OSRestoreInterrupts /* 80374A80 003719E0 48 00 CC 09 */ bl OSRestoreInterrupts
/* 80374A84 003719E4 38 60 00 00 */ li r3, 0 /* 80374A84 003719E4 38 60 00 00 */ li r3, 0
/* 80374A88 003719E8 48 00 00 14 */ b lbl_80374A9C /* 80374A88 003719E8 48 00 00 14 */ b .L_80374A9C
lbl_80374A8C: .L_80374A8C:
/* 80374A8C 003719EC 90 A4 00 00 */ stw r5, 0(r4) /* 80374A8C 003719EC 90 A4 00 00 */ stw r5, 0(r4)
/* 80374A90 003719F0 90 85 00 04 */ stw r4, 4(r5) /* 80374A90 003719F0 90 85 00 04 */ stw r4, 4(r5)
/* 80374A94 003719F4 48 00 CB F5 */ bl OSRestoreInterrupts /* 80374A94 003719F4 48 00 CB F5 */ bl OSRestoreInterrupts
/* 80374A98 003719F8 38 60 00 01 */ li r3, 1 /* 80374A98 003719F8 38 60 00 01 */ li r3, 1
lbl_80374A9C: .L_80374A9C:
/* 80374A9C 003719FC 80 01 00 1C */ lwz r0, 0x1c(r1) /* 80374A9C 003719FC 80 01 00 1C */ lwz r0, 0x1c(r1)
/* 80374AA0 00371A00 83 E1 00 14 */ lwz r31, 0x14(r1) /* 80374AA0 00371A00 83 E1 00 14 */ lwz r31, 0x14(r1)
/* 80374AA4 00371A04 38 21 00 18 */ addi r1, r1, 0x18 /* 80374AA4 00371A04 38 21 00 18 */ addi r1, r1, 0x18
/* 80374AA8 00371A08 7C 08 03 A6 */ mtlr r0 /* 80374AA8 00371A08 7C 08 03 A6 */ mtlr r0
/* 80374AAC 00371A0C 4E 80 00 20 */ blr /* 80374AAC 00371A0C 4E 80 00 20 */ blr
.endfn __DVDDequeueWaitingQueue

View File

@ -754,7 +754,7 @@ LIBS = [
"Dolphin/dvd/dvdlow", "Dolphin/dvd/dvdlow",
["Dolphin/dvd/dvdfs", True], ["Dolphin/dvd/dvdfs", True],
["Dolphin/dvd/dvd", False], ["Dolphin/dvd/dvd", False],
"Dolphin/dvd/dvdqueue", ["Dolphin/dvd/dvdqueue", True],
["Dolphin/dvd/dvderror", True], ["Dolphin/dvd/dvderror", True],
["Dolphin/dvd/dvdidutils", True], ["Dolphin/dvd/dvdidutils", True],
["Dolphin/dvd/dvdfatal", True], ["Dolphin/dvd/dvdfatal", True],

142
src/Dolphin/dvd/dvdqueue.c Normal file
View File

@ -0,0 +1,142 @@
#include "dolphin/DVDPriv.h"
#define MAX_QUEUES 4
typedef struct {
DVDCommandBlock* next;
DVDCommandBlock* prev;
} DVDQueue;
static DVDQueue WaitingQueue[MAX_QUEUES];
void __DVDClearWaitingQueue(void) {
u32 i;
for (i = 0; i < MAX_QUEUES; i++) {
DVDCommandBlock* q;
q = (DVDCommandBlock*)&(WaitingQueue[i]);
q->next = q;
q->prev = q;
}
}
BOOL __DVDPushWaitingQueue(s32 prio, DVDCommandBlock* block) {
BOOL enabled;
DVDCommandBlock* q;
enabled = OSDisableInterrupts();
q = (DVDCommandBlock*)&(WaitingQueue[prio]);
q->prev->next = block;
block->prev = q->prev;
block->next = q;
q->prev = block;
OSRestoreInterrupts(enabled);
return TRUE;
}
static DVDCommandBlock* PopWaitingQueuePrio(s32 prio) {
DVDCommandBlock* tmp;
BOOL enabled;
DVDCommandBlock* q;
enabled = OSDisableInterrupts();
q = (DVDCommandBlock*)&(WaitingQueue[prio]);
tmp = q->next;
q->next = tmp->next;
tmp->next->prev = q;
OSRestoreInterrupts(enabled);
tmp->next = (DVDCommandBlock*)NULL;
tmp->prev = (DVDCommandBlock*)NULL;
return tmp;
}
DVDCommandBlock* __DVDPopWaitingQueue(void) {
u32 i;
BOOL enabled;
DVDCommandBlock* q;
enabled = OSDisableInterrupts();
for (i = 0; i < MAX_QUEUES; i++) {
q = (DVDCommandBlock*)&(WaitingQueue[i]);
if (q->next != q) {
OSRestoreInterrupts(enabled);
return PopWaitingQueuePrio((s32)i);
}
}
OSRestoreInterrupts(enabled);
return (DVDCommandBlock*)NULL;
}
BOOL __DVDCheckWaitingQueue(void) {
u32 i;
BOOL enabled;
DVDCommandBlock* q;
enabled = OSDisableInterrupts();
for (i = 0; i < MAX_QUEUES; i++) {
q = (DVDCommandBlock*)&(WaitingQueue[i]);
if (q->next != q) {
OSRestoreInterrupts(enabled);
return TRUE;
}
}
OSRestoreInterrupts(enabled);
return FALSE;
}
BOOL __DVDDequeueWaitingQueue(DVDCommandBlock* block) {
BOOL enabled;
DVDCommandBlock* prev;
DVDCommandBlock* next;
enabled = OSDisableInterrupts();
prev = block->prev;
next = block->next;
if ((prev == (DVDCommandBlock*)NULL) || (next == (DVDCommandBlock*)NULL)) {
OSRestoreInterrupts(enabled);
return FALSE;
}
prev->next = next;
next->prev = prev;
OSRestoreInterrupts(enabled);
return TRUE;
}
BOOL __DVDIsBlockInWaitingQueue(DVDCommandBlock* block) {
u32 i;
DVDCommandBlock* start;
DVDCommandBlock* q;
for (i = 0; i < MAX_QUEUES; i++) {
start = (DVDCommandBlock*)&(WaitingQueue[i]);
if (start->next != start) {
for (q = start->next; q != start; q = q->next) {
if (q == block)
return TRUE;
}
}
}
return FALSE;
}