Booting a homebrew OS. Is it possible?

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Sun Apr 10, 2011 4:03 pm

Yesterday I was chatting with a friend who's now at university studying Operating Systems. He told me how he and a couple of classmates were writing a kernel to boot on a x86 Intel machine, as part of their exercises.

Without entering into too much detail, he told me that to boot on a x86 you just need to write 5 simple lines:

Code: Select all

hang:
    jmp hang
 
    times 510-($-$$) db 0 ;just moving zeros
    db 0x55
    db 0xAA


Apparently (if I understood well) to boot a disk you just need to use all the 512 bytes of the boot sector (510 bytes of zeros + 2 bytes of instructions) and put 0x55 and 0xAA on bytes 511 and 512. From there, you can add your kernel and boot it.

I was wondering (for pure curiosity and to be able to tell my friend "yes, but Atari can do it too" :mrgreen: ), can be this achieved on an Atari ST too? I mean, the TOS is on a ROM, hence, can you bypass the TOS on ROM and load your own homebrew kernel from a floppy or HDD? I've seen code like this one, but I'm not sure how you put it into a floppy and make it boot.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby simonsunnyboy » Sun Apr 10, 2011 7:44 pm

Well most autobooting demos and games do that. Use TOS as a simple BIOS to load the first bootsector and user whatever code from that to boot a custom kernel to takeover the machine.

It is also possible to map code on the cartridge port and have TOS immediately jump to it. The Atari ST Profibuch I think describes the needed special bytes in the cartridge ROM space.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Sun Apr 10, 2011 8:35 pm

Hi Simon, thanks a lot for the reply.

simonsunnyboy wrote:Well most autobooting demos and games do that. Use TOS as a simple BIOS to load the first bootsector and user whatever code from that to boot a custom kernel to takeover the machine.

Yes, I thought it myself, but this means that the TOS is still loaded, right? I mean, my friend was "challenging" with the idea of using the machine with a complete different OS. Like if TOS wasn't there at all. Like if somebody stole your TOS chips :lol:

simonsunnyboy wrote:It is also possible to map code on the cartridge port and have TOS immediately jump to it. The Atari ST Profibuch I think describes the needed special bytes in the cartridge ROM space.

Hmm, mein Deutsch ist nicht gut :? But it gave me the idea of having a look at The Atari Compendium. It says there that Upon a cold or warm boot, microprocessors in the 680x0 series load the initial supervisor stack pointer from the first longword in memory ($0) and begin execution at the PC found in the second longword ($4). I suppose it is done at chip level, so you would have to load your homebrew OS on a chip and point that $4 to the address where your OS is located, right?

The idea of using cartridge is attractive too. I guess that is what Spectre GCR is doing, as seems that the cartridge is loaded before the TOS.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby simonsunnyboy » Sun Apr 10, 2011 8:42 pm

TOS is in ROM so no space is wasted. As long as you make sure that not a single routine from that is called, you can use all available RAM for any desired custom OS.

For a start, ensure that all trap vectors and interupt vectors point into RAM and not ROM space. Any custom OS would install its own dispatcher tables as a first step.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby simonsunnyboy » Sun Apr 10, 2011 8:51 pm

The initial values for PC and SP are actually shadowed from the TOS ROM.

That is the hardware maps any read access to $0 and $4 to the first 8 bytes of the TOS eeprom, at $FC0000 or $E00000, depeding on the TOS version that is builtin.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Sun Apr 10, 2011 9:17 pm

OK, so if I understood correctly, the code I mentioned before could be used as bootlader to start your OS? If so, how do you create a boot disk?

Sent from my HTC Desire using Tapatalk
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby wongck » Mon Apr 11, 2011 12:41 am

I think TOS is used first regardless of boot from Diskette, HDD, ROMPORT or Desktop.
Because the computer will always check the floppy, ROMPORT and HDD first, and how does it do that?
It does it with BIOS calls, and where is that BIOS from?
It loaded codes in the ROM.... or collectively called TOS :mrgreen:
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Mon Apr 11, 2011 10:07 am

wongck wrote:I think TOS is used first regardless of boot from Diskette, HDD, ROMPORT or Desktop.
Because the computer will always check the floppy, ROMPORT and HDD first, and how does it do that?
It does it with BIOS calls, and where is that BIOS from?
It loaded codes in the ROM.... or collectively called TOS :mrgreen:

Are you sure about that? I'm far from being an expert on computers' hardware, but for example PCs have a BIOS that is independent of the OS. I thought the Atari BIOS was independent too, even having OS on ROM.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

