amiga_boottest
changeset 2:58ebd84822e7
it works
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 22 Feb 2018 12:44:20 +0200 |
parents | 48093e4bd99a |
children | 555b986cc420 |
files | Makefile amiga.ld src/boot/boot.s src/copper.c src/intr.s src/main.c src/startup.s |
diffstat | 7 files changed, 67 insertions(+), 54 deletions(-) [+] |
line diff
1.1 --- a/Makefile Wed Feb 21 18:00:45 2018 +0200 1.2 +++ b/Makefile Thu Feb 22 12:44:20 2018 +0200 1.3 @@ -16,7 +16,7 @@ 1.4 OBJCOPY = $(tool_prefix)objcopy 1.5 1.6 ASFLAGS = -m68000 1.7 -CFLAGS = -m68000 -pedantic -Wall 1.8 +CFLAGS = -m68000 -ffreestanding -pedantic -Wall -O3 1.9 LDFLAGS = -T amiga.ld -print-gc-sections \ 1.10 -L/usr/lib/gcc-cross/m68k-linux-gnu/6 -lgcc 1.11 1.12 @@ -34,4 +34,8 @@ 1.13 1.14 .PHONY: clean 1.15 clean: 1.16 - rm -f $(obj) $(bin) $(elf) 1.17 + rm -f $(obj) src/boot/boot.o $(bin) $(elf) 1.18 + 1.19 +.PHONY: run 1.20 +run: 1.21 + fs-uae
2.1 --- a/amiga.ld Wed Feb 21 18:00:45 2018 +0200 2.2 +++ b/amiga.ld Thu Feb 22 12:44:20 2018 +0200 2.3 @@ -3,13 +3,11 @@ 2.4 PROVIDE (_stacktop = 0x80000); 2.5 2.6 SECTIONS { 2.7 - /* bootblock will load us at 100h, after the interrupt vectors */ 2.8 - . = 0x100; 2.9 + /* bootblock will load us at 10000h */ 2.10 + . = 0x10000; 2.11 2.12 - .text : { 2.13 - * (.text.startup); 2.14 - * (.text); 2.15 - } 2.16 + .startup : { * (.startup); } 2.17 + .text : { * (.text); } 2.18 .rodata : { * (.rodata); } 2.19 .data : { * (.data); } 2.20
3.1 --- a/src/boot/boot.s Wed Feb 21 18:00:45 2018 +0200 3.2 +++ b/src/boot/boot.s Thu Feb 22 12:44:20 2018 +0200 3.3 @@ -1,20 +1,20 @@ 3.4 | vi:filetype=gas68k: 3.5 .equ CMD_READ, 2 3.6 + .equ EXEC_DO_IO, -0x1c8 3.7 + .equ LOADADDR, 0x10000 3.8 3.9 - .equ EXEC_DO_IO, -0x1c8 3.10 - 3.11 +start: 3.12 | starting with trackdisk device I/O request pointer in a1 3.13 | load the program at 0x100 and jump there 3.14 | program length is patched by mk_adf just before start 3.15 -start: 3.16 - move.l -6(%pc), %d0 | get binary size 3.17 + move.l -6(%pc), %d0 | get program size 3.18 + move.w #0x080, 0xdff180 3.19 move.l %d0, 0x24(%a1) | I/O length 3.20 - move.l #0x100, 0x28(%a1) | I/O data pointer 3.21 + move.l #LOADADDR, 0x28(%a1) | I/O data pointer 3.22 move.l #512, 0x2c(%a1) | I/O offset (skip first sector) 3.23 move.w #CMD_READ, 0x1c(%a1) | I/O command 3.24 - move.l %a1, -(%sp) 3.25 jsr EXEC_DO_IO(%a6) 3.26 - move.l (%sp)+, %a1 3.27 + move.w #0xf0f, 0xdff180 3.28 3.29 - bra 0x100 3.30 + jmp LOADADDR 3.31 .align 4
4.1 --- a/src/copper.c Wed Feb 21 18:00:45 2018 +0200 4.2 +++ b/src/copper.c Thu Feb 22 12:44:20 2018 +0200 4.3 @@ -5,7 +5,7 @@ 4.4 static uint32_t *copmem, *curlist; 4.5 static int mode, copmem_size; 4.6 4.7 -extern uint32_t _mem_start; 4.8 +extern uint32_t **_mem_start; 4.9 4.10 int init_copper(int maxlist, int nlists) 4.11 { 4.12 @@ -14,7 +14,7 @@ 4.13 mode = nlists >= COPPER_DOUBLE ? COPPER_DOUBLE : COPPER_SINGLE; 4.14 4.15 copmem_size = maxlist * 4 * mode; 4.16 - copmem = (uint32_t*)_mem_start; 4.17 + copmem = *_mem_start; 4.18 4.19 curlist = copperlist = copmem; 4.20 *curlist = COPPER_END;
5.1 --- a/src/intr.s Wed Feb 21 18:00:45 2018 +0200 5.2 +++ b/src/intr.s Thu Feb 22 12:44:20 2018 +0200 5.3 @@ -10,4 +10,5 @@ 5.4 movem.l (%sp)+, %d0-%a6 5.5 rte 5.6 5.7 + .global dbgval 5.8 dbgval: .word 0x00f
6.1 --- a/src/main.c Wed Feb 21 18:00:45 2018 +0200 6.2 +++ b/src/main.c Thu Feb 22 12:44:20 2018 +0200 6.3 @@ -2,58 +2,69 @@ 6.4 #include "intr.h" 6.5 #include "copper.h" 6.6 6.7 -void wait_vpos(int x); 6.8 -void wait_vblank(void); 6.9 - 6.10 #define BPLSZ (320 / 8 * 256) 6.11 static unsigned char fb0[BPLSZ]; 6.12 6.13 +extern uint16_t dbgval; 6.14 + 6.15 +#define wait_vpos(x) \ 6.16 + asm volatile ( \ 6.17 + "0: move.l 0xdff004, %%d0\n\t" \ 6.18 + "and.l #0x1ff00, %%d0\n\t" \ 6.19 + "cmp.l %0, %%d0\n\t" \ 6.20 + "bne 0b\n\t" \ 6.21 + :: "i"((x) << 8) : "%d0") 6.22 + 6.23 +#define wait_vblank() wait_vpos(300) 6.24 +#define wait_scanline(x) wait_vpos((x) + 0x2c) 6.25 + 6.26 +#define clear_bpl(p) \ 6.27 + asm volatile ( \ 6.28 + "move.l %0, %%a0\n\t" \ 6.29 + "move.l %1, %%d0\n\t" \ 6.30 + "0: clr.l (%%a0)+\n\t" \ 6.31 + "dbra %%d0, 0b\n\t" \ 6.32 + :: "a"(p), "i"(BPLSZ / 4 - 1) \ 6.33 + : "a0", "d0") 6.34 + 6.35 +static uint32_t coplist[] = { 6.36 + COPPER_MOVE(REGN_BPL1PTH, 0), 6.37 + COPPER_MOVE(REGN_BPL1PTL, 0), 6.38 + COPPER_VWAIT(50), 6.39 + COPPER_MOVE(REGN_COLOR0, 0x00a), 6.40 + COPPER_VWAIT(60), 6.41 + COPPER_MOVE(REGN_COLOR0, 0x008), 6.42 + COPPER_END 6.43 +}; 6.44 + 6.45 int main(void) 6.46 { 6.47 - uint32_t fb0_addr = (uint32_t)fb0; 6.48 - 6.49 REG_INTENA = SETBITS(INTEN_VERTB | INTEN_MASTER); 6.50 6.51 REG_DMACON = CLRBITS(DMA_ALL); 6.52 - REG_BPLCON0 = BPLCON0_COUNT(0) | BPLCON0_COLOR; 6.53 + REG_BPLCON0 = BPLCON0_COUNT(1) | BPLCON0_COLOR; 6.54 REG_BPLCON1 = 0; 6.55 REG_DIWSTART = 0x2981; 6.56 REG_DIWSTOP = 0x29c1; 6.57 REG_DDFSTART = 0x38; 6.58 REG_DDFSTOP = 0xd0; 6.59 6.60 - REG_COLOR0 = 0x00f; 6.61 - REG_COLOR1 = 0xff0; 6.62 - 6.63 - init_copper(0, 0); 6.64 + REG_COLOR0 = 0x008; 6.65 + REG_COLOR1 = 0xaaa; 6.66 6.67 wait_vblank(); 6.68 - add_copper(COPPER_MOVE(REGN_BPL1PTH, fb0_addr >> 16)); 6.69 - add_copper(COPPER_MOVE(REGN_BPL1PTL, fb0_addr)); 6.70 + coplist[0] = COPPER_MOVE(REGN_BPL1PTH, (uint32_t)fb0 >> 16); 6.71 + coplist[1] = COPPER_MOVE(REGN_BPL1PTL, (uint32_t)fb0); 6.72 + REG32_COP1LC = (uint32_t)coplist; 6.73 + REG_COPJMP1 = 0; 6.74 6.75 - add_copper(COPPER_VWAIT(64)); 6.76 - add_copper(COPPER_MOVE(REGN_COLOR0, 0xf00)); 6.77 - add_copper(COPPER_VWAIT(70)); 6.78 - add_copper(COPPER_MOVE(REGN_COLOR0, 0x00f)); 6.79 + fb0[128 * 320 / 8 + 160 / 8] = 8; 6.80 6.81 - add_copper(COPPER_END); 6.82 + REG_DMACON = SETBITS(DMA_BPL | DMA_COPPER | DMA_MASTER); 6.83 6.84 - fb0[128 * 320 / 8] = 8; 6.85 + for(;;) { 6.86 + wait_vblank(); 6.87 + } 6.88 6.89 - REG_DMACON = SETBITS(DMA_COPPER | DMA_MASTER); 6.90 - enable_intr(); 6.91 - 6.92 - for(;;); 6.93 return 0; 6.94 } 6.95 - 6.96 -void wait_vpos(int x) 6.97 -{ 6.98 - x <<= 8; 6.99 - while((REG32_VPOSR & 0x1ff00) < x); 6.100 -} 6.101 - 6.102 -void wait_vblank(void) 6.103 -{ 6.104 - wait_vpos(300); 6.105 -}
7.1 --- a/src/startup.s Wed Feb 21 18:00:45 2018 +0200 7.2 +++ b/src/startup.s Thu Feb 22 12:44:20 2018 +0200 7.3 @@ -1,9 +1,8 @@ 7.4 | vi:filetype=gas68k: 7.5 - .global start 7.6 .global halt_cpu 7.7 .extern main 7.8 7.9 - .section .text.startup 7.10 + .section .startup,"a" 7.11 7.12 | enter supervisor mode (assumes VBR=0) 7.13 move.l #super, 0x80 7.14 @@ -16,7 +15,7 @@ 7.15 move.l #_bss_end, %a1 7.16 cmp.l %a0, %a1 7.17 beq.s 1f | skip zeroing if the section is empty 7.18 -0: clr.l (%a0)+ 7.19 +0: clr.b (%a0)+ 7.20 cmp.l %a0, %a1 7.21 bne.s 0b 7.22 1: