Main Page | Directories | File List | Globals

gates.c File Reference

#include <asm/types.h>
#include <asm/tss.h>
#include <asm/desc.h>

Include dependency graph for gates.c:

Go to the source code of this file.

Defines

#define CODE_RE_DESC_TYPE   0x1A
#define DATA_RW_DESC_TYPE   0x12
#define INTERRUPT_GATE_TYPE   0x0E
#define TRAP_GATE_TYPE   0x0F
#define TASK_GATE_TYPE   0x05
#define TSS_DESC_TYPE   0x09
#define GATE_PRESENT_FLAG   1 << 7
#define GRANULARITY_FLAG   1 << 7
#define DB_FLAG   1 << 6
#define set_type_byte(type)

Functions

void set_IDT_gate_descriptor (struct desc_struct *desc_table, u16 selector, void *offset, u8 type_byte)
void set_TSS_descriptor (struct desc_struct *desc_table, void *offset, u32 limit, u8 type_byte)
void set_GDT_descriptor (struct desc_struct *desc_table, u32 base, u32 limit, u8 type_byte, u8 db)
void set_code_desc (u32 entry, u32 base, u32 limit, u8 dpl, u8 db)
void set_data_desc (u32 entry, u32 base, u32 limit, u8 dpl, u8 db)
void set_interrupt_gate (u32 entry, u16 selector, void *offset, u8 dpl)
void set_trap_gate (u32 entry, u16 selector, void *offset, u8 dpl)
void set_task_gate (u32 entry, u16 selector, u8 dpl)
void set_TSS_desc (u32 entry, void *offset, u32 limit, u8 dpl)

Variables

desc_struct idt_table [256]


Define Documentation

#define CODE_RE_DESC_TYPE   0x1A
 

Definition at line 18 of file gates.c.

Referenced by set_code_desc().

#define DATA_RW_DESC_TYPE   0x12
 

Definition at line 19 of file gates.c.

Referenced by set_data_desc().

#define DB_FLAG   1 << 6
 

Definition at line 26 of file gates.c.

#define GATE_PRESENT_FLAG   1 << 7
 

Definition at line 24 of file gates.c.

#define GRANULARITY_FLAG   1 << 7
 

Definition at line 25 of file gates.c.

#define INTERRUPT_GATE_TYPE   0x0E
 

Definition at line 20 of file gates.c.

Referenced by set_interrupt_gate().

#define set_type_byte type   ) 
 

Value:

u8 type_byte = 0;                       \
    type_byte |= GATE_PRESENT_FLAG;     \
    type_byte |= type;                  \
    type_byte |= dpl << 5;

Definition at line 28 of file gates.c.

Referenced by set_code_desc(), set_data_desc(), set_interrupt_gate(), set_task_gate(), set_trap_gate(), and set_TSS_desc().

#define TASK_GATE_TYPE   0x05
 

Definition at line 22 of file gates.c.

Referenced by set_task_gate().

#define TRAP_GATE_TYPE   0x0F
 

Definition at line 21 of file gates.c.

Referenced by set_trap_gate().

#define TSS_DESC_TYPE   0x09
 

Definition at line 23 of file gates.c.

Referenced by set_TSS_desc().


Function Documentation

void set_code_desc u32  entry,
u32  base,
u32  limit,
u8  dpl,
u8  db
 

Definition at line 68 of file gates.c.

References CODE_RE_DESC_TYPE, set_GDT_descriptor(), and set_type_byte.

Referenced by apm_init().

00069 {
00070     set_type_byte(CODE_RE_DESC_TYPE);    
00071     set_GDT_descriptor(gdt_table + entry, base, limit, type_byte, db);
00072 }

Here is the call graph for this function:

void set_data_desc u32  entry,
u32  base,
u32  limit,
u8  dpl,
u8  db
 

Definition at line 74 of file gates.c.

References DATA_RW_DESC_TYPE, set_GDT_descriptor(), and set_type_byte.

Referenced by apm_init().

00075 {
00076     set_type_byte(DATA_RW_DESC_TYPE);    
00077     set_GDT_descriptor(gdt_table + entry, base, limit, type_byte, db);
00078 }

