2 C based implemention of IA32 interrupt handling only
3 requiring a minimal assembly interrupt entry point.
5 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 // Global descriptor table (GDT) Template
22 STATIC GDT_ENTRIES GdtTemplate
= {
31 0x0, // limit 19:16, flags
38 0x0FFFF, // limit 0xFFFFF
41 0x092, // present, ring 0, data, expand-up, writable
42 0x0CF, // page-granular, 32-bit
49 0x0FFFF, // limit 0xFFFFF
52 0x09A, // present, ring 0, data, expand-up, writable
53 0x0CF, // page-granular, 32-bit
60 0x0FFFF, // limit 0xFFFFF
63 0x092, // present, ring 0, data, expand-up, writable
64 0x0CF, // page-granular, 32-bit
71 0x0FFFF, // limit 0xFFFFF
74 0x09A, // present, ring 0, data, expand-up, writable
75 0x0CF, // page-granular, 32-bit
82 0x0FFFF, // limit 0xFFFFF
85 0x09B, // present, ring 0, code, expand-up, writable
86 0x0AF, // LimitHigh (CS.L=1, CS.D=0)
96 0x0, // present, ring 0, data, expand-up, writable
97 0x0, // page-granular, 32-bit
107 0x0, // present, ring 0, data, expand-up, writable
108 0x0, // page-granular, 32-bit
114 Initialize Global Descriptor Table.
118 InitGlobalDescriptorTable (
123 IA32_DESCRIPTOR gdtPtr
;
126 // Allocate Runtime Data for the GDT
128 gdt
= AllocateRuntimePool (sizeof (GdtTemplate
) + 8);
129 ASSERT (gdt
!= NULL
);
130 gdt
= ALIGN_POINTER (gdt
, 8);
133 // Initialize all GDT entries
135 CopyMem (gdt
, &GdtTemplate
, sizeof (GdtTemplate
));
138 // Write GDT register
140 gdtPtr
.Base
= (UINT32
)(UINTN
)(VOID
*) gdt
;
141 gdtPtr
.Limit
= (UINT16
) (sizeof (GdtTemplate
) - 1);
142 AsmWriteGdtr (&gdtPtr
);
145 // Update selector (segment) registers base on new GDT
147 SetCodeSelector ((UINT16
)CPU_CODE_SEL
);
148 SetDataSelectors ((UINT16
)CPU_DATA_SEL
);