📄 os_core.s
字号:
lw $2,0($2) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $2,$2,1 # Extract IE bit
or $4,$4,$2 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
j $31
.end OSSched
.align 2
.globl OSSchedLock
.text
.ent OSSchedLock
OSSchedLock:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
lbu $3,OSRunning
li $2,1 # 0x1
bne $3,$2,$L61
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $4,$2,1 # Clear the IE bit
sll $4,$4,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
lbu $3,OSLockNesting
sw $2,vect_level
addu $3,$3,1
sb $3,OSLockNesting
la $2,vect_level
#APP
lw $2,0($2) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $2,$2,1 # Extract IE bit
or $4,$4,$2 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
$L61:
j $31
.end OSSchedLock
.align 2
.globl OSSchedUnlock
.text
.ent OSSchedUnlock
OSSchedUnlock:
.frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, extra= 0
.mask 0x80000000,-8
.fmask 0x00000000,0
lbu $3,OSRunning
subu $sp,$sp,24
li $2,1 # 0x1
.set noreorder
.set nomacro
bne $3,$2,$L63
sw $31,16($sp)
.set macro
.set reorder
#APP
mfc0 $3,$12 # Get status register
nop # and return it in $v0
srl $4,$3,1 # Clear the IE bit
sll $4,$4,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
lbu $2,OSLockNesting
la $4,vect_level
sw $3,vect_level
.set noreorder
.set nomacro
beq $2,$0,$L65
addu $5,$2,255
.set macro
.set reorder
lbu $2,OSIntNesting
#nop
or $2,$5,$2
andi $2,$2,0x00ff
sb $5,OSLockNesting
.set noreorder
.set nomacro
bne $2,$0,$L66
move $3,$4
.set macro
.set reorder
#APP
lw $4,0($4) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
jal OSSched
j $L63
$L66:
#APP
lw $4,0($3) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
j $L63
$L65:
#APP
lw $4,0($4) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
$L63:
lw $31,16($sp)
#nop
.set noreorder
.set nomacro
j $31
addu $sp,$sp,24
.set macro
.set reorder
.end OSSchedUnlock
.align 2
.globl OSStart
.text
.ent OSStart
OSStart:
.frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, extra= 0
.mask 0x80000000,-8
.fmask 0x00000000,0
lui $2,%hi(OSUnMapTbl) # high
addiu $5,$2,%lo(OSUnMapTbl) # low
lbu $2,OSRunning
subu $sp,$sp,24
lui $3,%hi(OSTCBPrioTbl) # high
sw $31,16($sp)
.set noreorder
.set nomacro
bne $2,$0,$L73
addiu $6,$3,%lo(OSTCBPrioTbl) # low
.set macro
.set reorder
lbu $2,OSRdyGrp
la $3,OSRdyTbl
addu $2,$2,$5
lbu $4,0($2)
#nop
addu $3,$4,$3
lbu $2,0($3)
sll $4,$4,3
addu $2,$2,$5
lbu $3,0($2)
#nop
addu $3,$3,$4
andi $2,$3,0x00ff
sll $2,$2,2
addu $2,$2,$6
sb $3,OSPrioHighRdy
sb $3,OSPrioCur
lw $3,0($2)
#nop
sw $3,OSTCBCur
sw $3,OSTCBHighRdy
jal OSStartHighRdy
$L73:
lw $31,16($sp)
#nop
.set noreorder
.set nomacro
j $31
addu $sp,$sp,24
.set macro
.set reorder
.end OSStart
.align 2
.globl OSStatInit
.text
.ent OSStatInit
OSStatInit:
.frame $sp,24,$31 # vars= 0, regs= 2/0, args= 16, extra= 0
.mask 0x80010000,-4
.fmask 0x00000000,0
subu $sp,$sp,24
li $4,2 # 0x2
sw $31,20($sp)
.set noreorder
.set nomacro
jal OSTimeDly
sw $16,16($sp)
.set macro
.set reorder
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $3,$2,1 # Clear the IE bit
sll $3,$3,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
sw $2,vect_level
sw $0,OSIdleCtr
la $16,vect_level
#APP
lw $4,0($16) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
.set noreorder
.set nomacro
jal OSTimeDly
li $4,200 # 0xc8
.set macro
.set reorder
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $4,$2,1 # Clear the IE bit
sll $4,$4,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
lw $3,OSIdleCtr
li $4,1 # 0x1
sw $2,vect_level
sw $3,OSIdleCtrMax
sb $4,OSStatRdy
#APP
lw $16,0($16) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $16,$16,1 # Extract IE bit
or $3,$3,$16 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
lw $31,20($sp)
lw $16,16($sp)
#nop
.set noreorder
.set nomacro
j $31
addu $sp,$sp,24
.set macro
.set reorder
.end OSStatInit
.align 2
.globl OSTaskIdle
.text
.ent OSTaskIdle
OSTaskIdle:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
la $7,vect_level
$L80:
#APP
mfc0 $3,$12 # Get status register
nop # and return it in $v0
srl $2,$3,1 # Clear the IE bit
sll $2,$2,1 # ...
mtc0 $2,$12 # Restore status register
lw $6,0($7) # Get old interrupt mask
mfc0 $5,$12 # Get status register
and $6,$6,1 # Extract IE bit
or $5,$5,$6 # Merge it into the status register
srl $5,$5,1 # Clear the IE bit
sll $5,$4,1 # ...
mtc0 $5,$12 # Restore status register
#NO_APP
j $L80
.end OSTaskIdle
.align 2
.globl OSTaskStat
.text
.ent OSTaskStat
OSTaskStat:
.frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, extra= 0
.mask 0x80000000,-8
.fmask 0x00000000,0
lbu $2,OSStatRdy
subu $sp,$sp,24
.set noreorder
.set nomacro
bne $2,$0,$L91
sw $31,16($sp)
.set macro
.set reorder
$L89:
.set noreorder
.set nomacro
jal OSTimeDly
li $4,400 # 0x190
.set macro
.set reorder
lbu $2,OSStatRdy
#nop
beq $2,$0,$L89
$L91:
#APP
mfc0 $3,$12 # Get status register
nop # and return it in $v0
srl $2,$3,1 # Clear the IE bit
sll $2,$2,1 # ...
mtc0 $2,$12 # Restore status register
#NO_APP
lw $5,OSIdleCtr
sw $3,vect_level
sw $5,OSIdleCtrRun
sw $0,OSIdleCtr
la $2,vect_level
#APP
lw $2,0($2) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $2,$2,1 # Extract IE bit
or $4,$4,$2 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
li $4,100 # 0x64
mult $5,$4
lw $3,OSIdleCtrMax
mflo $2
beq $3,$0,$L96
divu $0,$2,$3
.set noreorder
bne $3,$0,1f
nop
break 7
1:
.set reorder
mflo $2
subu $2,$4,$2
sll $2,$2,24
sra $2,$2,24
slt $3,$2,101
bne $3,$0,$L97
sb $4,OSCPUUsage
j $L101
$L97:
bltz $2,$L96
sb $2,OSCPUUsage
j $L101
$L96:
sb $0,OSCPUUsage
$L101:
jal OSTaskStatHook
.set noreorder
.set nomacro
jal OSTimeDly
li $4,200 # 0xc8
.set macro
.set reorder
j $L91
.end OSTaskStat
.align 2
.globl OSTCBInit
.text
.ent OSTCBInit
OSTCBInit:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
move $9,$5
andi $8,$4,0x00ff
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $3,$2,1 # Clear the IE bit
sll $3,$3,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
lw $6,OSTCBFreeList
la $7,vect_level
sw $2,vect_level
.set noreorder
.set nomacro
beq $6,$0,$L105
move $3,$7
.set macro
.set reorder
lw $2,4($6)
#nop
sw $2,OSTCBFreeList
#APP
lw $5,0($7) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $5,$5,1 # Extract IE bit
or $4,$4,$5 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
srl $2,$8,3
andi $3,$8,0x7
sb $2,21($6)
sb $3,20($6)
lbu $4,20($6)
lbu $3,21($6)
lui $2,%hi(OSMapTbl) # high
addiu $2,$2,%lo(OSMapTbl) # low
addu $3,$3,$2
addu $4,$4,$2
lbu $5,0($3)
lbu $2,0($4)
sw $9,0($6)
sb $5,23($6)
sb $2,22($6)
sb $8,19($6)
sb $0,18($6)
sh $0,16($6)
sw $0,12($6)
#APP
mfc0 $4,$12 # Get status register
nop # and return it in $v0
srl $2,$4,1 # Clear the IE bit
sll $2,$2,1 # ...
mtc0 $2,$12 # Restore status register
#NO_APP
lui $3,%hi(OSTCBPrioTbl) # high
lw $5,OSTCBList
addiu $3,$3,%lo(OSTCBPrioTbl) # low
sll $2,$8,2
addu $2,$2,$3
sw $6,0($2)
sw $4,vect_level
sw $5,4($6)
.set noreorder
.set nomacro
beq $5,$0,$L108
sw $0,8($6)
.set macro
.set reorder
sw $6,8($5)
$L108:
lbu $3,23($6)
lbu $2,OSRdyGrp
sw $6,OSTCBList
or $2,$2,$3
sb $2,OSRdyGrp
lbu $4,21($6)
la $3,OSRdyTbl
addu $4,$4,$3
lbu $5,22($6)
lbu $2,0($4)
#nop
or $2,$2,$5
sb $2,0($4)
#APP
lw $6,0($7) # Get old interrupt mask
mfc0 $5,$12 # Get status register
and $6,$6,1 # Extract IE bit
or $5,$5,$6 # Merge it into the status register
srl $5,$5,1 # Clear the IE bit
sll $5,$3,1 # ...
mtc0 $5,$12 # Restore status register
#NO_APP
.set noreorder
.set nomacro
j $31
move $2,$0
.set macro
.set reorder
$L105:
#APP
lw $4,0($3) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
.set noreorder
.set nomacro
j $31
li $2,70 # 0x46
.set macro
.set reorder
.end OSTCBInit
.align 2
.globl OSTimeTick
.text
.ent OSTimeTick
OSTimeTick:
.frame $sp,24,$31 # vars= 0, regs= 1/0, args= 16, extra= 0
.mask 0x80000000,-8
.fmask 0x00000000,0
subu $sp,$sp,24
sw $31,16($sp)
jal OSTimeTickHook
lw $6,OSTCBList
li $3,12 # 0xc
lbu $2,19($6)
#nop
beq $2,$3,$L125
li $12,65535 # 0xffff
la $11,OSRdyTbl
li $10,1 # 0x1
la $7,vect_level
li $9,12 # 0xc
$L115:
#APP
mfc0 $8,$12 # Get status register
nop # and return it in $v0
srl $2,$8,1 # Clear the IE bit
sll $2,$2,1 # ...
mtc0 $2,$12 # Restore status register
#NO_APP
lhu $3,16($6)
#nop
addu $2,$3,$12
.set noreorder
.set nomacro
beq $3,$0,$L117
andi $4,$2,0xffff
.set macro
.set reorder
.set noreorder
.set nomacro
bne $4,$0,$L117
sh $2,16($6)
.set macro
.set reorder
lbu $2,18($6)
#nop
andi $2,$2,0x8
bne $2,$0,$L119
lbu $3,23($6)
lbu $2,OSRdyGrp
#nop
or $2,$2,$3
sb $2,OSRdyGrp
lbu $3,21($6)
lbu $4,22($6)
addu $3,$3,$11
lbu $2,0($3)
#nop
or $2,$2,$4
.set noreorder
.set nomacro
j $L117
sb $2,0($3)
.set macro
.set reorder
$L119:
sh $10,16($6)
$L117:
lw $6,4($6)
#APP
lw $5,0($7) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $5,$5,1 # Extract IE bit
or $4,$4,$5 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
#nop
lbu $2,19($6)
#nop
bne $2,$9,$L115
sw $8,vect_level
$L125:
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $4,$2,1 # Clear the IE bit
sll $4,$4,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
lw $3,OSTime
sw $2,vect_level
addu $3,$3,1
sw $3,OSTime
la $2,vect_level
#APP
lw $2,0($2) # Get old interrupt mask
mfc0 $4,$12 # Get status register
and $2,$2,1 # Extract IE bit
or $4,$4,$2 # Merge it into the status register
srl $4,$4,1 # Clear the IE bit
sll $4,$3,1 # ...
mtc0 $4,$12 # Restore status register
#NO_APP
lw $31,16($sp)
#nop
.set noreorder
.set nomacro
j $31
addu $sp,$sp,24
.set macro
.set reorder
.end OSTimeTick
.align 2
.globl OSVersion
.text
.ent OSVersion
OSVersion:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
.set noreorder
.set nomacro
j $31
li $2,200 # 0xc8
.set macro
.set reorder
.end OSVersion
.align 2
.globl disable_ints
.text
.file 2 "../Source/os_cpu.h"
.ent disable_ints
disable_ints:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
#APP
mfc0 $2,$12 # Get status register
nop # and return it in $v0
srl $3,$2,1 # Clear the IE bit
sll $3,$3,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
j $31
.end disable_ints
.align 2
.globl enable_ints
.text
.ent enable_ints
enable_ints:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
.mask 0x00000000,0
.fmask 0x00000000,0
#APP
lw $4,0($4) # Get old interrupt mask
mfc0 $3,$12 # Get status register
and $4,$4,1 # Extract IE bit
or $3,$3,$4 # Merge it into the status register
srl $3,$3,1 # Clear the IE bit
sll $3,$2,1 # ...
mtc0 $3,$12 # Restore status register
#NO_APP
j $31
.end enable_ints
.comm OSCtxSwCtr,4
.comm OSEventFreeList,4
.comm OSEventTbl,24
.comm OSIdleCtr,4
.comm OSCPUUsage,1
.comm OSIdleCtrMax,4
.comm OSIdleCtrRun,4
.comm OSStatRdy,1
.comm OSIntNesting,1
.comm OSLockNesting,1
.comm OSPrioCur,1
.comm OSPrioHighRdy,1
.comm OSRdyGrp,1
.comm OSRdyTbl,2
.comm OSRunning,1
.comm OSTaskCtr,1
.comm OSTCBCur,4
.comm OSTCBFreeList,4
.comm OSTCBHighRdy,4
.comm OSTCBList,4
.comm OSTCBPrioTbl,52
.comm OSTime,4
.lcomm OSIntExitY,1
.lcomm OSTaskIdleStk,2048
.lcomm OSTaskStatStk,2048
.lcomm OSTCBTbl,312
.extern vect_level, 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -