Adapt GDT code to our codeing style

GDT code was taken from SOS project
This commit is contained in:
Mathieu Maret 2018-07-26 12:23:49 +02:00
parent 86f55a41ef
commit 05c78e5e0c
3 changed files with 13 additions and 18 deletions

View File

@ -61,7 +61,7 @@ struct x86_gdt_register {
/* This is not exactly a "virtual" address, ie an adddress such as
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
"virtual") addresses directly map to the 0-4GB paged memory (ie
"linear"), so that the "linear" addresses are numerically equal
@ -106,12 +106,12 @@ struct x86_gdt_register {
/** The actual GDT */
static struct x86_segment_descriptor gdt[] = {
[SOS_SEG_NULL] =
[SEG_NULL] =
(struct x86_segment_descriptor){
0,
},
[SOS_SEG_KCODE] = BUILD_GDTE(0, 1),
[SOS_SEG_KDATA] = BUILD_GDTE(0, 0),
[SEG_KCODE] = BUILD_GDTE(0, 1),
[SEG_KDATA] = BUILD_GDTE(0, 0),
};
int gdtSetup(void)
@ -139,8 +139,8 @@ int gdtSetup(void)
movw %%ax, %%fs \n\
movw %%ax, %%gs"
:
: "m"(gdtr), "i"(SOS_BUILD_SEGMENT_REG_VALUE(0, FALSE, SOS_SEG_KCODE)),
"i"(SOS_BUILD_SEGMENT_REG_VALUE(0, FALSE, SOS_SEG_KDATA))
: "m"(gdtr), "i"(BUILD_SEGMENT_REG_VALUE(0, FALSE, SEG_KCODE)),
"i"(BUILD_SEGMENT_REG_VALUE(0, FALSE, SEG_KDATA))
: "memory", "eax");
return 0;

View File

@ -16,15 +16,14 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
#ifndef _SOS_GDT_H_
#define _SOS_GDT_H_
#pragma once
/**
* @file gdt.h
*
* The routines that manage the GDT, the table that maps the virtual
* 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.
*
* @see Intel x86 doc vol 3, chapter 3
@ -36,4 +35,3 @@
*/
int gdtSetup(void);
#endif /* _SOS_GDT_H_ */

View File

@ -16,8 +16,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
#ifndef _SOS_HWSEGS_H_
#define _SOS_HWSEGS_H_
#pragma once
/**
* @file segments.h
@ -37,15 +36,15 @@
*
* @see gdt.h
*/
#define SOS_SEG_NULL 0 /* NULL segment, unused by the procesor */
#define SOS_SEG_KCODE 1 /* Kernel code segment */
#define SOS_SEG_KDATA 2 /* Kernel data segment */
#define SEG_NULL 0 /* NULL segment, unused by the procesor */
#define SEG_KCODE 1 /* Kernel code segment */
#define SEG_KDATA 2 /* Kernel data segment */
/**
* 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) \
| (((in_ldt)?1:0) << 2) \
| ((seg_index) << 3) )
@ -55,5 +54,3 @@
* Local segment selectors (LDT) for SOS/x86
*/
/* None */
#endif /* _SOS_HWSEGS_H_ */