cpu: make brk address rules CPU specific
authorAlan Cox <alan@linux.intel.com>
Tue, 13 Jan 2015 22:01:23 +0000 (22:01 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 13 Jan 2015 22:01:23 +0000 (22:01 +0000)
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.

Kernel/cpu-6502/cpu.h
Kernel/cpu-6809/cpu.h
Kernel/cpu-z80/cpu.h

index 79f1ce5..a8aece3 100644 (file)
@@ -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
index 8ec0e33..29cbe74 100644 (file)
@@ -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);
index 7ed070d..e841ecf 100644 (file)
@@ -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)