/shark/tags/rel_0_5/oslib/libm/makefile |
---|
6,20 → 6,20 |
# |
ifndef BASE |
BASE = ../.. |
BASEDOS = ..\.. |
BASE = .. |
BASEDOS = .. |
endif |
include $(BASE)/config/config.mk |
include $(BASE)/config.mk |
C_INC= -I. -I$(BASE)/include/ll -I$(BASE)/include |
C_OPT += -I$(INCL)/ll -I. |
C_OPT += -Dlint -Wno-uninitialized -Wno-parentheses |
ASM_OPT += -Dlint -I. |
# by Massy |
# so there is no conflict with standard libC library |
C_OPT += -Dwrite=ll_internal_write |
C_OPT += -Dwrite=glue_write |
SRCDIRS = msun/src msun/i387 machine |
space := $(empty) $(empty) |
75,16 → 75,17 |
allclean : clean |
echo # Kernel Dependency file > deps |
$(RM) ..\lib\libhm.a |
$(RM) (LIB_PATH)libhm.a |
deps : $(OBJS:.o=.c) |
$(CC) $(C_OPT) $(VMINCL) -M $(OBJS:.o=.c) > deps |
#deps : $(OBJS:.o=.c) |
deps : makefile $(CFILES) |
$(CC) $(C_OPT) -M $(CFILES) > deps |
libhm.a : $(OBJS) |
$(AR) rs libhm.a $(OBJS) |
deb: |
type $(VPATH) |
echo $(CFILES) |
%.s:%.c |
/shark/tags/rel_0_5/oslib/todo.txt |
---|
1,6 → 1,17 |
- The vm86 reflection code contains a dirty hack: the vm86_exc1 function |
in vm86-exc.c hardcodes the int to be reflected... |
This should be fixed in some way!!! |
FIXED (and seems to be working very well...) |
- Now, the registers structure should be fixed: move the flags field to the |
other side of the structure (adding the CS and EIP fields), so that |
we will not have to push flags and explicitly move it anymore... |
DONE |
- Fix problems with ASs and INTs (see kl/cxsw-1.s and xlib/exc.s) |
Done! At least it doesn't crash :) |
Must check in some way if the stack is correct or not... |
I checked it, and it seems to be ok... |
- verify that only the needed .o files are linked (see -DPROFILE); provide |
a lightweight implementation of ``message'' (currently remapped on |
17,6 → 28,7 |
Assigned to Gerardo |
- provide some macro for int-based and call gate-based system calls |
Done for INT: see examples/syscalls.c |
- begin to implement some serious code using OSLib: |
1) some simple multithreading executive based on cooperative and |
32,4 → 44,8 |
to the latest version of the standard. Implement modules loading |
== Some work has been done... Now the eXtender can load MB compiant images |
and manages modules. |
== Now everything is compatible with the latest MB standard (the loader |
name is used) |
o Still to do: the memory map stuff & module parameters |
- what about fixing that _NOH4_ story? |
/shark/tags/rel_0_5/oslib/kl/cxsw-1.s |
---|
File deleted |
/shark/tags/rel_0_5/oslib/kl/stuff.c |
---|
File deleted |
/shark/tags/rel_0_5/oslib/kl/time.c |
---|
30,17 → 30,15 |
#include <ll/sys/ll/time.h> |
/* These are for the EXECT and TICK modes */ |
extern DWORD ticksize; /* From init.c */ |
extern struct timespec actTime; /* From event.c */ |
extern WORD pit_time_const; /* From init.c */ |
extern DWORD timermode; /* From init.c */ |
extern DWORD ticksize; /* From init.c */ |
extern struct timespec actTime; /* From event.c */ |
extern WORD pit_time_const; /* From init.c */ |
extern DWORD timermode; /* From init.c */ |
/* These two are for the NEW algorithm */ |
extern WORD lastTime; /* From event.c */ |
extern struct pitspec globalCounter; /* From event.c */ |
extern WORD lastTime; /* From event.c */ |
extern struct pitspec globalCounter; /* From event.c */ |
extern BYTE frc; |
extern int activeEvent; |
FILE(Time); |
47,80 → 45,84 |
TIME ll_gettime(int mode, struct timespec *tsres) |
{ |
DWORD res, tc; |
BYTE isr; |
struct timespec tmp; |
DWORD res, tc; |
BYTE isr; |
struct timespec tmp; |
if (activeEvent) { |
if (tsres != NULL) { |
PITSPEC2TIMESPEC(&globalCounter, tsres); |
return TIMESPEC2USEC(tsres); |
} else { |
PITSPEC2TIMESPEC(&globalCounter, &tmp); |
return TIMESPEC2USEC(&tmp); |
} |
} |
#if 1 |
if (activeEvent) { |
if (tsres != NULL) { |
PITSPEC2TIMESPEC(&globalCounter, tsres); |
} else { |
struct timespec tmp; |
if (mode == TIME_PTICK) { |
if (timermode != LL_PERIODIC) { |
return 0; |
PITSPEC2TIMESPEC(&globalCounter, &tmp); |
return TIMESPEC2USEC(&tmp); |
} |
return TIMESPEC2USEC(tsres); |
} |
res = TIMESPEC2USEC(&actTime); |
if (tsres != NULL) { |
memcpy(tsres, &actTime, sizeof(struct timespec)); |
#endif |
if (mode == TIME_PTICK) { |
if (timermode != LL_PERIODIC) { |
return 0; |
} |
res = TIMESPEC2USEC(&actTime); |
if (tsres != NULL) { |
memcpy(tsres, &actTime, sizeof(struct timespec)); |
} |
return res; |
} |
return res; |
} |
if (mode == TIME_EXACT) { |
WORD tmp; |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
if (tsres != NULL) { |
if (mode == TIME_NEW) { |
WORD tmp; |
tmp = pit_read(frc); |
ADDPITSPEC((WORD)(lastTime - tmp), &globalCounter); |
lastTime = tmp; |
if (tsres != NULL) { |
PITSPEC2TIMESPEC(&globalCounter, tsres); |
} |
return (PITSPEC2USEC(&globalCounter)); |
} |
return (PITSPEC2USEC(&globalCounter)); |
} |
if (mode == TIME_NEW) { |
if (timermode == LL_PERIODIC) { |
memcpy(&tmp, &actTime, sizeof(struct timespec)); |
/* How much time has elapsed |
* from the last Tick Boundary? |
*/ |
tc = pit_read(0); |
if (tc > pit_time_const) { |
error("LL Time Panic!!!\n"); |
ll_abort(1); |
} |
res = pit_time_const - tc; |
res *= ticksize; |
res /= pit_time_const; |
if (mode == TIME_EXACT) { |
if (timermode == LL_PERIODIC) { |
memcpy(&tmp, &actTime, sizeof(struct timespec)); |
/* How much time has elapsed |
* from the last Tick Boundary? |
*/ |
tc = pit_read(0); |
if (tc > pit_time_const) { |
error("LL Time Panic!!!\n"); |
ll_abort(1); |
} |
res = pit_time_const - tc; |
res *= ticksize; |
res /= pit_time_const; |
/* Detect tick boundary and adjust the time... */ |
outp(0x20, 0x0A); |
isr = inp(0x20); |
if ((isr & 1) && res < ((8 * ticksize) / 10)) { |
/* |
res += ticksize; |
ADDNANO2TIMESPEC(ticksize * 1000, &tmp); |
*/ |
res = ticksize; |
} |
/* Detect tick boundary and adjust the time... */ |
outp(0x20, 0x0A); |
isr = inp(0x20); |
if ((isr & 1) && res < ((8*ticksize)/10)){ |
/* |
res += ticksize; |
ADDNANO2TIMESPEC(ticksize * 1000, &tmp); |
*/ |
res = ticksize; |
} |
/* Sum the Tick time... */ |
ADDNANO2TIMESPEC(res * 1000, &tmp); |
res += TIMESPEC2USEC(&actTime); |
/* Sum the Tick time... */ |
ADDNANO2TIMESPEC(res * 1000, &tmp); |
res += TIMESPEC2USEC(&actTime); |
if (tsres != NULL) { |
memcpy(tsres, &tmp, sizeof(struct timespec)); |
} |
return res; |
} else { |
return 0; |
if (tsres != NULL) { |
memcpy(tsres, &tmp, sizeof(struct timespec)); |
} |
return res; |
} else { |
return 0; |
} |
} |
} |
return 0; |
return 0; |
} |
/shark/tags/rel_0_5/oslib/kl/event1.c |
---|
1,216 → 1,216 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Time Event routines (one shot mode) */ |
#include <ll/i386/stdlib.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/pit.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/event.h> |
FILE(EventOneShot); |
extern int activeInt; |
int activeEvent; |
extern BYTE frc; |
extern struct event eventlist[MAX_EVENT]; |
extern WORD lastTime; |
extern struct pitspec globalCounter; |
extern struct event *freeevents; |
extern struct event *firstevent; |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
/* TODO: oneshot_event_delete & oneshot_event_init... */ |
/* Switched to timespec */ |
int oneshot_event_post(struct timespec time, void (*handler) (void *p), |
void *par) |
{ |
struct event *p; |
struct event *p1, *t; |
struct timespec now, tmp; |
int done; |
DWORD tnext; |
if (!freeevents) { |
return -1; |
} |
/* Extract from the ``free events'' queue */ |
p = freeevents; |
freeevents = p->next; |
/* Fill the event fields */ |
p->handler = handler; |
TIMESPEC_ASSIGN(&(p->time), &time); |
p->par = par; |
/* ...And insert it in the event queue!!! */ |
t = NULL; |
done = 0; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; p1; p1 = t->next) { |
if (TIMESPEC_A_GT_B((&time), (&p1->time))) { |
t = p1; |
} else |
break; |
} |
/* adjust next entry */ |
if (t) { |
t->next = p; |
} else { |
firstevent = p; |
if (!activeEvent) { |
ll_gettime(TIME_EXACT, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
tnext = TIMESPEC2USEC(&tmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
} |
} |
p->next = p1; |
return p->index; |
} |
void oneshot_wake_up(void) |
{ /* CHANGE the NAME, please... */ |
struct event *p = NULL, *pp; |
struct timespec now, ttmp; |
WORD tmp; |
DWORD tnext; |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
if (firstevent != NULL) { |
activeEvent = 1; |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
if (!activeInt && evt_prol != NULL) { |
evt_prol(); |
} |
activeInt++; |
for (p = firstevent; p != NULL; p = pp) { |
if ((p->time.tv_sec > now.tv_sec) || |
((p->time.tv_sec == now.tv_sec) |
&& (p->time.tv_nsec > now.tv_nsec))) { |
break; |
} |
pp = p->next; |
p->next = freeevents; |
freeevents = p; |
firstevent = pp; |
p->handler(p->par); |
} |
if (activeInt == 1 && evt_epil != NULL) { |
evt_epil(); |
} |
activeInt--; |
} |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&ttmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &ttmp); |
} |
/* SUBTIMESPEC(&(firstevent->time), &now, &ttmp); */ |
tnext = TIMESPEC2USEC(&ttmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
activeEvent = 0; |
} else { |
pit_setconstant(0, 0xFFFF); |
} |
} |
int oneshot_event_delete(int index) |
{ |
struct event *p1, *t; |
struct timespec tmp, now; |
DWORD tnext; |
int firstdeleted = FALSE; |
t = NULL; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; (p1) && (index != p1->index); p1 = t->next) { |
t = p1; |
} |
if (p1 == NULL) { |
return -1; |
} |
if (t == NULL) { |
firstevent = p1->next; |
firstdeleted = TRUE; |
} else { |
t->next = p1->next; |
} |
p1->next = freeevents; |
freeevents = p1; |
if (!activeEvent) { |
if (firstevent == NULL) { |
pit_setconstant(0, 0xFFFF); |
} else { |
if (firstdeleted) { |
ll_gettime(TIME_EXACT, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
/*SUBTIMESPEC(&now, &(firstevent->time), &tmp); */ |
tnext = TIMESPEC2USEC(&tmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
} |
} |
} |
return 1; |
} |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Time Event routines (one shot mode) */ |
#include <ll/i386/stdlib.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/pit.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/event.h> |
FILE(EventOneShot); |
extern int activeInt; |
int activeEvent; |
extern BYTE frc; |
extern struct event eventlist[MAX_EVENT]; |
extern WORD lastTime; |
extern struct pitspec globalCounter; |
extern struct event *freeevents; |
extern struct event *firstevent; |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
/* TODO: oneshot_event_delete & oneshot_event_init... */ |
/* Switched to timespec */ |
int oneshot_event_post(struct timespec time, void (*handler) (void *p), |
void *par) |
{ |
struct event *p; |
struct event *p1, *t; |
struct timespec now, tmp; |
int done; |
DWORD tnext; |
if (!freeevents) { |
return -1; |
} |
/* Extract from the ``free events'' queue */ |
p = freeevents; |
freeevents = p->next; |
/* Fill the event fields */ |
p->handler = handler; |
TIMESPEC_ASSIGN(&(p->time), &time); |
p->par = par; |
/* ...And insert it in the event queue!!! */ |
t = NULL; |
done = 0; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; p1; p1 = t->next) { |
if (TIMESPEC_A_GT_B((&time), (&p1->time))) { |
t = p1; |
} else |
break; |
} |
/* adjust next entry */ |
if (t) { |
t->next = p; |
} else { |
firstevent = p; |
if (!activeEvent) { |
ll_gettime(TIME_NEW, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
tnext = TIMESPEC2USEC(&tmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
} |
} |
p->next = p1; |
return p->index; |
} |
void oneshot_wake_up(void) |
{ /* CHANGE the NAME, please... */ |
struct event *p = NULL, *pp; |
struct timespec now, ttmp; |
WORD tmp; |
DWORD tnext; |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
if (firstevent != NULL) { |
activeEvent = 1; |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
if (!activeInt && evt_prol != NULL) { |
evt_prol(); |
} |
activeInt++; |
for (p = firstevent; p != NULL; p = pp) { |
if ((p->time.tv_sec > now.tv_sec) || |
((p->time.tv_sec == now.tv_sec) |
&& (p->time.tv_nsec > now.tv_nsec))) { |
break; |
} |
pp = p->next; |
p->next = freeevents; |
freeevents = p; |
firstevent = pp; |
p->handler(p->par); |
} |
if (activeInt == 1 && evt_epil != NULL) { |
evt_epil(); |
} |
activeInt--; |
} |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&ttmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &ttmp); |
} |
/* SUBTIMESPEC(&(firstevent->time), &now, &ttmp); */ |
tnext = TIMESPEC2USEC(&ttmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
activeEvent = 0; |
} else { |
pit_setconstant(0, 0xFFFF); |
} |
} |
int oneshot_event_delete(int index) |
{ |
struct event *p1, *t; |
struct timespec tmp, now; |
DWORD tnext; |
int firstdeleted = FALSE; |
t = NULL; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; (p1) && (index != p1->index); p1 = t->next) { |
t = p1; |
} |
if (p1 == NULL) { |
return -1; |
} |
if (t == NULL) { |
firstevent = p1->next; |
firstdeleted = TRUE; |
} else { |
t->next = p1->next; |
} |
p1->next = freeevents; |
freeevents = p1; |
if (!activeEvent) { |
if (firstevent == NULL) { |
pit_setconstant(0, 0xFFFF); |
} else { |
if (firstdeleted) { |
ll_gettime(TIME_NEW, &now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
/*SUBTIMESPEC(&now, &(firstevent->time), &tmp); */ |
tnext = TIMESPEC2USEC(&tmp); |
tnext = (tnext * 1197) / 1000; |
pit_setconstant(0, tnext); |
} |
} |
} |
return 1; |
} |
/shark/tags/rel_0_5/oslib/kl/init.c |
---|
28,6 → 28,7 |
#include <ll/i386/mb-info.h> |
#include <ll/i386/error.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/hw-arch.h> |
34,14 → 35,19 |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/ll-mem.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/event.h> /* for irq_bind() & irq_init() */ |
#include <ll/sys/ll/exc.h> /* These are the HW exceptions */ |
#include <ll/sys/ll/event.h> /* for irq_bind() & irq_init() */ |
#include <ll/sys/ll/exc.h> /* These are the HW exceptions */ |
FILE(LL - Init); |
FILE(LL-Init); |
/* These are declared in llCx32b.C */ |
TSS TSS_table[TSSMax]; |
WORD TSS_control[TSSMax]; |
BYTE ll_FPU_stdctx[FPU_CONTEXT_SIZE]; |
void ll_exc_hook(int i) |
{ |
static char *exc_mess[] = { |
static char *exc_mess[] = { |
"#Division by 0", |
"#Debug fault", |
"#NMI detected", |
49,7 → 55,7 |
"#Overflow detected on INTO", |
"#BOUND limit exceeded", |
"*Unvalid opcode", |
"1FPU context switch", /* Handled in the llCtx.Asm/S File */ |
"1FPU context switch", /* Handled in the llCtx.Asm/S File */ |
"*Double defect", |
"#INTEL reserved", |
"*Unvalid TSS", |
59,103 → 65,131 |
"#Page fault", |
"#INTEL reserved", |
"2Coprocessor error" |
}; |
}; |
static int exc_code[] = { |
static int exc_code[] = { |
DIV_BY_0, NMI_EXC, DEBUG_EXC, BREAKPOINT_EXC, |
HW_FAULT, HW_FAULT, HW_FAULT, |
0, /* This is the FPU ctx Switch */ |
0, /* This is the FPU ctx Switch */ |
HW_FAULT, HW_FAULT, HW_FAULT, HW_FAULT, |
HW_FAULT, HW_FAULT, HW_FAULT, HW_FAULT, |
MATH_EXC |
}; |
}; |
char code = *exc_mess[i]; |
#ifdef __LL_DEBUG__ |
extern long int ndp_called, ndp_switched; |
extern wu_called; |
extern ai_called; |
extern DWORD *smain; |
#endif |
char code = *exc_mess[i]; |
#ifdef __LL_DEBUG__ |
extern long int ndp_called,ndp_switched; |
extern wu_called; |
extern ai_called; |
extern DWORD *smain; |
#endif |
/* Math error! FPU has to be acknowledgded */ |
if (code == '2') |
ll_out(0x0F0, 0); |
message("Exception %d occurred\n", i); |
message("%s\n", &exc_mess[i][1]); |
#ifdef __LL_DEBUG__ |
if (code == '*') { |
/* Dump additional info */ |
message("DS:%nx CS:%nx\n", get_DS(), get_CS()); |
/* message("WU : %d AI : %d\n",wu_called,ai_called); */ |
message("Actual stack : %x\n", get_SP()); |
/* message("Main stack : %p\n",smain); */ |
dump_TSS(get_TR()); |
} |
#endif |
/* halt(); */ |
ll_abort(exc_code[i]); |
/* Math error! FPU has to be acknowledgded */ |
if (code == '2') ll_out(0x0F0,0); |
message("Exception %d occurred\n", i); |
message("%s\n", &exc_mess[i][1]); |
#ifdef __LL_DEBUG__ |
if (code == '*') { |
/* Dump additional info */ |
message("DS:%nx CS:%nx\n",get_DS(),get_CS()); |
/* message("WU : %d AI : %d\n",wu_called,ai_called); */ |
message("Actual stack : %x\n",get_SP()); |
/* message("Main stack : %p\n",smain); */ |
dump_TSS(get_TR()); |
} |
#endif |
/* halt(); */ |
ll_abort(exc_code[i]); |
} |
void *ll_init(void) |
{ |
void *p; |
int i; |
LIN_ADDR b; |
DWORD s; |
BYTE *base; |
void *p; |
int i; |
LIN_ADDR b; |
/* |
DWORD s; |
BYTE *base; |
*/ |
TSS dummy_tss; /* Very dirty, but we need it, in order to |
get an initial value for the FPU |
context... |
*/ |
p = l1_init(); |
/* First of all, init the exc and irq tables... */ |
irq_init(); |
for(i = 0; i < 32; i++) { |
p = l1_init(); |
/* First of all, init the exc and irq tables... */ |
irq_init(); |
for (i = 0; i < 16; i++) { |
void act_int(int i); |
/* Warning!!! The hw exceptions should be 32.... Fix it!!! */ |
/* |
ll_irq_table[i] = (DWORD)act_int; |
ll_exc_table[i] = (DWORD)ll_exc_hook; |
*/ |
l1_irq_bind(i, act_int); |
l1_exc_bind(i, ll_exc_hook); |
} |
l1_exc_bind(i, ll_exc_hook); |
} |
for(i = 0; i < 16; i++) { |
void act_int(int i); |
l1_irq_bind(i, act_int); |
} |
/* ll_mem_init must be explicitelly called by program... */ |
/* Init TSS table & put the corrispondent selectors into GDT */ |
TSS_control[TSSMain] |= TSS_USED; |
for (i = 0; i < TSSMax; i++) { |
/* b = appl2linear(&TSS_table[i]); */ |
b = (LIN_ADDR)(&TSS_table[i]); |
GDT_place(TSSindex2sel(i),(DWORD)b,sizeof(TSS),FREE_TSS386, GRAN_16); |
} |
#if 0 |
/* Get info about extended memory! We suppose that X has loaded */ |
/* there the application; if you switch to DOS memory, then you */ |
/* have to change the stuff in order it works; check X_... for */ |
/* details. */ |
X_meminfo(&b, &s, NULL, NULL); |
base = (BYTE *) b; |
#ifdef __MEM_DEBUG__ |
message("PM Free Mem Base : %lx\n", b); |
message("PM null addr (0L) : %lx\n", appl2linear((void *) 0L)); |
message("PM Free Mem Base (Cnvrtd): %lp\n", base); |
ll_FPU_save(); |
memcpy(ll_FPU_stdctx,ll_FPU_savearea,FPU_CONTEXT_SIZE); |
#else |
save_fpu(&dummy_tss); /* OK???*/ |
memcpy(ll_FPU_stdctx, dummy_tss.ctx_FPU, FPU_CONTEXT_SIZE); |
#endif |
ll_mem_init(base, s); |
#ifdef __MEM_DEBUG__ |
ll_mem_dump(); |
init_fpu(); |
/* ll_mem_init must be explicitelly called by program... */ |
#if 0 |
/* Get info about extended memory! We suppose that X has loaded */ |
/* there the application; if you switch to DOS memory, then you */ |
/* have to change the stuff in order it works; check X_... for */ |
/* details. */ |
X_meminfo(&b,&s,NULL,NULL); |
base = (BYTE *)b; |
#ifdef __MEM_DEBUG__ |
message("PM Free Mem Base : %lx\n",b); |
message("PM null addr (0L) : %lx\n",appl2linear((void *)0L)); |
message("PM Free Mem Base (Cnvrtd): %lp\n",base); |
#endif |
ll_mem_init(base,s); |
#ifdef __MEM_DEBUG__ |
ll_mem_dump(); |
#endif |
#endif |
#endif |
return p; |
return p; |
} |
void abort_tail(int code) |
{ |
message("ABORT %d !!!", code); |
l1_end(); |
sti(); |
l1_exit(1); |
message("ABORT %d !!!",code); |
l1_end(); |
sti(); |
l1_exit(1); |
} |
void ll_end(void) |
{ |
l1_end(); |
l1_end(); |
} |
/shark/tags/rel_0_5/oslib/kl/intevt.c |
---|
1,4 → 1,3 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
27,6 → 26,7 |
#include <ll/i386/error.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/pic.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/time.h> |
88,6 → 88,15 |
{ |
static int ai_called = 0; |
if ((n >= PIC1_BASE) && (n < PIC1_BASE + 8)) { |
n = n - PIC1_BASE; |
} else if ((n >= PIC2_BASE) && (n < PIC2_BASE + 8)) { |
n = n - PIC2_BASE + 8; |
} else { |
/* Wow... Here, we are in error... Return? */ |
return; |
} |
activeInt++; |
if (activeInt == 1 && evt_prol != NULL) { |
evt_prol(); |
109,3 → 118,5 |
} |
activeInt--; |
} |
/shark/tags/rel_0_5/oslib/kl/mem.c |
---|
32,16 → 32,16 |
FILE(Memory); |
#define MAX_PARTITION 50 /* Max available partition */ |
#define MAX_PARTITION 50 /* Max available partition */ |
static struct { |
BYTE used; |
BYTE used; |
#ifdef __WC16__ |
BYTE __huge *addr; |
BYTE __huge *addr; |
#else |
BYTE *addr; |
BYTE *addr; |
#endif |
DWORD size; |
DWORD size; |
} mem_table[MAX_PARTITION]; |
void ll_mem_init(void *base, DWORD size) |
50,8 → 50,7 |
mem_table[0].used = 1; |
mem_table[0].addr = base; |
mem_table[0].size = size; |
for (i = 1; i < MAX_PARTITION; i++) |
mem_table[i].used = 0; |
for (i = 1; i < MAX_PARTITION; i++) mem_table[i].used = 0; |
} |
void *ll_alloc(DWORD s) |
61,31 → 60,28 |
while (i < MAX_PARTITION && p == NULL) { |
if (mem_table[i].used && (mem_table[i].size >= s)) |
p = mem_table[i].addr; |
else |
i++; |
p = mem_table[i].addr; |
else i++; |
} |
if (p != NULL) { |
if (mem_table[i].size > s) { |
mem_table[i].size -= s; |
mem_table[i].addr += s; |
} else |
mem_table[i].used = FALSE; |
} |
else mem_table[i].used = FALSE; |
} |
return (p); |
return(p); |
} |
WORD ll_free(void *p, DWORD s) |
WORD ll_free(void *p,DWORD s) |
{ |
register int i = 1; |
unsigned i1 = 0, i2 = 0; |
while (i < MAX_PARTITION && ((i1 == 0) || (i2 == 0))) { |
while (i < MAX_PARTITION && ((i1 == 0) || (i2 == 0)) ) { |
if (mem_table[i].used) { |
if (mem_table[i].addr + mem_table[i].size == p) |
i1 = i; |
if (mem_table[i].addr == (BYTE *) (p) + s) |
i2 = i; |
if (mem_table[i].addr + mem_table[i].size == p) i1 = i; |
if (mem_table[i].addr == (BYTE *)(p) + s) i2 = i; |
} |
i++; |
} |
92,22 → 88,21 |
if (i1 != 0 && i2 != 0) { |
mem_table[i1].size += mem_table[i2].size + s; |
mem_table[i2].used = FALSE; |
} else if (i1 == 0 && i2 != 0) { |
} |
else if (i1 == 0 && i2 != 0) { |
mem_table[i2].addr = p; |
mem_table[i2].size += s; |
} else if (i1 != 0 && i2 == 0) |
mem_table[i1].size += s; |
} |
else if (i1 != 0 && i2 == 0) mem_table[i1].size += s; |
else { |
i = 0; |
while (i < MAX_PARTITION && (mem_table[i].used == TRUE)) |
i++; |
if (i == MAX_PARTITION) |
return (FALSE); |
while (i < MAX_PARTITION && (mem_table[i].used == TRUE)) i++; |
if (i == MAX_PARTITION) return(FALSE); |
mem_table[i].addr = p; |
mem_table[i].size = s; |
mem_table[i].used = TRUE; |
} |
return (TRUE); |
return(TRUE); |
} |
void ll_mem_dump(void) |
114,8 → 109,6 |
{ |
register int i; |
for (i = 0; i < MAX_PARTITION; i++) { |
if (mem_table[i].used) |
message("Entry : [%d] Addr : %p Size : %ld\n", i, |
mem_table[i].addr, mem_table[i].size); |
if (mem_table[i].used) message("Entry : [%d] Addr : %p Size : %ld\n",i,mem_table[i].addr,mem_table[i].size); |
} |
} |
/shark/tags/rel_0_5/oslib/kl/event.c |
---|
25,6 → 25,7 |
#include <ll/i386/mem.h> |
#include <ll/i386/error.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/pit.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-instr.h> |
60,7 → 61,10 |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
void event_setlasthandler(void *p) { last_handler = p; } |
void event_setlasthandler(void *p) |
{ |
last_handler = p; |
} |
void event_setprologue(void *p) |
{ |
190,15 → 194,14 |
BYTE mask; |
TIME t; |
IDT_place(0x40, ll_timer); |
IDT_place(0x40,ll_timer); |
if (l->mode != LL_PERIODIC) { |
message("One-shot timer selected...\n"); |
error("Trying one-shot!!!"); |
t = 0; |
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */ |
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */ |
} else { |
message("Periodic timer selected...\n"); |
t = l->tick; |
/* Translate the tick value in usec into a suitable time constant */ |
/* for 8254 timer chip; the chip is driven with a 1.19718 MHz */ |
221,8 → 224,8 |
} |
timermode = l->mode; |
if (ll_arch.x86.cpu > 4) { |
if (ll_arch.x86.cpu > 4) { |
/* Timer1: mode 0, time const 0... */ |
pit_init(1, TMR_MD0, 0); |
frc = 1; |
229,7 → 232,7 |
} else { |
frc = 2; |
pit_init(2, TMR_MD0, 0); |
outp(0x61, 3); |
outp(0x61, 3); |
} |
mask = ll_in(0x21); |
265,4 → 268,7 |
event_post = oneshot_event_post; |
event_delete = oneshot_event_delete; |
} |
/* Last but not least... */ |
irq_unmask(0); |
} |
/shark/tags/rel_0_5/oslib/kl/estub.c |
---|
24,7 → 24,7 |
#include <hw-data.h> |
#include "event.h" |
FILE(Event - Stub); |
FILE(Event-Stub); |
extern struct event *freeevents; |
extern struct event *firstevent; |
33,76 → 33,76 |
void called(void) |
{ |
printf("Called...\n"); |
printf("Called...\n"); |
} |
void event_printqueue(struct event *q) |
{ |
struct event *p; |
struct event *p; |
for (p = q; p; p = p->next) { |
printf("Entry %d: Time %d...\n", p->index, p->time); |
} |
for (p = q; p; p = p->next) { |
printf("Entry %d: Time %d...\n", p->index, p->time); |
} |
} |
main() |
{ |
int i, rem; |
event_init(); |
int i, rem; |
event_init(); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_post(10, called, NULL); |
printf("Inserted Event %d\n", i); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_post(100, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(10, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(5, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(50, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(1, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(110, called, NULL); |
printf("Inserted Event %d\n", i); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_post(100, called, NULL); |
printf("Inserted Event %d\n", i); |
printf("Now, Wakin' up...\n"); |
i = event_post(5, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(50, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(1, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(110, called, NULL); |
printf("Inserted Event %d\n", i); |
actTime = 1; |
wake_up(10); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
printf("Now, Wakin' up...\n"); |
actTime = 1; |
wake_up(10); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
actTime = 70; |
wake_up(10); |
i = event_post(45, called, NULL); |
i = event_post(80, called, NULL); |
i = event_post(20, called, NULL); |
rem = event_post(90, called, NULL); |
i = event_post(105, called, NULL); |
i = event_post(150, called, NULL); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_delete(rem); |
printf("EVT %d removed...OK=%d Pending events queue:\n", rem, i); |
event_printqueue(firstevent); |
i = event_delete(6); |
printf("EVT 6 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(2); |
printf("EVT 2 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(8); |
printf("EVT 8 removed...OK=%d Pending events queue:\n", i); |
event_printqueue(firstevent); |
actTime = 70; |
wake_up(10); |
i = event_post(45, called, NULL); |
i = event_post(80, called, NULL); |
i = event_post(20, called, NULL); |
rem = event_post(90, called, NULL); |
i = event_post(105, called, NULL); |
i = event_post(150, called, NULL); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_delete(rem); |
printf("EVT %d removed...OK=%d Pending events queue:\n", rem, i); |
event_printqueue(firstevent); |
i = event_delete(6); |
printf("EVT 6 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(2); |
printf("EVT 2 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(8); |
printf("EVT 8 removed...OK=%d Pending events queue:\n", i); |
event_printqueue(firstevent); |
} |
/shark/tags/rel_0_5/oslib/kl/cxsw-2.c |
---|
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); |
} |
/shark/tags/rel_0_5/oslib/kl/timeint.s |
---|
83,7 → 83,6 |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
#if 0 |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
110,7 → 109,6 |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
#endif |
cld |
movl SYMBOL_NAME(timermode), %eax |
cmpl $1, %eax |
133,13 → 131,12 |
call SYMBOL_NAME(ll_abort) |
Timer_OK: |
#if 0 |
/* Restore ESP */ |
popl %edx |
popl %ebx /* We must subtract it from ESP...*/ |
subl %ebx, %esp |
movw %dx, %ss |
#endif |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
/shark/tags/rel_0_5/oslib/kl/makefile |
---|
6,11 → 6,11 |
# |
ifndef BASE |
BASE = ../.. |
BASEDOS = ..\.. |
BASE = .. |
BASEDOS = .. |
endif |
include $(BASE)/config/config.mk |
include $(BASE)/config.mk |
C_OPT += -D__VIRCSW__ |
ASM_OPT += -D__VIRCSW__ |
17,9 → 17,7 |
#C_OPT += -DPROFILE |
#ASM_OPT += -DPROFILE |
KL_C_OBJ = stuff.o \ |
mem.o \ |
KL_C_OBJ = mem.o \ |
cxsw-2.o \ |
init.o \ |
time.o \ |
56,7 → 54,7 |
allclean : clean |
echo # Kernel Dependency file > deps |
$(RM) ..\lib\libkl.a |
$(RM) $(LIB_PATH)libkl.a |
deps :$(KL_C_OBJ:.o=.c) |
$(CC) $(C_OPT) $(KLINCL) -M $(KL_C_OBJ:.o=.c) > deps |
/shark/tags/rel_0_5/oslib/kl/aspace.c |
---|
24,61 → 24,61 |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/aspace.h> |
FILE(Address - Space); |
FILE(Address-Space); |
struct as AS_table[ASMax]; |
void as_init(void) |
{ |
int i; |
int i; |
for (i = 0; i < ASMax; i++) { |
AS_table[i].status = AS_FREE; |
} |
for (i = 0; i < ASMax; i++) { |
AS_table[i].status = AS_FREE; |
} |
} |
AS as_create(void) |
{ |
int i; |
int i; |
i = 0; |
while ((i < ASMax) && (AS_table[i].status & AS_BUSY)) { |
i++; |
} |
i = 0; |
while((i < ASMax) && (AS_table[i].status & AS_BUSY)) { |
i++; |
} |
if (i == ASMax) { |
return 0; |
} |
AS_table[i].status = AS_BUSY; /* Empty address space... */ |
AS_table[i].base = 0; |
AS_table[i].limit= 0; |
if (i == ASMax) { |
return 0; |
} |
AS_table[i].status = AS_BUSY; /* Empty address space... */ |
AS_table[i].base = 0; |
AS_table[i].limit = 0; |
GDT_place(ASindex2sel(i), AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(ASindex2sel(i) + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
GDT_place(ASindex2sel(i), AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(ASindex2sel(i) + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
/* We also need a code segment... */ |
return ASindex2sel(i); |
return ASindex2sel(i); |
} |
int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size) |
{ |
int i = ASsel2index(as); |
int i = ASsel2index(as); |
/* We have not paging... So l_addr must be 0 */ |
if (l_addr != 0) |
return -1; |
/* We have not paging... So l_addr must be 0 */ |
if (l_addr != 0) |
return -1; |
AS_table[i].base = ph_addr; |
AS_table[i].limit = size; |
AS_table[i].base = ph_addr; |
AS_table[i].limit= size; |
GDT_place(as, AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(as + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
GDT_place(as, AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(as + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
/* We also need a code segment... */ |
return 1; |
return 1; |
} |
/shark/tags/rel_0_5/oslib/lib/readme |
---|
0,0 → 1,0 |
This file is to force CVS to export the oslib/lib directory |
/shark/tags/rel_0_5/oslib/ll/i386/pic.h |
---|
0,0 → 1,64 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The Programmable Interrupt Controller management code */ |
#ifndef __PIC_H__ |
#define __PIC_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#define PIC1_BASE 0x040 /* Interrupt base for each PIC */ |
#define PIC2_BASE 0x070 |
void PIC_init(void); |
void PIC_end(void); |
void irq_mask(WORD irqno); |
void irq_unmask(WORD irqno); |
INLINE_OP void l1_exc_bind(int i, void (*f)(int n)) |
{ |
l1_int_bind(i, f); |
} |
INLINE_OP int l1_irq_bind(int irq, void *f) |
{ |
int i; |
if (irq < 8) { |
i = irq + PIC1_BASE; |
} else if (irq < 16) { |
i = irq + PIC2_BASE - 8; |
} else { |
return -1; |
} |
l1_int_bind(i, f); |
return 1; |
} |
END_DEF |
#endif /* __PIC_H__ */ |
/shark/tags/rel_0_5/oslib/ll/i386/mem.h |
---|
0,0 → 1,354 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Memory manipulation functions... |
Some of them are derived from Linux */ |
#ifndef __LL_I386_MEM_H__ |
#define __LL_I386_MEM_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* Various string manipulation functions */ |
/* Assembler low level routines */ |
/* File: Mem.S */ |
#ifndef NULL |
#define NULL 0L |
#endif |
#include <ll/sys/types.h> |
#include <ll/i386/hw-data.h> |
/* |
#ifndef __HW_DEP_H__ |
#include "hw_dep.h" |
#endif |
*/ |
extern inline void * __memcpy(void * to, const void * from, size_t n) |
{ |
int d0, d1, d2; |
__asm__ __volatile__( |
"cld\n\t" |
"rep ; movsl\n\t" |
"testb $2,%b4\n\t" |
"je 1f\n\t" |
"movsw\n" |
"1:\ttestb $1,%b4\n\t" |
"je 2f\n\t" |
"movsb\n" |
"2:" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) |
: "memory"); |
return (to); |
} |
/* |
* This looks horribly ugly, but the compiler can optimize it totally, |
* as the count is constant. |
*/ |
extern inline void * __constant_memcpy(void * to, const void * from, size_t n) |
{ |
switch (n) { |
case 0: |
return to; |
case 1: |
*(unsigned char *)to = *(const unsigned char *)from; |
return to; |
case 2: |
*(unsigned short *)to = *(const unsigned short *)from; |
return to; |
case 3: |
*(unsigned short *)to = *(const unsigned short *)from; |
*(2+(unsigned char *)to) = *(2+(const unsigned char *)from); |
return to; |
case 4: |
*(unsigned long *)to = *(const unsigned long *)from; |
return to; |
case 6: /* for Ethernet addresses */ |
*(unsigned long *)to = *(const unsigned long *)from; |
*(2+(unsigned short *)to) = *(2+(const unsigned short *)from); |
return to; |
case 8: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
return to; |
case 12: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
return to; |
case 16: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from); |
return to; |
case 20: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from); |
*(4+(unsigned long *)to) = *(4+(const unsigned long *)from); |
return to; |
} |
#define COMMON(x) \ |
__asm__ __volatile__( \ |
"cld\n\t" \ |
"rep ; movsl" \ |
x \ |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) \ |
: "0" (n/4),"1" ((long) to),"2" ((long) from) \ |
: "memory"); |
{ |
int d0, d1, d2; |
switch (n % 4) { |
case 0: COMMON(""); return to; |
case 1: COMMON("\n\tmovsb"); return to; |
case 2: COMMON("\n\tmovsw"); return to; |
default: COMMON("\n\tmovsw\n\tmovsb"); return to; |
} |
} |
#undef COMMON |
} |
#define __HAVE_ARCH_MEMCPY |
#define memcpy(t, f, n) \ |
(__builtin_constant_p(n) ? \ |
__constant_memcpy((t),(f),(n)) : \ |
__memcpy((t),(f),(n))) |
extern inline void *lmemcpy(LIN_ADDR t, LIN_ADDR f, size_t n) |
{ |
void *p1; |
void *p2; |
p1 = (void *)(t); |
p2 = (void *)(f); |
return memcpy(p1, p2, n); |
} |
#define __HAVE_ARCH_MEMMOVE |
extern inline void * memmove(void * dest,const void * src, size_t n) |
{ |
int d0, d1, d2; |
if (dest<src) |
__asm__ __volatile__( |
"cld\n\t" |
"rep\n\t" |
"movsb" |
: "=&c" (d0), "=&S" (d1), "=&D" (d2) |
:"0" (n),"1" (src),"2" (dest) |
: "memory"); |
else |
__asm__ __volatile__( |
"std\n\t" |
"rep\n\t" |
"movsb\n\t" |
"cld" |
: "=&c" (d0), "=&S" (d1), "=&D" (d2) |
:"0" (n), |
"1" (n-1+(const char *)src), |
"2" (n-1+(char *)dest) |
:"memory"); |
return dest; |
} |
#define memcmp __builtin_memcmp |
#define __HAVE_ARCH_MEMCHR |
extern inline void * memchr(const void * cs,int c,size_t count) |
{ |
int d0; |
register void * __res; |
if (!count) |
return NULL; |
__asm__ __volatile__( |
"cld\n\t" |
"repne\n\t" |
"scasb\n\t" |
"je 1f\n\t" |
"movl $1,%0\n" |
"1:\tdecl %0" |
:"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count)); |
return __res; |
} |
extern inline void * __memset_generic(void * s, char c,size_t count) |
{ |
int d0, d1; |
__asm__ __volatile__( |
"cld\n\t" |
"rep\n\t" |
"stosb" |
: "=&c" (d0), "=&D" (d1) |
:"a" (c),"1" (s),"0" (count) |
:"memory"); |
return s; |
} |
/* we might want to write optimized versions of these later */ |
#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count)) |
/* |
* memset(x,0,y) is a reasonably common thing to do, so we want to fill |
* things 32 bits at a time even when we don't know the size of the |
* area at compile-time.. |
*/ |
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count) |
{ |
int d0, d1; |
__asm__ __volatile__( |
"cld\n\t" |
"rep ; stosl\n\t" |
"testb $2,%b3\n\t" |
"je 1f\n\t" |
"stosw\n" |
"1:\ttestb $1,%b3\n\t" |
"je 2f\n\t" |
"stosb\n" |
"2:" |
: "=&c" (d0), "=&D" (d1) |
:"a" (c), "q" (count), "0" (count/4), "1" ((long) s) |
:"memory"); |
return (s); |
} |
/* |
* This looks horribly ugly, but the compiler can optimize it totally, |
* as we by now know that both pattern and count is constant.. |
*/ |
extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) |
{ |
switch (count) { |
case 0: |
return s; |
case 1: |
*(unsigned char *)s = pattern; |
return s; |
case 2: |
*(unsigned short *)s = pattern; |
return s; |
case 3: |
*(unsigned short *)s = pattern; |
*(2+(unsigned char *)s) = pattern; |
return s; |
case 4: |
*(unsigned long *)s = pattern; |
return s; |
} |
#define COMMON(x) \ |
__asm__ __volatile__("cld\n\t" \ |
"rep ; stosl" \ |
x \ |
: "=&c" (d0), "=&D" (d1) \ |
: "a" (pattern),"0" (count/4),"1" ((long) s) \ |
: "memory") |
{ |
int d0, d1; |
switch (count % 4) { |
case 0: COMMON(""); return s; |
case 1: COMMON("\n\tstosb"); return s; |
case 2: COMMON("\n\tstosw"); return s; |
default: COMMON("\n\tstosw\n\tstosb"); return s; |
} |
} |
#undef COMMON |
} |
#define __constant_c_x_memset(s, c, count) \ |
(__builtin_constant_p(count) ? \ |
__constant_c_and_count_memset((s),(c),(count)) : \ |
__constant_c_memset((s),(c),(count))) |
#define __memset(s, c, count) \ |
(__builtin_constant_p(count) ? \ |
__constant_count_memset((s),(c),(count)) : \ |
__memset_generic((s),(c),(count))) |
#define __HAVE_ARCH_MEMSET |
#define memset(s, c, count) \ |
(__builtin_constant_p(c) ? \ |
__constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \ |
__memset((s),(c),(count))) |
/* |
* find the first occurrence of byte 'c', or 1 past the area if none |
*/ |
#define __HAVE_ARCH_MEMSCAN |
extern inline void * memscan(void * addr, int c, size_t size) |
{ |
if (!size) |
return addr; |
__asm__("cld\n\t" |
"repnz; scasb\n\t" |
"jnz 1f\n\t" |
"dec %%edi\n\t" |
"1:\n\t" |
: "=D" (addr), "=c" (size) |
: "0" (addr), "1" (size), "a" (c)); |
return addr; |
} |
void fmemcpy(unsigned short ds,unsigned long dof,unsigned short ss,unsigned long sof,unsigned n); |
#if 0 |
extern inline void fmemcpy(unsigned short ds,unsigned long dof,unsigned short ss,unsigned long sof,unsigned n) |
{ |
/* Build the standard stack frame */ |
__asm__ __volatile__( |
/* Get parms into register */ |
movl 8(%ebp),%eax |
movw %ax,%es |
movl 12(%ebp),%edi |
movl 16(%ebp),%eax |
movw %ax,%ds |
movl 20(%ebp),%esi |
movl 24(%ebp),%ecx |
cld |
rep |
"movsb" |
"2:" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
:"0" (n), "q" (n),"1" ((long) to),"2" ((long) from) |
: "memory"); |
); |
popw %es |
popw %ds |
popl %edi |
popl %esi |
leave |
ret |
#endif |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/x-bios.h |
---|
0,0 → 1,83 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* For accessing BIOS calls returning in Real Mode, or using VM86 */ |
#ifndef __LL_I386_X_BIOS_H__ |
#define __LL_I386_X_BIOS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#define DOS_OFF(x) ((DWORD)(x) & 0x000F) |
#define DOS_SEG(x) (((DWORD)(x) & 0xFFFF0) >> 4) |
typedef union x_regs16 { |
struct { |
WORD ax __attribute__ ((packed)); |
WORD bx __attribute__ ((packed)); |
WORD cx __attribute__ ((packed)); |
WORD dx __attribute__ ((packed)); |
WORD si __attribute__ ((packed)); |
WORD di __attribute__ ((packed)); |
WORD cflag __attribute__ ((packed)); |
WORD _pad __attribute__ ((packed)); |
} x __attribute__ ((packed)); |
struct { |
BYTE al,ah __attribute__ ((packed)); |
BYTE bl,bh __attribute__ ((packed)); |
BYTE cl,ch __attribute__ ((packed)); |
BYTE dl,dh __attribute__ ((packed)); |
} h __attribute__ ((packed)); |
} X_REGS16; |
typedef struct x_sregs16 { |
WORD es __attribute__ ((packed)); |
WORD cs __attribute__ ((packed)); |
WORD ss __attribute__ ((packed)); |
WORD ds __attribute__ ((packed)); |
} X_SREGS16; |
typedef struct { |
/* The GDT linear address inheritable from X */ |
DWORD _GDT_base; |
/* These are used for BIOS calling */ |
X_REGS16 _ir; |
X_REGS16 _or; |
X_SREGS16 _sr; |
DWORD _irqno; |
/* This is the X version */ |
DWORD _ver; |
} X_CALLBIOS; |
X_CALLBIOS * x_bios_address(void); |
void X_meminfo(LIN_ADDR *b1,DWORD *s1,LIN_ADDR *b2,DWORD *s2); |
void X_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s); |
void vm86_init(); |
TSS *vm86_get_tss(void); |
int vm86_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/hw-instr.h |
---|
0,0 → 1,235 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... All the hardware-dependent instructions |
there is a 1->1 corrispondence with ASM instructions */ |
#ifndef __LL_I386_HW_INSTR_H__ |
#define __LL_I386_HW_INSTR_H__ |
#include <ll/i386/defs.h> |
#define INLINE_OP __inline__ static |
#include <ll/i386/hw-data.h> |
/* Low Level I/O funcs are in a separate file (by Luca) */ |
#include <ll/i386/hw-io.h> |
BEGIN_DEF |
INLINE_OP WORD get_CS(void) |
{WORD r; __asm__ __volatile__ ("movw %%cs,%0" : "=q" (r)); return(r);} |
INLINE_OP WORD get_DS(void) |
{WORD r; __asm__ __volatile__ ("movw %%ds,%0" : "=q" (r)); return(r);} |
INLINE_OP WORD get_FS(void) |
{WORD r; __asm__ __volatile__ ("movw %%fs,%0" : "=q" (r)); return(r);} |
/*INLINE_OP DWORD get_SP(void) |
{DWORD r; __asm__ __volatile__ ("movw %%esp,%0" : "=q" (r)); return(r);}*/ |
INLINE_OP DWORD get_SP(void) |
{ |
DWORD rv; |
__asm__ __volatile__ ("movl %%esp, %0" |
: "=a" (rv)); |
return(rv); |
} |
INLINE_OP DWORD get_BP(void) |
{ |
DWORD rv; |
__asm__ __volatile__ ("movl %%ebp, %0" |
: "=a" (rv)); |
return(rv); |
} |
INLINE_OP WORD get_TR(void) |
{WORD r; __asm__ __volatile__ ("strw %0" : "=q" (r)); return(r); } |
INLINE_OP void set_TR(WORD n) |
{__asm__ __volatile__("ltr %%ax": /* no output */ :"a" (n)); } |
INLINE_OP void set_LDTR(WORD addr) |
{ __asm__ __volatile__("lldt %%ax": /* no output */ :"a" (addr)); } |
/* Clear Task Switched Flag! Used for FPU preemtion */ |
INLINE_OP void clts(void) |
{__asm__ __volatile__ ("clts"); } |
/* Halt the processor! */ |
INLINE_OP void hlt(void) |
{__asm__ __volatile__ ("hlt"); } |
/* These functions are used to mask/unmask interrupts */ |
INLINE_OP void sti(void) {__asm__ __volatile__ ("sti"); } |
INLINE_OP void cli(void) {__asm__ __volatile__ ("cli"); } |
INLINE_OP SYS_FLAGS ll_fsave(void) |
{ |
SYS_FLAGS result; |
__asm__ __volatile__ ("pushfl"); |
__asm__ __volatile__ ("cli"); |
__asm__ __volatile__ ("popl %eax"); |
__asm__ __volatile__ ("movl %%eax,%0" |
: "=r" (result) |
: |
: "eax" ); |
return(result); |
} |
INLINE_OP void ll_frestore(SYS_FLAGS f) |
{ |
__asm__ __volatile__ ("mov %0,%%eax" |
: |
: "r" (f) |
: "eax"); |
__asm__ __volatile__ ("pushl %eax"); |
__asm__ __volatile__ ("popfl"); |
} |
/* |
FPU context switch management functions! |
FPU management exported at kernel layer to allow the use |
of floating point in kernel primitives; this turns to be |
useful for bandwidth reservation or guarantee! |
*/ |
/* FPU lazy state save handling.. */ |
INLINE_OP void save_fpu(TSS *t) |
{ |
__asm__ __volatile__("fnsave %0\n\tfwait":"=m" (t->ctx_FPU)); |
} |
INLINE_OP void restore_fpu(TSS *t) |
{ |
#if 1 |
__asm__ __volatile__("frstor %0": :"m" (t->ctx_FPU)); |
#else |
__asm__ __volatile__("frstor %0\n\tfwait": :"m" (t->ctx_FPU)); |
#endif |
/* __asm__ __volatile__("frstor _LL_FPU_savearea"); */ |
} |
INLINE_OP void smartsave_fpu(TSS *t) |
{ |
if (t->control & FPU_USED) save_fpu(t); |
} |
INLINE_OP void reset_fpu(void) { __asm__ __volatile__ ("fninit"); } |
#if 0 |
/* OK, now everything is clear... We test the NE bit to see if the |
* CPU is using the internal mechanism for reporting FPU errors or not... |
*/ |
INLINE_OP int check_fpu(void) |
{ |
int result; |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("movl %eax,%edi"); |
__asm__ __volatile__ ("andl $0x0FFFFFFEF,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("xchgl %edi,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
#if 0 |
__asm__ __volatile__ ("xorl %eax,%eax"); |
__asm__ __volatile__ ("movb %bl,%al"); |
#else |
__asm__ __volatile__ ("movl %edi,%eax"); |
__asm__ __volatile__ ("andl $0x10,%eax"); |
#endif |
__asm__ __volatile__ ("shrb $4,%al"); |
__asm__ __volatile__ ("movl %%eax,%0" |
: "=r" (result) |
: |
: "eax" ); |
return(result); |
} |
#endif |
INLINE_OP void init_fpu(void) |
{ |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("orl $34,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
__asm__ __volatile__ ("fninit"); |
} |
extern BYTE LL_FPU_savearea[]; |
extern __inline__ void LL_FPU_save(void) |
{ |
#ifdef __LINUX__ |
__asm__ __volatile__ ("fsave LL_FPU_savearea"); |
#else |
__asm__ __volatile__ ("fsave _LL_FPU_savearea"); |
#endif |
} |
extern __inline__ void LL_FPU_restore(void) |
{ |
#ifdef __LINUX__ |
__asm__ __volatile__ ("frstor LL_FPU_savearea"); |
#else |
__asm__ __volatile__ ("frstor _LL_FPU_savearea"); |
#endif |
} |
INLINE_OP void lmempokeb(LIN_ADDR a, BYTE v) |
{ |
*((BYTE *)a) = v; |
} |
INLINE_OP void lmempokew(LIN_ADDR a, WORD v) |
{ |
*((WORD *)a) = v; |
} |
INLINE_OP void lmempoked(LIN_ADDR a, DWORD v) |
{ |
*((DWORD *)a) = v; |
} |
INLINE_OP BYTE lmempeekb(LIN_ADDR a) |
{ |
return *((BYTE *)a); |
} |
INLINE_OP WORD lmempeekw(LIN_ADDR a) |
{ |
return *((WORD *)a); |
} |
INLINE_OP DWORD lmempeekd(LIN_ADDR a) |
{ |
return *((DWORD *)a); |
} |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/stdio.h |
---|
0,0 → 1,40 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_I386_STDIO_H__ |
#define __LL_I386_STDIO_H__ |
#include <ll/i386/defs.h> |
#include <ll/stdarg.h> |
BEGIN_DEF |
int vsprintf(char *buf,char *fmt,va_list parms); |
int vksprintf(char *buf,char *fmt,va_list parms); |
int sprintf(char *buf,char *fmt,...) __attribute__((__format__(printf,2,3))); |
int ksprintf(char *buf,char *fmt,...) __attribute__((__format__(printf,2,3))); |
int vsscanf(char *buf,char *fmt,va_list parms); |
int sscanf(char *buf,char *fmt,...) __attribute__((__format__(scanf,2,3))); |
int ll_printf(char *fmt,...); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/pit.h |
---|
0,0 → 1,188 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The Programmable Interrupt Timer management code */ |
#ifndef __PIT_H__ |
#define __PIT_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#define MIN_INT 100 |
#define TMR_CTRL 0x43 /* PIT Control port*/ |
#define TMR_CNT0 0x40 /* Counter 0 port */ |
#define TMR_CNT1 0x41 /* Counter 1 port */ |
#define TMR_CNT2 0x42 /* Counter 2 port */ |
#define TMR_SC0 0x00 /* Select Channel 0 */ |
#define TMR_SC1 0x40 /* Select Channel 1 */ |
#define TMR_SC2 0x80 /* Select Channel 2 */ |
#define TMR_LSB 0x10 /* R/W Least Significative Byte */ |
#define TMR_MSB 0x20 /* R/W Most Significative Byte */ |
#define TMR_BOTH 0x30 /* R/W Both Bytes */ |
#define TMR_LATCH 0x00 /* Latch Command */ |
#define TMR_READ 0xF0 /* Read Command */ |
#define TMR_CNT 0x20 /* Read Counter */ |
#define TMR_STAT 0x10 /* Read Status */ |
#define TMR_CH2 0x08 /* Read Channel 2 Counter/Status */ |
#define TMR_CH1 0x04 /* Read Channel 1 Counter/Status */ |
#define TMR_CH0 0x02 /* Read Channel 0 Counter/Status */ |
#define TMR_MD0 0x00 /* Mode 0 */ |
#define TMR_MD1 0x02 /* Mode 1 */ |
#define TMR_MD2 0x04 /* Mode 2 */ |
#define TMR_MD3 0x06 /* Mode 3 */ |
#define TMR_MD4 0x08 /* Mode 4 */ |
#define TMR_MD5 0x0A /* Mode 5 */ |
INLINE_OP int pit_init(BYTE channel, BYTE mode, WORD tconst) |
{ |
BYTE v, ch; |
WORD cnt; |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
ch = TMR_SC0; |
break; |
case 1: |
cnt = TMR_CNT1; |
ch = TMR_SC1; |
break; |
case 2: |
cnt = TMR_CNT2; |
ch = TMR_SC2; |
break; |
default: |
return -1; |
} |
/* VM_out(TMR_CTRL, 0x34); */ |
outp(TMR_CTRL, ch | TMR_BOTH | mode); |
/* Load Time_const with 2 access to CTR */ |
v = (BYTE)(tconst); |
outp(cnt, v); |
v = (BYTE)(tconst >> 8); |
outp(cnt, v); |
return 1; |
} |
INLINE_OP int pit_setconstant(BYTE channel, DWORD c) |
{ |
BYTE v; |
WORD cnt; |
WORD tconst; |
if (c > 0xF000) { |
tconst = 0xF000; |
} else { |
if (c < MIN_INT) { |
tconst = MIN_INT; |
} else { |
tconst = c; |
} |
} |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
break; |
case 1: |
cnt = TMR_CNT1; |
break; |
case 2: |
cnt = TMR_CNT2; |
break; |
default: |
return -1; |
} |
/* Load Time_const with 2 access to CTR */ |
v = (BYTE)(tconst); |
outp(cnt, v); |
v = (BYTE)(tconst >> 8); |
outp(cnt, v); |
return 1; |
} |
INLINE_OP WORD pit_read(BYTE channel) |
{ |
WORD result; |
WORD cnt; |
BYTE ch; |
BYTE str_msb, str_lsb; |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
ch = TMR_CH0; |
break; |
case 1: |
cnt = TMR_CNT1; |
ch = TMR_CH1; |
break; |
case 2: |
cnt = TMR_CNT2; |
ch = TMR_CH2; |
break; |
default: |
return 0; |
} |
/* Read Back Command on counter 0 */ |
#if 0 |
outp(TMR_CTRL, ch | TMR_LATCH | TMR_BOTH); |
#else |
outp(TMR_CTRL, TMR_READ - TMR_CNT + ch /*0xD2*/); |
#endif |
/* Read the latched value from STR */ |
str_lsb = inp(cnt); |
str_msb = inp(cnt); |
/* Combine the byte values to obtain a word */ |
result = ((WORD)str_msb << 8) | (WORD)str_lsb; |
return result; |
} |
struct pitspec { |
long units; |
long gigas; |
}; |
#define ADDPITSPEC(n, t) ((t)->units += (n), \ |
(t)->gigas += (t)->units / 1432809, \ |
(t)->units %= 1432809) |
#define NULLPITSPEC(t) (t)->units = 0, (t)->gigas = 0 |
#define PITSPEC2USEC(t) ((((t)->units * 1000) / 1197) \ |
+ (((t)->gigas * 1000) * 1197)) |
#define CPPITSPEC(a, b) (b)->units = (a)->units, (b)->gigas = (a)->gigas |
END_DEF |
#endif /* __PIT_H__ */ |
/shark/tags/rel_0_5/oslib/ll/i386/x-dosmem.h |
---|
0,0 → 1,37 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Management functions for memory in the first MegaByte */ |
#ifndef __LL_I386_X_DOSMEM_H__ |
#define __LL_I386_X_DOSMEM_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
void DOS_dump_mem(void); |
void DOS_mem_init(void); |
LIN_ADDR DOS_alloc(DWORD s); |
int DOS_free(LIN_ADDR p,DWORD s); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/error.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The LL error dump function */ |
#ifndef __LL_I386_ERROR_H__ |
#define __LL_I386_ERROR_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/cons.h> |
int message(char *fmt,...) __attribute__((format(printf,1,2))); |
#define error(msg) \ |
message("Error! File:%s Line:%d %s", __FILE__, __LINE__, msg) |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/hw-arch.h |
---|
0,0 → 1,102 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Code & data fot CPU identification */ |
#ifndef __LL_I386_HW_ARCH_H__ |
#define __LL_I386_HW_ARCH_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* The following structure is filled up by the ll_init() and can be */ |
/* read by the kernel modules to know about the architecture */ |
/* Each time a new hardware CPU is added to the ll layer, you have to */ |
/* define a new XXX_ARCH structure, whose first field is a char *arch */ |
/* This is used to identify the architecture, then subsequent field */ |
/* can be decoded!! */ |
/* WARNING: I tried to use bitfields, but this caused am INTO error?!? */ |
/* only when using GNU-C!! So i preferred to use standard DWORD flags */ |
/* Capabilities */ |
#define LL_X86_HAS_INVLPG 0x01 |
#define LL_X86_HAS_CPUID 0x02 |
#define LL_X86_HAS_FPU 0x04 |
#define LL_X86_INTERNAL_FPU 0x08 |
#define LL_X86_HAS_TSTAMP 0x10 |
/* Bugs */ |
#define LL_X86_FDIV_BUG 0x01 |
#define LL_X86_F00F_BUG 0x02 |
typedef struct { |
char *arch; |
int cpu; /* 0,1,2,3,4,5,6 -> |
8086/8,80186,80286,80386,80486,P5,PII o Overdrive */ |
int fpu; /* 0,1,2,3 -> None,8087,80287,80387 */ |
char *model; /* Dx, Dx2, ... */ |
char vendor[12]; /* Intel, Cyrix, AMD or unknown */ |
DWORD capabilities; |
DWORD bugs; |
/* BUGs!! Warning: Currently, no workaround is available! |
*/ |
int f00f_bug; |
int fdiv_bug; |
} X86_ARCH; |
struct ll_cpuInfo { |
DWORD X86_cpu; |
DWORD X86_cpuIdFlag; |
DWORD X86_vendor_1; |
DWORD X86_vendor_2; |
DWORD X86_vendor_3; |
DWORD X86_signature; |
DWORD X86_IntelFeature_1; |
DWORD X86_IntelFeature_2; |
DWORD X86_StandardFeature; |
}; |
typedef struct { |
char *arch; |
/* Tonino, fill up this stuff! */ |
} AXP_ARCH; |
typedef union { |
char *arch; |
X86_ARCH x86; |
AXP_ARCH axp; |
} LL_ARCH; |
void X86_get_CPU(struct ll_cpuInfo *p); |
void X86_get_FPU(void); |
int X86_is386(void); |
int X86_isCyrix(void); |
int X86_hasCPUID(void); |
extern LL_ARCH ll_arch; |
END_DEF |
#endif /* __LL_I386_HW_ARCH_H__ */ |
/shark/tags/rel_0_5/oslib/ll/i386/int.h |
---|
0,0 → 1,32 |
#ifndef __LL_I386_INT__ |
#define __LL_I386_INT__ |
#include <ll/i386/linkage.h> |
#define INT(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler |
#define INT_1(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler_master_pic |
#define INT_2(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler_slave_pic |
#define EXC(n) \ |
.globl SYMBOL_NAME(exc##n) ; \ |
SYMBOL_NAME_LABEL(exc##n) ; \ |
movl $##n, %eax ; \ |
jmp ll_handler2 |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/x-dos.h |
---|
0,0 → 1,49 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Accessing a DOS filesystem from OSLib/X */ |
#ifndef __LL_I386_X_DOS_H__ |
#define __LL_I386_X_DOS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/x-bios.h> |
typedef struct { |
LIN_ADDR buf; |
LIN_ADDR n1; |
char n2[80]; |
BYTE mode,index; |
DWORD handle,offset; |
} DOS_FILE; |
int DOS_init(void); |
DOS_FILE *DOS_fopen(char *name, char *mode); |
void DOS_fclose(DOS_FILE *f); |
DWORD DOS_fread(void *buf,DWORD size,DWORD num,DOS_FILE *f); |
DWORD DOS_fwrite(void *buf,DWORD size,DWORD num,DOS_FILE *f); |
unsigned DOS_error(void); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/farptr.h |
---|
0,0 → 1,246 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (c) 1995 DJ Delorie. Permission granted to use for any |
purpose, provided this copyright remains attached and unmodified. |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» |
º Far Pointer Simulation Functions º |
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ |
This file attempts to make up for the lack of a "far" keyword in GCC. |
Although it doesn't provide access to far call APIs (like Windows), it |
does allow you to do far pointer data access without the overhead of |
movedata() or dosmemget/dosmemput(). |
You should *always* include this file when using these functions and |
compile with optimization enabled. They don't exist as normal functions |
in any library, and they compile down to only a few opcodes when used |
this way. They are almost as fast as native pointer operations, and |
about as fast as far pointers can get. |
If you don't use optimization, this file becomes prototypes for |
farptr.c, which generates real functions for these when not optimizing. |
When optimizing, farptr.c compiles to nothing. |
There are two types of functions here - standalone and invariant. The |
standalone functions take a selector and offset. These are used when |
you need only a few accesses, time isn't critical, or you don't know |
what's in the %fs register. The invariant ones don't take a selector, |
they only take an offset. These are used inside loops and in |
time-critical accesses where the selector doesn't change. To specify |
the selector, use the farsetsel() function. That selector is used for |
all farns*() functions until changed. You can use _fargetsel() if you |
want to temporary change the selector with _farsetsel() and restore |
it afterwards. |
The farpoke* and farpeek* take selectors. |
The farnspoke* and farnspeek* don't (note the `ns' for `no selector'). |
Warning: These routines all use the %fs register for their accesses. |
GCC normally uses only %ds and %es, and libc functions (movedata, |
dosmemget, dosmemput) use %gs. Still, you should be careful about |
assumptions concerning whether or not the value you put in %fs will be |
preserved across calls to other functions. If you guess wrong, your |
program will crash. Better safe than sorry. |
*/ |
#ifndef __dj_include_sys_farptr_h_ |
#define __dj_include_sys_farptr_h_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __dj_ENFORCE_ANSI_FREESTANDING |
#ifndef __STRICT_ANSI__ |
#ifndef _POSIX_SOURCE |
void _farpokeb(unsigned short, unsigned long, unsigned char); |
void _farpokew(unsigned short, unsigned long, unsigned short); |
void _farpokel(unsigned short, unsigned long, unsigned long); |
unsigned char _farpeekb(unsigned short, unsigned long); |
unsigned short _farpeekw(unsigned short, unsigned long); |
unsigned long _farpeekl(unsigned short, unsigned long); |
void _farsetsel(unsigned short); |
unsigned short _fargetsel(void); |
void _farnspokeb(unsigned long, unsigned char); |
void _farnspokew(unsigned long, unsigned short); |
void _farnspokel(unsigned long, unsigned long); |
unsigned char _farnspeekb(unsigned long); |
unsigned short _farnspeekw(unsigned long); |
unsigned long _farnspeekl(unsigned long); |
extern __inline__ void |
_farpokeb(unsigned short selector, |
unsigned long offset, |
unsigned char value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs\n" |
" .byte 0x64 \n" |
" movb %b1,%%fs:(%k2)" |
: |
: "rm" (selector), "qi" (value), "r" (offset)); |
} |
extern __inline__ void |
_farpokew(unsigned short selector, |
unsigned long offset, |
unsigned short value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs \n" |
" .byte 0x64 \n" |
" movw %w1,(%k2)" |
: |
: "rm" (selector), "ri" (value), "r" (offset)); |
} |
extern __inline__ void |
_farpokel(unsigned short selector, |
unsigned long offset, |
unsigned long value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs \n" |
" .byte 0x64 \n" |
" movl %k1,(%k2)" |
: |
: "rm" (selector), "ri" (value), "r" (offset)); |
} |
extern __inline__ unsigned char |
_farpeekb(unsigned short selector, |
unsigned long offset) |
{ |
unsigned char result; |
__asm__ __volatile__ ("movw %w1,%%fs \n" |
" .byte 0x64 \n" |
" movb (%k2),%b0" |
: "=q" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ unsigned short |
_farpeekw(unsigned short selector, |
unsigned long offset) |
{ |
unsigned short result; |
__asm__ __volatile__ ("movw %w1, %%fs \n" |
" .byte 0x64 \n" |
" movw (%k2),%w0 \n" |
: "=r" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ unsigned long |
_farpeekl(unsigned short selector, |
unsigned long offset) |
{ |
unsigned long result; |
__asm__ __volatile__ ("movw %w1,%%fs\n" |
" .byte 0x64\n" |
" movl (%k2),%k0" |
: "=r" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ void |
_farsetsel(unsigned short selector) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs" |
: |
: "rm" (selector)); |
} |
extern __inline__ unsigned short |
_fargetsel(void) |
{ |
unsigned short selector; |
__asm__ __volatile__ ("movw %%fs,%w0 \n" |
: "=r" (selector) |
: ); |
return selector; |
} |
extern __inline__ void |
_farnspokeb(unsigned long offset, |
unsigned char value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movb %b0,(%k1)" |
: |
: "qi" (value), "r" (offset)); |
} |
extern __inline__ void |
_farnspokew(unsigned long offset, |
unsigned short value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movw %w0,(%k1)" |
: |
: "ri" (value), "r" (offset)); |
} |
extern __inline__ void |
_farnspokel(unsigned long offset, |
unsigned long value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movl %k0,(%k1)" |
: |
: "ri" (value), "r" (offset)); |
} |
extern __inline__ unsigned char |
_farnspeekb(unsigned long offset) |
{ |
unsigned char result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movb (%k1),%b0" |
: "=q" (result) |
: "r" (offset)); |
return result; |
} |
extern __inline__ unsigned short |
_farnspeekw(unsigned long offset) |
{ |
unsigned short result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movw (%k1),%w0" |
: "=r" (result) |
: "r" (offset)); |
return result; |
} |
extern __inline__ unsigned long |
_farnspeekl(unsigned long offset) |
{ |
unsigned long result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movl (%k1),%k0" |
: "=r" (result) |
: "r" (offset)); |
return result; |
} |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__STRICT_ANSI__ */ |
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
#ifndef __dj_ENFORCE_FUNCTION_CALLS |
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* !__dj_include_sys_farptr_h_ */ |
/shark/tags/rel_0_5/oslib/ll/i386/limits.h |
---|
0,0 → 1,43 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Some POSIX compliance stuff */ |
#ifndef __LL_I386_LIMITS_H__ |
#define __LL_I386_LIMITS_H__ |
/* Number limits */ |
#define CHAR_BIT 8 |
#define CHAR_MAX 255 |
#define CHAR_MIN 0 |
#define SCHAR_MAX 127 |
#define SCHAR_MIN -128 |
#define INT_MAX 2147483647 |
#define INT_MIN (-INT_MAX - 1) |
#define UINT_MAX 4294967295U |
#define LONG_MAX 2147483647L |
#define LONG_MIN (-LONG_MAX - 1) |
#define ULONG_MAX 4294967295UL |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/cons.h |
---|
0,0 → 1,97 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions */ |
#ifndef __LL_I386_CONS_H__ |
#define __LL_I386_CONS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* for reference only */ |
extern int cons_columns; /* number of screen columns */ |
extern int cons_rows; /* number of screen rows */ |
/* X-dependent Console Output functions */ |
/* Rememeber that console functions are NOT REENTRANT */ |
/* The console must be considered a preemtable resource */ |
/* File : Cons.C */ |
void set_visual_page(int page); |
void set_active_page(int page); |
int get_visual_page(void); |
int get_active_page(void); |
void place(int x,int y); |
void getcursorxy(int *x, int *y); |
int get_attr(void); |
void cursor(int start,int end); |
void _clear(char c,char attr,int x1,int y1,int x2,int y2); |
void clear(void); |
void _scroll(char attr,int x1,int y1,int x2,int y2); |
void scroll(void); |
void bios_save(void); |
void bios_restore(void); |
void cputc(char c); |
void cputs(char *s); |
int cprintf(char *fmt,...) __attribute__((format(printf,1,2))); |
/* These functions allow direct access to video RAM */ |
/* Hence you can use it without the explicit use of */ |
/* a resource manager */ |
/* File : Cons.C */ |
void putc_xy(int x,int y,char attr,char c); |
char getc_xy(int x,int y,char *attr,char *c); |
void puts_xy(int x,int y,char attr,char *s); |
int printf_xy(int x,int y,char attr, char *fmt,...) __attribute__((format(printf,4,5))); |
/* These are simple useful macro! */ |
#define HOME() place(0,0); |
#define CRSR_BLOB() cursor(0,15); |
#define CRSR_OFF() cursor(16,16); |
#define CRSR_STD() cursor(14,15); |
#define NL() cputc('\n'); |
/* Text mode color definitions */ |
#define BLACK 0 |
#define BLUE 1 |
#define GREEN 2 |
#define CYAN 3 |
#define RED 4 |
#define MAGENTA 5 |
#define BROWN 6 |
#define LIGHTGRAY 7 |
#define DARKGRAY 8 |
#define LIGHTBLUE 9 |
#define LIGHTGREEN 10 |
#define LIGHTCYAN 11 |
#define LIGHTRED 12 |
#define LIGHTMAGENTA 13 |
#define YELLOW 14 |
#define WHITE 15 |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/tss-ctx.h |
---|
0,0 → 1,34 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Macros for CONTEXT <-> TSS Translation */ |
#ifndef __LL_I386_TSS_CTX_H__ |
#define __LL_I386_TSS_CTX_H__ |
#define TSSMax 155 |
#define TSSMain (TSSMax-1) |
#define MAIN_SEL 0xF8 |
#define TSSBase 0x100 |
#define TSSsel2index(sel) ((sel-TSSBase)/8) |
#define TSSindex2sel(i) (TSSBase + i*8) |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/float.h |
---|
0,0 → 1,59 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The POSIX float.h header */ |
#ifndef __LL_I386_FLOAT_H |
#define __LL_I386_FLOAT_H__ |
#define DBL_DIG 15 |
#define DBL_EPSILON 2.22044604925031300e-016 |
#define DBL_MANT_DIG 53 |
#define DBL_MAX 1.79769313486231500e+308 |
#define DBL_MAX_10_EXP 308 |
#define DBL_MAX_EXP 1024 |
#define DBL_MIN 2.22507385850720200e-308 |
#define DBL_MIN_10_EXP (-307) |
#define DBL_MIN_EXP (-1021) |
#define FLT_DIG 6 |
#define FLT_EPSILON 1.192092896e-7f |
#define FLT_MANT_DIG 24 |
#define FLT_MAX 3.402823466e+38f |
#define FLT_MAX_10_EXP 38 |
#define FLT_MAX_EXP 128 |
#define FLT_MIN 1.175494351e-38f |
#define FLT_MIN_10_EXP (-37) |
#define FLT_MIN_EXP (-125) |
#define FLT_RADIX 2 |
#define FLT_ROUNDS 1 |
#define LDBL_DIG DBL_DIG |
#define LDBL_EPSILON DBL_EPSILON |
#define LDBL_MANT_DIG DBL_MANT_DIG |
#define LDBL_MAX DBL_MAX |
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP |
#define LDBL_MAX_EXP DBL_MAX_EXP |
#define LDBL_MIN DBL_MIN |
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP |
#define LDBL_MIN_EXP DBL_MIN_EXP |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/string.h |
---|
0,0 → 1,50 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* String manipulation functions */ |
#ifndef __LL_I386_STRING_H__ |
#define __LL_I386_STRING_H__ |
#include <ll/i386/mem.h> |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* Various string manipulation functions */ |
/* File: String.C */ |
char *strcpy(char *dst,const char *src); |
char *strncpy(char *dst,const char *src,int n); |
int strcmp(const char *s1,const char *s2); |
int strncmp(const char *s1,const char *s2,int n); |
int strlen(const char *s); |
char *strscn(char *s,char *pattern); |
char *strchr(char *s,int c); |
char *strupr(char *s); |
char *strlwr(char *s); |
char *strcat(char *dst,char *src); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/hw-func.h |
---|
0,0 → 1,82 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... |
All the hardware-dependent functions |
IDT/GDT management |
context switch |
IRQ/Exc handling... */ |
#ifndef __LL_I386_HW_FUNC_H__ |
#define __LL_I386_HW_FUNC_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-instr.h> |
/* Low level exit functions! It will halt, reboot or |
* give back the control to X, depending on how YAMME started... |
*/ |
void __exit(int code) __attribute__((noreturn)); |
void halt(void); |
/* Functions to reboot the machine */ |
void cold_reboot(void); |
void warm_reboot(void); |
void reboot(int mode); |
/* System tables management functions */ |
void IDT_place(BYTE num,void (*handler)(void)); |
void GDT_place(WORD sel,DWORD base,DWORD lim,BYTE acc,BYTE gran); |
DWORD GDT_read(WORD sel,DWORD *lim,BYTE *acc,BYTE *gran); |
LIN_ADDR addr2linear(unsigned short sel,unsigned long offset); |
/* These 3 function realize the context switching. The context_save has */ |
/* to be the first call of a kernel primitive, and the context_change has */ |
/* to be the last call. */ |
/* The context_save disables the interrupt (a kernel primitive must be */ |
/* atomic) and return the context of the running task. */ |
/* The context_change take the context of the new task (or of the */ |
/* same task), switch to the new context and return restoring the flag */ |
/* register. */ |
/* The context_load is used when the task is going to be killed; then its */ |
/* context does not need to be saved; we only need to load the context of */ |
/* the new task; the effective implementation of this functions can vary */ |
/* greatly throughout different implementations as some of them are */ |
/* mapped to empty functions or mapped one onto another */ |
CONTEXT ll_context_save(void); |
void ll_context_change(CONTEXT c); |
void ll_context_load(CONTEXT c); |
CONTEXT ll_context_from(void); |
void ll_context_to(CONTEXT c); |
void *l1_init(void); |
void IDT_init(void); |
void l1_end(void); |
void l1_int_bind(int i, void *f); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/mb-hdr.h |
---|
0,0 → 1,80 |
/* |
* GRUB -- GRand Unified Bootloader |
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
/* |
* MultiBoot Header description |
* |
* |
* struct multiboot_header |
* { |
* Must be MULTIBOOT_MAGIC - see below. |
* unsigned magic; |
* |
* Feature flags - see below. |
* unsigned flags; |
* |
* |
* Checksum |
* |
* The above fields plus this one must equal 0 mod 2^32. |
* |
* unsigned checksum; |
* |
* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. |
* unsigned header_addr; |
* unsigned load_addr; |
* unsigned load_end_addr; |
* unsigned bss_end_addr; |
* unsigned entry_addr; |
* }; |
*/ |
/* |
* The entire multiboot_header must be contained |
* within the first MULTIBOOT_SEARCH bytes of the kernel image. |
* #define MULTIBOOT_SEARCH 8192 |
* #define MULTIBOOT_FOUND(addr, len) \ |
* (!((addr) & 0x3) && ((len) >= 12) && (*((int *)(addr)) == MULTIBOOT_MAGIC) \ |
* && !(*((unsigned *)(addr)) + *((unsigned *)(addr+4)) \ |
* + *((unsigned *)(addr+8))) \ |
* && (!(MULTIBOOT_AOUT_KLUDGE & *((int *)(addr+4))) || ((len) >= 32))) |
*/ |
/* Magic value identifying the multiboot_header. */ |
#define MULTIBOOT_MAGIC 0x1BADB002 |
/* |
* Features flags for 'flags'. |
* If a boot loader sees a flag in MULTIBOOT_MUSTKNOW set |
* and it doesn't understand it, it must fail. |
*/ |
#define MULTIBOOT_MUSTKNOW 0x0000FFFF |
/* currently unsupported flags... this is a kind of version number. */ |
#define MULTIBOOT_UNSUPPORTED 0x0000FFFC |
/* Align all boot modules on i386 page (4KB) boundaries. */ |
#define MULTIBOOT_PAGE_ALIGN 0x00000001 |
/* Must pass memory information to OS. */ |
#define MULTIBOOT_MEMORY_INFO 0x00000002 |
/* This flag indicates the use of the other fields in the header. */ |
#define MULTIBOOT_AOUT_KLUDGE 0x00010000 |
/shark/tags/rel_0_5/oslib/ll/i386/linkage.h |
---|
0,0 → 1,44 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* This file derives from linux/linkage.h. It allows a transparent naming |
* between COFF and ELF executable models. We use ELF when we cross-compile |
* OSLib from Linux with Linux GCC |
*/ |
#ifdef __LINUX__ |
#define SYMBOL_NAME_STR(X) #X |
#define SYMBOL_NAME(X) X |
#ifdef __STDC__ |
#define SYMBOL_NAME_LABEL(X) X##: |
#else |
#define SYMBOL_NAME_LABEL(X) X/**/: |
#endif |
#else |
#define SYMBOL_NAME_STR(X) "_"#X |
#ifdef __STDC__ |
#define SYMBOL_NAME(X) _##X |
#define SYMBOL_NAME_LABEL(X) _##X##: |
#else |
#define SYMBOL_NAME(X) _/**/X |
#define SYMBOL_NAME_LABEL(X) _/**/X/**/: |
#endif |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/stdlib.h |
---|
0,0 → 1,93 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Standard library for OSLib applications */ |
#ifndef __LL_I386_STDLIB_H__ |
#define __LL_I386_STDLIB_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#define EXIT_FAILURE 1 /* Failing exit status. */ |
#define EXIT_SUCCESS 0 /* Successful exit status. */ |
#ifndef NULL |
#define NULL 0L |
#endif |
#define RAND_MAX 2147483647 |
/* String conversion functions */ |
/* File: StrConv.C */ |
long strtoi(char *s,int base,char **scan_end); |
unsigned long strtou(char *s,int base,char **scan_end); |
double strtod(char *s,char **scan_end); |
long strtol(const char *nptr, char **endptr, int base); |
unsigned long strtoul(const char *nptr, char **endptr, int base); |
unsigned ecvt(double v,char *buffer,int width,int prec,int flag); |
unsigned fcvt(double v,char *buffer,int width,int prec,int flag); |
unsigned gcvt(double v,char *buffer,int width,int prec,int flag); |
unsigned dcvt(long v,char *buffer,int base,int width,int flag); |
unsigned ucvt(unsigned long v,char *buffer,int base,int width,int flag); |
/* StdLib Macro */ |
#define atof(s) strtod(s, NULL) |
#define atoi(s) strtoi(s, 10, NULL) |
#define atou(s) strtou(s, 10, NULL) |
#define atol(s) strtol(s, 10, NULL) |
/* Generic utility functions */ |
/* File StdLib.C */ |
void srand(long int seed); |
long int rand(void); |
unsigned abs(int x); |
/* The stdlib exit functions */ |
void l1_exit(int code); |
/* Stdlib Macro */ |
#ifndef __WC16__ |
#define labs(x) abs(x) |
#endif |
#if !defined(__max) |
#define __max(a,b) (((a) > (b)) ? (a) : (b)) |
#endif |
#if !defined(max) && !defined(__cplusplus) |
#define max(a,b) (((a) > (b)) ? (a) : (b)) |
#endif |
#if !defined(__min) |
#define __min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
#if !defined(min) && !defined(__cplusplus) |
#define min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/defs.h |
---|
0,0 → 1,46 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Definitions to be used in all .h and .c files */ |
#ifndef __LL_I386_DEFS_H__ |
#define __LL_I386_DEFS_H__ |
#ifdef __cplusplus |
#define BEGIN_DEF extern "C" { |
#else |
#define BEGIN_DEF |
#endif |
#ifdef __cplusplus |
#define END_DEF } |
#else |
#define END_DEF |
#endif |
#ifdef PROFILE |
#define FILE(a) static char FileName[] = "Profile:"#a |
#define ASMFILE(a) FileName: .string "Profile:"#a |
#else |
#define FILE(a) |
#define ASMFILE(a) |
#endif |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/sel.h |
---|
0,0 → 1,43 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Hardware selectors used by OSLib */ |
#ifndef __LL_I386_SEL_H__ |
#define __LL_I386_SEL_H__ |
#define NULL_SEL 0x00 |
#define X_DATA16_SEL 0x08 |
#define X_CODE16_SEL 0x10 |
#define X_CODE32_SEL 0x18 |
#define X_RM_BACK_GATE 0x20 |
#define X_PM_ENTRY_GATE 0x28 |
#define X_FLATDATA_SEL 0x30 |
#define X_FLATCODE_SEL 0x38 |
#define X_CALLBIOS_SEL 0x40 |
#define X_CALLBIOS_GATE 0x48 |
#define X_VM86_TSS 0x50 |
#define X_MAIN_TSS 0x58 |
#define X_FLATDATA3_SEL 0x60 |
#define X_FLATCODE3_SEL 0x68 |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/hw-io.h |
---|
0,0 → 1,94 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The hw I/O instructions |
Never include this file!!! Include hw-instr.h instead!!! */ |
#ifndef __LL_I386_HW_IO_H__ |
#define __LL_I386_HW_IO_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* |
The code for inp, outp, inpw, outpw, inpd & outpd is from |
standard GNU C distribution! |
The full source code for the GNU-C distribution is available |
from www.delorie.com |
The following code is ... |
copyright (C) 1995 DJ Delorie, see COPYING.DJ for details |
*/ |
INLINE_OP unsigned char inp(unsigned short _port) |
{ |
unsigned char rv; |
__asm__ __volatile__ ("inb %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP unsigned short inpw (unsigned short _port) |
{ |
unsigned short rv; |
__asm__ __volatile__ ("inw %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP unsigned long inpd(unsigned short _port) |
{ |
unsigned long rv; |
__asm__ __volatile__ ("inl %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP void outp(unsigned short _port, unsigned char _data) |
{ |
__asm__ __volatile__ ("outb %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
INLINE_OP void outpw(unsigned short _port, unsigned short _data) |
{ |
__asm__ __volatile__ ("outw %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
INLINE_OP void outpd(unsigned short _port, unsigned long _data) |
{ |
__asm__ __volatile__ ("outl %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/hw-data.h |
---|
0,0 → 1,233 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... All the hardware-dependent data structures... */ |
#ifndef __LL_I386_HW_DATA_H__ |
#define __LL_I386_HW_DATA_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* DO WE NEED A SEPARATE INCL FILE FOR THIS? */ |
#if defined(__GNU__) |
#define __LL_ARCH__ "32/DJGPP C/COFF" |
#elif defined(__LINUX__) |
#define __LL_ARCH__ "32/LINUX CrossCompiled/ELF" |
#else |
#error Architecture Undefined! |
#endif |
#include <ll/i386/sel.h> |
/* Useful basic types */ |
#ifndef __BASIC_DATA__ |
#define __BASIC_DATA__ |
typedef void *LIN_ADDR; |
typedef unsigned long long QWORD; |
typedef unsigned long DWORD; |
typedef unsigned short WORD; |
typedef unsigned char BYTE; |
typedef unsigned long TIME; |
typedef unsigned long SYS_FLAGS; |
#define TRUE 1 |
#define FALSE 0 |
#define MAX_DWORD 0xFFFFFFFF |
#define MAX_WORD 0xFFFF |
#define MAX_BYTE 0xFF |
#define MAX_TIME MAX_DWORD |
#endif |
typedef short CONTEXT; |
/* Hardware based types (Self explanatory) */ |
typedef struct gate { |
WORD offset_lo __attribute__ ((packed)); |
WORD sel __attribute__ ((packed)); |
BYTE dword_cnt __attribute__ ((packed)); |
BYTE access __attribute__ ((packed)); |
WORD offset_hi __attribute__ ((packed)); |
} GATE; |
typedef struct descriptor { |
WORD lim_lo __attribute__ ((packed)); |
WORD base_lo __attribute__ ((packed)); |
BYTE base_med __attribute__ ((packed)); |
BYTE access __attribute__ ((packed)); |
BYTE gran __attribute__ ((packed)); |
BYTE base_hi __attribute__ ((packed)); |
} DESCRIPTOR; |
/* A LDT/GDT entry could be a gate or a selector */ |
/* An IDT entry could be a gate only */ |
union gdt_entry { |
DESCRIPTOR d __attribute__ ((packed)); |
GATE g __attribute__ ((packed)); |
}; |
struct registers { |
DWORD dummy1; |
DWORD dummy2; |
DWORD egs; |
DWORD efs; |
DWORD ees; |
DWORD ess; |
DWORD eds; |
DWORD edi; |
DWORD esi; |
DWORD ebp; |
DWORD esp; |
DWORD ebx; |
DWORD edx; |
DWORD ecx; |
DWORD eax; |
DWORD eip; |
DWORD ecs; |
DWORD flags; |
}; |
#define STACK_ACCESS 0x92 /* Basic Access bytes */ |
#define DATA_ACCESS 0x92 |
#define CODE_ACCESS 0x9A |
/* At this level we just need to set up 2 gates to enter/exit PM */ |
/* The entry gate is a 386 32 bit call gate */ |
/* The exit (Back To Real Mode) gate is a 286 16 bit gate */ |
#define CALL_GATE286 0x84 /* Call & Int Gate Access bytes */ |
#define CALL_GATE386 0x8C |
#define TASK_GATE 0x85 |
#define INT_GATE286 0x86 |
#define INT_GATE386 0x8E |
#define TRAP_GATE286 0x87 |
#define TRAP_GATE386 0x8F |
/* TSS selectors */ |
#define FREE_TSS386 0x89 |
#define BUSY_TSS386 0x8B |
#define FREE_TSS286 0x81 |
#define BUSY_TSS286 0x83 |
#define GRAN_32B 0xC0 /* Granularity settings */ |
#define GRAN_32 0x40 |
#define GRAN_16 0x00 |
/* This is the TSS image for a 386 hardware task */ |
/* I added two other fields to the basic structure: */ |
/* 1) The CONTROL field which is used by system software to detect */ |
/* particular conditions; in this the first phase it is mainly used */ |
/* to mark the unused TSS & TSS which use math, altough thanks to */ |
/* the automatic FPU preemption supported in 386 this would be not */ |
/* necessary. */ |
/* 2) The ctx_FPU field used to store the FPU context if necessaary */ |
#define TSS_USED 0x8000 |
#define FPU_USED 0x4000 |
#define FPU_CONTEXT_SIZE 108 |
/* CPU flags definitions */ |
#define CPU_FLAG_TF 0x00000100 |
#define CPU_FLAG_IF 0x00000200 |
#define CPU_FLAG_IOPL 0x00003000 |
#define CPU_FLAG_NT 0x00004000 |
#define CPU_FLAG_VM 0x00020000 |
#define CPU_FLAG_AC 0x00040000 |
#define CPU_FLAG_VIF 0x00080000 |
#define CPU_FLAG_VIP 0x00100000 |
#define CPU_FLAG_ID 0x00200000 |
typedef struct tss { |
WORD back_link __attribute__ ((packed)); |
WORD _fill0 __attribute__ ((packed)); |
DWORD esp0 __attribute__ ((packed)); |
WORD ss0 __attribute__ ((packed)); |
WORD _fill1 __attribute__ ((packed)); |
DWORD esp1 __attribute__ ((packed)); |
WORD ss1 __attribute__ ((packed)); |
WORD _fill2 __attribute__ ((packed)); |
DWORD esp2 __attribute__ ((packed)); |
WORD ss2 __attribute__ ((packed)); |
WORD _fill3 __attribute__ ((packed)); |
DWORD cr3 __attribute__ ((packed)); |
DWORD eip __attribute__ ((packed)); |
DWORD eflags __attribute__ ((packed)); |
DWORD eax __attribute__ ((packed)); |
DWORD ecx __attribute__ ((packed)); |
DWORD edx __attribute__ ((packed)); |
DWORD ebx __attribute__ ((packed)); |
DWORD esp __attribute__ ((packed)); |
DWORD ebp __attribute__ ((packed)); |
DWORD esi __attribute__ ((packed)); |
DWORD edi __attribute__ ((packed)); |
WORD es __attribute__ ((packed)); |
WORD _fill5 __attribute__ ((packed)); |
WORD cs __attribute__ ((packed)); |
WORD _fill6 __attribute__ ((packed)); |
WORD ss __attribute__ ((packed)); |
WORD _fill7 __attribute__ ((packed)); |
WORD ds __attribute__ ((packed)); |
WORD _fill8 __attribute__ ((packed)); |
WORD fs __attribute__ ((packed)); |
WORD _fill9 __attribute__ ((packed)); |
WORD gs __attribute__ ((packed)); |
WORD _fill10 __attribute__ ((packed)); |
WORD ldt __attribute__ ((packed)); |
WORD _fill11 __attribute__ ((packed)); |
WORD trap __attribute__ ((packed)); |
WORD io_base __attribute__ ((packed)); |
DWORD control __attribute__ ((packed)); |
BYTE ctx_FPU[FPU_CONTEXT_SIZE] __attribute__ ((packed)); |
} TSS; |
/* Irq services specifications */ |
#define TIMER_IRQ 0 |
#define KEYB_IRQ 1 |
#define COM2_IRQ 3 |
#define COM1_IRQ 4 |
#define COM4_IRQ 3 |
#define COM3_IRQ 4 |
#define SB_IRQ 5 |
#define FDC_IRQ 6 |
#define SB2_IRQ 7 |
#define RTC_IRQ 8 |
#define PS2MOUSE_IRQ 12 |
#define COPROC_IRQ 13 |
#define IDE0_IRQ 14 |
#define IDE1_IRQ 15 |
typedef void (*INTERRUPT)(void); |
/* Any Kernel primitive is declared with the SYSCALL() modifier */ |
/* This is useful to add special purposes meaning to the function */ |
/* defclaration */ |
#define SYSCALL(x) x |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/i386/mb-info.h |
---|
0,0 → 1,228 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* |
* GRUB -- GRand Unified Bootloader |
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org> |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef __LL_I386_MB_INFO_H__ |
#define __LL_I386_MB_INFO_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* |
* The structure type "mod_list" is used by the "multiboot_info" structure. |
*/ |
struct mod_list |
{ |
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ |
unsigned long mod_start; |
unsigned long mod_end; |
/* Module command line */ |
unsigned long cmdline; |
/* padding to take it to 16 bytes (must be zero) */ |
unsigned long pad; |
}; |
/* |
* INT-15, AX=E820 style "AddressRangeDescriptor" |
* ...with a "size" parameter on the front which is the structure size - 4, |
* pointing to the next one, up until the full buffer length of the memory |
* map has been reached. |
*/ |
struct AddrRangeDesc |
{ |
unsigned long size; |
unsigned long BaseAddrLow; |
unsigned long BaseAddrHigh; |
unsigned long LengthLow; |
unsigned long LengthHigh; |
unsigned long Type; |
/* unspecified optional padding... */ |
}; |
/* usable memory "Type", all others are reserved. */ |
#define MB_ARD_MEMORY 1 |
/* |
* MultiBoot Info description |
* |
* This is the struct passed to the boot image. This is done by placing |
* its address in the EAX register. |
*/ |
struct multiboot_info |
{ |
/* MultiBoot info version number */ |
unsigned long flags; |
/* Available memory from BIOS */ |
unsigned long mem_lower; |
unsigned long mem_upper; |
/* "root" partition */ |
unsigned long boot_device; |
/* Kernel command line */ |
unsigned long cmdline; |
/* Boot-Module list */ |
unsigned long mods_count; |
unsigned long mods_addr; |
union |
{ |
struct |
{ |
/* (a.out) Kernel symbol table info */ |
unsigned long tabsize; |
unsigned long strsize; |
unsigned long addr; |
unsigned long pad; |
} a; |
struct |
{ |
/* (ELF) Kernel section header table */ |
unsigned long num; |
unsigned long size; |
unsigned long addr; |
unsigned long shndx; |
} e; |
} syms; |
/* Memory Mapping buffer */ |
unsigned long mmap_length; |
unsigned long mmap_addr; |
/* Drive Info buffer */ |
unsigned long drives_length; |
unsigned long drives_addr; |
/* ROM configuration table */ |
unsigned long config_table; |
/* Boot Loader Name */ |
unsigned long boot_loader_name; |
/* APM table */ |
unsigned long apm_table; |
/* Video */ |
unsigned long vbe_control_info; |
unsigned long vbe_mode_info; |
unsigned short vbe_mode; |
unsigned short vbe_interface_seg; |
unsigned short vbe_interface_off; |
unsigned short vbe_interface_len; |
#ifndef __OLD_MB__ |
/* |
Gerardo: I need to add also the phisical address base for |
both low ( < 1MB) & upper ( > 1MB) memory, as X starts from DOS |
which could have preallocated some of this memory... |
For example, GRUB assumes that mem_lowbase = 0x0 & |
mem_upbase = 0x100000 |
*/ |
unsigned long mem_lowbase; |
unsigned long mem_upbase; |
#endif /* __OLD_MB__ */ |
}; |
/* |
* Flags to be set in the 'flags' parameter above |
*/ |
/* is there basic lower/upper memory information? */ |
#define MB_INFO_MEMORY 0x1 |
/* is there a boot device set? */ |
#define MB_INFO_BOOTDEV 0x2 |
/* is the command-line defined? */ |
#define MB_INFO_CMDLINE 0x4 |
/* are there modules to do something with? */ |
#define MB_INFO_MODS 0x8 |
/* These next two are mutually exclusive */ |
/* is there a symbol table loaded? */ |
#define MB_INFO_AOUT_SYMS 0x10 |
/* is there an ELF section header table? */ |
#define MB_INFO_ELF_SHDR 0x20 |
/* is there a full memory map? */ |
#define MB_INFO_MEM_MAP 0x40 |
/* Is there drive info? */ |
#define MB_INFO_DRIVE_INFO 0x00000080 |
/* Is there a config table? */ |
#define MB_INFO_CONFIG_TABLE 0x00000100 |
/* Is there a boot loader name? */ |
#define MB_INFO_BOOT_LOADER_NAME 0x00000200 |
/* Is there a APM table? */ |
#define MB_INFO_APM_TABLE 0x00000400 |
/* Is there video information? */ |
#define MB_INFO_VIDEO_INFO 0x00000800 |
#if 0 |
/* Gerardo: Added this! |
-------------------- |
The idea is that the BootLoader provides an interface |
to return back to it; this is useful to implement a DOS |
boot-loader, in order to use DOS as development environment. |
*/ |
#define MB_INFO_USEGDT 0x80 |
#endif |
/* |
* The following value must be present in the EAX register. |
*/ |
#define MULTIBOOT_VALID 0x2BADB002 |
struct multiboot_info * mbi_address(void); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/stdarg.h |
---|
0,0 → 1,90 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Paolo Gai <pj@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/** |
------------ |
CVS : $Id: stdarg.h,v 1.2 2003-03-17 09:27:56 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-03-17 09:27:56 $ |
------------ |
lowlevel's stdarg.h |
**/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* the Free Software Foundation; either version 2 of the License, or |
* (at your option) any later version. |
* |
* This program is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#ifndef __dj_include_stdarg_h_ |
#define __dj_include_stdarg_h_ |
#include <ll/i386/defs.h> |
#ifndef __dj_ENFORCE_ANSI_FREESTANDING |
#ifdef __dj_include_varargs_h_ |
#error stdarg.h and varargs.h are mutually exclusive |
#endif |
#include <ll/sys/types.h> |
BEGIN_DEF |
#define __dj_va_rounded_size(T) \ |
(((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) |
#define va_arg(ap, T) \ |
(ap = (va_list) ((char *) (ap) + __dj_va_rounded_size (T)), \ |
*((T *) (void *) ((char *) (ap) - __dj_va_rounded_size (T)))) |
#define va_end(ap) |
#define va_start(ap, last_arg) \ |
(ap = ((va_list) __builtin_next_arg (last_arg))) |
#ifndef __STRICT_ANSI__ |
#ifndef _POSIX_SOURCE |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__STRICT_ANSI__ */ |
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
#ifndef __dj_ENFORCE_FUNCTION_CALLS |
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ |
END_DEF |
#endif /* !__dj_include_stdarg_h_ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/aspace.h |
---|
0,0 → 1,66 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Address spaces code & data */ |
#ifndef __LL_SYS_LL_ASPACE_H__ |
#define __LL_SYS_LL_ASPACE_H__ |
#include <ll/i386/defs.h> |
/* I dont't know if we really need all these things... */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/tss-ctx.h> |
BEGIN_DEF |
struct as { |
DWORD base; |
DWORD limit; |
WORD status; |
}; |
/* An Address Space descriptor is a Segment descriptor... so it is a WORD... */ |
#define AS WORD |
#define AS_FREE 0 |
#define AS_BUSY 1 |
#define ASMax 60 |
#if 0 |
#define ASBase 0x300 /* Is it correct? TSSBase + 64 *8... */ |
#endif |
#define ASBase (TSSBase + TSSMax * 8) |
#define ASsel2index(sel) ((sel-ASBase) / 16) |
#define ASindex2sel(i) (ASBase + i * 16) |
void as_init(void); |
AS as_create(void); |
int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size); |
END_DEF |
#endif /* __LL_SYS_LL_ASPACE_H__ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/ll-func.h |
---|
0,0 → 1,56 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Kernel Library functions interfaces */ |
#ifndef __LL_SYS_LL_LL_FUNC_H_ |
#define __LL_SYS_LL_LL_FUNC_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/sys/ll/ll-data.h> |
void ll_context_setspace(CONTEXT c, WORD as); |
CONTEXT ll_context_create(void (*task)(void *p),BYTE *stack, |
void *parm,void (*killer)(void),WORD ctrl); |
/* Release a used task context */ |
void ll_context_delete(CONTEXT c); |
/* Put the context value into human readable form; used for debug! */ |
char *ll_context_sprintf(char *str,CONTEXT c); |
/* These functions start-up & close the ll layer */ |
void *ll_init(void); |
void ll_end(void); |
/* This functions acts as safety place where to go when any error */ |
/* occurs and we do not know what context is active */ |
void ll_abort(int code); |
END_DEF |
#endif /* __LL_SYS_LL_LL_MEM_H_ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/event.h |
---|
0,0 → 1,85 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Time event management functions */ |
#ifndef __LL_SYS_LL_EVENT_H__ |
#define __LL_SYS_LL_EVENT_H__ |
#include <ll/i386/defs.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/ll-data.h> |
BEGIN_DEF |
#define MAX_EVENT 100 |
struct event { |
struct event *next; /* Next event in an event queue */ |
void *par; /* Handler's parameter */ |
void (*handler)(void *p); /* Event Handler */ |
struct timespec time; /* Time at which the event |
will raise */ |
int index; /* Event ID */ |
}; |
/* Event management functions... */ |
void event_setprologue(void *p); |
void event_setepilogue(void *p); |
void event_setlasthandler(void *p); |
int (*event_post)(struct timespec time, void (*handler)(void *p), void *par); |
int (*event_delete)(int index); |
int oneshot_event_post(struct timespec time, void (*handler)(void *p), void *par); |
int oneshot_event_delete(int index); |
int periodic_event_post(struct timespec time, void (*handler)(void *p), void *par); |
int periodic_event_delete(int index); |
void event_init(struct ll_initparms *l); |
/* Interrupt handler entry */ |
struct intentry { |
void *par; /* Handler's parameter */ |
void (*handler)(void *p); /* Interrupt Handler */ |
int index; /* Interrupt number */ |
DWORD status; /* Interrupt status |
no handler --> FREE |
handler --> ASSIGNED |
being served --> BUSY |
*/ |
DWORD flags; |
}; |
#define INT_PREEMPTABLE 1 |
#define INT_FORCE 2 |
#define INTSTAT_FREE 1 |
#define INTSTAT_ASSIGNED 2 |
#define INTSTAT_BUSY 3 |
void irq_init(void); |
int irq_bind(int irq, void (*handler)(void *p), DWORD flags); |
int ll_ActiveInt(); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/sys/ll/ll-data.h |
---|
0,0 → 1,44 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Kernel Library data structures definitions */ |
#ifndef __LL_SYS_LL_LL_DATA_H__ |
#define __LL_SYS_LL_LL_DATA_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* These are used by the ll_init function... */ |
#define LL_PERIODIC 0 |
#define LL_ONESHOT 1 |
struct ll_initparms { |
DWORD mode; |
TIME tick; |
}; |
END_DEF |
#endif /* __LL_SYS_LL_LL_DATA_H__ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/time.h |
---|
0,0 → 1,157 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Inline functions for managing timespec structures. |
All timespec values are pointers!!! |
This file defines these functions: |
TIMESPEC2NANOSEC(t) |
converts a timespec value to a nanosec value, and return |
it, no checks |
TIMESPEC2USEC(t) |
converts a timespec value to a nanosec value, and return |
it, no checks |
NULL_TIMESPEC(t) |
the timespec value is set to the Epoch (=0) |
ADDNANO2TIMESPEC(n, t) |
t = t + n |
ADDUSEC2TIMESPEC(m, t) |
t = t + m |
SUBTIMESPEC(s1, s2, d) |
d = s1 - s2 |
ADDTIMESPEC(s1, s2, d) |
d = s1 + s2 |
TIMESPEC_A_LT_B(a,b) |
a < b |
TIMESPEC_A_GT_B(a,b) |
a > b |
TIMESPEC_A_EQ_B(a,b) |
a == b |
TIMESPEC_A_NEQ_B(a,b) |
a != b |
TIMESPEC_ASSIGN(t1,t2) |
t1 = t2 */ |
#ifndef __LL_SYS_LL_TIME_H__ |
#define __LL_SYS_LL_TIME_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
struct timespec { |
long tv_sec; /* Seconds */ |
long tv_nsec; /* Nanoseconds */ |
}; |
/* |
* these macros come from the Utah Flux oskit... |
*/ |
#define TIMESPEC2NANOSEC(t) ((t)->tv_sec * 1000000000 + (t)->tv_nsec) |
#define TIMESPEC2USEC(t) ((t)->tv_sec * 1000000 + (t)->tv_nsec / 1000) |
#define NULL_TIMESPEC(t) ((t)->tv_sec = (t)->tv_nsec = 0) |
#define ADDNANO2TIMESPEC(n, t) ((t)->tv_nsec += (n), \ |
(t)->tv_sec += (t)->tv_nsec / 1000000000, \ |
(t)->tv_nsec %= 1000000000) |
#define SUBTIMESPEC(s1, s2, d) \ |
((d)->tv_nsec = ((s1)->tv_nsec >= (s2)->tv_nsec) ? \ |
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec), \ |
(s1)->tv_nsec - (s2)->tv_nsec) \ |
: \ |
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec - 1), \ |
(1000000000 + (s1)->tv_nsec - (s2)->tv_nsec))) |
/* |
* ...and these not! |
*/ |
extern __inline__ void ADDTIMESPEC(const struct timespec *s1, |
const struct timespec *s2, |
struct timespec *d) |
{ |
d->tv_sec = s1->tv_sec + s2->tv_sec; |
d->tv_nsec = s1->tv_nsec + s2->tv_nsec; |
if (d->tv_nsec < 0) { |
d->tv_sec--; |
d->tv_nsec += 1000000000; |
} else if (d->tv_nsec >= 1000000000) { |
d->tv_sec++; |
d->tv_nsec -= 1000000000; |
} |
} |
#define ADDUSEC2TIMESPEC(m, t) ((t)->tv_nsec += (m%1000000)*1000, \ |
(t)->tv_sec += ((t)->tv_nsec / 1000000000) + (m/1000000), \ |
(t)->tv_nsec %= 1000000000) |
#define TIMESPEC_A_LT_B(a,b) \ |
( \ |
((a)->tv_sec < (b)->tv_sec) || \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec < (b)->tv_nsec) \ |
) |
#define TIMESPEC_A_GT_B(a,b) \ |
( \ |
((a)->tv_sec > (b)->tv_sec) || \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec > (b)->tv_nsec) \ |
) |
#define TIMESPEC_A_EQ_B(a,b) \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec == (b)->tv_nsec) |
#define TIMESPEC_A_NEQ_B(a,b) \ |
((a)->tv_sec != (b)->tv_sec || (a)->tv_nsec != (b)->tv_nsec) |
#define TIMESPEC_ASSIGN(t1,t2) \ |
((t1)->tv_sec = (t2)->tv_sec, (t1)->tv_nsec = (t2)->tv_nsec) |
#if 0 |
#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \ |
(b)->tv_sec = ((a)->gigas * 1197) / 1000) /*, \ |
(b)->tv_sec += (b)->tv_nsec / 1000000000, \ |
(b)->tv_nsec %= 1000000000) */ |
#else |
/*#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \ |
(b)->tv_nsec += (((a)->gigas * 1197) % 1000) * 1000000, \ |
(b)->tv_sec = ((a)->gigas * 1197) / 1000 , \ |
(b)->tv_sec += (b)->tv_nsec / 1000000000, \ |
(b)->tv_nsec %= 1000000000)*/ |
#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197), \ |
(b)->tv_nsec += (((a)->gigas * 1197) % 1000) * 1000, \ |
(b)->tv_sec = ((a)->gigas * 1197) / 1000 , \ |
(b)->tv_sec += (b)->tv_nsec / 1000000, \ |
(b)->tv_nsec %= 1000000, \ |
(b)->tv_nsec *= 1000) |
#endif |
TIME ll_gettime(int mode, struct timespec *tsres); |
#define TIME_PTICK 1 |
#define TIME_EXACT 2 |
#define TIME_NEW 3 |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/sys/ll/exc.h |
---|
0,0 → 1,40 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Hardware exceptions */ |
#ifndef __LL_SYS_LL_HW_EXC_H__ |
#define __LL_SYS_LL_HW_EXC_H__ |
#define DIV_BY_0 0 /* These are the ll... exceptions */ |
#define MATH_EXC 1 |
#define NMI_EXC 2 |
#define DEBUG_EXC 3 |
#define BREAKPOINT_EXC 4 |
#define HW_FAULT 5 |
#define NO_MORE_HW_DESC 6 |
#define VM86_PANIC 7 |
/* Please, do not confuse them with the HW exception!!! */ |
#define CLOCK_OVERRUN 64 /* Warning this is used in vm1.asm */ |
#endif /* __LL_SYS_LL_HW_EXC_H__ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/ll-mem.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Some memory management code */ |
#ifndef __LL_SYS_LL_LL_MEM_H_ |
#define __LL_SYS_LL_LL_MEM_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* These function are used to manage memory at ll layer */ |
void * ll_alloc(DWORD size); |
WORD ll_free(void *ptr,DWORD size); |
void ll_mem_init(void *base,DWORD size); |
void ll_mem_dump(void); |
END_DEF |
#endif /* __LL_SYS_LL_LL_MEM_H_ */ |
/shark/tags/rel_0_5/oslib/ll/sys/ll/ll-instr.h |
---|
0,0 → 1,57 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_SYS_LL_LL_INSTR_H_ |
#define __LL_SYS_LL_LL_INSTR_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* |
Well, these are simple macros... to map the HARTIK names |
onto the standard names! |
*/ |
#define ll_in(port) inp(port) |
#define ll_out(port,v) outp(port,v) |
#define ll_inw(port) inpw(port) |
#define ll_outw(port,v) outpw(port,v) |
#define ll_ind(port) inpd(port) |
#define ll_outd(port,v) outpd(port,v) |
/* These functions are used to mask/unmask selectively interrupts */ |
/* The irq services are also #defined to allow more generic inteface */ |
/* This is done into hw... files! */ |
void ll_irq_mask(WORD irqno); |
void ll_irq_unmask(WORD irqno); |
/* These functions provide direct access to interrupt table */ |
/* We can write the HARTIK interrupt table but only read */ |
/* the host OS interrupt table! */ |
void ll_irq_set(WORD irqno,INTERRUPT handler); |
INTERRUPT ll_irq_get(WORD irqno); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/sys/types.h |
---|
0,0 → 1,45 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_SYS_TYPES_H__ |
#define __LL_SYS_TYPES_H__ |
#include <ll/i386/hw-data.h> |
#define size_t DWORD |
#define ssize_t long int |
#define va_list void* |
#define u_int unsigned int |
#define u_char BYTE |
#define u_short WORD |
#define u_long DWORD |
/* unsigned integers */ |
typedef BYTE u_int8_t; |
typedef WORD u_int16_t; |
typedef DWORD u_int32_t; |
/* signed integers */ |
typedef signed char int8_t; |
typedef short int int16_t; |
typedef int int32_t; |
#endif |
/shark/tags/rel_0_5/oslib/ll/sys/cdefs.h |
---|
0,0 → 1,147 |
/* |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Berkeley Software Design, Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)cdefs.h 8.7 (Berkeley) 1/21/94 |
*/ |
#ifndef __LL_SYS_CDEFS_H__ |
#define __LL_SYS_CDEFS_H__ |
#if defined(__cplusplus) |
#define __BEGIN_DECLS extern "C" { |
#define __END_DECLS }; |
#else |
#define __BEGIN_DECLS |
#define __END_DECLS |
#endif |
/* |
* The __CONCAT macro is used to concatenate parts of symbol names, e.g. |
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. |
* The __CONCAT macro is a bit tricky -- make sure you don't put spaces |
* in between its arguments. __CONCAT can also concatenate double-quoted |
* strings produced by the __STRING macro, but this only works with ANSI C. |
*/ |
#if defined(__STDC__) || defined(__cplusplus) |
#define __P(protos) protos /* full-blown ANSI C */ |
#define __CONCAT1(x,y) x ## y |
#define __CONCAT(x,y) __CONCAT1(x,y) |
#define __STRING(x) #x |
#define __const const /* define reserved names to standard */ |
#define __signed signed |
#define __volatile volatile |
#if defined(__cplusplus) |
#define __inline inline /* convert to C++ keyword */ |
#else |
#ifndef __GNUC__ |
#define __inline /* delete GCC keyword */ |
#endif /* !__GNUC__ */ |
#endif /* !__cplusplus */ |
#else /* !(__STDC__ || __cplusplus) */ |
#define __P(protos) () /* traditional C preprocessor */ |
#define __CONCAT(x,y) x/**/y |
#define __STRING(x) "x" |
#ifndef __GNUC__ |
#define __const /* delete pseudo-ANSI C keywords */ |
#define __inline |
#define __signed |
#define __volatile |
/* |
* In non-ANSI C environments, new programs will want ANSI-only C keywords |
* deleted from the program and old programs will want them left alone. |
* When using a compiler other than gcc, programs using the ANSI C keywords |
* const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. |
* When using "gcc -traditional", we assume that this is the intent; if |
* __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. |
*/ |
#ifndef NO_ANSI_KEYWORDS |
#define const /* delete ANSI C keywords */ |
#define inline |
#define signed |
#define volatile |
#endif |
#endif /* !NO_ANSI_KEYWORDS */ |
#endif /* !(__STDC__ || __cplusplus) */ |
/* |
* GCC1 and some versions of GCC2 declare dead (non-returning) and |
* pure (no side effects) functions using "volatile" and "const"; |
* unfortunately, these then cause warnings under "-ansi -pedantic". |
* GCC2.5 uses a new, peculiar __attribute__((attrs)) style. All of |
* these work for GNU C++ (modulo a slight glitch in the C++ grammar |
* in the distribution version of 2.5.5). |
*/ |
#if __GNUC__ < 2 |
#define __dead |
#define __dead2 |
#define __pure |
#define __pure2 |
#define __attribute__(x) |
#endif |
#if __GNUC__ == 2 && __GNUC_MINOR__ < 5 |
#define __dead __volatile |
#define __dead2 |
#define __pure __const |
#define __pure2 |
#endif |
#if __GNUC__ == 2 && __GNUC_MINOR__ > 5 || __GNUC__ >= 3 |
#define __dead |
#define __dead2 __attribute__((noreturn)) |
#define __pure |
#define __pure2 __attribute__((const)) |
#endif |
#ifdef __GNUC__ |
#ifdef __STDC__ |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs \"" msg "\",30,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#else |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs msg,30,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#endif |
#endif |
#endif /* !_SYS_CDEFS_H_ */ |
/shark/tags/rel_0_5/oslib/ll/math.h |
---|
0,0 → 1,141 |
/* |
* Copyright (c) 1985, 1990, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)math.h 8.1 (Berkeley) 6/2/93 |
*/ |
#ifndef __LL_MATH_H__ |
#define __LL_MATH_H__ |
#if defined(vax) || defined(tahoe) /* DBL_MAX from float.h */ |
#define HUGE_VAL 1.701411834604692294E+38 |
#else |
#define HUGE_VAL 1e500 /* IEEE: positive infinity */ |
#endif |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
#if defined(vax) || defined(tahoe) |
/* |
* HUGE for the VAX and Tahoe converts to the largest possible F-float value. |
* This implies an understanding of the conversion behavior of atof(3). It |
* was defined to be the largest float so that overflow didn't occur when it |
* was assigned to a single precision number. HUGE_VAL is strongly preferred. |
*/ |
#define HUGE 1.701411733192644270E+38 |
#else |
#define HUGE HUGE_VAL |
#endif |
#define M_E 2.7182818284590452354 /* e */ |
#define M_LOG2E 1.4426950408889634074 /* log 2e */ |
#define M_LOG10E 0.43429448190325182765 /* log 10e */ |
#define M_LN2 0.69314718055994530942 /* log e2 */ |
#define M_LN10 2.30258509299404568402 /* log e10 */ |
#define M_PI 3.14159265358979323846 /* pi */ |
#define M_PI_2 1.57079632679489661923 /* pi/2 */ |
#define M_PI_4 0.78539816339744830962 /* pi/4 */ |
#define M_1_PI 0.31830988618379067154 /* 1/pi */ |
#define M_2_PI 0.63661977236758134308 /* 2/pi */ |
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ |
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
#include <ll/sys/cdefs.h> |
/* |
* Most of these functions have the side effect of setting errno, except |
* in the (broken) BSD libm, so they not declared as __pure2. |
*/ |
__BEGIN_DECLS double acos __P((double)); |
double asin __P((double)); |
double atan __P((double)); |
double atan2 __P((double, double)); |
double ceil __P((double)); |
double cos __P((double)); |
double cosh __P((double)); |
double exp __P((double)); |
double fabs __P((double)); |
double floor __P((double)); |
double fmod __P((double, double)); |
double frexp __P((double, int *)); /* fundamentally !__pure2 */ |
double ldexp __P((double, int)); |
double log __P((double)); |
double log10 __P((double)); |
double modf __P((double, double *)); /* fundamentally !__pure2 */ |
double pow __P((double, double)); |
double sin __P((double)); |
double sinh __P((double)); |
double sqrt __P((double)); |
double tan __P((double)); |
double tanh __P((double)); |
/* |
* These functions are non-ANSI so they can be "right". The ones that |
* don't set errno in [lib]msun are declared as __pure2. |
*/ |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
double acosh __P((double)); |
double asinh __P((double)); |
double atanh __P((double)); |
double cabs(); /* we can't describe cabs()'s argument properly */ |
double cbrt __P((double)) __pure2; |
double copysign __P((double, double)) __pure2; |
double drem __P((double, double)); |
double erf __P((double)); |
double erfc __P((double)) __pure2; |
double expm1 __P((double)) __pure2; |
int finite __P((double)) __pure2; |
double hypot __P((double, double)); |
#if defined(vax) || defined(tahoe) |
double infnan __P((int)); |
#endif |
int isinf __P((double)) __pure2; |
int isnan __P((double)) __pure2; |
double j0 __P((double)); |
double j1 __P((double)); |
double jn __P((int, double)); |
double lgamma __P((double)); |
double log1p __P((double)) __pure2; |
double logb __P((double)) __pure2; |
double rint __P((double)) __pure2; |
double scalb __P((double, int)); |
double y0 __P((double)); |
double y1 __P((double)); |
double yn __P((int, double)); |
#endif |
#define isinf(x) (isspecial(x, NULL) > 1) |
#define isnan(x) (isspecial(x, NULL) == 1) |
__END_DECLS |
#endif /* !_MATH_H_ */ |
/shark/tags/rel_0_5/oslib/ll/time.h |
---|
0,0 → 1,35 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* A wrapper to the time handling functions */ |
#ifndef __LL_TIME_H__ |
#define __LL_TIME_H__ |
#include <ll/sys/types.h> |
#ifndef NULL |
#define NULL 0L |
#endif |
#include <ll/sys/ll/time.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/stdlib.h |
---|
0,0 → 1,27 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The system independent part of the standard library */ |
#ifndef __LL_STDLIB_H__ |
#define __LL_STDLIB_H__ |
#include <ll/i386/stdlib.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/limits.h |
---|
0,0 → 1,4 |
#ifndef __LL_LIMITS_H__ |
#define __LL_LIMITS_H__ |
#include <ll/i386/limits.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/assert.h |
---|
0,0 → 1,39 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Assert & demand: diagnostic routines */ |
#ifndef __LL_ASSERT_H__ |
#define __LL_ASSERT_H__ |
#include <ll/i386/error.h> |
#define assert(x) { \ |
if (! (x)) \ |
message("%s:%d: assertion failed: %s", __FILE__, __LINE__, #x); \ |
} |
#define demand(x,y) { \ |
if (! (x)) \ |
message("%s:%d: demand %s failed: %s", __FILE__, __LINE__, #x, #y); \ |
} |
#endif |
/shark/tags/rel_0_5/oslib/ll/stdio.h |
---|
0,0 → 1,26 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The standard input/output */ |
#ifndef __LL_STDIO_H__ |
#define __LL_STDIO_H__ |
#include <ll/i386/stdio.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/ctype.h |
---|
0,0 → 1,47 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Standard character conversions and tests */ |
#ifndef __LL_CTYPE_H__ |
#define __LL_CTYPE_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* String conversion functions */ |
char toupper(char c); |
char tolower(char c); |
int tonumber(char c); |
char todigit(int c); |
int isalnum(char c); |
int isalpha(char c); |
int iscntrl(char c); |
int isdigit(char c); |
int islower(char c); |
int isspace(char c); |
int isupper(char c); |
int isxdigit(char c); |
int isnumber(char c,int base); |
int isspecial(double d,char *bufp); |
END_DEF |
#endif |
/shark/tags/rel_0_5/oslib/ll/errno.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Stuff needed by the Math library... It wants to set errno!!! */ |
#ifndef __LL_ERRNO_H__ |
#define __LL_ERRNO_H__ |
void seterrnumber(int *(*e)(void)); |
extern int *__errnumber1(); |
/*+ this macro refers the correct errno... +*/ |
#define errno (*__errnumber1()) |
#define __set_errno(val) ((*__errnumber1()) = (val) ) |
#define EDOM 33 |
#define EILSEQ 84 |
#define ERANGE 34 |
#endif |
/shark/tags/rel_0_5/oslib/ll/float.h |
---|
0,0 → 1,4 |
#ifndef __LL_FLOAT_H__ |
#define __LL_FLOAT_H__ |
#include <ll/i386/float.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/unistd.h |
---|
0,0 → 1,33 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_UNISTD_H__ |
#define __LL_UNISTD_H__ |
/* _exit */ |
#include <ll/i386/hw-func.h> |
/* cprintf */ |
#include <ll/i386/cons.h> |
#include <ll/sys/types.h> |
#endif /* !_SYS_UNISTD_H_ */ |
/shark/tags/rel_0_5/oslib/ll/string.h |
---|
0,0 → 1,29 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* String operations... */ |
#ifndef __LL_STRING_H__ |
#define __LL_STRING_H__ |
#include <ll/i386/string.h> |
#include <ll/sys/types.h> |
#endif |
/shark/tags/rel_0_5/oslib/ll/ll.h |
---|
0,0 → 1,51 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The abominious: an ``include all'' header!!! */ |
#ifndef __LL_LL_H__ |
#define __LL_LL_H__ |
#include <ll/sys/ll/aspace.h> |
#include <ll/sys/ll/event.h> |
#include <ll/sys/ll/exc.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/ll-mem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-io.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/mb-hdr.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/sel.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/x-dos.h> |
#endif |
/shark/tags/rel_0_5/oslib/mk/linux.mk |
---|
6,7 → 6,9 |
LIB_PATH = $(BASE)/lib/ |
LIB_DIR = $(BASE)/lib |
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__LINUX__ -I$(INCL) |
# Linux.mk for gcc 2.x |
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__LINUX__ -DMAIN=__kernel_init__ -I$(INCL) |
ASM_OPT = -x assembler-with-cpp -D__LINUX__ -I$(INCL) |
LINK_OPT = -Bstatic -Ttext 0x220000 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
/shark/tags/rel_0_5/oslib/mk/linux32.mk |
---|
0,0 → 1,29 |
CC = gcc |
AS = gcc |
LD = ld |
AR = ar |
INCL = $(BASE) |
LIB_PATH = $(BASE)/lib/ |
LIB_DIR = $(BASE)/lib |
# Linux32.mk for gcc 3.2 |
C_OPT = -Wall -O -fno-builtin -nostdinc -D__LINUX__ -DMAIN=__kernel_init__ -I$(INCL) |
ASM_OPT = -x assembler-with-cpp -D__LINUX__ -I$(INCL) |
LINK_OPT = -Bstatic -Ttext 0x220000 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
MKDIR = mkdir |
CP = cp |
CAT = cat |
RM = rm -f |
RMDIR = rm -rf |
# Common rules |
%.o : %.s |
$(REDIR) $(CC) $(ASM_OPT) -c $< |
%.o : %.c |
$(REDIR) $(CC) $(C_OPT) -c $< |
%.s : %.c |
$(REDIR) $(CC) $(C_OPT) -S $< |
/shark/tags/rel_0_5/oslib/mk/gnu.mk |
---|
6,9 → 6,9 |
LIB_PATH = $(BASE)/lib/ |
LIB_DIR = $(BASE)\lib |
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__GNU__ -I$(INCL) |
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__GNU__ -I$(INCL) -DMAIN=__kernel_init__ |
ASM_OPT = -x assembler-with-cpp -D__GNU__ -I$(INCL) |
LINK_OPT = -Bstatic -Ttext 0x320000 -oformat coff-go32 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
LINK_OPT = -T $(BASE)/mk/os.x -Bstatic -Ttext 0x320000 -oformat coff-go32 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
MKDIR = md |
CP = copy |
/shark/tags/rel_0_5/oslib/mk/os.x |
---|
0,0 → 1,25 |
OUTPUT_FORMAT("coff-go32") |
ENTRY(start) |
SECTIONS |
{ |
.text 0x1000+SIZEOF_HEADERS : { |
*(.text) |
etext = . ; _etext = .; |
} |
.data : { |
djgpp_first_ctor = . ; |
*(.ctor) |
djgpp_last_ctor = . ; |
djgpp_first_dtor = . ; |
*(.dtor) |
djgpp_last_dtor = . ; |
*(.data) |
edata = . ; _edata = .; |
} |
.bss SIZEOF(.data) + ADDR(.data) : |
{ |
*(.bss) |
*(COMMON) |
end = . ; _end = .; |
} |
} |
/shark/tags/rel_0_5/oslib/mk/oldgnu.mk |
---|
8,7 → 8,7 |
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__GNU__ -D__OLD_GNU__ -I$(INCL) |
ASM_OPT = -x assembler-with-cpp -D__GNU__ -I$(INCL) |
LINK_OPT = -Bstatic -Ttext 0x320000 -oformat coff-go32 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
LINK_OPT = -T $(BASE)/mk/os.x -Bstatic -Ttext 0x320000 -oformat coff-go32 -s -nostartfiles -nostdlib -L$(LIB_PATH) |
MKDIR = md |
CP = copy |
/shark/tags/rel_0_5/oslib/libc/cprintf.c |
---|
File deleted |
/shark/tags/rel_0_5/oslib/libc/cons1.c |
---|
File deleted |
/shark/tags/rel_0_5/oslib/libc/message.c |
---|
File deleted |
/shark/tags/rel_0_5/oslib/libc/cons2.c |
---|
File deleted |
/shark/tags/rel_0_5/oslib/libc/ioformat/ksprintf.c |
---|
25,8 → 25,6 |
#include <ll/i386/float.h> |
#include <ll/i386/mem.h> |
#include <ll/stdarg.h> |
#include <ll/ctype.h> |
#include <ll/math.h> |
#include "sprintf.h" |
FILE(ksprintf); |
/shark/tags/rel_0_5/oslib/libc/ioformat/ucvt.c |
---|
26,7 → 26,6 |
#include <ll/i386/mem.h> |
#include <ll/stdarg.h> |
#include <ll/ctype.h> |
#include <ll/math.h> |
#include "sprintf.h" |
FILE(ucvt); |
/shark/tags/rel_0_5/oslib/libc/ioformat/sscanf.c |
---|
24,7 → 24,6 |
#include <ll/i386/limits.h> |
#include <ll/stdarg.h> |
#include <ll/ctype.h> |
#include <ll/math.h> |
#include "sprintf.h" |
FILE(sscanf); |
/shark/tags/rel_0_5/oslib/libc/stdlib/strtou.c |
---|
24,7 → 24,6 |
#include <ll/i386/limits.h> |
#include <ll/stdarg.h> |
#include <ll/ctype.h> |
#include <ll/math.h> |
FILE(strtou); |
/shark/tags/rel_0_5/oslib/libc/reboot.c |
---|
22,7 → 22,7 |
/* Reset (or halt...) the system */ |
#include <ll/i386/hw-func.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
FILE(reboot); |
/shark/tags/rel_0_5/oslib/libc/makefile |
---|
5,18 → 5,17 |
# Makefile for GNU MAKE & GCC 2.8.0 |
ifndef BASE |
BASE = ../.. |
BASEDOS = ..\.. |
BASE = .. |
BASEDOS = .. |
endif |
include $(BASE)/config/config.mk |
include $(BASE)/config.mk |
COMMON_OBJS = cons1.o \ |
cons2.o \ |
reboot.o \ |
cprintf.o \ |
message.o |
#C_OPT += -DPROFILE |
#ASM_OPT += -DPROFILE |
COMMON_OBJS = reboot.o |
STRING_OBJS = strncat.o \ |
strrchr.o \ |
strstr.o \ |
47,8 → 46,6 |
OBJS = $(GNU_S_OBJS) $(GNU_C_OBJS) $(COMMON_OBJS) $(STRING_OBJS) $(IO_OBJS) $(STD_OBJS) |
vpath %.c string stdlib ioformat |
#VPATH := $(subst $(space),:,$(SRCDIRS) $(MOSTLY_SRCDIRS)) |
75,10 → 72,10 |
allclean : |
echo # XTN Library dependencies > deps |
$(RM) $(BASE)\lib\libhc.a |
$(RM) $(LIB_PATH)libhc.a |
deps: $(COMMON_OBJS:.o=.c) $(patsubst %.o,string/%.c,$(STRING_OBJS)) $(patsubst %.o,ioformat/%.c,$(IO_OBJS)) $(patsubst %.o,stdlib/%.c,$(STD_OBJS)) |
$(CC) -E $(C_OPT) $(VMINCL) -M $(COMMON_OBJS:.o=.c) \ |
$(CC) -E $(C_OPT) -M $(COMMON_OBJS:.o=.c) \ |
$(patsubst %.o,string/%.c,$(STRING_OBJS)) \ |
$(patsubst %.o,ioformat/%.c,$(IO_OBJS)) \ |
$(patsubst %.o,stdlib/%.c,$(STD_OBJS)) > deps |
/shark/tags/rel_0_5/oslib/libcons/cons1.c |
---|
0,0 → 1,201 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
/* #include <xsys.h>*/ |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
FILE(Cons1); |
/* CGA compatible registers value */ |
#define CURSOR_POS_MSB 0x0E |
#define CURSOR_POS_LSB 0x0F |
#define CURSOR_START 0x0A |
#define CURSOR_END 0x0B |
/* CGA compatible registers */ |
#define CGA_INDEX_REG 0x3D4 |
#define CGA_DATA_REG 0x3D5 |
/* Standard tab size */ |
#define TAB_SIZE 8 |
/* Store bios settings */ |
static unsigned char bios_start,bios_end; |
BYTE bios_x, bios_y, bios_attr; |
/* Access directly to video & BIOS memory through linear addressing */ |
/* Active video page-buffer */ |
#define PAGE_SIZE 2048 |
int active_page = 0; |
int visual_page = 0; |
void bios_save(void) |
{ |
/* This function must be called to init CONSole output */ |
#if 1 |
bios_attr = lmempeekb((LIN_ADDR)0xB8000 + 159); |
bios_x = lmempeekb((LIN_ADDR)0x00450); |
bios_y = lmempeekb((LIN_ADDR)0x00451); |
bios_end = lmempeekb((LIN_ADDR)0x00460); |
bios_start = lmempeekb((LIN_ADDR)0x00461); |
active_page = visual_page = 0; |
#else |
LIN_ADDR p; |
p = (LIN_ADDR)(0xB8000 + 159); |
bios_attr = *p; |
p = (LIN_ADDR)0x00450; |
bios_x = *p; |
p = (LIN_ADDR)0x00451; |
bios_y = *p; |
p = (LIN_ADDR)0x00460; |
bios_end = *p; |
p = (LIN_ADDR)0x00461; |
bios_start = *p; |
active_page = visual_page = 0; |
#endif |
} |
void getcursorxy(int *x, int *y) |
{ |
*x = bios_x; |
*y = bios_y; |
} |
int get_attr(void) |
{ |
return bios_attr; |
} |
void cursor(int start,int end) |
{ |
/* Same thing as above; Set cursor scan line */ |
outp(CGA_INDEX_REG, CURSOR_START); |
outp(CGA_DATA_REG, start); |
outp(CGA_INDEX_REG, CURSOR_END); |
outp(CGA_DATA_REG, end); |
} |
void bios_restore(void) |
{ |
lmempokeb((LIN_ADDR)0x00450,bios_x); |
lmempokeb((LIN_ADDR)0x00451,bios_y); |
place(bios_x,bios_y); |
cursor(bios_start, bios_end); |
} |
void place(int x,int y) |
{ |
unsigned short cursor_word = x + y*80 + active_page*PAGE_SIZE; |
/* Set cursor position */ |
/* CGA is programmed writing first the Index register */ |
/* to specify what internal register we are accessing */ |
/* Then we load the Data register with the wanted val */ |
outp(CGA_INDEX_REG,CURSOR_POS_LSB); |
outp(CGA_DATA_REG,cursor_word & 0xFF); |
outp(CGA_INDEX_REG,CURSOR_POS_MSB); |
outp(CGA_DATA_REG,(cursor_word >> 8) & 0xFF); |
/* Adjust temporary cursor bios position */ |
bios_x = x; |
bios_y = y; |
} |
void _scroll(char attr,int x1,int y1,int x2,int y2) |
{ |
register int x,y; |
WORD xattr = (((WORD)attr) << 8) + ' ',w; |
LIN_ADDR v = (LIN_ADDR)(0xB8000 + active_page*(2*PAGE_SIZE)); |
for (y = y1+1; y <= y2; y++) |
for (x = x1; x <= x2; x++) { |
w = lmempeekw((LIN_ADDR)(v + 2*(y*80+x))); |
lmempokew((LIN_ADDR)(v + 2*((y-1)*80+x)),w); |
} |
for (x = x1; x <= x2; x++) |
lmempokew((LIN_ADDR)(v + 2*((y-1)*80+x)),xattr); |
} |
void scroll(void) |
{ |
_scroll(bios_attr,0,0,79,24); |
} |
void cputc(char c) |
{ |
static unsigned short scan_x,x,y; |
LIN_ADDR v = (LIN_ADDR)(0xB8000 + active_page*(2*PAGE_SIZE)); |
x = bios_x; |
y = bios_y; |
switch (c) { |
case '\t' : x += 8; |
if (x >= 80) { |
x = 0; |
if (y == 24) scroll(); |
else y++; |
} else { |
scan_x = 0; |
while ((scan_x+8) < x) scan_x += 8; |
x = scan_x; |
} |
break; |
case '\n' : x = 0; |
if (y == 24) scroll(); |
else y++; |
break; |
case '\b' : x--; |
lmempokeb((LIN_ADDR)(v + 2*(x + y*80)),' '); |
x++; |
break; |
default : lmempokeb((LIN_ADDR)(v + 2*(x + y*80)),c); |
x++; |
if (x > 80) { |
x = 0; |
if (y == 24) scroll(); |
else y++; |
} |
} |
place(x,y); |
} |
void cputs(char *s) |
{ |
char c; |
while (*s != '\0') { |
c = *s++; |
cputc(c); |
} |
} |
/shark/tags/rel_0_5/oslib/libcons/cons2.c |
---|
0,0 → 1,130 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions - part 2 */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
/* #include <xsys.h>*/ |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
FILE(Cons2); |
#define PAGE_SIZE 2048 |
#define PAGE_MAX 8 |
/* CGA compatible registers */ |
#define CGA_INDEX_REG 0x3D4 |
#define CGA_DATA_REG 0x3D5 |
#define VIDEO_ADDRESS_MSB 0x0C |
#define VIDEO_ADDRESS_LSB 0x0D |
extern int active_page; |
extern int visual_page; |
static int curs_x[PAGE_MAX]; |
static int curs_y[PAGE_MAX]; |
extern BYTE bios_x, bios_y, bios_attr; |
void set_visual_page(int page) |
{ |
unsigned short page_offset; |
page_offset = page * PAGE_SIZE; |
visual_page = page; |
outp(CGA_INDEX_REG, VIDEO_ADDRESS_LSB); |
outp(CGA_DATA_REG, page_offset & 0xFF); |
outp(CGA_INDEX_REG, VIDEO_ADDRESS_MSB); |
outp(CGA_DATA_REG, (page_offset >> 8) & 0xFF); |
} |
void set_active_page(int page) |
{ |
curs_x[active_page] = bios_x; |
curs_y[active_page] = bios_y; |
bios_x = curs_x[page]; |
bios_y = curs_y[page]; |
active_page = page; |
} |
int get_visual_page(void) |
{ |
return(visual_page); |
} |
int get_active_page(void) |
{ |
return(active_page); |
} |
void _clear(char c,char attr,int x1,int y1,int x2,int y2) |
{ |
register int i,j; |
WORD w = attr; |
w <<= 8; w |= c; |
for (i = x1; i <= x2; i++) |
for (j = y1; j <= y2; j++) |
lmempokew((LIN_ADDR)(0xB8000 + 2*i+160*j + 2*active_page*PAGE_SIZE),w); |
place(x1,y1); |
bios_y = y1; |
bios_x = x1; |
} |
void clear() |
{ |
_clear(' ',bios_attr,0,0,79,24); |
} |
void puts_xy(int x,int y,char attr,char *s) |
{ |
LIN_ADDR v = (LIN_ADDR)(0xB8000 + (80*y+x)*2 + active_page*(2*PAGE_SIZE)); |
while (*s != 0) { |
/* REMEMBER! This is a macro! v++ is out to prevent side-effects */ |
lmempokeb(v,*s); s++; v++; |
lmempokeb(v,attr); v++; |
} |
} |
void putc_xy(int x,int y,char attr,char c) |
{ |
LIN_ADDR v = (LIN_ADDR)(0xB8000 + (80*y+x)*2 + active_page*(2*PAGE_SIZE)); |
/* REMEMBER! This is a macro! v++ is out to prevent side-effects */ |
lmempokeb(v,c); v++; |
lmempokeb(v,attr); |
} |
char getc_xy(int x,int y,char *attr,char *c) |
{ |
LIN_ADDR v = (LIN_ADDR)(0xB8000 + (80*y+x)*2 + active_page*(2*PAGE_SIZE)); |
char r; |
r = lmempeekb(v); v++; |
if (c != NULL) *c = r; |
r = lmempeekb(v); |
if (attr != NULL) *attr = r; |
return(r); |
} |
/shark/tags/rel_0_5/oslib/libcons/message.c |
---|
0,0 → 1,45 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
FILE(message); |
int message(char *fmt,...) |
{ |
static char cbuf[500]; |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vksprintf(cbuf,fmt,parms); |
va_end(parms); |
cputs(cbuf); |
return(result); |
} |
/shark/tags/rel_0_5/oslib/libcons/cprintf.c |
---|
0,0 → 1,57 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
FILE(cprintf); |
int cprintf(char *fmt,...) |
{ |
static char cbuf[500]; |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vsprintf(cbuf,fmt,parms); |
va_end(parms); |
cputs(cbuf); |
return(result); |
} |
int printf_xy(int x,int y,char attr,char *fmt,...) |
{ |
char cbuf[200]; |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vsprintf(cbuf,fmt,parms); |
va_end(parms); |
puts_xy(x,y,attr,cbuf); |
return(result); |
} |
/shark/tags/rel_0_5/oslib/libcons/makefile |
---|
0,0 → 1,53 |
# Standard library for X/COFF applications |
# Makefile for GNU MAKE & GCC 2.8.0 |
ifndef BASE |
BASE = .. |
BASEDOS = .. |
endif |
include $(BASE)/config.mk |
#C_OPT += -DPROFILE |
#ASM_OPT += -DPROFILE |
OBJS = cons1.o \ |
cons2.o \ |
cprintf.o \ |
message.o |
.PHONY : clean allclean info install |
info : |
@echo "OSLib Makefile" |
@echo "Chose: all, install, clean" |
all : libcons.a |
install : libcons.a $(LIB_DIR) |
$(CP) libcons.a $(LIB_DIR) |
$(LIB_DIR) : |
$(MKDIR) $(LIB_DIR) |
clean : |
$(RM) *.o |
$(RM) *.err |
$(RM) libcons.a |
allclean : |
echo # XTN Library dependencies > deps |
$(RM) $(LIB_PATH)libcons.a |
deps: $(OBJS:.o=.c) |
$(CC) $(C_OPT) -M $(OBJS:.o=.c) > deps |
# |
# The library!! |
# |
libcons.a : $(OBJS) |
$(AR) rs libcons.a $(OBJS) |
ifeq (deps,$(wildcard deps)) |
include deps |
endif |
/shark/tags/rel_0_5/oslib/makefile |
---|
1,19 → 1,27 |
include config.mk |
all: |
make -C xlib all |
make -C libm all |
make -C libc all |
make -C kl all |
make -C libcons all |
make -C kl all |
install: |
make -C xlib install |
make -C libm install |
make -C libc install |
make -C kl install |
# make -C examples all |
make -C libcons install |
make -C kl install |
#make -C examples all |
clean: |
make -C xlib clean |
make -C libm clean |
make -C libc clean |
make -C kl clean |
# make -C examples clean |
make -C libcons clean |
make -C kl clean |
#make -C examples clean |
allclean: clean |
$(RMDIR) lib |
/shark/tags/rel_0_5/oslib/examples/biosdemo.c |
---|
29,13 → 29,57 |
#include <ll/stdlib.h> |
#define T 1000 |
#if 1 |
#define WAIT() for (w = 0; w < 0xFFFFFFFF; w++) |
#else |
#define WAIT() for (w = 0; w < 0xFFFFF; w++) |
#endif |
static unsigned long int w; |
#define __VM86__ |
#ifdef __VM86__ |
//void emulate(void) |
void emulate(DWORD intnum, struct registers r) |
{ |
TSS *vm86_tss; |
DWORD *bos; |
DWORD isr_cs, isr_eip; |
WORD *old_esp; |
DWORD *IRQTable_entry; |
CONTEXT c = get_TR(); |
vm86_tss = vm86_get_tss(); |
bos = (DWORD *)vm86_tss->esp0; |
if (c == X_VM86_TSS) { |
/* |
message("Entering ESP: %lx (= 0x%lx?)\n", |
(DWORD)(tos + 9), vm86_tss->esp0); |
message("Old EIP: 0x%lx 0x%lx\n", *(tos + 9), *(bos - 9)); |
message("Old CS: 0x%x 0x%x\n", (WORD)(*(tos + 10)), (WORD)*(bos - 8)); |
message("Old EFlags: 0x%lx 0x%lx\n", *(tos + 11), *(bos - 7)); |
message("Old ESP: 0x%lx 0x%lx\n", *(tos + 12), *(bos - 6)); |
message("Emulate, please!!!\n"); |
*/ |
old_esp = (WORD *)(*(bos - 6) + (*(bos - 5) << 4)); |
// *(old_esp - 1) = /*(WORD)(*(bos - 7))*/ CPU_FLAG_VM | CPU_FLAG_IOPL; |
r.flags = CPU_FLAG_VM | CPU_FLAG_IOPL; |
*(old_esp - 2) = (WORD)(*(bos - 8)); |
*(old_esp - 3) = (WORD)(*(bos - 9)); |
*(bos - 6) -= 6; |
/* We are emulating INT 0x6d */ |
IRQTable_entry = (void *)(0L); |
isr_cs= ((IRQTable_entry[0x6d]) & 0xFFFF0000) >> 16; |
isr_eip = ((IRQTable_entry[0x6d]) & 0x0000FFFF); |
/* |
message("I have to call 0x%lx:0x%lx\n", isr_cs, isr_eip); |
*/ |
*(bos - 8) = isr_cs; |
*(bos - 9) = isr_eip; |
} |
} |
void vm86BIOSDemo(void) |
{ |
X_REGS16 ir,or; |
72,9 → 116,22 |
register int i; |
/* Set video mode */ |
ir.h.ah = 0; |
#if 0 |
ir.h.al = 0x03; |
vm86_callBIOS(0x10,&ir,&or,&sr); |
ir.h.ah = 0x0C; |
ir.h.al = i % 16; |
ir.x.bx = 0; |
ir.x.dx = i+40; |
ir.x.cx = i+100; |
vm86_callBIOS(0x10,&ir,&or,&sr); |
#else |
ir.h.al = 0x12; |
vm86_callBIOS(0x10,&ir,&or,&sr); |
#if 1 |
/* Put some pixels */ |
for (i = 0; i < 200; i++) { |
ir.h.ah = 0x0C; |
112,7 → 169,13 |
message("CX=%x\n",c); |
for (i = 0; i < 0x4F000; i++); |
#ifdef __VM86__ |
vm86_init(); |
vm86_init(); |
l1_int_bind(0x6d, emulate); |
/* |
l1_irq_bind(0x6d, emulate); |
*/ |
BIOSDemo(); |
#else |
XBIOSDemo(); |
/shark/tags/rel_0_5/oslib/examples/mbdemo.c |
---|
36,6 → 36,7 |
struct multiboot_info *mbi; |
DWORD lbase, hbase; |
DWORD lsize, hsize; |
int eXtender = 0; |
sp1 = get_SP(); |
cli(); |
54,6 → 55,12 |
message("LowLevel started...\n"); |
message("MultiBoot informations:\n"); |
if (mbi->flags & MB_INFO_BOOT_LOADER_NAME) { |
message("Loader Name provided: %s\n", (char *)mbi->boot_loader_name); |
if (*((char *)(mbi->boot_loader_name)) == 'X') { |
eXtender = 1; |
} |
} |
if (mbi->flags & MB_INFO_MEMORY) { |
message("\tMemory informations OK\n"); |
lsize = mbi->mem_lower * 1024; |
60,7 → 67,7 |
hsize = mbi->mem_upper * 1024; |
message("Mem Lower: %lx %lu\n", lsize, lsize); |
message("Mem Upper: %lx %lu\n", hsize, hsize); |
if (mbi->flags & MB_INFO_USEGDT) { |
if (eXtender) { |
lbase = mbi->mem_lowbase; |
hbase = mbi->mem_upbase; |
} else { |
92,7 → 99,7 |
if (mbi->flags & MB_INFO_MEM_MAP) { |
message("\tMemory map provided\n"); |
} |
if (mbi->flags & MB_INFO_USEGDT) { |
if (eXtender) { |
message("\tLoaded through X\n"); |
} |
cli(); |
/shark/tags/rel_0_5/oslib/examples/vmdemo.c |
---|
24,6 → 24,9 |
#include <ll/ll.h> |
#define T 1000 |
int a; /* This must be global, otherwise the compiler optimization will |
remove the division by 0... |
*/ |
int main (int argc, char *argv[]) |
{ |
53,6 → 56,7 |
return 1; |
*/ |
l1_init(); |
a = 1 / 0; /* Test the exception handler... */ |
l1_end(); |
return 1; |
/shark/tags/rel_0_5/oslib/examples/makefile |
---|
10,7 → 10,7 |
all: mbdemo.xtn timetest.xtn eventdem.xtn vmdemo.xtn \ |
ctxswdem.xtn scheddem.xtn cpudemo.xtn biosdemo.xtn \ |
asdemo.xtn |
asdemo.xtn kerndem.xtn |
%.ftp: %.xtn |
ncftpput -u ll -p example thorin . $< |
26,6 → 26,10 |
# Demo |
# |
kerndem.xtn: syscalls.o $(LIB_PATH)/libhc.a $(LIB_PATH)/libhm.a $(LIB_PATH)/libhx.a $(LIB_PATH)/libkl.a |
$(LD) $(LINK_OPT) $(LIB_PATH)x0.o syscalls.o --start-group -lhc -lhm -lhx -lkl -lcons --end-group -o $@ |
%.xtn : %.o $(LIB_PATH)/libhc.a $(LIB_PATH)/libhm.a $(LIB_PATH)/libhx.a $(LIB_PATH)/libkl.a |
$(LD) $(LINK_OPT) $(LIB_PATH)x0.o $< --start-group -lhc -lhm -lhx -lkl --end-group -o $@ |
$(LD) $(LINK_OPT) $(LIB_PATH)x0.o $< --start-group -lhc -lhm -lhx -lkl -lcons --end-group -o $@ |
# $(LD) $(LINK_OPT) $(LIB_PATH)x0.o $< --start-group -lhc -lhx -lkl --end-group -o $@ |
/shark/tags/rel_0_5/oslib/examples/syscalls.c |
---|
0,0 → 1,203 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Address Spaces test file */ |
#include <ll/i386/stdlib.h> |
#include <ll/i386/error.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/farptr.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/aspace.h> |
#include <ll/sys/ll/event.h> |
#include <ll/string.h> |
#define USE_NEW_HANDLERS |
#define T 1000 |
#define WAIT() for (w = 0; w < 0x5FFFFF; w++) |
extern DWORD GDT_base; |
extern void int0x31(void); |
#ifndef USE_NEW_HANDLERS |
struct regs { |
DWORD flags; |
DWORD egs; |
DWORD efs; |
DWORD ees; |
DWORD eds; |
DWORD edi; |
DWORD esi; |
DWORD ebp; |
DWORD esp; |
DWORD ebx; |
DWORD edx; |
DWORD ecx; |
DWORD eax; |
}; |
#endif |
BYTE space[2048]; |
WORD th1, th2, thm; |
char outstring[] = "Hi there!!!\n"; |
#ifdef USE_NEW_HANDLERS |
void chandler(DWORD intnum, struct registers r) |
#else |
void chandler(struct regs r, DWORD intnum) |
#endif |
{ |
message("[System Call] EAX = 0x%lx EBX = 0x%lx ECX = 0x%lx...\n", |
r.eax, r.ebx, r.ecx); |
if (r.eax == 1) { |
message("Exit!!!\n"); |
ll_context_load(thm); |
} |
if (r.eax == 2) { |
char string[20]; |
DWORD p; |
unsigned int size; |
p = GDT_read(r.eds, NULL, NULL, NULL); |
p += r.ebx; |
size = r.ecx; |
if (size > 20) { |
size = 20; |
} |
#if 0 |
message("Buffer @0x%lx, len %u\n", p, size); |
l1_end(); |
sti(); |
l1_exit(0); |
#endif |
memcpy(string, (void *)p, size); |
string[19] = 0; |
message("Write...\n"); |
message("%s", string); |
return; |
} |
message("Unsupported System Call!!!\n"); |
} |
/* For now, this is not called */ |
void killer(void) |
{ |
cli(); |
message("Killer!!!\n"); |
ll_context_load(thm); |
} |
/* |
And this is the thread that runs in the new AS... It cannot call |
any function (it is alone in its AS), so it simply plots a star |
on the screen and loops waiting for an event that switches to the |
main thread. |
*/ |
void nullfun(void *p) |
{ |
/* Some asm to write on the screen (we cannot use libc... it is not |
linked in this AS */ |
__asm__ __volatile__ ("movl $2, %eax"); |
__asm__ __volatile__ ("movl $1000, %ebx"); |
__asm__ __volatile__ ("movl $16, %ecx"); |
__asm__ __volatile__ ("int $0x31"); |
__asm__ __volatile__ ("movl $1, %eax"); |
__asm__ __volatile__ ("int $0x31"); |
/* should not arrive here... */ |
for(;;); |
halt(); |
} |
int main (int argc, char *argv[]) |
{ |
DWORD sp1, sp2; |
void *res; |
AS as, ds; |
int ok; |
sp1 = get_SP(); |
cli(); |
res = ll_init(); |
if (res == NULL) { |
message("Error in LowLevel initialization code...\n"); |
sti(); |
l1_exit(-1); |
} |
message("LowLevel started...\n"); |
#ifdef USE_NEW_HANDLERS |
l1_int_bind(0x31, chandler); |
#else |
IDT_place(0x31, int0x31); |
#endif |
as_init(); |
message("Creating an Address Space\n"); |
as = as_create(); |
message("Created: ID = %d %x\n", as, as); |
message("Binding array @ 0x%lx\n", (DWORD)space); |
ok = as_bind(as, (DWORD)space, 0, sizeof(space)); |
if (ok < 0) { |
message("Error in as_bind!!!\n"); |
} else { |
message("Bound\n"); |
} |
ds = get_DS(); |
/* Let's create the image of the process... |
* 0 --> 1000 : text |
* 1000 --> 1000 + strlen(outstring) : initialized data |
* ? <-- 2048 : stack |
*/ |
fmemcpy(as, 0, ds, (DWORD)nullfun, 1000); |
fmemcpy(as, 1000, ds, (DWORD)outstring, strlen(outstring)); |
/* Create a thread (in our AS) and a task (in a different AS) */ |
th1 = ll_context_create(0, (void *)2048, NULL,killer, 0); |
ll_context_setspace(th1, as); |
/* Save our context, in order to permit to switch back to main */ |
thm = ll_context_save(); |
message("I am thread %x\n", thm); |
message("Thread 1 created\n"); |
message("Switching to it...\n"); |
ll_context_load(th1); |
message("Back to Main\n"); |
cli(); |
ll_end(); |
sp2 = get_SP(); |
message("End reached!\n"); |
message("Actual stack : %lx - ", sp2); |
message("Begin stack : %lx\n", sp1); |
message("Check if same : %s\n",sp1 == sp2 ? "Ok :-)" : "No :-("); |
return 1; |
} |
/shark/tags/rel_0_5/oslib/xlib/vm86-exc.s |
---|
File deleted |
/shark/tags/rel_0_5/oslib/xlib/x1.c |
---|
63,7 → 63,7 |
/* function __CHK to detect it! The compiler place it whenever */ |
/* it calls a function to detect overflow */ |
DWORD _stkbase; |
DWORD _stkbase; |
DWORD _stktop; |
/* This is some extra stuff we need to compile with argument */ |
72,7 → 72,11 |
typedef char *charp; |
charp _argv[100]; |
extern void main(int argc, char *argv[]); |
#ifndef MAIN |
#define MAIN main |
#endif |
extern void MAIN(int argc,char *argv[]); |
extern void bios_save(void); |
extern void bios_restore(void); |
83,93 → 87,61 |
} |
struct multiboot_info *mbi_address(void) |
struct multiboot_info * mbi_address(void) |
{ |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern struct multiboot_info *mbi; |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern struct multiboot_info *mbi; |
return (mbi); |
return (mbi); |
} |
#ifndef __NOH4__ |
void __kernel_init__(struct multiboot_info *m); |
void _startup(void) |
{ |
struct multiboot_info *mbi = mbi_address(); |
register int i = 0; |
char temp[1000]; |
struct multiboot_info *mbi = mbi_address(); |
char *cmdline = (char *)(mbi->cmdline); |
bios_save(); |
if (!(mbi->flags & MB_INFO_MEMORY)) { |
cputs("X/Runtime library error!!! Unable to find memory information!\n"); |
l1_exit(-1); |
} |
/* Call init procedure using standard C convention */ |
/* Remember you cannot call any console I/O function */ |
/* if you do not call bios_save() */ |
#ifdef __DUMP_MEM__ |
message("X/MEM : %u\n", mbi->mem_upper); |
message("DOS/MEM : %u\n", mbi->mem_lower); |
message("x_bios Size : %u\n", sizeof(X_BIOSCALL)); |
message("mbi Size : %u\n", sizeof(struct multiboot_info)); |
message("Cmdline : %s\n", mbi->cmdline); |
/* message("Argc : %u",_argc); |
message("Argv[0] : %s / %s\n",_argv[0]); |
message("Argv[1] : %s\n",_argv[1]); |
message("Argv[2] : %s\n",_argv[2]); |
message("Argv[3] : %s\n",_argv[3]); */ |
#endif |
__kernel_init__(mbi); |
bios_restore(); |
} |
#else |
void _startup(void) |
{ |
register int i = 0; |
struct multiboot_info *mbi = mbi_address(); |
char *cmdline = (char *) (mbi->cmdline); |
if (!(mbi->flags & MB_INFO_MEMORY)) { |
cputs |
("X/Runtime library error!!! Unable to find memory information!\n"); |
l1_exit(-1); |
if (mbi->flags & MB_INFO_CMDLINE) { |
/* Build parameter list, up to 100 parms... */ |
while (cmdline[i] != 0 && i < 1000) { |
temp[i] = cmdline[i]; |
_argv[_argc] = &(temp[i]); |
while (cmdline[i] != ' ' && cmdline[i] != 0 && i < 1000) { |
temp[i] = cmdline[i]; |
i++; |
} |
if (cmdline[i] == ' ') { |
temp[i] = 0; i++; _argc++; |
} |
} |
temp[i] = 0; |
_argc++; |
} |
bios_save(); |
/* Call main procedure using standard C convention */ |
/* Remember you cannot call any console I/O function */ |
/* if you do not call bios_save() */ |
if (mbi->flags & MB_INFO_CMDLINE) { |
/* Build parameter list, up to 100 parms... */ |
while (cmdline[i] != 0) { |
_argv[_argc] = &(cmdline[i]); |
while (cmdline[i] != ' ' && cmdline[i] != 0) |
i++; |
if (cmdline[i] == ' ') { |
cmdline[i] = 0; |
i++; |
_argc++; |
} |
} |
_argc++; |
} |
bios_save(); |
/* Call main procedure using standard C convention */ |
/* Remember you cannot call any console I/O function */ |
/* if you do not call bios_save() */ |
#ifdef __DUMP_MEM__ |
message("X/MEM : %u\n", mbi->mem_upper); |
message("DOS/MEM : %u\n", mbi->mem_lower); |
message("x_bios Size : %u\n", sizeof(X_BIOSCALL)); |
message("mbi Size : %u\n", sizeof(struct multiboot_info)); |
message("Cmdline : %s\n", mbi->cmdline); |
message("Argc : %u", _argc); |
message("Argv[0] : %s / %s\n", _argv[0]); |
message("Argv[1] : %s\n", _argv[1]); |
message("Argv[2] : %s\n", _argv[2]); |
message("Argv[3] : %s\n", _argv[3]); |
message("X/MEM : %u\n",mbi->mem_upper); |
message("DOS/MEM : %u\n",mbi->mem_lower); |
message("x_bios Size : %u\n",sizeof(X_BIOSCALL)); |
message("mbi Size : %u\n",sizeof(struct multiboot_info)); |
message("Cmdline : %s\n",mbi->cmdline); |
message("Argc : %u\n",_argc); |
message("Argv[0] : %s\n",_argv[0]); |
message("Argv[1] : %s\n",_argv[1]); |
message("Argv[2] : %s\n",_argv[2]); |
message("Argv[3] : %s\n",_argv[3]); |
#endif |
main(_argc, _argv); |
bios_restore(); |
MAIN(_argc,_argv); |
bios_restore(); |
} |
#endif |
/shark/tags/rel_0_5/oslib/xlib/xinfo.c |
---|
26,7 → 26,7 |
#include <ll/i386/mb-info.h> |
#include <ll/i386/x-bios.h> |
FILE(X - Info); |
FILE(X-Info); |
/* |
The x_bios is stored in the low memory area and contains all the |
34,10 → 34,9 |
using a linear pointer, which is returned by the following call! |
*/ |
X_CALLBIOS *x_bios_address(void) |
X_CALLBIOS * x_bios_address(void) |
{ |
X_CALLBIOS *a = |
(X_CALLBIOS *) GDT_read(X_CALLBIOS_SEL, NULL, NULL, NULL); |
X_CALLBIOS *a = (X_CALLBIOS *)GDT_read(X_CALLBIOS_SEL,NULL,NULL,NULL); |
return (a); |
} |
46,30 → 45,32 |
WORD X_version(void) |
{ |
X_CALLBIOS *x_bios = x_bios_address(); |
return (x_bios->ver); |
return(x_bios->_ver); |
} |
void X_meminfo(LIN_ADDR * b1, DWORD * s1, LIN_ADDR * b2, DWORD * s2) |
void X_meminfo(LIN_ADDR *b1,DWORD *s1,LIN_ADDR *b2,DWORD *s2) |
{ |
struct multiboot_info *mbi = mbi_address(); |
if (mbi->flags & MB_INFO_USEGDT) { |
if (b1 != NULL) |
*b1 = (LIN_ADDR) mbi->mem_upbase; |
if (s1 != NULL) |
*s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) |
*b2 = (LIN_ADDR) mbi->mem_lowbase; |
if (s2 != NULL) |
*s2 = mbi->mem_lower * 1024; |
int x = 0; |
if (mbi->flags & MB_INFO_BOOT_LOADER_NAME) { |
char *name; |
name = (char *) mbi->boot_loader_name; |
if (*name == 'X') { |
x = 1; |
} |
} |
if (x) { |
if (b1 != NULL) *b1 = (LIN_ADDR)mbi->mem_upbase; |
if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) *b2 = (LIN_ADDR)mbi->mem_lowbase; |
if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
} else { |
if (b1 != NULL) |
*b1 = (LIN_ADDR) 0x100000; |
if (s1 != NULL) |
*s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) |
*b2 = (LIN_ADDR) 0x4000; |
if (s2 != NULL) |
*s2 = mbi->mem_lower * 1024; |
if (b1 != NULL) *b1 = (LIN_ADDR)0x100000; |
if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) *b2 = (LIN_ADDR)0x4000; |
if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
} |
/* |
#ifdef __OLD_MB__ |
91,12 → 92,11 |
/* Alert if a wrong addressing is intercepted */ |
/* Used only for debug purposes */ |
void check_addr(void *addr, char *caller) |
void check_addr(void *addr,char *caller) |
{ |
extern DWORD _stktop; |
if ((DWORD) (addr) < _stktop) { |
cprintf("CRISIS! Addr : %lx(%lx) Caller was %s\n", (DWORD) (addr), |
_stktop, caller); |
if ((DWORD)(addr) < _stktop) { |
cprintf("CRISIS! Addr : %lx(%lx) Caller was %s\n",(DWORD)(addr),_stktop,caller); |
} |
} |
#endif |
/shark/tags/rel_0_5/oslib/xlib/xbios.c |
---|
26,12 → 26,12 |
#include <ll/i386/x-bios.h> |
#include <ll/i386/mem.h> |
FILE(X - BIOS); |
FILE(X-BIOS); |
/* The interface between X (and 32 bit PM) and BIOS (which runs at 16 bits */ |
/* It works as int86() standard library call */ |
void X_callBIOS(int service, X_REGS16 * in, X_REGS16 * out, X_SREGS16 * s) |
void X_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s) |
{ |
/* Assembler gate JMP instruction */ |
extern void _x_callBIOS(void); |
38,14 → 38,14 |
X_CALLBIOS *xbc = x_bios_address(); |
/* Send interrupt request & register through the X_Info structure */ |
xbc->irqno = service; |
memcpy(&(xbc->ir), in, sizeof(X_REGS16)); |
memcpy(&(xbc->sr), s, sizeof(X_SREGS16)); |
xbc->_irqno = service; |
memcpy(&(xbc->_ir),in,sizeof(X_REGS16)); |
memcpy(&(xbc->_sr),s,sizeof(X_SREGS16)); |
/* Back to RM to execute the BIOS routine */ |
_x_callBIOS(); |
/* Get the return register values */ |
memcpy(out, &(xbc->or), sizeof(X_REGS16)); |
memcpy(s, &(xbc->sr), sizeof(X_SREGS16)); |
memcpy(out,&(xbc->_or),sizeof(X_REGS16)); |
memcpy(s,&(xbc->_sr),sizeof(X_SREGS16)); |
} |
/shark/tags/rel_0_5/oslib/xlib/idtinit.c |
---|
0,0 → 1,526 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-func.h> |
/* ll hardware interrupt hooks */ |
extern void h0(void); |
extern void h1(void); |
extern void h2(void); |
extern void h3(void); |
extern void h4(void); |
extern void h5(void); |
extern void h6(void); |
extern void exc7(void); |
extern void h8(void); |
extern void h9(void); |
extern void h10(void); |
extern void h11(void); |
extern void h12(void); |
extern void h13(void); |
extern void h14(void); |
extern void h15(void); |
extern void h16(void); |
extern void h17(void); |
extern void h18(void); |
extern void h19(void); |
extern void h20(void); |
extern void h21(void); |
extern void h22(void); |
extern void h23(void); |
extern void h24(void); |
extern void h25(void); |
extern void h26(void); |
extern void h27(void); |
extern void h28(void); |
extern void h29(void); |
extern void h30(void); |
extern void h31(void); |
extern void h32(void); |
extern void h33(void); |
extern void h34(void); |
extern void h35(void); |
extern void h36(void); |
extern void h37(void); |
extern void h38(void); |
extern void h39(void); |
extern void h40(void); |
extern void h41(void); |
extern void h42(void); |
extern void h43(void); |
extern void h44(void); |
extern void h45(void); |
extern void h46(void); |
extern void h47(void); |
extern void h48(void); |
extern void h49(void); |
extern void h50(void); |
extern void h51(void); |
extern void h52(void); |
extern void h53(void); |
extern void h54(void); |
extern void h55(void); |
extern void h56(void); |
extern void h57(void); |
extern void h58(void); |
extern void h59(void); |
extern void h60(void); |
extern void h61(void); |
extern void h62(void); |
extern void h63(void); |
extern void h64(void); |
extern void h65(void); |
extern void h66(void); |
extern void h67(void); |
extern void h68(void); |
extern void h69(void); |
extern void h70(void); |
extern void h71(void); |
extern void h72(void); |
extern void h73(void); |
extern void h74(void); |
extern void h75(void); |
extern void h76(void); |
extern void h77(void); |
extern void h78(void); |
extern void h79(void); |
extern void h80(void); |
extern void h81(void); |
extern void h82(void); |
extern void h83(void); |
extern void h84(void); |
extern void h85(void); |
extern void h86(void); |
extern void h87(void); |
extern void h88(void); |
extern void h89(void); |
extern void h90(void); |
extern void h91(void); |
extern void h92(void); |
extern void h93(void); |
extern void h94(void); |
extern void h95(void); |
extern void h96(void); |
extern void h97(void); |
extern void h98(void); |
extern void h99(void); |
extern void h100(void); |
extern void h101(void); |
extern void h102(void); |
extern void h103(void); |
extern void h104(void); |
extern void h105(void); |
extern void h106(void); |
extern void h107(void); |
extern void h108(void); |
extern void h109(void); |
extern void h110(void); |
extern void h111(void); |
extern void h112(void); |
extern void h113(void); |
extern void h114(void); |
extern void h115(void); |
extern void h116(void); |
extern void h117(void); |
extern void h118(void); |
extern void h119(void); |
extern void h120(void); |
extern void h121(void); |
extern void h122(void); |
extern void h123(void); |
extern void h124(void); |
extern void h125(void); |
extern void h126(void); |
extern void h127(void); |
extern void h128(void); |
extern void h129(void); |
extern void h130(void); |
extern void h131(void); |
extern void h132(void); |
extern void h133(void); |
extern void h134(void); |
extern void h135(void); |
extern void h136(void); |
extern void h137(void); |
extern void h138(void); |
extern void h139(void); |
extern void h140(void); |
extern void h141(void); |
extern void h142(void); |
extern void h143(void); |
extern void h144(void); |
extern void h145(void); |
extern void h146(void); |
extern void h147(void); |
extern void h148(void); |
extern void h149(void); |
extern void h150(void); |
extern void h151(void); |
extern void h152(void); |
extern void h153(void); |
extern void h154(void); |
extern void h155(void); |
extern void h156(void); |
extern void h157(void); |
extern void h158(void); |
extern void h159(void); |
extern void h160(void); |
extern void h161(void); |
extern void h162(void); |
extern void h163(void); |
extern void h164(void); |
extern void h165(void); |
extern void h166(void); |
extern void h167(void); |
extern void h168(void); |
extern void h169(void); |
extern void h170(void); |
extern void h171(void); |
extern void h172(void); |
extern void h173(void); |
extern void h174(void); |
extern void h175(void); |
extern void h176(void); |
extern void h177(void); |
extern void h178(void); |
extern void h179(void); |
extern void h180(void); |
extern void h181(void); |
extern void h182(void); |
extern void h183(void); |
extern void h184(void); |
extern void h185(void); |
extern void h186(void); |
extern void h187(void); |
extern void h188(void); |
extern void h189(void); |
extern void h190(void); |
extern void h191(void); |
extern void h192(void); |
extern void h193(void); |
extern void h194(void); |
extern void h195(void); |
extern void h196(void); |
extern void h197(void); |
extern void h198(void); |
extern void h199(void); |
extern void h200(void); |
extern void h201(void); |
extern void h202(void); |
extern void h203(void); |
extern void h204(void); |
extern void h205(void); |
extern void h206(void); |
extern void h207(void); |
extern void h208(void); |
extern void h209(void); |
extern void h210(void); |
extern void h211(void); |
extern void h212(void); |
extern void h213(void); |
extern void h214(void); |
extern void h215(void); |
extern void h216(void); |
extern void h217(void); |
extern void h218(void); |
extern void h219(void); |
extern void h220(void); |
extern void h221(void); |
extern void h222(void); |
extern void h223(void); |
extern void h224(void); |
extern void h225(void); |
extern void h226(void); |
extern void h227(void); |
extern void h228(void); |
extern void h229(void); |
extern void h230(void); |
extern void h231(void); |
extern void h232(void); |
extern void h233(void); |
extern void h234(void); |
extern void h235(void); |
extern void h236(void); |
extern void h237(void); |
extern void h238(void); |
extern void h239(void); |
extern void h240(void); |
extern void h241(void); |
extern void h242(void); |
extern void h243(void); |
extern void h244(void); |
extern void h245(void); |
extern void h246(void); |
extern void h247(void); |
extern void h248(void); |
extern void h249(void); |
extern void h250(void); |
extern void h251(void); |
extern void h252(void); |
extern void h253(void); |
extern void h254(void); |
extern void h255(void); |
void IDT_init(void) |
{ |
/* Insert the Exceptions handler into IDT */ |
IDT_place(0x00, h0); |
IDT_place(0x01, h1); |
IDT_place(0x02, h2); |
IDT_place(0x03, h3); |
IDT_place(0x04, h4); |
IDT_place(0x05, h5); |
IDT_place(0x06, h6); |
IDT_place(0x07, exc7); |
IDT_place(0x08, h8); |
IDT_place(0x09, h9); |
IDT_place(0x0A, h10); |
IDT_place(0x0B, h11); |
IDT_place(0x0C, h12); |
IDT_place(0x0D, h13); |
IDT_place(0x0E, h14); |
IDT_place(0x0F, h15); |
IDT_place(0x10, h16); |
IDT_place(0x11, h17); |
IDT_place(0x12, h18); |
IDT_place(0x13, h19); |
IDT_place(0x14, h20); |
IDT_place(0x15, h21); |
IDT_place(0x16, h22); |
IDT_place(0x17, h23); |
IDT_place(0x18, h24); |
IDT_place(0x19, h25); |
IDT_place(0x1A, h26); |
IDT_place(0x1B, h27); |
IDT_place(0x1C, h28); |
IDT_place(0x1D, h29); |
IDT_place(0x1E, h30); |
IDT_place(0x1F, h31); |
IDT_place(0x20, h32); |
IDT_place(0x21, h33); |
IDT_place(0x22, h34); |
IDT_place(0x23, h35); |
IDT_place(0x24, h36); |
IDT_place(0x25, h37); |
IDT_place(0x26, h38); |
IDT_place(0x27, h39); |
IDT_place(0x28, h40); |
IDT_place(0x29, h41); |
IDT_place(0x2A, h42); |
IDT_place(0x2B, h43); |
IDT_place(0x2C, h44); |
IDT_place(0x2D, h45); |
IDT_place(0x2E, h46); |
IDT_place(0x2F, h47); |
IDT_place(0x30, h48); |
IDT_place(0x31, h49); |
IDT_place(0x32, h50); |
IDT_place(0x33, h51); |
IDT_place(0x34, h52); |
IDT_place(0x35, h53); |
IDT_place(0x36, h54); |
IDT_place(0x37, h55); |
IDT_place(0x38, h56); |
IDT_place(0x39, h57); |
IDT_place(0x3A, h58); |
IDT_place(0x3B, h59); |
IDT_place(0x3C, h60); |
IDT_place(0x3D, h61); |
IDT_place(0x3E, h62); |
IDT_place(0x3F, h63); |
IDT_place(0x40, h64); |
IDT_place(0x41, h65); |
IDT_place(0x42, h66); |
IDT_place(0x43, h67); |
IDT_place(0x44, h68); |
IDT_place(0x45, h69); |
IDT_place(0x46, h70); |
IDT_place(0x47, h71); |
IDT_place(0x48, h72); |
IDT_place(0x49, h73); |
IDT_place(0x4A, h74); |
IDT_place(0x4B, h75); |
IDT_place(0x4C, h76); |
IDT_place(0x4D, h77); |
IDT_place(0x4E, h78); |
IDT_place(0x4F, h79); |
IDT_place(0x50, h80); |
IDT_place(0x51, h81); |
IDT_place(0x52, h82); |
IDT_place(0x53, h83); |
IDT_place(0x54, h84); |
IDT_place(0x55, h85); |
IDT_place(0x56, h86); |
IDT_place(0x57, h87); |
IDT_place(0x58, h88); |
IDT_place(0x59, h89); |
IDT_place(0x5A, h90); |
IDT_place(0x5B, h91); |
IDT_place(0x5C, h92); |
IDT_place(0x5D, h93); |
IDT_place(0x5E, h94); |
IDT_place(0x5F, h95); |
IDT_place(0x60, h96); |
IDT_place(0x61, h97); |
IDT_place(0x62, h98); |
IDT_place(0x63, h99); |
IDT_place(0x64, h100); |
IDT_place(0x65, h101); |
IDT_place(0x66, h102); |
IDT_place(0x67, h103); |
IDT_place(0x68, h104); |
IDT_place(0x69, h105); |
IDT_place(0x6A, h106); |
IDT_place(0x6B, h107); |
IDT_place(0x6C, h108); |
IDT_place(0x6D, h109); |
IDT_place(0x6E, h110); |
IDT_place(0x6F, h111); |
IDT_place(0x70, h112); |
IDT_place(0x71, h113); |
IDT_place(0x72, h114); |
IDT_place(0x73, h115); |
IDT_place(0x74, h116); |
IDT_place(0x75, h117); |
IDT_place(0x76, h118); |
IDT_place(0x77, h119); |
IDT_place(0x78, h120); |
IDT_place(0x79, h121); |
IDT_place(0x7A, h122); |
IDT_place(0x7B, h123); |
IDT_place(0x7C, h124); |
IDT_place(0x7D, h125); |
IDT_place(0x7E, h127); |
IDT_place(0x7F, h127); |
IDT_place(0x80, h128); |
IDT_place(0x81, h129); |
IDT_place(0x82, h130); |
IDT_place(0x83, h131); |
IDT_place(0x84, h132); |
IDT_place(0x85, h133); |
IDT_place(0x86, h134); |
IDT_place(0x87, h135); |
IDT_place(0x88, h136); |
IDT_place(0x89, h137); |
IDT_place(0x8A, h138); |
IDT_place(0x8B, h139); |
IDT_place(0x8C, h140); |
IDT_place(0x8D, h141); |
IDT_place(0x8E, h142); |
IDT_place(0x8F, h143); |
IDT_place(0x90, h144); |
IDT_place(0x91, h145); |
IDT_place(0x92, h146); |
IDT_place(0x93, h147); |
IDT_place(0x94, h148); |
IDT_place(0x95, h149); |
IDT_place(0x96, h150); |
IDT_place(0x97, h151); |
IDT_place(0x98, h152); |
IDT_place(0x99, h153); |
IDT_place(0x9A, h154); |
IDT_place(0x9B, h155); |
IDT_place(0x9C, h156); |
IDT_place(0x9D, h157); |
IDT_place(0x9E, h158); |
IDT_place(0x9F, h159); |
IDT_place(0xA0, h160); |
IDT_place(0xA1, h161); |
IDT_place(0xA2, h162); |
IDT_place(0xA3, h163); |
IDT_place(0xA4, h164); |
IDT_place(0xA5, h165); |
IDT_place(0xA6, h166); |
IDT_place(0xA7, h167); |
IDT_place(0xA8, h168); |
IDT_place(0xA9, h169); |
IDT_place(0xAA, h170); |
IDT_place(0xAB, h171); |
IDT_place(0xAC, h172); |
IDT_place(0xAD, h173); |
IDT_place(0xAE, h174); |
IDT_place(0xAF, h175); |
IDT_place(0xB0, h176); |
IDT_place(0xB1, h177); |
IDT_place(0xB2, h178); |
IDT_place(0xB3, h179); |
IDT_place(0xB4, h180); |
IDT_place(0xB5, h181); |
IDT_place(0xB6, h182); |
IDT_place(0xB7, h183); |
IDT_place(0xB8, h184); |
IDT_place(0xB9, h185); |
IDT_place(0xBA, h186); |
IDT_place(0xBB, h187); |
IDT_place(0xBC, h188); |
IDT_place(0xBD, h189); |
IDT_place(0xBE, h190); |
IDT_place(0xBF, h191); |
IDT_place(0xC0, h192); |
IDT_place(0xC1, h193); |
IDT_place(0xC2, h194); |
IDT_place(0xC3, h195); |
IDT_place(0xC4, h196); |
IDT_place(0xC5, h197); |
IDT_place(0xC6, h198); |
IDT_place(0xC7, h199); |
IDT_place(0xC8, h200); |
IDT_place(0xC9, h201); |
IDT_place(0xCA, h202); |
IDT_place(0xCB, h203); |
IDT_place(0xCC, h204); |
IDT_place(0xCD, h205); |
IDT_place(0xCE, h206); |
IDT_place(0xCF, h207); |
IDT_place(0xD0, h208); |
IDT_place(0xD1, h209); |
IDT_place(0xD2, h210); |
IDT_place(0xD3, h211); |
IDT_place(0xD4, h212); |
IDT_place(0xD5, h213); |
IDT_place(0xD6, h214); |
IDT_place(0xD7, h215); |
IDT_place(0xD8, h216); |
IDT_place(0xD9, h217); |
IDT_place(0xDA, h218); |
IDT_place(0xDB, h219); |
IDT_place(0xDC, h220); |
IDT_place(0xDD, h221); |
IDT_place(0xDE, h222); |
IDT_place(0xDF, h223); |
IDT_place(0xE0, h224); |
IDT_place(0xE1, h225); |
IDT_place(0xE2, h226); |
IDT_place(0xE3, h227); |
IDT_place(0xE4, h228); |
IDT_place(0xE5, h229); |
IDT_place(0xE6, h230); |
IDT_place(0xE7, h231); |
IDT_place(0xE8, h232); |
IDT_place(0xE9, h233); |
IDT_place(0xEA, h234); |
IDT_place(0xEB, h235); |
IDT_place(0xEC, h236); |
IDT_place(0xED, h237); |
IDT_place(0xEE, h238); |
IDT_place(0xEF, h239); |
IDT_place(0xF0, h240); |
IDT_place(0xF1, h241); |
IDT_place(0xF2, h242); |
IDT_place(0xF3, h243); |
IDT_place(0xF4, h244); |
IDT_place(0xF5, h245); |
IDT_place(0xF6, h246); |
IDT_place(0xF7, h247); |
IDT_place(0xF8, h248); |
IDT_place(0xF9, h249); |
IDT_place(0xFA, h250); |
IDT_place(0xFB, h251); |
IDT_place(0xFC, h252); |
IDT_place(0xFD, h253); |
IDT_place(0xFE, h254); |
IDT_place(0xFF, h255); |
} |
/shark/tags/rel_0_5/oslib/xlib/exc.s |
---|
33,10 → 33,8 |
ASMFILE(Exc) |
.globl SYMBOL_NAME(ll_irq_table) |
.globl SYMBOL_NAME(ll_exc_table) |
SYMBOL_NAME_LABEL(ll_irq_table) .space 64, 0 |
SYMBOL_NAME_LABEL(ll_exc_table) .space 64, 65 |
SYMBOL_NAME_LABEL(ll_irq_table) .space 1024, 0 |
.text |
48,6 → 46,7 |
/* These are the hardware handlers; they all jump to ll_handler setting */ |
/* the interrupt number into EAX & save the registers on stack */ |
INT(0) |
INT(1) |
INT(2) |
INT(3) |
54,7 → 53,6 |
INT(4) |
INT(5) |
INT(6) |
INT(7) |
INT(8) |
INT(9) |
INT(10) |
63,60 → 61,254 |
INT(13) |
INT(14) |
INT(15) |
INT(16) |
INT(17) |
INT(18) |
INT(19) |
INT(20) |
INT(21) |
INT(22) |
INT(23) |
INT(24) |
INT(25) |
INT(26) |
INT(27) |
INT(28) |
INT(29) |
INT(30) |
INT(31) |
#if 0 |
/* MPF... If we have an external FPU, it will generate |
* INT 13 instead of EXC 16... |
* We must remap it to EXC 16... |
*/ |
#if 1 |
SYMBOL_NAME_LABEL(h13_bis) |
/* Send EOI for 8086 coprocessor trick */ |
/* Send 0H on Coprocessor port 0F0H */ |
pushl %eax |
xorb %al, %al |
outb %al, $0x0F0 |
movb $0x020, %al |
outb %al, $0x0A0 |
outb %al, $0x020 |
popl %eax |
movl $16, %eax |
jmp ll_handler2 |
#else |
SYMBOL_NAME_LABEL(h13_bis) pushal |
/* Send EOI for 8086 coprocessor trick */ |
/* Send 0H on Coprocessor port 0F0H */ |
xorb %al,%al |
outb %al,$0x0F0 |
movb $0x020,%al |
outb %al,$0x0A0 |
outb %al,$0x020 |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
movw %ax,%ds |
movl $(MATH_EXC),%eax |
pushl %eax |
/* LL_ABORT OR EXC_HOOK?? */ |
/*THIS SURELY WRONG!!!! FIX IT!!!! Gerardo, help me!!! */ |
hlt |
/* call SYMBOL_NAME(ll_abort) */ |
addl $4,%esp |
popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
ret |
#endif |
#endif |
INT(32) |
INT(33) |
INT(34) |
INT(35) |
INT(36) |
INT(37) |
INT(38) |
INT(39) |
INT(40) |
INT(41) |
INT(42) |
INT(43) |
INT(44) |
INT(45) |
INT(46) |
INT(47) |
INT(48) |
INT(49) |
INT(50) |
INT(51) |
INT(52) |
INT(53) |
INT(54) |
INT(55) |
INT(56) |
INT(57) |
INT(58) |
INT(59) |
INT(60) |
INT(61) |
INT(62) |
INT(63) |
/* Master PIC... (int 0x40, see ll/i386/pic.h)*/ |
INT_1(64) |
INT_1(65) |
INT_1(66) |
INT_1(67) |
INT_1(68) |
INT_1(69) |
INT_1(70) |
INT_1(71) |
INT(72) |
INT(73) |
INT(74) |
INT(75) |
INT(76) |
INT(77) |
INT(78) |
INT(79) |
INT(80) |
INT(81) |
INT(82) |
INT(83) |
INT(84) |
INT(85) |
INT(86) |
INT(87) |
INT(88) |
INT(89) |
INT(90) |
INT(91) |
INT(92) |
INT(93) |
INT(94) |
INT(95) |
INT(96) |
INT(97) |
INT(98) |
INT(99) |
INT(100) |
INT(101) |
INT(102) |
INT(103) |
INT(104) |
INT(105) |
INT(106) |
INT(107) |
INT(108) |
INT(109) |
INT(110) |
INT(111) |
/* Slave PIC... (int 0x70, see ll/i386/pic.h)*/ |
INT_2(112) |
INT_2(113) |
INT_2(114) |
INT_2(115) |
INT_2(116) |
INT_2(117) |
INT_2(118) |
INT_2(119) |
INT(120) |
INT(121) |
INT(122) |
INT(123) |
INT(124) |
INT(125) |
INT(126) |
INT(127) |
INT(128) |
INT(129) |
INT(130) |
INT(131) |
INT(132) |
INT(133) |
INT(134) |
INT(135) |
INT(136) |
INT(137) |
INT(138) |
INT(139) |
INT(140) |
INT(141) |
INT(142) |
INT(143) |
INT(144) |
INT(145) |
INT(146) |
INT(147) |
INT(148) |
INT(149) |
INT(150) |
INT(151) |
INT(152) |
INT(153) |
INT(154) |
INT(155) |
INT(156) |
INT(157) |
INT(158) |
INT(159) |
INT(160) |
INT(161) |
INT(162) |
INT(163) |
INT(164) |
INT(165) |
INT(166) |
INT(167) |
INT(168) |
INT(169) |
INT(170) |
INT(171) |
INT(172) |
INT(173) |
INT(174) |
INT(175) |
INT(176) |
INT(177) |
INT(178) |
INT(179) |
INT(180) |
INT(181) |
INT(182) |
INT(183) |
INT(184) |
INT(185) |
INT(186) |
INT(187) |
INT(188) |
INT(189) |
INT(190) |
INT(191) |
INT(192) |
INT(193) |
INT(194) |
INT(195) |
INT(196) |
INT(197) |
INT(198) |
INT(199) |
INT(200) |
INT(201) |
INT(202) |
INT(203) |
INT(204) |
INT(205) |
INT(206) |
INT(207) |
INT(208) |
INT(209) |
INT(210) |
INT(211) |
INT(212) |
INT(213) |
INT(214) |
INT(215) |
INT(216) |
INT(217) |
INT(218) |
INT(219) |
INT(220) |
INT(221) |
INT(222) |
INT(223) |
INT(224) |
INT(225) |
INT(226) |
INT(227) |
INT(228) |
INT(229) |
INT(230) |
INT(231) |
INT(232) |
INT(233) |
INT(234) |
INT(235) |
INT(236) |
INT(237) |
INT(238) |
INT(239) |
INT(240) |
INT(241) |
INT(242) |
INT(243) |
INT(244) |
INT(245) |
INT(246) |
INT(247) |
INT(248) |
INT(249) |
INT(250) |
INT(251) |
INT(252) |
INT(253) |
INT(254) |
INT(255) |
/* The ll_handler process the request using the kernel function act_int() */ |
/* Then sends EOI & schedules any eventual new task! */ |
128,7 → 320,7 |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
pushl %gs |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
136,6 → 328,8 |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
148,7 → 342,6 |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
#if 0 |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
171,11 → 364,10 |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %bx |
movw %bx, %ss |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
#endif |
pushl %eax |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
182,20 → 374,10 |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
#if 0 |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
#endif |
/* Send EOI to master & slave (if necessary) PIC */ |
movb $0x20,%al |
cmpl $0x08,%ebx |
jb eoi_master |
eoi_slave: movl $0xA0,%edx |
outb %al,%dx |
eoi_master: movl $0x20,%edx |
outb %al,%dx |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
213,41 → 395,89 |
popl %ds |
popal |
iret |
EXC(0) |
EXC(1) |
EXC(2) |
EXC(3) |
EXC(4) |
EXC(5) |
EXC(6) |
EXC(8) |
EXC(9) |
EXC(10) |
EXC(11) |
EXC(12) |
EXC(13) |
EXC(14) |
EXC(15) |
EXC(16) |
/* OK, this is Exception 7, and it is generated when an ESC or WAIT |
* intruction is reached, and the MP and TS bits are set... Basically, |
* it means that the FPU context must be switched |
*/ |
SYMBOL_NAME_LABEL(exc7) pushal |
pushl %ds |
ll_handler_master_pic: |
/* We do not know what is the DS value */ |
/* Then we save it & set it correctly */ |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
movw %ax,%ds |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
/* CLD is necessary when calling a C function */ |
cld |
call SYMBOL_NAME(ll_FPU_hook) |
popl %gs |
/* The following could be optimized a little... */ |
popl %eax |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
pushl %eax |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
/* Send EOI to master PIC */ |
movb $0x20,%al |
movl $0x20,%edx |
outb %al,%dx |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw JmpSel,%ax |
je NoPreempt4 |
movw %ax,JmpSel |
ljmp JmpZone |
#endif |
NoPreempt4: popl %gs |
popl %fs |
popl %es |
popl %ss |
254,22 → 484,48 |
popl %ds |
popal |
iret |
ll_handler_slave_pic: |
/* We do not know what is the DS value */ |
/* Then we save it & set it correctly */ |
ll_handler2: |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%ds |
movw %ax,%es |
/* Again, the following could be optimized... */ |
/* |
If the Exception raised in a different address space, we have to |
access the task stack from the kernel address space (the linear one...) |
*/ |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
/* CLD is necessary when calling a C function */ |
cld |
/* The following could be optimized a little... */ |
popl %eax |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
281,17 → 537,68 |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %bx |
movw %bx, %ss |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
pushl %eax |
call *SYMBOL_NAME(ll_exc_table)(, %eax, 4) |
addl $4,%esp |
/* Restore the stack pointer!!! */ |
popl %eax |
popl %ebx |
movw %ax, %ss |
subl %ebx, %esp |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
/* Send EOI to master & slave PIC */ |
movb $0x20,%al |
movl $0xA0,%edx |
outb %al,%dx |
movl $0x20,%edx |
outb %al,%dx |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw JmpSel,%ax |
je NoPreempt5 |
movw %ax,JmpSel |
ljmp JmpZone |
#endif |
NoPreempt5: popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
/* OK, this is Exception 7, and it is generated when an ESC or WAIT |
* intruction is reached, and the MP and TS bits are set... Basically, |
* it means that the FPU context must be switched |
*/ |
SYMBOL_NAME_LABEL(exc7) pushal |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
movw %ax,%ds |
cld |
call SYMBOL_NAME(ll_FPU_hook) |
popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
/shark/tags/rel_0_5/oslib/xlib/vm86.c |
---|
27,14 → 27,16 |
* native VBE compliant Video card, without writing an explicit driver |
*/ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
FILE(VM - 86); |
FILE(VM-86); |
/* |
#define __LL_DEBUG__ |
42,10 → 44,12 |
#define __CHK_IO__ |
*/ |
#define VM86_STACK_SIZE 1024 |
#define VM86_STACK_SIZE 1024 |
extern DWORD ll_irq_table[256]; |
/* TSS optional section */ |
static BYTE vm86_stack0[VM86_STACK_SIZE]; |
static BYTE vm86_stack0[VM86_STACK_SIZE]; |
static struct { |
TSS t; |
55,76 → 59,77 |
static LIN_ADDR vm86_iretAddress; |
DWORD *GLOBesp; |
struct registers *global_regs; |
#ifdef __DUMB_CODE__ |
static LIN_ADDR vm86_code; |
static BYTE prova86[] = { |
0x1e, /* push ds */ |
0xb8, 0x00, 0xb8, /* mov ax,0xb800 */ |
0x8e, 0xd8, /* mov ds,ax */ |
0xbf, 0x9e, 0x00, /* mov di,0x009e (158) */ |
0xb0, 0x2a, /* mov ax,'*' */ |
0x88, 0x05, /* mov ds:[di],al */ |
0x1f, /* pop ds */ |
0xcd, 0x40, /*??? */ |
#ifdef __CHK_IO__ |
0xb0, 0x00, /* movb $0x0,%al */ |
0x66, 0xba, 0x80, 0x00, /* movw $0x80,%dx */ |
0x66, 0xef, /* outw %ax, (%dx) */ |
0x1e, /* push ds */ |
0xb8,0x00,0xb8, /* mov ax,0xb800 */ |
0x8e,0xd8, /* mov ds,ax */ |
0xbf,0x9e,0x00, /* mov di,0x009e (158) */ |
0xb0,0x2a, /* mov ax,'*' */ |
0x88,0x05, /* mov ds:[di],al */ |
0x1f, /* pop ds */ |
0xcd, 0x40, /*???*/ |
#ifdef __CHK_IO__ |
0xb0, 0x00, /* movb $0x0,%al*/ |
0x66,0xba, 0x80, 0x00, /* movw $0x80,%dx */ |
0x66,0xef, /* outw %ax, (%dx) */ |
#endif |
0xcf, /* iret */ |
0xf4, /* hlt */ |
0}; |
#endif |
0xcf, /* iret */ |
0xf4, /* hlt */ |
0 |
}; |
#endif |
#ifdef __LL_DEBUG__ |
static BYTE vm86_retAddr[] = { |
0x1e, /* push ds */ |
0xb8, 0x00, 0xb8, /* mov ax,0xb800 */ |
0x8e, 0xd8, /* mov ds,ax */ |
0xbf, 0x3e, 0x01, /* mov di,0x013c (316) */ |
0xb0, '%', /* mov ax,'%' */ |
0x88, 0x05, /* mov ds:[di],al */ |
0x1f, /* pop ds */ |
0xcd, 0x48 |
}; /* int 0x48 */ |
0x1e, /* push ds */ |
0xb8,0x00,0xb8, /* mov ax,0xb800 */ |
0x8e,0xd8, /* mov ds,ax */ |
0xbf,0x3e,0x01, /* mov di,0x013c (316) */ |
0xb0,'%', /* mov ax,'%' */ |
0x88,0x05, /* mov ds:[di],al */ |
0x1f, /* pop ds */ |
0xcd, 0x48}; /* int 0x48 */ |
#else |
static BYTE vm86_retAddr[] = { 0xcd, 0x48 }; /* int 48h */ |
static BYTE vm86_retAddr[] = {0xcd, 0x48}; /* int 48h */ |
#endif |
TSS *vm86_get_tss(void) |
{ |
return &(vm86_TSS.t); |
} |
/* This is the return point from V86 mode, called through int 0x48 |
* (see vm86-exc.s). We double check that this function is called in |
* the V86 TSS. Otherwise, Panic!!! |
*/ |
void vm86_return(DWORD * tos) |
void vm86_return(DWORD n, struct registers r) |
{ |
CONTEXT c = get_TR(); |
#ifdef __LL_DEBUG__ |
DWORD cs, eip; |
DWORD cs,eip; |
void *esp; |
DWORD a; |
/* message("Gotta code=%d [0 called from GPF/1 int 0x48]\n",code);*/ |
#endif |
if (c == X_VM86_TSS) { |
GLOBesp = tos; |
global_regs = &r; |
#ifdef __LL_DEBUG__ |
message("TSS CS=%x IP=%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
message("Switching to %x\n", vm86_TSS.t.back_link); |
a = (DWORD) (vm86_iretAddress); |
cs = (a & 0xFF000) >> 4; |
eip = (a & 0xFFF); |
message("Real-Mode Address is CS=%lx IP=%lx\nLinear=%lx\n", cs, |
eip, a); |
esp = (void *) (tos); |
message("Stack frame: %p %lx %lx\n", |
esp, vm86_TSS.t.esp0, vm86_TSS.t.esp); |
message("%lx ", lmempeekd(esp)); /* bp */ |
message("%lx ", lmempeekd(esp + 4)); /* eip */ |
message("%lx ", lmempeekd(esp + 8)); /* 0x0d */ |
message("%lx\n", lmempeekd(esp + 12)); /* error code */ |
message("TSS CS=%x IP=%lx\n",vm86_TSS.t.cs,vm86_TSS.t.eip); |
message("Switching to %x\n", vm86_TSS.t.back_link); |
a = (DWORD)(vm86_iretAddress); |
cs = (a & 0xFF000) >> 4; |
eip = (a & 0xFFF); |
message("Real-Mode Address is CS=%lx IP=%lx\nLinear=%lx\n",cs,eip,a); |
esp = /* (void *)(tos)*/ 0x69; |
message("Stack frame: %p %lx %lx\n", |
esp, vm86_TSS.t.esp0, vm86_TSS.t.esp); |
message("%lx ",lmempeekd(esp)); /* bp */ |
message("%lx ",lmempeekd(esp+4)); /* eip */ |
message("%lx ",lmempeekd(esp+8)); /* 0x0d */ |
message("%lx\n",lmempeekd(esp+12)); /* error code */ |
/* The error code is given by the selector causing shifted and or-ed with |
3 bits: [LDT/GDT | IDT | Ext/Int] |
If IDT == 1 -> the fault was provoked bu an interrupt (Internal if the |
132,17 → 137,18 |
Else the LDT/GDT bit shows if the selector belongs to the LDT (if 1) |
or GDT (if 0) |
*/ |
message("%lx ", lmempeekd(esp + 16)); /* EIP of faulting instr */ |
message("%lx ", lmempeekd(esp + 20)); /* CS of faulting instr */ |
message("%lx ", lmempeekd(esp + 24)); /* EFLAGS */ |
message("%lx\n", lmempeekd(esp + 28)); /* old ESP */ |
message("%lx ", lmempeekd(esp + 32)); /* old SS */ |
message("%lx ", lmempeekd(esp + 36)); /* old ES */ |
message("%lx ", lmempeekd(esp + 40)); /* old DS */ |
message("%lx\n", lmempeekd(esp + 44)); /* old FS */ |
message("%lx ",lmempeekd(esp+16)); /* EIP of faulting instr */ |
message("%lx ",lmempeekd(esp+20)); /* CS of faulting instr*/ |
message("%lx ",lmempeekd(esp+24)); /* EFLAGS*/ |
message("%lx\n",lmempeekd(esp+28)); /* old ESP*/ |
message("%lx ",lmempeekd(esp+32)); /* old SS*/ |
message("%lx ",lmempeekd(esp+36)); /* old ES*/ |
message("%lx ",lmempeekd(esp+40)); /* old DS*/ |
message("%lx\n",lmempeekd(esp+44)); /* old FS*/ |
#endif |
ll_context_load(vm86_TSS.t.back_link); |
ll_context_load(vm86_TSS.t.back_link); |
} |
message("Here?\n"); |
halt(); |
} |
151,27 → 157,27 |
/* Just a debugging function; it dumps the status of the TSS */ |
void vm86_dump_TSS(void) |
{ |
BYTE acc, gran; |
DWORD base, lim; |
BYTE acc,gran; |
DWORD base,lim; |
message("vm86_TSS.t dump\n"); |
message("Flag: %lx\n", vm86_TSS.t.eflags); |
message("SS: %hx SP:%lx\n", vm86_TSS.t.ss, vm86_TSS.t.esp); |
message("Stack0: %hx:%lx\n", vm86_TSS.t.ss0, vm86_TSS.t.esp0); |
message("Stack1: %hx:%lx\n", vm86_TSS.t.ss1, vm86_TSS.t.esp1); |
message("Stack2: %hx:%lx\n", vm86_TSS.t.ss2, vm86_TSS.t.esp2); |
message("CS: %hx IP: %lx", vm86_TSS.t.cs, vm86_TSS.t.eip); |
message("DS: %hx\n", vm86_TSS.t.ds); |
base = GDT_read(X_VM86_TSS, &lim, &acc, &gran); |
message("Flag: %lx\n",vm86_TSS.t.eflags); |
message("SS: %hx SP:%lx\n", vm86_TSS.t.ss,vm86_TSS.t.esp); |
message("Stack0: %hx:%lx\n",vm86_TSS.t.ss0,vm86_TSS.t.esp0); |
message("Stack1: %hx:%lx\n",vm86_TSS.t.ss1,vm86_TSS.t.esp1); |
message("Stack2: %hx:%lx\n",vm86_TSS.t.ss2,vm86_TSS.t.esp2); |
message("CS: %hx IP: %lx",vm86_TSS.t.cs, vm86_TSS.t.eip); |
message("DS: %hx\n",vm86_TSS.t.ds); |
base = GDT_read(X_VM86_TSS,&lim,&acc,&gran); |
message("Base : %lx Lim : %lx Acc : %x Gran %x\n", |
base, lim, (unsigned) (acc), (unsigned) (gran)); |
base,lim,(unsigned)(acc),(unsigned)(gran)); |
} |
void vm86_init(void) |
{ |
int register i; |
/* Init the DOS memory allocator */ |
// DOS_mem_init(); |
DOS_mem_init(); |
/* First of all, we need to setup a GDT entries to |
* allow vm86 task execution. We just need a free 386 TSS, which |
178,29 → 184,33 |
* will be used to store the execution context of the virtual 8086 |
* task |
*/ |
GDT_place(X_VM86_TSS, (DWORD) (&vm86_TSS), |
sizeof(vm86_TSS), FREE_TSS386, GRAN_16); |
IDT_place(0x48, vm86_exc); |
GDT_place(X_VM86_TSS,(DWORD)(&vm86_TSS), |
sizeof(vm86_TSS),FREE_TSS386,GRAN_16); |
/* HACKME!!! */ |
// IDT_place(0x48,vm86_exc); |
l1_int_bind(0x48, vm86_return); |
// ll_irq_table[0x48] = (DWORD)vm86_return; |
/* Prepare a real-mode stack, obtaining it from the |
* DOS memory allocator! |
* 8K should be OK! Stack top is vm86_stack + SIZE! |
*/ |
vm86_stack = DOS_alloc(VM86_STACK_SIZE * 2); |
vm86_stack += VM86_STACK_SIZE / 2; |
vm86_stack = DOS_alloc(VM86_STACK_SIZE*2); |
vm86_stack += VM86_STACK_SIZE/2; |
/* Create a location of DOS memory containing the |
* opcode sequence which will generate a GPF |
* We use the privileged instruction hlt to do it |
*/ |
vm86_iretAddress = DOS_alloc(sizeof(vm86_retAddr)); |
memcpy(vm86_iretAddress, vm86_retAddr, sizeof(vm86_retAddr)); |
memcpy(vm86_iretAddress,vm86_retAddr,sizeof(vm86_retAddr)); |
#ifdef __LL_DEBUG__ |
message("PM reentry linear address=%p\n", vm86_iretAddress); |
message("PM reentry linear address=0x%lx\n", (DWORD)vm86_iretAddress); |
#endif |
#ifdef __DUMB_CODE__ |
vm86_code = DOS_alloc(2048); |
lmemcpy(vm86_code, prova86, sizeof(prova86)); |
lmemcpy(vm86_code,prova86,sizeof(prova86)); |
#endif |
/* Zero the PM/Ring[1,2] ss:esp; they're unused! */ |
vm86_TSS.t.esp1 = 0; |
220,55 → 230,51 |
* Because of alignment problem, we need to add an extra byte all set |
* to 1, according to Intel manuals |
*/ |
vm86_TSS.t.io_base = (DWORD) (&(vm86_TSS.io_map)) - |
(DWORD) (&(vm86_TSS)); |
for (i = 0; i < 2047; i++) |
vm86_TSS.io_map[i] = 0; |
vm86_TSS.t.io_base = (DWORD)(&(vm86_TSS.io_map)) - |
(DWORD)(&(vm86_TSS)); |
for (i = 0; i < 2047; i++) vm86_TSS.io_map[i] = 0; |
vm86_TSS.io_map[2047] = 0xFF000000; |
} |
int vm86_callBIOS(int service, X_REGS16 * in, X_REGS16 * out, |
X_SREGS16 * s) |
int vm86_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s) |
{ |
DWORD vm86_tmpAddr; |
DWORD vm86_flags, vm86_cs, vm86_ip; |
DWORD vm86_flags, vm86_cs,vm86_ip; |
LIN_ADDR vm86_stackPtr; |
DWORD *IRQTable_entry; |
if (service < 0x10 || in == NULL) |
return -1; |
if (service < 0x10 || in == NULL) return -1; |
/* Setup the stack frame */ |
vm86_tmpAddr = (DWORD) (vm86_stack); |
vm86_tmpAddr = (DWORD)(vm86_stack); |
vm86_TSS.t.ss = (vm86_tmpAddr & 0xFF000) >> 4; |
vm86_TSS.t.ebp = vm86_TSS.t.esp = (vm86_tmpAddr & 0x0FFF) |
+ VM86_STACK_SIZE - 6; |
+ VM86_STACK_SIZE - 6; |
/* Build an iret stack frame which returns to vm86_iretAddress */ |
vm86_tmpAddr = (DWORD) (vm86_iretAddress); |
vm86_tmpAddr = (DWORD)(vm86_iretAddress); |
vm86_cs = (vm86_tmpAddr & 0xFF000) >> 4; |
vm86_ip = (vm86_tmpAddr & 0xFFF); |
vm86_flags = 0; /* CPU_FLAG_VM | CPU_FLAG_IOPL; */ |
vm86_flags = 0; /* CPU_FLAG_VM | CPU_FLAG_IOPL; */ |
vm86_stackPtr = vm86_stack + VM86_STACK_SIZE; |
lmempokew(vm86_stackPtr - 6, vm86_ip); |
lmempokew(vm86_stackPtr - 4, vm86_cs); |
lmempokew(vm86_stackPtr - 2, vm86_flags); |
lmempokew(vm86_stackPtr-6,vm86_ip); |
lmempokew(vm86_stackPtr-4,vm86_cs); |
lmempokew(vm86_stackPtr-2,vm86_flags); |
#ifdef __LL_DEBUG__ |
message("Stack: %lx SS: %lx SP: %lx\n", |
vm86_tmpAddr + VM86_STACK_SIZE, (DWORD) vm86_TSS.t.ss, |
vm86_TSS.t.esp); |
vm86_tmpAddr + VM86_STACK_SIZE,(DWORD)vm86_TSS.t.ss,vm86_TSS.t.esp); |
#endif |
/* Wanted VM86 mode + IOPL = 3! */ |
vm86_TSS.t.eflags = CPU_FLAG_VM | CPU_FLAG_IOPL; |
/* Preload some standard values into the registers */ |
vm86_TSS.t.ss0 = X_FLATDATA_SEL; |
vm86_TSS.t.esp0 = (DWORD) & (vm86_stack0[VM86_STACK_SIZE - 1]); |
vm86_TSS.t.esp0 = (DWORD)&(vm86_stack0[VM86_STACK_SIZE-1]); |
#ifdef __DUMB_CODE__ |
vm86_TSS.t.cs = ((DWORD) (vm86_code) & 0xFFFF0) >> 4; |
vm86_TSS.t.eip = ((DWORD) (vm86_code) & 0x000F); |
vm86_TSS.t.cs = ((DWORD)(vm86_code) & 0xFFFF0) >> 4; |
vm86_TSS.t.eip = ((DWORD)(vm86_code) & 0x000F); |
#ifdef __LL_DEBUG_ |
message("(DUMB CODE) CS:%x IP:%x/%x\n", |
(DWORD) vm86_TSS.t.cs, vm86_TSS.t.eip, &prova86); |
(DWORD)vm86_TSS.t.cs,vm86_TSS.t.eip,&prova86); |
message("(DUMB CODE) Go...\n"); |
#endif |
vm86_TSS.t.back_link = ll_context_save(); |
279,44 → 285,41 |
#endif |
#else |
/* Copy the parms from the X_*REGS structures in the vm86 TSS */ |
vm86_TSS.t.eax = (DWORD) in->x.ax; |
vm86_TSS.t.ebx = (DWORD) in->x.bx; |
vm86_TSS.t.ecx = (DWORD) in->x.cx; |
vm86_TSS.t.edx = (DWORD) in->x.dx; |
vm86_TSS.t.esi = (DWORD) in->x.si; |
vm86_TSS.t.edi = (DWORD) in->x.di; |
vm86_TSS.t.eax = (DWORD)in->x.ax; |
vm86_TSS.t.ebx = (DWORD)in->x.bx; |
vm86_TSS.t.ecx = (DWORD)in->x.cx; |
vm86_TSS.t.edx = (DWORD)in->x.dx; |
vm86_TSS.t.esi = (DWORD)in->x.si; |
vm86_TSS.t.edi = (DWORD)in->x.di; |
/* IF Segment registers are required, copy them... */ |
if (s != NULL) { |
vm86_TSS.t.es = (WORD) s->es; |
vm86_TSS.t.ds = (WORD) s->ds; |
vm86_TSS.t.es = (WORD)s->es; |
vm86_TSS.t.ds = (WORD)s->ds; |
} else { |
vm86_TSS.t.ds = vm86_TSS.t.ss; |
vm86_TSS.t.es = vm86_TSS.t.ss; |
vm86_TSS.t.ds = vm86_TSS.t.ss; |
vm86_TSS.t.es = vm86_TSS.t.ss; |
} |
vm86_TSS.t.gs = vm86_TSS.t.ss; |
vm86_TSS.t.fs = vm86_TSS.t.ss; |
vm86_TSS.t.gs = vm86_TSS.t.ss; |
vm86_TSS.t.fs = vm86_TSS.t.ss; |
/* Execute the BIOS call, fetching the CS:IP of the real interrupt |
* handler from 0:0 (DOS irq table!) |
*/ |
IRQTable_entry = (void *) (0L); |
vm86_TSS.t.cs = ((IRQTable_entry[service]) & 0xFFFF0000) >> 16; |
IRQTable_entry = (void *)(0L); |
vm86_TSS.t.cs= ((IRQTable_entry[service]) & 0xFFFF0000) >> 16; |
vm86_TSS.t.eip = ((IRQTable_entry[service]) & 0x0000FFFF); |
#ifdef __LL_DEBUG__ |
message("CS:%hx IP:%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
#ifdef __LL_DEBUG__ |
message("CS:%x IP:%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
#endif |
/* Let's use the ll standard call... */ |
vm86_TSS.t.back_link = ll_context_save(); |
ll_context_load(X_VM86_TSS); |
#ifdef __LL_DEBUG__ |
#ifdef __LL_DEBUG__ |
message("I am back...\n"); |
message("TSS CS=%hx IP=%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
{ |
char *xp = (char *) (vm86_iretAddress + 0xe); |
message("PM reentry linear address=%p\n", vm86_iretAddress); |
message("Executing code: %x ", (unsigned char) (*xp)); |
xp++; |
message("%x\n", (unsigned char) (*xp)); |
} |
{ char *xp = (char *)(vm86_iretAddress + 0xe); |
message("PM reentry linear address=%p\n", vm86_iretAddress); |
message("Executing code: %x ",(unsigned char)(*xp)); xp++; |
message("%x\n",(unsigned char)(*xp));} |
#endif |
/* Send back in the X_*REGS structure the value obtained with |
* the real-mode interrupt call |
332,26 → 335,26 |
out->x.cflag = (WORD)vm86_TSS.t.eflags; |
*/ |
#ifdef __LL_DEBUG__ |
message("%x\n", (WORD) * (GLOBesp)); |
message("%x\n", (WORD) * (GLOBesp + 1)); |
/*EDI*/ message("%x\n", (WORD) * (GLOBesp + 2)); |
/*ESI*/ message("%x\n", (WORD) * (GLOBesp + 3)); |
/*EBP*/ message("%x\n", (WORD) * (GLOBesp + 4)); |
/*ESP*/ message("%x\n", (WORD) * (GLOBesp + 5)); |
/*EBX*/ message("%x\n", (WORD) * (GLOBesp + 6)); |
/*EDX*/ |
#error Fix the following: use global_regs->xxx ??? |
message("%x\n", (WORD)*(GLOBesp)); |
message("%x\n", (WORD)*(GLOBesp+1)); /*EDI*/ |
message("%x\n", (WORD)*(GLOBesp+2)); /*ESI*/ |
message("%x\n", (WORD)*(GLOBesp+3)); /*EBP*/ |
message("%x\n", (WORD)*(GLOBesp+4)); /*ESP*/ |
message("%x\n", (WORD)*(GLOBesp+5)); /*EBX*/ |
message("%x\n", (WORD)*(GLOBesp+6)); /*EDX*/ |
#endif |
out->x.ax = (WORD) * (GLOBesp + 8); |
out->x.bx = (WORD) * (GLOBesp + 5); |
out->x.cx = (WORD) * (GLOBesp + 7); |
out->x.dx = (WORD) * (GLOBesp + 6); |
out->x.si = (WORD) * (GLOBesp + 2); |
out->x.di = (WORD) * (GLOBesp + 1); |
out->x.cflag = (WORD) * (GLOBesp); |
out->x.ax = global_regs->eax; |
out->x.bx = global_regs->ebx; |
out->x.cx = global_regs->ecx; |
out->x.dx = global_regs->edx; |
out->x.si = global_regs->esi; |
out->x.di = global_regs->edi; |
out->x.cflag = global_regs->flags; |
} |
if (s != NULL) { |
s->es = vm86_TSS.t.es; |
s->ds = vm86_TSS.t.ds; |
s->es = vm86_TSS.t.es; |
s->ds = vm86_TSS.t.ds; |
} |
#endif |
return 1; |
/shark/tags/rel_0_5/oslib/xlib/x0.s |
---|
153,23 → 153,27 |
*/ |
/* Test if GDT is usable */ |
movl %gs:0(%ebx),%ecx |
andl $0x080,%ecx |
jnz GDT_is_OK |
/* |
* Fix the X_RM_BACK_GATE with the address of halt() |
*/ |
/* Now I test if the check mechanism is OK... */ |
andl $0x0200,%ecx /* MB_INFO_BOOT_LOADER_NAME */ |
movl $0xB8000,%edi |
addl $150,%edi |
movb $'1',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
jz GDT_is_not_OK |
incl %edi |
movb $'2',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
movl %gs:64(%ebx), %ebp /* Name Address... */ |
cmpb $'X', %gs:0(%ebp) |
je GDT_is_OK |
GDT_is_not_OK: |
/* |
* Fix the X_RM_BACK_GATE with the address of halt() |
*/ |
/* Now I test if the check mechanism is OK... */ |
movl $SYMBOL_NAME(halt),%eax |
movw %ax,%gs:rmBckGateFix1 |
shrl $16,%eax |
/shark/tags/rel_0_5/oslib/xlib/ctxsw.c |
---|
25,7 → 25,7 |
#include <ll/i386/hw-func.h> |
#include <ll/i386/tss-ctx.h> |
FILE(Context - Switch); |
FILE(Context-Switch); |
extern unsigned short int currCtx; |
#ifdef __VIRCSW__ |
37,31 → 37,31 |
void ll_context_to(CONTEXT c) |
{ |
#ifdef __VIRCSW__ |
currCtx = c; |
if (activeInt == 0) { |
currCtx = c; |
if (activeInt == 0) { |
context_load(c); |
} |
#else |
currCtx = c; |
context_load(c); |
} |
#else |
currCtx = c; |
context_load(c); |
#endif |
} |
CONTEXT ll_context_from(void) |
{ |
#ifdef __VIRCSW__ |
return currCtx; |
return currCtx; |
#else |
return context_save(); |
return context_save(); |
#endif |
} |
CONTEXT ll_context_save(void) |
{ |
return currCtx; |
return currCtx; |
} |
void ll_context_load(CONTEXT c) |
{ |
currCtx = c; |
context_load(c); |
currCtx = c; |
context_load(c); |
} |
/shark/tags/rel_0_5/oslib/xlib/ctx.s |
---|
25,8 → 25,6 |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
#include <ll/sys/ll/exc.h> |
.data |
ASMFILE(Context) |
/shark/tags/rel_0_5/oslib/xlib/xdosf.c |
---|
27,7 → 27,7 |
#include <ll/i386/x-dos.h> |
#include <ll/i386/x-dosmem.h> |
FILE(X - Dos - File); |
FILE(X-Dos-File); |
/* Basic DOS I/O Flag */ |
37,8 → 37,8 |
#define DOS_WRITE 1 |
#define DOS_RW 2 |
#define DOS_BUFSIZE 1024 /* I/O auxiliary buffer */ |
#define DOS_MAXDESCR 16 /* Maximum number of DOS file */ |
#define DOS_BUFSIZE 1024 /* I/O auxiliary buffer */ |
#define DOS_MAXDESCR 16 /* Maximum number of DOS file */ |
static DOS_FILE DOS_descr[DOS_MAXDESCR]; |
/* I Hope this array is initialized with 0... */ |
47,61 → 47,56 |
/* The Last DOS Error occurred! */ |
static unsigned _DOS_error = 0; |
#ifdef __NOH4__ |
int DOS_init(void) |
{ |
/* Init the DOS memory allocator */ |
DOS_mem_init(); |
/* Init the DOS memory allocator */ |
DOS_mem_init(); |
/* TODO: Add a check if we are run through X */ |
return 1; |
/* TODO: Add a check if we are run through X */ |
return 1; |
} |
#endif |
unsigned DOS_error(void) |
{ |
unsigned v = _DOS_error; |
_DOS_error = 0; |
return (v); |
return(v); |
} |
DOS_FILE *DOS_fopen(char *name, char *mode) |
DOS_FILE *DOS_fopen(char *name,char *mode) |
{ |
X_REGS16 ir, or; |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DOS_FILE *f; |
register int i; |
#ifdef __DEBUG__ |
char xname[80]; |
#endif |
#ifdef __DEBUG__ |
char xname[80]; |
#endif |
for (i = 0; busy[i] && i < DOS_MAXDESCR; i++); |
/* Return NULL if no descriptor is available... */ |
if (i == DOS_MAXDESCR) |
return (NULL); |
if (i == DOS_MAXDESCR) return(NULL); |
/* Otherwise, lock the descriptor & remember the index */ |
f = &DOS_descr[i]; |
busy[i] = 1; |
f->index = i; |
f = &DOS_descr[i]; busy[i] = 1; f->index = i; |
/* Allocate a DOS buffer for the file name */ |
f->n1 = DOS_alloc(80); |
strcpy(f->n2, name); |
strcpy(f->n2,name); |
if (mode[0] == 'r') { |
/* DOS Call: Intr 0x21 |
AH = 0x3D - Open existing file |
AL = 0,1,2 - Read,Write, R/W |
*/ |
AH = 0x3D - Open existing file |
AL = 0,1,2 - Read,Write, R/W |
*/ |
f->mode = DOS_READ; |
ir.h.ah = 0x3D; |
ir.h.al = f->mode; |
} else if (mode[0] == 'w') { |
} |
else if (mode[0] == 'w') { |
/* DOS Call: Intr 0x21 |
AH = 0x3C - Create a file |
AL = File attribute [0x20 = Standard,r/w,archive] |
*/ |
AH = 0x3C - Create a file |
AL = File attribute [0x20 = Standard,r/w,archive] |
*/ |
f->mode = DOS_WRITE; |
ir.h.ah = 0x3C; |
ir.x.cx = 0x20; |
109,75 → 104,72 |
f->offset = 0; |
/* Copy th \0 also! */ |
memcpy(f->n1, name, strlen(name) + 1); |
#ifdef __DEBUG__ |
memcpy(xname, f->n1, strlen(name) + 1); |
message("Name is : %s -- Mode : %d\n", xname, f->mode); |
#endif |
#ifdef __DEBUG__ |
memcpy(xname, f->n1, strlen(name) + 1); |
message("Name is : %s -- Mode : %d\n",xname,f->mode); |
#endif |
/* Ask DOS to open File */ |
ir.x.dx = DOS_OFF(f->n1); |
sr.ds = DOS_SEG(f->n1); |
X_callBIOS(0x21, &ir, &or, &sr); |
X_callBIOS(0x21,&ir,&or,&sr); |
f->handle = (!(or.x.cflag) ? or.x.ax : -1); |
if (f->handle == -1) { |
/* DOS request failed! Release the used resources */ |
DOS_free(f->n1, 80); |
DOS_free(f->n1,80); |
busy[i] = 0; |
_DOS_error = or.x.ax; |
return (NULL); |
return(NULL); |
} |
/* Allocate the DOS buffer for temporary I/O */ |
f->buf = DOS_alloc(DOS_BUFSIZE); |
return (f); |
return(f); |
} |
void DOS_fclose(DOS_FILE * f) |
void DOS_fclose(DOS_FILE *f) |
{ |
X_REGS16 ir, or; |
X_REGS16 ir,or; |
X_SREGS16 sr; |
if (f == NULL || busy[f->index] == 0) |
return; |
if (f == NULL || busy[f->index] == 0) return; |
/* DOS Call: Intr 0x21 |
AH = 0x3E - Close a file |
BX = File handle |
*/ |
AH = 0x3E - Close a file |
BX = File handle |
*/ |
ir.h.ah = 0x3E; |
ir.x.bx = f->handle; |
X_callBIOS(0x21, &ir, &or, &sr); |
DOS_free(f->buf, DOS_BUFSIZE); |
DOS_free(f->n1, 80); |
X_callBIOS(0x21,&ir,&or,&sr); |
DOS_free(f->buf,DOS_BUFSIZE); |
DOS_free(f->n1,80); |
busy[f->index] = 0; |
} |
DWORD DOS_fread(void *abuf, DWORD size, DWORD num, DOS_FILE * f) |
DWORD DOS_fread(void *abuf,DWORD size,DWORD num,DOS_FILE *f) |
{ |
X_REGS16 ir, or; |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DWORD count = size * num, now = 0, chunk; |
DWORD count = size*num,now = 0,chunk; |
BYTE done = 0; |
BYTE *buf = (BYTE *) (abuf); |
BYTE *buf = (BYTE *)(abuf); |
while (done == 0) { |
/* Fragment the read operation ... */ |
if (count > DOS_BUFSIZE) |
chunk = DOS_BUFSIZE; |
else |
chunk = count; |
if (count > DOS_BUFSIZE) chunk = DOS_BUFSIZE; |
else chunk = count; |
/* DOS Call: Intr 0x21 |
AH = 0x3F - Read data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
AH = 0x3F - Read data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
ir.h.ah = 0x3F; |
ir.x.bx = f->handle; |
ir.x.cx = chunk; |
ir.x.dx = DOS_OFF(f->buf); |
sr.ds = DOS_SEG(f->buf); |
X_callBIOS(0x21, &ir, &or, &sr); |
X_callBIOS(0x21,&ir,&or,&sr); |
/* If it was OK ... */ |
if (!(or.x.cflag)) { |
/* Copy data into application buffer */ |
187,47 → 179,44 |
f->offset += or.x.ax; |
count -= or.x.ax; |
/* |
Finish if we have read all the data or |
if we have read less data than how expected |
*/ |
if (now == size * num || or.x.ax != chunk) |
done = 1; |
Finish if we have read all the data or |
if we have read less data than how expected |
*/ |
if (now == size*num || or.x.ax != chunk) done = 1; |
} else { |
done = -1; |
_DOS_error = or.x.ax; |
} |
} |
return (now); |
return(now); |
} |
DWORD DOS_fwrite(void *abuf, DWORD size, DWORD num, DOS_FILE * f) |
DWORD DOS_fwrite(void *abuf,DWORD size,DWORD num,DOS_FILE *f) |
{ |
X_REGS16 ir, or; |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DWORD count = size * num, now = 0, chunk; |
DWORD count = size*num,now = 0,chunk; |
BYTE done = 0; |
BYTE *buf = (BYTE *) (abuf); |
BYTE *buf = (BYTE *)(abuf); |
while (done == 0) { |
/* Fragment the write operation ... */ |
if (count > DOS_BUFSIZE) |
chunk = DOS_BUFSIZE; |
else |
chunk = count; |
if (count > DOS_BUFSIZE) chunk = DOS_BUFSIZE; |
else chunk = count; |
/* Copy data from application buffer */ |
memcpy(f->buf, buf, chunk); |
/* DOS Call: Intr 0x21 |
AH = 0x40 - Write data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
AH = 0x40 - Write data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
ir.h.ah = 0x40; |
ir.x.bx = f->handle; |
ir.x.cx = chunk; |
ir.x.dx = DOS_OFF(f->buf); |
sr.ds = DOS_SEG(f->buf); |
X_callBIOS(0x21, &ir, &or, &sr); |
X_callBIOS(0x21,&ir,&or,&sr); |
/* If it was OK ... */ |
if (!(or.x.cflag)) { |
f->offset += or.x.ax; |
234,12 → 223,12 |
count -= or.x.ax; |
buf += or.x.ax; |
now += or.x.ax; |
if (now == size * num || or.x.ax != chunk) |
done = 1; |
if (now == size*num || or.x.ax != chunk) done = 1; |
} else { |
done = -1; |
_DOS_error = or.x.ax; |
} |
} |
return (now); |
return(now); |
} |
/shark/tags/rel_0_5/oslib/xlib/fpu.c |
---|
1,4 → 1,3 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
27,6 → 26,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/tss-ctx.h> |
33,15 → 33,15 |
FILE(FPU); |
extern TSS TSS_table[]; |
extern TSS main_tss; |
BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */ |
BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */ |
#ifdef __FPU_DEBUG__ |
long int ndp_called = 0, ndp_switched = 0; |
long int ndp_called = 0,ndp_switched = 0; |
#endif |
/* FPU context management */ |
static CONTEXT LL_has_FPU = TSSMain; |
static TSS *LL_has_FPU = &main_tss; |
/* As the 8086 does not have an hardware mechanism to support task */ |
/* switch, also the FPU context switch is implemented via software. */ |
51,37 → 51,40 |
void ll_FPU_hook(void) |
{ |
CONTEXT current; |
TSS *base; |
current = get_TR(); |
base = (TSS *)GDT_read(current, NULL, NULL, NULL); |
clts(); |
#ifdef __FPU_DEBUG__ |
ndp_called++; |
#endif |
if (LL_has_FPU == TSSsel2index(get_TR())) |
return; |
#ifdef __FPU_DEBUG__ |
ndp_switched++; |
#endif |
#ifdef __FPU_DEBUG__ |
ndp_called++; |
#endif |
if (LL_has_FPU == base) return; |
#ifdef __FPU_DEBUG__ |
ndp_switched++; |
#endif |
#if 0 |
LL_FPU_save(); |
memcpy(TSS_table[LL_has_FPU].ctx_FPU, LL_FPU_savearea, |
FPU_CONTEXT_SIZE); |
#else |
save_fpu(&(TSS_table[LL_has_FPU])); |
memcpy(TSS_table[LL_has_FPU].ctx_FPU,LL_FPU_savearea,FPU_CONTEXT_SIZE); |
#else |
save_fpu(LL_has_FPU); |
#endif |
LL_has_FPU = TSSsel2index(get_TR()); |
LL_has_FPU = base; |
#if 1 |
memcpy(LL_FPU_savearea, TSS_table[LL_has_FPU].ctx_FPU, |
FPU_CONTEXT_SIZE); |
memcpy(LL_FPU_savearea, base->ctx_FPU, FPU_CONTEXT_SIZE); |
LL_FPU_restore(); |
#else |
#else |
restore_fpu(&(TSS_table[LL_has_FPU])); |
#endif |
return; |
} |
CONTEXT LL_FPU_get_task(void) |
TSS *LL_FPU_get_task(void) |
{ |
return (LL_has_FPU); |
return(LL_has_FPU); |
} |
/shark/tags/rel_0_5/oslib/xlib/ccpu.c |
---|
25,46 → 25,50 |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/mem.h> |
FILE(Cpu - C); |
FILE(Cpu-C); |
INLINE_OP void cpuid(DWORD a, DWORD * outa, DWORD * outb, DWORD * outc, |
DWORD * outd) |
INLINE_OP void cpuid(DWORD a, DWORD *outa, DWORD *outb, DWORD *outc, DWORD *outd) |
{ |
#ifdef __OLD_GNU__ |
__asm__ __volatile__(".byte 0x0F,0xA2" |
__asm__ __volatile__ (".byte 0x0F,0xA2" |
#else |
__asm__ __volatile__("cpuid" |
__asm__ __volatile__ ("cpuid" |
#endif |
:"=a"(*outa), |
"=b"(*outb), "=c"(*outc), "=d"(*outd):"a"(a)); |
: "=a" (*outa), |
"=b" (*outb), |
"=c" (*outc), |
"=d" (*outd) |
: "a" (a)); |
} |
void X86_get_CPU(struct ll_cpuInfo *p) |
{ |
DWORD tmp; |
DWORD tmp; |
memset(p, 0, sizeof(struct ll_cpuInfo)); |
if (X86_is386()) { |
p->X86_cpu = 3; |
return; |
} |
if (X86_hasCPUID()) { |
p->X86_cpuIdFlag = 1; |
p->X86_cpu = 5; |
cpuid(0, &tmp, &(p->X86_vendor_1), |
&(p->X86_vendor_3), &(p->X86_vendor_2)); |
if (tmp >= 1) { |
cpuid(1, &(p->X86_signature), |
&(p->X86_IntelFeature_1), |
&(p->X86_IntelFeature_2), &(p->X86_StandardFeature)); |
memset(p, 0, sizeof(struct ll_cpuInfo)); |
if (X86_is386()) { |
p->X86_cpu = 3; |
return; |
} |
} else { |
p->X86_cpu = 4; |
if (X86_isCyrix()) { |
/* Err... Adjust IT!!!! */ |
p->X86_cpu = 11; |
if (X86_hasCPUID()) { |
p->X86_cpuIdFlag = 1; |
p->X86_cpu = 5; |
cpuid(0, &tmp, &(p->X86_vendor_1), |
&(p->X86_vendor_3), |
&(p->X86_vendor_2)); |
if (tmp >= 1) { |
cpuid(1, &(p->X86_signature), |
&(p->X86_IntelFeature_1), |
&(p->X86_IntelFeature_2), |
&(p->X86_StandardFeature)); |
} |
} else { |
p->X86_cpu = 4; |
if (X86_isCyrix()) { |
/* Err... Adjust IT!!!! */ |
p->X86_cpu = 11; |
} |
/* Need tests for AMD and others... */ |
} |
/* Need tests for AMD and others... */ |
} |
} |
/shark/tags/rel_0_5/oslib/xlib/xdosm.c |
---|
26,7 → 26,7 |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/error.h> |
FILE(X - Dos - Memory); |
FILE(X-Dos-Memory); |
/* |
We do not use the standard K&R pointer based memory allocator! |
39,12 → 39,12 |
since DOS memory is only used for reflection related purposes |
*/ |
#define MAX_PARTITION 50 /* Max available partition */ |
#define MAX_PARTITION 50 /* Max available partition */ |
static struct { |
BYTE used; |
LIN_ADDR addr; |
DWORD size; |
BYTE used; |
LIN_ADDR addr; |
DWORD size; |
} mem_table[MAX_PARTITION]; |
static int inited = 0; |
53,28 → 53,26 |
{ |
register int i; |
for (i = 0; i < MAX_PARTITION; i++) { |
if (mem_table[i].used) |
message("(%d) Addr : %p Size : %lu/%lx\n", |
i, mem_table[i].addr, |
mem_table[i].size, mem_table[i].size); |
if (mem_table[i].used) message("(%d) Addr : %p Size : %lu/%lx\n", |
i, mem_table[i].addr, |
mem_table[i].size, mem_table[i].size); |
} |
} |
void DOS_mem_init(void) |
__attribute__ ((weak)) void DOS_mem_init(void) |
{ |
register int i; |
if (inited == 0) { |
mem_table[0].used = TRUE; |
X_meminfo(NULL, NULL, &(mem_table[0].addr), &(mem_table[0].size)); |
for (i = 1; i < MAX_PARTITION; i++) |
mem_table[i].used = FALSE; |
mem_table[0].used = TRUE; |
X_meminfo(NULL,NULL,&(mem_table[0].addr),&(mem_table[0].size)); |
for (i = 1; i < MAX_PARTITION; i++) mem_table[i].used = FALSE; |
} else { |
inited = 1; |
inited = 1; |
} |
} |
LIN_ADDR DOS_alloc(DWORD s) |
__attribute__ ((weak)) LIN_ADDR DOS_alloc(DWORD s) |
{ |
LIN_ADDR p = 0; |
int i = 0; |
81,31 → 79,28 |
while (i < MAX_PARTITION && p == NULL) { |
if (mem_table[i].used && (mem_table[i].size >= s)) |
p = mem_table[i].addr; |
else |
i++; |
p = mem_table[i].addr; |
else i++; |
} |
if (p != 0) { |
if (mem_table[i].size > s) { |
mem_table[i].size -= s; |
mem_table[i].addr += s; |
} else |
mem_table[i].used = FALSE; |
} |
else mem_table[i].used = FALSE; |
} |
return (p); |
return(p); |
} |
int DOS_free(LIN_ADDR p, DWORD s) |
__attribute__ ((weak)) int DOS_free(LIN_ADDR p,DWORD s) |
{ |
register int i = 1; |
unsigned i1 = 0, i2 = 0; |
while (i < MAX_PARTITION && ((i1 == 0) || (i2 == 0))) { |
while (i < MAX_PARTITION && ((i1 == 0) || (i2 == 0)) ) { |
if (mem_table[i].used) { |
if (mem_table[i].addr + mem_table[i].size == p) |
i1 = i; |
if (mem_table[i].addr == p + s) |
i2 = i; |
if (mem_table[i].addr + mem_table[i].size == p) i1 = i; |
if (mem_table[i].addr == p + s) i2 = i; |
} |
i++; |
} |
112,20 → 107,19 |
if (i1 != 0 && i2 != 0) { |
mem_table[i1].size += mem_table[i2].size + s; |
mem_table[i2].used = FALSE; |
} else if (i1 == 0 && i2 != 0) { |
} |
else if (i1 == 0 && i2 != 0) { |
mem_table[i2].addr = p; |
mem_table[i2].size += s; |
} else if (i1 != 0 && i2 == 0) |
mem_table[i1].size += s; |
} |
else if (i1 != 0 && i2 == 0) mem_table[i1].size += s; |
else { |
i = 0; |
while (i < MAX_PARTITION && (mem_table[i].used == TRUE)) |
i++; |
if (i == MAX_PARTITION) |
return (FALSE); |
while (i < MAX_PARTITION && (mem_table[i].used == TRUE)) i++; |
if (i == MAX_PARTITION) return(FALSE); |
mem_table[i].addr = p; |
mem_table[i].size = s; |
mem_table[i].used = TRUE; |
} |
return (TRUE); |
return(TRUE); |
} |
/shark/tags/rel_0_5/oslib/xlib/irq.c |
---|
22,10 → 22,11 |
/* PIC management code & data */ |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/pic.h> |
FILE(IRQ); |
#define ICW1_M 0x020 /* Master PIC (8259) register settings */ |
#define ICW1_M 0x020 /* Master PIC (8259) register settings */ |
#define ICW2_M 0x021 |
#define ICW3_M 0x021 |
#define ICW4_M 0x021 |
33,7 → 34,7 |
#define OCW2_M 0x020 |
#define OCW3_M 0x020 |
#define ICW1_S 0x0A0 /* Slave PIC register setting */ |
#define ICW1_S 0x0A0 /* Slave PIC register setting */ |
#define ICW2_S 0x0A1 |
#define ICW3_S 0x0A1 |
#define ICW4_S 0x0A1 |
41,66 → 42,61 |
#define OCW2_S 0x0A0 |
#define OCW3_S 0x0A0 |
#define PIC1_BASE 0x040 /* Interrupt base for each PIC in HARTIK 3.0 */ |
#define PIC2_BASE 0x070 |
#define EOI 0x020 /* End Of Interrupt code for PIC! */ |
#define EOI 0x020 /* End Of Interrupt code for PIC! */ |
#define bit_on(v,b) ((v) |= (1 << (b))) |
#define bit_off(v,b) ((v) &= ~(1 << (b))) |
/* PIC interrupt mask */ |
BYTE ll_PIC_master_mask = 0xFE; |
BYTE ll_PIC_slave_mask = 0xFE; |
BYTE ll_PIC_master_mask = 0xFF; |
BYTE ll_PIC_slave_mask = 0xFF; |
void PIC_init(void) |
{ |
outp(ICW1_M, 0x11); |
outp(ICW2_M, PIC1_BASE); |
outp(ICW3_M, 0x04); |
outp(ICW4_M, 0x01); |
outp(OCW1_M, 0xFF); |
outp(ICW1_M,0x11); |
outp(ICW2_M,PIC1_BASE); |
outp(ICW3_M,0x04); |
outp(ICW4_M,0x01); |
outp(OCW1_M,0xFF); |
outp(ICW1_S, 0x11); |
outp(ICW2_S, PIC2_BASE); |
outp(ICW3_S, 0x02); |
outp(ICW4_S, 0x01); |
outp(OCW1_S, 0xFF); |
outp(ICW1_S,0x11); |
outp(ICW2_S,PIC2_BASE); |
outp(ICW3_S,0x02); |
outp(ICW4_S,0x01); |
outp(OCW1_S,0xFF); |
} |
void PIC_end(void) |
{ |
outp(ICW1_M, 0x11); |
outp(ICW2_M, 0x08); |
outp(ICW3_M, 0x04); |
outp(ICW4_M, 0x01); |
outp(OCW1_M, 0xFF); |
outp(ICW1_M,0x11); |
outp(ICW2_M,0x08); |
outp(ICW3_M,0x04); |
outp(ICW4_M,0x01); |
outp(OCW1_M,0xFF); |
outp(ICW1_S, 0x11); |
outp(ICW2_S, 0x70); |
outp(ICW3_S, 0x02); |
outp(ICW4_S, 0x01); |
outp(OCW1_S, 0xFF); |
outp(ICW1_S,0x11); |
outp(ICW2_S,0x70); |
outp(ICW3_S,0x02); |
outp(ICW4_S,0x01); |
outp(OCW1_S,0xFF); |
} |
void irq_mask(WORD irqno) |
{ |
/* Cannot mask timer interrupt! */ |
if (irqno == 0) |
return; |
/* Interrupt is on master PIC */ |
if (irqno < 8) { |
bit_on(ll_PIC_master_mask, irqno); |
outp(0x21, ll_PIC_master_mask); |
bit_on(ll_PIC_master_mask,irqno); |
outp(0x21,ll_PIC_master_mask); |
} else if (irqno < 16) { |
/* Interrupt on slave PIC */ |
bit_on(ll_PIC_slave_mask, irqno - 8); |
outp(0xA1, ll_PIC_slave_mask); |
bit_on(ll_PIC_slave_mask,irqno-8); |
outp(0xA1,ll_PIC_slave_mask); |
/* If the slave PIC is completely off */ |
/* Then turn off cascading line (Irq #2) */ |
/* Then turn off cascading line (Irq #2)*/ |
if (ll_PIC_slave_mask == 0xFF && !(ll_PIC_master_mask & 0x04)) { |
bit_on(ll_PIC_master_mask, 2); |
outp(0x21, ll_PIC_master_mask); |
bit_on(ll_PIC_master_mask,2); |
outp(0x21,ll_PIC_master_mask); |
} |
} |
} |
107,22 → 103,19 |
void irq_unmask(WORD irqno) |
{ |
/* It is a nonsense to unmask the timer interrupt */ |
if (irqno == 0) |
return; |
/* Interrupt is on master PIC */ |
if (irqno < 8) { |
bit_off(ll_PIC_master_mask, irqno); |
outp(0x21, ll_PIC_master_mask); |
bit_off(ll_PIC_master_mask,irqno); |
outp(0x21,ll_PIC_master_mask); |
} else if (irqno < 16) { |
/* Interrupt on slave PIC */ |
bit_off(ll_PIC_slave_mask, irqno - 8); |
outp(0xA1, ll_PIC_slave_mask); |
bit_off(ll_PIC_slave_mask,irqno-8); |
outp(0xA1,ll_PIC_slave_mask); |
/* If the cascading irq line was off */ |
/* Then activate it also! */ |
if (ll_PIC_master_mask & 0x04) { |
bit_off(ll_PIC_master_mask, 2); |
outp(0x21, ll_PIC_master_mask); |
bit_off(ll_PIC_master_mask,2); |
outp(0x21,ll_PIC_master_mask); |
} |
} |
} |
/shark/tags/rel_0_5/oslib/xlib/xinit.c |
---|
31,240 → 31,118 |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/hw-arch.h> |
FILE(X - Init); |
FILE(X-Init); |
extern DWORD ll_irq_table[16]; |
extern DWORD ll_exc_table[16]; |
extern DWORD ll_irq_table[256]; |
#ifdef __VIRCSW__ |
int activeInt = 0; |
#endif |
/* Architecture definition */ |
LL_ARCH ll_arch; |
/* These are declared in llCx32b.C */ |
TSS TSS_table[TSSMax]; |
WORD TSS_control[TSSMax]; |
BYTE ll_FPU_stdctx[FPU_CONTEXT_SIZE]; |
/* The following stuff is in llCxA.Asm/S */ |
/* Assembly external routines! */ |
/* Setup the TR register of the 80386, to initialize context switch */ |
extern void init_TR(WORD v); |
TSS main_tss; |
/* ll hardware interrupt hooks */ |
extern void h1(void); |
extern void h2(void); |
extern void h3(void); |
extern void h4(void); |
extern void h5(void); |
extern void h6(void); |
extern void h7(void); |
extern void h8(void); |
extern void h9(void); |
extern void h10(void); |
extern void h11(void); |
extern void h12(void); |
extern void h13(void); |
extern void h13_bis(void); |
extern void h14(void); |
extern void h15(void); |
/* Architecture definition */ |
LL_ARCH ll_arch; |
/* ll hardware exception hooks */ |
/* In llCtx1.Asm/s */ |
extern void exc0(void); |
extern void exc1(void); |
extern void exc2(void); |
extern void exc3(void); |
extern void exc4(void); |
extern void exc5(void); |
extern void exc6(void); |
extern void exc7(void); |
extern void exc8(void); |
extern void exc9(void); |
extern void exc10(void); |
extern void exc11(void); |
extern void exc12(void); |
extern void exc13(void); |
extern void exc14(void); |
extern void exc15(void); |
extern void exc16(void); |
/* The following stuff is in llCxA.Asm/S */ |
static void dummyfun(int i) |
{ |
cputs("Unhandled Exc or Int occured!!!\n"); |
/* |
#if 0 |
if (i < 32) { |
cputs("Unhandled Exc occured!!!\n"); |
} else { |
cputs("Unhandled Int occured!!!\n"); |
} |
#else |
message("Unhandled Exc or Int %d occured!!!\n", i); |
*/ |
halt(); |
#endif |
halt(); |
} |
void l1_exc_bind(int i, void (*f) (int n)) |
void l1_int_bind(int i, void *f) |
{ |
ll_exc_table[i] = (DWORD) f; |
ll_irq_table[i] = (DWORD)f; |
} |
void l1_irq_bind(int i, void (*f) (int n)) |
{ |
ll_irq_table[i] = (DWORD) f; |
} |
void *l1_init(void) |
{ |
register int i; |
struct ll_cpuInfo cpuInfo; |
LIN_ADDR b; |
extern BYTE X86_fpu; |
TSS dummy_tss; /* Very dirty, but we need it, in order to |
get an initial value for the FPU |
context... |
*/ |
/* First of all, init the exc and irq tables... */ |
for (i = 0; i < 16; i++) { |
ll_irq_table[i] = (DWORD) dummyfun; |
ll_exc_table[i] = (DWORD) dummyfun; |
} |
X86_get_CPU(&cpuInfo); |
X86_get_FPU(); |
ll_arch.x86.arch = __LL_ARCH__; |
ll_arch.x86.cpu = cpuInfo.X86_cpu; |
ll_arch.x86.fpu = X86_fpu; |
memcpy(&(ll_arch.x86.vendor), &(cpuInfo.X86_vendor_1), 12); |
/* TODO! Need to map featuresXXX & Signature onto ll_arch! */ |
/* TODO! Need to check for CPU bugs!! */ |
register int i; |
struct ll_cpuInfo cpuInfo; |
extern BYTE X86_fpu; |
LIN_ADDR b; |
for(i = 0; i < 256; i++) { |
ll_irq_table[i] = (DWORD)dummyfun; |
} |
X86_get_CPU(&cpuInfo); |
X86_get_FPU(); |
ll_arch.x86.arch = __LL_ARCH__; |
ll_arch.x86.cpu = cpuInfo.X86_cpu; |
ll_arch.x86.fpu = X86_fpu; |
memcpy(&(ll_arch.x86.vendor), &(cpuInfo.X86_vendor_1), 12); |
/* TODO! Need to map featuresXXX & Signature onto ll_arch! */ |
/* TODO! Need to check for CPU bugs!! */ |
#ifdef __LL_DEBUG__ |
message("LL Architecture: %s\n", __LL_ARCH__); |
message("CPU : %u\nFPU : %u\n", cpuInfo.X86_cpu, X86_fpu); |
message("Signature : 0x%lx\nVendor: %s\n", cpuInfo.X86_signature, |
ll_arch.x86.vendor); |
message("Features #1: 0x%lx\n", cpuInfo.X86_IntelFeature_1); |
message("Features #2: 0x%lx\n", cpuInfo.X86_IntelFeature_2); |
message("Features #3: 0x%lx\n", cpuInfo.X86_StandardFeature); |
#endif /* __LL_DEBUG__ */ |
message("LL Architecture: %s\n", __LL_ARCH__); |
message("CPU : %u\nFPU : %u\n", cpuInfo.X86_cpu, X86_fpu); |
message("Signature : 0x%lx\nVendor: %s\n", cpuInfo.X86_signature, |
ll_arch.x86.vendor); |
message("Features #1: 0x%lx\n", cpuInfo.X86_IntelFeature_1); |
message("Features #2: 0x%lx\n", cpuInfo.X86_IntelFeature_2); |
message("Features #3: 0x%lx\n", cpuInfo.X86_StandardFeature); |
#endif /* __LL_DEBUG__ */ |
IDT_init(); |
/* Insert the Exceptions handler into IDT */ |
IDT_place(0x00, exc0); |
IDT_place(0x01, exc1); |
IDT_place(0x02, exc2); |
IDT_place(0x03, exc3); |
IDT_place(0x04, exc4); |
IDT_place(0x05, exc5); |
IDT_place(0x06, exc6); |
IDT_place(0x07, exc7); |
IDT_place(0x08, exc8); |
IDT_place(0x09, exc9); |
IDT_place(0x0A, exc10); |
IDT_place(0x0B, exc11); |
IDT_place(0x0C, exc12); |
IDT_place(0x0D, exc13); |
IDT_place(0x0E, exc14); |
IDT_place(0x0F, exc15); |
IDT_place(0x10, exc16); |
/* Insert HW timer handler into IDT */ |
/* Now it is done in event.c |
IDT_place(0x40,ll_timer); |
*/ |
IDT_place(0x41, h1); |
IDT_place(0x42, h2); |
IDT_place(0x43, h3); |
IDT_place(0x44, h4); |
IDT_place(0x45, h5); |
IDT_place(0x46, h6); |
IDT_place(0x47, h7); |
IDT_place(0x70, h8); |
IDT_place(0x71, h9); |
IDT_place(0x72, h10); |
IDT_place(0x73, h11); |
IDT_place(0x74, h12); |
#if 0 |
/* If FPU is on-chip IRQ #13 is free to use */ |
/* Else IRQ #13 vectors the coprocessor errors */ |
if (check_fpu()) |
ll_arch.x86.capabilities |= LL_X86_INTERNAL_FPU; |
#ifdef __LL_DEBUG__ |
message("Check FPU : %s\n", |
ll_arch.x86. |
capabilities & LL_X86_INTERNAL_FPU ? "Internal" : "External"); |
#endif |
if (ll_arch.x86.capabilities & LL_X86_INTERNAL_FPU) { |
/* Install the generic handler */ |
IDT_place(0x75, h13); |
} else { |
/* Install the external FPU error handler */ |
IDT_place(0x75, h13_bis); |
irq_unmask(13); |
} |
#else |
IDT_place(0x75, h13); |
#endif |
IDT_place(0x76, h14); |
IDT_place(0x77, h15); |
/* Init TSS table & put the corrispondent selectors into GDT */ |
TSS_control[TSSMain] |= TSS_USED; |
for (i = 0; i < TSSMax; i++) { |
/* b = appl2linear(&TSS_table[i]); */ |
b = (LIN_ADDR) (&TSS_table[i]); |
GDT_place(TSSindex2sel(i), (DWORD) b, sizeof(TSS), FREE_TSS386, |
GRAN_16); |
} |
/* Set the TR initial value */ |
init_TR(TSSindex2sel(TSSMain)); |
/* Init coprocessor & assign it to main() */ |
/* OK... Now I know the sense of all this... : |
We need a initial value for the FPU context (to be used for creating |
new FPU contexts, as init value)... |
... And we get it in this strange way!!!! |
*/ |
reset_fpu(); |
#if 0 |
ll_FPU_save(); |
memcpy(ll_FPU_stdctx, ll_FPU_savearea, FPU_CONTEXT_SIZE); |
#else |
save_fpu(&dummy_tss); /* OK??? */ |
memcpy(ll_FPU_stdctx, dummy_tss.ctx_FPU, FPU_CONTEXT_SIZE); |
#endif |
init_fpu(); |
/* Init PIC controllers & unmask timer */ |
PIC_init(); |
return mbi_address(); |
/* Init coprocessor & assign it to main() */ |
/* OK... Now I know the sense of all this... : |
We need a initial value for the FPU context (to be used for creating |
new FPU contexts, as init value)... |
... And we get it in this strange way!!!! |
*/ |
reset_fpu(); |
init_fpu(); |
/* Init PIC controllers & unmask timer */ |
PIC_init(); |
/* Set the TR initial value */ |
b = (LIN_ADDR)(&main_tss); |
GDT_place(MAIN_SEL, (DWORD)b, sizeof(TSS), FREE_TSS386, GRAN_16); |
init_TR(MAIN_SEL); |
return mbi_address(); |
} |
void l1_end(void) |
{ |
outp(0x21, 0xFF); |
outp(0xA1, 0xFF); |
/* Back to DOS settings */ |
PIC_end(); |
/* Reset the timer chip according DOS specification */ |
/* Mode: Binary/Mode 3/16 bit Time_const/Counter 0 */ |
outp(0x21,0xFF); |
outp(0xA1,0xFF); |
/* Back to DOS settings */ |
PIC_end(); |
/* Reset the timer chip according DOS specification */ |
/* Mode: Binary/Mode 3/16 bit Time_const/Counter 0 */ |
#if 0 |
outp(0x43, 0x36); |
/* Time_const = 65536; write 0 in CTR */ |
outp(0x40, 0); |
outp(0x40, 0); |
outp(0x43,0x36); |
/* Time_const = 65536; write 0 in CTR */ |
outp(0x40,0); |
outp(0x40,0); |
#endif |
pit_init(0, TMR_MD3, 0); /* Timer 0, Mode 3, Time constant 0 */ |
if (ll_arch.x86.cpu > 4) { |
pit_init(1, TMR_MD2, 18); |
} else { |
pit_init(2, TMR_MD0, 0); |
outp(0x61, 0); /* Stop channel 2 */ |
} |
pit_init(0, TMR_MD3, 0); /* Timer 0, Mode 3, Time constant 0 */ |
if(ll_arch.x86.cpu > 4) { |
pit_init(1, TMR_MD2, 18); |
} else { |
pit_init(2, TMR_MD0, 0); |
outp(0x61, 0); /* Stop channel 2 */ |
} |
} |
/shark/tags/rel_0_5/oslib/xlib/makefile |
---|
2,11 → 2,11 |
# Makefile for GNU MAKE & GCC 2.8.0 |
ifndef BASE |
BASE = ../.. |
BASEDOS = ..\.. |
BASE = .. |
BASEDOS = .. |
endif |
include $(BASE)/config/config.mk |
include $(BASE)/config.mk |
C_OPT += -D__VIRCSW__ |
ASM_OPT += -D__VIRCSW__ |
19,16 → 19,17 |
xsystab.o \ |
xconv.o \ |
xdosf.o \ |
xdosm.o \ |
ccpu.o \ |
fpu.o \ |
irq.o \ |
ctxsw.o \ |
xinit.o \ |
idtinit.o \ |
vm86.o \ |
xbios.o |
#xdosm.o |
GNU_S_OBJS = xsys0.o cpu2.o exc.o ctx.o vm86-exc.o mem.o |
GNU_S_OBJS = xsys0.o cpu2.o exc.o ctx.o mem.o |
#GNU_C_OBJS = gnucomp.o |
OBJS = $(GNU_S_OBJS) $(GNU_C_OBJS) $(COMMON_OBJS) |
57,11 → 58,11 |
allclean : |
echo # XTN Library dependencies > deps |
$(RM) $(BASE)\lib\libhx.a |
$(RM) $(BASE)\lib\x0.o |
$(RM) $(LIB_PATH)libhx.a |
$(RM) $(LIB_PATH)x0.o |
deps: $(COMMON_OBJS:.o=.c) $(patsubst %.o,gnu/%.c,$(GNU_C_OBJS)) |
$(CC) $(C_OPT) $(VMINCL) -M $(COMMON_OBJS:.o=.c) $(patsubst %.o,gnu/%.c,$(GNU_C_OBJS)) > deps |
$(CC) $(C_OPT) -M $(COMMON_OBJS:.o=.c) $(patsubst %.o,gnu/%.c,$(GNU_C_OBJS)) > deps |
# |
# The library!! |
/shark/tags/rel_0_5/oslib/xlib/xconv.c |
---|
24,7 → 24,7 |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
FILE(X - Conv); |
FILE(X-Conv); |
/* Conversion between PM address space & phisical address space */ |
/* If we do not support paging we need to relocate the .ELF executable */ |
54,9 → 54,9 |
} |
*/ |
LIN_ADDR addr2linear(unsigned short seg, unsigned long offset) |
LIN_ADDR addr2linear(unsigned short seg,unsigned long offset) |
{ |
LIN_ADDR flatbase; |
flatbase = (LIN_ADDR) GDT_read(seg, NULL, NULL, NULL); |
return (flatbase + offset); |
flatbase = (LIN_ADDR)GDT_read(seg,NULL,NULL,NULL); |
return(flatbase + offset); |
} |
/shark/tags/rel_0_5/oslib/xlib/xsystab.c |
---|
23,9 → 23,8 |
#include <ll/i386/cons.h> |
#include <ll/i386/mem.h> |
#include <ll/math.h> |
FILE(X - SysTab); |
FILE(X-SysTab); |
extern GATE IDT[256]; |
33,9 → 32,9 |
/* to fill a GATE structure & copy it into the Interrupt Descriptor */ |
/* Table or IDT; its phisical address is given by IDT_base */ |
void IDT_place(BYTE num, void (*handler) (void)) |
void IDT_place(BYTE num,void (*handler)(void)) |
{ |
DWORD offset = (DWORD) (handler); |
DWORD offset = (DWORD)(handler); |
IDT[num].sel = X_FLATCODE_SEL; |
/* Set DPL = 3, to allow execution of the gate from any ring */ |
IDT[num].access = INT_GATE386 | 0x60; |
49,7 → 48,7 |
/* When a descriptor is cleared using it will cause a SEGMENT FAULT */ |
/* to refer such descriptor */ |
void GDT_place(WORD sel, DWORD base, DWORD lim, BYTE acc, BYTE gran) |
void GDT_place(WORD sel,DWORD base,DWORD lim,BYTE acc,BYTE gran) |
{ |
union gdt_entry x; |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
60,8 → 59,8 |
x.d.base_hi = ((base & 0xFF000000) >> 24); |
x.d.access = acc; |
x.d.lim_lo = (lim & 0xFFFF); |
x.d.gran = (gran | ((lim >> 16) & 0x0F) | 0x40); |
memcpy(GDT_base + (sel & ~3), &x, sizeof(union gdt_entry)); |
x.d.gran = (gran | ((lim >> 16) & 0x0F) | 0x40); |
memcpy(GDT_base+(sel & ~3),&x,sizeof(union gdt_entry)); |
} |
/* This function is used to read & format the descriptor data */ |
69,14 → 68,14 |
/* a descriptor rather than reading,modifying & updating with */ |
/* this high level functions! */ |
DWORD GDT_read(WORD sel, DWORD * lim, BYTE * acc, BYTE * gran) |
DWORD GDT_read(WORD sel,DWORD *lim,BYTE *acc,BYTE *gran) |
{ |
union gdt_entry x; |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern LIN_ADDR GDT_base; |
/*DWORD offset = appl2linear(&x); */ |
/*DWORD offset = appl2linear(&x);*/ |
DWORD base; |
memcpy(&x, GDT_base + sel, sizeof(union gdt_entry)); |
memcpy(&x,GDT_base+sel,sizeof(union gdt_entry)); |
base = x.d.base_hi; |
base <<= 8; |
base |= x.d.base_med; |
87,9 → 86,7 |
*lim <<= 16; |
*lim |= x.d.lim_lo; |
} |
if (acc != NULL) |
*acc = x.d.access; |
if (gran != NULL) |
*gran = x.d.gran & 0xF0; |
return (base); |
if (acc != NULL) *acc = x.d.access; |
if (gran != NULL) *gran = x.d.gran & 0xF0; |
return(base); |
} |