03 March 2021, 17:18 | #21 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,569
|
Quote:
I know gcc is not 100% ISO-C compliant in its default setting (which is a bad idea for portability with other compilers), but isn't it just a matter of the option -std=c90or -ansi? As Roondar already indicated this will never work on an Amiga. There is no BIOS (simple interrupt handler from the 70s), but a full-blown multitasking OS in ROM, immediately when you switch on the system. So when you don't want to run as an application under AmigaOS you will have to do everything yourself and access the hardware chips directly. Also note that there is not even a standard FDC chip to access floppy disk dirves, but you have to do everything yourself: turning on the motor, step the head, start the disk-DMA, decode the MFM-data... |
|
03 March 2021, 17:56 | #22 | |||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,378
|
Quote:
Quote:
Quote:
There is no "Bios". There is kickstart. From within the boot sector of the floppy, you have the ability to read arbitrary sectors from disk, as you get the IORequest for floppy IO passed in. That is, you can run without Dos. But you cannot run without exec, graphics or intuition. They are all initialized before the boot sector picks the activity. The only thing it usually does is to initialize the dos.library and thus continue the bootstrap process from that point. |
|||
03 March 2021, 19:15 | #23 | |||||
Registered User
Join Date: Mar 2019
Location: Poland
Posts: 65
|
Quote:
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:
Quote:
Quote:
Quote:
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. |
|||||
03 March 2021, 21:00 | #24 | ||||
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,456
|
Quote:
Quote:
Quote:
Quote:
This is a follow up to earlier comments of mine, where I literally said "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". Context is key here. |
||||
03 March 2021, 23:54 | #25 | |||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
It's a 3 MB executable. Quote:
What about the Amiga 1000? Kickstart is not in ROM. How are the sectors of a floppy disk read without Kickstart being available? Maybe I want to target the Amiga 1000 purely, and for other environments (like Amiga 500) assume that the Kickstart ROM has been replaced with whatever the Amiga 1000 has in ROM (ie ignoring the Amiga 1000 Kickstart disk). Quote:
|
|||
04 March 2021, 00:36 | #26 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,569
|
Quote:
Quote:
You can use it to load your OS instead, but afterwards you still have to do everything yourself. |
||
04 March 2021, 02:50 | #27 | ||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
How about first step is write a 32-bit IBM PC-like BIOS to enable porting of IBM PC operating systems? Here are the main BIOS functions I currently use: C:\devel\pdos\src>grep Bos pdos.c bootedAt = BosGetClockTickCount(); memavail = BosExtendedMemorySize(); rc = BosFixedDiskStatus(x); BosReadKeyboardCharacter(&scan, &ascii); BosReadKeyboardCharacter(&scan, &ascii); retval = BosGetSystemDate(&c,&y,&m,&d); BosSetSystemDate(year / 100,year % 100,month,day); BosGetSystemTime(&ticks,&midnight); BosReadKeyboardCharacter(&scan, &ascii); rc = BosDiskSectorRead(readbuf, 1, drive, track, head, sect); BosDiskReset(drive); rc = BosDiskSectorRLBA(readbuf, 1, drive, sector, 0); BosDiskReset(drive); rc = BosDiskSectorWrite(writebuf, 1, drive, track, head, sect); BosDiskReset(drive); rc = BosDiskSectorWLBA(writebuf, 1, drive, sector, 0); ... Here is a simple example: /* BosWriteText - BIOS Int 10h Function 0Eh */ int BosWriteText(int page, int ch, int color) { union REGS regsin; regsin.h.ah = 0x0e; regsin.h.al = ch; regsin.h.bh = page; regsin.h.bl = color; int86i(0x10 + BIOS_INT_OFFSET, ®sin); return (0); } So Kickstart would be replaced by this BIOS. ie the BIOS would be loaded by the Amiga 1000, and install some interrupt vectors, not necessarily interrupt 0x10, and then wait for the OS disk to be inserted. The OS could be PDOS or Linux or FreeBSD, whatever. (Assuming they used the non-existent 32-bit BIOS, which they probably don't, but PDOS/386 basically does). Actually I would be happy if BosWrite() even did graphics conversion instead of writing to the serial port. So long as it is in the BIOS code, not the OS code. If the hardware hasn't provided text capabilities, then the BIOS should be the thing that compensates for the hardware, it shouldn't be left to the OS to do. That's my current thinking, anyway. That's what "feels right" to me. The BIOS should be providing this hardware separation layer. Having proposed this, ie a deviation from Commodore Kickstart, does this buy me anything: https://en.wikipedia.org/wiki/AROS_R...erating_System A workable AmigaOS Kickstart clone for the Motorola 68000 processor was released on March 31, 2011 as part of a programming bounty. Perhaps this alternate kickstart can be hacked into an actual BIOS? It may even contain character to graphics conversion capability already? |
||
04 March 2021, 03:17 | #28 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
I took a look at GCC 3.2.3 and there is a target called "rs6000". Do you think that would produce code that will run on these newer flavors of Amiga hardware? I'm still talking about 32-bit of course. |
|
04 March 2021, 03:33 | #29 | ||||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
Quote:
Quote:
|
||||
04 March 2021, 08:55 | #30 | ||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,378
|
Quote:
Quote:
Code:
struct DosLibrary *DOSBase; int main(int argc,char **argv) { DOSBase = OpenLibrary("dos.library",40); ... } |
||
04 March 2021, 09:10 | #31 | ||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
|
||
04 March 2021, 09:19 | #32 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,378
|
Quote:
However, see the autodocs: You cannot block the interrupts for an elongated time and hope that the system returns in proper shape. It probably works on your system, due the imense work that went into this hack, but that doesn't mean that the system supports this type of activity. |
|
04 March 2021, 09:31 | #33 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,456
|
Quote:
It is however certainly true it doesn't always (fully) work. IIRC it has some issues with networking in particular and no doubt it may have other incompatibilities as well. Overall, the best advice IMHO would still be to either use the OS or not use it at all. |
|
04 March 2021, 10:10 | #34 | ||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,378
|
Quote:
Quote:
Code:
struct Library *OpenLibrary(const char *name) { struct Library *l; for(l = SysBase->LibList.lh_Head;l->lib_Node.ln_Succ;l = l->lib_Node.ln_Succ) { if (!strcmp(name,l->lib_Node.ln_Name)) return lib; } return NULL } Of course, there's a bit more than this (version checking, disk access if not found), but that's the pattern. There is no interrupt here anyhwere. There is nothing linked. The executable just retrieves the library pointer, and in that library is an array of functions, one of which is Read(). In old times, there was still a set of "stub functions" in amiga.lib which called through the function pointer array of the library, but today, most compilers create the indirect jump through the function pointer array of the library transparently. |
||
04 March 2021, 10:16 | #35 | |||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,839
|
Quote:
Quote:
Quote:
Quote:
Quote:
The IBM PC BIOS was written in assembler. I suggest you do the same for your BIOS, then you can make use of code from games that take over the system (which are almost always written in pure assembly language). This BIOS could also be used in other 68k based machines, including DIY computers - something I have been thinking of doing myself. You might be interested in a program for the Amiga called 'The Transformer' - a PC emulator that was launched with the A1000 - which does something quite similar to what you propose. It has all the standard PC BIOS functions (including reading and writing 720k FAT format disks), plus an x86 CPU emulator to run PC code. When the program is run it takes over the entire machine, installs its own interrupt vectors and controls the hardware directly, including character based screen output. Unfortunately the source code to the Transformer seems to have been lost, however I have disassembled the exe and am working on making it compatible with higher spec Amigas. If this is successful then I will split off the x86 emulator part to make a standalone BIOS that could be used on an Amiga or other 68k hardware. |
|||||
04 March 2021, 10:39 | #36 | |
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Thanks. That's getting closer to what I need. How does SysBase get set? At some point there needs to be some sort of communication between the OS and the executable, whether that is an interrupt, a parameter passed at startup, or a DLL. I can't think of any other way to do it. Well, unless the entire functionality is linked into the executable, directly manipulating the hardware and bypassing the OS altogether.
Quote:
http://amigadev.elowar.com/read/ADCD.../node02E0.html would have resided in amiga.lib? I think I would like to revive that, to be able to build PDPCLIB (and thus GCC etc) according to the official docs of the Amiga 1000, and have the source still work in newer 68k environments. |
|
04 March 2021, 10:48 | #37 | |||
Registered User
Join Date: Mar 2021
Location: Ligao, Free World North
Posts: 228
|
Quote:
Quote:
Quote:
|
|||
04 March 2021, 10:49 | #38 | ||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,378
|
Quote:
Code:
SysBase = *((struct ExecBase **)(4L)); Quote:
Today, compilers do not need these stub functions but create the call code directly. |
||
04 March 2021, 11:03 | #39 | ||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,839
|
Quote:
Turning on the motor is pretty easy. Encoding and decoding the disk data is a lot harder. The Amiga does it with a combination of Blitter and CPU operations. Most other machines have a dedicated disk controller (eg. uPD765) to do it, which makes the job a lot easier but is not as flexible. It gets even more complicated when a disk is written to by a PC. The PC controller only writes one sector at a time, causing corruption in the sector gaps that can upset the Amiga's sync detector (the Amiga normally reads and writes whole tracks, so the sector gaps are always clean). Quote:
|
||
04 March 2021, 11:30 | #40 | |||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,839
|
Quote:
Quote:
No idea on timeframe. Right now I just want to get it working on faster Amigas to see what use it could have been if properly written (the code is full of MOVE SR instructions that crash on 68010 and later CPUs, and doesn't like FastRAM). Quote:
|
|||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|