Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 41 → Rev 42

/shark/trunk/oslib/lib/readme
0,0 → 1,0
This file is to force CVS to export the oslib/lib directory
/shark/trunk/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/trunk/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/trunk/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/trunk/oslib/ll/limits.h
0,0 → 1,4
#ifndef __LL_LIMITS_H__
#define __LL_LIMITS_H__
#include <ll/i386/limits.h>
#endif
/shark/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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 10
 
#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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/oslib/ll/i386/hw-instr.h
0,0 → 1,234
/* 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>
BEGIN_DEF
 
#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>
 
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/trunk/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 < 15) {
i = irq + PIC2_BASE;
} else {
return -1;
}
l1_int_bind(i, f);
return 1;
}
 
END_DEF
#endif /* __PIC_H__ */
/shark/trunk/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
repnz; scasb
jnz 1f
dec %%edi
1: "
: "=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/trunk/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/trunk/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/trunk/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>
BEGIN_DEF
 
#include <ll/stdarg.h>
 
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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/oslib/ll/stdarg.h
0,0 → 1,89
/*
* 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.1 2003-01-30 09:43:03 pj Exp $
 
File: $File$
Revision: $Revision: 1.1 $
Last update: $Date: 2003-01-30 09:43:03 $
------------
 
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>
BEGIN_DEF
 
#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>
 
#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/trunk/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/trunk/oslib/ll/float.h
0,0 → 1,4
#ifndef __LL_FLOAT_H__
#define __LL_FLOAT_H__
#include <ll/i386/float.h>
#endif
/shark/trunk/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/trunk/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/trunk/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/trunk/oslib/ll/sys/ll/aspace.h
0,0 → 1,65
/* 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>
BEGIN_DEF
 
/* 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>
 
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/trunk/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/trunk/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/trunk/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/trunk/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);
 
BEGIN_DEF
#endif /* __LL_SYS_LL_LL_MEM_H_ */
/shark/trunk/oslib/ll/sys/ll/event.h
0,0 → 1,84
/* 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>
BEGIN_DEF
 
#include <ll/sys/ll/time.h>
#include <ll/sys/ll/ll-data.h>
#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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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/trunk/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