From: Alan Cox Date: Tue, 13 Jan 2015 22:01:23 +0000 (+0000) Subject: cpu: make brk address rules CPU specific X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cc68be0696b1b46219bc70e277d709949c859915;p=FUZIX.git cpu: make brk address rules CPU specific The 6502 port has different stack policies to other processors. Also while we are at it add uaddr_t so we can support different address space sizes, ready for a future target or two. --- diff --git a/Kernel/cpu-6502/cpu.h b/Kernel/cpu-6502/cpu.h index 79f1ce57..a8aece37 100644 --- a/Kernel/cpu-6502/cpu.h +++ b/Kernel/cpu-6502/cpu.h @@ -11,6 +11,7 @@ typedef uint8_t irqflags_t; typedef int16_t arg_t; typedef uint16_t usize_t; /* Largest value passed by userspace */ typedef int16_t susize_t; +typedef uint16_t uaddr_t; extern void ei(void); extern irqflags_t di(void); @@ -21,6 +22,7 @@ extern void * __fastcall__ memset(void *, int, size_t); extern size_t __fastcall__ strlen(const char *); #define EMAGIC 0x4C /* Header of executable (JMP) */ +#define brk_limit() ramtop /* Stack is preallocated */ #define staticfast static @@ -40,7 +42,7 @@ typedef union { /* this structure is endian dependent */ } h; } ticks_t; -/* We don't yet have bank attributes and banking for Z80 */ +/* We don't yet have bank attributes and banking for 6502 */ #define CODE1 #define CODE2 #define COMMON diff --git a/Kernel/cpu-6809/cpu.h b/Kernel/cpu-6809/cpu.h index 8ec0e33c..29cbe743 100644 --- a/Kernel/cpu-6809/cpu.h +++ b/Kernel/cpu-6809/cpu.h @@ -11,12 +11,15 @@ typedef uint8_t irqflags_t; typedef int16_t arg_t; typedef uint16_t usize_t; /* Largest value passed by userspace */ typedef int16_t susize_t; +typedef uint16_t uaddr_t; /* A user address must fit this */ extern void ei(void); extern irqflags_t di(void); extern void irqrestore(irqflags_t f); #define EMAGIC 0x0E /* Header of executable (JMP) */ +/* Allow a minimum of 512 bytes gap between stack and top of allocations */ +#define brk_limit() (udata.u_syscall_sp - 512) extern void *memcpy(void *, const void *, size_t); extern void *memset(void *, int, size_t); diff --git a/Kernel/cpu-z80/cpu.h b/Kernel/cpu-z80/cpu.h index 7ed070d7..e841ecf8 100644 --- a/Kernel/cpu-z80/cpu.h +++ b/Kernel/cpu-z80/cpu.h @@ -8,6 +8,7 @@ typedef signed char int8_t; typedef int16_t arg_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 */ #define ei() do {__asm ei __endasm; } while(0); @@ -18,6 +19,9 @@ extern void irqrestore(irqflags_t f); /* Z80 binaries start with a JP */ #define EMAGIC 0xc3 /* Header of executable */ +/* Allow a minimum of 512 bytes gap between stack and top of allocations */ +#define brk_limit() (udata.u_syscall_sp - 512) + /* compiler provides optimised versions of these: */ #if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r3ka)