/* platform/tricks.s */
COMMON void switchout(void);
-COMMON void doexec(void *start_addr);
+COMMON void doexec(uint16_t start_addr);
COMMON void switchin(ptptr process);
COMMON int16_t dofork(ptptr child);
CODE2 uint8_t *swapin_prepare_uarea(ptptr p);
CODE2 void map_init(void);
CODE2 void platform_idle(void);
-extern uint8_t *ramtop; /* Note: ramtop must be in common in some cases */
+/* Will need a uptr_t eventually */
+extern uint16_t ramtop; /* Note: ramtop must be in common in some cases */
CODE2 extern void platform_interrupt(void);
CODE2 int16_t __exit(void); /* FUZIX system call 0 */
#define VT_BOTTOM 23
#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGBASE ((char *)(0x0200)) /* also data base */
-#define PROGLOAD ((char *)(0x0200))
-#define PROGTOP ((char *)(0xF000)) /* Top of program, base of U_DATA */
+#define PROGBASE 0x0200 /* also data base */
+#define PROGLOAD 0x0200
+#define PROGTOP 0xF000 /* Top of program, base of U_DATA */
-#define BOOT_TTY 3 /* Set this to default device for stdio, stderr */
+#define BOOT_TTY 513 /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
/* Temp FIXME set to serial port for debug ease */
#define VT_BOTTOM 23
#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGBASE ((uint8_t *)(0x0000)) /* also data base */
-#define PROGLOAD ((uint8_t *)(0x0000)) /* also data base */
-#define PROGTOP ((uint8_t *)(0x7C00)) /* Top of program */
+#define PROGBASE 0x0000 /* also data base */
+#define PROGLOAD 0x0000 /* also data base */
+#define PROGTOP 0x7C00 /* Top of program */
#define BOOT_TTY (512 + 1) /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
#define CONFIG_BANKS 1
#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGBASE ((char *)(0x0000)) /* also data base */
-#define PROGLOAD ((char *)(0x0100))
-#define PROGTOP ((char *)(0x7D00)) /* Top of program, base of U_DATA */
-#define PROC_SIZE 32 /* Memory needed per process */
+#define PROGBASE 0x0000 /* also data base */
+#define PROGLOAD 0x0100
+#define PROGTOP 0x7D00 /* Top of program, base of U_DATA */
+#define PROC_SIZE 32 /* Memory needed per process */
#define SWAP_SIZE 0x40 /* 32K in blocks (we actually don't need the low 256) */
#define SWAPBASE 0x0000 /* We swap the lot in one, include the */
#include <printf.h>
#include <devtty.h>
-uint8_t *ramtop = PROGTOP;
+uint16_t ramtop = PROGTOP;
/* On idle we spin checking for the terminals. Gives us more responsiveness
for the polled ports */
.globl init_hardware
.globl _program_vectors
.globl _system_tick_counter
+ .globl _kernel_flag
.globl map_kernel
.globl map_process
outchar:
out (0x01), a
ret
+
+; needs to be common
+_kernel_flag:
+ .db 1
#define VT_BOTTOM 23
#define TICKSPERSEC 50 /* Ticks per second (actually should be dynamic FIXME) */
-#define PROGBASE ((char *)(0x0000)) /* also data base */
-#define PROGLOAD ((char *)(0x0100))
-#define PROGTOP ((char *)(0x7D00)) /* Top of program (uarea stash) */
+#define PROGBASE 0x0000 /* also data base */
+#define PROGLOAD 0x0100
+#define PROGTOP 0x7D00 /* Top of program (uarea stash) */
#define BOOT_TTY (512 + 1) /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
.globl map_save
.globl map_restore
.globl _slot_table
+ .globl _kernel_flag
; video driver
.globl _vtinit
di
halt
+_kernel_flag:
+ .db 1
+
+
; -----------------------------------------------------------------------------
; KERNEL MEMORY BANK (below 0xF000, only accessible when the kernel is mapped)
; -----------------------------------------------------------------------------
#define VT_BOTTOM 23
#define TICKSPERSEC 50 /* Ticks per second (actually should be dynamic FIXME) */
-#define PROGBASE ((char *)(0x0000)) /* also data base */
-#define PROGLOAD ((char *)(0x0100))
-#define PROGTOP ((char *)(0xF000)) /* Top of program, base of U_DATA */
+#define PROGBASE 0x0000 /* also data base */
+#define PROGLOAD 0x0100
+#define PROGTOP 0xF000 /* Top of program, base of U_DATA */
#define BOOT_TTY (512 + 1) /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
.globl map_process_always
.globl map_save
.globl map_restore
+ .globl _kernel_flag
; video driver
.globl _vtinit
di
halt
+_kernel_flag:
+ .db 1
+
; -----------------------------------------------------------------------------
; KERNEL MEMORY BANK (below 0xF000, only accessible when the kernel is mapped)
; -----------------------------------------------------------------------------
/* NC100 or NC200 - your choice */
#define CONFIG_NC200
+#ifdef CONFIG_NC200
+#define CONFIG_CPM_EMU
+#endif
+
/* Enable to make ^Z dump the inode table for debug */
#undef CONFIG_IDUMP
/* Enable to make ^A drop back into the monitor */
#endif
#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGBASE ((char *)(0x0000)) /* also data base */
-#define PROGLOAD ((char *)(0x0100))
-#define PROGTOP ((char *)(0xF000)) /* Top of program, base of U_DATA */
-//#define PROC_SIZE 64 /* Memory needed per process (for now) */
+#define PROGBASE 0x0000 /* also data base */
+#define PROGLOAD 0x0100
+#define PROGTOP 0xF000 /* Top of program, base of U_DATA */
#define BOOT_TTY (512+1) /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
#define CONFIG_MULTI
/* Single tasking */
#undef CONFIG_SINGLETASK
+/* CPM emulation capable */
+#define CONFIG_CPM_EMU
/* 16K reported page size */
#define CONFIG_PAGE_SIZE 16
/* We use flexible 16K banks so use the helper */
#define VT_BOTTOM 31
#define TICKSPERSEC 50 /* Ticks per second */
-#define PROGBASE ((char *)(0x0000)) /* memory base of program */
-#define PROGLOAD ((char *)(0x0100)) /* load base of program */
-#define PROGTOP ((char *)(0xF000)) /* Top of program, base of U_DATA */
-#define PROC_SIZE 64 /* Memory needed per process */
+#define PROGBASE 0x0000 /* memory base of program */
+#define PROGLOAD 0x0100 /* load base of program */
+#define PROGTOP 0xF000 /* Top of program, base of U_DATA */
+#define PROC_SIZE 64 /* Memory needed per process */
#define SWAP_SIZE 0x80 /* 64K in blocks (we actually don't need the low 256) */
#define SWAPBASE 0x0000 /* We swap the lot in one, include the */
#define VT_BOTTOM 24
#define TICKSPERSEC 60 /* Ticks per second */
-#define PROGBASE ((char *)(0x0000)) /* Base of user */
-#define PROGLOAD ((char *)(0x0100)) /* Load and run here
-#define PROGTOP ((char *)(0xF900)) /* Top of program, base of U_DATA */
+#define PROGBASE 0x0000 /* Base of user */
+#define PROGLOAD 0x0100 /* Load and run here */
+#define PROGTOP 0xF900 /* Top of program, base of U_DATA */
#define PROC_SIZE 64 /* Memory needed per process */
#define SWAP_SIZE 0x80 /* 64K in blocks (we actually don't need quite all) */
#include <printf.h>
#include <devtty.h>
-uint8_t *ramtop = PROGTOP;
+uint16_t ramtop = PROGTOP;
/* On idle we spin checking for the terminals. Gives us more responsiveness
for the polled ports */
.globl map_save
.globl map_restore
.globl platform_interrupt_all
+ .globl _kernel_flag
; exported debugging tools
.globl _trap_monitor
_opreg: .db 0x36 ; kernel map, 80 columns
_modout: .db 0x50 ; 80 column, sound enabled, altchars off,
; external I/O enabled, 4MHz
+_kernel_flag:
+ .db 1 ; We start in kernel mode
_program_vectors:
; we are called, with interrupts disabled, by both newproc() and crt0
#define CONFIG_BANKS 1
#define TICKSPERSEC 100 /* Ticks per second */
-#define PROGLOAD ((char *)(0x0000)) /* also data base */
-#define PROGBASE ((char *)(0x0100)) /* also data base */
-#define PROGTOP ((char *)(0xED00)) /* Top of program, base of U_DATA copy */
+#define PROGLOAD 0x0000 /* also data base */
+#define PROGBASE 0x0100 /* also data base */
+#define PROGTOP 0xED00 /* Top of program, base of U_DATA copy */
#define PROC_SIZE 60 /* Memory needed per process */
#define SWAP_SIZE 0x78 /* 60K in blocks (we actually don't need the low 256) */
#include <printf.h>
#include <devtty.h>
-uint8_t *ramtop = PROGTOP;
+uint16_t ramtop = PROGTOP;
void pagemap_init(void)
#define CONFIG_FONT8X8
#define CONFIG_FONT8X8SMALL
-/* We have 1 bank at C000 with 6 possible pages to map, but I'm not sure if CONFIG_BANK_FIXED is our choise. */
+/* We have 1 bank at C000 with 6 possible pages to map, but I'm not sure
+ if CONFIG_BANK_FIXED is our choice. */
+
/* Fixed banking */
#define CONFIG_BANK_FIXED
/* 6 16K banks, 1 is for kernel needs */
#define VT_BOTTOM 23
#define TICKSPERSEC 50 /* Ticks per second */
-#define PROGBASE ((char *)(0xC000)) /* also data base */
-#define PROGTOP ((char *)(0xFFFF)) /* Top of program, base of U_DATA copy */
+#define PROGBASE 0xC000 /* also data base */
+#define PROGLOAD 0xC000 /* also data base */
+#define PROGTOP 0xFD00 /* Top of program, base of U_DATA copy */
#define PROC_SIZE 16 /* Memory needed per process */
#define UDATA_BLOCKS 0 /* We swap the stash not the uarea */
#define UDATA_SWAPSIZE 0
-#define BOOT_TTY (1) /* Set this to default device for stdio, stderr */
+#define BOOT_TTY (512+1) /* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
/* We need a tidier way to do this from the loader */
#include <printf.h>
#include <devtty.h>
-uint8_t *ramtop = PROGTOP;
+uint16_t ramtop = PROGTOP;
void pagemap_init(void)
.globl map_save
.globl map_restore
+ .globl _kernel_flag
+
.globl _fd_bankcmd
; exported debugging tools
outchar:
out (#0x15), A
ret
+
+_kernel_flag:
+ .db 1
int pagemap_realloc(uint16_t size)
{
- if (size >= (uint16_t) ramtop)
+ if (size >= ramtop)
return ENOMEM;
return 0;
}
uint16_t pagemap_mem_used(void)
{
- return ((uint16_t)(PROGTOP - PROGBASE)) >> 10;
+ return (PROGTOP - PROGBASE) >> 10;
}
void pagemap_init(void)
static int do_swap_out(uint8_t * s, uint16_t l)
{
- uint8_t *p = ramtop - 1;
+ uint8_t *p = (uint8_t *)(ramtop - 1);
// Xpanic("do_swap_out ");
// Xout((uint16_t)s);
*p-- = (uint16_t) ramtop >> 8;
*p = (uint16_t) ramtop & 0xFF;
// Xpanic("Ramtop was ");
-// Xout((uint16_t)ramtop);
- ramtop = p;
+// Xout(ramtop);
+ ramtop = (uint16_t)p;
// Xpanic(" now ");
-// Xout((uint16_t)ramtop);
+// Xout(ramtop);
// Xpanic("\r\n");
s;
l;
static void do_swap_in(uint8_t * d, uint16_t l)
{
- uint8_t *p = (uint8_t *) (ramtop[0] | (((uint16_t) ramtop[1]) << 8)); /* Recover old base pointer */
+ uint8_t *p;
+ p = (uint8_t *) ramtop;
+ p = (uint8_t *) (p[0] | (((uint16_t) p[1]) << 8)); /* Recover old base pointer */
// Xout(ramtop[1]);
// Xout(ramtop[2]);
// Xpanic("Entry Ramtop: ");
// Xpanic("New Ramtop: ");
// Xout((uint16_t)p);
unpack(d, p, l);
- ramtop = p;
+ ramtop = (uint16_t)p;
// Xpanic("\r\n");
}
#endif
static int do_swap_out(uint8_t * p, uint16_t l)
{
- uint16_t room = (uint16_t) ramtop - udata.u_top;
+ uint16_t room = ramtop - udata.u_top;
uint8_t *d;
Xpanic("len ");
return -1;
ramtop -= l + 2;
Xpanic("ramtop now ");
- Xout((uint16_t) ramtop);
+ Xout(ramtop);
d = (uint8_t *) ramtop;
d[0] = l & 0xFF;
d[1] = l >> 8;
int swapout(ptptr p)
{
- uint8_t *oldtop = ramtop;
+ uint16_t oldtop = ramtop;
p;
// Xpanic("Swapout");
// Xout((uint16_t)udata.u_ptab);
*j = NO_FILE;
}
/* Poke the execve arguments into user data space so _execve() can read them back */
- uput(arg, PROGLOAD, sizeof(arg));
+ uput(arg, (void *)PROGLOAD, sizeof(arg));
/* Poke in arv[0] - FIXME: Endianisms... */
- uputw((uint16_t)PROGLOAD + 1, PROGLOAD + 7);
+ uputw(PROGLOAD+1 , (void *)(PROGLOAD + 7));
/* Set up things to look like the process is calling _execve() */
- udata.u_argn = (uint16_t) PROGLOAD;
- udata.u_argn1 = (uint16_t)PROGLOAD + 0x7; /* Arguments (just "/init") */
- udata.u_argn2 = (uint16_t)PROGLOAD + 0xb; /* Environment (none) */
+ udata.u_argn = PROGLOAD;
+ udata.u_argn1 = PROGLOAD + 0x7; /* Arguments (just "/init") */
+ udata.u_argn2 = PROGLOAD + 0xb; /* Environment (none) */
}
void fuzix_main(void)
staticfast struct s_argblk *abuf, *ebuf;
int16_t (**sigp) ();
int argc;
- uint16_t emu_size, emu_copy;
- uint8_t *progptr, *emu_ptr, *emu_base;
+ uint16_t emu_size, emu_copy, progptr;
+ uint16_t emu_ptr, emu_base;
staticfast uint16_t top;
uint8_t c;
uint16_t blocks;
- top = (uint16_t)ramtop;
+ top = ramtop;
if (!(ino = n_open(name, NULLINOPTR)))
return (-1);
if (buf[3] == 'F' && buf[4] == 'Z' && buf[5] == 'X' && buf[6] == '1') {
top = buf[7] | ((unsigned int)buf[8] << 8);
if (top == 0) /* Legacy 'all space' binary */
- top = (uint16_t)ramtop;
+ top = ramtop;
emu_ino = 0; // no emulation, thanks
} else {
#ifdef CONFIG_CPM_EMU
udata.u_error = ENOEXEC;
goto nogood2;
}
- top = (uint16_t)ramtop;
+ top = ramtop;
#else
emu_size;
emu_copy;
/* We are definitely going to succeed with the exec,
* so we can start writing over the old program
*/
- uput(buf, PROGLOAD, 512); /* Move 1st Block to user bank */
+ uput(buf, (uint8_t *)PROGLOAD, 512); /* Move 1st Block to user bank */
brelse(buf);
- c = ugetc(PROGLOAD);
+ c = ugetc((uint8_t *)PROGLOAD);
if (c != 0xC3)
kprintf("Botched uput\n");
if (emu_ino) {
emu_size = emu_ino->c_node.i_size;
// round up to nearest multiple of 256 bytes, fit it in below ramtop
- emu_ptr =
- (char *) (udata.u_top - ((emu_size + 255) & 0xff00));
+ emu_ptr = udata.u_top - ((emu_size + 255) & 0xff00);
emu_base = emu_ptr;
blk = 0;
while (emu_size) {
buf = bread(emu_ino->c_dev, bmap(emu_ino, blk, 1), 0); // read block
emu_copy = min(512, emu_size);
- uput(buf, emu_ptr, emu_copy); // copy to userspace
+ uput(buf, (uint8_t *)emu_ptr, emu_copy); // copy to userspace
bufdiscard((bufptr) buf);
brelse((bufptr) buf); // release block
// adjust pointers
* of process memory
*/
- uzero(emu_ptr, top - emu_ptr);
+ uzero((uint8_t *)emu_ptr, top - emu_ptr);
} else
#endif
{
- emu_base = (uint8_t *)top;
+ emu_base = top;
}
/* emu_base now points at the byte after the last byte the program can occupy */
for (blk = 1; blk <= blocks; ++blk) {
buf = bread(ino->c_dev, bmap(ino, blk, 1), 0);
- uput(buf, progptr, 512);
+ uput(buf, (uint8_t *)progptr, 512);
bufdiscard((bufptr) buf);
brelse((bufptr) buf);
progptr += 512;
udata.u_break = (int) progptr; // Set initial break for program
// zero all remaining process memory above the last block loaded.
- uzero(progptr, emu_base - progptr);
+ uzero((uint8_t *)progptr, emu_base - progptr);
// Turn off caught signals
for (sigp = udata.u_sigvec; sigp < udata.u_sigvec + NSIGS; ++sigp)