joska
Hardware Guru
Hardware Guru
Posts: 4335
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby joska » Mon Apr 11, 2011 10:23 am

AtariSince1989 wrote:Are you sure about that? I'm far from being an expert on computers' hardware, but for example PCs have a BIOS that is independent of the OS. I thought the Atari BIOS was independent too, even having OS on ROM.


TOS = BIOS + XBIOS + GEMDOS + VDI + AES.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Mon Apr 11, 2011 10:35 am

joska wrote:
AtariSince1989 wrote:Are you sure about that? I'm far from being an expert on computers' hardware, but for example PCs have a BIOS that is independent of the OS. I thought the Atari BIOS was independent too, even having OS on ROM.


TOS = BIOS + XBIOS + GEMDOS + VDI + AES.

8O didn't know that. wongck was right then. Thanks you two for the info. Is good to learn something new every day :mrgreen:
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby wongck » Mon Apr 11, 2011 11:41 am

IIRC, there is a boot sequence in the Hitch Hikers Guide to the BIOS.
Now where is that link.... try the Atari Doc Archive.
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Booting a homebrew OS. Is it possible?

Postby Nyh » Mon Apr 11, 2011 12:16 pm

AtariSince1989 wrote:Hi Simon, thanks a lot for the reply.

simonsunnyboy wrote:Well most autobooting demos and games do that. Use TOS as a simple BIOS to load the first bootsector and user whatever code from that to boot a custom kernel to takeover the machine.

Yes, I thought it myself, but this means that the TOS is still loaded, right? I mean, my friend was "challenging" with the idea of using the machine with a complete different OS. Like if TOS wasn't there at all. Like if somebody stole your TOS chips :lol:

A normal PC comes with the BIOS in ROM. Whit the BIOS routines the OS is loaded. This can be MS DOS 3.30, windows 95, Windows XP, Linux, Free BSD etc.

The first ST had also only BIOS in ROM, the rest of the OS was loaded from floppy. See this thread: http://www.atari-forum.com/viewtopic.php?f=8&t=18457. The modern ST's have the complete OS in ROM but you can still boot a new OS from a floppy, like MiNT of Magic or Linux on Falcon or TT. Also most demos completely bypass all ROM OS routines after the boot sector is executed. When TOS tests for an executable bootsector only the BIOS is active, just like on a PC. You can actually remove 4 from the 6 ROM chips and the Atari can still execute the boot sector. You can not remove all ROM chips but neither can you do so on a PC. The BIOS is essential for booting.

However it is not too hard to rewrite everything on an Atari ST, including the BIOS. That would be like replacing the standard ROM with some new ones you created yourself. To do that on a PC would be a lot harder because you need to know about the chip set that is used on the motherboard. Compared to that the hardware of the ST is very well documented.

Making a bootable floppy disk is a bit harder on the ST. Instead of ending with $55 $AA a bootable disk on the Atari has a check sum of $1234. Just add all 256 words of the boot disk and make sure their sum is $1234. To make the same boot sector as in your example you need to do:

Code: Select all

hang:
     bra.s   hang
REPT 254
     DC.W 0
ENDR
     DC.W $B136

bra.s hang will compile into $60FE. $60FE + $B136 = $1234.

Normally the last two bytes are filled with the value $1234 - SUM(other 255 words) to make the boot sector executable. But you can put this fix value at any position you like except for the first word.

Hans Wessels

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Mon Apr 11, 2011 5:01 pm

wongck wrote:IIRC, there is a boot sequence in the Hitch Hikers Guide to the BIOS.
Now where is that link.... try the Atari Doc Archive.

The link is this one :D
There is a DMA Bus Boot Code on page 62.

Hans, thanks for the explanation.

I think I'll try to do some easy ASM stuff just for fun :mrgreen:
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Mon Apr 11, 2011 6:51 pm

Nyh wrote:Making a bootable floppy disk is a bit harder on the ST. Instead of ending with $55 $AA a bootable disk on the Atari has a check sum of $1234. Just add all 256 words of the boot disk and make sure their sum is $1234. To make the same boot sector as in your example you need to do:

Code: Select all

hang:
     bra.s   hang
REPT 254
     DC.W 0
ENDR
     DC.W $B136

bra.s hang will compile into $60FE. $60FE + $B136 = $1234.

Normally the last two bytes are filled with the value $1234 - SUM(other 255 words) to make the boot sector executable. But you can put this fix value at any position you like except for the first word.

Hans Wessels

On Linux you use dd to get the bootsector asm program onto a floppy. On Windows my friend is using John Fine's partcopy. What can you use on Atari?
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby simonsunnyboy » Mon Apr 11, 2011 6:53 pm

