02 March 2021, 14:05 | #1 |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
PDOS for Amiga
Hi.
I have written a public domain (not GPL etc) C runtime library (called PDPCLIB) for 8086 and 80836 platforms including MSDOS, Windows, OS/2, Linux, plus mainframe operating systems (MVS, CMS, VSE). You can find that here: http://pdos.sourceforge.net/ I am considering porting that to the Amiga. Preferably using 68000 instructions. But probably with 32-bit ints. I have also written my own public domain operating system (called PDOS) which currently runs on 8086, 80386 and S/3X0 (mainframe). It is available at the same link above. I would like to port that to the Amiga too. I am interested in using GCC 3.2.3, as I have banged that into C90 shape already. I am only interested in supporting the C90 language. I'm not sure if it is technically possible (that's my question), but I was thinking I could start by having a FAT-16 disk (since I already have FAT code) and the "Pos" interface, which is a wrapper on the MSDOS API, and ELF modules, to try to get something operational ASAP. But eventually I would like to support the normal Amiga file system (instead of FAT), and the AmigaDOS API (whatever that is, I'm not familiar with that), and the Amiga Hunk executable format. Some of this will be limited by availability of tools though, as I don't wish to write my own C compiler, assembler or linker. The objective is for AmigaPDOS (or whatever it would be called) to be able to rebuild the kernel under AmigaPDOS, as well as being able to rebuild gcc-amiga-pdos. Note - C90 = ISO C = C89 = ANSI C. I would like to eventually be in a position where a "hello, world" program could be built on a standard AmigaDOS system, with any compiler (such as SAS/C), but using PDPCLIB as the C runtime library, so that the entire "hello, world" is public domain, and then have that program run unchanged on AmigaPDOS. It would also be good if the 68000 emulator could address the entire 4 GiB of memory, but 64 MiB is in fact enough to run GCC 3.2.3. It only needs about 23 MiB to rebuild itself with full optimization. Oh, I'm also not interested in graphics. I am hoping that the Amiga has the ability for an OS to write a character to the screen without needing some sort of graphics library. Any guidance? Thanks. Paul. |
02 March 2021, 14:24 | #2 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Sounds like a nice project!
I'm not an OS coder so can't help you there much, but I do know a few things about the Amiga Hardware. And sadly, one thing you will not be able to do is create a text based screen. The Amiga's native chipsets only support bitplane based graphics using indexed colours. There are no text modes, so you'll have to emulate those yourself. |
02 March 2021, 14:29 | #3 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
However, I would be happy to drive a serial port instead, and rely on the user attaching some sort of VT100 terminal (emulated of course), or another computer, to the serial port prior to booting. I basically have to do something like that for the mainframe version of PDOS too. |
|
02 March 2021, 15:22 | #4 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,020
|
You might want to rethink or rejig the name you've given your project.
PDOS exists under an entirely different guise on Amiga and it would be a shame for your project to fly under the radar because people wrongly assume its the other PDOS |
02 March 2021, 16:38 | #5 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
I now have a specific question. I need to be able to read disk sectors. I assume that it is only possible for an operating system to do that if Kickstart is already loaded. What sort of interface did the very first publicly-released version of Kickstart provide to read disk sectors? I'm after clean 32-bit pointers. And does the latest Kickstart still support that interface? I know there is a freeware replacement for Kickstart. Does it provide the same interface above? Thanks. Paul. |
|
02 March 2021, 17:56 | #6 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,386
|
pdos (rob northen floppy disk code) can read disk sectors
and it doesnt need kickstart to be active. |
02 March 2021, 22:30 | #7 | ||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,767
|
Quote:
But that's not all. Without the OS you will have to control all hardware at the lowest level, including video output, floppy drives etc. some of which is quite complicated on the Amiga because the custom hardware is not autonomous and requires a fair amount of assistance from the CPU. But don't despair - most games do this, so there is plenty of example code you can use. Quote:
Quote:
I suggest learning a bit about Amiga OS now, including exec devices and graphics, then dos when it comes to supporting the 'normal' Amiga file system. The other alternative is to duplicate everything in your own code, which would be a lot of work and preclude running your OS in a multitasking environment. Only do this if you really want your OS to take over the whole machine. Quote:
|
||||
03 March 2021, 00:27 | #8 |
Registered User
Join Date: Mar 2019
Location: Poland
Posts: 61
|
You should start from defining how you would like to run your os on Amiga.
First option is to take over the hardware and have full control of it. This means that, in order to run some of Amiga programs, you'll need to recreate a number of Amiga libraries, device drivers and generally AmigaOS structures. AmigaOS is a sort of modular micro kernel with well defined APIs, where common module types are libraries, devices and resources. In order to run even a simple AmigaOS console application (ie not using any ui elements) the minimum set of libs you'll need to provide is exec.library and dos.library plus a few devices (timer.device, console.device) and resources, but many programs require other libs and will not run without them. To run most Amiga programs you'll at least need: exec.library, dos.library, graphics.library, layers.library, intuition.library, utility.library. You'll need also the following devices: console.device, input.device, keyboard.device, serial.device, trackdisk.device, timer.device and a number of resources like cia.resource, misc.resource, disk.resource etc. Recreating them is huge, time consuming task. The second option is to run your os hosted ie on top of AmigaOS and provide file/memory/console emulation for your PDOS programs using AmigaOS. Later you can try to provide some sort of bridge to native Amiga libraries/devices to run native Amiga programs. For your PDOS the second option is more real to accomplish. I'd start with porting your system to run hosted, test if any application you have source code for can be compiled and run on such system. Then try to add support for native Amiga programs. As for the c standard library, it would be the easiest task - most of the code like string operations etc. will probably compile for Amiga as is. For file operations you will need dos.library. memory allocation - exec.library, console - console.device or graphics.library |
03 March 2021, 04:24 | #9 | ||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
I found this: https://wiki.amigaos.net/wiki/Basic_...ut_Programming BPTR myfilehandle = IDOS->Open(UBYTE* filename, LONG accessMode); That looks doable to me. 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): C:\devel\pdos\pdpclib>grep Pos *.c pdossupc.c: if (PosOpenFile(filename, 0, &handle)) *errind = 1; pdossupc.c: if (PosCreatFile(filename, 0, &handle)) *errind = 1; pdossupc.c: if (PosReadFile(handle, buf, len, &readbytes)) *errind = 1; pdossupc.c: if (PosWriteFile(handle, buf, len, &writtenbytes)) *errind = 1; pdossupc.c: return (PosMoveFilePointer(handle, offset, whence, &dummy)); pdossupc.c: PosCloseFile(handle); pdossupc.c: PosDeleteFile(filename); pdossupc.c: PosRenameFile(old, new); pdossupc.c: *ptr = PosAllocMem(size, POS_LOC20); pdossupc.c: PosFreeMem(ptr); pdossupc.c: PosExec(cmd, env); pdossupc.c: PosGetSystemDate(&year, &month, &day, &dow); pdossupc.c: PosGetSystemTime(&hour, &minute, &second, &hundredths); pdossupc.c: PosGetSystemDate(&year, &month, &day, &dow); pdossupc.c: PosTerminate(retcode); start.c: p = PosGetCommandLine(); start.c: __envptr = PosGetEnvBlock(); As you can see, there are only a small number of OS calls needed. 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? 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. 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. |
||
03 March 2021, 08:55 | #10 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,864
|
It is for AmigaOS 4, if you wanna target AmigaOS classic you’ve to look there instead.
http://amigadev.elowar.com/ |
03 March 2021, 09:49 | #11 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,643
|
I would suggest using a newer gcc if cross-compilation is ok, as they produce much better code..
|
03 March 2021, 10:46 | #12 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
http://amigadev.elowar.com/read/ADCD.../node02D6.html file = Open( name, accessMode ) D0 D1 D2 BPTR Open(STRPTR, LONG) And reading looks clean too: actualLength = Read( file, buffer, length ) D0 D1 D2 D3 LONG Read(BPTR, void *, LONG) Is there any reason I shouldn't be targeting AmigaOS classic? Thanks. Paul. |
|
03 March 2021, 10:48 | #13 |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
I'm not really interested in code quality. I've already put a huge effort into making GCC 3.2.3 C90-compliant. Chasing the latest (or different) compilers and different languages will be an exercise for someone else. I will have moved on to a different machine by then (e.g. VAX).
|
03 March 2021, 10:51 | #14 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
However, in both scenarios I'd have a question: in what way is your OS an OS if it requires a pre-installed other OS? If you use the Kickstart functionality for stuff like reading files, etc you pretty much have to run the whole OS for that to correctly work in all circumstances. It's perhaps best pointed out here that Kickstart doesn't just contain a BIOS, but rather contains the actual micro kernel and a bunch of the OS's libraries etc. The traditional BIOS functionality from the PC doesn't exist as such in the Kickstart, it's all mixed in the with the Amiga OS. Edit: when I reread the above, it dawned on me it may have sounded somewhat harsh. That wasn't the intention, I'm genuinely interested in your reasons for mixing the existing OS with your new OS. Is your goal merely PDS compatibility, or do you want to have your own OS without any of the Amiga OS getting in the way/being used? Last edited by roondar; 03 March 2021 at 11:02. |
|
03 March 2021, 11:05 | #15 | |||||||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Note that once the work had already been done to make GCC C90-compliant (which was done as a separate project), GCC is basically a glorified "hello, world". |
|||||||
03 March 2021, 11:29 | #16 | |||||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
Quote:
Quote:
Quote:
But I bring to the table a C90-compliant GCC and a C90 C runtime library and an existing OS (around 30,000 lines of code). So I have a solution in search of a problem. And part of the problem is that I have spent decades just coming to grips with the difference between PCs and mainframes. I ended up changing the (emulated) mainframe hardware so that I could have 32-bit addressing instead of just 31-bit (while still being compatible with 31-bit and even 24-bit). It's only just recently that I realized that a better goal was to spread PDOS to other hardware rather than the previous goal which was to add functionality to PDOS/386 to make it more of a Windows clone (still command-line though). My exploration of different hardware will be tempered by whatever GCC 3.2.3 is able to target and what executable formats binutils is able to build. When I've exhausted all 32-bit hardware supported by GCC 3.2.3 I will take an interest in later versions of GCC. Or slit my wrists, whatever I feel like doing when/if the time comes. :-) Or maybe I will then try writing my own C compiler or something, something public domain, to replace GCC, even if it is never as good. Or start with the assembler or linker. Or maybe go back to older versions of GCC if there are some 32-bit targets that have been dropped. They dropped i370 after GCC 3.4.6 too, but that is the target I have been using for about 2 decades. Bringing a free C compiler to the commercially-used mainframe environments was a ridiculously long process that even involved the invention of new (emulated) hardware (S/380). Yeah, that's another thing I could do also - work on a public domain emulator. |
|||||
03 March 2021, 11:37 | #17 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
https://en.wikipedia.org/wiki/Amiga_emulation An AROS boot ROM can be used instead of Kickstart |
|
03 March 2021, 12:28 | #18 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Replacing the BIOS, including with a 32-bit version, is a separate exercise which I am unlikely to ever get involved in. And something that wasn't available when the 80386 first came out (which is what I'm really interested in - I want to go backwards and explore that). |
|
03 March 2021, 13:53 | #19 | |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,864
|
Quote:
AmigaOS 4.x introduced Interfaces which are not present in AmigaOS 1.x to 3.x isn’t the classic the way to go? |
|
03 March 2021, 16:56 | #20 | ||||
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
Quote:
Quote:
Essentially, the issue as I understand it is that the trackdisk device in the Kickstart (which you'd need to use to read sectors from disk at the lowest supported level) is not built to be independent of the rest of the OS. Basically, the trackdisk device relies on the kernel for memory allocation and probably runs as a task under Exec as well. If you want to stay compatible with that, you might have to define areas of memory that you can't interact with. And that'll get tricky as one of the areas Exec requires to properly function is the interrupt vector table and secondly, Exec does not guarantee that memory it allocates will be at certain addresses (so the trackdisk.device can end up allocating buffers at essentially a random address). Basically, the issue is that for the Amiga, the BIOS and the OS are essentially intertwined to a high degree and that there is no official way to bypass this and just say, read a sector from a disk. This is one of the reasons why many Amiga games and demos (those that ditched the OS) back in the day usually had their own, custom made, trackloader to read from disk. Quote:
Last edited by roondar; 03 March 2021 at 17:04. |
||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|