[LinksOS CVS Commit]linksos/main/include gdt.h,NONE,1.1 io.h,1.2,1.3 kstdio.h,1.1,1.2
Status: Inactive
Brought to you by:
terencevs
|
From: <bg...@us...> - 2003-01-26 11:31:54
|
Update of /cvsroot/linksos/linksos/main/include
In directory sc8-pr-cvs1:/tmp/cvs-serv2091/main/include
Modified Files:
kstdio.h
Added Files:
gdt.h io.h
Log Message:
Title: Rebuild of CVS
Changes: Added license and returned code that was removed
Effects: We now have a bootable hello world kernel with correct copyright notice
a=n/a b=n/a
--- NEW FILE: gdt.h ---
/*
Copyright (c) 2003, LinksOS Developer Team
All rights reserved.
*/
#ifndef __GDT_H
#define __GDT_H
/*
* The desc_table, stnd_desc and gate_desc macros piece together a descriptor
* table.
*
* Example usage:
*
* desc_table(GDT, 2) {
* stnd_desc(0, 0, 0),
* stnd_desc(0, 0xfffff, (D_CODE + D_READ + D_BIG + D_BIG_LIM))
* };
*
* gate_desc(offset, selector, control) ;For gate descriptors
* stnd_desc(base, limit, control) ;For all other descriptors
*
* base is the full 32 bit base address of the segment
* limit is one less than the segment length in 1 or 4K byte units
* control the sum of all the "D_" equates which apply (for call gates, you
* also add the "parameter dword count" to flags).
*
* desc_table(symbol, size) ;Start a descriptor table
*
* symbol is the C symbol that is used for this descriptor table
* size is the amount of descriptors defined in this table
*
* The descriptor table can be accessed in the code through the symbol [symbol],
* which is defined as an array of DT_entry unions. Every DT_entry union can
* contain either a normal descriptor, gate descriptor, or some other value
* which is 64 bits in size (this could be used to store custom info in the
* dummy descriptor of the GDT, for instance.)
*
* The dummy value can be inserted like this:
*
* desc_table(GDT, 2) {
* {dummy: 0x1234567890123456},
* ...
* };
*/
/*
* Each descriptor should have exactly one of next 8 codes to define the
* type of descriptor
*/
#define D_LDT 0x200 /* LDT segment */
#define D_TASK 0x500 /* Task gate */
#define D_TSS 0x900 /* TSS */
#define D_CALL 0x0C00 /* 386 call gate */
#define D_INT 0x0E00 /* 386 interrupt gate */
#define D_TRAP 0x0F00 /* 386 trap gate */
#define D_DATA 0x1000 /* Data segment */
#define D_CODE 0x1800 /* Code segment */
/*
* Descriptors may include the following as appropriate:
*/
#define D_DPL3 0x6000 /* DPL3 or mask for DPL */
#define D_DPL2 0x4000 /* DPL2 or mask for DPL */
#define D_DPL1 0x2000 /* DPL1 or mask for DPL */
#define D_PRESENT 0x8000 /* Present */
#define D_NOT_PRESENT 0x8000 /* Not Present */
/* Note, the PRESENT bit is set by default */
/* Include NOT_PRESENT to turn it off */
/* Do not specify D_PRESENT */
/*
* Segment descriptors (not gates) may include:
*/
#define D_ACC 0x100 /* Accessed (Data or Code) */
#define D_WRITE 0x200 /* Writable (Data segments only) */
#define D_READ 0x200 /* Readable (Code segments only) */
#define D_BUSY 0x200 /* Busy (TSS only) */
#define D_EXDOWN 0x400 /* Expand down (Data segments only) */
#define D_CONFORM 0x400 /* Conforming (Code segments only) */
#define D_BIG 0x40 /* Default to 32 bit mode */
#define D_BIG_LIM 0x80 /* Limit is in 4K units */
/*
* Now we define the structures for descriptors and gates:
*/
struct x86_desc {
unsigned short limit_low; /* limit 0..15 */
unsigned short base_low; /* base 0..15 */
unsigned char base_med; /* base 16..23 */
unsigned char access; /* access byte */
unsigned int limit_high:4; /* limit 16..19 */
unsigned int granularity:4; /* granularity */
unsigned char base_high; /* base 24..31 */
} __attribute__ ((packed));
struct x86_gate {
unsigned short offset_low; /* offset 0..15 */
unsigned short selector; /* selector */
unsigned short access; /* access flags */
unsigned short offset_high; /* offset 16..31 */
} __attribute__ ((packed));
/*
* Descriptor tables are basically arrays of either standard or gate
* descriptors; The exception is the first descriptor, which is a
* 'dummy' and can be filled with anything without crashing the machine.
*
* We define the union DT_entry as a general type of entry in a descriptor
* table; It can contain a normal descriptor, a gate descriptor, or any
* 64-bit number (for defining the dummy entries, if neccessary.)
*/
union DT_entry {
struct x86_desc desc; /* Normal descriptor */
struct x86_gate gate; /* Gate descriptor */
unsigned long long dummy; /* Any other info */
};
/*
* Now we perform the macro magic of the day.
*/
#define desc_table(name,length) union DT_entry name[length] =
#define stnd_desc(base, limit, control) {desc: {(limit & 0xffff), (base & 0xffff), ((base >> 16) & 0xff), \
((control+D_PRESENT) >> 8), (limit >> 16), \
((control & 0xff) >> 4), (base >> 24)}}
#define gate_desc(offset, selector, control) {gate: {(offset & 0xffff), selector, \
(control+D_PRESENT), (offset >> 16) }}
/* These are bound to look a bit cryptic, so I'll just show what the result
* would look like:
*
* desc_table(GDT, 3) {
* stnd_desc(base, limit, control),
* stnd_desc(base, limit, control),
* gate_desc(offset, selector, control)
* };
*
* ... would produce something looking like:
*
* union DT_entry GDT[3] = {
* {desc: {limit_low, base_low, base_med, access, limit_high, granularity, base_high}},
* {desc: {limit_low, base_low, base_med, access, limit_high, granularity, base_high}},
* {gate: {offset_low, selector, word_count, access, offset_high}}
* };
*
* The values are conveted using a bit of cryptic, but straightforward magic.
*/
#endif
Index: kstdio.h
===================================================================
RCS file: /cvsroot/linksos/linksos/main/include/kstdio.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** kstdio.h 24 Dec 2002 00:00:47 -0000 1.1
--- kstdio.h 26 Jan 2003 11:31:50 -0000 1.2
***************
*** 1,21 ****
! /****************************************************************************\
! ** filename: kstdio.h **
! ** creation date: 11/29/2002, 0103 MST **
! ** author: Charles Banas **
! ** version: 0.01 **
! ******************************************************************************
! ** revision history: **
! ** 11/29/2002 - 0103 MST - Charles **
! ** added kprintf(). let's see if this baby links, eh. **
! \****************************************************************************/
!
! #ifndef __DOORS_KSTDIO_H__
! #define __DOORS_KSTDIO_H__
! //extern 'c' {
void kprintf(char* text);
! //};
!
! #endif
--- 1,11 ----
! /*
! Copyright (c) 2003, LinksOS Developer Team
! All rights reserved.
! */
! #ifndef __KSTDIO_H__
! #define __KSTDIO_H__
void kprintf(char* text);
! #endif /* __KSTDIO_H__ */
|