Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 39 → Rev 40

/shark/trunk/oslib/kl/time.c
39,8 → 39,6
extern WORD lastTime; /* From event.c */
extern struct pitspec globalCounter; /* From event.c */
extern BYTE frc;
 
 
extern int activeEvent;
 
FILE(Time);
51,15 → 49,19
BYTE isr;
struct timespec tmp;
 
#if 1
if (activeEvent) {
if (tsres != NULL) {
PITSPEC2TIMESPEC(&globalCounter, tsres);
return TIMESPEC2USEC(tsres);
} else {
struct timespec tmp;
 
PITSPEC2TIMESPEC(&globalCounter, &tmp);
return TIMESPEC2USEC(&tmp);
}
return TIMESPEC2USEC(tsres);
}
#endif
 
if (mode == TIME_PTICK) {
if (timermode != LL_PERIODIC) {
72,7 → 74,7
return res;
}
 
if (mode == TIME_EXACT) {
if (mode == TIME_NEW) {
WORD tmp;
 
tmp = pit_read(frc);
84,7 → 86,7
return (PITSPEC2USEC(&globalCounter));
}
 
if (mode == TIME_NEW) {
if (mode == TIME_EXACT) {
if (timermode == LL_PERIODIC) {
memcpy(&tmp, &actTime, sizeof(struct timespec));
/* How much time has elapsed
/shark/trunk/oslib/kl/event1.c
87,7 → 87,7
} else {
firstevent = p;
if (!activeEvent) {
ll_gettime(TIME_EXACT, &now);
ll_gettime(TIME_NEW, &now);
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) {
NULL_TIMESPEC(&tmp);
} else {
199,7 → 199,7
pit_setconstant(0, 0xFFFF);
} else {
if (firstdeleted) {
ll_gettime(TIME_EXACT, &now);
ll_gettime(TIME_NEW, &now);
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) {
NULL_TIMESPEC(&tmp);
} else {
/shark/trunk/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>
39,6 → 40,11
 
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[] = {
79,8 → 85,7
#endif
 
/* Math error! FPU has to be acknowledgded */
if (code == '2')
ll_out(0x0F0, 0);
if (code == '2') ll_out(0x0F0,0);
 
message("Exception %d occurred\n", i);
message("%s\n", &exc_mess[i][1]);
105,14 → 110,20
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 < 16; i++) {
void act_int(int i);
for(i = 0; i < 32; i++) {
 
/* Warning!!! The hw exceptions should be 32.... Fix it!!! */
 
120,10 → 131,32
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);
}
for(i = 0; i < 16; i++) {
void act_int(int i);
l1_irq_bind(i, act_int);
}
 
 
/* 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
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();
 
/* ll_mem_init must be explicitelly called by program... */
#if 0
/* Get info about extended memory! We suppose that X has loaded */
159,3 → 192,4
{
l1_end();
}
 
/shark/trunk/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/trunk/oslib/kl/mem.c
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)
62,16 → 61,15
while (i < MAX_PARTITION && p == NULL) {
if (mem_table[i].used && (mem_table[i].size >= s))
p = mem_table[i].addr;
else
i++;
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);
}
 
82,10 → 80,8
 
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,17 → 88,16
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;
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/trunk/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)
{
193,12 → 197,11
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 */
265,4 → 268,7
event_post = oneshot_event_post;
event_delete = oneshot_event_delete;
}
 
/* Last but not least... */
irq_unmask(0);
}
/shark/trunk/oslib/kl/cxsw-2.c
59,8 → 59,7
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("Base : %lx Lim : %lx Acc : %x Gran %x\n", base, lim, (unsigned)(acc),(unsigned)(gran));
}
 
 
89,8 → 88,7
stack_ptr--;
*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");
/shark/trunk/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/trunk/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