forked from keirf/amiga-stuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systest: Produce a WB/CLI executable as well as raw disk image.
- Loading branch information
Showing
11 changed files
with
261 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,7 @@ | |
*.hex | ||
*.orig | ||
*.rej | ||
*.exe | ||
*.zip | ||
degzip | ||
rom-swizzle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
include base/Rules.mk | ||
|
||
SUBDIRS := base overscan systest | ||
|
||
.PHONY: all | ||
all: | ||
|
||
clean:: $(addsuffix clean,$(SUBDIRS)) | ||
%clean: % | ||
$(MAKE) -C $< clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../base/Rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* dos_entry.S | ||
* | ||
* Entry code for startup from Amiga Workbench or CLI. | ||
* | ||
* Written & released by Keir Fraser <keir.xen@gmail.com> | ||
* | ||
* This is free and unencumbered software released into the public domain. | ||
* See the file COPYING for more details, or visit <http://unlicense.org>. | ||
*/ | ||
|
||
/* Exec Library Vector Offsets */ | ||
#define EXEC_Forbid -0x84 | ||
#define EXEC_FindTask -0x126 | ||
#define EXEC_GetMsg -0x174 | ||
#define EXEC_ReplyMsg -0x17a | ||
#define EXEC_WaitPort -0x180 | ||
#define EXEC_OpenLibrary -0x198 | ||
#define EXEC_CloseLibrary -0x19e | ||
|
||
/* Graphics Linrary Vector Offsets */ | ||
#define GFX_LoadView -0xde | ||
#define GFX_WaitTOF -0x10e | ||
|
||
/* Offsets into DOS Process structure (extends Exec Task) */ | ||
#define pr_MsgPort 0x5c | ||
#define pr_CLI 0xac | ||
|
||
/* Offsets into GfxBase */ | ||
#define gfx_ActiView 0x22 | ||
#define gfx_cop1 0x26 | ||
#define gfx_cop2 0x32 | ||
|
||
.section .text.init | ||
.global start | ||
start: | ||
move.l 4,a6 | ||
/* Find our Process structure and determine how we were started. */ | ||
sub.l a1,a1 | ||
move.l a1,-(sp) /* no wb startup msg yet */ | ||
jsr EXEC_FindTask(a6) /* FindTask(NULL) */ | ||
move.l d0,a4 | ||
tst.l pr_CLI(a4) /* Running from CLI? */ | ||
bne .nowb | ||
|
||
/* Started from Workbench: wait for start message */ | ||
lea pr_MsgPort(a4),a0 | ||
jsr EXEC_WaitPort(a6) | ||
lea pr_MsgPort(a4),a0 | ||
jsr EXEC_GetMsg(a6) | ||
move.l d0,(sp) /* Save the startup msg */ | ||
.nowb: | ||
/* graphics.library set up a compatible view */ | ||
lea .gfx(pc),a1 | ||
moveq #0,d0 | ||
jsr EXEC_OpenLibrary(a6) | ||
move.l d0,a6 | ||
move.l gfx_ActiView(a6),-(sp) | ||
sub.l a1,a1 | ||
jsr GFX_LoadView(a6) /* LoadView(NULL) */ | ||
jsr GFX_WaitTOF(a6) | ||
jsr GFX_WaitTOF(a6) | ||
move.l a6,-(sp) | ||
|
||
bsr .begin | ||
move.l d0,d7 | ||
|
||
/* d7 = return code */ | ||
/* 0(sp) = gfxbase */ | ||
/* 4(sp) = original view */ | ||
/* 8(sp) = wb msg (or null) */ | ||
|
||
/* Restore original view */ | ||
move.l (sp)+,a6 | ||
jsr GFX_WaitTOF(a6) | ||
jsr GFX_WaitTOF(a6) | ||
lea.l (0xdff000).l,a5 | ||
move.l gfx_cop1(a6),0x80(a5) /* cop1lc */ | ||
move.l gfx_cop2(a6),0x84(a5) /* cop2lc */ | ||
move.l (sp)+,a1 | ||
jsr GFX_LoadView(a6) /* original view */ | ||
|
||
/* Close graphics library */ | ||
movel a6,a1 | ||
move.l 4,a6 | ||
jsr EXEC_CloseLibrary(a6) | ||
|
||
move.l (sp)+,d3 /* d3 = workbench msg */ | ||
beq .quit | ||
/* Workbench: Return the startup message to our parent */ | ||
jsr EXEC_Forbid(a6) | ||
move.l d3,a1 | ||
jsr EXEC_ReplyMsg(a6) | ||
.quit: move.l d7,d0 | ||
rts | ||
|
||
.gfx: .asciz "graphics.library" | ||
.align 2 | ||
|
||
.begin: | ||
#include "init.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* entry.S | ||
* | ||
* Common startup/entry code | ||
* | ||
* Written & released by Keir Fraser <keir.xen@gmail.com> | ||
* | ||
* This is free and unencumbered software released into the public domain. | ||
* See the file COPYING for more details, or visit <http://unlicense.org>. | ||
*/ | ||
|
||
#define EXEC_Supervisor -0x1e | ||
|
||
/* a4 = current VBR */ | ||
move.l 4,a6 | ||
sub.l a4,a4 | ||
btst.b #0,297(a6) /* check for 68010+ in AttnFlags */ | ||
jeq .novbr /* If a mere 68000 then there is no VBR */ | ||
lea getvbr(pc),a5 | ||
jsr EXEC_Supervisor(a6) | ||
.novbr: | ||
|
||
/* Initialise custom chips */ | ||
lea.l (0xdff000).l,a6 | ||
move.w #0x7fff,d0 | ||
move.w d0,0x9a(a6) /* intena = 0 */ | ||
move.w d0,0x9c(a6) /* intreq = 0 */ | ||
move.w d0,0x96(a6) /* dmacon = 0 */ | ||
move.w d0,0x9e(a6) /* adkcon = 0 */ | ||
move.w #0x8200,0x96(a6) /* enable master DMA */ | ||
move.w #0xc000,0x9a(a6) /* enable master IRQ */ | ||
moveq #0,d0 | ||
move.w d0,0x180(a6) /* color0 = black */ | ||
|
||
/* Floppy motors off */ | ||
lea (0xbfd100).l,a5 | ||
ori.b #0xf8,(a5) | ||
andi.b #0x87,(a5) | ||
ori.b #0x78,(a5) | ||
|
||
/* Initialise CPU state */ | ||
lea.l .priv(pc),a0 | ||
move.l a0,0x20(a4) | ||
.priv: move.w #0x2700,sr /* SR = 0x2700 (supervisor mode, no irqs) */ | ||
lea.l .skip(pc),a0 | ||
move.l a0,(0x10).w | ||
dc.l 0x4e7b0801 /* movec.l d0,vbr (VBR = 0) */ | ||
dc.l 0x4e7b0002 /* movec.l d0,cacr (CACR = 0) */ | ||
.skip: lea.l (SUPER_SP).l,sp /* SSP */ | ||
lea.l (USER_SP).l,a0 | ||
move.l a0,usp /* USP */ | ||
|
||
lea.l start(pc),a0 | ||
move.l a0,d0 /* a0 = d0 = current location */ | ||
move.l #start,d1 /* d1 = destination */ | ||
moveq #4,d2 | ||
swap d2 /* d2 = 0x40000 (256kB) */ | ||
eor.l d1,d0 /* *Very* conservative test: could current */ | ||
and.l d2,d0 /* location and destination overlap? */ | ||
jne 1f | ||
/* Temp. copy to other half of bottom 512kB */ | ||
eor.l d2,d1 | ||
jsr copy | ||
eor.l d2,d1 | ||
move.l #1f,d0 | ||
eor.l d2,d0 | ||
move.l d0,a0 | ||
jmp (a0) | ||
1: /* Main copy to final relocation point */ | ||
move.l #main,-(sp) | ||
|
||
copy: lea.l start(pc),a0 /* a0 = current location */ | ||
move.l d1,a1 /* a1 = destination */ | ||
move.l #_end-start,d0 | ||
lsr.l #2,d0 | ||
1: move.l (a0)+,(a1)+ | ||
dbf d0,1b | ||
rts | ||
|
||
main: move.w #0x2000,sr /* allow CPU interrupts now that we are */ | ||
/* definitely executing clear of the stack */ | ||
|
||
jra cstart | ||
|
||
getvbr: dc.l 0x4e7ac801 /* movec.l vbr,a4 */ | ||
rte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# mk_amiga_exe.py | ||
# | ||
# Convert a raw binary into a simple AmigaDOS executable | ||
# file with one loadable hunk and no relocations | ||
# | ||
# Written & released by Keir Fraser <keir.xen@gmail.com> | ||
# | ||
# This is free and unencumbered software released into the public domain. | ||
# See the file COPYING for more details, or visit <http://unlicense.org>. | ||
|
||
import struct, sys | ||
|
||
HUNK_CODE = 0x3e9 | ||
HUNK_END = 0x3f2 | ||
HUNK_HEADER = 0x3f3 | ||
|
||
def main(argv): | ||
in_f = open(argv[1], "rb") | ||
out_f = open(argv[2], "wb") | ||
in_dat = in_f.read() | ||
in_len = len(in_dat) | ||
assert (in_len & 3) == 0, "input is not longword padded" | ||
out_f.write(struct.pack(">LLLLLL", HUNK_HEADER, 0, 1, 0, 0, in_len/4)) | ||
out_f.write(struct.pack(">LL", HUNK_CODE, in_len/4)) | ||
out_f.write(in_dat) | ||
out_f.write(struct.pack(">L", HUNK_END)) | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ overscan.adf: overscan.bin | |
adfwrite $@ $< 0 21 -r -c | ||
|
||
clean:: | ||
$(RM) *.adf | ||
$(RM) *.adf ../base/*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SysTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
OBJS += ../base/bootblock.o | ||
OBJS += ../base/util.o | ||
OBJS += disk.o | ||
OBJS += systest.o | ||
|
||
include ../base/Rules.mk | ||
|
||
.PHONY: all | ||
all: systest.adf | ||
all: systest.zip | ||
|
||
systest.adf: systest.bin | ||
dd if=/dev/zero of=$@ bs=512 count=1760 | ||
systest.zip: systest.adf systest.exe SysTest.info | ||
cp systest.exe SysTest | ||
chmod 0755 SysTest | ||
$(RM) $@ | ||
zip -q $@ $(subst systest.exe,SysTest,$^) | ||
$(RM) SysTest | ||
|
||
systest_exe.elf: OBJS := ../base/dos_entry.o $(OBJS) | ||
systest_exe.elf: ../base/dos_entry.o | ||
|
||
systest_adf.elf: OBJS := ../base/bootblock.o $(OBJS) | ||
systest_adf.elf: ../base/bootblock.o | ||
|
||
systest.exe: systest_exe.bin | ||
python ../base/mk_amiga_exe.py $< $@ | ||
|
||
systest.adf: systest_adf.bin | ||
dd if=/dev/zero of=$@ bs=512 count=1760 status=none | ||
adfwrite $@ $< 0 43 -r -c | ||
|
||
clean:: | ||
$(RM) *.adf | ||
$(RM) *.adf *.exe *.zip ../base/*.o SysTest |
Binary file not shown.