This is a very diagramatical document :) When the user has nothing on his calculator, and is using only TI-OS as TI intended, here is a diagram of user RAM, beginning at 8c01 and going through to FFFF for good measure. +---------------+8C01 | User RAM | | | | | | | | | | | | | | | | | +---------------+ (8BE5) | VAT | +---------------+ FA6F |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+ FFFF After the user puts on the BSL (Bootstrap Loader) for the DHOS, his/her RAM setup map looks like this. (while TI-OS is still execution normal) +---------------+8BF7 | BSL (VE0) | VAT entry #0 (1st one) +---------------+ |otherTIOSvars | VE1+ +---------------+ (8B27)=first byte of free user ram | | | | |FREE USER RAM | | | | | +---------------+ (8BE5)=last byte of free user ram | VAT | +---------------+ FA6F |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+ FFFF When the BSL is executed by using the custom menu thing, the BSL goes through varios preperation stages. Here are the RAM setups that are used and some psuedocode information for what is going on to do it. +---------------+8BF7 | BSL (VE0) | VAT entry #0 (1st one) +---------------+ |otherTIOSvars | VE1+ +---------------+ Arena 0:size=F900-(8b27):owner=FD (free) | | ^ | | | |FREE DHOS MEM | +----this arena begins at (8b27) | | | | +---------------+<---(8be5) | VAT | +---------------+F900 <--End of Arena 0 |Rest of VAT | +---------------+ FA6F |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+ FFFF The BSL sets up the Arena Memory Model, running from the top of free user mem to F900, used for simplicity. The VAT will be moved, although it has not yet. The next step is the moving of the VAT into an arena in the Arena Memory Model so it can be used by the kernal using DHOS memory functions. First, an arena is allocated in the low (where most are) part of the arena memory model. The arena is the size of the VAT, or $FA70-($8BE5) ArenaID=AllocateArena($FA70-($8BE5)) Since I want to access RAM that is not using the arena mem model (the original copy of the VAT), I need to convert the Arena i'm using into that too: AddressOfNewVAT=GetHardAddress(ArenaID) SizeOfNewVAT=SizeOf(ArenaID) then, some standard moving Z80 code to get the stuff into the new arena ld DE,AddressOfNewVAT ;Destination Arena ld HL,($8BE5) ;source of VAT ld BC,SizeOfNewVAT ;size of VAT ldir And so now, here is my new memory map: +---------------+8BF7 | BSL (VE0) | VAT entry #0 (1st one) A +---------------+ r |otherTIOSvars | VE1+ e / +---------------+Arena 1:size=VATSize:owner=0 (Kernal PRocess) n | | VAT copy | a | | | | +---------------+Arena 0:size=FreeMem:owner=FD (Free) M -{ | | e | |FREE DHOS MEM | m | | | o | | | r \ +---------------+F900 <--End of Arena 0 y |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+FFFF By now, a lot of stuff has been initialized, but the main DHOS Kernal code needs to be loaded onto the calculator. So, we do that with this psuedo. But, since we are forcing this code into the top of arena mem, whcih will be a certain location, it does not need to be relocated. But, the reloc function is called for rom patching. ArenaID=AllocateForceHigh(KErnalSize) FileID=Assign("DHOSKERN.SYS",E2Device) LoadFile(ArenaID,FileID) ProcessID=RelocateArena(ArenaID) Since this is the first relocation to occur, the kernal is given PID=0. It has AID of 2, because 0 is the Free Arena, and 1 is the VAT copy. But this will be automatic. So now we have a mem map looking like this: +---------------+8BF7 | BSL (VE0) | VAT entry #0 (1st one) A +---------------+ r |otherTIOSvars | VE1+ e / +---------------+Arena 1:size=VATSize:owner=0 (Kernal PRocess) n | | VAT copy | a | | | | +---------------+Arena 0:size=FreeMem:owner=FD (Free) | | | | | | | | | | | | | | | M -{ | | e | |FREE DHOS MEM | m | +---------------+Arena 2:size=SizeOf(Kernal):owner=FF(process) o | | the Kernal | :PID=0:owner2=0 (it owns itself) r | |Code | y \ +---------------+F900 <--End of Arena 0 |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+FFFF Now, we need to load in the shell from the E2. this is similar to loading the kernal, but this time, wehn we are done we will call it. ShellArena=AllocateArena(SizeOf(Shell)) ShellFile=Assign("SHELL.EXE",E2Device) LoadFile(ShellArena,ShellFile) ShellProcess=RelocateArena(ShellArena) CallProcess(ShellProcess) so, when the shell is called, the mem map looks like this: +---------------+8BF7 | BSL (VE0) | VAT entry #0 (1st one) A +---------------+ r |otherTIOSvars | VE1+ e / +---------------+Arena 1:size=VATSize:owner=0 (Kernal PRocess) n | | VAT copy | a | | | | +---------------+Arena 3:size=SizeOf(shell):owner=FF(process) | |Shell program | :PID=1:owner2=0(kernal) | +---------------+Arena 0:size=FreeMem:owner=FD (Free) | | | | | | | | | M -{ | | e | |FREE DHOS MEM | m | +---------------+Arena 2:size=SizeOf(Kernal):owner=FF(process) o | | the Kernal | :PID=0:owner2=0 (it owns itself) r | |Code | y \ +---------------+F900 <--End of Arena 0 |System Stack | +---------------+FC00 | VIDEO RAM | +---------------+FFFF So, when the shell exits, some more code is executed: KillProcess(ShellProcess) ;althogh this isnt necessary, since its only ; a single tasking system, its used for good ;measure, and also to give the kernal owner- ;ship of all the arenas used by the shell DeallocateArena(ShellArena) ;this releases the arena used by the shell ; to be usable again. although since ;we are exiting, it probly wont be used ; anymore, but its good practice. After that, the BSL does some more stuff that i dont have time to psuedocode, or fully thought through yet :) 1) it kills the KErnal's process, and deallocates its memory. 2) it moves the VAT back to its original location 3) it goes throught the list of modifications to the TI-OS variables, and actually modifies the variables and updates the VAT 4) it deinitializes everthing else and quits back to TI-OS, leaving everything wehre it found it. OK. questions, comments, ideas, please? Jonathan Kaus kaus@cybrzn.com