Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 41 → Rev 40

/shark/trunk/oslib/kl/cxsw-1.s
0,0 → 1,150
/* 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.
*/
 
/* Safe abort routine & timer asm handler */
 
.title "VmCx32a.S"
 
#include <ll/i386/sel.h>
#include <ll/i386/linkage.h>
#include <ll/i386/defs.h>
 
#include <ll/sys/ll/exc.h>
 
.data
 
ASMFILE(Context)
 
.extern JmpSel
.extern JmpZone
.globl SYMBOL_NAME(ll_clock)
.globl SYMBOL_NAME(SafeStack)
/* Used as JMP entry point to check if a real */
/* context switch is necessary */
SYMBOL_NAME_LABEL(ll_clock) .int 0
 
/* Safe stack area for aborts */
.space 4096,0
SYMBOL_NAME_LABEL(SafeStack)
 
.extern SYMBOL_NAME(periodic_wake_up)
.extern SYMBOL_NAME(oneshot_wake_up)
.extern SYMBOL_NAME(act_int)
.extern SYMBOL_NAME(abort_tail)
 
.text
.globl SYMBOL_NAME(ll_timer)
.globl SYMBOL_NAME(ll_abort)
 
SYMBOL_NAME_LABEL(ll_abort)
/* As we are terminating we cannnot handle */
/* any other interrupt! */
cli
/* Get argument */
movl 4(%esp),%eax
/* Switch to safe stack */
movl $(SYMBOL_NAME(SafeStack)),%esp
/* Push argument */
pushl %eax
/* Call sys_abort(code) */
call SYMBOL_NAME(abort_tail)
 
/* This is the timer handler; it reloads for safety the DS register; this */
/* prevents from mess when timer interrupts linear access to memory (not in */
/* ELF address space); then EOI is sent in order to detect timer overrun */
/* The high level kernel procedure wake_up() is called to perform the */
/* preeption at higher level (process descriptos); the resulting context */
/* if different from the old one is used to trigger the task activation. */
 
SYMBOL_NAME_LABEL(ll_timer)
pushal
pushw %ds
pushw %es
pushw %fs
pushw %gs
movw $(X_FLATDATA_SEL),%ax
movw %ax,%ds
movw %ax,%es
 
/* Send EOI to master PIC */
/* to perform later the overrun test */
movb $0x20,%al
movl $0x20,%edx
outb %al,%dx
 
/* Call wake_up(actual_context) */
cld
movl SYMBOL_NAME(ll_clock),%eax
incl %eax
movl %eax,SYMBOL_NAME(ll_clock)
xorl %eax,%eax
#if 0
strw %ax
pushl %eax
call SYMBOL_NAME(wake_up)
addl $4,%esp
pushl %eax /* Save result on stack */
#else
movl SYMBOL_NAME(timermode), %eax
cmpl $1, %eax
je oneshot
call SYMBOL_NAME(periodic_wake_up)
jmp goon
oneshot: call SYMBOL_NAME(oneshot_wake_up)
goon:
#endif
/* This is the overrun test */
/* Do it after sending EOI to master PIC */
movb $0x0A,%al
movl $0x020,%edx
outb %al,%dx
inb %dx,%al
testb $1,%al
jz Timer_OK
movl $(CLOCK_OVERRUN),%eax
pushl %eax
call SYMBOL_NAME(ll_abort)
 
#ifdef __VIRCSW__
Timer_OK:
 
movw SYMBOL_NAME(currCtx), %ax
cmpw %ax,JmpSel
je NoPreempt2
movw %ax,JmpSel
ljmp JmpZone /* DISPATCH! */
#else
Timer_OK:
#endif
NoPreempt2:
popw %gs
popw %fs
popw %es
popw %ds
popal
iret
/shark/trunk/oslib/kl/stuff.c
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.
*/
 
/* ll_* 32 bit utility functions: here, there are all the things that
we don't know where to put */
 
 
/* This is declared in the LLCtx.Asm/S file */
/* Timer 0 counter */
 
#include <ll/i386/stdlib.h>
#include <ll/i386/string.h>
#include <ll/i386/stdio.h>
#include <ll/i386/mem.h>
#include <ll/i386/cons.h>
 
#include <ll/stdarg.h>
 
FILE(Stuff);
 
int ll_printf(char *fmt, ...)
{
char buf[500];
va_list parms;
int result;
 
va_start(parms, fmt);
result = vksprintf(buf, fmt, parms);
cputs(buf);
va_end(parms);
return (result);
}
/shark/trunk/oslib/mk/os.x
File deleted
/shark/trunk/oslib/mk/gnu.mk
6,7 → 6,7
LIB_PATH = $(BASE)/lib/
LIB_DIR = $(BASE)\lib
 
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__GNU__ -I$(INCL) -DMAIN=__kernel_init__
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__GNU__ -I$(INCL)
ASM_OPT = -x assembler-with-cpp -D__GNU__ -I$(INCL)
LINK_OPT = -T $(BASE)/mk/os.x -Bstatic -Ttext 0x320000 -oformat coff-go32 -s -nostartfiles -nostdlib -L$(LIB_PATH)
 
