Line 4... |
Line 4... |
//
|
//
|
// Project: CMod S6 System on a Chip, ZipCPU demonstration project
|
// Project: CMod S6 System on a Chip, ZipCPU demonstration project
|
//
|
//
|
// Purpose: These are the routines from kernel.c that didn't need to be
|
// Purpose: These are the routines from kernel.c that didn't need to be
|
// in RAM memory. They are specifically the pre-run setup
|
// in RAM memory. They are specifically the pre-run setup
|
// routines.
|
// routines that are executed from FLASH memory.
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
Line 56... |
Line 56... |
|
|
#define CONTEXT_LENGTH 100000 // 1ms
|
#define CONTEXT_LENGTH 100000 // 1ms
|
|
|
int LAST_TASK;
|
int LAST_TASK;
|
|
|
|
__attribute__((cold))
|
TASKP *ksetup(void) {
|
TASKP *ksetup(void) {
|
TASKP *tasklist;
|
TASKP *tasklist;
|
IOSPACE *sys = (IOSPACE *)IOADDR;
|
IOSPACE *sys = (IOSPACE *)IOADDR;
|
|
|
sys->io_spio = 0x0f0;
|
sys->io_spio = 0x0f0;
|
Line 76... |
Line 77... |
|
|
rxpipe = new_syspipe(16); //rxpipe->m_wrtask=INTERRUPT_WRITE_TASK;
|
rxpipe = new_syspipe(16); //rxpipe->m_wrtask=INTERRUPT_WRITE_TASK;
|
txpipe = new_syspipe(8); txpipe->m_rdtask = INTERRUPT_READ_TASK;
|
txpipe = new_syspipe(8); txpipe->m_rdtask = INTERRUPT_READ_TASK;
|
keypipe = new_syspipe(16);
|
keypipe = new_syspipe(16);
|
lcdpipe = new_syspipe(16);
|
lcdpipe = new_syspipe(16);
|
pwmpipe = new_syspipe(256); pwmpipe->m_rdtask= INTERRUPT_READ_TASK;
|
pwmpipe = new_syspipe(128); pwmpipe->m_rdtask= INTERRUPT_READ_TASK;
|
cmdpipe = new_syspipe(16);
|
cmdpipe = new_syspipe(16);
|
|
|
tasklist = sys_malloc(sizeof(TASKP)*(1+LAST_TASK));
|
tasklist = sys_malloc(sizeof(TASKP)*(1+LAST_TASK));
|
kinit(tasklist);
|
kinit(tasklist);
|
tasklist[LAST_TASK] = new_task(2, idle_task);
|
tasklist[LAST_TASK] = new_task(2, idle_task);
|
Line 110... |
Line 111... |
for(int i=0; i<40000; i++)
|
for(int i=0; i<40000; i++)
|
sys->io_spio = ((i>>14)&2)|0x020;
|
sys->io_spio = ((i>>14)&2)|0x020;
|
sys->io_spio = 0x0f7;
|
sys->io_spio = 0x0f7;
|
}
|
}
|
|
|
|
// __attribute__((noreturn))
|
void kuserexit(int a) {
|
void kuserexit(int a) {
|
syscall(TRAPID_EXIT, a, 0, 0);
|
syscall(TRAPID_EXIT, a, 0, 0);
|
}
|
}
|
|
|
|
__attribute__((malloc))
|
void *sys_malloc(int sz) {
|
void *sys_malloc(int sz) {
|
{
|
if (0) {
|
SCOPE *s = (SCOPE *)SCOPEADDR;
|
SCOPE *s = (SCOPE *)SCOPEADDR;
|
s->s_control = TRIGGER_SCOPE_NOW | (s->s_control & 0x0ffff);
|
s->s_control = TRIGGER_SCOPE_NOW | (s->s_control & 0x0ffff);
|
}
|
}
|
|
|
void *res = heap;
|
void *res = heap;
|
Line 130... |
Line 133... |
asm("break 0");
|
asm("break 0");
|
}
|
}
|
return res;
|
return res;
|
}
|
}
|
|
|
|
KFILDES *kopen(int id, KDEVICE *dev) {
|
|
KFILDES *fd = (KFILDES *)sys_malloc(sizeof(KFILDES));
|
|
fd->id = (int)id;
|
|
fd->dev= dev;
|
|
return fd;
|
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|