../syscall_net.o net_native.o ../level2.o ../syscall_level2.o \
../select.o
dd if=../fuzix.bin of=fuzix.img bs=256 skip=255 count=1
- dd if=../fuzix.bin of=fuzix.img bs=256 seek=1 skip=1 conv=notrunc
\ No newline at end of file
+ dd if=/dev/zero of=fuzix.img bs=256 seek=1 count=2
+ dd if=fuzix.i of=fuzix.img bs=256 seek=3 count=239
+ dd if=fuzix.d of=fuzix.img bs=256 seek=242 count=10
;
; We are entered at $0102 just after the required magic number
;
-; We get run from bank 0, our I/O writes would otherwise need to be
-; 24bit
+; The big image load is much more complicated as we need to shuffle
+; chunks of it into banks, clear spaces and fire things up
+;
;
sep #$30 ; ensure we are in 8bit mode
lda #'F'
- sta $FE20 ; signal our arrival
+ sta f:$00FE20 ; signal our arrival
sei ; interrupts off
cld ; decimal off
-
- ; vectors is packed in DP, move it to FF00
rep #$30
.a16
.i16
- lda #255
- ldx #0
+
+;
+; Move the stubs into bank 1
+;
+ ldx #$0000
ldy #$FF00
- mvn KERNEL_BANK,KERNEL_BANK
+ lda #$00FF
+ mvn $1,$0
+;
+; Move the code into bank 1
+;
+ ldx #$0300
+ ldy #$0300
+ lda #$EEFF
+ mvn $1,$0
+;
+; Move the data into bank 2
+;
+ ldx #$F200
+ ldy #$0200
+ lda #$09FF
+ mvn $2,$0
+;
+; Wipe the rest (bank was left as 2 here)
+;
+ ldx #$0C00
+ ldy #$0C01
+ stz $0C00
+ lda #$EFFE ; Wipe 0C00-FBFF
+ mvn $2,$2
+
+;
+; Wipe the low spaces
+;
+ ldx #$0C00
+ ldy #$0000
+ lda #$1FF
+ mvn $2,$2 ; Wipe low memory using clear space in bank 2
+
+ ldx #$0C00
+ ldy #$0000
+ lda #$1FF
+ mvn $0,$2 ; Wipe low memory using clear space in bank 2
+
sep #$30
.a8
lda #'u'
- sta $FE20
+ sta f:$00FE20
+ ; jml 1:switch (the assembler is too smart for its own good so
+ ; do it by hand)
+ .byte $5C
+ .word switch
+ .byte $01
+
+;
+; We are now running in the right bank of code
+;
+
+switch:
+ lda #$02
+ pha
+ plb
+
+;
+; And the right bank of data
+;
rep #$10
.i16
txs ; Stack (6502 not C)
lda #'z'
- sta $FE20
+ sta f:$00FE20
ldx #kstackc_top-1 ; C stack
stx sp
ldx #__BSS_RUN__
lda #'i'
- sta $FE20
+ sta f:$00FE20
txy
iny
- ; Wipe the BSS
-
- rep #$20
- .a16
-
- lda #__BSS_SIZE__-2 ; must be >=2 bytes or else
- stz a:0,x
- mvn 0,0
-
sep #$30
.a8
.i8
lda #'x'
- sta $FE20
+ sta f:$00FE20
jsr init_early
lda #'.'
- sta $FE20
+ sta f:$00FE20
jsr init_hardware
+ lda #13
+ sta f:$00FE20
+ lda #10
+ sta f:$00FE20
+
jmp code
.code
.a8
.i8
code:
- lda #13
- sta $FE20
- lda #10
- sta $FE20
jsr _fuzix_main ; Should never return
sei ; Spin
stop: bra stop
;
-; Processor vector table (0xFFE0)
+; Processor vector table (0:0xFFE0)
;
.segment "VECTORS"
#include <device.h>
#include <vt.h>
#include <tty.h>
-
-static volatile uint8_t *uart = (volatile uint8_t *)0xFE20;
-static volatile uint8_t *timer = (volatile uint8_t *)0xFE10;
+#include <io.h>
static char tbuf1[TTYSIZ];
PTY_BUFFERS;
void tty_putc(uint8_t minor, unsigned char c)
{
minor;
- uart[0] = c;
+ poke(0x2000|c);
}
void tty_setup(uint8_t minor)
{
uint8_t x;
- x = uart[1] & 1;
+ x = peek(0x21);
if (x) {
- x = uart[0];
+ x = peek(0x20);
tty_inproc(1, x);
}
}
void platform_interrupt(void)
{
- uint8_t t = *timer;
+ uint8_t t = peek(0x10);
tty_poll();
while(t--) {
timer_interrupt();
--- /dev/null
+extern uint8_t peek(uint8_t);
+extern void poke(uint16_t);
STUB: start = $FF00, size = $00E0, type = rw, fill = yes;
VECTOR: start = $FFE0, size = $0020, type = rw, fill = yes;
#Bank1
- MAIN: file = "fuzix.i", start = $0200, size = $10000, type = rw, fill = yes;
+ MAIN: file = "fuzix.i", start = $0300, size = $EF00, type = rw, fill = yes;
#Bank2
UDATA: file = "fuzix.d", start = $0000, size = $0200, type = rw, fill = yes;
- BSEG: file = "fuzix.d", start = $0200, size = $FE000, type = rw, fill = yes;
+ BSEG: file = "fuzix.d", start = $0200, size = $FE00, type = rw, fill = yes;
}
SEGMENTS {
RODATA: load = BSEG, type = ro;
DATA: load = BSEG, type = rw, define = yes;
- BSS: load = BSEG, type = bss, define = yes;
DISCARD: load = MAIN, type = ro;
DISCARDDATA: load = BSEG, type = ro;
+ BSS: load = BSEG, type = bss, define = yes;
+
STUBS: load = STUB, type = ro;
VECTORS: load = VECTOR, type = ro;
}
.export _hd_kmap
.export _hd_read_data
.export _hd_write_data
+ .export _peek,_poke
;
; Disk copier
_hd_kmap:
.res 1
+
+;
+; For non bank 0 we can't just poke addresses from C but need helpers.
+; We pass a single argument of dataoffset,data so we get a single
+; value in XA for speed (X is offset A data)
+;
+_poke:
+ stx ptr1
+ ldx #$FE
+ stx ptr1+1
+ ldx #0
+ phb
+ phx
+ plb
+ sta (ptr1)
+ plb
+ rts
+_peek:
+ sta ptr1
+ lda #$FE
+ sta ptr1+1
+ phb
+ lda #0
+ pha
+ plb
+ lda (ptr1)
+ plb
+ ldx #0
+ rts
+
+
+
\ No newline at end of file