donut-decomp/asm/os/OSMutex.s
2022-10-17 09:03:07 +01:00

255 lines
11 KiB
ArmAsm

.include "macros.inc"
.section .text, "ax" # 0x80006A00 - 0x80406260 ; 0x003FF860
.global OSInitMutex
OSInitMutex:
/* 80022B60 0001E9A0 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80022B64 0001E9A4 7C 08 02 A6 */ mflr r0
/* 80022B68 0001E9A8 90 01 00 14 */ stw r0, 0x14(r1)
/* 80022B6C 0001E9AC 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80022B70 0001E9B0 7C 7F 1B 78 */ mr r31, r3
/* 80022B74 0001E9B4 48 00 1B CD */ bl OSInitThreadQueue
/* 80022B78 0001E9B8 38 00 00 00 */ li r0, 0x0
/* 80022B7C 0001E9BC 90 1F 00 08 */ stw r0, 0x8(r31)
/* 80022B80 0001E9C0 90 1F 00 0C */ stw r0, 0xc(r31)
/* 80022B84 0001E9C4 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 80022B88 0001E9C8 80 01 00 14 */ lwz r0, 0x14(r1)
/* 80022B8C 0001E9CC 7C 08 03 A6 */ mtlr r0
/* 80022B90 0001E9D0 38 21 00 10 */ addi r1, r1, 0x10
/* 80022B94 0001E9D4 4E 80 00 20 */ blr
/* 80022B98 0001E9D8 00 00 00 00 */ .4byte 0x00000000
/* 80022B9C 0001E9DC 00 00 00 00 */ .4byte 0x00000000
.global OSLockMutex
OSLockMutex:
/* 80022BA0 0001E9E0 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80022BA4 0001E9E4 7C 08 02 A6 */ mflr r0
/* 80022BA8 0001E9E8 90 01 00 24 */ stw r0, 0x24(r1)
/* 80022BAC 0001E9EC 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 80022BB0 0001E9F0 93 C1 00 18 */ stw r30, 0x18(r1)
/* 80022BB4 0001E9F4 93 A1 00 14 */ stw r29, 0x14(r1)
/* 80022BB8 0001E9F8 93 81 00 10 */ stw r28, 0x10(r1)
/* 80022BBC 0001E9FC 7C 7C 1B 78 */ mr r28, r3
/* 80022BC0 0001EA00 4B FF EC 61 */ bl OSDisableInterrupts
/* 80022BC4 0001EA04 7C 7D 1B 78 */ mr r29, r3
/* 80022BC8 0001EA08 48 00 1B 89 */ bl OSGetCurrentThread
/* 80022BCC 0001EA0C 7C 7E 1B 78 */ mr r30, r3
/* 80022BD0 0001EA10 3B E0 00 00 */ li r31, 0x0
.global lbl_80022BD4
lbl_80022BD4:
/* 80022BD4 0001EA14 80 1C 00 08 */ lwz r0, 0x8(r28)
/* 80022BD8 0001EA18 2C 00 00 00 */ cmpwi r0, 0x0
/* 80022BDC 0001EA1C 40 82 00 40 */ bne lbl_80022C1C
/* 80022BE0 0001EA20 80 7C 00 0C */ lwz r3, 0xc(r28)
/* 80022BE4 0001EA24 93 DC 00 08 */ stw r30, 0x8(r28)
/* 80022BE8 0001EA28 38 03 00 01 */ addi r0, r3, 0x1
/* 80022BEC 0001EA2C 90 1C 00 0C */ stw r0, 0xc(r28)
/* 80022BF0 0001EA30 80 7E 02 F8 */ lwz r3, 0x2f8(r30)
/* 80022BF4 0001EA34 2C 03 00 00 */ cmpwi r3, 0x0
/* 80022BF8 0001EA38 40 82 00 0C */ bne lbl_80022C04
/* 80022BFC 0001EA3C 93 9E 02 F4 */ stw r28, 0x2f4(r30)
/* 80022C00 0001EA40 48 00 00 08 */ b lbl_80022C08
.global lbl_80022C04
lbl_80022C04:
/* 80022C04 0001EA44 93 83 00 10 */ stw r28, 0x10(r3)
.global lbl_80022C08
lbl_80022C08:
/* 80022C08 0001EA48 38 00 00 00 */ li r0, 0x0
/* 80022C0C 0001EA4C 90 7C 00 14 */ stw r3, 0x14(r28)
/* 80022C10 0001EA50 90 1C 00 10 */ stw r0, 0x10(r28)
/* 80022C14 0001EA54 93 9E 02 F8 */ stw r28, 0x2f8(r30)
/* 80022C18 0001EA58 48 00 00 3C */ b lbl_80022C54
.global lbl_80022C1C
lbl_80022C1C:
/* 80022C1C 0001EA5C 7C 00 F0 40 */ cmplw r0, r30
/* 80022C20 0001EA60 40 82 00 14 */ bne lbl_80022C34
/* 80022C24 0001EA64 80 7C 00 0C */ lwz r3, 0xc(r28)
/* 80022C28 0001EA68 38 03 00 01 */ addi r0, r3, 0x1
/* 80022C2C 0001EA6C 90 1C 00 0C */ stw r0, 0xc(r28)
/* 80022C30 0001EA70 48 00 00 24 */ b lbl_80022C54
.global lbl_80022C34
lbl_80022C34:
/* 80022C34 0001EA74 93 9E 02 F0 */ stw r28, 0x2f0(r30)
/* 80022C38 0001EA78 80 7C 00 08 */ lwz r3, 0x8(r28)
/* 80022C3C 0001EA7C 80 9E 02 D0 */ lwz r4, 0x2d0(r30)
/* 80022C40 0001EA80 48 00 1E 31 */ bl __OSPromoteThread
/* 80022C44 0001EA84 7F 83 E3 78 */ mr r3, r28
/* 80022C48 0001EA88 48 00 2B C9 */ bl OSSleepThread
/* 80022C4C 0001EA8C 93 FE 02 F0 */ stw r31, 0x2f0(r30)
/* 80022C50 0001EA90 4B FF FF 84 */ b lbl_80022BD4
.global lbl_80022C54
lbl_80022C54:
/* 80022C54 0001EA94 7F A3 EB 78 */ mr r3, r29
/* 80022C58 0001EA98 4B FF EC 09 */ bl OSRestoreInterrupts
/* 80022C5C 0001EA9C 80 01 00 24 */ lwz r0, 0x24(r1)
/* 80022C60 0001EAA0 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 80022C64 0001EAA4 83 C1 00 18 */ lwz r30, 0x18(r1)
/* 80022C68 0001EAA8 83 A1 00 14 */ lwz r29, 0x14(r1)
/* 80022C6C 0001EAAC 83 81 00 10 */ lwz r28, 0x10(r1)
/* 80022C70 0001EAB0 7C 08 03 A6 */ mtlr r0
/* 80022C74 0001EAB4 38 21 00 20 */ addi r1, r1, 0x20
/* 80022C78 0001EAB8 4E 80 00 20 */ blr
/* 80022C7C 0001EABC 00 00 00 00 */ .4byte 0x00000000
.global OSUnlockMutex
OSUnlockMutex:
/* 80022C80 0001EAC0 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80022C84 0001EAC4 7C 08 02 A6 */ mflr r0
/* 80022C88 0001EAC8 90 01 00 24 */ stw r0, 0x24(r1)
/* 80022C8C 0001EACC 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 80022C90 0001EAD0 93 C1 00 18 */ stw r30, 0x18(r1)
/* 80022C94 0001EAD4 93 A1 00 14 */ stw r29, 0x14(r1)
/* 80022C98 0001EAD8 7C 7D 1B 78 */ mr r29, r3
/* 80022C9C 0001EADC 4B FF EB 85 */ bl OSDisableInterrupts
/* 80022CA0 0001EAE0 7C 7F 1B 78 */ mr r31, r3
/* 80022CA4 0001EAE4 48 00 1A AD */ bl OSGetCurrentThread
/* 80022CA8 0001EAE8 80 1D 00 08 */ lwz r0, 0x8(r29)
/* 80022CAC 0001EAEC 7C 7E 1B 78 */ mr r30, r3
/* 80022CB0 0001EAF0 7C 00 18 40 */ cmplw r0, r3
/* 80022CB4 0001EAF4 40 82 00 70 */ bne lbl_80022D24
/* 80022CB8 0001EAF8 80 1D 00 0C */ lwz r0, 0xc(r29)
/* 80022CBC 0001EAFC 34 00 FF FF */ addic. r0, r0, -0x1
/* 80022CC0 0001EB00 90 1D 00 0C */ stw r0, 0xc(r29)
/* 80022CC4 0001EB04 40 82 00 60 */ bne lbl_80022D24
/* 80022CC8 0001EB08 80 9D 00 10 */ lwz r4, 0x10(r29)
/* 80022CCC 0001EB0C 80 BD 00 14 */ lwz r5, 0x14(r29)
/* 80022CD0 0001EB10 2C 04 00 00 */ cmpwi r4, 0x0
/* 80022CD4 0001EB14 40 82 00 0C */ bne lbl_80022CE0
/* 80022CD8 0001EB18 90 A3 02 F8 */ stw r5, 0x2f8(r3)
/* 80022CDC 0001EB1C 48 00 00 08 */ b lbl_80022CE4
.global lbl_80022CE0
lbl_80022CE0:
/* 80022CE0 0001EB20 90 A4 00 14 */ stw r5, 0x14(r4)
.global lbl_80022CE4
lbl_80022CE4:
/* 80022CE4 0001EB24 2C 05 00 00 */ cmpwi r5, 0x0
/* 80022CE8 0001EB28 40 82 00 0C */ bne lbl_80022CF4
/* 80022CEC 0001EB2C 90 83 02 F4 */ stw r4, 0x2f4(r3)
/* 80022CF0 0001EB30 48 00 00 08 */ b lbl_80022CF8
.global lbl_80022CF4
lbl_80022CF4:
/* 80022CF4 0001EB34 90 85 00 10 */ stw r4, 0x10(r5)
.global lbl_80022CF8
lbl_80022CF8:
/* 80022CF8 0001EB38 38 00 00 00 */ li r0, 0x0
/* 80022CFC 0001EB3C 90 1D 00 08 */ stw r0, 0x8(r29)
/* 80022D00 0001EB40 80 83 02 D0 */ lwz r4, 0x2d0(r3)
/* 80022D04 0001EB44 80 03 02 D4 */ lwz r0, 0x2d4(r3)
/* 80022D08 0001EB48 7C 04 00 00 */ cmpw r4, r0
/* 80022D0C 0001EB4C 40 80 00 10 */ bge lbl_80022D1C
/* 80022D10 0001EB50 7F C3 F3 78 */ mr r3, r30
/* 80022D14 0001EB54 48 00 1B 6D */ bl __OSGetEffectivePriority
/* 80022D18 0001EB58 90 7E 02 D0 */ stw r3, 0x2d0(r30)
.global lbl_80022D1C
lbl_80022D1C:
/* 80022D1C 0001EB5C 7F A3 EB 78 */ mr r3, r29
/* 80022D20 0001EB60 48 00 2B E1 */ bl OSWakeupThread
.global lbl_80022D24
lbl_80022D24:
/* 80022D24 0001EB64 7F E3 FB 78 */ mr r3, r31
/* 80022D28 0001EB68 4B FF EB 39 */ bl OSRestoreInterrupts
/* 80022D2C 0001EB6C 80 01 00 24 */ lwz r0, 0x24(r1)
/* 80022D30 0001EB70 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 80022D34 0001EB74 83 C1 00 18 */ lwz r30, 0x18(r1)
/* 80022D38 0001EB78 83 A1 00 14 */ lwz r29, 0x14(r1)
/* 80022D3C 0001EB7C 7C 08 03 A6 */ mtlr r0
/* 80022D40 0001EB80 38 21 00 20 */ addi r1, r1, 0x20
/* 80022D44 0001EB84 4E 80 00 20 */ blr
/* 80022D48 0001EB88 00 00 00 00 */ .4byte 0x00000000
/* 80022D4C 0001EB8C 00 00 00 00 */ .4byte 0x00000000
.global __OSUnlockAllMutex
__OSUnlockAllMutex:
/* 80022D50 0001EB90 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80022D54 0001EB94 7C 08 02 A6 */ mflr r0
/* 80022D58 0001EB98 90 01 00 14 */ stw r0, 0x14(r1)
/* 80022D5C 0001EB9C 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80022D60 0001EBA0 3B E0 00 00 */ li r31, 0x0
/* 80022D64 0001EBA4 93 C1 00 08 */ stw r30, 0x8(r1)
/* 80022D68 0001EBA8 7C 7E 1B 78 */ mr r30, r3
/* 80022D6C 0001EBAC 48 00 00 2C */ b lbl_80022D98
.global lbl_80022D70
lbl_80022D70:
/* 80022D70 0001EBB0 80 83 00 10 */ lwz r4, 0x10(r3)
/* 80022D74 0001EBB4 2C 04 00 00 */ cmpwi r4, 0x0
/* 80022D78 0001EBB8 40 82 00 0C */ bne lbl_80022D84
/* 80022D7C 0001EBBC 93 FE 02 F8 */ stw r31, 0x2f8(r30)
/* 80022D80 0001EBC0 48 00 00 08 */ b lbl_80022D88
.global lbl_80022D84
lbl_80022D84:
/* 80022D84 0001EBC4 93 E4 00 14 */ stw r31, 0x14(r4)
.global lbl_80022D88
lbl_80022D88:
/* 80022D88 0001EBC8 90 9E 02 F4 */ stw r4, 0x2f4(r30)
/* 80022D8C 0001EBCC 93 E3 00 0C */ stw r31, 0xc(r3)
/* 80022D90 0001EBD0 93 E3 00 08 */ stw r31, 0x8(r3)
/* 80022D94 0001EBD4 48 00 2B 6D */ bl OSWakeupThread
.global lbl_80022D98
lbl_80022D98:
/* 80022D98 0001EBD8 80 7E 02 F4 */ lwz r3, 0x2f4(r30)
/* 80022D9C 0001EBDC 2C 03 00 00 */ cmpwi r3, 0x0
/* 80022DA0 0001EBE0 40 82 FF D0 */ bne lbl_80022D70
/* 80022DA4 0001EBE4 80 01 00 14 */ lwz r0, 0x14(r1)
/* 80022DA8 0001EBE8 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 80022DAC 0001EBEC 83 C1 00 08 */ lwz r30, 0x8(r1)
/* 80022DB0 0001EBF0 7C 08 03 A6 */ mtlr r0
/* 80022DB4 0001EBF4 38 21 00 10 */ addi r1, r1, 0x10
/* 80022DB8 0001EBF8 4E 80 00 20 */ blr
/* 80022DBC 0001EBFC 00 00 00 00 */ .4byte 0x00000000
.global OSTryLockMutex
OSTryLockMutex:
/* 80022DC0 0001EC00 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80022DC4 0001EC04 7C 08 02 A6 */ mflr r0
/* 80022DC8 0001EC08 90 01 00 24 */ stw r0, 0x24(r1)
/* 80022DCC 0001EC0C 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 80022DD0 0001EC10 93 C1 00 18 */ stw r30, 0x18(r1)
/* 80022DD4 0001EC14 93 A1 00 14 */ stw r29, 0x14(r1)
/* 80022DD8 0001EC18 7C 7D 1B 78 */ mr r29, r3
/* 80022DDC 0001EC1C 4B FF EA 45 */ bl OSDisableInterrupts
/* 80022DE0 0001EC20 7C 7F 1B 78 */ mr r31, r3
/* 80022DE4 0001EC24 48 00 19 6D */ bl OSGetCurrentThread
/* 80022DE8 0001EC28 80 1D 00 08 */ lwz r0, 0x8(r29)
/* 80022DEC 0001EC2C 2C 00 00 00 */ cmpwi r0, 0x0
/* 80022DF0 0001EC30 40 82 00 44 */ bne lbl_80022E34
/* 80022DF4 0001EC34 80 9D 00 0C */ lwz r4, 0xc(r29)
/* 80022DF8 0001EC38 90 7D 00 08 */ stw r3, 0x8(r29)
/* 80022DFC 0001EC3C 38 04 00 01 */ addi r0, r4, 0x1
/* 80022E00 0001EC40 90 1D 00 0C */ stw r0, 0xc(r29)
/* 80022E04 0001EC44 80 83 02 F8 */ lwz r4, 0x2f8(r3)
/* 80022E08 0001EC48 2C 04 00 00 */ cmpwi r4, 0x0
/* 80022E0C 0001EC4C 40 82 00 0C */ bne lbl_80022E18
/* 80022E10 0001EC50 93 A3 02 F4 */ stw r29, 0x2f4(r3)
/* 80022E14 0001EC54 48 00 00 08 */ b lbl_80022E1C
.global lbl_80022E18
lbl_80022E18:
/* 80022E18 0001EC58 93 A4 00 10 */ stw r29, 0x10(r4)
.global lbl_80022E1C
lbl_80022E1C:
/* 80022E1C 0001EC5C 38 00 00 00 */ li r0, 0x0
/* 80022E20 0001EC60 90 9D 00 14 */ stw r4, 0x14(r29)
/* 80022E24 0001EC64 3B C0 00 01 */ li r30, 0x1
/* 80022E28 0001EC68 90 1D 00 10 */ stw r0, 0x10(r29)
/* 80022E2C 0001EC6C 93 A3 02 F8 */ stw r29, 0x2f8(r3)
/* 80022E30 0001EC70 48 00 00 24 */ b lbl_80022E54
.global lbl_80022E34
lbl_80022E34:
/* 80022E34 0001EC74 7C 00 18 40 */ cmplw r0, r3
/* 80022E38 0001EC78 40 82 00 18 */ bne lbl_80022E50
/* 80022E3C 0001EC7C 80 7D 00 0C */ lwz r3, 0xc(r29)
/* 80022E40 0001EC80 3B C0 00 01 */ li r30, 0x1
/* 80022E44 0001EC84 38 03 00 01 */ addi r0, r3, 0x1
/* 80022E48 0001EC88 90 1D 00 0C */ stw r0, 0xc(r29)
/* 80022E4C 0001EC8C 48 00 00 08 */ b lbl_80022E54
.global lbl_80022E50
lbl_80022E50:
/* 80022E50 0001EC90 3B C0 00 00 */ li r30, 0x0
.global lbl_80022E54
lbl_80022E54:
/* 80022E54 0001EC94 7F E3 FB 78 */ mr r3, r31
/* 80022E58 0001EC98 4B FF EA 09 */ bl OSRestoreInterrupts
/* 80022E5C 0001EC9C 7F C3 F3 78 */ mr r3, r30
/* 80022E60 0001ECA0 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 80022E64 0001ECA4 83 C1 00 18 */ lwz r30, 0x18(r1)
/* 80022E68 0001ECA8 83 A1 00 14 */ lwz r29, 0x14(r1)
/* 80022E6C 0001ECAC 80 01 00 24 */ lwz r0, 0x24(r1)
/* 80022E70 0001ECB0 7C 08 03 A6 */ mtlr r0
/* 80022E74 0001ECB4 38 21 00 20 */ addi r1, r1, 0x20
/* 80022E78 0001ECB8 4E 80 00 20 */ blr
/* 80022E7C 0001ECBC 00 00 00 00 */ .4byte 0x00000000