Modestus Moon OS  R4
CS 450 project
tables.h File Reference
#include "system.h"
Include dependency graph for tables.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  idt_entry_struct
 
struct  idt_struct
 
struct  gdt_descriptor_struct
 
struct  gdt_entry_struct
 

Functions

struct idt_entry_struct __attribute__ ((packed)) idt_entry
 
void idt_set_gate (u8int idx, u32int base, u16int sel, u8int flags)
 
void gdt_init_entry (int idx, u32int base, u32int limit, u8int access, u8int flags)
 
void init_idt ()
 
void init_gdt ()
 

Variables

u16int base_low
 
u16int sselect
 
u8int zero
 
u8int flags
 
u16int base_high
 
u16int limit
 
u32int base
 
u16int limit_low
 
u8int base_mid
 
u8int access
 

Function Documentation

struct idt_entry_struct __attribute__ ( (packed)  )
void gdt_init_entry ( int  idx,
u32int  base,
u32int  limit,
u8int  access,
u8int  flags 
)

Definition at line 57 of file tables.c.

References access, and gdt_entries.

Referenced by init_gdt().

59 {
60  gdt_entry *new_entry = &gdt_entries[idx];
61  new_entry->base_low = (base & 0xFFFF);
62  new_entry->base_mid = (base >> 16) & 0xFF;
63  new_entry->base_high = (base >> 24) & 0xFF;
64  new_entry->limit_low = (limit & 0xFFFF);
65  new_entry->flags = (limit >> 16) & 0xFF;
66  new_entry->flags |= flags & 0xF0;
67  new_entry->access = access;
68 }
u32int base
Definition: tables.h:53
u16int limit
Definition: tables.h:52
u8int access
Definition: tables.h:55
u8int flags
Definition: tables.h:55
gdt_entry gdt_entries[5]
Definition: tables.c:13
void idt_set_gate ( u8int  idx,
u32int  base,
u16int  sel,
u8int  flags 
)

Definition at line 27 of file tables.c.

References flags, and idt_entries.

Referenced by init_irq().

29 {
30  idt_entry *new_entry = &idt_entries[idx];
31  new_entry->base_low = (base & 0xFFFF);
32  new_entry->base_high = (base >> 16) & 0xFFFF;
33  new_entry->sselect = sel;
34  new_entry->zero = 0;
35  new_entry->flags = flags;
36 }
u32int base
Definition: tables.h:53
idt_entry idt_entries[256]
Definition: tables.c:17
u8int flags
Definition: tables.h:55
void init_gdt ( )

Definition at line 75 of file tables.c.

References gdt_entries, gdt_init_entry(), gdt_ptr, limit, and write_gdt_ptr().

Referenced by kmain().

76 {
77  gdt_ptr.limit = 5 * sizeof(gdt_entry) - 1;
78  gdt_ptr.base = (u32int) gdt_entries;
79 
80  u32int limit = 0xFFFFFFFF;
81  gdt_init_entry(0, 0, 0, 0, 0); //required null segment
82  gdt_init_entry(1, 0, limit, 0x9A, 0xCF); //code segment
83  gdt_init_entry(2, 0, limit, 0x92, 0xCF); //data segment
84  gdt_init_entry(3, 0, limit, 0xFA, 0xCF); //user mode code segment
85  gdt_init_entry(4, 0, limit, 0xF2, 0xCF); //user mode data segment
86 
87  write_gdt_ptr((u32int) &gdt_ptr, sizeof(gdt_ptr));
88 }
u16int limit
Definition: tables.h:52
unsigned long u32int
Definition: system.h:27
void write_gdt_ptr(u32int, size_t)
void gdt_init_entry(int idx, u32int base, u32int limit, u8int access, u8int flags)
Definition: tables.c:57
gdt_descriptor gdt_ptr
Definition: tables.c:12
gdt_entry gdt_entries[5]
Definition: tables.c:13
void init_idt ( )

Definition at line 43 of file tables.c.

References idt_entries, idt_ptr, memset(), and write_idt_ptr().

Referenced by kmain().

44 {
45  idt_ptr.limit = 256*sizeof(idt_descriptor) - 1;
46  idt_ptr.base = (u32int)idt_entries;
47  memset(idt_entries, 0, 256*sizeof(idt_descriptor));
48 
50 }
idt_entry idt_entries[256]
Definition: tables.c:17
void write_idt_ptr(u32int)
idt_descriptor idt_ptr
Definition: tables.c:16
unsigned long u32int
Definition: system.h:27
void * memset(void *s, int c, size_t n)
memset Set a region of memory.
Definition: string.c:139

Variable Documentation

u8int access

Definition at line 55 of file tables.h.

Referenced by gdt_init_entry().

u32int base

Definition at line 53 of file tables.h.

Referenced by alloc().

u8int base_high

Definition at line 56 of file tables.h.

u16int base_low

Definition at line 52 of file tables.h.

u8int base_mid

Definition at line 54 of file tables.h.

u8int flags

Definition at line 55 of file tables.h.

Referenced by idt_set_gate().

u16int limit

Definition at line 52 of file tables.h.

Referenced by init_gdt().

u16int limit_low

Definition at line 52 of file tables.h.

u16int sselect

Definition at line 53 of file tables.h.

u8int zero

Definition at line 54 of file tables.h.