Reverse userspace sync primitives

Namely queues, semaphores, critical regions, event groups and
"notifications". The MP calls implementing these services have been
named after their MPLibrary wrapper functions. This convention will be
followed in the future (no more NKCreateEvent).
This commit is contained in:
Elliot Nunn 2018-02-18 00:57:01 +08:00
parent f0696e5ceb
commit 7fdc813d8f
25 changed files with 4155 additions and 3404 deletions

View File

@ -19,7 +19,8 @@ BootstrapVersion ds.b 16 ; f00:f10 ; Bootstrap loader version info, from Config
; Gets called the "system context"
ContextBlock record 0,INCR
EmpiricalCpuFeatures ds.l 1 ; 000 ; (SPAC) copied from kdp by CreateTask
Flags ds.l 1 ; 000 ; (SPAC) copied from kdp by CreateTask
Enables ds.l 1 ; 004
org 0x5c
LA_EmulatorKernelTrapTable ds.l 1

View File

@ -327,7 +327,7 @@ VMDispatchCountTblPtr ds.l 1 ; 128, kdp+ee8
ds.l 1
ds.l 1
MPDispatchCountTblPtr ds.l 1 ; 134, kdp+ef4 ; ???????
AddrSpcSetCtr ds.l 1 ; 138, kdp+ef8 ; incremented by SetAddrSpcRegisters
AddrSpcSetCtr ds.l 1 ; 138, kdp+ef8 ; incremented by SetSpaceSRsAndBATs
IDCtr ds.l 1 ; 13c, kdp+efc
org 0x160

View File

@ -22,6 +22,7 @@
Process record 0,INCR
kIDClass equ 1
kFirstID equ 0x00010001
kSignature equ 'PROC'
;_______________________
@ -30,7 +31,39 @@ kSignature equ 'PROC'
ID ds.l 1 ; 00
Signature ds.l 1 ; 04 ; 'PROC'
Unused ds.l 1 ; 08 ; MPCall_5 does something here
Flags ds.l 1 ; 08 ; MPCall_5 does something here
kFlag0 equ 0
kFlag1 equ 1
kFlag2 equ 2
kFlag3 equ 3
kFlag4 equ 4
kFlag5 equ 5
kFlag6 equ 6
kFlag7 equ 7
kFlag8 equ 8
kFlag9 equ 9
kFlag10 equ 10
kFlag11 equ 11
kFlag12 equ 12
kFlag13 equ 13
kFlag14 equ 14
kFlag15 equ 15
kFlag16 equ 16
kFlag17 equ 17
kFlag18 equ 18
kFlag19 equ 19
kFlag20 equ 20
kFlag21 equ 21
kFlag22 equ 22
kFlag23 equ 23
kFlag24 equ 24
kFlag25 equ 25
kFlag26 equ 26
kFlag27 equ 27
kFlag28 equ 28
kFlag29 equ 29
kFlag30 equ 30
kFlag31 equ 31
SystemAddressSpaceID ds.l 1 ; 0c ; set by Init.s after addrspc creation
TaskCount ds.l 1 ; 10 ; incremented by CreateTask
SystemAddressSpacePtr ds.l 1 ; 14
@ -57,6 +90,7 @@ Size equ *
Task record 0,INCR
kIDClass equ 2
kFirstID equ 0x00020001
kSignature equ 'TASK'
;_______________________
@ -77,13 +111,46 @@ Signature ds.l 1 ; 004
QueueMember ds.l 4 ; 008:018 ; a task is always a member of a queue, e.g. the RDYQ
MysteryByte1 ds.b 1 ; 018 ; CreateTask sets 0 by default (blue = 2)
Priority ds.b 1 ; 019 ; CreateTask sets 2 by default
MysteryHalf ds.w 1 ; 01a
CPUIndex ds.w 1 ; 01a
Weight ds.l 1 ; 01c ; default is 100, blue gets 200, idle gets 1
Timer ds.b 64 ; 020:060
ProcessID ds.l 1 ; 060
ThingThatAlignVecHits ds.l 1 ; 064 ; IntAlignment is interested in bit 9, MPCalls 52/116 in bit 15
Flags ds.l 1 ; 064 ; IntAlignment is interested in bit 9, MPCalls 52/116 in bit 15
kFlag0 equ 0
kFlag1 equ 1
kFlag2 equ 2
kFlag3 equ 3
kFlag4 equ 4
kFlag5 equ 5
kFlag6 equ 6
kFlag7 equ 7
kFlag8 equ 8
kFlag9 equ 9
kFlag10 equ 10
kFlag11 equ 11
kFlag12 equ 12 ; set for idle1, idle2
kFlag13 equ 13
kFlag14 equ 14 ; set for blue, idle1
kFlagBlue equ 15
kFlag16 equ 16
kFlag17 equ 17
kFlag18 equ 18
kFlag19 equ 19
kFlag20 equ 20
kFlag21 equ 21
kFlag22 equ 22
kFlag23 equ 23
kFlag24 equ 24
kFlag25 equ 25 ; set for idle1, idle2
kFlag26 equ 26 ; set for blue
kFlag27 equ 27
kFlag28 equ 28 ; set for blue
kFlag29 equ 29
kFlag30 equ 30
kFlag31 equ 31
ds.l 1 ; 068
OwningProcessPtr ds.l 1 ; 06c
AddressSpacePtr ds.l 1 ; 070 ; borrowed from PROC argument to CreateTask
@ -113,8 +180,8 @@ Zero4 ds.l 1 ; 0e4
Zero5 ds.l 1 ; 0e8
ds.l 1 ; 0ec
YellowVecTblPtr ds.l 1 ; 0f0
ds.l 1 ; 0f4
ds.l 1 ; 0f8
ExceptionHandlerID ds.l 1 ; 0f4 ; a queue
ErrToReturnIfIDie ds.l 1 ; 0f8
ds.l 1 ; 0fc
ContextBlock ds.b 768 ; 100:400 ; like the EDP's Emulator Context Block -- unsure of size
@ -134,6 +201,7 @@ Size equ *
Timer record 0,INCR
kIDClass equ 3
kFirstID equ 0x00030001
kSignature equ 'TIME'
;_______________________
@ -145,18 +213,29 @@ Signature ds.l 1 ; 04 ; task+24
QueueLLL ds.l 1 ; 08 ; task+28 ; overlaps with the below bytefields, as a union?
ds.l 1 ; 0c ; task+2c
ProcessID ds.l 1 ; 10 ; task+30
Byte0 ds.b 1 ; 14 ; task+34 ; InitTMRQs sets to 6, MPCall 55 to 1, MPCall 52 to 2
Kind ds.b 1 ; 14 ; task+34 ; InitTMRQs sets to 6, MPCall 55 to 1, MPCall 52 to 2
kKind1 equ 1
kKind2 equ 2
kKind3 equ 3
kKind4 equ 4
kKind5 equ 5
kKind6 equ 6
kKind7 equ 7
Byte1 ds.b 1 ; 15 ; task+35
Byte2 ds.b 1 ; 16 ; task+36 ; InitTMRQs sets to 1
KeepAfterFiring ds.b 1 ; 16 ; task+36 ; InitTMRQs sets to 1
Byte3 ds.b 1 ; 17 ; task+37 ; called_by_init_tmrqs sets to 1
ParentTaskPtr ds.l 1 ; 18 ; task+38 ; MPCall 55 sets
ds.l 1 ; 1c ; task+3c
ds.l 1 ; 20 ; task+40
ds.l 1 ; 24 ; task+44
ds.l 1 ; 28 ; task+48
ds.l 1 ; 2c ; task+4c
ds.l 1 ; 30 ; task+50
ds.l 1 ; 34 ; task+54
MessageQueueID
ParentTaskPtr ds.l 1 ; 18 ; task+38 ; task to be unblocked when timer fires
ReservedMessage ds.l 1 ; 1c ; task+3c ; 'note' allocated when timer armed
Message1 ds.l 1 ; 20 ; task+40 ; if I hit a message queue
Message2 ds.l 1 ; 24 ; task+44
Message3 ds.l 1 ; 28 ; task+48
EventGroupID ds.l 1 ; 2c ; task+4c ; if I hit an event group
EventGroupFlags ds.l 1 ; 30 ; task+50
SemaphoreID ds.l 1 ; 34 ; task+54
Time ds.l 2 ; 38 ; task+58 ; set from first two args to MPCall 55
Size equ *
@ -174,18 +253,19 @@ Size equ *
Queue record 0,INCR
kIDClass equ 4
kFirstID equ 0x00040001
;_______________________
; Fields
;_______________________
LLL ds.l 4 ; 00:10
ds.l 4 ; 10:20
ProcessID ds.l 1 ; 20
ds.l 1 ; 24
ds.l 1 ; 28
ds.l 1 ; 2c
ds.l 1 ; 30
BlockedTasks ds.l 4 ; 00:10 ; titled MSGQ ; waiting for messages
Messages ds.l 4 ; 10:20 ; titled NOTQ ; waiting for tasks
ProcessID ds.l 1 ; 20 ; why associate a queue with a process?
ReserveCount ds.l 1 ; 24 ; as number of messages, from MPSetQueueReserve
ReservePtr ds.l 1 ; 28 ; ptr to first element of
BlockedTaskCount ds.l 1 ; 2c
MessageCount ds.l 1 ; 30
Size equ *
endr
@ -209,6 +289,20 @@ kSignature equ 'RDYQ'
Message record 0,INCR
kSignature equ 'note'
kReservedSignature equ 'notr'
LLL ds.l 4 ; 00:10 ; singly linked (next ptrs) only
Word1 ds.l 1 ; 10
Word2 ds.l 1 ; 14
Word3 ds.l 1 ; 18
Size equ *
endr
kTimerQueueSignature equ 'TMRQ'
kDelayQueueSignature equ 'DLYQ'
kDbugQueueSignature equ 'DBUG'
@ -228,17 +322,18 @@ kSemaQueueSignature equ 'SEMQ'
Semaphore record 0,INCR
kIDClass equ 5
kFirstID equ 0x00050001
kSignature equ 'SEMA'
;_______________________
; Fields
;_______________________
LLL ds.l 4 ; 00:10
ds.l 1 ; 10
ds.l 1 ; 14
BlockedTasks ds.l 4 ; 00:10 ; blocked tasks
Value ds.l 1 ; 10 ; negative if tasks are blocked???
MaxValue ds.l 1 ; 14
ProcessID ds.l 1 ; 18
ds.l 1 ; 1c
BlockedTaskCount ds.l 1 ; 1c ; starts as 0
Size equ *
endr
@ -255,6 +350,7 @@ Size equ *
CriticalRegion record 0,INCR
kIDClass equ 6
kFirstID equ 0x00060001
kSignature equ 'CRGN'
;_______________________
@ -280,6 +376,7 @@ Size equ *
CPU record 0,INCR
kIDClass equ 7
kFirstID equ 0x00070001
kSignature equ 'CPU '
;_______________________
@ -311,6 +408,7 @@ Size equ *
AddressSpace record 0,INCR
kIDClass equ 8
kFirstID equ 0x00080001
kSignature equ 'SPAC'
;_______________________
@ -362,6 +460,7 @@ Size equ *
EventGroup record 0,INCR
kIDClass equ 9
kFirstID equ 0x00090001
kSignature equ 'EVNT'
;_______________________
@ -389,6 +488,7 @@ Size equ *
CoherenceGroup record 0,INCR
kIDClass equ 10
kFirstID equ 0x000a0001
kSignature equ 'CGRP'
;_______________________
@ -428,6 +528,7 @@ Size equ *
Area record 0,INCR
kIDClass equ 11
kFirstID equ 0x000b0001
kSignature equ 'AREA'
;_______________________
@ -488,22 +589,26 @@ Size equ *
Notification record 0,INCR
kIDClass equ 12
kFirstID equ 0x000c0001
kSignature equ 'KNOT'
;_______________________
; Fields
;_______________________
ds.l 1 ; 00
Signature ds.l 1 ; 04
ProcessID ds.l 1 ; 08
ds.l 1 ; 0c
ds.l 1 ; 10
ds.l 1 ; 14
ds.l 1 ; 18
ds.l 1 ; 1c
ds.l 1 ; 20
ds.l 1 ; 24
TaskPtr ds.l 1 ; 00 ; (set on init)
Signature ds.l 1 ; 04 ; (set on init)
ProcessID ds.l 1 ; 08 ; (set on init)
QueueID ds.l 1 ; 0c ; message queue
MsgWord1 ds.l 1 ; 10
MsgWord2 ds.l 1 ; 14
MsgWord3 ds.l 1 ; 18
EventGroupID ds.l 1 ; 1c
EventFlags ds.l 1 ; 20
SemaphoreID ds.l 1 ; 24
Size equ *
endr
@ -521,6 +626,7 @@ Size equ *
ConsoleLog record 0,INCR
kIDClass equ 13
kFirstID equ 0x000d0001
;_______________________
; Fields

View File

@ -125,13 +125,13 @@ QueueRelatedZero2 ds.l 1 ; -9fc ; same again
ds.l 1 ; -9f8
ds.l 1 ; -9f4
ReadyQueues
CriticalReadyQ ds.l 8 ; -9f0:-9d0
LatencyProtectReadyQ ds.l 8 ; -9d0:-9b0
NominalReadyQ ds.l 8 ; -9b0:-990
IdleReadyQ ds.l 8 ; -990:-970
CriticalReadyQ ds.l 8 ; -9f0:-9d0 ; unblocked tasks with priority 0
LatencyProtectReadyQ ds.l 8 ; -9d0:-9b0 ; unblocked tasks with priority 1
NominalReadyQ ds.l 8 ; -9b0:-990 ; unblocked tasks with priority 2
IdleReadyQ ds.l 8 ; -990:-970 ; unblocked tasks with priority 3
PriorityFlags ds.l 1 ; -970 ; bit 0 is 0, bit 1 is 1, etc...
ScrambledMPCallTime ds.l 1 ; -96c ; by MP call return
EmpiricalCpuFeatures ds.l 1 ; -968 ; Init.s saves MQ (should be possible) here
GlobalCPUFlags ds.l 1 ; -968 ; Init.s saves MQ (should be possible) here
MQFeatureBit equ 13 ; equals 0x00040000
AVFeatureBit equ 12 ; equals 0x00080000
; 8 0x00800000
@ -172,7 +172,7 @@ SystemAddressSpaceID ds.l 1 ; -424
blueProcessPtr ds.l 1 ; -41c ; physical ptr to first type-1 struct created
ThermalHandlerID ds.l 1 ; -418 ; is a Note struct
PMFHandlerID ds.l 1 ; -414 ; also a Note struct
SomeEvtGrpID ds.l 1 ; -410
BlueSpinningOn ds.l 1 ; -410 ; ID or 0 or -1
ds.l 1 ; -40c
ds.l 1 ; -408
ds.l 1 ; -404
@ -313,7 +313,7 @@ SpacesDeferredAreaPtr ds.l 1 ; -26c, cpu+0d4
ds.l 1 ; -264, cpu+0dc
ds.l 1 ; -260, cpu+0e0
ds.l 1 ; -25c, cpu+0e4
ds.l 1 ; -258, cpu+0e8
TimerDispatchLR ds.l 1 ; -258, cpu+0e8
ds.l 1 ; -254, cpu+0ec
ds.l 1 ; -250, cpu+0f0
ds.l 1 ; -24c, cpu+0f4
@ -393,7 +393,9 @@ SpacesDeferredAreaPtr ds.l 1 ; -26c, cpu+0d4
ds.l 1 ; -124, cpu+21c
ds.l 1 ; -120, cpu+220
ds.l 1 ; -11c, cpu+224
BinaryFlag ds.l 1 ; -118, cpu+228 ; 1 or 0, actually a byte!
SchEvalFlag ds.b 1 ; -118, cpu+228
TaskPriority ds.b 1 ; -117, cpu+229
CPUIndex ds.w 1 ; -116, cpu+22a
ds.l 1 ; -114, cpu+22c
ds.l 1 ; -110, cpu+230
ds.l 1 ; -10c, cpu+234
@ -460,7 +462,7 @@ PA_CurAddressSpace ds.l 1 ; -01c, cpu+324
PA_PSA ds.l 1 ; -018, cpu+328
PA_ContextBlock ds.l 1 ; -014, cpu+32c
Flags ds.l 1 ; -010, cpu+330
ds.l 1 ; -00c, cpu+334
Enables ds.l 1 ; -00c, cpu+334
PA_CurTask ds.l 1 ; -008, cpu+338
PA_KDP ds.l 1 ; -004, cpu+33c

View File

@ -637,7 +637,7 @@ NKCreateAddressSpaceSub
bl PoolFree
@fail_OOM
li r8, -0x726e
li r8, -29294
b @return
@fail_notcgrp
@ -732,18 +732,15 @@ KCSetTaskAddressSpace ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
; r8 = something not sure what
; r9 = 0:inval, 1:proc, 2:task, 3:timer, 4:q, 5:sema, 6:cr, 7:cpu, 8:addrspc, 9:evtg, 10:cgrp, 11:area, 12:not, 13:log
mr r31, r8
cmpwi r9, 0x02
cmpwi r9, Task.kIDClass
bne+ ReleaseAndReturnMPCallInvalidIDErr
lwz r16, 0x0064(r31)
lwz r16, Task.Flags(r31)
mtcr r16
li r3, -0x7271
li r3, kMPTaskAbortedErr
beq+ cr7, ReleaseAndReturnMPCall
bne+ cr5, ReleaseAndReturnMPCallOOM
lbz r16, 0x0018(r31)
@ -817,7 +814,7 @@ MPCreateArea
li r8, Area.Size
bl PoolAlloc
mr. r31, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
; Populate
stw r30, Area.AddressSpacePtr(r31)
@ -1363,7 +1360,7 @@ major_0x102c8 ; OUTSIDE REFERER
li r29, 0x00
stw r29, 0x0018(r26)
mr r30, r26
bl major_0x0db04
bl CauseNotification
b major_0x10320_0x20
@ -1383,7 +1380,7 @@ major_0x102c8 ; OUTSIDE REFERER
major_0x10320 ; OUTSIDE REFERER
mr r8, r31
li r9, -0x726e
li r9, -29294
b ReturnFromCreateArea
dc.l 0x811f0000
dc.l 0x48004fd1
@ -1411,7 +1408,7 @@ major_0x10320_0x64 ; OUTSIDE REFERER
lwz r8, Area.ID(r31)
bl DeleteID
mr r8, r31
li r9, -0x7272
li r9, kMPInsufficientResourcesErr
b ReturnFromCreateArea
major_0x10320_0x94 ; OUTSIDE REFERER
@ -1488,13 +1485,13 @@ MPCreateAliasArea
mr r30, r8
lwz r16, Area.Flags(r30)
rlwinm. r8, r16, 0, Area.kAliasFlag, Area.kAliasFlag
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
; Allocate the new Area
li r8, Area.Size
bl PoolAlloc
mr. r31, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
; Populate
mfsprg r28, 0
@ -1766,7 +1763,7 @@ MPCall_75 ; OUTSIDE REFERER
lwz r17, Area.Length(r31)
and. r5, r5, r18
and r17, r17, r18
ble+ major_0x0b054
ble+ ReleaseAndReturnParamErrFromMPCall
subf. r27, r17, r5
; r1 = kdp
@ -1904,27 +1901,27 @@ MPCall_130 ; OUTSIDE REFERER
ori r16, r16, 0xfff8
lwz r17, 0x0020(r31)
and. r16, r16, r4
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
rlwinm. r8, r17, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
mr r29, r5
lwz r18, 0x0134(r6)
lwz r19, 0x0068(r31)
lwz r16, Area.LogicalBase(r31)
cmplw r18, r19
add r28, r18, r29
bge+ major_0x0b054
bge+ ReleaseAndReturnParamErrFromMPCall
lwz r17, 0x007c(r31)
addi r28, r28, -0x01
lwz r18, 0x0020(r31)
lwz r19, Area.LogicalEnd(r31)
cmplw cr1, r29, r16
cmplw cr2, r28, r19
blt+ cr1, major_0x0b054
bgt+ cr2, major_0x0b054
blt+ cr1, ReleaseAndReturnParamErrFromMPCall
bgt+ cr2, ReleaseAndReturnParamErrFromMPCall
xor r8, r28, r29
rlwinm. r8, r8, 0, 0, 19
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
_Lock PSA.HTABLock, scratch1=r14, scratch2=r15
@ -1935,7 +1932,7 @@ MPCall_130 ; OUTSIDE REFERER
rlwinm r8, r16, 0, 29, 30
lwz r16, 0x0000(r30)
cmpwi cr7, r8, 0x04
beq+ cr7, major_0x0b054
beq+ cr7, ReleaseAndReturnParamErrFromMPCall
lwz r16, 0x0098(r31)
MPCall_130_0xe8
@ -1964,7 +1961,7 @@ MPCall_130_0x11c
; r8 = ptr
mr. r16, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
addi r18, r31, 0x90
lis r17, 0x4645
ori r17, r17, 0x4e43
@ -2021,11 +2018,11 @@ MPSetAreaAccess ; OUTSIDE REFERER
lis r16, -0x01
ori r16, r16, 0xff10
and. r16, r16, r4
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
lis r16, -0x01
ori r16, r16, 0xff10
and. r16, r16, r5
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
lwz r29, 0x0134(r6)
lwz r18, 0x013c(r6)
lwz r16, Area.LogicalBase(r31)
@ -2037,8 +2034,8 @@ MPSetAreaAccess ; OUTSIDE REFERER
rlwinm. r8, r18, 0, 16, 16
cmplw cr1, r29, r16
cmplw cr2, r28, r19
blt+ cr1, major_0x0b054
bgt+ cr2, major_0x0b054
blt+ cr1, ReleaseAndReturnParamErrFromMPCall
bgt+ cr2, ReleaseAndReturnParamErrFromMPCall
bne- MPSetAreaAccess_0x154
_Lock PSA.HTABLock, scratch1=r14, scratch2=r15
@ -2096,7 +2093,7 @@ MPSetAreaAccess_0x118
b ReleaseAndReturnZeroFromMPCall
MPSetAreaAccess_0x154
bne+ cr1, major_0x0b054
bne+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r18, 0x001c(r31)
and r8, r4, r5
orc r9, r4, r5
@ -2297,8 +2294,8 @@ MPCall_123 ; OUTSIDE REFERER
lwz r18, 0x0020(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
rlwinm. r8, r18, 0, 16, 16
lwz r5, 0x001c(r31)
@ -2375,7 +2372,7 @@ MPCall_78 ; OUTSIDE REFERER
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
cmpwi r4, 0x01
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
cmplwi r5, 0x00
bne- MPCall_78_0x68
li r16, 0x01
@ -2443,7 +2440,7 @@ MPCall_78_0xd0
MPCall_78_0xfc
cmpwi r5, 0x3c
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
li r16, 0x00
stw r16, 0x0154(r6)
@ -2515,7 +2512,7 @@ MPCall_80_0x38
lwz r16, 0x0024(r8)
li r5, 0x00
cmplw r16, r4
bgt+ major_0x0b054
bgt+ ReleaseAndReturnParamErrFromMPCall
lwz r5, 0x0000(r8)
; r1 = kdp
@ -2555,7 +2552,7 @@ MPCall_125_0x38
MPCall_125_0x58
lwz r9, 0x002c(r8)
cmpwi r9, noErr
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lwz r5, 0x0000(r8)
; r1 = kdp
@ -2582,8 +2579,8 @@ MPCall_81 ; OUTSIDE REFERER
lwz r18, 0x0020(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
rlwinm. r8, r18, 0, 16, 16
lwz r19, 0x0070(r31)
beq- MPCall_81_0x70
@ -2591,7 +2588,7 @@ MPCall_81 ; OUTSIDE REFERER
rlwinm r19, r19, 0, 0, 19
cmpwi r17, 0x00
subf r18, r16, r4
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
add r5, r18, r19
; r1 = kdp
@ -2614,7 +2611,7 @@ MPCall_81_0xa4
b ReleaseAndReturnMPCall
MPCall_81_0xc8
li r3, -0x7272
li r3, kMPInsufficientResourcesErr
b MPCall_81_0xa4
@ -2641,13 +2638,13 @@ MPCall_98 ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r20, Area.BytesMapped(r31)
rlwinm. r8, r18, 0, 16, 16
cmpwi cr1, r20, 0x00
beq- MPCall_98_0x84
beq+ cr1, major_0x0b054
beq+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0070(r31)
subf r18, r16, r4
rlwinm r19, r19, 0, 0, 19
@ -2671,7 +2668,7 @@ MPCall_98_0x84
li r3, 0x00
bso- cr7, MPCall_98_0xc4
crset cr3_eq
li r3, -0x7272
li r3, kMPInsufficientResourcesErr
MPCall_98_0xc4
rlwimi r17, r4, 0, 20, 31
@ -2793,7 +2790,7 @@ MPCall_83_0x5c ; OUTSIDE REFERER
mr r31, r8
bne+ ReleaseAndReturnMPCallOOM
lwz r8, 0x0020(r31)
bl major_0x0d35c
bl SetEvent
b ReleaseAndReturnMPCallOOM
MPCall_83_0x90 ; OUTSIDE REFERER
@ -2930,19 +2927,19 @@ KCMapPage ; OUTSIDE REFERER
mr r31, r8
lwz r16, Area.Flags(r31)
rlwinm. r8, r16, 0, 28, 28
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
lwz r16, Area.LogicalBase(r31)
lwz r17, Area.LogicalEnd(r31)
lwz r19, 0x0020(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
rlwinm. r8, r19, 0, 16, 16
cmplw cr1, r4, r16
lwz r20, Area.BytesMapped(r31)
beq- KCMapPage_0x8c
bne+ cr1, major_0x0b054
bne+ cr1, ReleaseAndReturnParamErrFromMPCall
cmpwi r20, 0x00
lwz r8, 0x0070(r31)
bne+ ReleaseAndReturnMPCallOOM
@ -3046,7 +3043,7 @@ KCUnmapPages ; OUTSIDE REFERER
lwz r8, 0x0134(r6)
lwz r16, Area.Flags(r31)
rlwinm. r16, r16, 0, 28, 28
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
clrlwi. r8, r8, 0x1f
add r5, r5, r4
lwz r16, Area.LogicalBase(r31)
@ -3056,14 +3053,14 @@ KCUnmapPages ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r29, 0x0068(r31)
lwz r20, Area.BytesMapped(r31)
rlwinm. r8, r19, 0, 16, 16
cmplw cr1, r4, r16
beq- KCUnmapPages_0xd8
bne+ cr1, major_0x0b054
bne+ cr1, ReleaseAndReturnParamErrFromMPCall
cmpwi r20, 0x00
li r20, 0x00
ble+ ReleaseAndReturnMPCallOOM
@ -3161,12 +3158,12 @@ KCMakePhysicallyContiguous ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0020(r31)
lwz r29, 0x0068(r31)
rlwinm. r8, r19, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
_Lock PSA.HTABLock, scratch1=r14, scratch2=r15
@ -3250,19 +3247,19 @@ KCLockPages ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0020(r31)
lwz r29, 0x0068(r31)
rlwinm. r8, r19, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
mr r27, r4
li r28, 0x00
KCLockPages_0x68
mr r8, r27
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
rlwinm r17, r18, 24, 25, 31
rlwinm. r8, r18, 0, 16, 16
@ -3335,18 +3332,18 @@ KCUnlockPages ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0020(r31)
lwz r29, 0x0068(r31)
rlwinm. r8, r19, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
mr r27, r4
KCUnlockPages_0x60
mr r8, r27
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
rlwinm r17, r18, 24, 25, 31
rlwinm. r8, r18, 0, 16, 16
@ -3362,7 +3359,7 @@ KCUnlockPages_0x60
KCUnlockPages_0x98
mr r8, r4
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
rlwinm r17, r18, 24, 25, 31
addi r17, r17, -0x01
@ -3419,19 +3416,19 @@ KCHoldPages_0x2c ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0020(r31)
lwz r29, 0x0068(r31)
rlwinm. r8, r19, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
mr r27, r4
li r28, 0x00
KCHoldPages_0x64
mr r8, r27
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
clrlwi r17, r18, 0x18
rlwinm. r8, r18, 0, 16, 16
@ -3504,18 +3501,18 @@ KCUnholdPages ; OUTSIDE REFERER
addi r5, r5, -0x01
cmplw r4, r16
cmplw cr1, r5, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
lwz r19, 0x0020(r31)
lwz r29, 0x0068(r31)
rlwinm. r8, r19, 0, 16, 16
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
mr r27, r4
KCUnholdPages_0x60
mr r8, r27
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
clrlwi r17, r18, 0x18
rlwinm. r8, r18, 0, 16, 16
@ -3531,7 +3528,7 @@ KCUnholdPages_0x60
KCUnholdPages_0x98
mr r8, r4
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
clrlwi r17, r18, 0x18
addi r17, r17, -0x01
@ -3577,8 +3574,8 @@ MPCall_91 ; OUTSIDE REFERER
lwz r17, Area.LogicalEnd(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
_Lock PSA.HTABLock, scratch1=r14, scratch2=r15
@ -3634,19 +3631,19 @@ MPCall_92 ; OUTSIDE REFERER
mr r31, r8
lwz r16, Area.Flags(r31)
rlwinm. r8, r16, 0, 28, 28
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
lwz r29, 0x0134(r6)
li r8, 0x318
andc. r9, r5, r8
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
andc. r9, r29, r8
bne+ major_0x0b054
bne+ ReleaseAndReturnParamErrFromMPCall
lwz r16, Area.LogicalBase(r31)
lwz r17, Area.LogicalEnd(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
_Lock PSA.HTABLock, scratch1=r14, scratch2=r15
@ -3694,11 +3691,11 @@ MPCall_93 ; OUTSIDE REFERER
lwz r17, Area.LogicalEnd(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
mr r8, r4
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
rlwinm. r8, r18, 0, 16, 16
li r5, 0x00
@ -3730,13 +3727,13 @@ MPCall_94 ; OUTSIDE REFERER
lwz r17, Area.LogicalEnd(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
mr r8, r4
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
cmplwi r5, 0x7fff
bgt+ major_0x0b054
bgt+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
rlwinm. r8, r18, 0, 16, 16
bne+ ReleaseAndReturnMPCallOOM
@ -3779,11 +3776,11 @@ MPCall_129 ; OUTSIDE REFERER
lwz r17, Area.LogicalEnd(r31)
cmplw r4, r16
cmplw cr1, r4, r17
blt+ major_0x0b054
bgt+ cr1, major_0x0b054
blt+ ReleaseAndReturnParamErrFromMPCall
bgt+ cr1, ReleaseAndReturnParamErrFromMPCall
mr r8, r4
bl MPCall_95_0x254
beq+ major_0x0b054
beq+ ReleaseAndReturnParamErrFromMPCall
lhz r18, 0x0000(r30)
li r5, 0x00
rlwinm. r8, r18, 0, 16, 16

View File

@ -145,7 +145,7 @@ kcCacheDispatch_0x1d0
lwz r22, 0x01b4(r6)
lwz r23, 0x01bc(r6)
sync
b skeleton_key
b IntReturn
kcCacheDispatch_0x1e4
clrlwi r8, r3, 0x10

View File

@ -46,5 +46,9 @@ kKDPfromIRP equ 10 * 4096
; Branch instruction BO fields
; (disregarding static prediction :)
BO_IF equ 12
BO_IF_NOT equ 4
noErr equ 0
Z equ 0x80000000

View File

@ -213,7 +213,7 @@ FinishInitBuiltin
mtspr mq, r8
li r8, 0
mfspr r8, mq
stw r8, PSA.EmpiricalCpuFeatures(r1)
stw r8, PSA.GlobalCPUFlags(r1)
; Add AV and save that in scratch field
oris r9, r8, 1 << (15 - PSA.AVFeatureBit)
@ -230,11 +230,11 @@ FinishInitBuiltin
stvewx v0, 0, r9
; Scratch field now contains AltiVec and MQ flags.
; Copy it to EmpiricalCpuFeatures
; Copy it to GlobalCPUFlags
lwz r8, EWA.r0(r1)
stw r8, PSA.EmpiricalCpuFeatures(r1)
stw r8, PSA.GlobalCPUFlags(r1)
; AllCpuFeatures = EmpiricalCpuFeatures | 0x00a00000
; current flags = tested flags | CPU flag 8 | CPU flag 9
oris r7, r8, 0xa0
stw r7, EWA.Flags(r1)
@ -300,7 +300,7 @@ ResetBuiltinKernel
; r5 = SystemInfo
; r6 = PA_ECB
; r7 = AllCpuFeatures
; r8 = EmpiricalCpuFeatures
; r8 = GlobalCPUFlags
; r9 = even more altivec crud
; r10 = LA_EmulatorKernelTrapTable
; r11 = MSR
@ -1105,13 +1105,13 @@ SetProcessorFlags
lwz r8, EWA.PA_CurAddressSpace(r1)
li r9, 0
bl SetAddrSpcRegisters
bl SetSpaceSRsAndBATs
; Create the Blue MacOS task
; ARG EmpiricalCpuFeatures r7, Process *r8
; ARG GlobalCPUFlags r7, Process *r8
; RET Task *r8
lwz r8, PSA.blueProcessPtr(r1)
@ -1140,8 +1140,8 @@ SetProcessorFlags
li r8, 2
stb r8, Task.MysteryByte1(r31)
lisori r8, 0x00030028
stw r8, 0x0064(r31)
lisori r8, 0x30028 ; (Z>>Task.kFlag14) | (Z>>Task.kFlagBlue) | (Z>>Task.kFlag26) | (Z>>Task.kFlag28)
stw r8, Task.Flags(r31)
li r8, 200
stw r8, Task.Weight(r31)
@ -1149,7 +1149,7 @@ SetProcessorFlags
li r8, Task.kNominalPriority
stb r8, Task.Priority(r31)
lhz r8, -0x0116(r1) ; zero??????
lhz r8, EWA.CPUIndex(r1) ; zero??????
sth r8, 0x001a(r31)
lwz r8, EWA.CPUBase + CPU.ID(r1)
@ -1209,20 +1209,20 @@ SetProcessorFlags
; Create the idle task for the first CPU
; Unset the AV bit in EmpiricalCpuFeatures so that
; Unset the AV bit in GlobalCPUFlags so that
; idle task vector registers are not saved/restored
; (Leave the old value in r31)
av set PSA.AVFeatureBit
mr r31, r7
rlwinm r7, r7, 0, av + 1, av - 1
; ARG EmpiricalCpuFeatures r7, Process *r8
; ARG GlobalCPUFlags r7, Process *r8
; RET Task *r8
lwz r8, PSA.blueProcessPtr(r1)
bl CreateTask
; Restore EmpiricalCpuFeatures
; Restore GlobalCPUFlags
mr r7, r31
; Check
@ -1234,9 +1234,8 @@ av set PSA.AVFeatureBit
stw r8, Task.Name(r31)
; Blue has 0x00030028
lisori r8, 0x000a0040
stw r8, Task.ThingThatAlignVecHits(r31)
lisori r8, 0xA0040 ; (Z>>Task.kFlag12) | (Z>>Task.kFlag14) | (Z>>Task.kFlag25)
stw r8, Task.Flags(r31)
; For the scheduler
li r8, 1
@ -1253,9 +1252,9 @@ av set PSA.AVFeatureBit
stw r8, Task.CpuID(r31)
; Add a feature!?!?!?!
lwz r8, Task.ContextBlock + ContextBlock.EmpiricalCpuFeatures(r31)
lwz r8, Task.ContextBlock + ContextBlock.Flags(r31)
oris r8, r8, 0x40
stw r8, Task.ContextBlock + ContextBlock.EmpiricalCpuFeatures(r31)
stw r8, Task.ContextBlock + ContextBlock.Flags(r31)
; Point task ECB at the idle loop within the nanokernel code
lwz r8, KDP.PA_NanoKernelCode(r1)

View File

@ -9,7 +9,7 @@ Local_Panic set *
; major_0x02ccc
major_0x02964 ; OUTSIDE REFERER
b AlternateMPCallReturnPath
b BlockMPCall
@ -37,7 +37,7 @@ major_0x02964 ; OUTSIDE REFERER
major_0x02980 ; OUTSIDE REFERER
mfsprg r1, 0
mtsprg 3, r24
lwz r9, -0x000c(r1)
lwz r9, EWA.Enables(r1)
rlwinm r23, r17, 31, 27, 31
rlwnm. r9, r9, r8, 0x00, 0x00
bsol- cr3, major_0x02980_0x100
@ -84,12 +84,12 @@ major_0x02980_0xa8
stw r12, 0x008c(r6)
stw r3, 0x0094(r6)
stw r4, 0x009c(r6)
lwz r8, -0x000c(r1)
lwz r8, EWA.Enables(r1)
stw r7, 0x0040(r6)
stw r8, 0x0044(r6)
li r8, 0x00
lwz r10, 0x004c(r6)
stw r8, -0x000c(r1)
stw r8, EWA.Enables(r1)
lwz r1, -0x0004(r1)
lwz r4, 0x0054(r6)
lwz r3, 0x0654(r1)
@ -102,7 +102,7 @@ major_0x02980_0xec
bsol- cr6, major_0x02980_0x114
rlwinm r7, r7, 0, 29, 16
rlwimi r11, r7, 0, 20, 23
b skeleton_key
b IntReturn
major_0x02980_0x100
lwz r2, 0x0008(r1)
@ -124,7 +124,7 @@ major_0x02980_0x114 ; OUTSIDE REFERER
major_0x02980_0x134 ; OUTSIDE REFERER
mfsprg r1, 0
mtcrf 0x3f, r7
lwz r9, -0x000c(r1)
lwz r9, EWA.Enables(r1)
lwz r1, -0x0004(r1)
rlwnm. r9, r9, r8, 0x00, 0x00
rlwimi r7, r8, 24, 0, 7
@ -142,16 +142,16 @@ major_0x02980_0x134 ; OUTSIDE REFERER
major_0x02980_0x178 ; OUTSIDE REFERER
lwz r1, -0x0004(r1)
lwz r9, 0x0658(r1)
lwz r9, KDP.PA_ECB(r1)
addi r8, r1, 0x360
mtsprg 3, r8
bltl- cr2, major_0x02ccc_0x108
bltl- cr2, BlueException
major_0x02980_0x18c ; OUTSIDE REFERER
mfsprg r1, 0
lwz r8, -0x000c(r1)
stw r7, 0x0000(r6)
stw r8, 0x0004(r6)
lwz r8, EWA.Enables(r1)
stw r7, ContextBlock.Flags(r6)
stw r8, ContextBlock.Enables(r6)
bns- cr6, major_0x02980_0x1b8
stw r17, 0x0024(r6)
stw r20, 0x0028(r6)
@ -217,7 +217,7 @@ major_0x02980_0x260
andi. r8, r11, 0x900
lwz r8, 0x0004(r6)
lwz r13, 0x00dc(r6)
stw r8, -0x000c(r1)
stw r8, EWA.Enables(r1)
lwz r8, 0x00d4(r6)
lwz r12, 0x00ec(r6)
mtxer r8
@ -264,7 +264,7 @@ major_0x02980_0x2d0
; skeleton_key
; IntReturn
; Called when a Gary reset trap is called. When else?
@ -288,14 +288,14 @@ major_0x02980_0x2d0
; CommonMPCallReturnPath
; CommonPIHPath
skeleton_key ; OUTSIDE REFERER
IntReturn ; OUTSIDE REFERER
andi. r8, r7, 0x30
mfsprg r1, 0
bnel- major_0x02ccc
li r8, 0x00
stw r7, -0x0010(r1)
stw r7, EWA.Flags(r1)
stw r8, -0x0114(r1)
b major_0x142a8
b ReturnToAnyTask
@ -303,20 +303,20 @@ skeleton_key ; OUTSIDE REFERER
; Xrefs:
; major_0x02980
; skeleton_key
; IntReturn
major_0x02ccc ; OUTSIDE REFERER
mtcrf 0x3f, r7
bns- cr6, major_0x02ccc_0x18
bc BO_IF_NOT, 27, major_0x02ccc_0x18
rlwinm r7, r7, 0, 28, 26
bso- cr7, major_0x02ccc_0x30
bc BO_IF, 31, major_0x02ccc_0x30
rlwinm r7, r7, 0, 27, 25
b major_0x02ccc_0x2c
major_0x02ccc_0x18
bne- cr6, major_0x02ccc_0x2c
rlwinm r7, r7, 0, 27, 25
stw r7, -0x0010(r1)
stw r7, EWA.Flags(r1)
li r8, 0x08
b major_0x02980_0x134
@ -325,8 +325,8 @@ major_0x02ccc_0x2c
major_0x02ccc_0x30
rlwinm. r8, r7, 0, 8, 8
beq- major_0x02ccc_0x108
stw r7, -0x0010(r1)
beq- BlueException
stw r7, EWA.Flags(r1)
lwz r8, 0x0104(r6)
stw r8, 0x0000(r1)
stw r2, 0x0008(r1)
@ -361,7 +361,7 @@ major_0x02ccc_0x30
rlwimi r25, r17, 7, 25, 30
lhz r26, 0x0d20(r25)
rlwimi r25, r19, 1, 28, 30
stw r16, -0x0010(r1)
stw r16, EWA.Flags(r1)
rlwimi r26, r26, 8, 8, 15 ; copy hi byte of entry to second byte of word
rlwimi r25, r17, 4, 23, 27
mtcrf 0x10, r26 ; so the second nybble of the entry is copied to cr3
@ -381,36 +381,44 @@ major_0x02ccc_0x30
major_0x02ccc_0x108 ; OUTSIDE REFERER
BlueException
bl Save_r14_r31 ; r8 := EWA
lwz r31, EWA.PA_CurTask(r8)
lwz r8, 0x00f4(r31)
; r8 = id
lwz r8, Task.ExceptionHandlerID(r31)
bl LookupID
cmpwi r9, Queue.kIDClass
mr r30, r8
bnel- major_0x02ccc_0x20c
lwz r28, 0x0028(r30)
cmpwi r28, 0x00
beql- major_0x02ccc_0x20c
bnel- @no_exception_handler
lwz r28, Queue.ReservePtr(r30)
cmpwi r28, 0
beql- @no_memory_reserved_for_exception_messages
;notify exception handler
_Lock PSA.SchLock, scratch1=r8, scratch2=r9
lwz r29, 0x0064(r31)
ori r29, r29, 0x200
ori r29, r29, 0x1000
stw r29, 0x0064(r31)
lwz r17, 0x0008(r28)
stw r17, 0x0028(r30)
lwz r17, 0x0000(r31)
stw r17, 0x0010(r28)
li r18, -0x7271
stw r18, 0x0014(r28)
stw r18, 0x00f8(r31)
stw r10, 0x0018(r28)
lwz r29, Task.Flags(r31)
_bset r29, r29, Task.kFlag22
_bset r29, r29, Task.kFlag19
stw r29, Task.Flags(r31)
; pop 'notr'
lwz r17, Message.LLL + LLL.Next(r28)
stw r17, Queue.ReservePtr(r30)
; word1 = task ID
lwz r17, Task.ID(r31)
stw r17, Message.Word1(r28)
; word 2 = kMPTaskAbortedErr
li r18, kMPTaskAbortedErr
stw r18, Message.Word2(r28)
stw r18, Task.ErrToReturnIfIDie(r31)
; word 3 = SRR0
stw r10, Message.Word3(r28)
_log 'Blue task suspended. Notifying exception handler - srr1/0 '
mr r8, r11
bl Printw
@ -420,12 +428,15 @@ major_0x02ccc_0x108 ; OUTSIDE REFERER
mr r8, r12
bl Printw
_log '^n'
mr r31, r30
mr r8, r28
bl major_0x0c8b4
b major_0x142dc
bl EnqueueMessage ; Message *r8, Queue *r31
major_0x02ccc_0x20c
b RescheduleAndReturn
@no_exception_handler
@no_memory_reserved_for_exception_messages
mflr r16
_log 'Blue task terminated - no exception handler registered - srr1/0 '
mr r8, r11
@ -439,6 +450,8 @@ major_0x02ccc_0x20c
mtlr r16
b Local_Panic
major_0x02ccc_0x2a4 ; OUTSIDE REFERER
bsol+ cr6, Local_Panic
@ -457,7 +470,7 @@ major_0x02ccc_0x2a4 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r28, scratch2=r29
mr r8, r31
bl DequeueTask
bl TaskUnready
lwz r16, 0x0064(r31)
srwi r8, r7, 24
rlwinm. r16, r16, 0, 9, 9
@ -489,7 +502,7 @@ major_0x02ccc_0x310 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r28, scratch2=r29
mr r8, r31
bl DequeueTask
bl TaskUnready
lwz r16, 0x0064(r31)
srwi r8, r7, 24
rlwinm. r16, r16, 0, 9, 9
@ -545,7 +558,7 @@ major_0x02ccc_0x3d4
stw r27, 0x0014(r26)
stw r28, 0x0018(r26)
mr r30, r26
bl major_0x0db04
bl CauseNotification
cmpwi r8, 0x00
beq+ major_0x02964
@ -572,10 +585,10 @@ major_0x02ccc_0x430
stw r30, 0x0018(r26)
mr r8, r26
addi r31, r1, -0xa24
bl major_0x0c8b4
bl EnqueueMessage ; Message *r8, Queue *r31
lwz r8, -0x0410(r1)
bl major_0x0dce8
b AlternateMPCallReturnPath
bl UnblockBlueIfCouldBePolling
b BlockMPCall
major_0x02ccc_0x4a8
mr r8, r31
@ -606,7 +619,7 @@ major_0x02ccc_0x50c
mr r8, r31
bl TaskReadyAsPrev
bl major_0x14af8_0xa0
b AlternateMPCallReturnPath
b BlockMPCall
major_0x02ccc_0x524
b FuncExportedFromTasks
@ -635,24 +648,27 @@ IntDecrementer ; OUTSIDE REFERER
; r12 = sprg2
; r13 = cr
lwz r8, 0x05a0(r1)
lwz r8, KDP.OldKDP(r1)
rlwinm. r9, r11, 0, 16, 16
cmpwi cr1, r8, 0x00
beq- MaskedInterruptTaken
beq- cr1, IntDecrementer_0x54
stw r16, 0x0184(r6)
stw r17, 0x018c(r6)
stw r18, 0x0194(r6)
stw r25, 0x01cc(r6)
stw r16, ContextBlock.r16(r6)
stw r17, ContextBlock.r17(r6)
stw r18, ContextBlock.r18(r6)
stw r25, ContextBlock.r25(r6)
bl major_0x14a98
ble- IntDecrementer_0x48
lwz r8, -0x09d4(r1)
lwz r8, PSA.CriticalReadyQ + ReadyQueue.Timecake + 4(r1)
mtspr dec, r8
lwz r16, 0x0184(r6)
lwz r17, 0x018c(r6)
lwz r18, 0x0194(r6)
b skeleton_key
lwz r16, ContextBlock.r16(r6)
lwz r17, ContextBlock.r17(r6)
lwz r18, ContextBlock.r18(r6)
b IntReturn
IntDecrementer_0x48
lwz r16, 0x0184(r6)
@ -673,9 +689,8 @@ IntDecrementer_0x54
bl TimerDispatch
_AssertAndRelease PSA.SchLock, scratch=r8
; r6 = ewa
bl Restore_r14_r31
b skeleton_key
b IntReturn
@ -698,7 +713,7 @@ IntDSI ; OUTSIDE REFERER
mfsprg r12, 2
mfcr r13
mfsprg r24, 3
lwz r16, -0x0010(r1)
lwz r16, EWA.Flags(r1)
lwz r1, -0x0004(r1)
mfspr r26, dsisr
addi r23, r1, 0x4e0
@ -731,7 +746,7 @@ major_0x03324 ; OUTSIDE REFERER
major_0x03324_0x18
andis. r26, r27, 0xec00
lwz r16, -0x0010(r1)
lwz r16, EWA.Flags(r1)
rlwinm r17, r27, 0, 6, 15
rlwimi r16, r16, 27, 26, 26
bge- major_0x03324_0x58
@ -831,7 +846,7 @@ IntAlignment ; OUTSIDE REFERER
lwz r11, EWA.PA_CurTask(r1)
lwz r16, EWA.Flags(r1)
lwz r21, Task.ThingThatAlignVecHits(r11)
lwz r21, Task.Flags(r11)
lwz r1, -0x0004(r1) ; wha???
lwz r11, KDP.NanoKernelInfo + NKNanoKernelInfo.MisalignmentCount(r1)
@ -846,7 +861,7 @@ IntAlignment ; OUTSIDE REFERER
mfspr r27, dsisr
mfspr r18, dar
rlwinm. r21, r21, 0, 9, 9 ; KDP.ThingThatAlignVecHits
rlwinm. r21, r21, 0, Task.kFlag9, Task.kFlag9
addi r23, r1, KDP.RedVecBase
@ -1223,7 +1238,7 @@ IntISI ; OUTSIDE REFERER
mfsprg r8, 0
mtsprg 3, r24
lmw r14, 0x0038(r8)
b skeleton_key
b IntReturn
@ -1289,7 +1304,7 @@ IntMachineCheck ; OUTSIDE REFERER
rlwinm. r8, r11, 0, 2, 2
beq- IntMachineCheck_0xa4
bl kcCacheDispatch_0x39c
b skeleton_key
b IntReturn
IntMachineCheck_0xa4
li r8, 0x07
@ -1393,14 +1408,14 @@ major_0x03be0_0x58
rlwimi r7, r8, 0, 17, 7
lwz r8, 0x0044(r6)
rlwimi r11, r7, 0, 20, 23
stw r8, -0x000c(r1)
stw r8, EWA.Enables(r1)
andi. r8, r11, 0x900
lwz r12, 0x008c(r6)
lwz r3, 0x0094(r6)
lwz r4, 0x009c(r6)
bnel- major_0x03e18
addi r9, r6, 0x40
b skeleton_key
b IntReturn
major_0x03be0_0x90
lwz r9, 0x0ea8(r1)
@ -1413,7 +1428,7 @@ major_0x03be0_0x90
lwz r8, 0x0044(r6)
mtcrf 0x0f, r7
rlwimi r11, r7, 0, 20, 23
stw r8, -0x000c(r1)
stw r8, EWA.Enables(r1)
lwz r12, 0x008c(r6)
lwz r3, 0x0094(r6)
lwz r4, 0x009c(r6)
@ -1462,7 +1477,7 @@ save_all_registers ; OUTSIDE REFERER
mfspr r11, srr1
mfcr r13
mfsprg r12, 2
lwz r7, -0x0010(r1)
lwz r7, EWA.Flags(r1)
lwz r1, -0x0004(r1)
; r6 = ewa
@ -1495,7 +1510,7 @@ save_all_registers ; OUTSIDE REFERER
; r4 (itself)
; r5 (itself)
; r6 ContextBlock EWA
; r7 AllCpuFeatures ContextBlock
; r7 Flags ContextBlock
; r8 EWA ContextBlock
; r9 (itself) ContextBlock
; r10 SRR0 ContextBlock
@ -1833,21 +1848,18 @@ IntPerfMonitor ; OUTSIDE REFERER
stw r16, 0x0014(r30)
mfspr r16, 955
stw r16, 0x0018(r30)
bl major_0x0db04
bl CauseNotification
IntPerfMonitor_0x88
_AssertAndRelease PSA.SchLock, scratch=r8
; r6 = ewa
bl Restore_r14_r31
b skeleton_key
b IntReturn
; IntThermalEvent
; Xrefs:
; "vec"
; Notify the Thermal Handler
align kIntAlign
@ -1860,24 +1872,20 @@ IntThermalEvent ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r8, scratch2=r9
lwz r8, -0x0418(r1)
; r8 = id
lwz r8, PSA.ThermalHandlerID(r1)
bl LookupID
cmpwi r9, Notification.kIDClass
mr r30, r8
bne- IntThermalEvent_0x68
lwz r16, -0x0340(r28)
stw r16, 0x0010(r30)
bl major_0x0db04
bne- @no_thermal_handler
lwz r16, EWA.CPUBase + CPU.ID(r28)
stw r16, Notification.MsgWord1(r30)
bl CauseNotification
@no_thermal_handler
IntThermalEvent_0x68
_AssertAndRelease PSA.SchLock, scratch=r8
; r6 = ewa
bl Restore_r14_r31
b skeleton_key
b IntReturn
@ -1890,12 +1898,12 @@ IntThermalEvent_0x68
kcRunAlternateContext ; OUTSIDE REFERER
mtcrf 0x3f, r7
bnel+ cr2, skeleton_key
bnel+ cr2, IntReturn
and. r8, r4, r13
lwz r9, 0x0340(r1)
rlwinm r8, r3, 0, 0, 25
cmpw cr1, r8, r9
bne+ skeleton_key
bne+ IntReturn
lwz r9, 0x0344(r1)
bne- cr1, major_0x043a0_0x48
@ -2014,20 +2022,11 @@ wordfill ; OUTSIDE REFERER
; kcResetSystem
; Handle a 68k reset trap.
; Some messing around with 601 RTC vs later timebase
; registers.
; If Gary Davidian's first name and birthdate were in the
; 68k's A0/A1 (the 'skeleton key'), do something.
; Otherwise, farm it out to non_skeleton_reset_trap.
; Xrefs:
; "sup"
; If A0(r3)/A1(r4) == 'Gary'/$05051955, load the register list in A3? Or is this now disabled?
; > r3 = a0
; > r4 = a1
; New SRR0 = SRR0 & ~r5(D0) | r7(D2)
align kIntAlign
@ -2056,12 +2055,12 @@ kcResetSystem ; OUTSIDE REFERER
andis. r9, r9, 0xffff
cmplwi r8, 'ry'
bne- non_skeleton_reset_trap
bne- NonGaryReset
; r4 (i.e. A1) == 5 May 1956?
xoris r8, r4, 0x0505
cmplwi r8, 0x1956
bne- non_skeleton_reset_trap
bne- NonGaryReset
andc r11, r11, r5
lwz r8, ContextBlock.r7(r6)
@ -2077,18 +2076,18 @@ kcResetSystem ; OUTSIDE REFERER
_log '^n'
b skeleton_key
b IntReturn
; non_skeleton_reset_trap
; NonGaryReset
; A 68k reset trap without Gary Davidian's magic numbers.
; Xrefs:
; kcResetSystem
non_skeleton_reset_trap
NonGaryReset
_log 'ResetSystem trap entered^n'
@ -2114,7 +2113,7 @@ non_skeleton_reset_trap
stw r6, 0x065c(r8)
stw r7, 0x0660(r8) ; ??????????
lwz r9, -0x000c(r1)
lwz r9, EWA.Enables(r1)
stw r9, 0x0664(r8)
; r6 = ewa
@ -2130,7 +2129,7 @@ non_skeleton_reset_trap
; r11 = new srr1
; r12 = lr restore
; r13 = cr restore
b int_teardown
b ReturnFromInterrupt
@ -2338,7 +2337,7 @@ IntProgram_0xd0
xoris r13, r13, 0x2000
lwz r8, 0x00ec(r9)
stw r8, 0x0104(r6)
b skeleton_key
b IntReturn
IntProgram_0x110
mtcr r7
@ -2435,13 +2434,13 @@ IntExternalYellow ; OUTSIDE REFERER
cmpwi cr2, r8, -0x725f
beq+ kcPrioritizeInterrupts
beq+ cr1, skeleton_key
beq+ cr1, IntReturn
bne+ cr2, kcPrioritizeInterrupts
mfsprg r9, 0
li r8, 0x01
stb r8, EWA.BinaryFlag(r9)
b skeleton_key
stb r8, EWA.SchEvalFlag(r9)
b IntReturn
@ -2454,7 +2453,7 @@ IntExternalYellow ; OUTSIDE REFERER
; MPCall_43
; KCStartCPU
; KCCpuPlugin
; major_0x14af8
; FlagSchEvaluationIfTaskRequires
; MPCall_103
; > r7 = flags
@ -2501,7 +2500,7 @@ SIGP_0x28
lwz r8, 0x004c(r22)
cmpw r9, r8
beq- SIGP_0x94
bl SetAddrSpcRegisters
bl SetSpaceSRsAndBATs
SIGP_0x94
lwz r16, 0x0004(r23)
@ -2513,7 +2512,7 @@ SIGP_0x94
stw r5, 0x012c(r6)
stw r17, 0x0134(r6)
lwz r17, 0x0648(r1)
lhz r16, -0x0116(r23)
lhz r16, EWA.CPUIndex(r23)
lwz r19, -0x0964(r1)
slwi r16, r16, 2
rlwinm r19, r19, 0, 18, 15
@ -2581,7 +2580,7 @@ major_0x04a20_0x30
lwz r9, -0x001c(r23)
cmpw r9, r8
beq- major_0x04a20_0x44
bl SetAddrSpcRegisters
bl SetSpaceSRsAndBATs
major_0x04a20_0x44
lwz r10, -0x02d0(r23)
@ -2648,7 +2647,7 @@ IntSyscall ; OUTSIDE REFERER
; sc -1: mess around with flags
lwz r0, -0x0010(r1)
lwz r0, EWA.Flags(r1)
mfsprg r1, 2
rlwinm. r0, r0, 0, 10, 10
mtlr r1
@ -2661,7 +2660,7 @@ IntSyscall ; OUTSIDE REFERER
; sc -2: more flag nonsense?
lwz r0, -0x0010(r1)
lwz r0, EWA.Flags(r1)
lwz r1, -0x0008(r1)
rlwinm. r0, r0, 0, 10, 10
lwz r0, 0x00ec(r1)

View File

@ -267,7 +267,7 @@ ReturnZeroFromMPCall ; OUTSIDE REFERER
; major_0x0af60
; ReleaseAndScrambleMPCall
; Xrefs:
; KCRegisterCpuPlugin
@ -326,14 +326,14 @@ ReturnZeroFromMPCall ; OUTSIDE REFERER
; MPCall_94
; MPCall_95
major_0x0af60 ; OUTSIDE REFERER
ReleaseAndScrambleMPCall ; OUTSIDE REFERER
_AssertAndRelease PSA.SchLock, scratch=r16
; I'd really live a name for this.
major_0x0af60_0x20 ; OUTSIDE REFERER
ScrambleMPCall ; OUTSIDE REFERER
mfspr r16, pvr
rlwinm. r16, r16, 0, 0, 14
@ -348,7 +348,7 @@ major_0x0af60_0x20 ; OUTSIDE REFERER
xoris r16, r16, 0x1950
stw r16, PSA.ScrambledMPCallTime(r1)
li r3, -0x726e
li r3, -29294
b CommonMPCallReturnPath
@ -382,7 +382,7 @@ ReleaseAndReturnMPCallOOM ; OUTSIDE REFERER
; ReturnMPCallOOM
; Xrefs:
; major_0x0af60
; ReleaseAndScrambleMPCall
; MPCall_0
; KCRegisterCpuPlugin
; MPCall_47
@ -428,7 +428,7 @@ ReturnMPCallBlueBlocking ; OUTSIDE REFERER
; major_0x0b054
; ReleaseAndReturnParamErrFromMPCall
; Xrefs:
; MPCall_128
@ -456,7 +456,7 @@ ReturnMPCallBlueBlocking ; OUTSIDE REFERER
; MPCall_94
; MPCall_129
major_0x0b054 ; OUTSIDE REFERER
ReleaseAndReturnParamErrFromMPCall ; OUTSIDE REFERER
_AssertAndRelease PSA.SchLock + Lock.Count, scratch=r16
@ -464,7 +464,7 @@ major_0x0b054 ; OUTSIDE REFERER
; ReturnParamErrFromMPCall
; Xrefs:
; major_0x0b054
; ReleaseAndReturnParamErrFromMPCall
; KCGetNextIDOwnedByProcess
; NKLocateInfoRecord
; MPCall_108
@ -624,7 +624,7 @@ ReturnZeroFromMPCall_again ; OUTSIDE REFERER
; AlternateMPCallReturnPath
; BlockMPCall
; Xrefs:
; major_0x02964
@ -645,8 +645,8 @@ ReturnZeroFromMPCall_again ; OUTSIDE REFERER
; MPCall_81
; MPCall_98
AlternateMPCallReturnPath ; OUTSIDE REFERER
crclr cr2_eq
BlockMPCall ; OUTSIDE REFERER
crclr 10
b TrulyCommonMPCallReturnPath
ReleaseAndReturnMPCall ; OUTSIDE REFERER
@ -659,7 +659,7 @@ ReleaseAndReturnMPCall ; OUTSIDE REFERER
; Xrefs:
; MPCallBad
; ReturnZeroFromMPCall
; major_0x0af60
; ReleaseAndScrambleMPCall
; ReturnMPCallOOM
; ReturnMPCallBlueBlocking
; ReturnParamErrFromMPCall
@ -667,7 +667,7 @@ ReleaseAndReturnMPCall ; OUTSIDE REFERER
; ReturnMPCallInvalidIDErr
; major_0x0b0cc
; ReturnZeroFromMPCall_again
; AlternateMPCallReturnPath
; BlockMPCall
; KCGetCpuCount
; MPCall_6
; KCYieldWithHint
@ -689,19 +689,21 @@ ReleaseAndReturnMPCall ; OUTSIDE REFERER
; major_0x16b80
CommonMPCallReturnPath ; OUTSIDE REFERER
crset cr2_eq
crset 10
TrulyCommonMPCallReturnPath ; OUTSIDE REFERER
mfsprg r8, 0
lwz r9, 0x0134(r6)
stw r9, 0x0018(r8)
bne- cr2, @do_the_other_thing_instead
bl Restore_r14_r31
b skeleton_key
@do_the_other_thing_instead
bc BO_IF_NOT, 10, @block
b major_0x142dc
;return immediately
bl Restore_r14_r31
b IntReturn
@block
b RescheduleAndReturn
@ -917,7 +919,7 @@ KCCreateProcess ; OUTSIDE REFERER
bl PoolAlloc
mr. r31, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
li r9, Process.kIDClass
bl MakeID
@ -926,7 +928,7 @@ KCCreateProcess ; OUTSIDE REFERER
bne- @did_not_fail
mr r8, r31
bl PoolFree
b major_0x0af60
b ReleaseAndScrambleMPCall
@did_not_fail
stw r8, Process.ID(r31)
@ -974,63 +976,67 @@ MPCall_5 ; OUTSIDE REFERER
; MPCall_6
; ARG ProcessID r3
; RET OSStatus r3
; Xrefs:
; kcMPDispatch
; KCStopScheduling
; MPCall_9
; KCThrowException
DeclareMPCall 6, MPDeleteProcess
DeclareMPCall 6, MPCall_6
MPDeleteProcess
MPCall_6 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
cmpwi r9, Process.kIDClass
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
lwz r16, 0x0008(r31)
lwz r17, 0x0010(r31)
rlwinm. r8, r16, 0, 30, 30
cmpwi cr1, r17, 0x00
lwz r16, Process.Flags(r31)
lwz r17, Process.TaskCount(r31)
rlwinm. r8, r16, 0, Process.kFlag30, Process.kFlag30
cmpwi cr1, r17, 0
beq+ ReleaseAndReturnMPCallOOM
bne+ cr1, ReleaseAndReturnMPCallOOM
mr r8, r3
bl DeleteID
_AssertAndRelease PSA.SchLock + Lock.Count, scratch=r16
mr r8, r31
bl PoolFree
b ReturnZeroFromMPCall
MPCall_6_0x78 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mfsprg r16, 0
rlwinm. r8, r7, 0, 10, 10
lwz r17, 0x0658(r1)
lwz r31, -0x0008(r16)
rlwinm. r8, r7, 0, 10, 10
lwz r17, KDP.PA_ECB(r1)
lwz r31, EWA.PA_CurTask(r16)
beq- MPCall_6_0xb4
lwz r8, 0x00cc(r17)
lwz r8, ContextBlock.PriorityShifty(r17)
rlwinm r8, r8, 0, 24, 21
oris r8, r8, 0x8000
stw r8, 0x00cc(r17)
stw r8, ContextBlock.PriorityShifty(r17)
MPCall_6_0xb4
mr r8, r31
bl DequeueTask
li r16, 0x02
stb r16, 0x0019(r31)
bl TaskUnready
li r16, Task.kNominalPriority
stb r16, Task.Priority(r31)
bl TaskReadyAsPrev
mr r8, r31
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
_AssertAndRelease PSA.SchLock + Lock.Count, scratch=r16
b CommonMPCallReturnPath
@ -1047,20 +1053,20 @@ KCYieldWithHint ; OUTSIDE REFERER
mfsprg r16, 0
rlwinm. r8, r7, 0, 10, 10
lwz r17, 0x0658(r1)
lwz r17, KDP.PA_ECB(r1)
lwz r31, -0x0008(r16)
beq- KCYieldWithHint_0x68
clrlwi. r8, r3, 0x1f
lwz r8, 0x00cc(r17)
lwz r8, ContextBlock.PriorityShifty(r17)
rlwinm r8, r8, 0, 24, 21
oris r8, r8, 0x8000
stw r8, 0x00cc(r17)
stw r8, ContextBlock.PriorityShifty(r17)
beq- KCYieldWithHint_0x68
lbz r16, 0x0019(r31)
cmpwi r16, 0x02
bge- KCYieldWithHint_0x7c
mr r8, r31
bl DequeueTask
bl TaskUnready
li r16, 0x02
stb r16, 0x0019(r31)
bl TaskReadyAsNext
@ -1068,14 +1074,14 @@ KCYieldWithHint ; OUTSIDE REFERER
KCYieldWithHint_0x68
mr r8, r31
bl DequeueTask
bl TaskUnready
li r16, 0x02
stb r16, 0x0019(r31)
bl TaskReadyAsPrev
KCYieldWithHint_0x7c
mr r8, r31
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
_AssertAndRelease PSA.SchLock + Lock.Count, scratch=r16
b CommonMPCallReturnPath
@ -1120,12 +1126,11 @@ MPCall_55 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
; if(-0x0410(r1) == -1) {-0x0410(r1) = 0; return 0;}
lwz r16, -0x0410(r1)
cmpwi r16, -0x01
li r16, 0x00
lwz r16, PSA.BlueSpinningOn(r1)
cmpwi r16, -1
li r16, 0
bne- MPCall_55_0x60
stw r16, -0x0410(r1)
stw r16, PSA.BlueSpinningOn(r1)
b ReleaseAndReturnZeroFromMPCall
@ -1135,9 +1140,9 @@ MPCall_55_0x60 ; OUTSIDE REFERER
li r17, 1
lwz r31, EWA.PA_CurTask(r16)
addi r16, r31, 0x20
addi r16, r31, Task.Timer
stb r17, Timer.Byte0(r16)
stb r17, Timer.Kind(r16)
; High bit is possibly suspect? Or a flag?
clrlwi r3, r3, 1
@ -1150,7 +1155,7 @@ MPCall_55_0x60 ; OUTSIDE REFERER
bl EnqueueTimer
mr r8, r31
bl DequeueTask
bl TaskUnready
addi r16, r1, PSA.DelayQueue
addi r17, r31, Timer.QueueLLL
@ -1159,7 +1164,7 @@ MPCall_55_0x60 ; OUTSIDE REFERER
InsertAsPrev r17, r16, scratch=r18
li r3, 0
b AlternateMPCallReturnPath
b BlockMPCall
@ -1173,7 +1178,7 @@ MPCall_34 ; OUTSIDE REFERER
; r9 = kind
bl MakeID
cmpwi r8, 0x00
beq+ major_0x0af60_0x20
beq+ ScrambleMPCall
mr r5, r8
b ReturnZeroFromMPCall
@ -1307,7 +1312,7 @@ KCGetNextIDOwnedByProcess ; OUTSIDE REFERER
b ReturnParamErrFromMPCall
@task
lwz r17, Task.ThingThatAlignVecHits(r8)
lwz r17, Task.Flags(r8)
lwz r9, Task.ProcessID(r8)
rlwinm. r17, r17, 0, 15, 15
@ -1479,7 +1484,7 @@ KCCreateCpuStruct_0x24
; r8 = ptr
mr. r31, r8
beq+ major_0x0af60_0x20
beq+ ScrambleMPCall
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
@ -1492,7 +1497,7 @@ KCCreateCpuStruct_0x24
bne+ KCCreateCpuStruct_0x68
mr r8, r31
bl PoolFree
b major_0x0af60
b ReleaseAndScrambleMPCall
KCCreateCpuStruct_0x68
@ -1584,7 +1589,7 @@ MPCall_43 ; OUTSIDE REFERER
mfsprg r15, 0
li r16, 0x04
stw r16, -0x0238(r15)
lhz r16, 0x022a(r31)
lhz r16, CPU.EWA + EWA.CPUIndex(r31)
stw r16, -0x0234(r15)
li r8, 0x02
@ -1628,7 +1633,7 @@ KCStartCPU ; OUTSIDE REFERER
mfsprg r15, 0
li r16, 0x04
stw r16, -0x0238(r15)
lhz r16, 0x022a(r30)
lhz r16, CPU.EWA + EWA.CPUIndex(r30)
stw r16, -0x0234(r15)
@ -1650,21 +1655,21 @@ KCStartCPU ; OUTSIDE REFERER
rlwinm r7, r7, 0, 13, 11
lwz r8, PSA.blueProcessPtr(r1)
; ARG EmpiricalCpuFeatures r7, Process *r8
; ARG GlobalCPUFlags r7, Process *r8
bl CreateTask
; RET Task *r8
mr r7, r31
mr. r31, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
stw r31, CPU.IdleTaskPtr(r30)
lisori r8, 'idle'
stw r8, Task.Name(r31)
lisori r8, 0x00080040 ; clearly flags
stw r8, Task.ThingThatAlignVecHits(r31)
lisori r8, 0x80040 ; (Z>>Task.kFlag12)| (Z>>Task.kFlag25)
stw r8, Task.Flags(r31)
li r8, 1
stw r8, Task.Weight(r31)
@ -1673,12 +1678,12 @@ KCStartCPU ; OUTSIDE REFERER
stb r8, Task.Priority(r31)
; whoa -- cpu structs arent this big?
lhz r8, 0x022a(r30)
sth r8, Task.MysteryHalf(r31)
lhz r8, CPU.EWA + EWA.CPUIndex(r30)
sth r8, Task.CPUIndex(r31)
lwz r8, Task.ContextBlock + ContextBlock.EmpiricalCpuFeatures(r31)
lwz r8, Task.ContextBlock + ContextBlock.Flags(r31)
_bset r8, r8, 9
stw r8, Task.ContextBlock + ContextBlock.EmpiricalCpuFeatures(r31)
stw r8, Task.ContextBlock + ContextBlock.Flags(r31)
lwz r8, KDP.PA_NanoKernelCode(r1)
@ -1699,7 +1704,7 @@ KCStartCPU ; OUTSIDE REFERER
mfsprg r15, 0
li r16, 0x08
stw r16, -0x0238(r15)
lhz r16, 0x022a(r30)
lhz r16, CPU.EWA + EWA.CPUIndex(r30)
stw r16, -0x0234(r15)
MPCall_44_0x15c
@ -1718,7 +1723,7 @@ MPCall_44_0x15c
mfsprg r15, 0
li r16, 0x01
stw r16, -0x0238(r15)
lhz r16, 0x022a(r30)
lhz r16, CPU.EWA + EWA.CPUIndex(r30)
stw r16, -0x0234(r15)
lwz r16, 0x064c(r1)
llabel r17, major_0x14bcc
@ -1774,7 +1779,7 @@ KCStopScheduling ; OUTSIDE REFERER
oris r17, r17, 0x80
stw r17, 0x0064(r31)
mr r8, r31
bl DequeueTask
bl TaskUnready
li r17, 0x00
stb r17, 0x0019(r31)
mr r8, r31
@ -1991,9 +1996,9 @@ KCMarkPMFTask ; OUTSIDE REFERER
@use_blue_task_instead
; Insert bit 31 of r4 into bit 21 of these flags
lwz r17, Task.ThingThatAlignVecHits(r31)
lwz r17, Task.Flags(r31)
rlwimi r17, r4, 10, 21, 21
stw r17, Task.ThingThatAlignVecHits(r31)
stw r17, Task.Flags(r31)
; Don't know what this does!
@ -2155,7 +2160,7 @@ NKSetClockStep ; OUTSIDE REFERER
; r1 = kdp
beq+ ReleaseAndReturnZeroFromMPCall
mr r8, r31
bl major_0x136c8
bl DequeueTimer
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall
@ -2265,7 +2270,7 @@ NKSetClockDriftCorrection_0x12c
; r1 = kdp
beq+ ReleaseAndReturnZeroFromMPCall
mr r8, r31
bl major_0x136c8
bl DequeueTimer
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall

View File

@ -86,7 +86,7 @@
MACRO
StartLoadingWord &reg, &val
_lstart &reg, &val
LHHI (&reg), (&val)
HalfLoadedWord set (&val)
HalfLoadedReg set (&reg)
@ -94,16 +94,16 @@ HalfLoadedReg set (&reg)
MACRO
FinishLoadingWord
_lfinish
LLHI HalfLoadedReg, HalfLoadedWord
ENDM
MACRO
InitList &ptr, &sig, &scratch==r8
StartLoadingWord &scratch, &sig
_lstart &scratch, &sig
stw &ptr, LLL.Next(&ptr)
FinishLoadingWord
_lfinish
stw &ptr, LLL.Prev(&ptr)
stw &scratch, LLL.Signature(&ptr)
ENDM
@ -203,3 +203,30 @@ HalfLoadedReg set (&reg)
ENDIF
ENDM
MACRO
_b_if_time_gt &lhi, &rhi, &targ
cmpw &lhi, &rhi
cmplw cr1, &lhi + 1, &rhi + 1
bgt &targ
blt @fallthru
bgt cr1, &targ
@fallthru
ENDM
MACRO
_b_if_time_le &lhi, &rhi, &targ
cmpw &lhi, &rhi
cmplw cr1, &lhi + 1, &rhi + 1
blt &targ
bgt @fallthru
ble cr1, &targ
@fallthru
ENDM

View File

@ -83,7 +83,7 @@ InitPool ; OUTSIDE REFERER
; MPCall_40
; MPCall_31
; MPCall_64
; major_0x0db04
; CauseNotification
; CreateTask
; MPCall_58
; convert_pmdts_to_areas

View File

@ -138,7 +138,7 @@ major_0x09e28_0x4
lwz r29, 0x01ec(r6)
lwz r30, 0x01f4(r6)
lwz r31, 0x01fc(r6)
b skeleton_key
b IntReturn
major_0x09e28_0x24 ; OUTSIDE REFERER
li r3, -0x7267
@ -146,11 +146,11 @@ major_0x09e28_0x24 ; OUTSIDE REFERER
major_0x09e28_0x2c ; OUTSIDE REFERER
li r3, 0x00
b skeleton_key
b IntReturn
major_0x09e28_0x34 ; OUTSIDE REFERER
li r3, -0x01
b skeleton_key
b IntReturn
major_0x09e28_0x3c ; OUTSIDE REFERER
mfsprg r9, 0
@ -158,7 +158,7 @@ major_0x09e28_0x3c ; OUTSIDE REFERER
lwz r9, 0x0024(r8)
cmpwi r9, 0x01
li r3, -0x7267
bgt+ skeleton_key
bgt+ IntReturn
stw r26, 0x01d4(r6)
stw r27, 0x01dc(r6)
stw r28, 0x01e4(r6)
@ -510,7 +510,7 @@ major_0x09e28_0x4a8
mtspr ibat3l, r9
lwz r16, 0x0184(r6)
li r3, 0x00
b skeleton_key
b IntReturn
major_0x09e28_0x59c
mflr r9
@ -573,7 +573,7 @@ major_0x0a600 ; OUTSIDE REFERER
major_0x0a600_0x10 ; OUTSIDE REFERER
mtspr 1019, r5
li r3, 0x00
b skeleton_key
b IntReturn
major_0x0a600_0x1c ; OUTSIDE REFERER
b major_0x0a600_0x1c

View File

@ -64,17 +64,19 @@ PIHTableEnd
; > r1 = kdp
; ARG r28 = 68k int number
; Alignment probably to fit a cache block (very oft-run code).
align 5
CommonPIHPath ; OUTSIDE REFERER
mtsprg 3, r30
lwz r23, KDP.PA_EmulatorIplValue(r1)
lwz r27, -0x0428(r1)
lwz r27, PSA.ExternalHandlerID(r1)
CommonPIHPath_0xc ; OUTSIDE REFERER
cmpwi cr7, r28, 0
li r31, 0x00
li r31, 0
blt- cr7, @negative
beq- cr7, @zero_rupt
@ -83,7 +85,7 @@ CommonPIHPath_0xc ; OUTSIDE REFERER
@zero_rupt
andis. r8, r11, 0x8000 >> 14 ; some kind of perfmon bit
cmpwi cr1, r27, 0x00
cmpwi cr1, r27, 0
lwz r29, KDP.ClearIntMaskInit(r1)
bne- @noperf
@ -100,7 +102,7 @@ CommonPIHPath_0xc ; OUTSIDE REFERER
@negative
_AssertAndRelease PSA.PIHLock, scratch=r8
bl Restore_r20_r31
b skeleton_key
b IntReturn
CommonPIHPath_0x78
_AssertAndRelease PSA.PIHLock, scratch=r8
@ -109,24 +111,21 @@ CommonPIHPath_0x78
_Lock PSA.SchLock, scratch1=r8, scratch2=r9
mr r8, r27
; r8 = id
bl LookupID
cmpwi r9, Notification.kIDClass
mr r30, r8
bne- CommonPIHPath_0x100
clrlwi r9, r28, 0x11
stw r9, 0x0010(r30)
stw r22, 0x0014(r30)
bl major_0x0db04
bne- @no_handler_notification
clrlwi r9, r28, 17
stw r9, Notification.MsgWord1(r30)
stw r22, Notification.MsgWord2(r30)
bl CauseNotification
_AssertAndRelease PSA.SchLock, scratch=r8
; r6 = ewa
bl Restore_r14_r31
b skeleton_key
b IntReturn
CommonPIHPath_0x100
@no_handler_notification
li r27, 0x00
lwz r23, 0x067c(r1)
stw r27, -0x0428(r1)
@ -156,7 +155,7 @@ CommonPIHPath_0x14c
cmpwi r29, 0x00
lhz r16, 0x001a(r31)
beq- CommonPIHPath_0x1dc
lhz r17, -0x0116(r30)
lhz r17, EWA.CPUIndex(r30)
cmpw cr1, r16, r17
rlwinm. r8, r28, 0, 26, 26
beq- cr1, CommonPIHPath_0x1d0
@ -164,7 +163,7 @@ CommonPIHPath_0x14c
CommonPIHPath_0x1d0
mr r8, r31
bl DequeueTask
bl TaskUnready
b CommonPIHPath_0x218
CommonPIHPath_0x1dc
@ -174,7 +173,7 @@ CommonPIHPath_0x1dc
cmpwi r17, 0x01
bne- CommonPIHPath_0x210
addi r8, r31, 0x20
bl major_0x136c8
bl DequeueTimer
CommonPIHPath_0x210
lwz r16, 0x0e80(r1)
@ -190,12 +189,12 @@ CommonPIHPath_0x218
CommonPIHPath_0x230
mr r8, r31
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
_AssertAndRelease PSA.SchLock, scratch=r16
; r6 = ewa
bl Restore_r14_r31
b skeleton_key
b IntReturn

File diff suppressed because it is too large Load Diff

View File

@ -22,15 +22,15 @@ kcRTASDispatch ; OUTSIDE REFERER
cmpwi r8, 0x00
bne- rtas_is_available
li r3, -0x01
b skeleton_key
b IntReturn
rtas_is_available
_Lock PSA.RTASLock, scratch1=r8, scratch2=r9
mtcrf 0x3f, r7
lwz r9, 0x0658(r1)
lwz r8, -0x000c(r1)
lwz r9, KDP.PA_ECB(r1)
lwz r8, EWA.Enables(r1)
stw r7, 0x0000(r6)
stw r8, 0x0004(r6)
bns- cr6, kcRTASDispatch_0x5c
@ -138,7 +138,7 @@ kcRTASDispatch_0x190
andi. r8, r11, 0x900
lwz r8, 0x0004(r6)
lwz r13, 0x00dc(r6)
stw r8, -0x000c(r1)
stw r8, EWA.Enables(r1)
lwz r8, 0x00d4(r6)
lwz r12, 0x00ec(r6)
mtxer r8
@ -174,7 +174,7 @@ kcRTASDispatch_0x190
lwz r31, 0x01fc(r6)
_AssertAndRelease PSA.RTASLock, scratch=r8
li r3, 0x00
b skeleton_key
b IntReturn
rtas_make_actual_call
mtctr r9

View File

@ -111,7 +111,7 @@ InitReplacement
; Do something terrible with the CPU features
lwz r12, -0x0010(r1)
lwz r12, EWA.Flags(r1)
li r10, 0x00
rlwimi r10, r12, 0, 12, 15
rlwimi r10, r12, 0, 28, 30
@ -161,7 +161,7 @@ InitReplacement
stw r12, EWA.Flags(r1)
lwz r12, 0x0664(r1)
stw r12, -0x000c(r1) ; boy, better figure out what this is
stw r12, EWA.Enables(r1) ; boy, better figure out what this is
b @endif
@replaces_later_than_0101
@ -178,7 +178,7 @@ InitReplacement
stw r12, EWA.Flags(r1)
lwz r12, -0x000c(r11)
stw r12, -0x000c(r1)
stw r12, EWA.Enables(r1)
@endif

View File

@ -3,19 +3,33 @@ Local_Panic set *
; Called by setup only
; Each queue has a 64-bit time value (measured in implementation-dependent ticks).
; Critical queue has ~1ms, other queues increase this by 8x.
#### ## ## #### ######## ######## ######## ## ## ####### ######
## ### ## ## ## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ## ## ## ## ## #### ## ## ##
## ## ## ## ## ## ######## ## ## ## ## ## ######
## ## #### ## ## ## ## ## ## ## ## ## ## ##
## ## ### ## ## ## ## ## ## ## ## ## ## ##
#### ## ## #### ## ## ## ######## ## ##### ## ######
; Create the queues that hold unblocked tasks ready to be run.
; There are four ready queues (RDYQs), all in the PSA:
; 1. critical
; 2. latency protection (newly unblocked tasks)
; 3. nominal
; 4. idle
; Each one has a "time cake" that gets divided among its tasks.
; For critical it is ~1ms, successively multiplying by 8.
InitRDYQs
li r16, 0
stw r16, KDP.NanoKernelInfo + NKNanoKernelInfo.TaskCount(r1)
; Get a time doubleword approximating 1ms (for critical priority)
mflr r20
; Get a time doubleword approximating 1ms (for critical priority)
li r8, -1042 ; negative args are in usec
bl TimebaseTicksPerPeriod
mr r16, r8 ; hi
@ -23,42 +37,37 @@ InitRDYQs
mtlr r20
; Zero out the KDP priority flags (a full value would be 0xf0000000)
; These priority flags (top 4 bits) denote the state of each queue
li r23, 0
stw r23, PSA.PriorityFlags(r1)
; Populate one RDYQ for each of the four task priorities
addi r9, r1, PSA.ReadyQueues
; Populate one RDYQ for each of the four task priorities
; r23 = index of queue, r16/r17 = time cake
@loop
; Empty linked list
lisori r8, ReadyQueue.kSignature
stw r8, LLL.Signature(r9)
stw r9, LLL.Next(r9)
stw r9, LLL.Prev(r9)
; Set one word in the structure in the format of KDP PriorityFlags,
; with the bit SET that corresponds with this queue
; ... with a priority flag in its freeform field!
lis r8, 0x8000 ; ...0000
srw r8, r8, r23
stw r8, LLL.Freeform(r9)
; Zero some shit
li r8, 0
stw r8, ReadyQueue.Counter(r9) ; incremented by TaskReadyAsNext
stw r8, ReadyQueue.Counter(r9) ; incremented by TaskReadyAsPrev/Next
stw r8, ReadyQueue.TotalWeight(r9)
; Save the doubleword (1ms, 8ms...) for this priority
; 1ms for critical, successively 8x for other queues
stw r16, ReadyQueue.Timecake(r9)
stw r17, ReadyQueue.Timecake + 4(r9)
; Show off a bit
mflr r20
@ -67,7 +76,7 @@ InitRDYQs
mr r8, r23 ; the priority (1,2,3,4)
bl printw
mr r8, r16 ; the Timeslice
mr r8, r16 ; the time cake
bl printw
mr r8, r17
@ -77,8 +86,7 @@ InitRDYQs
mtlr r20
; Multiply Timeslice by 8 for the next iteration
; Multiply time by 8 for the next iteration
slwi r16, r16, 3
rlwimi r16, r17, 3, 29, 31
slwi r17, r17, 3
@ -89,11 +97,10 @@ InitRDYQs
addi r9, r9, 32 ;ReadyQueue.Size
blt+ @loop
; If the low nybble is empty, set ContextBlock.PriorityShifty to 2.
lwz r16, KDP.PA_ECB(r1)
lwz r17, ContextBlock.PriorityShifty(r16)
andi. r9, r17, (1<<4)-1
andi. r9, r17, 0xF
li r17, 2
bnelr-
@ -102,6 +109,14 @@ InitRDYQs
###### ### ## ## ######## ###### ######## ######## ######
## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ###### ## #### ######## ######## ######
## ######### ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ### ######## ###### ## ## ## ######
; ...to (ECB *)r6
; (and also copy SPRG0 to r8)
@ -144,6 +159,14 @@ Save_r24_r31
## ####### ### ######## ###### ######## ######## ######
## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## #### ######## ######## ######
## ## ## ######### ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ##
######## ####### ## ## ######## ###### ## ## ## ######
; ...from (ECB *)r6
Restore_r14_r31
@ -184,6 +207,14 @@ Restore_r24_r31
###### ### ## ## ######## ######## ######## ######## ######
## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ###### ###### ######## ######## ######
## ######### ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ### ######## ## ## ## ## ######
; ...to (ECB *)r6
; (but first set the MSR_FP bit in MSR, but *unset* it in r11)
@ -246,6 +277,13 @@ Save_f0_f31
## ####### ### ######## ## ## ######## ######
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ######## ######
## ## ## ######### ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
######## ####### ## ## ######## ### ## ## ######
Restore_v0_v31 ; OUTSIDE REFERER
li r8, 0x200
@ -452,6 +490,14 @@ major_0x13988_0x2f8
###### ### ## ## ######## ## ## ######## ######
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ###### ## ## ######## ######
## ######### ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ### ######## ### ## ## ######
; Save_v0_v31
; Xrefs:
@ -638,15 +684,22 @@ Save_v0_v31_0x1b8
; Remove a task from a queue, cleaning up the queue structures behind me.
######## ### ###### ## ## ## ## ## ## ######## ######## ## ##
## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## #### ## ## ## ## ## ####
## ## ## ###### ##### ## ## ## ## ## ######## ## ## ##
## ######### ## ## ## ## ## ## #### ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ##
## ## ## ###### ## ## ####### ## ## ## ## ######## ##
; Remove a task from its RDYQ, cleaning up the queue structures behind me.
; If a queue is empty, unset the priority flag of the queue in
; PSA.PriorityFlags (presumably has no effect with non-ready queues).
; Also set the mysterious EWA.BinaryFlag to 1.
; PSA.PriorityFlags. Also set the mysterious EWA.SchEvalFlag to 1.
; ARG Task *r8
; CLOB r16, r17, r18
DequeueTask
TaskUnready
lwz r17, Task.QueueMember + LLL.Next( r8)
lbz r18, Task.MysteryByte1( r8)
@ -691,32 +744,18 @@ DequeueTask
mfsprg r17, 0
li r16, 1
stb r16, EWA.BinaryFlag(r17)
stb r16, EWA.SchEvalFlag(r17)
blr
; TaskReadyAsNext
; Xrefs:
; major_0x02ccc
; MPCall_6
; KCYieldWithHint
; MPCall_55
; KCStopScheduling
; MPCall_18
; MPCall_23
; MPCall_27
; MPCall_52
; MPCall_9
; KCThrowException
; MPCall_114
; major_0x130f0
; major_0x142dc
; CommonPIHPath
######## ### ###### ## ## ######## ######## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ####
## ## ## ###### ##### ######## ## ## ##
## ######### ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ###### ## ## ## ## ######## ##
; These two entry cases specify different directions of queue insertion
@ -787,6 +826,13 @@ TaskReadyCommonPath
###### ######## ######## ### ######## ###### ######## ########
## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ##
###### ######## ###### ######## ## ## ## ###### ###### ##
## ## ## ## ## ## ######### ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ######## ## ## ## ###### ######## ##
; Set the segment and block allocation table registers according to the
; SPAC structure passed in. On non-601 machines, unset the "guarded" bit
@ -796,7 +842,7 @@ TaskReadyCommonPath
; ARG AddressSpace *r8, AddressSpace *r9 (can be zero?)
SetAddrSpcRegisters
SetSpaceSRsAndBATs
; This is the only function that hits this counter
lwz r17, KDP.NanoKernelInfo + NKNanoKernelInfo.AddrSpcSetCtr(r1)
@ -1084,59 +1130,41 @@ SetAddrSpcRegisters_0x314:
; major_0x142a8
######## ######## ######## ## ### ## ## ## ##
## ## ## ## ## ## ## ### ## ## ##
## ## ## ## ## ## ## #### ## ####
######## ###### ## ## ## ## ## ## ## ##
## ## ## ## ## ######### ## #### ##
## ## ## ## ## ## ## ## ### ##
## ## ######## ## ## ## ## ## ## ##
; Xrefs:
; skeleton_key
major_0x142a8 ; OUTSIDE REFERER
lbz r8, EWA.BinaryFlag(r1)
rlwinm. r9, r7, 0, 16, 16
lwz r1, -0x0004(r1)
ReturnToAnyTask ; OUTSIDE REFERER
lbz r8, EWA.SchEvalFlag(r1)
rlwinm. r9, r7, 0, 16, 16
lwz r1, EWA.PA_KDP(r1)
cmpwi cr1, r8, 0x00
; sprg0 = for r1 and r6
; r1 = kdp
; r6 = register restore area
; r7 = flag to insert into XER
; r10 = new srr0 (return location)
; r11 = new srr1
; r12 = lr restore
; r13 = cr restore
bne- int_teardown
bne- ReturnFromInterrupt
beq+ cr1, ReturnFromInterrupt
; sprg0 = for r1 and r6
; r1 = kdp
; r6 = register restore area
; r7 = flag to insert into XER
; r10 = new srr0 (return location)
; r11 = new srr1
; r12 = lr restore
; r13 = cr restore
beq+ cr1, int_teardown
; r6 = ewa
bl Save_r14_r31
; r8 = sprg0 (not used by me)
_Lock PSA.SchLock, scratch1=r27, scratch2=r28
_Lock PSA.SchLock, scratch1=r27, scratch2=r28
; major_0x142dc
######## ######## ######## ## ####### ######## ## ## ######## ########
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
######## ###### ## ## ## ## ## ######### ###### ########
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ######## ## ## ####### ## ## ## ######## ## ##
; Xrefs:
; major_0x02ccc
; CommonMPCallReturnPath
; major_0x142a8
; major_0x14bcc
major_0x142dc ; OUTSIDE REFERER
RescheduleAndReturn ; OUTSIDE REFERER
mfsprg r14, 0
li r8, 0x00
stb r8, EWA.BinaryFlag(r14)
stb r8, EWA.SchEvalFlag(r14)
lwz r31, -0x0008(r14)
lwz r1, -0x0004(r14)
lwz r9, 0x0ee4(r1)
@ -1153,7 +1181,7 @@ major_0x142dc_0x38
cmpw r27, r26
mr r8, r31
beq- major_0x142dc_0x58
bl DequeueTask
bl TaskUnready
stb r26, 0x0019(r31)
mr r8, r31
bl TaskReadyAsPrev
@ -1174,7 +1202,7 @@ major_0x142dc_0x5c
addi r30, r29, -0x08
major_0x142dc_0x80
lhz r28, -0x0116(r14)
lhz r28, EWA.CPUIndex(r14)
lwz r24, 0x0064(r30)
lhz r25, 0x001a(r30)
rlwinm. r8, r24, 0, 25, 26
@ -1264,7 +1292,15 @@ major_0x142dc_0x1bc
; int_teardown
######## ######## ####
## ## ## ##
## ## ## ##
######## ###### ##
## ## ## ##
## ## ## ##
## ## ## ####
; ReturnFromInterrupt
; All MPCalls get here?
; r0,7,8,9,10,11,12,13 restored from r6 area
@ -1276,8 +1312,8 @@ major_0x142dc_0x1bc
; Xrefs:
; non_skeleton_reset_trap
; major_0x142a8
; major_0x142dc
; ReturnToAnyTask
; RescheduleAndReturn
; major_0x14548
; > sprg0 = for r1 and r6
@ -1289,20 +1325,20 @@ major_0x142dc_0x1bc
; > r12 = lr restore
; > r13 = cr restore
int_teardown ; OUTSIDE REFERER
ReturnFromInterrupt ; OUTSIDE REFERER
lwz r8, 0x0edc(r1)
mfsprg r1, 0
mtlr r12
mtspr srr0, r10
mtspr srr1, r11
rlwinm. r8, r8, 0, 27, 27
beq- int_teardown_0x2c
beq- ReturnFromInterrupt_0x2c
mfxer r8
rlwinm r8, r8, 0, 23, 21
rlwimi r8, r7, 19, 23, 23
mtxer r8
int_teardown_0x2c
ReturnFromInterrupt_0x2c
mtcr r13
lwz r10, 0x0154(r6)
lwz r11, 0x015c(r6)
@ -1323,7 +1359,7 @@ int_teardown_0x2c
; major_0x14548
; Xrefs:
; major_0x142dc
; RescheduleAndReturn
major_0x14548 ; OUTSIDE REFERER
lwz r16, 0x0064(r31)
@ -1381,12 +1417,12 @@ major_0x14548_0x58
cmpwi r16, 0x00
mr r8, r31
beql+ TaskReadyAsPrev
major_0x14548_0xd4
mfsprg r19, 0
li r8, 0x00
stb r8, EWA.BinaryFlag(r19)
lhz r8, -0x0116(r19)
stb r8, EWA.SchEvalFlag(r19)
lhz r8, EWA.CPUIndex(r19)
lwz r6, 0x0088(r30)
lwz r28, -0x0340(r19)
sth r8, 0x001a(r30)
@ -1411,7 +1447,7 @@ major_0x14548_0xd4
cmpw r18, r9
beq- major_0x14548_0x148
mr r8, r18
bl SetAddrSpcRegisters
bl SetSpaceSRsAndBATs
major_0x14548_0x148
mfsprg r19, 0
@ -1430,7 +1466,7 @@ major_0x14548_0x148
bsol+ cr6, Local_Panic
clrlwi r8, r7, 0x08
stw r8, 0x0000(r6)
lwz r6, 0x0658(r1)
lwz r6, KDP.PA_ECB(r1)
addi r26, r1, 0x360
mtsprg 3, r26
stw r26, 0x00f0(r30)
@ -1449,9 +1485,9 @@ major_0x14548_0x148
stw r7, -0x0010(r19)
major_0x14548_0x1cc
lwz r17, 0x00cc(r6)
lwz r17, ContextBlock.PriorityShifty(r6)
ori r17, r17, 0x100
stw r17, 0x00cc(r6)
stw r17, ContextBlock.PriorityShifty(r6)
lhz r17, -0x043c(r1)
lwz r18, 0x067c(r1)
cmplwi r17, 0xffff
@ -1578,14 +1614,14 @@ major_0x14548_0x380
; r11 = new srr1
; r12 = lr restore
; r13 = cr restore
b int_teardown
b ReturnFromInterrupt
; major_0x148ec
; Xrefs:
; major_0x142dc
; RescheduleAndReturn
; major_0x14548
major_0x148ec ; OUTSIDE REFERER
@ -1666,18 +1702,20 @@ major_0x148ec_0xc8
; setup
; KCStopScheduling
; major_0x0c8b4
; major_0x0ccf4
; SignalSemaphore
; MPCall_28
; major_0x0d35c
; SetEvent
; MPCall_8
; major_0x130f0
; major_0x142dc
; RescheduleAndReturn
; major_0x14bcc
; CommonPIHPath
; Almost certain this was hand-written. Has a typo, and some
; instructions the compiler rarely touched, and is in hot path.
; ARG Task *r8
major_0x149d4 ; OUTSIDE REFERER
crset cr1_eq
b major_0x149d4_0xc
@ -1688,61 +1726,58 @@ CalculateTimeslice ; OUTSIDE REFERER
major_0x149d4_0xc:
; CALCULATE TASK'S TIMESLICE
; Get task info
lwz r18, Task.QueueMember + LLL.Next(r8)
lwz r16, Task.QueueMember + LLL.Freeform(r8) ; points to RDYQ
cmpwi r18, 0
lwz r17, Task.Weight(r8)
beq+ Local_Panic
; Get queue info
lwz r18, ReadyQueue.TotalWeight(r16)
lwz r19, ReadyQueue.Timecake(r16)
lwz r20, ReadyQueue.Timecake + 4(r16)
; Skip some stuff if this task accounts for all of the weight in this queue
; Skip calculation if only task in queue
cmpw r18, r17
rlwinm r17, r17, 10, 0, 22 ; looks like a typo; should multiply wt by 1024
rlwinm r17, r17, 10, 0, 22 ; r17 *= 1024, but with minor masking typo?
beq- @is_only_weighted_task
divw. r18, r17, r18 ; how many slices do I get in 1024?
divw. r18, r17, r18 ; r8 = my share of this queue's weight, out of 1024
ble- @no_time ; if not specified, fall back on 1/1024
ble- @no_time ; fall back on one slice worth of ticks per 1024 slices
; r19 || r20 = (r19 || r20) * r18 = ticks owed to this task in 1024 slices
; t = t * r18 = my share of queue's time, out of 1024
mulhw r17, r20, r18
mullw r19, r19, r18
mullw r20, r20, r18
add r19, r19, r17
@no_time
; Set r19 || r20 to ticks owed to this task per RoundRobinTime
; t = t / 1024 = my share of queue's time
srwi r20, r20, 10
rlwimi r20, r19, 22, 0, 9
srwi r19, r19, 10
@is_only_weighted_task
; NOW: r19 || r20 == task's slice of queue Timecake, in TB/DEC units
; Now r19 || r20 contains something meaningful
lbz r18, Task.Priority(r8)
cmpwi r18, Task.kNominalPriority
ori r20, r20, 1 ; why make this odd?
bge- @nominal_or_idle
bge- @priority_nominal_or_idle
; Critical or latency protection: save the low word of (ticks per round)
;critical or latency protected
stw r20, 0x00fc(r8)
blr
@priority_nominal_or_idle
@nominal_or_idle
lwz r16, 0x00d8(r8)
lwz r17, 0x00dc(r8)
beq- cr1, @definitely_do_the_thing
bc BO_IF, cr1_eq, @definitely_do_the_thing
cmpwi r16, 0
cmplwi cr2, r17, 0
blt- @definitely_do_the_thing
@ -1750,6 +1785,7 @@ major_0x149d4_0xc:
bgtlr- cr2
@definitely_do_the_thing
;double-int is negative or zero
mfxer r18
addc r20, r20, r17
adde r19, r19, r16
@ -1780,130 +1816,114 @@ clear_cr0_lt ; OUTSIDE REFERER
; Xrefs:
; IntDecrementer
; major_0x142dc
; RescheduleAndReturn
major_0x14a98 ; OUTSIDE REFERER
rlwinm r8, r7, 10, 0, 0
lwz r18, 0x0658(r1)
lwz r18, KDP.PA_ECB(r1)
nand. r8, r8, r8
lwz r17, 0x00cc(r18)
lwz r17, ContextBlock.PriorityShifty(r18)
bltlr-
cmpwi r17, 0x00
cmpwi r17, 0
rlwinm r9, r17, 0, 22, 22
blt- major_0x14a98_0x54
cmpwi r9, 0x200
lwz r16, 0x01cc(r18)
lwz r16, ContextBlock.r25(r18)
beq- major_0x14a98_0x48
clrlwi r8, r16, 0x1d
clrlwi r9, r17, 0x1c
cmpwi r8, 0x06
clrlwi r8, r16, 29
clrlwi r9, r17, 28
cmpwi r8, 6
bgt- major_0x14a98_0x48
cmpw r8, r9
bltlr-
cmpw r8, r8
major_0x14a98_0x48
ori r17, r17, 0x100
stw r17, 0x00cc(r18)
ori r17, r17, 0x100
stw r17, ContextBlock.PriorityShifty(r18)
blr
major_0x14a98_0x54
clrlwi r17, r17, 0x01
stw r17, 0x00cc(r18)
clrlwi r17, r17, 1
stw r17, ContextBlock.PriorityShifty(r18)
blr
; major_0x14af8
######## ## ### ###### ######## ## ## ### ##
## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## #### ###### ## ## ## ## ##
## ## ######### ## ## ## ## ## ######### ##
## ## ## ## ## ## ## ## ## ## ## ##
## ######## ## ## ###### ######## ### ## ## ########
; Xrefs:
; setup
; major_0x02ccc
; MPCall_6
; KCYieldWithHint
; KCStopScheduling
; KCMarkPMFTask
; MPCall_16
; major_0x0c8b4
; major_0x0ccf4
; MPCall_21
; MPCall_28
; MPCall_26
; MPCall_50
; major_0x0d35c
; major_0x0dce8
; MPCall_8
; MPCall_9
; MPCall_14
; KCThrowException
; MPCall_58
; MPCall_114
; major_0x130f0
; CommonPIHPath
major_0x14af8 ; OUTSIDE REFERER
lwz r16, 0x0064(r8)
FlagSchEvaluationIfTaskRequires ; OUTSIDE REFERER
lwz r16, Task.Flags(r8)
mfsprg r15, 0
rlwinm. r16, r16, 0, 25, 26
rlwinm. r16, r16, 0, Task.kFlag25, Task.kFlag26
bne- major_0x14af8_0xa0
addi r16, r15, -0x340
lbz r17, 0x0019(r8)
lwz r19, 0x0008(r16)
lwz r14, 0x0024(r19)
cmpwi r14, 0x02
blt- major_0x14af8_0xa0
lwz r14, 0x0020(r19)
mr r18, r16
b major_0x14af8_0x3c
major_0x14af8_0x34
addi r16, r15, EWA.CPUBase
lbz r17, 0x0019(r8)
lwz r19, CPU.LLL + LLL.Freeform(r16)
lwz r14, CoherenceGroup.ScheduledCpuCount(r19)
cmpwi r14, 2
blt- major_0x14af8_0xa0
;multiprocessor
lwz r14, CoherenceGroup.CpuCount(r19)
mr r18, r16
b @loopentry
@34
lwz r16, 0x0008(r19)
major_0x14af8_0x38
@38
addi r16, r16, -0x08
major_0x14af8_0x3c
@loopentry
addi r14, r14, -0x01
lbz r20, 0x0229(r16)
lwz r21, 0x0018(r16)
cmpw cr1, r17, r20
rlwinm. r21, r21, 0, 28, 28
bge- cr1, major_0x14af8_0x60
beq- major_0x14af8_0x60
bge- cr1, @60
beq- @60
mr r17, r20
mr r18, r16
major_0x14af8_0x60
@60
lwz r16, 0x0010(r16)
cmpwi cr1, r14, 0x00
cmpw r16, r19
ble- cr1, major_0x14af8_0x78
beq+ major_0x14af8_0x34
b major_0x14af8_0x38
ble- cr1, @78
beq+ @34
b @38
major_0x14af8_0x78
@78
lbz r16, 0x0019(r8)
cmpw r17, r16
blelr-
lhz r17, -0x0116(r15)
lhz r18, 0x022a(r18)
lhz r17, EWA.CPUIndex(r15)
lhz r18, CPU.EWA + EWA.CPUIndex(r18)
cmpw r18, r17
bne- major_0x14af8_0xb4
bne- BEFOUR
major_0x14af8_0x94
NINETYFOUR
li r16, 0x01
stb r16, EWA.BinaryFlag(r15)
stb r16, EWA.SchEvalFlag(r15)
blr
major_0x14af8_0xa0 ; OUTSIDE REFERER
major_0x14af8_0xa0
mfsprg r15, 0
lhz r18, Task.MysteryHalf(r8)
lhz r17, -0x0116(r15) ; somewhere in EWA
lhz r18, Task.CPUIndex(r8)
lhz r17, EWA.CPUIndex(r15)
cmpw r17, r18
beq+ major_0x14af8_0x94
beq+ NINETYFOUR
major_0x14af8_0xb4
BEFOUR
lwz r9, 0x0ee0(r1)
addi r9, r9, 0x01
stw r9, 0x0ee0(r1)
@ -1945,7 +1965,7 @@ major_0x14bcc
_log 'Sch: Symmetric Multiprocessing^n'
_log 'Sch: On CPU '
lhz r8, 0x022a(r3)
lhz r8, CPU.EWA + EWA.CPUIndex(r3)
bl Printh
_log ' ID-'
lwz r8, -0x0340(r3)
@ -1967,75 +1987,101 @@ major_0x14bcc
bl PagingFlushTLB
; This is important to figure out:
_log 'Sch: Starting SMP idle task^n'
_Lock PSA.SchLock, scratch1=r27, scratch2=r28
mfsprg r14, 0
lwz r31, 0x001c(r3)
li r8, 0x00
stb r8, EWA.BinaryFlag(r14)
lwz r6, 0x0088(r31)
stw r31, -0x0008(r14)
stw r6, -0x0014(r14)
lwz r7, 0x0000(r6)
lwz r28, 0x0004(r6)
stw r7, -0x0010(r14)
stw r28, -0x000c(r14)
lwz r8, 0x00f0(r31)
lwz r31, CPU.IdleTaskPtr(r3)
li r8, 0
stb r8, EWA.SchEvalFlag(r14)
lwz r6, Task.ContextBlockPtr(r31)
stw r31, EWA.PA_CurTask(r14)
stw r6, EWA.PA_ContextBlock(r14)
lwz r7, ContextBlock.Flags(r6)
lwz r28, ContextBlock.Enables(r6)
stw r7, EWA.Flags(r14)
stw r28, EWA.Enables(r14)
lwz r8, Task.YellowVecTblPtr(r31)
mtsprg 3, r8
lwz r10, 0x00fc(r6)
lwz r11, 0x00a4(r6)
lwz r13, 0x00dc(r6)
lwz r12, 0x00ec(r6)
lwz r10, ContextBlock.CodePtr(r6)
lwz r11, ContextBlock.MSR(r6)
lwz r13, 0x00dc(r6)
lwz r12, 0x00ec(r6)
_log 'EWA '
mr r8, r14
bl Printw
_log 'ContextPtr '
mr r8, r6
bl Printw
_log 'Flags '
mr r8, r7
bl Printw
_log 'Enables '
mr r8, r28
bl Printw
_log '^n'
addi r16, r31, 0x08
addi r16, r31, Task.QueueMember
RemoveFromList r16, scratch1=r17, scratch2=r18
li r16, 0x02
stb r16, 0x0018(r31)
lwz r16, 0x0064(r31)
ori r16, r16, 0x20
stw r16, 0x0064(r31)
li r16, 2
stb r16, Task.MysteryByte1(r31)
lwz r16, Task.Flags(r31)
ori r16, r16, 0x20
stw r16, Task.Flags(r31)
mfsprg r14, 0
lbz r8, 0x0019(r31)
stb r8, -0x0117(r14)
lwz r8, 0x0070(r31)
li r9, 0x00
bl SetAddrSpcRegisters
lbz r8, Task.Priority(r31)
stb r8, EWA.TaskPriority(r14)
lwz r8, Task.AddressSpacePtr(r31)
li r9, 0
bl SetSpaceSRsAndBATs
_log 'Adding idle task 0x'
mr r8, r31
bl Printw
_log 'to the ready queue^n'
mr r8, r31
bl TaskReadyAsPrev
bl CalculateTimeslice
lwz r16, 0x0018(r3)
ori r16, r16, 0x08
stw r16, 0x0018(r3)
lwz r17, 0x0008(r3)
lwz r16, CPU.Eff(r3)
ori r16, r16, 8
stw r16, CPU.Eff(r3)
lwz r17, Task.QueueMember + LLL.Freeform(r3)
lwz r16, 0x0024(r17)
addi r16, r16, 0x01
stw r16, 0x0024(r17)
li r8, 0x01
li r8, 1
mtspr dec, r8
_log 'Sch: Going to '
mr r8, r11
mr r8, r11 ; MSR
bl Printw
mr r8, r10
mr r8, r10 ; PC
bl Printw
_log '^n'
mr r30, r31
b major_0x142dc_0xd8
b major_0x142dc_0x58
@ -2138,7 +2184,7 @@ StopProcessor
lwz r8, 0x001c(r31)
li r9, 0x00
stw r9, 0x001c(r31)
bl DequeueTask
bl TaskUnready
addi r16, r1, -0xa44
addi r17, r8, 0x08
stw r16, 0x0000(r17)
@ -2147,7 +2193,7 @@ StopProcessor
_AssertAndRelease PSA.SchLock, scratch=r16
_log 'SIGP kStopProcessor^n'
li r3, 0x03
lhz r4, 0x022a(r31)
lhz r4, CPU.EWA + EWA.CPUIndex(r31)
li r0, 0x2e
twi 31, r31, 0x08
_log 'Stop didn''t work - going to sleep.^n'

View File

@ -122,7 +122,7 @@ MPCall_103_0x10c
mr r29, r17
li r16, 0x06
stw r16, -0x0238(r15)
lhz r16, -0x0116(r15)
lhz r16, EWA.CPUIndex(r15)
stw r16, -0x0234(r15)
li r8, 0x02
@ -259,7 +259,7 @@ MPCall_103_0x270
mfsprg r15, 0
li r16, 0x11
stw r16, -0x0238(r15)
lhz r16, -0x0116(r15)
lhz r16, EWA.CPUIndex(r15)
stw r16, -0x0234(r15)
li r8, 0x02
@ -359,12 +359,12 @@ RestoreKernelState_0x144
mfsprg r15, 0
lwz r8, -0x001c(r15)
li r9, 0x00
bl SetAddrSpcRegisters
bl SetSpaceSRsAndBATs
isync
mfsprg r15, 0
li r16, 0x07
stw r16, -0x0238(r15)
lhz r16, -0x0116(r15)
lhz r16, EWA.CPUIndex(r15)
stw r16, -0x0234(r15)
li r8, 0x02
@ -374,7 +374,7 @@ RestoreKernelState_0x144
mfsprg r15, 0
li r16, 0x11
stw r16, -0x0238(r15)
lhz r16, -0x0116(r15)
lhz r16, EWA.CPUIndex(r15)
stw r16, -0x0234(r15)
li r8, 0x02

3031
NanoKernel/NKSync.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,9 @@ Local_Panic set *
; ARG ProcessID r3
; RET OSStatus r3, TaskID r10
DeclareMPCall 7, MPCall_7
MPCall_7 ; OUTSIDE REFERER
@ -17,62 +20,71 @@ MPCall_7 ; OUTSIDE REFERER
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
cmpwi r9, Process.kIDClass
mr r30, r8
bne+ ReleaseAndReturnMPCallInvalidIDErr
lwz r16, 0x0008(r30)
rlwinm. r17, r16, 0, 30, 30
lwz r16, Process.Flags(r30)
rlwinm. r17, r16, 0, 30, 30
bne+ ReleaseAndReturnMPCallOOM
; ARG CPUFlags r7, Process *r8
bl CreateTask
; RET Task *r8
mr. r31, r8
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
mfsprg r15, 0
lwz r17, 0x0000(r31)
stw r17, 0x0154(r6)
lhz r16, -0x0116(r15)
sth r16, 0x001a(r31)
addi r16, r31, 0x100
lwz r17, 0x013c(r6)
stw r17, 0x0164(r16)
lwz r17, 0x0144(r6)
stw r17, 0x00fc(r16)
lwz r17, 0x014c(r6)
stw r17, 0x0114(r16)
lwz r17, Task.ID(r31)
stw r17, ContextBlock.r10(r6)
lhz r16, EWA.CPUIndex(r15)
sth r16, Task.CPUIndex(r31)
addi r16, r31, Task.ContextBlock
lwz r17, ContextBlock.r7(r6)
stw r17, ContextBlock.r12(r16)
lwz r17, ContextBlock.r8(r6)
stw r17, ContextBlock.CodePtr(r16)
lwz r17, ContextBlock.r9(r6)
stw r17, ContextBlock.r2(r16)
stw r4, 0x0098(r31)
lwz r17, 0x0134(r6)
lwz r17, ContextBlock.r6(r6)
stw r17, 0x00ec(r31)
lwz r16, 0x0064(r28)
rlwinm. r8, r5, 0, 30, 30
beq- MPCall_7_0x98
oris r16, r16, 0x40
MPCall_7_0x98
rlwinm. r8, r5, 0, 29, 29
beq- MPCall_7_0xa4
oris r16, r16, 0x02
MPCall_7_0xa4
stw r16, 0x0064(r28)
lwz r16, Task.Flags(r28)
rlwinm. r8, r5, 0, 30, 30
beq- @noflag
oris r16, r16, 0x40 ; Task.kFlag9
@noflag
rlwinm. r8, r5, 0, 29, 29
beq- @noflag2
oris r16, r16, 0x02 ; Task.kFlag14
@noflag2
stw r16, Task.Flags(r28)
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall
;Xrefs:
;setup
;major_0x0bb20
;major_0x0e284
; ARG EmpiricalCpuFeatures r7, Process *r8
; ARG GlobalCPUFlags r7, Process *r8
; RET Task *r8
CreateTask
; Save arg and lr for later
@ -122,9 +134,9 @@ CreateTask
; (NOT a semaphore queue)
addi r16, r28, Task.SemaphoreLLL
StartLoadingWord r17, 'SEMA'
_lstart r17, 'SEMA'
stw r16, LLL.Next(r16)
FinishLoadingWord
_lfinish
stw r16, LLL.Prev(r16)
stw r17, LLL.Signature(r16)
@ -196,8 +208,8 @@ CreateTask
li r16, 0
stb r16, Task.MysteryByte1(r28)
li r16, 9
stw r16, 0x0064(r28)
li r16, 9 ; (Z>>Task.kFlag28) | (Z>>Task.kFlag31)
stw r16, Task.Flags(r28)
lisori r16, 'time'
stw r16, 0x0024(r28)
@ -217,8 +229,8 @@ CreateTask
addi r16, r28, Task.ContextBlock
stw r16, Task.ContextBlockPtr(r28) ; overridden to real ECB on blue
lwz r16, PSA.EmpiricalCpuFeatures(r1)
stw r16, Task.ContextBlock + ContextBlock.EmpiricalCpuFeatures(r28)
lwz r16, PSA.GlobalCPUFlags(r1)
stw r16, Task.ContextBlock + ContextBlock.Flags(r28)
lwz r16, PSA.UserModeMSR(r1)
stw r16, Task.ContextBlock + ContextBlock.MSR(r28)
@ -230,7 +242,7 @@ CreateTask
lwz r17, Task.NotificationPtr(r28)
stw r16, 0x0010(r17)
stw r16, 0x0014(r17)
li r16, -0x7271
li r16, kMPTaskAbortedErr
stw r16, 0x0018(r17)
li r16, 0
@ -346,7 +358,7 @@ MPCall_8 ; OUTSIDE REFERER
mr r8, r31
bl TaskReadyAsPrev
bl CalculateTimeslice
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall
@ -383,7 +395,7 @@ MPCall_9 ; OUTSIDE REFERER
beq- cr1, MPCall_9_0xb4
mfsprg r15, 0
lhz r18, 0x001a(r31)
lhz r17, -0x0116(r15)
lhz r17, EWA.CPUIndex(r15)
cmpw r18, r17
beq- MPCall_9_0xe0
ori r16, r16, 0x400
@ -401,7 +413,7 @@ MPCall_9_0x98 ; OUTSIDE REFERER
ori r16, r16, 0x02
stw r16, 0x0064(r31)
lwz r17, 0x009c(r31)
li r16, -0x7271
li r16, kMPTaskAbortedErr
stw r16, 0x0018(r17)
b MPCall_9_0xfc
@ -416,7 +428,7 @@ MPCall_9_0xe0
ori r16, r16, 0x02
stw r16, 0x0064(r31)
mr r8, r31
bl DequeueTask
bl TaskUnready
MPCall_9_0xf0
lwz r17, 0x009c(r31)
@ -432,7 +444,7 @@ MPCall_9_0xfc
cmpwi r8, 0x01
bne- MPCall_9_0x130
addi r8, r31, 0x20
bl major_0x136c8
bl DequeueTimer
MPCall_9_0x130
lwz r8, 0x0098(r31)
@ -447,7 +459,7 @@ MPCall_9_0x130
bne- MPCall_9_0x15c
mr r31, r8
mr r8, r17
bl major_0x0c8b4
bl EnqueueMessage ; Message *r8, Queue *r31
b ReleaseAndReturnMPCall
MPCall_9_0x15c
@ -595,94 +607,102 @@ MPCall_14_0x70
DeclareMPCall 56, MPCall_56
; MPLibrary passthrough
MPCall_56 ; OUTSIDE REFERER
; When an exception occurs, the message to the queue will be:
; (32 bits) task ID
; (32 bits) exception type a la MachineExceptions.h
; (32 bits) 0 (reserved)
; ARG TaskID r3, QueueID r4
; RET OSStatus r3
DeclareMPCall 56, MPSetExceptionHandler
MPSetExceptionHandler
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
cmpwi r9, Task.kIDClass
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
mr r8, r4
; r8 = id
bl LookupID
cmpwi r9, 0 ; invalid
cmpwi cr1, r9, 0x04
beq- MPCall_56_0x44
cmpwi r9, 0
cmpwi cr1, r9, Queue.kIDClass
beq- @isnil
bne+ cr1, ReleaseAndReturnMPCallInvalidIDErr
@isnil
MPCall_56_0x44
mr r30, r8
stw r4, 0x00f4(r31)
stw r4, Task.ExceptionHandlerID(r31)
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall
; KCThrowException
; MPLibrary passthrough
; Throws an exception to a specified task.
; > r3 = MPTaskID task
; > r4 = MPExceptionKind kind
; ARG TaskID r3, ExceptionKind r4
; RET OSStatus r3
; < r3 = result code
DeclareMPCall 57, MPThrowException
DeclareMPCall 57, KCThrowException
KCThrowException ; OUTSIDE REFERER
MPThrowException
mfsprg r15, 0
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
cmpwi r9, Task.kIDClass
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
lwz r16, 0x0064(r31)
mtcr r16
li r3, -0x7271
beq+ cr7, ReleaseAndReturnMPCall
li r3, -0x726c
beq+ cr5, ReleaseAndReturnMPCall
beq+ cr3, ReleaseAndReturnMPCallOOM
; This is gold!
lwz r16, Task.Flags(r31)
mtcr r16
li r3, kMPTaskAbortedErr
bc BO_IF, 30, ReleaseAndReturnMPCall
li r3, kMPTaskStoppedErr
bc BO_IF, 22, ReleaseAndReturnMPCall
bc BO_IF, 14, ReleaseAndReturnMPCallOOM
lbz r17, 0x0018(r31)
lhz r18, 0x001a(r31)
cmpwi cr1, r17, 0x00
bne- cr1, KCThrowException_0x70
bc BO_IF_NOT, 6, KCThrowException_0x70
ori r16, r16, 0x600
stw r4, 0x00f8(r31)
stw r16, 0x0064(r31)
li r3, -0x726b
li r3, kMPTaskBlockedErr
b ReleaseAndReturnMPCall
KCThrowException_0x70
lhz r19, -0x0116(r15)
lhz r19, EWA.CPUIndex(r15)
cmpw r19, r18
bne- KCThrowException_0xb8
ori r16, r16, 0x200
stw r4, 0x00f8(r31)
stw r16, 0x0064(r31)
mr r8, r31
bl DequeueTask
bl TaskUnready
addi r16, r1, -0xa34
addi r17, r31, 0x08
stw r16, 0x0000(r17)
InsertAsPrev r17, r16, scratch=r18
li r3, -0x726c
li r3, kMPTaskStoppedErr
b ReleaseAndReturnMPCall
KCThrowException_0xb8
@ -720,21 +740,24 @@ MPCall_58 ; OUTSIDE REFERER
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
lwz r29, 0x0064(r31)
lwz r29, Task.Flags(r31)
mtcr r29
li r3, -0x7271
beq+ cr7, ReleaseAndReturnMPCall
beq- cr4, MPCall_58_0x44
bne+ cr5, ReleaseAndReturnMPCallOOM
li r3, kMPTaskAbortedErr
bc BO_IF, 30, ReleaseAndReturnMPCall
bc BO_IF, 18, MPCall_58_0x44
bc BO_IF_NOT, 22, ReleaseAndReturnMPCallOOM
MPCall_58_0x44
mtcr r4
lwz r30, 0x0088(r31)
bns- cr7, MPCall_58_0x68
bc BO_IF_NOT, 31, MPCall_58_0x68
li r8, 0x1c
bl PoolAlloc_with_crset
cmpwi r8, 0x00
beq+ major_0x0af60
beq+ ReleaseAndScrambleMPCall
li r3, 0x00
b MPCall_58_0x114
@ -768,7 +791,7 @@ MPCall_58_0xb4
RemoveFromList r16, scratch1=r17, scratch2=r18
mr r8, r31
bl TaskReadyAsPrev
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
MPCall_58_0xe0
; r1 = kdp
@ -783,14 +806,14 @@ FuncExportedFromTasks ; OUTSIDE REFERER
InsertAsPrev r17, r16, scratch=r18
li r8, 0x1c
bl PoolAlloc_with_crset
lwz r29, 0x0064(r31)
ori r29, r29, 0x200
lwz r29, Task.Flags(r31)
_bset r29, r29, 22
MPCall_58_0x114
mtcr r29
mr r28, r8
beq- cr3, MPCall_58_0x13c
blt- cr5, MPCall_58_0x13c
bc BO_IF, 14, MPCall_58_0x13c
bc BO_IF, 20, MPCall_58_0x13c
lwz r8, -0x08e8(r1)
; r8 = id
@ -802,7 +825,7 @@ MPCall_58_0x114
beq- MPCall_58_0x184
MPCall_58_0x13c
bso- cr4, MPCall_58_0x158
bc BO_IF, 19, MPCall_58_0x158
lwz r8, 0x00f4(r31)
; r8 = id
@ -843,7 +866,7 @@ MPCall_58_0x1a4
stw r17, 0x0018(r8)
stw r18, 0x00f8(r31)
mr r31, r30
bl major_0x0c8b4
bl EnqueueMessage ; Message *r8, Queue *r31
b ReleaseAndReturnMPCall
@ -903,12 +926,15 @@ MPCall_60 ; OUTSIDE REFERER
mr r31, r8
cmpwi r4, 0x05
beq- MPCall_60_0x288
lwz r16, 0x0064(r31)
lwz r16, Task.Flags(r31)
mtcr r16
li r3, -0x7271
beq+ cr7, ReleaseAndReturnMPCall
beq- cr4, MPCall_60_0x4c
bne+ cr5, ReleaseAndReturnMPCallOOM
li r3, kMPTaskAbortedErr
bc BO_IF, 30, ReleaseAndReturnMPCall
bc BO_IF, 18, MPCall_60_0x4c
bc BO_IF_NOT, 22, ReleaseAndReturnMPCallOOM
MPCall_60_0x4c
lbz r16, 0x0018(r31)
@ -1226,12 +1252,15 @@ MPCall_61 ; OUTSIDE REFERER
bne+ ReleaseAndReturnMPCallInvalidIDErr
mr r31, r8
lwz r16, 0x0064(r31)
lwz r16, Task.Flags(r31)
mtcr r16
li r3, -0x7271
beq+ cr7, ReleaseAndReturnMPCall
beq- cr4, MPCall_61_0x44
bne+ cr5, ReleaseAndReturnMPCallOOM
li r3, kMPTaskAbortedErr
bc BO_IF, 30, ReleaseAndReturnMPCall
bc BO_IF, 18, MPCall_61_0x44
bc BO_IF_NOT, 22, ReleaseAndReturnMPCallOOM
MPCall_61_0x44
lbz r16, 0x0018(r31)
@ -1469,41 +1498,38 @@ MPCall_114 ; OUTSIDE REFERER
cmplwi cr1, r17, 0x04
beq+ ReleaseAndReturnMPCallOOM
lwz r16, 0x0064(r31)
lhz r17, 0x022a(r30)
lhz r17, CPU.EWA + EWA.CPUIndex(r30)
ori r16, r16, 0x40
stw r16, 0x0064(r31)
sth r17, 0x001a(r31)
rlwinm. r8, r16, 0, 26, 26
mr r8, r31
bne- MPCall_114_0x90
bl DequeueTask
bl TaskUnready
bl TaskReadyAsPrev
MPCall_114_0x90
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
; r1 = kdp
b ReleaseAndReturnZeroFromMPCall
; KCSetTaskType
; ARG TaskID r3, OSType r4
; RET OSStatus r3
DeclareMPCall 126, KCSetTaskType
KCSetTaskType ; OUTSIDE REFERER
KCSetTaskType
_Lock PSA.SchLock, scratch1=r16, scratch2=r17
mr r8, r3
; r8 = id
bl LookupID
cmpwi r9, Task.kIDClass
bne+ ReleaseAndReturnMPCallInvalidIDErr
stw r4, 0x0074(r8)
; r1 = kdp
stw r4, Task.Name(r8)
b ReleaseAndReturnZeroFromMPCall

View File

@ -20,12 +20,12 @@
; kcRTASDispatch
; ReleaseAndMPCallWasBad
; ReleaseAndReturnZeroFromMPCall
; major_0x0af60
; ReleaseAndScrambleMPCall
; ReleaseAndReturnMPCallBlueBlocking
; major_0x0b054
; ReleaseAndReturnMPCallPrivilegedErr
; major_0x0b0cc
; AlternateMPCallReturnPath
; BlockMPCall
; MPCall_0
; MPCall_6
; KCYieldWithHint
@ -33,7 +33,7 @@
; KCStopScheduling
; MPCall_115
; Local_Panic
; major_0x0d35c
; SetEvent
; MPCall_41
; Local_Panic
; MPCall_9
@ -68,7 +68,7 @@
; major_0x129cc
; Local_Panic
; Local_Panic
; major_0x142dc
; RescheduleAndReturn
; major_0x14548
; Local_Panic
; CommonPIHPath
@ -695,7 +695,7 @@ panic_common
bl Printw
_log ' is CPU '
lhz r8, -0x0116(r17)
lhz r8, EWA.CPUIndex(r17)
bl Printh
_log ' ID-'

View File

@ -92,10 +92,11 @@ InitTMRQs_0xb4
mr. r31, r8
beq+ Local_Panic
li r9, 0x06
stb r9, 0x0014(r31)
li r9, 0x01
stb r9, 0x0016(r31)
li r9, Timer.kKind6
stb r9, Timer.Kind(r31)
li r9, 1
stb r9, Timer.KeepAfterFiring(r31)
bl GetTime
stw r8, Timer.Time(r31)
@ -116,88 +117,91 @@ InitTMRQs_0xb4
; Xrefs:
; IntDecrementer
; major_0x130f0
; TimerFire0
TimerTable
dc.l major_0x130f0 - NKTop
dc.l major_0x13120 - NKTop
dc.l major_0x1318c - NKTop
dc.l major_0x1324c - NKTop
dc.l major_0x132e8 - NKTop
dc.l major_0x13350 - NKTop
dc.l major_0x135b8 - NKTop
dc.l major_0x134bc - NKTop
dc.l major_0x13524 - NKTop
dc.l TimerFireUnknownKind - NKTop ; Timer.kKind0
dc.l TimerFire1 - NKTop ; Timer.kKind1
dc.l TimerFire2 - NKTop ; Timer.kKind2
dc.l TimerFire3 - NKTop ; Timer.kKind3
dc.l TimerFire4 - NKTop ; Timer.kKind4
dc.l TimerFire5 - NKTop ; Timer.kKind5
dc.l TimerFire6 - NKTop ; Timer.kKind6
dc.l TimerFire7 - NKTop ; Timer.kKind7
dc.l TimerFire8 - NKTop ; Timer.kKind8
TimerDispatch ; OUTSIDE REFERER
mflr r19
mfsprg r18, 0
stw r19, -0x0258(r18)
stw r19, EWA.TimerDispatchLR(r18)
TimerDispatch_0x30 ; OUTSIDE REFERER
mfspr r8, pvr
rlwinm. r8, r8, 0, 0, 14
beq- TimerDispatch_0x54
beq- @is_601
TimerDispatch_0x3c
;not 601
@gettime_loop_non_601
mftbu r8
mftb r9
mftbu r16
cmpw r8, r16
bne- TimerDispatch_0x3c
b TimerDispatch_0x90
bne- @gettime_loop_non_601
b @common
TimerDispatch_0x54
@is_601
@gettime_loop_601
mfspr r8, rtcu
mfspr r9, rtcl
mfspr r16, rtcu
cmpw r8, r16
bne- TimerDispatch_0x54
lis r16, 0x3b9a
ori r16, r16, 0xca00
mfspr r17, mq
dc.l 0x7d1040d6
mfspr r16, mq
mtspr mq, r17
bne- @gettime_loop_601
dialect POWER
liu r16, 1000000000 >> 16
oril r16, r16, 1000000000 & 0xffff
mfmq r17
mul r8, r16, r8
mfmq r16
mtmq r17
mfxer r17
addc r9, r16, r9
addze r8, r8
a r9, r16, r9
aze r8, r8
mtxer r17
TimerDispatch_0x90
lbz r19, -0x0309(r18)
addi r30, r18, -0x320
cmpwi r19, 0x01
lwz r16, 0x0038(r30)
bne- TimerDispatch_0xcc
lwz r17, 0x003c(r30)
cmpw r16, r8
cmplw cr1, r17, r9
bgt- TimerDispatch_0xcc
blt- TimerDispatch_0xbc
bgt- cr1, TimerDispatch_0xcc
dialect PowerPC
@common
TimerDispatch_0xbc
lbz r19, EWA.GlobalTimeIsValid(r18)
addi r30, r18, EWA.Base
cmpwi r19, 1
lwz r16, EWA.GlobalTime - EWA.Base(r30)
bne- timer_earlier_than_sometime
lwz r17, EWA.GlobalTime + 4 - EWA.Base(r30)
_b_if_time_gt r16, r8, timer_earlier_than_sometime
@skipbranch
li r19, 0x00
stw r30, -0x0254(r18)
stb r19, 0x0017(r30)
b major_0x132e8_0x10
b TimerFire4_0x10
TimerDispatch_0xcc
timer_earlier_than_sometime
lwz r30, -0x0a7c(r1)
lwz r16, 0x0038(r30)
lwz r17, 0x003c(r30)
cmpw r16, r8
cmplw cr1, r17, r9
bgt- TimerDispatch_0x188
blt- TimerDispatch_0xec
bgt- cr1, TimerDispatch_0x188
TimerDispatch_0xec
_b_if_time_gt r16, r8, TimerDispatch_0x188
RemoveFromList r30, scratch1=r19, scratch2=r20
lwz r19, 0x064c(r1)
lbz r20, 0x0014(r30)
lbz r20, Timer.Kind(r30)
rlwimi r19, r20, 2, 23, 29
cmplwi r20, 0x09
llabel r20, TimerTable
@ -233,7 +237,7 @@ TimerDispatch_0x180:
b TimerDispatch_0x30
TimerDispatch_0x188
lwz r19, -0x0258(r18)
lwz r19, EWA.TimerDispatchLR(r18)
mtlr r19
b AdjustDecForTMRQGivenCurTimeAndTripTime
@ -248,7 +252,7 @@ StartTimeslicing ; OUTSIDE REFERER
mfsprg r19, 0
li r8, 1
stb r8, -0x0309(r19)
stb r8, EWA.GlobalTimeIsValid(r19)
li r8, 0
stw r8, -0x02e8(r19)
@ -278,7 +282,7 @@ AdjustDecForTMRQ
AdjustDecForTMRQGivenCurTime
; This should get the most distant time???
lwz r18, PSA.TimerQueue + Queue.LLL + LLL.Next(r1)
lwz r18, PSA.TimerQueue + LLL.Next(r1)
lwz r16, Timer.Time(r18)
lwz r17, Timer.Time+4(r18)
@ -300,20 +304,15 @@ AdjustDecForTMRQGivenCurTimeAndTripTime
; r16/r17 = soonest(last timer, global PSA time if available)
bne- @global_time_invalid
bne- global_time_invalid
lwz r18, EWA.GlobalTime(r19)
lwz r19, EWA.GlobalTime+4(r19)
cmpw r16, r18
cmplw cr1, r17, r19
blt- @last_timer_fires_sooner
bgt- @global_time_sooner
ble- cr1, @last_timer_fires_sooner
@global_time_sooner
_b_if_time_le r16, r18, last_timer_fires_sooner
mr r17, r19
mr r16, r18
@last_timer_fires_sooner
@global_time_invalid
last_timer_fires_sooner
global_time_invalid
; Subtract the current time (or what we were passed in r8/r9) from that time
@ -341,23 +340,23 @@ AdjustDecForTMRQGivenCurTimeAndTripTime
; major_0x130f0
; TimerFire0
; Xrefs:
; TimerDispatch
major_0x130f0 ; OUTSIDE REFERER
TimerFireUnknownKind
_log 'TimerInformation.kind is zero??^n'
; major_0x13120
; TimerFire1
; Xrefs:
; TimerDispatch
; major_0x130f0
; TimerFire0
major_0x13120 ; OUTSIDE REFERER
TimerFire1 ; OUTSIDE REFERER
bl Local_Panic
lwz r18, 0x0018(r30)
stw r16, 0x0080(r18)
@ -368,29 +367,29 @@ major_0x13120 ; OUTSIDE REFERER
lwz r19, 0x0088(r8)
cmpwi r17, 0x00
stw r16, 0x011c(r19)
bne- major_0x13120_0x64
bne- TimerFire1_0x64
addi r16, r8, 0x08
RemoveFromList r16, scratch1=r17, scratch2=r19
li r17, 0x01
stb r17, 0x0019(r8)
bl TaskReadyAsPrev
bl CalculateTimeslice
bl major_0x14af8
bl FlagSchEvaluationIfTaskRequires
b TimerDispatch_0x144
major_0x13120_0x64
TimerFire1_0x64
lwz r16, 0x0064(r8)
rlwinm. r16, r16, 0, 30, 30
; major_0x1318c
; TimerFire2
; Xrefs:
; TimerDispatch
; major_0x13120
; TimerFire1
major_0x1318c ; OUTSIDE REFERER
TimerFire2 ; OUTSIDE REFERER
bne+ TimerDispatch_0x144
bl Local_Panic
lwz r18, 0x0018(r30)
@ -401,7 +400,7 @@ major_0x1318c ; OUTSIDE REFERER
lbz r17, 0x0018(r8)
lwz r18, 0x0088(r8)
cmpwi r17, 0x00
bne- major_0x1324c_0x8
bne- TimerFire3_0x8
stw r16, 0x011c(r18)
lwz r8, 0x0008(r8)
lwz r8, 0x0000(r8)
@ -411,35 +410,35 @@ major_0x1318c ; OUTSIDE REFERER
cmpwi r9, Queue.kIDClass
cmpwi cr1, r9, 0x05
beq- major_0x1318c_0x8c
beq- cr1, major_0x1318c_0x7c
beq- TimerFire2_0x8c
beq- cr1, TimerFire2_0x7c
cmpwi r9, 0x09
cmpwi cr1, r9, 0x06
beq- major_0x1318c_0x6c
beq- TimerFire2_0x6c
bne+ cr1, Local_Panic
lwz r16, 0x0020(r8)
addi r16, r16, -0x01
stw r16, 0x0020(r8)
b major_0x1318c_0x98
b TimerFire2_0x98
major_0x1318c_0x6c
TimerFire2_0x6c
lwz r16, 0x001c(r8)
addi r16, r16, -0x01
stw r16, 0x001c(r8)
b major_0x1318c_0x98
b TimerFire2_0x98
major_0x1318c_0x7c
TimerFire2_0x7c
lwz r16, 0x001c(r8)
addi r16, r16, -0x01
stw r16, 0x001c(r8)
b major_0x1318c_0x98
b TimerFire2_0x98
major_0x1318c_0x8c
TimerFire2_0x8c
lwz r16, 0x002c(r8)
addi r16, r16, -0x01
stw r16, 0x002c(r8)
major_0x1318c_0x98
TimerFire2_0x98
lwz r8, 0x0018(r30)
addi r16, r8, 0x08
RemoveFromList r16, scratch1=r17, scratch2=r18
@ -447,17 +446,17 @@ major_0x1318c_0x98
; major_0x1324c
; TimerFire3
; Xrefs:
; TimerDispatch
; major_0x1318c
; TimerFire2
major_0x1324c ; OUTSIDE REFERER
bl major_0x14af8
TimerFire3 ; OUTSIDE REFERER
bl FlagSchEvaluationIfTaskRequires
b TimerDispatch_0x144
major_0x1324c_0x8 ; OUTSIDE REFERER
TimerFire3_0x8 ; OUTSIDE REFERER
b Local_Panic
@ -498,7 +497,7 @@ major_0x13258_0x4c
stw r16, 0x0010(r8)
stw r17, 0x0014(r8)
stw r18, 0x0018(r8)
bl major_0x0c8b4
bl EnqueueMessage ; Message *r8, Queue *r31
major_0x13258_0x68
lwz r8, 0x0034(r30)
@ -509,7 +508,7 @@ major_0x13258_0x68
mr r31, r8
bne- major_0x13258_0x80
bl major_0x0ccf4
bl SignalSemaphore
major_0x13258_0x80
lwz r8, 0x002c(r30)
@ -522,62 +521,62 @@ major_0x13258_0x80
; major_0x132e8
; TimerFire4
; Xrefs:
; TimerDispatch
; major_0x13258
major_0x132e8 ; OUTSIDE REFERER
bne- major_0x132e8_0xc
TimerFire4 ; OUTSIDE REFERER
bne- TimerFire4_0xc
lwz r8, 0x0030(r30)
bl major_0x0d35c
bl SetEvent
major_0x132e8_0xc
TimerFire4_0xc
b TimerDispatch_0x144
major_0x132e8_0x10 ; OUTSIDE REFERER
TimerFire4_0x10 ; OUTSIDE REFERER
mfsprg r28, 0
lwz r29, -0x0008(r28)
mr r8, r29
bl DequeueTask
bl TaskUnready
lbz r17, 0x0019(r29)
cmpwi r17, 0x02
bge- major_0x132e8_0x64
bge- TimerFire4_0x64
mr r8, r29
lwz r16, 0x0038(r30)
lwz r17, 0x003c(r30)
bl clear_cr0_lt
bge- major_0x132e8_0x50
bge- TimerFire4_0x50
mr r8, r29
bl TaskReadyAsPrev
bl CalculateTimeslice
b major_0x13350_0x8
b TimerFire5_0x8
major_0x132e8_0x50
TimerFire4_0x50
li r18, 0x02
stb r18, 0x0019(r29)
mr r8, r29
bl TaskReadyAsPrev
b major_0x13350_0x8
b TimerFire5_0x8
major_0x132e8_0x64
TimerFire4_0x64
mr r8, r29
; major_0x13350
; TimerFire5
; Xrefs:
; TimerDispatch
; major_0x132e8
; TimerFire4
major_0x13350 ; OUTSIDE REFERER
TimerFire5 ; OUTSIDE REFERER
bl TaskReadyAsPrev
bl major_0x149d4
major_0x13350_0x8 ; OUTSIDE REFERER
bl major_0x14af8
TimerFire5_0x8 ; OUTSIDE REFERER
bl FlagSchEvaluationIfTaskRequires
mfsprg r18, 0
b TimerDispatch_0x30
@ -605,7 +604,7 @@ major_0x13350_0x8 ; OUTSIDE REFERER
mr r8, r16
bl printb
_log 'scr-'
lwz r16, 0x0658(r1)
lwz r16, KDP.PA_ECB(r1)
lwz r18, 0x0674(r1)
lwz r16, 0x00dc(r16)
and r16, r16, r18
@ -621,7 +620,7 @@ major_0x13350_0x8 ; OUTSIDE REFERER
mr r8, r16
bl printh
_log 'eSR-'
lwz r16, 0x0658(r1)
lwz r16, KDP.PA_ECB(r1)
lwz r16, 0x01cc(r16)
andi. r16, r16, 0x07
mr r8, r16
@ -636,13 +635,13 @@ major_0x13350_0x8 ; OUTSIDE REFERER
; major_0x134bc
; TimerFire7
; Xrefs:
; TimerDispatch
; major_0x13364
major_0x134bc ; OUTSIDE REFERER
TimerFire7 ; OUTSIDE REFERER
addze r16, r16
stw r16, 0x0038(r30)
stw r17, 0x003c(r30)
@ -660,7 +659,7 @@ major_0x134bc ; OUTSIDE REFERER
lwz r18, -0x0438(r1)
lwz r19, 0x0f88(r1)
subf. r19, r18, r19
ble- major_0x13524_0x1c
ble- TimerFire8_0x1c
srwi r19, r19, 11
mfxer r20
@ -681,13 +680,13 @@ major_0x134d8_0x18
; major_0x13524
; TimerFire8
; Xrefs:
; TimerDispatch
; major_0x134d8
major_0x13524 ; OUTSIDE REFERER
TimerFire8 ; OUTSIDE REFERER
addc r17, r17, r18
addze r16, r16
stw r16, 0x0038(r30)
@ -696,7 +695,7 @@ major_0x13524 ; OUTSIDE REFERER
mr r8, r30
bl EnqueueTimer
major_0x13524_0x1c ; OUTSIDE REFERER
TimerFire8_0x1c ; OUTSIDE REFERER
b TimerDispatch_0x144
@ -709,7 +708,7 @@ major_0x13524_0x1c ; OUTSIDE REFERER
mfxer r20
cmpwi cr1, r19, 0x00
srawi r8, r19, 31
beq- cr1, major_0x135b8_0x4
beq- cr1, TimerFire6_0x4
major_0x13544_0x14
mftbu r16
@ -743,16 +742,16 @@ major_0x13544_0x64
; major_0x135b8
; TimerFire6
; Xrefs:
; TimerDispatch
; major_0x13544
major_0x135b8 ; OUTSIDE REFERER
TimerFire6 ; OUTSIDE REFERER
stw r17, 0x003c(r30)
major_0x135b8_0x4 ; OUTSIDE REFERER
TimerFire6_0x4 ; OUTSIDE REFERER
mtxer r20
beq+ cr1, TimerDispatch_0x144
mr r8, r30
@ -873,40 +872,26 @@ EnqueueTimer ; OUTSIDE REFERER
; Remove a Timer from the global timer firing queue (TMRQ).
; If the Timer was to be the next to fire, then perform the
; standard decrementer rollover adjustment.
; ARG Timer *r8
; major_0x136c8
; Xrefs:
; NKSetClockStep
; NKSetClockDriftCorrection
; MPCall_16
; major_0x0c8b4
; major_0x0ccf4
; MPCall_21
; MPCall_28
; MPCall_26
; MPCall_50
; major_0x0d35c
; MPCall_41
; MPCall_31
; MPCall_32
; major_0x0dce8
; MPCall_9
; CommonPIHPath
major_0x136c8 ; OUTSIDE REFERER
lwz r16, 0x0008(r8)
cmpwi r16, 0x00
lwz r18, -0x0a7c(r1)
DequeueTimer
lwz r16, Timer.QueueLLL + LLL.FreeForm(r8)
cmpwi r16, 0
lwz r18, PSA.TimerQueue + TimerQueueStruct.LLL + LLL.Next(r1)
beq+ Local_Panic
RemoveFromList r8, scratch1=r16, scratch2=r17
li r16, 0x00
li r16, 0
cmpw r18, r8
stb r16, 0x0017(r8)
stb r16, Timer.Byte3(r8)
beq+ AdjustDecForTMRQ
blr
@ -966,7 +951,7 @@ TimebaseTicksPerPeriod
; CreateTask
; InitTMRQs
; AdjustDecForTMRQ
; major_0x142dc
; RescheduleAndReturn
; major_0x14548
; RET long r8 tbu, long r9 tbl

View File

@ -189,7 +189,7 @@ VMReturn ; OUTSIDE REFERER
lwz r7, -0x0010(r8)
lwz r6, -0x0014(r8)
_AssertAndRelease PSA.HTABLock, scratch=r8
b skeleton_key
b IntReturn

View File

@ -1,4 +1,5 @@
include 'MacErrors.a'
include 'Multiprocessing.a'
include 'InfoRecords.a'
include 'EmulatorPublic.a'
@ -29,7 +30,7 @@ NKTop
align 5
include 'NKMPCalls.s'
align 5
include 'NKQueues.s'
include 'NKSync.s'
align 5
include 'NKTasks.s'
align 5