From: Alan Cox Date: Wed, 6 Feb 2019 14:00:53 +0000 (+0000) Subject: 8080: initial cpu bits for 8080 support X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f7709e75f73c86f13e3c766677a0811efc26d035;p=FUZIX.git 8080: initial cpu bits for 8080 support --- diff --git a/Kernel/cpu-8080/cpu.h b/Kernel/cpu-8080/cpu.h new file mode 100644 index 00000000..a0e5c48a --- /dev/null +++ b/Kernel/cpu-8080/cpu.h @@ -0,0 +1,81 @@ +typedef unsigned long uint32_t; +typedef signed long int32_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned char uint8_t; +typedef signed char int8_t; + +typedef int16_t arg_t; /* Holds arguments */ +typedef uint16_t uarg_t; /* Holds arguments */ +typedef uint16_t usize_t; /* Largest value passed by userspace */ +typedef int16_t susize_t; +typedef uint16_t uaddr_t; /* User address */ +typedef uint16_t uptr_t; /* Userspace pointer equivalent */ + +#define uputp uputw /* Copy user pointer type */ +#define ugetp ugetw /* between user and kernel */ +#define uputi uputw /* Copy user int type */ +#define ugeti ugetw /* between user and kernel */ + +typedef uint16_t irqflags_t; + +/* 8080 binaries start with a JP */ +#define EMAGIC 0xc3 /* Header of executable */ +#define EMAGIC_2 0xc3 /* JR */ +/* Allow a minimum of 512 bytes gap between stack and top of allocations */ +#define brk_limit() (udata.u_syscall_sp - 512) + +typedef uint16_t size_t; +typedef uint16_t ssize_t; +extern void *memcpy(void *dest, const void *src, size_t n); +extern char *strcpy(char *dest, const char *src); +extern char *strncpy(char *dest, const char *src, size_t n); +extern char *strchr(const char *s, int c); +extern void *memset(void *dest, int c, size_t n); + +/* There is no compiler optimized inline memmove */ +extern void *memmove(void *dest, const void *src, size_t n); + +extern int16_t strlen(const char *p); + +#define staticfast static/* User's structure for times() system call */ +typedef unsigned long clock_t; + +/* Must match native ordering of long long */ +typedef struct { + uint32_t low; + uint32_t high; +} time_t; + +typedef union { /* this structure is endian dependent */ + clock_t full; /* 32-bit count of ticks since boot */ + struct { + uint16_t low; /* 16-bit count of ticks since boot */ + uint16_t high; + } h; +} ticks_t; + +/* SDCC is arsy about unused parameters */ +#define used(x) x + +#define cpu_to_le16(x) (x) +#define le16_to_cpu(x) (x) +#define cpu_to_le32(x) (x) +#define le32_to_cpu(x) (x) + +#define ntohs(x) ((((x) & 0xFF) << 8) | (((x) & 0xFF00) >> 8)) +#define ntohl(x) ((((x) & 0xFF) << 24) | (((x) & 0xFF00) << 8) | \ + (((x) & 0xFF0000) >> 8) | (((x >> 24) & 0xFF))) + +#define CPUTYPE CPUTYPE_8080 + +/* Deal with SDCC code gen issue */ +#define HIBYTE32(x) (((uint8_t *)&(x))[3]) + +/* FIXME: check this */ +/* ack8080 does not support attribute(packed) but then it also doesn't insert + padding either */ + +#define __packed +#define barrier() +#define inline diff --git a/Kernel/cpu-8080/image.mk b/Kernel/cpu-8080/image.mk new file mode 100644 index 00000000..3d4d381b --- /dev/null +++ b/Kernel/cpu-8080/image.mk @@ -0,0 +1,2 @@ +fuzix.bin: target $(OBJS) + +$(MAKE) -C platform-$(TARGET) image diff --git a/Kernel/cpu-8080/rules.mk b/Kernel/cpu-8080/rules.mk new file mode 100644 index 00000000..019ec2c7 --- /dev/null +++ b/Kernel/cpu-8080/rules.mk @@ -0,0 +1,19 @@ +export CROSS_AS=ack +export CROSS_LD=$(ACK_ROOT)/lib/ack/em_led +export CROSS_CC=ack +export CROSS_CCOPTS= -c -O2 -I$(ROOT_DIR)/cpu-$(CPU) -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include +export CROSS_CC_SEG2= +export CROSS_CC_SEG3= +export CROSS_CC_SEG4= +export CROSS_CC_SEGDISC= +export CROSS_CC_FONT= +export CROSS_CC_VIDEO= +export CROSS_CC_SYS1= +export CROSS_CC_SYS2= +export CROSS_CC_SYS3= +export CROSS_CC_SYS4= +export CROSS_CC_SYS5= +export ASOPTS=-c +export ASMEXT = .s +export BINEXT = .o +export BITS=16 diff --git a/Kernel/cpu-8080/std-commonmem.s b/Kernel/cpu-8080/std-commonmem.s new file mode 100644 index 00000000..0ec44574 --- /dev/null +++ b/Kernel/cpu-8080/std-commonmem.s @@ -0,0 +1,45 @@ +! +! +! Standard 8080 common memory area blocks. +! +! Must remain a multiple of 256 bytes +! +.define _ub +.define _udata +.define kstack_top +.define istack_top +.define istack_switched_sp + +_ub: ! first 512 bytes: starts with struct u_block, with the kernel stack working down from above +_udata: +kstack_base: + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + .data1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +istack_top: +istack_switched_sp: .data2 0