summaryrefslogtreecommitdiffstats
path: root/sw/z80
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-07-04 11:35:23 +0200
committerNao Pross <naopross@thearcway.org>2017-07-04 11:35:23 +0200
commitb14d0afe86966b91ad6a40816439cdc34602b49e (patch)
treef0d3bb06a9d41ad4dc5277251f9d82fe40e46595 /sw/z80
parentmerge branch 'atlas' into naopross (diff)
downloadz80uPC-b14d0afe86966b91ad6a40816439cdc34602b49e.tar.gz
z80uPC-b14d0afe86966b91ad6a40816439cdc34602b49e.zip
new structure for process management, structures to discuss
the idea behind kernel/include/progman.h was good but the implementation was very not unix-like, so I made a new file under kernel/include/process.h that will implement the same features other changes: - move usart register structs definitions outside of the device - remove old build files - delete boot.h and boot_loader.h (as they weren't used by anything) - change on makefile to build binary with `makebin` instead of `xxd` - new file memory.h to implement memory mapping and mmu control - new type `uint` in types.h
Diffstat (limited to 'sw/z80')
-rw-r--r--sw/z80/build/helvetiOS.lk11
-rw-r--r--sw/z80/build/helvetiOS.map182
-rw-r--r--sw/z80/build/helvetiOS.noi50
-rw-r--r--sw/z80/build/kernel/kernel.asm65
-rw-r--r--sw/z80/build/kernel/kernel.lst65
-rw-r--r--sw/z80/build/kernel/kernel.rel23
-rw-r--r--sw/z80/build/kernel/kernel.sym27
-rw-r--r--sw/z80/crt0.rel86
-rw-r--r--sw/z80/kernel/drivers/pio.c (renamed from sw/z80/kernel/pio.c)3
-rw-r--r--sw/z80/kernel/drivers/usart.c (renamed from sw/z80/kernel/usart.c)2
-rw-r--r--sw/z80/kernel/include/devices.h2
-rw-r--r--sw/z80/kernel/include/drivers/pio.h (renamed from sw/z80/kernel/include/pio.h)0
-rw-r--r--sw/z80/kernel/include/drivers/usart.h155
-rw-r--r--sw/z80/kernel/include/login.h23
-rw-r--r--sw/z80/kernel/include/memory.h48
-rw-r--r--sw/z80/kernel/include/process.h42
-rw-r--r--sw/z80/kernel/include/progman.h109
-rw-r--r--sw/z80/kernel/include/sysexe.h55
-rw-r--r--sw/z80/kernel/include/types.h5
-rw-r--r--sw/z80/kernel/include/usart.h149
-rw-r--r--sw/z80/kernel/login.c12
-rw-r--r--sw/z80/kernel/memory.c43
-rw-r--r--sw/z80/kernel/process.c18
-rw-r--r--sw/z80/kernel/progman.c90
-rw-r--r--sw/z80/kernel/sysexe.c14
-rw-r--r--sw/z80/makefile18
26 files changed, 328 insertions, 969 deletions
diff --git a/sw/z80/build/helvetiOS.lk b/sw/z80/build/helvetiOS.lk
deleted file mode 100644
index c16247f..0000000
--- a/sw/z80/build/helvetiOS.lk
+++ /dev/null
@@ -1,11 +0,0 @@
--mjwx
--i build/helvetiOS.hex
--b _CODE = 0x0800
--b _DATA = 0x8000
--k /usr/bin/../share/sdcc/lib/z80
--k /usr/share/sdcc/lib/z80
--l z80
-crt0.rel
-build/kernel/kernel.rel
-
--e
diff --git a/sw/z80/build/helvetiOS.map b/sw/z80/build/helvetiOS.map
deleted file mode 100644
index 98210c7..0000000
--- a/sw/z80/build/helvetiOS.map
+++ /dev/null
@@ -1,182 +0,0 @@
- ASxxxx Linker V03.00 + NoICE + sdld, page 1.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-. .ABS. 00000000 00000000 = 0. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- 00000000 .__.ABS. kernel
- 00000000 l__BSEG
- 00000000 l__BSS
- 00000000 l__CABS
- 00000000 l__DABS
- 00000000 l__DATA
- 00000000 l__HEADER
- 00000000 l__HEAP
- 00000000 l__HOME
- 00000000 l__INITIALIZED
- 00000000 l__INITIALIZER
- 00000000 s__CABS
- 00000000 s__DABS
- 00000000 s__HEADER
- 00000000 s__HEADER0
- 00000000 s__HEADER1
- 00000000 s__HEADER2
- 00000000 s__HEADER3
- 00000000 s__HEADER4
- 00000000 s__HEADER5
- 00000000 s__HEADER6
- 00000000 s__HEADER7
- 00000000 s__HEADER8
- 00000001 l__GSFINAL
- 00000002 l__HEADER1
- 00000002 l__HEADER2
- 00000002 l__HEADER3
- 00000002 l__HEADER4
- 00000002 l__HEADER5
- 00000002 l__HEADER6
- 00000002 l__HEADER7
- 00000003 l__HEADER0
- 00000006 l__GSINIT
- 0000000C l__HEADER8
- 00000017 l__CODE
- 00000800 s__CODE
- 00000817 s__GSINIT
- 00000817 s__HOME
- 00000817 s__INITIALIZER
- 0000081D s__GSFINAL
- 00008000 s__BSEG
- 00008000 s__BSS
- 00008000 s__DATA
- 00008000 s__HEAP
- 00008000 s__INITIALIZED
- ASxxxx Linker V03.00 + NoICE + sdld, page 2.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_CODE 00000800 00000017 = 23. bytes (REL,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- 00000800 __clock crt0
- 00000804 _exit crt0
- 0000080A _main kernel
- ASxxxx Linker V03.00 + NoICE + sdld, page 3.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER0 00000000 00000003 = 3. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 4.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER1 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 5.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER2 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 6.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER3 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 7.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER4 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 8.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER5 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 9.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER6 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 10.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER7 00000000 00000002 = 2. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 11.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_HEADER8 00000000 0000000C = 12. bytes (ABS,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 12.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_GSINIT 00000817 00000006 = 6. bytes (REL,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- 00000817 gsinit crt0
-
- ASxxxx Linker V03.00 + NoICE + sdld, page 13.
-Hexadecimal [32-Bits]
-
-Area Addr Size Decimal Bytes (Attributes)
--------------------------------- ---- ---- ------- ----- ------------
-_GSFINAL 0000081D 00000001 = 1. bytes (REL,CON)
-
- Value Global Global Defined In Module
- ----- -------------------------------- ------------------------
- ASxxxx Linker V03.00 + NoICE + sdld, page 14.
-
-Files Linked [ module(s) ]
-
-crt0.rel [ crt0 ]
-build/kernel/kernel.rel [ kernel ]
-
- ASxxxx Linker V03.00 + NoICE + sdld, page 15.
-
-User Base Address Definitions
-
-_CODE = 0x0800
-_DATA = 0x8000
-
- \ No newline at end of file
diff --git a/sw/z80/build/helvetiOS.noi b/sw/z80/build/helvetiOS.noi
deleted file mode 100644
index 1b9c284..0000000
--- a/sw/z80/build/helvetiOS.noi
+++ /dev/null
@@ -1,50 +0,0 @@
-DEF .__.ABS. 0x0
-DEF l__BSEG 0x0
-DEF l__BSS 0x0
-DEF l__CABS 0x0
-DEF l__DABS 0x0
-DEF l__DATA 0x0
-DEF l__HEADER 0x0
-DEF l__HEAP 0x0
-DEF l__HOME 0x0
-DEF l__INITIALIZED 0x0
-DEF l__INITIALIZER 0x0
-DEF s__CABS 0x0
-DEF s__DABS 0x0
-DEF s__HEADER 0x0
-DEF s__HEADER0 0x0
-DEF s__HEADER1 0x0
-DEF s__HEADER2 0x0
-DEF s__HEADER3 0x0
-DEF s__HEADER4 0x0
-DEF s__HEADER5 0x0
-DEF s__HEADER6 0x0
-DEF s__HEADER7 0x0
-DEF s__HEADER8 0x0
-DEF l__GSFINAL 0x1
-DEF l__HEADER1 0x2
-DEF l__HEADER2 0x2
-DEF l__HEADER3 0x2
-DEF l__HEADER4 0x2
-DEF l__HEADER5 0x2
-DEF l__HEADER6 0x2
-DEF l__HEADER7 0x2
-DEF l__HEADER0 0x3
-DEF l__GSINIT 0x6
-DEF l__HEADER8 0xC
-DEF l__CODE 0x17
-DEF s__CODE 0x800
-DEF s__GSINIT 0x817
-DEF s__HOME 0x817
-DEF s__INITIALIZER 0x817
-DEF s__GSFINAL 0x81D
-DEF s__BSEG 0x8000
-DEF s__BSS 0x8000
-DEF s__DATA 0x8000
-DEF s__HEAP 0x8000
-DEF s__INITIALIZED 0x8000
-DEF __clock 0x800
-DEF _exit 0x804
-DEF _main 0x80A
-DEF gsinit 0x817
-LOAD build/helvetiOS.ihx
diff --git a/sw/z80/build/kernel/kernel.asm b/sw/z80/build/kernel/kernel.asm
deleted file mode 100644
index a29db4d..0000000
--- a/sw/z80/build/kernel/kernel.asm
+++ /dev/null
@@ -1,65 +0,0 @@
-;--------------------------------------------------------
-; File Created by SDCC : free open source ANSI-C Compiler
-; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
-; This file was generated Tue May 2 18:13:35 2017
-;--------------------------------------------------------
- .module kernel
- .optsdcc -mz80
-
-;--------------------------------------------------------
-; Public variables in this module
-;--------------------------------------------------------
- .globl _main
-;--------------------------------------------------------
-; special function registers
-;--------------------------------------------------------
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _DATA
-;--------------------------------------------------------
-; ram data
-;--------------------------------------------------------
- .area _INITIALIZED
-;--------------------------------------------------------
-; absolute external ram data
-;--------------------------------------------------------
- .area _DABS (ABS)
-;--------------------------------------------------------
-; global & static initialisations
-;--------------------------------------------------------
- .area _HOME
- .area _GSINIT
- .area _GSFINAL
- .area _GSINIT
-;--------------------------------------------------------
-; Home
-;--------------------------------------------------------
- .area _HOME
- .area _HOME
-;--------------------------------------------------------
-; code
-;--------------------------------------------------------
- .area _CODE
-;kernel/kernel.c:4: void main(void)
-; ---------------------------------
-; Function main
-; ---------------------------------
-_main::
-;kernel/kernel.c:7: for (i = 0; i < 10; i++) {
- ld de,#0x000A
-00104$:
-;kernel/kernel.c:8: j--;
- ld c,e
- ld b,d
- dec bc
- ld e, c
-;kernel/kernel.c:7: for (i = 0; i < 10; i++) {
- ld a,b
- ld d,a
- or a,c
- jr NZ,00104$
- ret
- .area _CODE
- .area _INITIALIZER
- .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/kernel.lst b/sw/z80/build/kernel/kernel.lst
deleted file mode 100644
index 8ec7438..0000000
--- a/sw/z80/build/kernel/kernel.lst
+++ /dev/null
@@ -1,65 +0,0 @@
- 1 ;--------------------------------------------------------
- 2 ; File Created by SDCC : free open source ANSI-C Compiler
- 3 ; Version 3.5.0 #9253 (Mar 24 2016) (Linux)
- 4 ; This file was generated Tue May 2 18:13:35 2017
- 5 ;--------------------------------------------------------
- 6 .module kernel
- 7 .optsdcc -mz80
- 8
- 9 ;--------------------------------------------------------
- 10 ; Public variables in this module
- 11 ;--------------------------------------------------------
- 12 .globl _main
- 13 ;--------------------------------------------------------
- 14 ; special function registers
- 15 ;--------------------------------------------------------
- 16 ;--------------------------------------------------------
- 17 ; ram data
- 18 ;--------------------------------------------------------
- 19 .area _DATA
- 20 ;--------------------------------------------------------
- 21 ; ram data
- 22 ;--------------------------------------------------------
- 23 .area _INITIALIZED
- 24 ;--------------------------------------------------------
- 25 ; absolute external ram data
- 26 ;--------------------------------------------------------
- 27 .area _DABS (ABS)
- 28 ;--------------------------------------------------------
- 29 ; global & static initialisations
- 30 ;--------------------------------------------------------
- 31 .area _HOME
- 32 .area _GSINIT
- 33 .area _GSFINAL
- 34 .area _GSINIT
- 35 ;--------------------------------------------------------
- 36 ; Home
- 37 ;--------------------------------------------------------
- 38 .area _HOME
- 39 .area _HOME
- 40 ;--------------------------------------------------------
- 41 ; code
- 42 ;--------------------------------------------------------
- 43 .area _CODE
- 44 ;kernel/kernel.c:4: void main(void)
- 45 ; ---------------------------------
- 46 ; Function main
- 47 ; ---------------------------------
- 0000 48 _main::
- 49 ;kernel/kernel.c:7: for (i = 0; i < 10; i++) {
- 0000 11 0A 00 [10] 50 ld de,#0x000A
- 0003 51 00104$:
- 52 ;kernel/kernel.c:8: j--;
- 0003 4B [ 4] 53 ld c,e
- 0004 42 [ 4] 54 ld b,d
- 0005 0B [ 6] 55 dec bc
- 0006 59 [ 4] 56 ld e, c
- 57 ;kernel/kernel.c:7: for (i = 0; i < 10; i++) {
- 0007 78 [ 4] 58 ld a,b
- 0008 57 [ 4] 59 ld d,a
- 0009 B1 [ 4] 60 or a,c
- 000A 20 F7 [12] 61 jr NZ,00104$
- 000C C9 [10] 62 ret
- 63 .area _CODE
- 64 .area _INITIALIZER
- 65 .area _CABS (ABS)
diff --git a/sw/z80/build/kernel/kernel.rel b/sw/z80/build/kernel/kernel.rel
deleted file mode 100644
index 1079edc..0000000
--- a/sw/z80/build/kernel/kernel.rel
+++ /dev/null
@@ -1,23 +0,0 @@
-XL2
-H 9 areas 2 global symbols
-M kernel
-O -mz80
-S .__.ABS. Def0000
-A _CODE size D flags 0 addr 0
-S _main Def0000
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _DABS size 0 flags 8 addr 0
-A _HOME size 0 flags 0 addr 0
-A _GSINIT size 0 flags 0 addr 0
-A _GSFINAL size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _CABS size 0 flags 8 addr 0
-T 00 00
-R 00 00 00 00
-T 00 00 11 0A 00
-R 00 00 00 00
-T 03 00
-R 00 00 00 00
-T 03 00 4B 42 0B 59 78 57 B1 20 F7 C9
-R 00 00 00 00
diff --git a/sw/z80/build/kernel/kernel.sym b/sw/z80/build/kernel/kernel.sym
deleted file mode 100644
index d01735c..0000000
--- a/sw/z80/build/kernel/kernel.sym
+++ /dev/null
@@ -1,27 +0,0 @@
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 1.
-Hexadecimal [16-Bits]
-
-Symbol Table
-
- .__.$$$. = 2710 L
- .__.ABS. = 0000 G
- .__.CPU. = 0000 L
- .__.H$L. = 0000 L
- 0 _main 0000 GR
-
-
- ASxxxx Assembler V02.00 + NoICE + SDCC mods (Zilog Z80 / Hitachi HD64180), page 2.
-Hexadecimal [16-Bits]
-
-Area Table
-
- 0 _CODE size D flags 0
- 1 _DATA size 0 flags 0
- 2 _INITIALIZED size 0 flags 0
- 3 _DABS size 0 flags 8
- 4 _HOME size 0 flags 0
- 5 _GSINIT size 0 flags 0
- 6 _GSFINAL size 0 flags 0
- 7 _INITIALIZER size 0 flags 0
- 8 _CABS size 0 flags 8
-
diff --git a/sw/z80/crt0.rel b/sw/z80/crt0.rel
deleted file mode 100644
index 809c0e6..0000000
--- a/sw/z80/crt0.rel
+++ /dev/null
@@ -1,86 +0,0 @@
-XL2
-H 14 areas 5 global symbols
-M crt0
-S _main Ref0000
-S .__.ABS. Def0000
-A _CODE size A flags 0 addr 0
-S __clock Def0000
-S _exit Def0004
-A _HEADER size 0 flags 8 addr 0
-A _HEADER0 size 3 flags 8 addr 0
-A _HEADER1 size 2 flags 8 addr 8
-A _HEADER2 size 2 flags 8 addr 10
-A _HEADER3 size 2 flags 8 addr 18
-A _HEADER4 size 2 flags 8 addr 20
-A _HEADER5 size 2 flags 8 addr 28
-A _HEADER6 size 2 flags 8 addr 30
-A _HEADER7 size 2 flags 8 addr 38
-A _HEADER8 size C flags 8 addr 100
-A _HOME size 0 flags 0 addr 0
-A _INITIALIZER size 0 flags 0 addr 0
-A _GSINIT size 6 flags 0 addr 0
-S gsinit Def0000
-A _GSFINAL size 1 flags 0 addr 0
-A _DATA size 0 flags 0 addr 0
-A _INITIALIZED size 0 flags 0 addr 0
-A _BSEG size 0 flags 0 addr 0
-A _BSS size 0 flags 0 addr 0
-A _HEAP size 0 flags 0 addr 0
-T 00 00
-R 00 00 02 00
-T 00 00 C3 00 01
-R 00 00 02 00 00 03 0A 00
-T 08 00
-R 00 00 03 00
-T 08 00 ED 4D
-R 00 00 03 00
-T 10 00
-R 00 00 04 00
-T 10 00 ED 4D
-R 00 00 04 00
-T 18 00
-R 00 00 05 00
-T 18 00 ED 4D
-R 00 00 05 00
-T 20 00
-R 00 00 06 00
-T 20 00 ED 4D
-R 00 00 06 00
-T 28 00
-R 00 00 07 00
-T 28 00 ED 4D
-R 00 00 07 00
-T 30 00
-R 00 00 08 00
-T 30 00 ED 4D
-R 00 00 08 00
-T 38 00
-R 00 00 09 00
-T 38 00 ED 4D
-R 00 00 09 00
-T 00 01
-R 00 00 0A 00
-T 00 01
-R 00 00 0A 00
-T 00 01 31 FF FF CD 00 00 CD 00 00 C3 04 00
-R 00 00 0A 00 00 06 0D 00 02 09 00 00 00 0C 00 00
-T 00 00
-R 00 00 00 00
-T 00 00 3E 02 CF C9
-R 00 00 00 00
-T 04 00
-R 00 00 00 00
-T 04 00 3E 00 CF
-R 00 00 00 00
-T 07 00
-R 00 00 00 00
-T 07 00 76 18 FD
-R 00 00 00 00
-T 00 00
-R 00 00 0D 00
-T 00 00 78 B1 28 02 ED B0
-R 00 00 0D 00
-T 06 00
-R 00 00 0D 00
-T 00 00 C9
-R 00 00 0E 00
diff --git a/sw/z80/kernel/pio.c b/sw/z80/kernel/drivers/pio.c
index 4b9caee..e29383f 100644
--- a/sw/z80/kernel/pio.c
+++ b/sw/z80/kernel/drivers/pio.c
@@ -1,4 +1,4 @@
-#include "pio.h"
+#include "drivers/pio.h"
static uint8_t *pio_port = (uint8_t *) ADDR_DEV_PIO;
static uint8_t *pio_ctrl = (uint8_t *) (ADDR_DEV_PIO + 2);
@@ -15,4 +15,5 @@ void _pio_command(int port, uint8_t cmd)
void pio_set_mode(int port, int mode)
{
+
}
diff --git a/sw/z80/kernel/usart.c b/sw/z80/kernel/drivers/usart.c
index 9ec6dbd..c54fe37 100644
--- a/sw/z80/kernel/usart.c
+++ b/sw/z80/kernel/drivers/usart.c
@@ -1,4 +1,4 @@
-#include "usart.h"
+#include "drivers/usart.h"
static struct _usart_device *_usart = (struct _usart_device *) ADDR_DEV_USART;
diff --git a/sw/z80/kernel/include/devices.h b/sw/z80/kernel/include/devices.h
index e8c183f..a846f9b 100644
--- a/sw/z80/kernel/include/devices.h
+++ b/sw/z80/kernel/include/devices.h
@@ -8,6 +8,8 @@
#define ADDR_DEV_CTC 0x4100
#define ADDR_DEV_PIO 0x4200
+#define ADDR_DEV_MMU
+
#define ADDR_DEV_RAM 0x8000
#endif
diff --git a/sw/z80/kernel/include/pio.h b/sw/z80/kernel/include/drivers/pio.h
index 5d289ca..5d289ca 100644
--- a/sw/z80/kernel/include/pio.h
+++ b/sw/z80/kernel/include/drivers/pio.h
diff --git a/sw/z80/kernel/include/drivers/usart.h b/sw/z80/kernel/include/drivers/usart.h
new file mode 100644
index 0000000..b85ee3e
--- /dev/null
+++ b/sw/z80/kernel/include/drivers/usart.h
@@ -0,0 +1,155 @@
+#ifndef __USART_H__
+#define __USART_H__
+
+#include "types.h"
+#include "devices.h"
+
+#include "string.h"
+
+// baudrate clock divisors
+// values from TL16C550C datasheet (table 9 for 1.8432 MHz crystal)
+#define USART_BAUDRATE_50 2304
+#define USART_BAUDRATE_75 1536
+#define USART_BAUDRATE_110 1047
+#define USART_BAUDRATE_134_5 857
+#define USART_BAUDRATE_150 768
+#define USART_BAUDRATE_300 384
+#define USART_BAUDRATE_600 192
+#define USART_BAUDRATE_1200 96
+#define USART_BAUDRATE_1800 64
+#define USART_BAUDRATE_2000 58
+#define USART_BAUDRATE_2400 48
+#define USART_BAUDRATE_3600 32
+#define USART_BAUDRATE_4800 24
+#define USART_BAUDRATE_7200 16
+#define USART_BAUDRATE_9600 12
+#define USART_BAUDRATE_19200 6
+#define USART_BAUDRATE_38400 3
+#define USART_BAUDRATE_56000 3
+
+// parity
+#define USART_PARITY_NONE 0
+#define USART_PARITY_EVEN 1
+#define USART_PARITY_ODD 2
+
+// stop bits
+#define USART_STOP_BITS_1 10
+#define USART_STOP_BITS_15 15
+#define USART_STOP_BITS_2 20
+
+// word lenght
+#define USART_WORD_LENGTH_5 0
+#define USART_WORD_LENGTH_6 1
+#define USART_WORD_LENGTH_7 2
+#define USART_WORD_LENGTH_8 3
+
+// autoflow
+#define USART_AUTOFLOW_ALL 3
+#define USART_AUTOFLOW_CTS 2
+#define USART_AUTOFLOW_OFF 0
+
+/* stuctures for usart registers */
+struct IER
+{
+ volatile uint received_data_interrupt :1;
+ volatile uint transmitter_empty_interrupt :1;
+ volatile uint receiver_line_status_interrupt :1;
+ volatile uint modem_status_interrupt :1;
+ volatile uint reserved :4;
+};
+
+struct IIR
+{
+ volatile uint interrupt_pending :1;
+ volatile uint interrupt_id :3;
+ volatile uint reserved :2;
+ volatile uint fifos :2;
+};
+
+struct FCR
+{
+ volatile uint fifo_enable :1;
+ volatile uint receiver_fifo_rst :1;
+ volatile uint trasmitter_fifo_rst :1;
+ volatile uint dma_mode_select :1;
+ volatile uint reserved :1;
+ volatile uint receiver_trigger :2;
+};
+
+struct LCR
+{
+ volatile uint word_length :2;
+ volatile uint stop_bits :1;
+ volatile uint parity :1;
+ volatile uint even_parity :1;
+ volatile uint stick_parity :1;
+ volatile uint break_control :1;
+ volatile uint divisor_latch_access :1;
+};
+
+struct MCR
+{
+ volatile uint data_terminal_ready :1;
+ volatile uint request_to_send :1;
+ volatile uint out1;
+ volatile uint out2;
+ volatile uint loop;
+ volatile uint autoflow :1;
+ volatile uint reserved :2;
+};
+
+struct LSR
+{
+ volatile uint data_ready :1;
+ volatile uint overrun_error :1;
+ volatile uint parity_error :1;
+ volatile uint framing_error :1;
+ volatile uint break_interrupt :1;
+ volatile uint transmitter_holder_empty :1;
+ volatile uint transmitter_empty :1;
+ volatile uint fifo_recv_error :1;
+};
+
+struct MSR
+{
+ volatile uint delta_cts :1;
+ volatile uint delta_data_set_ready :1;
+ volatile uint trailing_edge_ring_indicator :1;
+ volatile uint delta_data_carrier_detect :1;
+ volatile uint clear_to_send :1;
+ volatile uint data_set_ready :1;
+ volatile uint ring_indicator :1;
+ volatile uint data_carrier_detect :1;
+};
+
+/* this structure is only for internal usage */
+struct _usart_device
+{
+ register_t buffer; // also used as LSB for divisor latch
+ struct IER IER;
+ struct IIR IIR;
+ struct FCR FCR;
+ struct LCR LCR;
+ struct MCR MCR;
+ struct LSR LSR;
+ struct MSR MSR;
+ register_t scratch;
+};
+
+
+// setup functions (wrappers)
+void usart_set_baudrate(uint16_t baudrate);
+void usart_set_parity(int mode);
+void usart_set_stop_bits(int count);
+void usart_set_word_length(int length);
+void usart_set_autoflow(int mode);
+
+inline void usart_init(uint16_t baudrate, int parity, int stop_bits);
+
+void usart_transmit(uint8_t data);
+uint8_t usart_receive();
+
+int usart_write(uint8_t *data, size_t size);
+int usart_read(uint8_t *buffer, size_t count);
+
+#endif // __USART__H__
diff --git a/sw/z80/kernel/include/login.h b/sw/z80/kernel/include/login.h
deleted file mode 100644
index 5fa4b5e..0000000
--- a/sw/z80/kernel/include/login.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef LOGIN_H
-#define LOGIN_H
-
-#include "types.h"
-
-#define LOGIN_PC // TODO find an address in ROM, to perform jumps
-
-#define PWD_ADDR // TODO find an address in ROM, password
-#define PWD_SIZE 8
-
-/*
-* It returns 1 if succeded, otherwise 0
-*/
-
-int8_t authenticate(const char *pwd);
-
-/*
-* It sets the password in the ROM space, maximum 8 characters
-*/
-
-void set_pwd(const char *pwd);
-
-#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/memory.h b/sw/z80/kernel/include/memory.h
new file mode 100644
index 0000000..5bca5a5
--- /dev/null
+++ b/sw/z80/kernel/include/memory.h
@@ -0,0 +1,48 @@
+#ifndef __MEMORY_H__
+#define __MEMORY_H__
+
+#include "types.h"
+#include "devices.h"
+
+/* maximum number of pages on the system */
+#define PAGES_MAX_COUNT 32
+
+/* in our system there are only 16 pages since only 64KB can be addressed
+ * to optimize the memory management in ROM and RAM only pages from this set
+ * shall be used
+ */
+// ROM
+#define ADDR_PAGE_0 0x0000
+#define ADDR_PAGE_1 0x1000
+#define ADDR_PAGE_2 0x2000
+#define ADDR_PAGE_3 0x3000
+// IOSPACE
+#define ADDR_PAGE_4 0x4000
+#define ADDR_PAGE_5 0x5000
+#define ADDR_PAGE_6 0x6000
+#define ADDR_PAGE_7 0x7000
+// RAM
+#define ADDR_PAGE_8 0x8000
+#define ADDR_PAGE_9 0x9000
+#define ADDR_PAGE_10 0xA000
+#define ADDR_PAGE_11 0xB000
+#define ADDR_PAGE_12 0xC000
+#define ADDR_PAGE_13 0xD000
+#define ADDR_PAGE_14 0xE000
+#define ADDR_PAGE_15 0xF000
+
+struct page
+{
+ uint used :1;
+ uint8_t pid; // process owner of the page
+ uint16_t addr; // physical address
+};
+
+extern struct page pages_table[PAGES_MAX_COUNT];
+
+int mmu_write_table(void);
+
+int page_map(int page, int pid, uint16_t addr);
+int page_unmap(int page);
+
+#endif // __MEMORY_H__ \ No newline at end of file
diff --git a/sw/z80/kernel/include/process.h b/sw/z80/kernel/include/process.h
new file mode 100644
index 0000000..ffd39e7
--- /dev/null
+++ b/sw/z80/kernel/include/process.h
@@ -0,0 +1,42 @@
+#ifndef __PROCESS_H__
+#define __PROCESS_H__
+
+#include "types.h"
+
+ /* maximum number of processes (i.e. pages in ram)
+ * since each program can use only one page in ram
+ */
+#define PROC_COUNT 2
+
+struct executable
+{
+ void *text;
+ size_t text_size;
+ void *bss;
+ size_t bss_size;
+}
+
+struct process
+{
+ uint blocked :1; // process is waiting for hardware or locked
+ uint running :1; // pid is used
+ uint pages[4]; // pages used by the process
+ // TODO: implement quick callback?
+};
+
+/* the pid is defined with a single byte (pid_t is uint8_t), because of that
+ * there cannot be more than 255 processes open at the same time. this is a
+ * limitation but for our purposes is more than enough
+ */
+extern struct process proc_table[255];
+
+static pid_t newpid(void);
+
+int fork(void);
+int exec(char *path, char *args);
+int spawn(char *path, char *args);
+
+pid_t getpid(void);
+int kill(pid_t pid);
+
+#endif // __PROCESS_H__
diff --git a/sw/z80/kernel/include/progman.h b/sw/z80/kernel/include/progman.h
deleted file mode 100644
index b59e14a..0000000
--- a/sw/z80/kernel/include/progman.h
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef PROGRAM_MAN
-#define PROGRAM_MAN
-
-#include "types.h"
-
-#define PROG_0 0x0
-#define PROG_1 0x1
-
-#define PROG_VSTART 0x1000
-#define PROG_0_PREFIX 0xA000
-#define PROG_1_PREFIX 0xC000
-
-#define PROG_0_INFO // TODO
-#define PROG_1_INFO // TODO find a space in the ram
-
-struct prog_status {
-
- // The program is in execution
-
- uint8_t running:1;
-
- // The program is executing its quit callback
-
- uint8_t exiting:1;
-
- uint8_t unused:6; // TODO, find a usage for these bits
-}:
-
-struct prog_data {
-
- struct prog_status status;
-
- /*
- * The following addresses are needed to map
- * map the usable memory for dynamic allocations
- */
-
- // Virtual address of the heap
-
- uint8_t heap_addr:12;
-
- // Virtual address of the stack limit
-
- uint8_t stack_limit:12;
-
- /*
- * Function called when the program exits normally
- */
-
- void (*quit_cb)(void); // 16
-};
-
-/*
-* Initialize the program manager system
-*/
-
-void progman_init();
-
-/*
-* Check if it can start a new program
-* If it succedes, the program id is returned,
-* otherwise it is returned an error number
-*
-* ! Disable virtual addresses when this function is called
-*/
-
-#define PROG_REQ_FULL -1
-
-int8_t prog_req();
-
-/*
-* It allocates a program in the RAM
-* To obtain the right id call prog_req() first
-* Basic informations must be allocated and referenced by a program_base struct
-*
-* ! Disable virtual addresses when this function is called
-*/
-
-struct prog_space {
-
- void * inst_set; // pointer to the instructions set
- size_t inst_size; // size of the instructions set
- void * bss_data; // pointer to the bss/data space
- size_t data_size; // size of the bss/data space
-};
-
-void prog_alloc(int8_t id, struct prog_data *data, const struct prog_space *space);
-
-/*
-* It jumps the program counter to the given one
-*/
-
-void prog_exec(int8_t id, struct prog_data *data);
-
-/*
-* It sets a quit callback
-*/
-
-void prog_0_set_qcb(void (*callback)(void));
-void prog_1_set_qcb(void (*callback)(void));
-
-/*
-* It quits a program, if a callback is set, it will be called
-*/
-
-void prog_0_quit(uint8_t force);
-void prog_1_quit(uint8_t force);
-
-#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/sysexe.h b/sw/z80/kernel/include/sysexe.h
deleted file mode 100644
index 9c13c09..0000000
--- a/sw/z80/kernel/include/sysexe.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef SYS_EXE
-#define SYS_EXE
-
-#define SYS_EXEC_ADDR // TODO find an address in Kernel space
-
-struct sys_progman {
-
- // program 0 enabled
-
- uint8_t prog_0_enabled:1;
-
- // program 1 enabled
-
- /*
- * Obs: A program is enabled when its space is allocated
- * and its virtual program counter is stored in
- * the hardware or in the silent_pc.
- * An enabled program is not necessarly running, it
- * could be paused too.
- */
-
- uint8_t prog_1_enabled:1;
-
- // running's program id
-
- uint8_t prog_running:1;
-};
-
-struct sys_exec {
-
- /*
- * Virtual addresses are activated
- */
-
- uint8_t virtual_addr:1;
-
- struct sys_progman progman;
-
- /*
- * The silent_pc is the place designed to store the
- * program counter of the program that's not running
- */
-
- uint8_t silent_pc:12;
-};
-
-/*
-* Function to access informations
-*/
-
-uint8_t vaddr_enabled();
-
-struct sys_progman * sys_prog_data(struct sys_progman *data);
-
-#endif \ No newline at end of file
diff --git a/sw/z80/kernel/include/types.h b/sw/z80/kernel/include/types.h
index 552b7e9..44df3eb 100644
--- a/sw/z80/kernel/include/types.h
+++ b/sw/z80/kernel/include/types.h
@@ -3,11 +3,14 @@
#define register_t volatile unsigned char
+#define uint unsigned int
+
#define int8_t char
#define uint8_t unsigned char
#define int16_t int
-#define uint16_t unsigned int
+#define uint16_t unsigned long int
#define size_t uint16_t
+#define pid_t uint8_t
#endif
diff --git a/sw/z80/kernel/include/usart.h b/sw/z80/kernel/include/usart.h
deleted file mode 100644
index 3e5c070..0000000
--- a/sw/z80/kernel/include/usart.h
+++ /dev/null
@@ -1,149 +0,0 @@
-#ifndef __USART_H__
-#define __USART_H__
-
-#include "types.h"
-#include "devices.h"
-
-#include "string.h"
-
-// baudrate clock divisors
-// values from TL16C550C datasheet (table 9 for 1.8432 MHz crystal)
-#define USART_BAUDRATE_50 2304
-#define USART_BAUDRATE_75 1536
-#define USART_BAUDRATE_110 1047
-#define USART_BAUDRATE_134_5 857
-#define USART_BAUDRATE_150 768
-#define USART_BAUDRATE_300 384
-#define USART_BAUDRATE_600 192
-#define USART_BAUDRATE_1200 96
-#define USART_BAUDRATE_1800 64
-#define USART_BAUDRATE_2000 58
-#define USART_BAUDRATE_2400 48
-#define USART_BAUDRATE_3600 32
-#define USART_BAUDRATE_4800 24
-#define USART_BAUDRATE_7200 16
-#define USART_BAUDRATE_9600 12
-#define USART_BAUDRATE_19200 6
-#define USART_BAUDRATE_38400 3
-#define USART_BAUDRATE_56000 3
-
-// parity
-#define USART_PARITY_NONE 0
-#define USART_PARITY_EVEN 1
-#define USART_PARITY_ODD 2
-
-// stop bits
-#define USART_STOP_BITS_1 10
-#define USART_STOP_BITS_15 15
-#define USART_STOP_BITS_2 20
-
-// word lenght
-#define USART_WORD_LENGTH_5 0
-#define USART_WORD_LENGTH_6 1
-#define USART_WORD_LENGTH_7 2
-#define USART_WORD_LENGTH_8 3
-
-// autoflow
-#define USART_AUTOFLOW_ALL 3
-#define USART_AUTOFLOW_CTS 2
-#define USART_AUTOFLOW_OFF 0
-
-
-/* this structure is only for internal usage */
-struct _usart_device
-{
- register_t buffer; // also used as LSB for divisor latch
-
- struct IER
- {
- volatile int received_data_interrupt :1;
- volatile int transmitter_empty_interrupt :1;
- volatile int receiver_line_status_interrupt :1;
- volatile int modem_status_interrupt :1;
- volatile int reserved :4;
- } IER;
-
- struct IIR
- {
- volatile int interrupt_pending :1;
- volatile int interrupt_id :3;
- volatile int reserved :2;
- volatile int fifos :2;
- } IIR;
-
- struct FCR
- {
- volatile int fifo_enable :1;
- volatile int receiver_fifo_rst :1;
- volatile int trasmitter_fifo_rst :1;
- volatile int dma_mode_select :1;
- volatile int reserved :1;
- volatile int receiver_trigger :2;
- } FCR;
-
- struct LCR
- {
- volatile int word_length :2;
- volatile int stop_bits :1;
- volatile int parity :1;
- volatile int even_parity :1;
- volatile int stick_parity :1;
- volatile int break_control :1;
- volatile int divisor_latch_access :1;
- } LCR;
-
- struct MCR
- {
- volatile int data_terminal_ready :1;
- volatile int request_to_send :1;
- volatile int out1;
- volatile int out2;
- volatile int loop;
- volatile int autoflow :1;
- volatile int reserved :2;
- } MCR;
-
- struct LSR
- {
- volatile int data_ready :1;
- volatile int overrun_error :1;
- volatile int parity_error :1;
- volatile int framing_error :1;
- volatile int break_interrupt :1;
- volatile int transmitter_holder_empty :1;
- volatile int transmitter_empty :1;
- volatile int fifo_recv_error :1;
- } LSR;
-
- struct MSR
- {
- volatile int delta_cts :1;
- volatile int delta_data_set_ready :1;
- volatile int trailing_edge_ring_indicator :1;
- volatile int delta_data_carrier_detect :1;
- volatile int clear_to_send :1;
- volatile int data_set_ready :1;
- volatile int ring_indicator :1;
- volatile int data_carrier_detect :1;
- } MSR;
-
- register_t scratch;
-};
-
-
-// setup functions (wrappers)
-void usart_set_baudrate(uint16_t baudrate);
-void usart_set_parity(int mode);
-void usart_set_stop_bits(int count);
-void usart_set_word_length(int length);
-void usart_set_autoflow(int mode);
-
-inline void usart_init(uint16_t baudrate, int parity, int stop_bits);
-
-void usart_transmit(uint8_t data);
-uint8_t usart_receive();
-
-int usart_write(uint8_t *data, size_t size);
-int usart_read(uint8_t *buffer, size_t count);
-
-#endif // __USART__H__
diff --git a/sw/z80/kernel/login.c b/sw/z80/kernel/login.c
deleted file mode 100644
index 5e100bf..0000000
--- a/sw/z80/kernel/login.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "login.h"
-#include "string.h"
-
-int8_t authenticate(const char *pwd) {
-
- return !memcmp(PWD_ADDR, pwd, PWD_SIZE);
-}
-
-void set_pwd(const char *pwd) {
-
- memcpy(PWD_ADDR, pwd, PWD_SIZE);
-} \ No newline at end of file
diff --git a/sw/z80/kernel/memory.c b/sw/z80/kernel/memory.c
new file mode 100644
index 0000000..f174906
--- /dev/null
+++ b/sw/z80/kernel/memory.c
@@ -0,0 +1,43 @@
+#include "memory.h"
+
+struct page pages_table[PAGES_MAX_COUNT];
+
+int mmu_write_table(void)
+{
+ int i;
+
+ for (i = 0; i < PAGES_MAX_COUNT; i++) {
+ if (pages_table[i].used) {
+ // write to mmu table
+ }
+ }
+
+ return 0;
+}
+
+int page_map(int page, int pid, uint16_t addr)
+{
+ if (page >= PAGES_MAX_COUNT)
+ return -1;
+
+ if (pages_table[page].used)
+ return -2;
+
+ pages_table[page].addr = addr;
+ pages_table[page].pid = pid;
+
+ pages_table[page].used = 1;
+ return 0;
+}
+
+int page_unmap(int page)
+{
+ if (page >= PAGES_MAX_COUNT)
+ return -1;
+
+ if (pages_table[page].used == 0)
+ return -2;
+
+ pages_table[page].used = 0;
+ return 0;
+}
diff --git a/sw/z80/kernel/process.c b/sw/z80/kernel/process.c
new file mode 100644
index 0000000..f33ead6
--- /dev/null
+++ b/sw/z80/kernel/process.c
@@ -0,0 +1,18 @@
+#include "process.h"
+
+struct process proc_table[255];
+
+int fork(void)
+{
+
+}
+
+int exec(char *path, char *args)
+{
+
+}
+
+int spawn(char *path, char *args)
+{
+
+} \ No newline at end of file
diff --git a/sw/z80/kernel/progman.c b/sw/z80/kernel/progman.c
deleted file mode 100644
index 44888f8..0000000
--- a/sw/z80/kernel/progman.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "progman.h"
-#include "string.h"
-#include "syscall.h"
-#include "sysexe.h"
-
-#define EMPTY_PROG_INFO 0x0
-
-volatile struct prog_data *prog_0 = PROG_0_INFO,
- *prog_1 = PROG_1_INFO;
-
-void progman_init() {
-
- *prog_0 = EMPTY_PROG_INFO;
- *prog_1 = EMPTY_PROG_INFO;
-
- // TODO other stuff
-}
-
-int8_t prog_req() {
-
- struct sys_progman data;
-
- sys_prog_data(&data);
-
- if (data.prog_0_enabled)
- return PROG_0;
- else if (data.prog_1_enabled)
- return PROG_1;
-
- return PROG_REQ_FULL;
-}
-
-void prog_alloc(int8_t id, struct prog_data *data, const struct prog_space *space) {
-
- void *addr = (id ? PROG_1_PREFIX : PROG_0_PREFIX) + PROG_VSTART;
-
- memcpy(addr, base->inst_set, base->inst_size);
-
- addr += base->inst_size;
-
- memcpy(addr, base->bss_data, base->data_size);
-
- addr += base->data_size;
-
- // TODO, empty heap and stack
-}
-
-void prog_exec(int8_t id, struct prog_data *data) {
-
- if (id)
- prog_exec_1(); // system call
- else
- prog_exec_0(); // system call
-}
-
-void prog_0_set_qcb(void (*callback)(void)) {
-
- prog_0->quit_cb = callback;
-}
-
-void prog_1_set_qcb(void (*callback)(void)) {
-
- prog_1->quit_cb = callback;
-}
-
-void prog_0_quit(uint8_t force) {
-
- if (!prog_0->enabled || prog_0->exiting)
- return;
-
- if (!force && prog_0->quit_cb)
- prog_0->quit_cb();
-
- *prog_0 = EMPTY_PROG_INFO;
-
- prog_stop_0(); // system call
-}
-
-void prog_1_quit(uint8_t force) {
-
- if (!prog_1->enabled || prog_1->exiting)
- return;
-
- if (!force && prog_1->quit_cb)
- prog_1->quit_cb();
-
- *prog_1 = EMPTY_PROG_INFO;
-
- prog_stop_1(); // system call
-} \ No newline at end of file
diff --git a/sw/z80/kernel/sysexe.c b/sw/z80/kernel/sysexe.c
deleted file mode 100644
index f020b88..0000000
--- a/sw/z80/kernel/sysexe.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "sysexe.h"
-
-volatile struct sys_exec *exec_data = SYS_EXEC_ADDR;
-
-uint8_t vaddr_enabled() {
-
- return exec_data->virtual_addr;
-}
-
-struct sys_progman * sys_prog_data(struct sys_progman *data) {
-
- *data = exec_data->sys_progman;
- return data;
-} \ No newline at end of file
diff --git a/sw/z80/makefile b/sw/z80/makefile
index 3d682ca..2eb4713 100644
--- a/sw/z80/makefile
+++ b/sw/z80/makefile
@@ -3,7 +3,10 @@
#
OSNAME := helvetiOS
-CSOURCES := $(wildcard kernel/*.c) $(wildcard libc/*.c)
+CSOURCES := $(wildcard kernel/*.c) \
+ $(wildcard kernel/drivers/*.c) \
+ $(wildcard libc/*.c)
+
OBJECTS := $(patsubst %.c,build/%.rel,$(CSOURCES))
HEXFILE := build/$(OSNAME).hex
BINARY := build/$(OSNAME).bin
@@ -14,7 +17,10 @@ BINARY := build/$(OSNAME).bin
CC := sdcc
CFLAGS := -mz80 \
- -I kernel/include -I libc/include -DDEBUG
+ -I kernel/include \
+ -I kernel/include/drivers \
+ -I libc/include \
+ -DDEBUG
LDFLAGS := -mz80 --no-std-crt0 crt0.rel \
--code-loc 0x0800 --data-loc 0x8000
@@ -25,9 +31,11 @@ all: $(BINARY)
# build binary
$(BINARY): $(OBJECTS) dirs
$(CC) $(LDFLAGS) $(OBJECTS) -o $(HEXFILE)
- xxd -r -p $(HEXFILE) $(BINARY)
+ @# xxd -r -p $(HEXFILE) $(BINARY)
+ makebin -s 16384 $(HEXFILE) $(BINARY)
$(OBJECTS): build/%.rel : %.c $(CSOURCES) dirs crt0.rel
+ @printf "\n"
$(CC) $(CFLAGS) -c $< -o $@
crt0.rel: crt0.s
@@ -37,9 +45,9 @@ dirs:
mkdir -p build build/kernel build/libc
dis: $(BINARY)
- z80dasm -a -g 0h $< -o $(OSNAME).s
+ @# z80dasm -a -l -g 0h $< -o build/$(OSNAME).s
+ dz80 -b -n $<
clean:
- rm -rd build/*
- - rm $(OSNAME).s
- rm crt0.rel