28,12 → 28,12 |
#include <ll/i386/error.h> |
|
#include <ll/i386/tss-ctx.h> |
#include <ll/sys/ll/ll-instr.h> /* Only for HW instr... */ |
#include <ll/sys/ll/ll-instr.h> /* Only for HW instr... */ |
#include <ll/sys/ll/ll-func.h> |
|
FILE(KL - Context - Switch); |
FILE(KL-Context-Switch); |
|
extern TSS TSS_table[TSSMax]; |
extern TSS TSS_table[TSSMax]; |
extern WORD TSS_control[TSSMax]; |
extern BYTE ll_FPU_stdctx[FPU_CONTEXT_SIZE]; |
|
47,8 → 47,8 |
/* Just a debugging function; it dumps the status of the TSS */ |
void dump_TSS(WORD sel) |
{ |
BYTE acc, gran; |
DWORD base, lim; |
BYTE acc,gran; |
DWORD base,lim; |
message("TR %x\n", sel); |
sel = TSSsel2index(sel); |
message("SS:SP %x:%lx\n", TSS_table[sel].ss, TSS_table[sel].esp); |
57,16 → 57,15 |
message("Stack2 : %x:%lx\n", TSS_table[sel].ss2, TSS_table[sel].esp2); |
message("CS : %x DS : %x\n", TSS_table[sel].cs, TSS_table[sel].ds); |
sel = TSSindex2sel(sel); |
message("Descriptor [%x] Info", sel); |
base = GDT_read(sel, &lim, &acc, &gran); |
message("Base : %lx Lim : %lx Acc : %x Gran %x\n", base, lim, |
(unsigned) (acc), (unsigned) (gran)); |
message("Descriptor [%x] Info",sel); |
base = GDT_read(sel,&lim,&acc,&gran); |
message("Base : %lx Lim : %lx Acc : %x Gran %x\n", base, lim, (unsigned)(acc),(unsigned)(gran)); |
} |
|
|
void ll_context_setspace(CONTEXT c, WORD as) |
{ |
int index = TSSsel2index(c); |
int index = TSSsel2index(c); |
|
TSS_table[index].ss0 = as; |
TSS_table[index].cs = as + 8; |
76,30 → 75,29 |
} |
|
/* Initialize context -> TSS in 32 bit */ |
CONTEXT ll_context_create(void (*task) (void *p), BYTE * stack, |
void *parm, void (*killer) (void), WORD control) |
CONTEXT ll_context_create(void (*task)(void *p),BYTE *stack, |
void *parm,void (*killer)(void),WORD control) |
{ |
CONTEXT index = 0; |
DWORD *stack_ptr = (DWORD *) stack; |
DWORD *stack_ptr = (DWORD *)stack; |
|
/* Push onto stack the input parameter */ |
/* And the entry point to the task killer procedure */ |
stack_ptr--; |
*stack_ptr = (DWORD) (parm); |
*stack_ptr = (DWORD)(parm); |
stack_ptr--; |
*stack_ptr = (DWORD) (killer); |
*stack_ptr = (DWORD)(killer); |
/* Find a free TSS */ |
while ((TSS_control[index] & TSS_USED) && (index < TSSMain)) |
index++; |
while ((TSS_control[index] & TSS_USED) && (index < TSSMain)) index++; |
/* This exception would signal an error */ |
if (index >= TSSMain) { |
message("No more Descriptors...\n"); |
message("No more Descriptors...\n"); |
return 0; |
} |
TSS_control[index] |= (TSS_USED | control); |
/* Fill the TSS structure */ |
/* No explicit protection; use only one stack */ |
TSS_table[index].esp0 = (DWORD) (stack_ptr); |
TSS_table[index].esp0 = (DWORD)(stack_ptr); |
TSS_table[index].esp1 = 0; |
TSS_table[index].esp2 = 0; |
TSS_table[index].ss0 = get_DS(); |
108,7 → 106,7 |
/* No paging activated */ |
TSS_table[index].cr3 = 0; |
/* Task entry point */ |
TSS_table[index].eip = (DWORD) (task); |
TSS_table[index].eip = (DWORD)(task); |
/* Need only to unmask interrupts */ |
TSS_table[index].eflags = 0x00000200; |
TSS_table[index].eax = 0; |
117,8 → 115,8 |
TSS_table[index].edx = 0; |
TSS_table[index].esi = 0; |
TSS_table[index].edi = 0; |
TSS_table[index].esp = (DWORD) (stack_ptr); |
TSS_table[index].ebp = (DWORD) (stack_ptr); |
TSS_table[index].esp = (DWORD)(stack_ptr); |
TSS_table[index].ebp = (DWORD)(stack_ptr); |
TSS_table[index].cs = get_CS(); |
TSS_table[index].es = get_DS(); |
TSS_table[index].ds = get_DS(); |
130,10 → 128,10 |
TSS_table[index].trap = 0; |
TSS_table[index].io_base = 0; |
/* Fill in the coprocessor status */ |
memcpy(TSS_table[index].ctx_FPU, ll_FPU_stdctx, FPU_CONTEXT_SIZE); |
memcpy(TSS_table[index].ctx_FPU,ll_FPU_stdctx,FPU_CONTEXT_SIZE); |
/* Convert the index into a valid selector */ |
/* Which really represent CONTEXT */ |
return (TSSindex2sel(index)); |
return(TSSindex2sel(index)); |
} |
|
|
145,18 → 143,18 |
TSS_control[index] = 0; |
} |
|
#if 0 /* It does not work... Fix it!!! */ |
DWORD ll_push_func(void (*func) (void)) |
#if 0 /* It does not work... Fix it!!! */ |
DWORD ll_push_func(void (*func)(void)) |
{ |
DWORD *p; |
DWORD old; |
DWORD *p; |
DWORD old; |
|
p = (DWORD *) entrypoint; |
old = *p; |
p = (DWORD *)entrypoint; |
old = *p; |
|
*p = (DWORD) func; |
|
return old; |
*p = (DWORD)func; |
|
return old; |
} |
#endif |
|
167,5 → 165,5 |
char *ll_context_sprintf(char *str, CONTEXT c) |
{ |
ksprintf(str, "%x (Hex)", c); |
return (str); |
return(str); |
} |