i used a little code snippet from Grazey/PHF in the past:

Code: Select all

   ; ---------------------------
   ; ATARI FORUM DEMO  BOOTBLOCK
   ; ---------------------------
   ; (c) 2004 by Simon Sunnyboy / Paradize
   ; Version 23 May 2004
   ;

gemdos equ 1
xbios equ 14
bios equ 13

text

; init program
go:   move.l sp,a5
   lea stackend,sp

; calculate program and data size for TOS - to free unused space
   movea.l 4(a5),a5   ; a5 points 100bytes below program start
   move.l $c(a5),d0
   add.l $14(a5),d0
   add.l $1c(a5),d0
   add.l #$100,d0
   move.l d0,-(sp)
   move.l a5,-(sp)
   move.w #0,-(sp)
   move.w #$4a,-(sp)
   trap #gemdos      ; SETBLOCK Gemdos
   add.l #12,sp      ; correct stack
   tst.l d0
   bne exit      ; error occured? -> go to error
   
; -------------------------
; main program entry point:
; -------------------------
main:

   pea my_palette
   move.w #$26,-(sp)
   trap #xbios
   addq.l #6,sp


; print banner...
   pea banner
   move.w #9,-(sp)
   trap #gemdos
   addq.l #6,sp

; wait for keypress 'w' or 'q'
press_w:
   move.w #8,-(sp)
   trap #gemdos
   addq.l #2,sp
   
   ; w pressed? - then write the bootblock...
   cmpi #'w',d0
   beq read_boot
   cmpi #'W',d0
   beq read_boot
   ; Q pressed? - then terminate program...
   cmpi #'q',d0
   beq exit
   cmpi #'Q',d0
   beq exit
   cmpi #'t',d0
   beq testboot
   cmpi #'T',d0
   beq testboot
   
   ; neither w nor q? - then get another keypress   
   bra press_w

; read old bootblock from disk including BPB
read_boot:
   moveq.w #8,d0
   bsr rw_boot


;  transfer bootcode to buffer...
transfer_boot:
off:   equ $1a
   move.l #bootcode,a0
   move.w #(bootcode_end-bootcode)/2,d0
   move.l #boots+off+2,a1
.loop   move.w (a0)+,(a1)+
   dbf d0,.loop
   move.w #$6000+off,boots
   
; calculate checksum to make bootcode executable on disk...   
make_exec:
   move.l #$00000001ffffffff,-(sp)
   move.l #-1,-(sp)
   move.l #boots,-(sp)
   move.w #18,-(sp)
   trap #14
   lea.l 14(sp),sp      
   move.w d0,checksum


; write bootcode to disk....
write_boot:
   moveq.w #9,d0
   bsr rw_boot
   
   
   ; and return to program start....
   jmp main
   
   ; test bootcode routine
testboot:
   ; run bootsector routine in supervisor
   pea bootcode
   move.w #$26,-(sp)
   trap #xbios
   addq.l #6,sp
   
   move.w #8,-(sp)
   trap #gemdos
   addq.l #2,sp
   jmp main
      
   
; terminate program properly and return to desktop or shell...   
exit:   clr.l -(sp)
   trap #gemdos   ; TERM PROCESS Gemdos

;------------------------
; SUBROUTINES/ FUNCTIONS
;------------------------

; subroutine reads and writes bootcode from disk
; to/from buffer
rw_boot:
   move.w #1,-(sp)
   move.l #0,-(sp)
   move.w #1,-(sp)
   move.w #0,-(sp)
   clr.l -(sp)
   move.l #boots,-(sp)
   move.w d0,-(sp)
   trap #14
   lea.l 20(sp),sp
   rts
   
   ; gets called in SUPER
my_palette:
   move.w #$777,$FFFF8240.w
   move.w #$000,$FFFF825E.w
   rts

;-----------------------------------
data
; initialisierte Daten hier...
banner: dc.b 27,"b",15,27,"E",27,"p"
   dc.b "------------------------------",13,10
   dc.b "The Atari Forum Demo Bootblock",13,10
   dc.b "------------------------------",13,10
   dc.b 27,"qby Simon Sunnyboy/Paradize",13,10,13,10,10
   dc.b "Please insert your disk in drive A and",13,10
   dc.b "press 'w' to write a new bootsector.",13,10,13,10
   dc.b "REMOVE WRITE PROTECTION TAB!",13,10,13,10,13,10
   dc.b "Press 'q' to return to the desktop.",13,10,0
   
   even

boots:   ds.b 510
checksum:   ds.b 2

   even

   ; a nice raster bootblock
   ; ripped from a Megatari disk
   ;
