Adapt GDT code to our codeing style
GDT code was taken from SOS project
This commit is contained in:
parent
86f55a41ef
commit
05c78e5e0c
12
core/gdt.c
12
core/gdt.c
@ -61,7 +61,7 @@ struct x86_gdt_register {
|
|||||||
|
|
||||||
/* This is not exactly a "virtual" address, ie an adddress such as
|
/* This is not exactly a "virtual" address, ie an adddress such as
|
||||||
those of instructions and data; this is a "linear" address, ie an
|
those of instructions and data; this is a "linear" address, ie an
|
||||||
address in the paged memory. However, in SOS we configure the
|
address in the paged memory. However, we configure the
|
||||||
segmented memory as a "flat" space: the 0-4GB segment-based (ie
|
segmented memory as a "flat" space: the 0-4GB segment-based (ie
|
||||||
"virtual") addresses directly map to the 0-4GB paged memory (ie
|
"virtual") addresses directly map to the 0-4GB paged memory (ie
|
||||||
"linear"), so that the "linear" addresses are numerically equal
|
"linear"), so that the "linear" addresses are numerically equal
|
||||||
@ -106,12 +106,12 @@ struct x86_gdt_register {
|
|||||||
|
|
||||||
/** The actual GDT */
|
/** The actual GDT */
|
||||||
static struct x86_segment_descriptor gdt[] = {
|
static struct x86_segment_descriptor gdt[] = {
|
||||||
[SOS_SEG_NULL] =
|
[SEG_NULL] =
|
||||||
(struct x86_segment_descriptor){
|
(struct x86_segment_descriptor){
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
[SOS_SEG_KCODE] = BUILD_GDTE(0, 1),
|
[SEG_KCODE] = BUILD_GDTE(0, 1),
|
||||||
[SOS_SEG_KDATA] = BUILD_GDTE(0, 0),
|
[SEG_KDATA] = BUILD_GDTE(0, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
int gdtSetup(void)
|
int gdtSetup(void)
|
||||||
@ -139,8 +139,8 @@ int gdtSetup(void)
|
|||||||
movw %%ax, %%fs \n\
|
movw %%ax, %%fs \n\
|
||||||
movw %%ax, %%gs"
|
movw %%ax, %%gs"
|
||||||
:
|
:
|
||||||
: "m"(gdtr), "i"(SOS_BUILD_SEGMENT_REG_VALUE(0, FALSE, SOS_SEG_KCODE)),
|
: "m"(gdtr), "i"(BUILD_SEGMENT_REG_VALUE(0, FALSE, SEG_KCODE)),
|
||||||
"i"(SOS_BUILD_SEGMENT_REG_VALUE(0, FALSE, SOS_SEG_KDATA))
|
"i"(BUILD_SEGMENT_REG_VALUE(0, FALSE, SEG_KDATA))
|
||||||
: "memory", "eax");
|
: "memory", "eax");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -16,15 +16,14 @@
|
|||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
USA.
|
USA.
|
||||||
*/
|
*/
|
||||||
#ifndef _SOS_GDT_H_
|
#pragma once
|
||||||
#define _SOS_GDT_H_
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file gdt.h
|
* @file gdt.h
|
||||||
*
|
*
|
||||||
* The routines that manage the GDT, the table that maps the virtual
|
* The routines that manage the GDT, the table that maps the virtual
|
||||||
* addresses (data/instructions, segment-relative), to "linear"
|
* addresses (data/instructions, segment-relative), to "linear"
|
||||||
* addresses (ie paged-memory). In SOS/x86, we use a "flat" virtual
|
* addresses (ie paged-memory). Here, we use a "flat" virtual
|
||||||
* space, ie the virtual and linear spaces are equivalent.
|
* space, ie the virtual and linear spaces are equivalent.
|
||||||
*
|
*
|
||||||
* @see Intel x86 doc vol 3, chapter 3
|
* @see Intel x86 doc vol 3, chapter 3
|
||||||
@ -36,4 +35,3 @@
|
|||||||
*/
|
*/
|
||||||
int gdtSetup(void);
|
int gdtSetup(void);
|
||||||
|
|
||||||
#endif /* _SOS_GDT_H_ */
|
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
USA.
|
USA.
|
||||||
*/
|
*/
|
||||||
#ifndef _SOS_HWSEGS_H_
|
#pragma once
|
||||||
#define _SOS_HWSEGS_H_
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file segments.h
|
* @file segments.h
|
||||||
@ -37,15 +36,15 @@
|
|||||||
*
|
*
|
||||||
* @see gdt.h
|
* @see gdt.h
|
||||||
*/
|
*/
|
||||||
#define SOS_SEG_NULL 0 /* NULL segment, unused by the procesor */
|
#define SEG_NULL 0 /* NULL segment, unused by the procesor */
|
||||||
#define SOS_SEG_KCODE 1 /* Kernel code segment */
|
#define SEG_KCODE 1 /* Kernel code segment */
|
||||||
#define SOS_SEG_KDATA 2 /* Kernel data segment */
|
#define SEG_KDATA 2 /* Kernel data segment */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper macro that builds a segment register's value
|
* Helper macro that builds a segment register's value
|
||||||
*/
|
*/
|
||||||
#define SOS_BUILD_SEGMENT_REG_VALUE(desc_privilege,in_ldt,seg_index) \
|
#define BUILD_SEGMENT_REG_VALUE(desc_privilege,in_ldt,seg_index) \
|
||||||
( (((desc_privilege) & 0x3) << 0) \
|
( (((desc_privilege) & 0x3) << 0) \
|
||||||
| (((in_ldt)?1:0) << 2) \
|
| (((in_ldt)?1:0) << 2) \
|
||||||
| ((seg_index) << 3) )
|
| ((seg_index) << 3) )
|
||||||
@ -55,5 +54,3 @@
|
|||||||
* Local segment selectors (LDT) for SOS/x86
|
* Local segment selectors (LDT) for SOS/x86
|
||||||
*/
|
*/
|
||||||
/* None */
|
/* None */
|
||||||
|
|
||||||
#endif /* _SOS_HWSEGS_H_ */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user