/shark/trunk/oslib/mk/linux.mk
6,7 → 6,7
LIB_PATH = $(BASE)/lib/
LIB_DIR = $(BASE)/lib
 
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__LINUX__ -DMAIN=__kernel_init__ -I$(INCL)
C_OPT = -Wall -O -finline-functions -fno-builtin -nostdinc -D__LINUX__ -I$(INCL)
ASM_OPT = -x assembler-with-cpp -D__LINUX__ -I$(INCL)
LINK_OPT = -Bstatic -Ttext 0x220000 -s -nostartfiles -nostdlib -L$(LIB_PATH)
 
/shark/trunk/oslib/libc/cons1.c
0,0 → 1,198
/* 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;
 
/* MG */
extern int cons_columns; /* number of screen columns */
extern int cons_rows; /* number of screen rows */
 
/* 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
/* MG */
cons_columns=lmempeekw((LIN_ADDR)0x0044a);
cons_rows=lmempeekb((LIN_ADDR)0x00484)+1;
 
bios_attr = lmempeekb((LIN_ADDR)0xB8000 + cons_columns * 2 -1);
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 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*cons_columns + 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 = 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*cons_columns+x)));
lmempokew((LIN_ADDR)(v + 2*((y-1)*cons_columns+x)),w);
}
for (x = x1; x <= x2; x++)
lmempokew((LIN_ADDR)(v + 2*((y-1)*cons_columns+x)),xattr);
}
 
void scroll(void)
{
_scroll(bios_attr,0,0,(cons_columns-1),(cons_rows-1));
}
 
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 >= cons_columns) {
x = 0;
if (y == (cons_rows-1)) 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 == (cons_rows-1)) scroll();
else y++;
break;
case '\b' : x--;
lmempokeb((LIN_ADDR)(v + 2*(x + y*cons_columns)),' ');
x++;
break;
default : lmempokeb((LIN_ADDR)(v + 2*(x + y*cons_columns)),c);
x++;
if (x > cons_columns) {
x = 0;
if (y == (cons_rows-1)) scroll();
else y++;
}
}
place(x,y);
}
 
void cputs(char *s)
{
char c;
while (*s != '\0') {
c = *s++;
cputc(c);
}
}
 
 
/shark/trunk/oslib/libc/cons2.c
0,0 → 1,134
/* 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;
 
/* MG */
int cons_columns; /* number of screen columns */
int cons_rows; /* number of screen rows */
 
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+cons_columns*2*j + 2*active_page*PAGE_SIZE),w);
place(x1,y1);
bios_y = y1;
bios_x = x1;
}
 
void clear()
{
_clear(' ',bios_attr,0,0,(cons_columns-1),(cons_rows-1));
}
 
void puts_xy(int x,int y,char attr,char *s)
{
LIN_ADDR v = (LIN_ADDR)(0xB8000 + (cons_columns*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 + (cons_columns*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 + (cons_columns*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/trunk/oslib/libc/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(const char *fmt,...)
{
static char cbuf[500];
va_list parms;
int result;
 
va_start(parms,fmt);
result = vksprintf(cbuf,(char *)fmt,parms);
va_end(parms);
cputs(cbuf);
return(result);
}
/shark/trunk/oslib/libc/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/trunk/oslib/examples/syscalls.c
File deleted
/shark/trunk/oslib/xlib/idtinit.c
File deleted
/shark/trunk/oslib/xlib/vm86-exc.s
0,0 → 1,73
/* 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.
*/
 
/* Virtual VM86 Mode swith return handler */
 
.title "vm86-exc.S"
 
#include <ll/i386/sel.h>
#include <ll/i386/linkage.h>
#include <ll/i386/defs.h>
 
 
#ifdef __LINUX__
# define P2ALIGN(p2) .align (1<<(p2))
#else
# define P2ALIGN(p2) .align p2
#endif
#ifdef __LINUX__
#define FUNCSYM(x) .type x,@function
#else
#define FUNCSYM(x) /* nothing */
#endif
 
#define TEXT_ALIGN 4
 
.data
 
ASMFILE(VM86-Exc)
 
.text
.globl SYMBOL_NAME(vm86_exc)
 
SYMBOL_NAME_LABEL(vm86_exc)
/*
movl $0xAAAA, %eax
movl $0xBBBB, %ebx
movl $0xCCCC, %ecx
movl $0xDDDD, %edx
*/
pushal
pushfl
movw $(X_FLATDATA_SEL),%ax
movw %ax,%es
movw %ax,%ds
/*
movl $0xB8020,%edi
movl $'*',%ds:(%edi)
pushl $1
*/
cld
pushl %esp
call SYMBOL_NAME(vm86_return)
addl $4,%esp
iret