bootcode:

   pea       bootmsg(pc)
         move.w    #9,-(sp)       ; print text
         trap      #1
         lea       6(sp),a7
         move      sr,-(sp)      ; save irq status
         ori.w     #$700,sr      
         clr.l     $42a.w      ; reset vector
         clr.l     $426.w       ; resvalid
         move.w    #$ea60,d0       ; loop count
         move.w     #$474,$ffff825c.w   ; color 14 = white
         
   lea       $ffff825e.w,a0   ; indirect addressing of color 15
.loop:
   clr.w     (a0)
         clr.w     (a0)
         clr.w     (a0)
         clr.w     (a0)
         clr.w     (a0)
         clr.w     (a0)
         move.w    #$001,(a0)
         move.w    (a0),(a0)
         move.w    #$002,(a0)
         move.w    (a0),(a0)
         move.w    #$013,(a0)
         move.w    (a0),(a0)    
         move.w    #$024,(a0)
         move.w    (a0),(a0)
         move.w    #$035,(a0)
         move.w    (a0),(a0)
         move.w    #$046,(a0)
         move.w    (a0),(a0)
         move.w    #$057,(a0)
         move.w    (a0),(a0)
         move.w    (a0),(a0)
         move.w    (a0),(a0)
         move.w    #$046,(a0)
         move.w    (a0),(a0)
         move.w    #$035,(a0)
         move.w    (a0),(a0)
         move.w    #$024,(a0)
         move.w    (a0),(a0)
         move.w    #$013,(a0)
         move.w    (a0),(a0)
         move.w    #$002,(a0)
         move.w    (a0),(a0)
         move.w    #$001,(a0)
         move.w    (a0),(a0)
         clr.w     (a0)
         move.w    (a0),$ffff8240.w
         nop
         ; optional keypress exit
         cmpi.b    #$39,$fffffc02.w   ; SPACE pressed?
         beq.s     .exit       ; then exit
         dbra       d0,.loop
.exit:
   move      (sp)+,sr      ; restore IRQ status
   move.w    #$000,$ffff8240.w    ; restore background color
   rts
bootmsg:
   dc.b 27,'b',15,27,'E',27,'Y',11+32,10+32
   dc.b "THE ATARI FORUM DEMO"
   dc.b 27,'Y',13+32,3+32
   dc.b 189,"'2004 http://www.atari-forum.com/  "
   dc.b 27,"b",14,27,"Y",24+32,8+32
   dc.b "THIS DISK IS VIRUS FREE!",0

bootcode_end:   dc.b 0

; BOOTSECTOR CODE END
;
; stack
stkstart:    ds.l 256
stackend:   ds.l 1   


Put the bootcode for the final bootsector between bootcode and bootcode_end, assemble and run to write the new bootsector to a fresh floppy from TOS.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Mon Apr 11, 2011 8:25 pm

simonsunnyboy wrote:i used a little code snippet from Grazey/PHF in the past:

Put the bootcode for the final bootsector between bootcode and bootcode_end, assemble and run to write the new bootsector to a fresh floppy from TOS.

Thanks a lot Simon :cheers: I've assembled it with DEVPAC and I've seen the disk booting and showing the nice banner. Now I'll use it to start a newbie demo :mrgreen:
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby wongck » Tue Apr 12, 2011 12:31 am

AtariSince1989 wrote:Thanks a lot Simon I've assembled it with DEVPAC and I've seen the disk booting and showing the nice banner. Now I'll use it to start a newbie demo


So how does the code looks like?
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Booting a homebrew OS. Is it possible?

Postby Nyh » Tue Apr 12, 2011 7:00 am

AtariSince1989 wrote:On Linux you use dd to get the bootsector asm program onto a floppy. On Windows my friend is using John Fine's partcopy. What can you use on Atari?

FcopyPro: Inspect Disk -> Load, use sector 0 and point the file selector to your 512 byte sector image.

Hans Wessels

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Tue Apr 12, 2011 8:41 am

wongck wrote:
AtariSince1989 wrote:Thanks a lot Simon I've assembled it with DEVPAC and I've seen the disk booting and showing the nice banner. Now I'll use it to start a newbie demo


So how does the code looks like?

Not very good. It was late and I was tired (being working 12 hours a day), so I thought to Keep It Short and Simple. I replaced the code within bootcode-bootcode_end with this code:

Code: Select all

        text

        move.l  #string,-(sp)           ; put string address on stack.
        move.w  #9,-(sp)                ; function # to display string.
        trap    #1                      ; call the operating system.
        addq.l  #6,sp                   ; clean up the stack.

        move.w  #1,-(sp)                ; function # to wait for keypress.
        trap    #1                      ; call the operating system.

        move.w  #0,-(sp)                ; function # to exit program.
        trap    #1                      ; call the operating system.

        data

