Thread: PDOS for Amiga
View Single Post
Old 03 March 2021, 19:15   #23
Docent
Registered User
 
Join Date: Mar 2019
Location: Poland
Posts: 60
Quote:
Originally Posted by kerravon View Post
Yes, I want to do this - but it will be a minimal implementation. Just enough to run C90 programs - and specifically C90 programs that have been built using PDPCLIB.
Taking over the hardware can be done but it will significantly limit the possibility to use any of the additional devices or expansion cards - their drivers are offered as system devices and require AmigaOS to run. You'll be limited to default PAL/NTSC display, builtin keyboard, serial and floppy.
Additionally, bear in mind that Amiga hardware is more complex than most of its competitors. For example, the floppy controller is not a simple pc controller that only requires to specify track/sector number to read it. Its a DMA controller that reads the whole track in MFM format and you need to decode it yourself to read a sector.
Get "Amiga Hardware Reference Manual Third Edition" from here https://commodore.bombjack.org/amiga/amiga-books.htm You'll find there the information on Amiga hardware directly from the source

Now, As I wrote earlier in order to recreate some of AmigaOS functionality, you'll need to implement a number of libraries and devices.
Amiga doesn't have any sort of minimal BIOS, its Kickstart contains all required libraries and devices and it is initialized when the computer is turned on.
Get "Amiga ROM Kernal Reference Manual Libraries Third Edition" and "Amiga ROM Kernal Reference Manual Devices Third Edition" from the link above and see yourself that there is no way to build some minimal implementation without reimplementing most of exec.library and a number of devices. Things like memory management, interrupt handling, task management, scheduling, libraries/devices handling need to be implemented with exact clones of all AmigaOS structures for compatibility.
Basically, you need to implement the whole microkernel functionality.
Quote:
Originally Posted by kerravon View Post
Ok, thanks for the pointer.

I found this:

https://wiki.amigaos.net/wiki/Basic_...ut_Programming

BPTR myfilehandle = IDOS->Open(UBYTE* filename, LONG accessMode);

That looks doable to me.
This is for AmigaOS4. This version targets PPC cpus, you'll probably want to target Motorola 68k based Amiga classic systems, ie. Kickstart 1.3,2.0, 3.0 or 3.1. There is no interfaces there, just plain Open/Close calls. See the books I listed above for details.

Quote:
Originally Posted by kerravon View Post
PDPCLIB implements PDOS/386 (a 32-bit version of MSDOS, basically) with the use of Pos*() function calls, which you can see here (with some edits to avoid confusion):

So basically for AmigaOS I need to replace PosOpenFile() with Open().

If I use the Open() from dos.library that comes with a recent version of AmigaOS, will the resulting executable actually work on the very first version of AmigaOS on the Amiga 1000?
Unless you use functions that were added later for KS 2.0 or 3.0 it should work - usually API in newer Kickstarts is compatible with previous versions.

Quote:
Originally Posted by kerravon View Post
I would like PDPCLIB to be able to be used with the standard dos.library, but I would also like to build my own mini dos.library with just Open() etc that PDPCLIB actually needs.
As I mentioned earlier, it will be quite easy to use dos.library when running hosted. But even mini dos.library reimplementation will require other system components to be recreated. For your PDPCLIB, just redirect all Open/Close/Read/Write calls to their counterparts in dos.library. You'll just need to have initialized DosBase first.

Quote:
Originally Posted by kerravon View Post
Regardless, when I have my executable that calls Open(), what does that executable actually look like? Is there some code linked in that does an INT like MSDOS, or is there a DLL reference like Windows uses, and the AmigaOS (or AmigaPDOS) loader will modify the executable to provide a pointer to the code that needs to be executed?

Thanks. Paul.
In order to call a function in a library, you need to have an initialized library base. To get initialized library base, the library needs to be opened first.
There is one library (exec.library) that is always open and its LibraryBase is usually at $4 address. Exec.library contains functions to open/close other libraries and devices. So, to call a function from dos.library, first you need to call OpenLibrary from exec.library with "dos.library" as a name and 0 for any version. If this function succeeded, you'll get from it a pointer to DosBase. AmigaOS includes/pragmas resolve dos.library's Open call to a call relative to DosBase, so you need initialized DosBase first to perform any dos library function calls. This is also the case for any other library or device.
In an executable, generated assembly code is usually in the form of jsr -440(a6), where DosBase is first loaded in register a6 and -440 is a negative offset in jumptable, containing jump to address of called function in a library.
Docent is offline  
 
Page generated in 0.04316 seconds with 11 queries