Welcome, Guest. Please login or register.

Author Topic: How to Hijack the classic Amiga hardware?  (Read 5613 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline MskoDestnyTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
How to Hijack the classic Amiga hardware?
« on: November 09, 2005, 04:30:59 AM »
I'm writing an operating system and I'm thinking about doing my initial development on it targetting the Amiga (specifically my A4000). So I'm looking for information about two things:

1) How to gain complete control over the processor (get into system mode basically)
2) How to control the basic Amiga hardware without any help from the OS libraries/kickstart ROM.

Since the idea is to replace Amiga OS once the new OS is loaded, there's no need to be system friendly (beyond being able to boot after workbench has loaded). Also the Amiga won't be the primary target(well unless a bunch of weird Amigans want to run a PalmOS clone on their Amigas for some reason) in the long run (it's just a fun and accessible place to start) so making the bootloader flexible isn't a big requirement. It just has to work on my Amiga.
 

Offline MskoDestnyTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Re: How to Hijack the classic Amiga hardware?
« Reply #1 on: November 09, 2005, 01:16:35 PM »
Quote

Zac67 wrote:
No offense meant, but you asking these questions (esp. 1) kind of leaves me in doubt that you're really up to the task...

Well I could just poke the vector table (either the reset vector or some interrupt I know is going to happen soon), but I figured it would be wise to ask here the best approach in case there were any gotchas I should worry about. For all I know the vector table could be in ROM and you can't exactly muck about with VBR in user mode. Heck on many operating systems you can't even poke around in the vector table because it's protected with the MMU (though as I understand it that's not the case on the Amiga).

Quote
If you don't target the Amiga as primary system, but just use it as a development platform, there's no need for 2) since you leave it to normal Kickstart to setup the hardware (RAM, caches, IDE, video, ...) and then take over the machine much like most games do it or other OSes.

It's difficult to write a proper pre-emptive scheduler that runs in user mode. Besides, part of the reason I'm targetting the Amiga is to better understand how the hardware works.

Quote
If you're going to ask 'Then how do I take over the machine?' you're definitely not up to it, sorry.
Okay Mr. Bad Attitude.

Quote
Furthermore, writing a modern OS is nothing one single person can do in his lifetime...
AtheOS was written by a single person. It's now maintained by several people as Syllable, but it was a complete modern working operating system as AtheOS. I've already written an implementation for most of the functionality in the Palm OS memory manager (though once I tackle the MMU, I need to tweak the memory allocator so that two processes can't allocate memory in the same page and to deal with fragmentation using the MMU) and that probably took about a days worth of effort, two at the most.

Quote
movea.l 4.s,a6 ;Execbase
jsr _LVOForbid(a6) ;Disable multitasking

lea $dff000,a5 ;Custom chip base
move.w #$7FFF,intena(a5) ;Disable interrupts
move.w #$7FFF,dmacon(a5) ;Disable DMA

But that will leave me in user mode won't it? Is code in the bootblock of a floppy started in system or user mode? Is there a guide on the format of the bootblock somewhere?

Quote

From hwstartup.asm:
; if full interrupt control is desired, _main must _LVODisable,
; save intenar and disable all interrupts by writing $7fff to
; intena. to restore, write $7fff to intena, or $8000 to saved
; intenar value and write it to intena, and finally _LVOEnable.

So I'm guessing intenar is the read version of intena and that intena is used to control the interrupts generated by the hardware?

Quote
Could be a good idea to have a look at the NetBSD for initialization purposies and hw interface.

Reading driver source code to figure out how the hardware works is a bit of a pain. I suppose the bootloader might be useful, but the code Piru posted seems to have set me in the right direction.

Quote
BTW, if you do not plan to use the MMU (by far, a complicated task), could be a good idea to target the A500 or A600. A lees complicated processor. Try to use UAE to run your soft, that will save you plenty of time

Well I do plan to use the MMU eventually and unfortunately neither the A500 or UAE have an MMU. One of my goals in this project is to bring memory protection to classic Palm OS and I will need to deal with memory fragmentation and I'd rather not use the hackish mechanism Palm OS 5 and below use to deal with that.
 

Offline MskoDestnyTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Re: How to Hijack the classic Amiga hardware?
« Reply #2 on: November 09, 2005, 02:03:46 PM »
A quick google shows mention of a preliminary MMU patch, but I haven't seen any evidence this was integrated into the main source tree. It also looked like it might not be working 100%.

Frankly, I've had bad experiences in the past testing code on emulators so I'd rather not do it now.
 

Offline MskoDestnyTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Re: How to Hijack the classic Amiga hardware?
« Reply #3 on: November 09, 2005, 04:05:27 PM »
Quote

IMHO you might be best off doing some 'oldskool' hardware bashing code first to learn about the hardware (like trackloaders or copper/blitter effects).  Then try to build on this experience later. I'm sure most people reading this topic will have gained thier experience that way.

Well that was the basic plan. I doubt I'll write anything too intersting demo-wise in the near future. The immediate goal is just to figure out how to setup an appropriate screen mode, write some pixels to the screen (since the Palm OS graphics primitives are largely based around the assumption of a dumb framebuffer) and talk to the mouse and keyboard.

At the moment, I'm still having trouble finding decent information on the hardware itself. I don't really need anything beyond OCS level at the moment, but I haven't found a good resource for that kind of info.
 

Offline MskoDestnyTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2004
  • Posts: 363
    • Show all replies
    • http://www.retrodev.com
Re: How to Hijack the classic Amiga hardware?
« Reply #4 on: November 10, 2005, 03:33:58 AM »
Quote

msh5150 wrote:
Get yourself the 3rd revision of the Hardware Reference Manual - that should help a lot! I still use mine quite a bit  :-D

Tracking down an out of print book is a bit more trouble than making an Amiga port of my little OS is worth to me.

Quote
Also this might be of interest on some other bits:
http://www.mways.co.uk/amiga/howtocode/

I found that via google, but by itself it's not very useful. It sort of assumes you already have the hardware manual. A lot of it also geared at using OS functions to get things done.