string:         dc.b    "Hello World!",13,10,0


But didn't work. It just hangs the Atari.

Nyh wrote:
AtariSince1989 wrote:On Linux you use dd to get the bootsector asm program onto a floppy. On Windows my friend is using John Fine's partcopy. What can you use on Atari?

FcopyPro: Inspect Disk -> Load, use sector 0 and point the file selector to your 512 byte sector image.

Thanks a lot Hans. I'll try it.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12669
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby wongck » Tue Apr 12, 2011 9:02 am

AtariSince1989 wrote:But didn't work. It just hangs the Atari.

Do you have to set the stack buffer for your program first ?
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Tue Apr 12, 2011 9:27 am

Nyh wrote:

Code: Select all

hang:
     bra.s   hang
REPT 254
     DC.W 0
ENDR
     DC.W $B136

Nyh, what is that REPT instruction? DEVPAC complains Error: instruction not recognised. Also, I cannot find it on the M68k Instruction set.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Tue Apr 12, 2011 9:35 am

wongck wrote:
AtariSince1989 wrote:But didn't work. It just hangs the Atari.

Do you have to set the stack buffer for your program first ?

Hmmm, just started my ASM coding life, I'll have to look some documentation to understand what you said.
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Booting a homebrew OS. Is it possible?

Postby Nyh » Tue Apr 12, 2011 10:01 am

AtariSince1989 wrote:Not very good. It was late and I was tired (being working 12 hours a day), so I thought to Keep It Short and Simple. I replaced the code within bootcode-bootcode_end with this code:

Code: Select all

        text

        move.l  #string,-(sp)           ; put string address on stack.

All code in a boot sector has to be PC relative. So use something like pea string(pc).

AtariSince1989 wrote:

Code: Select all

        move.w  #0,-(sp)                ; function # to exit program.
        trap    #1                      ; call the operating system.

You exit the boot sector code with RTS. Not with a Pterm0(). You don't compile it into a program but just some PC relative code.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Booting a homebrew OS. Is it possible?

Postby Nyh » Tue Apr 12, 2011 10:04 am

AtariSince1989 wrote:
Nyh wrote:

Code: Select all

hang:
     bra.s   hang
REPT 254
     DC.W 0
ENDR
     DC.W $B136

Nyh, what is that REPT instruction? DEVPAC complains Error: instruction not recognised. Also, I cannot find it on the M68k Instruction set.

REPT 254 repeats the code between REPT 254 and ENDR 254 times. Turboassemler understands this syntax. I don't know the syntax for DEVPAC but no doubt it has something equal.

Hans Wessels

User avatar
AtariSince1989
Atari Super Hero
Atari Super Hero
Posts: 778
Joined: Sun Jan 11, 2009 1:14 pm
Location: Edinburgh, Scotland
Contact:

Re: Booting a homebrew OS. Is it possible?

Postby AtariSince1989 » Tue Apr 12, 2011 11:03 am

Nyh wrote:
AtariSince1989 wrote:
Nyh wrote:

Code: Select all

hang:
     bra.s   hang
REPT 254
     DC.W 0
ENDR
     DC.W $B136

Nyh, what is that REPT instruction? DEVPAC complains Error: instruction not recognised. Also, I cannot find it on the M68k Instruction set.

REPT 254 repeats the code between REPT 254 and ENDR 254 times. Turboassemler understands this syntax. I don't know the syntax for DEVPAC but no doubt it has something equal.

Hans Wessels

Yes, thanks, a quick look onto DEVPAC's manual showed me that indeed REPT should be understood by DEVPAC, so the error must be somewhere else. I'll check.

EDITED: Stupid mistake from me. REPT and ENDR have to be indented :D

Code: Select all

hang:
     bra.s   hang
     REPT 254
     DC.W 0
     ENDR
     DC.W $B136
- Atari 520 STe 4MB RAM + TOS 2.06 + UltraSatan
- Atari Falcon030 14MB RAM + TOS 4.04 + IDE-SD card HDD + NVRAM mod + SCSI buffer clock mod + EtherNEC
- Amstrad CPC 6128 + HxC USB Floppy Emulator
- Acorn A3010 4MB RAM + 40MB IDE HDD

Atari ST Essential software (The List)
My FTP Server: http://www.datavase.info/FTPserver (only from Midnight to 8am UK Time)
My music at http://soundcloud.com/datavase/


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 4 guests