04 June 2022, 14:00 | #1 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Bootblock completion function
I've written a bootblock trackdisk hunk loader and it's all working fine. Currently to execute the loaded code, the address of the entry point is loaded into A0 and jumped to:
Code:
; BB Header <load hunk file> <clear caches> movea.l rootHunks(pc),a0 ; first root hunk memory jmp (a0) ... rootHunks: ds.l MAX_ROOT_HUNKS ; table of pointers (32-bit addresses, longwords) 3. The boot code returns with results in both D0 and A0. a) Non-zero D0 indicates boot failure. The recoverable alert AN_BootError is presented before continuing. b) Zero D0 indicates A0 contains a pointer to the function to complete the boot. This completion function is chained to with SysBase in A6 after the strap module frees all its resources. It is usually the dos.library initialization function, from the dos.library resident tag. Return from this function is identical to return from the strap module itself. http://amigadev.elowar.com/read/ADCD.../node007D.html Code:
; BB Header <load hunk file> <clear caches> movea.l rootHunks(pc),a0 ; first root hunk memory moveq #0,d0 rts ... rootHunks: ds.l MAX_ROOT_HUNKS ; table of pointers (32-bit addresses, longwords) Perhaps I have misunderstood this, or there is a bug in my implementation. |
04 June 2022, 18:07 | #2 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
|
At what address does it fail? Is your code called? (put a breakpoint on the first instruction
of the loaded code). Check that the stack pointer is the same when you return as it was on entry. KS1.3 (and probably the others) do very little between returning from the BB code and doing literally "JMP (A0)" itself, just cleanup and adding a DF0 DosNode. Maybe you're corrupting some OS data structures or use too much stack for yourself (not sure if that can be an issue though). |
04 June 2022, 18:36 | #3 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
A0, but a function which initialises dos.library, so the system can complete the boot. If you return from the boot block you must have called FindResident("dos.library")and return a pointer to its init function. Nothing else. I'm sure Thomas can provide you with more details. |
|
04 June 2022, 19:03 | #4 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
|
Quote:
If for whatever reason the code is fine with just using exec, graphics and trackdevice shouldn't it still be fine (like OPs code, since it works without returning)? Made a quick test boot block, that allocates some memory, copies some fixed code there and it runs just fine (and can call exec). The linked doc even says "It is usually the dos.library initialization function" indicating that it could be something else. |
|
04 June 2022, 20:05 | #5 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
You can examine my addchip bootblock: https://eab.abime.net/showpost.php?p...3&postcount=25
|
05 June 2022, 01:29 | #6 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Only hop can answer what his code-hunk is really doing. Maybe it just returns with RTS, which could explain the Guru. |
||
05 June 2022, 02:12 | #7 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
Quote:
If he hasn't done that, he's not bypassing the first 32 bytes which can sometimes be interpreted as code when its not. |
|
05 June 2022, 10:20 | #8 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
Quote:
Well, it works as stated. If your code returns with d0=0, then a0 is assumed to be a function pointer to a function that completes the boot. The standard os boot block continues with the dos.library init function, but it can be any other function as well. This other function is not "expected to return" to anything, it just does the booting and takes over the system. If the function returns, then the ROM code runs into WarmCapture (in exec), and then just stops the system with a colored background. Note, however, that if that other function is in your boot block, you have a problem because the memory of your boot block is released after you return, and thus the Os jumps into the wild. IOWs, you need to be sure that this other function runs on its own memory, so you have to allocate memory on your own, and copy or load this other function to this place. The reason for this indirection was that CBM envisioned that some other Dos than Tripos could be used on top of AmigaOs, thus the dos.library is just one potential candidate DOS a boot block could initiate. The dos.library itself initializes itself, then initializes remaining ROM modules, and then the situation differs a bit: Under 3.1.4 and below, it starts a shell (the Initial CLI), then terminates. The initial CLI then initializes the remaining system as part of its InitCLI() function (which is an internal function in the dos.library). In 3.2, this is somewhat different. Dos Init there starts System-startup, then termintes itself, and System-startup initializes the rest of the system, and as last step, it lauches the initial CLI and then quits. It's like the "Init" process of of Unix that takes care of mounting devices and triggering the initial shell. |
|
05 June 2022, 10:33 | #9 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Thanks for all the responses.
Please find attached loader and loadfile source to provide more context (EDIT: To assemble, requires latest build of vasm to support ASSERT directive) My loadfile(s) are not initialising the dos library. I hope this is not a requirement. I was under the impression that the boot process was designed to be flexible, providing the open IO trackdisk request and calling an arbitrary function at the end of it. I didn't realise the Completion Handler had to init DOS. Seems very restrictive. If this is the case, then I guess a JMP is the only option and the bootblock memory can never be reclaimed, unless the system is completely taken-over. It doesn't look like even my simple artificial loadfile is being called. Stack is not being corrupted. I have confirmed that the loadfile is being correctly relocated. I have been testing under stock A500 Kickstart 1.3. Last edited by hop; 05 June 2022 at 10:44. |
05 June 2022, 10:38 | #10 | |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Quote:
This is the case. Hunk memory is AllocMemed and relocated as appropriate. |
|
05 June 2022, 10:40 | #11 | |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Quote:
|
|
05 June 2022, 10:48 | #12 | |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Quote:
Code:
; BB Header movem.l d0-d7/a0-a6,-(sp) <load hunk file> <clear caches> movem.l (sp)+,d0-d7/a0-a6 movea.l rootHunks(pc),a0 ; first root hunk memory moveq #0,d0 rts ... rootHunks: ds.l MAX_ROOT_HUNKS ; table of pointers (32-bit addresses, longwords) EDIT: Perhaps the bootblock code has to adhere to the OS calling convention and is allowed to trash d0-d1/a0-a1 but must preserve all others? |
|
05 June 2022, 11:08 | #13 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
05 June 2022, 12:01 | #14 |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Makes perfect sense. A bootblock is a system call so when writing one the user has to follow the conventions. Unfortunately this is likely to be the only system call that most people will ever write!
If possible, it might be worth explicitly stating this at |
05 June 2022, 12:59 | #15 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
05 June 2022, 13:07 | #16 | |
Registered User
Join Date: Apr 2019
Location: UK
Posts: 172
|
Quote:
What I mean is that most coders call system calls e.g. AllocMem from their application code, and and have to remember that d0-d1/a0-a1 could be trashed internally but their other registers they have used will be preserved. When a bootblock is written by the user, the system calls into the bootblock (application code), so this time the user has to manually implement the same system convention. Kind of upside down. I guess I'm wrong here because there a calls like Supervisor() userfunc which follow the same callback type pattern. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
fd2pragma inline entry for function that returns pointer to another function | Sim085 | Coders. C/C++ | 11 | 02 March 2022 10:38 |
Issue with PiMiGA 1.5 and Speedlink Completion Pro. | Jonny0r | support.OtherUAE | 6 | 17 March 2021 17:55 |
Tab Completion in AmigaDOS | robotriot | support.Apps | 5 | 04 January 2019 12:33 |
ViNCEd tab completion not working on OS 1.3 | Giuseppe | support.Apps | 4 | 21 January 2013 02:54 |
Games you played to completion over and over and never got sick of | CaptainNow | Nostalgia & memories | 60 | 16 December 2011 00:42 |
|
|