Here is the call graph for this function:

void set_GDT_descriptor struct desc_struct *  desc_table,
u32  base,
u32  limit,
u8  type_byte,
u8  db
 

Definition at line 58 of file gates.c.

Referenced by set_code_desc(), and set_data_desc().

00059 {
00060     u16 *table = (u16 *)desc_table;
00061     
00062     table[0] = (u16)(limit & 0xFFFF);
00063     table[1] = (u16)(base & 0xFFFF);
00064     table[2] = (u16)((type_byte << 8) | ((base >> 16) & 0xFF));
00065     table[3] = (u16)(((base >> 16) & 0xFF00) | ((limit >> 16) & 0x0F) | ((db & 0x01) << 6));
00066 }

void set_IDT_gate_descriptor struct desc_struct *  desc_table,
u16  selector,
void *  offset,
u8  type_byte
 

Definition at line 36 of file gates.c.

Referenced by set_interrupt_gate(), set_task_gate(), and set_trap_gate().

00037 {
00038     u16 *table = (u16 *)desc_table;
00039     u32 offset_32 = (u32)offset;
00040     
00041     table[0] = (u16)(offset_32 & 0xFFFF);
00042     table[1] = selector;
00043     table[2] = (type_byte << 8);
00044     table[3] = (u16)((offset_32 >> 16) & 0xFFFF);
00045 }

void set_interrupt_gate u32  entry,
u16  selector,
void *  offset,
u8  dpl
 

Definition at line 80 of file gates.c.

References idt_table, INTERRUPT_GATE_TYPE, set_IDT_gate_descriptor(), and set_type_byte.

Referenced by faults_init(), and irqs_init().

00081 {
00082     set_type_byte(INTERRUPT_GATE_TYPE);    
00083     set_IDT_gate_descriptor(idt_table + entry, selector, offset, type_byte);
00084 }

Here is the call graph for this function:

void set_task_gate u32  entry,
u16  selector,
u8  dpl
 

Definition at line 92 of file gates.c.

References idt_table, set_IDT_gate_descriptor(), set_type_byte, and TASK_GATE_TYPE.

00093 {
00094     set_type_byte(TASK_GATE_TYPE);    
00095     set_IDT_gate_descriptor(idt_table + entry, selector, 0, type_byte);
00096 }

Here is the call graph for this function:

void set_trap_gate u32  entry,
u16  selector,
void *  offset,
u8  dpl
 

Definition at line 86 of file gates.c.

References idt_table, set_IDT_gate_descriptor(), set_type_byte, and TRAP_GATE_TYPE.

Referenced by faults_init().

00087 {
00088     set_type_byte(TRAP_GATE_TYPE);    
00089     set_IDT_gate_descriptor(idt_table + entry, selector, offset, type_byte);
00090 }

Here is the call graph for this function:

void set_TSS_desc u32  entry,
void *  offset,
u32  limit,
u8  dpl
 

Definition at line 98 of file gates.c.

References set_TSS_descriptor(), set_type_byte, and TSS_DESC_TYPE.

Referenced by task_exit(), task_fork(), and task_kernel_create().

00099 {
00100     set_type_byte(TSS_DESC_TYPE);        
00101     set_TSS_descriptor(gdt_table + entry, offset, limit, type_byte);
00102 }

Here is the call graph for this function:

void set_TSS_descriptor struct desc_struct *  desc_table,
void *  offset,
u32  limit,
u8  type_byte
 

Definition at line 47 of file gates.c.

Referenced by set_TSS_desc().

00048 {
00049     u16 *table = (u16 *)desc_table;
00050     u32 base_32 = (u32)offset;
00051     
00052     table[0] = (u16)(limit   & 0xFFFF);
00053     table[1] = (u16)(base_32 & 0xFFFF);
00054     table[2] = (u16)((type_byte << 8) | ((base_32 >> 16) & 0xFF));
00055     table[3] = (u16)(((base_32 >> 16) & 0xFF00) | ((limit >> 16) & 0x0F));
00056 }


Variable Documentation

struct desc_struct idt_table[256]
 

Referenced by set_interrupt_gate(), set_task_gate(), and set_trap_gate().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix