1 | /*
|
---|
2 | ** Copyright 2002, Michael Noisternig. All rights reserved.
|
---|
3 | ** Distributed under the terms of the NewOS License.
|
---|
4 | */
|
---|
5 | #ifndef _I386_SELECTOR_H_
|
---|
6 | #define _I386_SELECTOR_H_
|
---|
7 |
|
---|
8 | #include <arch/i386/types.h>
|
---|
9 |
|
---|
10 | typedef uint32 selector_id;
|
---|
11 | typedef uint64 selector_type;
|
---|
12 |
|
---|
13 | // DATA segments are read-only
|
---|
14 | // CODE segments are execute-only
|
---|
15 | // both can be modified by using the suffixed enum versions
|
---|
16 | // legend: w = writable
|
---|
17 | // d = expand down
|
---|
18 | // r = readable
|
---|
19 | // c = conforming
|
---|
20 | enum segment_type {
|
---|
21 | DATA = 0x8, DATA_w, DATA_d, DATA_wd, CODE, CODE_r, CODE_c, CODE_rc
|
---|
22 | };
|
---|
23 |
|
---|
24 | #define SELECTOR(base,limit,type,mode32) \
|
---|
25 | (((uint64)(((((uint32)base)>>16)&0xff) | (((uint32)base)&0xff000000) | ((type)<<9) | ((mode32)<<22) | (1<<15))<<32) \
|
---|
26 | | ( (limit) >= (1<<20) ? (((limit)>>12)&0xffff) | ((uint64)(((limit)>>12)&0xf0000)<<32) | ((uint64)1<<(23+32)) : ((limit)&0xffff) | ((uint64)((limit)&0xf0000)<<32) ) \
|
---|
27 | | ((((uint32)base)&0xffff)<<16))
|
---|
28 |
|
---|
29 | void i386_selector_init( void *gdt );
|
---|
30 | selector_id i386_selector_add( selector_type selector );
|
---|
31 | void i386_selector_remove( selector_id id );
|
---|
32 | selector_type i386_selector_get( selector_id id );
|
---|
33 |
|
---|
34 | #endif
|
---|
35 |
|
---|