Commit dc348188 authored by Kevin Bracey's avatar Kevin Bracey
Browse files

ChocolateSysVars and ChocolateOscli merged from Ursula.

Version 4.84. Tagged as 'Kernel-4_84'
parent a5fd3ad0
......@@ -6,9 +6,9 @@
GBLS Module_MinorVersion
GBLS Module_Date
GBLS Module_FullVersion
Module_MajorVersion SETS "4.83"
Module_Version SETA 483
Module_MajorVersion SETS "4.84"
Module_Version SETA 484
Module_MinorVersion SETS ""
Module_Date SETS "17 Aug 1999"
Module_FullVersion SETS "4.83"
Module_Date SETS "19 Aug 1999"
Module_FullVersion SETS "4.84"
END
/* (4.83)
/* (4.84)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 4.83
#define Module_MajorVersion_CMHG 4.84
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Aug 1999
#define Module_Date_CMHG 19 Aug 1999
#define Module_MajorVersion "4.83"
#define Module_Version 483
#define Module_MajorVersion "4.84"
#define Module_Version 484
#define Module_MinorVersion ""
#define Module_Date "17 Aug 1999"
#define Module_Date "19 Aug 1999"
#define Module_FullVersion "4.83"
#define Module_FullVersion "4.84"
......@@ -967,6 +967,11 @@ SyncCodeA_sema # 1 ; re-entrancy semaphore for SynchroniseCodeAreas
]
AlignSpace 4
Oscli_CmdHashSum # 4 ;for hashed command lookup
Oscli_CmdHashLists # 4 ;anchor for hashed command lists structure
! 0, "Oscli_CmdHashSum at ":CC::STR:(Oscli_CmdHashSum)
! 0, "Oscli_CmdHashLists at ":CC::STR:(Oscli_CmdHashLists)
Serv_SysChains # 4 ;anchor for block handling 'system' service numbers, in range 1 to 255
Serv_UsrChains # 4 ;anchor for block handling 'user' service numbers, > 255
Serv_AwkwardChain # 4 ;anchor for chain handling non-compliant modules (no service table)
......
This diff is collapsed.
......@@ -2876,6 +2876,19 @@ InitDynamicAreas ENTRY "r0-r8,r11"
]
[ Oscli_HashedCommands
MOV r3,#4*(Oscli_MHashValMask+1)
BL ClaimSysHeapNode ; better not fail
MOV r0,#0
STR r0,[r0,#Oscli_CmdHashSum]
STR r2,[r0,#Oscli_CmdHashLists]
MOV r3,#Oscli_MHashValMask+1
DynArea_OHinit_loop
STR r0,[r2],#4
SUBS r3,r3,#1
BNE DynArea_OHinit_loop
]
[ NewStyle_All
STR r0, [r0, #CDASemaphore] ; clear CDASemaphore
]
......
......@@ -370,11 +370,15 @@ ARM810_POST SETL {FALSE} :LAND: ARM810support
GBLL ChocolateSysHeap ;whether to save cost of SysHeap block claim/release for common cases (eg. callback blocks)
;also reduces SysHeap stress by using fewer blocks in total
GBLL ChocolateOSMod ;whether to reduce SysHeap stress in module handling
GBLL ChocolateSysVars ;whether to do performance improvements in system variable handling
GBLL ChocolateOscli ;whether to do performance improvements in Oscli command stuff
GBLL ChocolateService ;whether to implement fast module service call distribution (uses table introduced
;into module format by Ursula API
ChocolateSysHeap SETL {TRUE}
ChocolateOSMod SETL {TRUE}
ChocolateSysVars SETL {TRUE}
ChocolateOscli SETL {TRUE}
ChocolateService SETL {TRUE}
[ ChocolateSysHeap
GBLA MaxChocolateCBBlocks ;max quick CallBack blocks available at any one time (else ordinary heap nodes used)
......
......@@ -2009,6 +2009,12 @@ CallInit ROUT
; to make sure module's init entry is called before service entry (command
; and SWI hashing don't have these worries - they won't be used yet)
[ Oscli_HashedCommands
; see if we need to update command hash nodes
BL AddCmdHashEntries
BVS %FT02
]
; see if we need to set up a module swi node
BL CheckForSWIEntries
......@@ -2108,6 +2114,9 @@ CallInit ROUT
02 LDR R12, [stack, #4*(6+2)]
BL FreeIncarnation
[ Oscli_HashedCommands
BL FreeCmdHashEntries
]
[ ChocolateService
BL RemoveFromServiceChains
]
......@@ -2216,6 +2225,216 @@ FreeSWIEntry ROUT
]
Pull "R0-R4, R12, PC",,^
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[ Oscli_HashedCommands
ASSERT Oscli_MHashValMask = &ff
;entry: R11 -> module cmd table, R4-> 8-word (256-bit) sieve workspace
;exit: sieve updated, R0-R3,R5,R6 trashed
;
CmdHashSieve ROUT
MOV R0,R4
MOV R1,#0
MOV R2,#8
10
STR R1,[R0],#4 ;zero the sieve
SUBS R2,R2,#1
BNE %BT10
;commands with either of these flags set in information word won't be of interest:
MOV R5,#FS_Command_Flag :OR: Status_Keyword_Flag
MOV R0,R11
18
MOV R6,#0 ;hash value accumulator
LDRB R1,[R0],#1
CMP R1,#0
BEQ %FT40 ;no more entries
20
UpperCase R1,R2
ADD R6,R6,R1 ;hash value is sum of upper cased char values
LDRB R1,[R0],#1
CMP R1,#0
BNE %BT20
ADD R0,R0,#3
BIC R0,R0,#3 ;align to word boundary
LDR R1,[R0,#4] ;pick up information word
TST R1,R5
BNE %FT30 ;not interested in this type of command
AND R6,R6,#&FF ;hash value (256-wide)
AND R2,R6,#&1F
MOV R3,#1
MOV R3,R3,LSL R2 ;position in sieve word
MOV R6,R6,LSR #5 ;sieve word index
LDR R1,[R4,R6,LSL #2]
ORR R1,R1,R3 ;set bit in sieve for this hash value
STR R1,[R4,R6,LSL #2]
30
ADD R0,R0,#4*4 ;next command entry (skip 4 word fields)
B %BT18
40
MOV PC,LR
;
;entry: R0 -> Oscli_CmdHashLists array
; R6 = hash index
;exit: node created/expanded if necessary to allow room for at least 1 more hash ptr
; R1 -> node (may have moved, or been created)
; OR V set, error returned if no room
;
; - a cmd hash node is:
; 1 word = max count (according to current size of node)
; 1 word = current count (N)
; N words = the entries themselves (entries are module node pointers)
;
CheckRoomForNewCmdHash ROUT
Push "R0,R2,R3,LR"
LDR R1,[R0,R6,LSL #2] ;pick up list for this hash value
CMP R1,#0
BNE %FT10
Push "R0,R1"
MOV R3,#(5+2)*4 ;enough for 5 entries, plus the two count words
BL ClaimSysHeapNode
STRVS R0,[SP]
Pull "R0,R1"
BVS %FT90
MOV R1,R2
MOV R3,#5
STR R3,[R1,#0] ;set the max count word
MOV R3,#0
STR R3,[R1,#4] ;zero the current count word
STR R1,[R0,R6,LSL #2] ;store pointer to node in array
B %FT90
10
LDR R3,[R1,#0] ;pick up the max count
LDR R2,[R1,#4] ;pick up thr current count
ADD R2,R2,#1 ;need one more entry
CMP R2,R3
BLS %FT90
Push "R0"
MOV R0,#HeapReason_ExtendBlock
MOV R2,R1
MOV R3,#4*4 ;enough for 4 more entries
BL DoSysHeapOpWithExtension
STRVS R0,[SP]
Pull "R0"
BVS %FT90
MOV R1,R2
STR R1,[R0,R6,LSL #2] ;store pointer to node in array (may have moved)
LDR R3,[R1,#0]
ADD R3,R3,#4
STR R3,[R1,#0] ;bump max count by 4
90
STRVS R0,[SP]
Pull "R0,R2,R3,PC"
;
;
;entry: R9 -> module node
;exit: module entered into command hash table(s) where appropriate
; OR V set, error returned if no room
;
AddCmdHashEntries ROUT
Push "R0-R6,R11,R12,LR"
LDR R12,[R9,#Module_incarnation_list]
CMP R12,#0
BNE %FT90 ;only do stuff if no incarnations yet
LDR R12,[R9,#Module_code_pointer]
LDR R11,=UtilityMod
CMP R12,R11
BEQ %FT90 ;ignore UtilityModule (Oscli deals directly with it)
LDR R11,[R12,#Module_HC_Table]
CMP R11,#0
BEQ %FT90 ;no commands
ADD R11,R12,R11 ;R11 -> command table
SUB SP,SP,#8*4 ;256-bit workspace for 256-wide hashing sieve
MOV R4,SP
BL CmdHashSieve
;now our sieve has a bit set for each hash value that this module occupies for commands
MOV R0,#0
LDR R0,[R0,#Oscli_CmdHashLists]
MOV R6,#0
42
AND R2,R6,#&1F
MOV R3,#1
MOV R3,R3,LSL R2 ;position in sieve word
MOV R5,R6,LSR #5 ;sieve word index
LDR R1,[R4,R5,LSL #2]
TST R1,R3
BEQ %FT50 ;module does not occupy this hash value
BL CheckRoomForNewCmdHash ;returns R1 -> cmd hash node
BVS %FT88
LDR R2,[R1,#4] ;current no. of entries on list
ADD R2,R2,#1
STR R2,[R1,#4]
ADD R1,R1,#4
STR R9,[R1,R2,LSL #2] ;store ptr to module node at end of list
50
ADD R6,R6,#1 ;next hash value
CMP R6,#256
BLO %BT42
88
ADD SP,SP,#8*4 ;drop sieve workspace
90
STRVS R0,[SP]
Pull "R0-R6,R11,R12,PC"
;
;
;entry: R9 -> module node
;exit: module removed from cmd hash table(s) as necessary
;
FreeCmdHashEntries ROUT
Push "R0-R6,R11,R12,LR"
LDR R12,[R9,#Module_incarnation_list]
CMP R12,#0
BNE %FT90 ;only do stuff if no incarnations
LDR R12,[R9,#Module_code_pointer]
LDR R11,=UtilityMod
CMP R12,R11
BEQ %FT90 ;ignore UtilityModule (Oscli deals directly with it)
LDR R11,[R12,#Module_HC_Table]
CMP R11,#0
BEQ %FT90 ;no commands
ADD R11,R12,R11 ;R11 -> command table
SUB SP,SP,#8*4 ;256-bit workspace for 256-wide hashing sieve
MOV R4,SP
BL CmdHashSieve
;now our sieve has a bit set for each hash value that this module occupies for commands
MOV R0,#0
LDR R0,[R0,#Oscli_CmdHashLists]
MOV R6,#0
42
AND R2,R6,#&1F
MOV R3,#1
MOV R3,R3,LSL R2 ;position in sieve word
MOV R5,R6,LSR #5 ;sieve word index
LDR R1,[R4,R5,LSL #2]
TST R1,R3
BEQ %FT50 ;module does not occupy this hash value
LDR R1,[R0,R6,LSL #2] ;pick up list for this hash value
LDR R2,[R1,#4] ;current no. of entries on list
SUB R2,R2,#1
STR R2,[R1,#4]
ADD R1,R1,#8 ;scrunch list to remove module (R9)
MOV R3,R1
CMP R2,#0
BEQ %FT50
ADD R2,R2,#1
40
LDR R5,[R1],#4
CMP R5,R9
STRNE R5,[R3],#4
SUBS R2,R2,#1
BNE %BT40
50
ADD R6,R6,#1 ;next hash value
CMP R6,#256
BLO %BT42
ADD SP,SP,#8*4 ;drop sieve workspace
90
Pull "R0-R6,R11,R12,PC",,^ ;MUST preserve flags
;
] ;Oscli_HashedCommands
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[ ChocolateService
......@@ -2834,6 +3053,9 @@ ModuleIsntCAO
HaveKilled
|
BVS %BT01
]
[ Oscli_HashedCommands
BL FreeCmdHashEntries
]
BL FreeSWIEntry
......
......@@ -14,6 +14,19 @@
;
TTL => Oscli - main Oscli code and system commands.
;
;mjs performance enhancements for Ursula (ChocolateOscli)
;
GBLL Oscli_QuickAliases
GBLL Oscli_HashedCommands
Oscli_QuickAliases SETL {TRUE} :LAND: ChocolateOscli ;try to do a better job of checking for aliases
Oscli_HashedCommands SETL {TRUE} :LAND: ChocolateOscli ;try to do a better job of finding commands
Oscli_CHashValMask * &1f ;32-wide Command hashing, for commands within kernel
Oscli_MHashValMask * &ff ;256-wide Module hashing, for command groups in other modules
; - kernel cmd hashed tables must be reorganised if Oscli_CHashValMask is changed
; - UtilityModule MUST be first in module chain, if hashing in use
GBLL redirectinkey
redirectinkey SETL True
......@@ -329,6 +342,51 @@ pfssss LDRB R10, [R1], #1
; If success : Recursively call OSCLI for each line in expansion.
Push "R0, R3-R6"
[ Oscli_QuickAliases
;
;at least make a vague attempt not to run like a drain - since we can do a binary
;chop search for an exactly known var name, do this unless command is abbreviated
;
ADR R6,AliasStr_QA
LDR R3,=AliasExpansionBuffer ; construct the alias name here
MOV R5,#6
oqa_loop1 ; bung in "ALIAS$"
LDRB R4,[R6],#1
STRB R4,[R3],#1
SUBS R5,R5,#1
BNE oqa_loop1
MOV R6,R0
ADRL R2, Up_ItAndTerm_Check_Table
oqa_loop2 ; bung in command, upper cased
LDRB R4,[R6],#1
CMP R4,#&80 ; char in table ?
LDRCCB R4,[R2,R4]
STRB R4,[R3],#1
CMP R4,#0
BNE oqa_loop2
LDRB R4,[R3,#-2] ; pick up last char of command
CMP R4,#"."
BEQ oqa_treacletime ; it's abbreviated, go to slow code
LDR R3,=AliasExpansionBuffer
Push "r6,r7"
BL VarFindIt_QA ; quick binary chop type stuff
Pull "r6,r7",EQ
BEQ oqa_quicksilvertime_noalias ; no alias - carry on
;found alias
MOV R0,#-1 ; special, VarFindIt skipping call (r5,r6,r7 from VarFindIt_QA)
MOV R1,R3 ; output buffer
MOV R2,#256
MOV R3,#0
MOV R4,#VarType_Expanded
SWI XOS_ReadVarVal ; expand it
Pull "r6,r7"
SUB R6,R6,#1 ; arg ptr
B oqa_quicksilvertime_alias
oqa_treacletime
;
] ;Oscli_Quickaliases
[ International
MOV R3,#0
LDRB R6,[R3,#ErrorSemaphore] ; We are about to get lots of buffer overflow errors,
......@@ -339,7 +397,7 @@ pfssss LDRB R10, [R1], #1
MOV R3, #:LEN: "Alias$"
31 SUB R3, R3, #:LEN: "Alias$"
MOV R2, #-1 ; negative length means just look for it.
ADR R0, AliasStr
ADRL R0, AliasStr
SWI XOS_ReadVarVal
CMP R2, #0 ; V always set anyway
[ International
......@@ -397,6 +455,9 @@ pfssss LDRB R10, [R1], #1
MOV R3, #0
MOV R4, #VarType_Expanded
SWI XOS_ReadVarVal
[ Oscli_QuickAliases
oqa_quicksilvertime_alias
]
BVS AliasOscliTooLong
MOV R3, #13
STRB R3, [R1, R2]
......@@ -458,11 +519,17 @@ AliasOscliTooLong
LTORG
[ Oscli_QuickAliases
AliasStr_QA = "ALIAS$", 0
]
AliasStr = "Alias$*", 0
AliasDot = "Alias$"
dotstring = ".", 0
ALIGN
[ Oscli_QuickAliases
oqa_quicksilvertime_noalias
]
10 ; Failed macro expansion.
Pull "R0, R3-R6"
......@@ -471,12 +538,71 @@ dotstring = ".", 0
CMP R1, #"."
BEQ PercentDot
[ Oscli_HashedCommands
BL Oscli_cmd_hashsum ; => hash value in r1
MOV r2,#0
STR r1,[r2,#Oscli_CmdHashSum]
CMP r1,#0
BEQ oscli_sysabbrevation
BL SysCommsHashedLookup
B oscli_syslook_done
oscli_sysabbrevation
]
ADRL R1, SysCommsModule
MOV R2, #SCHCTab-SysCommsModule
TEQP PC, #C_bit :OR: SVC_mode ; carry set means sys module
BL ModCommsLookUp
oscli_syslook_done
BCS OscliExit
[ Oscli_HashedCommands
;now try UtilityModule, if non-abbreviated command
Push "R2"
MOV r2,#0
LDR r1,[r2,#Oscli_CmdHashSum]
CMP r1,#0
Pull "R2",EQ
BEQ oscli_modabbreviation
BL UtilCommsHashedLookup
ADDCS stack, stack, #4 ;discard R2
BCS OscliExit
;now try list of modules on hash value
MOV r2,#0
LDR r1,[r2,#Oscli_CmdHashSum]
AND r1,r1,#Oscli_MHashValMask
LDR r11,[r2,#Oscli_CmdHashLists]
CMP r11,#0
LDRNE r11,[r11,r1,LSL #2]
CMPNE r11,#0
BEQ %FT75
Push "r3,r4"
ADD r3,r11,#8
LDR r4,[r11,#4]
ADD r4,r4,#1
oscli_hlist_loop
SUBS r4,r4,#1
Pull "r3,r4",EQ
BEQ %FT75
LDR R2,[stack,#2*4]
CMP R2, #0
Pull "r3,r4",MI
BMI OneModule_Failed
LDR R11,[R3],#4
LDR R1, [R11, #Module_code_pointer]
LDR R2, [R1, #Module_HC_Table]
CMP R2, #0
BEQ oscli_hlist_loop
LDR R12, [R11, #Module_incarnation_list] ; preferred life
ADD R12, R12, #Incarnation_Workspace
TEQP PC, #SVC_mode ; clear C
BL ModCommsLookUp
BCC oscli_hlist_loop
Pull "r3,r4"
ADD stack,stack,#4
B OscliExit
oscli_modabbreviation
] ;Oscli_HashedCommands
; now try looking round the modules.
MOV R11, #Module_List
Push "R2"
......@@ -584,7 +710,7 @@ OscliExit
07
Push "R0, R3-R6"
MOV R6, R0
ADR R0, AliasDot
ADRL R0, AliasDot
MOV R3, #0
MOV R2, #-1 ; negative length means just look for it.
SWI XOS_ReadVarVal
......@@ -597,6 +723,96 @@ PercentDot ; entry for *%.
MOV R0, #FSControl_CAT ; *., skip .
B %BT71
;***************************************************************************
[ Oscli_HashedCommands
;
; - routine to compute hash value for unabbreviated commands
; - does not apply mask to hash value (since different hash widths are
; required in different cases)
;
; hash value = sum of all chars of command, excluding terminator, all
; chars being processed through Up_ItAndTerm_Check_Table
;
; entry:
; R0 -> command
; exit:
; R1 = hash value, or 0 if invalid (abbreviation encountered)
;
Oscli_cmd_hashsum ROUT
Push "r0,r2-r3,lr"
MOV r1,#0
ADRL r2, Up_ItAndTerm_Check_Table
B %FT15
10
ADD r1,r1,r3
15
LDRB r3,[r0],#1
CMP r3,#&80
LDRCCB r3,[r2,r3]
CMP r3,#"."
BEQ %FT30
CMP r3,#0
BNE %BT10
20
Pull "r0,r2-r3,PC"
30
MOV r1,#0
Pull "r0,r2-r3,PC"
;
;special entry of ModCommsLookUp, for hashed lookup of commands in SysCommsModule
;entry: R0 -> command, r1 = hash value of command
;
SysCommsHashedLookup ROUT
Push "R0, R2-R10, lr"
;
;first a fudge, to allow old syntax (no space before first, numeric, parameter)
;for *fx, *key, *opt and *tv - look for '&' or a numeric char at R0 + 2, 3 or 4
;
MOV R4, #2
schl_fudgeloop
LDRB R2, [R0,R4]
CMP R2, #' '
BLS schl_nofudge
CMP R2, #'&'
BEQ schl_fudge
CMP R2, #'0'
BLO schl_nofudgesofar
CMP R2, #'9'
BLS schl_fudge
schl_nofudgesofar
ADD R4, R4, #1
CMP R4, #4
BLS schl_fudgeloop
schl_nofudge
AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing
ADRL R1, SysCommsModule
ADRL R2, SysCoHashedCmdTab
LDR R2, [R2, R4, LSL #2] ;command list for this hash value
TEQP PC, #C_bit :OR: SVC_mode ;carry set means sys module
B ModCommsLookUp_AltEntry
schl_fudge
ADRL R1, SysCommsModule
ADRL R2, SHC_fudgeulike
SUB R2, R2, R1 ;fudge command list (offset)
TEQP PC, #C_bit :OR: SVC_mode ;carry set means sys module
B ModCommsLookUp_AltEntry
;
;special entry of ModCommsLookUp, for hashed lookup of commands in UtilityMod
;entry: R0 -> command, r1 = hash value of command
;
UtilCommsHashedLookup ROUT
Push "R0, R2-R10, lr"
AND R4, R1,#Oscli_CHashValMask ;hash value, masked for command hashing
ADRL R1, UtilityMod
ADRL R2, UtilHashedCmdTab
LDR R2, [R2, R4, LSL #2] ;command list for this hash value
TEQP PC, #SVC_mode ;clear C
B ModCommsLookUp_AltEntry
;
] ;Oscli_HashedCommands
;***************************************************************************
; Routine to look through a module table for a command, and call it.
......@@ -611,6 +827,9 @@ PercentDot ; entry for *%.
ModCommsLookUp ROUT
Push "R0, R2-R10, lr"
[ Oscli_HashedCommands
ModCommsLookUp_AltEntry
]
MOV R4, #0 ; want all flags clear
TEQ R2, #0 ; don't corrupt C!
MOVMI R4, #FS_Command_Flag
......