]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/BootSector/st16_64.S
Update the copyright notice format
[mirror_edk2.git] / DuetPkg / BootSector / st16_64.S
CommitLineData
f3eb2131 1#------------------------------------------------------------------------------\r
2#*\r
b1f700a8
HT
3#* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
4#* This program and the accompanying materials \r
f3eb2131 5#* are licensed and made available under the terms and conditions of the BSD License \r
6#* which accompanies this distribution. The full text of the license may be found at \r
7#* http://opensource.org/licenses/bsd-license.php \r
8#* \r
9#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11#* \r
12#* st16_64.asm\r
13#* \r
14#* Abstract:\r
15#*\r
16#------------------------------------------------------------------------------\r
17\r
18\r
19 .stack: \r
20 .486p: \r
21 .code16\r
22\r
72f7d3c3 23.equ FAT_DIRECTORY_ENTRY_SIZE, 0x020\r
24.equ FAT_DIRECTORY_ENTRY_SHIFT, 5\r
25.equ BLOCK_SIZE, 0x0200\r
26.equ BLOCK_MASK, 0x01ff\r
f3eb2131 27.equ BLOCK_SHIFT, 9\r
28\r
29 .org 0x0\r
30Ia32Jump: \r
31 jmp BootSectorEntryPoint # JMP inst - 3 bytes\r
32 nop\r
33\r
72f7d3c3 34OemId: .ascii "INTEL " # OemId - 8 bytes\r
35\r
36SectorSize: .word 0 # Sector Size - 16 bits\r
37SectorsPerCluster: .byte 0 # Sector Per Cluster - 8 bits\r
38ReservedSectors: .word 0 # Reserved Sectors - 16 bits\r
39NoFats: .byte 0 # Number of FATs - 8 bits\r
40RootEntries: .word 0 # Root Entries - 16 bits\r
41Sectors: .word 0 # Number of Sectors - 16 bits\r
42Media: .byte 0 # Media - 8 bits - ignored\r
43SectorsPerFat: .word 0 # Sectors Per FAT - 16 bits\r
44SectorsPerTrack: .word 0 # Sectors Per Track - 16 bits - ignored\r
45Heads: .word 0 # Heads - 16 bits - ignored\r
46HiddenSectors: .long 0 # Hidden Sectors - 32 bits - ignored\r
47LargeSectors: .long 0 # Large Sectors - 32 bits \r
48PhysicalDrive: .byte 0 # PhysicalDriveNumber - 8 bits - ignored\r
49CurrentHead: .byte 0 # Current Head - 8 bits\r
50Signature: .byte 0 # Signature - 8 bits - ignored\r
51VolId: .ascii " " # Volume Serial Number- 4 bytes\r
52FatLabel: .ascii " " # Label - 11 bytes\r
53SystemId: .ascii "FAT16 " # SystemId - 8 bytes\r
f3eb2131 54\r
55BootSectorEntryPoint: \r
56 # ASSUME ds:@code\r
57 # ASSUME ss:@code\r
58 # ds = 1000, es = 2000 + x (size of first cluster >> 4)\r
59 # cx = Start Cluster of EfiLdr\r
60 # dx = Start Cluster of Efivar.bin\r
61\r
62# Re use the BPB data stored in Boot Sector\r
63 movw $0x7c00,%bp\r
64\r
65 pushw %cx\r
66# Read Efivar.bin\r
67# 1000:dx = DirectoryEntry of Efivar.bin -> BS.com has filled already\r
68 movw $0x1900,%ax\r
69 movw %ax,%es\r
70 testw %dx,%dx\r
71 jnz CheckVarStoreSize\r
72\r
73 movb $1,%al\r
74NoVarStore: \r
75 pushw %es\r
76# Set the 5th byte start @ 0:19000 to non-zero indicating we should init var store header in DxeIpl\r
b29a823d 77 movb %al, %es:(4)\r
f3eb2131 78 jmp SaveVolumeId\r
79\r
80CheckVarStoreSize: \r
81 movw %dx,%di\r
82 cmpl $0x4000, %ds:2(%di)\r
83 movb $2,%al\r
84 jne NoVarStore\r
85\r
86LoadVarStore: \r
87 movb $0,%al\r
72f7d3c3 88 movb %al, %es:(4)\r
f3eb2131 89 movw (%di), %cx\r
90# ES:DI = 1500:0\r
91 xorw %di,%di\r
92 pushw %es\r
93 movw $0x1500,%ax\r
94 movw %ax,%es\r
95 call ReadFile\r
96SaveVolumeId: \r
97 popw %es\r
72f7d3c3 98 movw VolId(%bp), %ax\r
99 movw %ax, %es:(0) # Save Volume Id to 0:19000. we will find the correct volume according to this VolumeId\r
100 movw VolId+2(%bp), %ax\r
f3eb2131 101 movw %ax, %es:(2)\r
102\r
103# Read Efildr\r
104 popw %cx\r
105# cx = Start Cluster of Efildr -> BS.com has filled already\r
106# ES:DI = 2000:0, first cluster will be read again\r
107 xorw %di,%di # di = 0\r
108 movw $0x2000,%ax\r
109 movw %ax,%es\r
110 call ReadFile\r
111 movw %cs,%ax\r
112 movw %ax, %cs:JumpSegment\r
113\r
114CheckEm64T: \r
115 movl $0x80000001,%eax\r
116# cpuid\r
117 .word 0xA20F\r
118 btl $29,%edx\r
119 jc CheckEm64TPass\r
120 pushw %cs\r
121 popw %ds\r
122 leaw Em64String,%si\r
123 movw $18,%cx\r
124 jmp PrintStringAndHalt\r
125CheckEm64TPass: \r
126jumpFarInstruction: \r
127 .byte 0xea\r
128jumpOffset: \r
129 .word 0x200\r
130jumpSegment: \r
131 .word 0x2000\r
132\r
133\r
134\r
135# ****************************************************************************\r
136# ReadFile\r
137#\r
138# Arguments:\r
139# CX = Start Cluster of File\r
140# ES:DI = Buffer to store file content read from disk\r
141#\r
142# Return:\r
143# (ES << 4 + DI) = end of file content Buffer\r
144#\r
145# ****************************************************************************\r
146ReadFile: \r
147# si = NumberOfClusters\r
148# cx = ClusterNumber\r
149# dx = CachedFatSectorNumber\r
150# ds:0000 = CacheFatSectorBuffer\r
151# es:di = Buffer to load file\r
152# bx = NextClusterNumber\r
153 pusha\r
154 movw $1,%si # NumberOfClusters = 1\r
155 pushw %cx # Push Start Cluster onto stack\r
156 movw $0xfff,%dx # CachedFatSectorNumber = 0xfff\r
157FatChainLoop: \r
158 movw %cx,%ax # ax = ClusterNumber \r
159 andw $0xfff8,%ax # ax = ax & 0xfff8\r
160 cmpw $0xfff8,%ax # See if this is the last cluster\r
161 je FoundLastCluster # Jump if last cluster found\r
162 movw %cx,%ax # ax = ClusterNumber\r
163 shlw %ax # FatOffset = ClusterNumber * 2\r
164 pushw %si # Save si\r
165 movw %ax,%si # si = FatOffset\r
166 shrw $BLOCK_SHIFT, %ax # ax = FatOffset >> BLOCK_SHIFT\r
167 addw ReservedSectors(%bp), %ax # ax = FatSectorNumber = ReservedSectors + (FatOffset >> BLOCK_OFFSET)\r
168 andw $BLOCK_MASK, %si # si = FatOffset & BLOCK_MASK\r
169 cmpw %dx,%ax # Compare FatSectorNumber to CachedFatSectorNumber\r
170 je SkipFatRead\r
171 movw $2,%bx\r
172 pushw %es\r
173 pushw %ds\r
174 popw %es\r
175 call ReadBlocks # Read 2 blocks starting at AX storing at ES:DI\r
176 popw %es\r
177 movw %ax,%dx # CachedFatSectorNumber = FatSectorNumber\r
178SkipFatRead: \r
179 movw (%si), %bx # bx = NextClusterNumber\r
180 movw %cx,%ax # ax = ClusterNumber\r
181 popw %si # Restore si\r
182 decw %bx # bx = NextClusterNumber - 1\r
183 cmpw %cx,%bx # See if (NextClusterNumber-1)==ClusterNumber\r
184 jne ReadClusters\r
185 incw %bx # bx = NextClusterNumber\r
186 incw %si # NumberOfClusters++\r
187 movw %bx,%cx # ClusterNumber = NextClusterNumber\r
188 jmp FatChainLoop\r
189ReadClusters: \r
190 incw %bx\r
191 popw %ax # ax = StartCluster\r
192 pushw %bx # StartCluster = NextClusterNumber\r
193 movw %bx,%cx # ClusterNumber = NextClusterNumber\r
194 subw $2,%ax # ax = StartCluster - 2\r
195 xorb %bh,%bh\r
196 movb SectorsPerCluster(%bp), %bl # bx = SectorsPerCluster\r
197 mulw %bx # ax = (StartCluster - 2) * SectorsPerCluster\r
198 addw (%bp), %ax # ax = FirstClusterLBA + (StartCluster-2)*SectorsPerCluster\r
199 pushw %ax # save start sector\r
200 movw %si,%ax # ax = NumberOfClusters\r
201 mulw %bx # ax = NumberOfClusters * SectorsPerCluster\r
202 movw %ax,%bx # bx = Number of Sectors\r
203 popw %ax # ax = Start Sector\r
204 call ReadBlocks\r
205 movw $1,%si # NumberOfClusters = 1\r
206 jmp FatChainLoop\r
207FoundLastCluster: \r
208 popw %cx\r
209 popa\r
210 ret\r
211\r
212\r
213# ****************************************************************************\r
214# ReadBlocks - Reads a set of blocks from a block device\r
215#\r
216# AX = Start LBA\r
217# BX = Number of Blocks to Read\r
218# ES:DI = Buffer to store sectors read from disk\r
219# ****************************************************************************\r
220\r
221# cx = Blocks\r
222# bx = NumberOfBlocks\r
223# si = StartLBA\r
224\r
225ReadBlocks: \r
226 pusha\r
72f7d3c3 227 addl LBAOffsetForBootSector(%bp), %eax # Add LBAOffsetForBootSector to Start LBA\r
f3eb2131 228 addl HiddenSectors(%bp), %eax # Add HiddenSectors to Start LBA\r
229 movl %eax,%esi # esi = Start LBA\r
230 movw %bx,%cx # cx = Number of blocks to read\r
231ReadCylinderLoop: \r
232 movw $0x7bfc,%bp # bp = 0x7bfc\r
233 movl %esi,%eax # eax = Start LBA\r
234 xorl %edx,%edx # edx = 0\r
b29a823d 235 movzwl (%bp), %ebx # bx = MaxSector\r
f3eb2131 236 divl %ebx # ax = StartLBA / MaxSector\r
237 incw %dx # dx = (StartLBA % MaxSector) + 1\r
238\r
239 movw (%bp), %bx # bx = MaxSector\r
240 subw %dx,%bx # bx = MaxSector - Sector\r
241 incw %bx # bx = MaxSector - Sector + 1\r
242 cmpw %bx,%cx # Compare (Blocks) to (MaxSector - Sector + 1)\r
243 jg LimitTransfer\r
244 movw %cx,%bx # bx = Blocks\r
245LimitTransfer: \r
246 pushw %ax # save ax\r
247 movw %es,%ax # ax = es\r
248 shrw $(BLOCK_SHIFT-4), %ax # ax = Number of blocks into mem system\r
249 andw $0x7f,%ax # ax = Number of blocks into current seg\r
250 addw %bx,%ax # ax = End Block number of transfer\r
251 cmpw $0x80,%ax # See if it crosses a 64K boundry\r
252 jle NotCrossing64KBoundry # Branch if not crossing 64K boundry\r
253 subw $0x80,%ax # ax = Number of blocks past 64K boundry\r
254 subw %ax,%bx # Decrease transfer size by block overage\r
255NotCrossing64KBoundry: \r
256 popw %ax # restore ax\r
257\r
258 pushw %cx\r
259 movb %dl,%cl # cl = (StartLBA % MaxSector) + 1 = Sector\r
260 xorw %dx,%dx # dx = 0\r
72f7d3c3 261 divw 2(%bp) # ax = ax / (MaxHead + 1) = Cylinder \r
f3eb2131 262 # dx = ax % (MaxHead + 1) = Head\r
263\r
264 pushw %bx # Save number of blocks to transfer\r
265 movb %dl,%dh # dh = Head\r
266 movw $0x7c00,%bp # bp = 0x7c00\r
267 movb PhysicalDrive(%bp), %dl # dl = Drive Number\r
268 movb %al,%ch # ch = Cylinder\r
269 movb %bl,%al # al = Blocks\r
270 movb $2,%ah # ah = Function 2\r
271 movw %di,%bx # es:bx = Buffer address\r
272 int $0x13\r
273 jc DiskError\r
274 popw %bx\r
275 popw %cx\r
276 movzwl %bx,%ebx\r
277 addl %ebx,%esi # StartLBA = StartLBA + NumberOfBlocks\r
278 subw %bx,%cx # Blocks = Blocks - NumberOfBlocks\r
279 movw %es,%ax\r
280 shlw $(BLOCK_SHIFT-4), %bx\r
281 addw %bx,%ax\r
282 movw %ax,%es # es:di = es:di + NumberOfBlocks*BLOCK_SIZE\r
283 cmpw $0,%cx\r
284 jne ReadCylinderLoop\r
285 popa\r
286 ret\r
287\r
288DiskError: \r
289 pushw %cs\r
290 popw %ds\r
291 leaw ErrorString,%si\r
292 movw $7,%cx\r
293 jmp PrintStringAndHalt\r
294\r
295PrintStringAndHalt: \r
296 movw $0xb800,%ax\r
297 movw %ax,%es\r
298 movw $160,%di\r
299 rep\r
300 movsw\r
301Halt: \r
302 jmp Halt\r
303\r
72f7d3c3 304ErrorString: \r
f3eb2131 305 .byte 'S', 0x0c, 'E', 0x0c, 'r', 0x0c, 'r', 0x0c, 'o', 0x0c, 'r', 0x0c, '!',0x0c\r
306\r
307 .org 0x01fa\r
308LBAOffsetForBootSector: \r
309 .long 0x0\r
310\r
311 .org 0x01fe\r
312 .word 0xaa55\r
313\r
314#******************************************************************************\r
315#******************************************************************************\r
316#******************************************************************************\r
317\r
318.equ DELAY_PORT, 0x0ed # Port to use for 1uS delay\r
319.equ KBD_CONTROL_PORT, 0x060 # 8042 control port \r
320.equ KBD_STATUS_PORT, 0x064 # 8042 status port \r
321.equ WRITE_DATA_PORT_CMD, 0x0d1 # 8042 command to write the data port\r
322.equ ENABLE_A20_CMD, 0x0df # 8042 command to enable A20\r
323\r
324 .org 0x200\r
325 jmp start\r
326Em64String: \r
327.byte 'E', 0x0c, 'm', 0x0c, '6', 0x0c, '4', 0x0c, 'T', 0x0c, ' ', 0x0c, 'U', 0x0c, 'n', 0x0c, 's', 0x0c, 'u', 0x0c, 'p', 0x0c, 'p', 0x0c, 'o', 0x0c, 'r', 0x0c, 't', 0x0c, 'e', 0x0c, 'd', 0x0c, '!', 0x0c\r
328\r
329start: \r
330 movw %cs,%ax\r
331 movw %ax,%ds\r
332 movw %ax,%es\r
333 movw %ax,%ss\r
334 movw $MyStack, %sp\r
335\r
336# mov ax,0b800h\r
337# mov es,ax\r
338# mov byte ptr es:[160],'a'\r
339# mov ax,cs\r
340# mov es,ax\r
341\r
342 movl $0,%ebx\r
343 leal MemoryMap, %edi\r
344MemMapLoop: \r
345 movl $0xe820,%eax\r
346 movl $20,%ecx\r
347 movl $0x534d4150, %edx # SMAP\r
348 int $0x15\r
349 jc MemMapDone\r
350 addl $20,%edi\r
351 cmpl $0,%ebx\r
352 je MemMapDone\r
353 jmp MemMapLoop\r
354MemMapDone: \r
355 leal MemoryMap, %eax\r
356 subl %eax,%edi # Get the address of the memory map\r
b29a823d 357 movl %edi, MemoryMapSize # Save the size of the memory map\r
f3eb2131 358\r
359 xorl %ebx,%ebx\r
360 movw %cs,%bx # BX=segment\r
361 shll $4,%ebx # BX="linear" address of segment base\r
72f7d3c3 362 leal GDT_BASE(%ebx), %eax # EAX=PHYSICAL address of gdt\r
363 movl %eax, (gdtr + 2) # Put address of gdt into the gdtr\r
364 leal IDT_BASE(%ebx), %eax # EAX=PHYSICAL address of idt\r
365 movl %eax, (idtr + 2) # Put address of idt into the idtr\r
f3eb2131 366 leal MemoryMapSize(%ebx), %edx # Physical base address of the memory map\r
367\r
368# mov ax,0b800h\r
369# mov es,ax\r
370# mov byte ptr es:[162],'b'\r
371# mov ax,cs\r
372# mov es,ax\r
373\r
374#\r
375# Enable A20 Gate \r
376#\r
377\r
378 movw $0x2401,%ax # Enable A20 Gate\r
379 int $0x15\r
380 jnc A20GateEnabled # Jump if it suceeded\r
381\r
382#\r
383# If INT 15 Function 2401 is not supported, then attempt to Enable A20 manually.\r
384#\r
385\r
386 call Empty8042InputBuffer # Empty the Input Buffer on the 8042 controller\r
387 jnz Timeout8042 # Jump if the 8042 timed out\r
388 outw %ax, $DELAY_PORT # Delay 1 uS\r
389 movb $WRITE_DATA_PORT_CMD, %al # 8042 cmd to write output port\r
390 outb %al, $KBD_STATUS_PORT # Send command to the 8042\r
391 call Empty8042InputBuffer # Empty the Input Buffer on the 8042 controller\r
392 jnz Timeout8042 # Jump if the 8042 timed out\r
393 movb $ENABLE_A20_CMD, %al # gate address bit 20 on\r
394 outb %al, $KBD_CONTROL_PORT # Send command to thre 8042\r
395 call Empty8042InputBuffer # Empty the Input Buffer on the 8042 controller\r
396 movw $25,%cx # Delay 25 uS for the command to complete on the 8042\r
397Delay25uS: \r
398 outw %ax, $DELAY_PORT # Delay 1 uS\r
399 loop Delay25uS\r
400Timeout8042: \r
401\r
402\r
403A20GateEnabled: \r
404\r
405#\r
406# DISABLE INTERRUPTS - Entering Protected Mode\r
407#\r
408\r
409 cli\r
410\r
411# mov ax,0b800h\r
412# mov es,ax\r
413# mov byte ptr es:[164],'c'\r
414# mov ax,cs\r
415# mov es,ax\r
416\r
417 leal OffsetIn32BitProtectedMode, %eax\r
418 addl $0x20000+0x6,%eax\r
b29a823d 419 movl %eax, OffsetIn32BitProtectedMode \r
f3eb2131 420\r
421 leal OffsetInLongMode, %eax\r
422 addl $0x20000+0x6,%eax\r
423 movl %eax, OffsetInLongMode \r
424\r
425 #\r
426 # load GDT\r
427 #\r
428 .byte 0x66\r
429 lgdt gdtr\r
430\r
431 #\r
432 # Enable Protect Mode (set CR0.PE=1)\r
433 #\r
434 movl $cr0, %eax # Read CR0.\r
435 orl $0x1,%eax # Set PE=1\r
436 movl %eax, %cr0 # Write CR0.\r
437 .byte 0x66\r
438 .byte 0xea # jmp far 16:32\r
439OffsetIn32BitProtectedMode: \r
440 .long 0x0000000 # offset $+8 (In32BitProtectedMode)\r
441 .word 0x10 # selector (flat CS)\r
442In32BitProtectedMode: \r
443\r
444#\r
445# Entering Long Mode\r
446#\r
447 .byte 0x66\r
448 movw $8,%ax\r
449 movw %ax,%ds\r
450 movw %ax,%es\r
451 movw %ax,%ss\r
452\r
453 #\r
454 # Enable the 64-bit page-translation-table entries by\r
455 # setting CR4.PAE=1 (this is _required_ before activating\r
456 # long mode). Paging is not enabled until after long mode\r
457 # is enabled.\r
458 #\r
459 .byte 0xf\r
460 .byte 0x20\r
461 .byte 0xe0\r
462# mov eax, cr4\r
463 btsl $5,%eax\r
464 .byte 0xf\r
465 .byte 0x22\r
466 .byte 0xe0\r
467# mov cr4, eax\r
468\r
469 #\r
470 # This is the Trapolean Page Tables that are guarenteed\r
471 # under 4GB.\r
472 #\r
473 # Address Map:\r
474 # 10000 ~ 12000 - efildr (loaded)\r
475 # 20000 ~ 21000 - start64.com\r
476 # 21000 ~ 22000 - efi64.com\r
477 # 22000 ~ 90000 - efildr\r
478 # 90000 ~ 96000 - 4G pagetable (will be reload later)\r
479 #\r
480 .byte 0xb8\r
481 .long 0x90000\r
482# mov eax, 90000h\r
483 movl %eax, %cr3\r
484\r
485 #\r
486 # Enable long mode (set EFER.LME=1).\r
487 #\r
488 .byte 0xb9\r
489 .long 0xc0000080\r
490# mov ecx, 0c0000080h ; EFER MSR number.\r
491 .byte 0xf\r
492 .byte 0x32\r
493# rdmsr ; Read EFER.\r
494 .byte 0xf\r
495 .byte 0xba\r
496 .byte 0xe8\r
497 .byte 0x8\r
498# bts eax, 8 ; Set LME=1.\r
499 .byte 0xf\r
500 .byte 0x30\r
501# wrmsr ; Write EFER.\r
502\r
503 #\r
504 # Enable paging to activate long mode (set CR0.PG=1)\r
505 #\r
506 movl $cr0, %eax # Read CR0.\r
507 .byte 0xf\r
508 .byte 0xba\r
509 .byte 0xe8\r
510 .byte 0x1f\r
511# bts eax, 31 ; Set PG=1.\r
512 movl %eax, %cr0 # Write CR0.\r
513 jmp GoToLongMode\r
514GoToLongMode: \r
515\r
516 .byte 0x67\r
517 .byte 0xea # Far Jump $+9:Selector to reload CS\r
518OffsetInLongMode: \r
519 .long 00000000 # $+9 Offset is ensuing instruction boundary\r
520 .word 0x38 # Selector is our code selector, 38h\r
521\r
522InLongMode: \r
523 .byte 0x66\r
524 movw $0x30,%ax\r
525 movw %ax,%ds\r
526\r
527 .byte 0x66\r
528 movw $0x18,%ax\r
529 movw %ax,%es\r
530 movw %ax,%ss\r
531 movw %ax,%ds\r
532\r
533 .byte 0xbd\r
534 .long 0x400000\r
535# mov ebp,000400000h ; Destination of EFILDR32\r
536 .byte 0xbb\r
537 .long 0x70000\r
538# mov ebx,000070000h ; Length of copy\r
539\r
540 #\r
541 # load idt later\r
542 #\r
543 .byte 0x48\r
544 .byte 0x33\r
545 .byte 0xc0\r
546# xor rax, rax\r
547 .byte 0x66\r
548 movw $idtr, %ax\r
549 .byte 0x48\r
550 .byte 0x5\r
551 .long 0x20000\r
552# add rax, 20000h\r
553\r
554 .byte 0xf\r
555 .byte 0x1\r
556 .byte 0x18\r
557# lidt fword ptr [rax]\r
558\r
559 .byte 0x48\r
560 .byte 0xc7\r
561 .byte 0xc0\r
562 .long 0x21000\r
563# mov rax, 21000h\r
564 .byte 0x50\r
565# push rax\r
566\r
567# ret\r
568 .byte 0xc3\r
569\r
570Empty8042InputBuffer: \r
571 movw $0,%cx\r
572Empty8042Loop: \r
573 outw %ax, $DELAY_PORT # Delay 1us\r
574 inb $KBD_STATUS_PORT, %al # Read the 8042 Status Port\r
575 andb $0x2,%al # Check the Input Buffer Full Flag\r
576 loopnz Empty8042Loop # Loop until the input buffer is empty or a timout of 65536 uS\r
577 ret\r
578\r
579##############################################################################\r
580# data\r
581##############################################################################\r
582\r
9811c392 583 .p2align 1\r
f3eb2131 584\r
b29a823d 585 gdtr: .long GDT_END - GDT_BASE - 1 # GDT limit \r
f3eb2131 586 .long 0 # (GDT base gets set above)\r
587##############################################################################\r
588# global descriptor table (GDT)\r
589##############################################################################\r
590\r
9811c392 591 .p2align 1\r
f3eb2131 592\r
593GDT_BASE: \r
594# null descriptor\r
595.equ NULL_SEL, .-GDT_BASE # Selector [0x0]\r
596 .word 0 # limit 15:0\r
597 .word 0 # base 15:0\r
598 .byte 0 # base 23:16\r
599 .byte 0 # type\r
600 .byte 0 # limit 19:16, flags\r
601 .byte 0 # base 31:24\r
602\r
603# linear data segment descriptor\r
604.equ LINEAR_SEL, .-GDT_BASE # Selector [0x8]\r
605 .word 0xFFFF # limit 0xFFFFF\r
606 .word 0 # base 0\r
607 .byte 0\r
608 .byte 0x92 # present, ring 0, data, expand-up, writable\r
609 .byte 0xCF # page-granular, 32-bit\r
610 .byte 0\r
611\r
612# linear code segment descriptor\r
613.equ LINEAR_CODE_SEL, .-GDT_BASE # Selector [0x10]\r
614 .word 0xFFFF # limit 0xFFFFF\r
615 .word 0 # base 0\r
616 .byte 0\r
617 .byte 0x9A # present, ring 0, data, expand-up, writable\r
618 .byte 0xCF # page-granular, 32-bit\r
619 .byte 0\r
620\r
621# system data segment descriptor\r
622.equ SYS_DATA_SEL, .-GDT_BASE # Selector [0x18]\r
623 .word 0xFFFF # limit 0xFFFFF\r
624 .word 0 # base 0\r
625 .byte 0\r
626 .byte 0x92 # present, ring 0, data, expand-up, writable\r
627 .byte 0xCF # page-granular, 32-bit\r
628 .byte 0\r
629\r
630# system code segment descriptor\r
631.equ SYS_CODE_SEL, .-GDT_BASE # Selector [0x20]\r
632 .word 0xFFFF # limit 0xFFFFF\r
633 .word 0 # base 0\r
634 .byte 0\r
635 .byte 0x9A # present, ring 0, data, expand-up, writable\r
636 .byte 0xCF # page-granular, 32-bit\r
637 .byte 0\r
638\r
639# spare segment descriptor\r
640.equ SPARE3_SEL, .-GDT_BASE # Selector [0x28]\r
641 .word 0 # limit 0xFFFFF\r
642 .word 0 # base 0\r
643 .byte 0\r
644 .byte 0 # present, ring 0, data, expand-up, writable\r
645 .byte 0 # page-granular, 32-bit\r
646 .byte 0\r
647\r
648#\r
649# system data segment descriptor\r
650#\r
651.equ SYS_DATA64_SEL, .-GDT_BASE # Selector [0x30]\r
652 .word 0xFFFF # limit 0xFFFFF\r
653 .word 0 # base 0\r
654 .byte 0\r
655 .byte 0x92 # P | DPL [1..2] | 1 | 1 | C | R | A\r
656 .byte 0xCF # G | D | L | AVL | Segment [19..16]\r
657 .byte 0\r
658\r
659#\r
660# system code segment descriptor\r
661#\r
662.equ SYS_CODE64_SEL, .-GDT_BASE # Selector [0x38]\r
663 .word 0xFFFF # limit 0xFFFFF\r
664 .word 0 # base 0\r
665 .byte 0\r
666 .byte 0x9A # P | DPL [1..2] | 1 | 1 | C | R | A\r
667 .byte 0xAF # G | D | L | AVL | Segment [19..16]\r
668 .byte 0\r
669\r
670# spare segment descriptor\r
671.equ SPARE4_SEL, .-GDT_BASE # Selector [0x40]\r
672 .word 0 # limit 0xFFFFF\r
673 .word 0 # base 0\r
674 .byte 0\r
675 .byte 0 # present, ring 0, data, expand-up, writable\r
676 .byte 0 # page-granular, 32-bit\r
677 .byte 0\r
678\r
679GDT_END: \r
680\r
9811c392 681 .p2align 1\r
f3eb2131 682\r
683\r
684\r
685idtr: .long IDT_END - IDT_BASE - 1 # IDT limit\r
686 .quad 0 # (IDT base gets set above)\r
687\r
688##############################################################################\r
689# interrupt descriptor table (IDT)\r
690#\r
691# Note: The hardware IRQ's specified in this table are the normal PC/AT IRQ\r
692# mappings. This implementation only uses the system timer and all other\r
693# IRQs will remain masked. The descriptors for vectors 33+ are provided\r
694# for convenience.\r
695##############################################################################\r
696\r
697#idt_tag db "IDT",0 \r
9811c392 698 .p2align 1\r
f3eb2131 699\r
700\r
701IDT_BASE: \r
702# divide by zero (INT 0)\r
703.equ DIV_ZERO_SEL, .-IDT_BASE\r
b29a823d 704 .word 0 # offset 15:0\r
f3eb2131 705 .long SYS_CODE64_SEL # selector 15:0\r
706 .byte 0 # 0 for interrupt gate\r
707 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 708 .word 0 # offset 31:16\r
709 .long 0 # offset 63:32\r
710 .long 0 # 0 for reserved\r
f3eb2131 711\r
712# debug exception (INT 1)\r
713.equ DEBUG_EXCEPT_SEL, .-IDT_BASE\r
b29a823d 714 .word 0 # offset 15:0\r
f3eb2131 715 .long SYS_CODE64_SEL # selector 15:0\r
716 .byte 0 # 0 for interrupt gate\r
717 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 718 .word 0 # offset 31:16\r
719 .long 0 # offset 63:32\r
720 .long 0 # 0 for reserved\r
f3eb2131 721\r
722# NMI (INT 2)\r
723.equ NMI_SEL, .-IDT_BASE\r
b29a823d 724 .word 0 # offset 15:0\r
f3eb2131 725 .long SYS_CODE64_SEL # selector 15:0\r
726 .byte 0 # 0 for interrupt gate\r
727 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 728 .word 0 # offset 31:16\r
729 .long 0 # offset 63:32\r
730 .long 0 # 0 for reserved\r
f3eb2131 731\r
732# soft breakpoint (INT 3)\r
733.equ BREAKPOINT_SEL, .-IDT_BASE\r
b29a823d 734 .word 0 # offset 15:0\r
f3eb2131 735 .long SYS_CODE64_SEL # selector 15:0\r
736 .byte 0 # 0 for interrupt gate\r
737 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 738 .word 0 # offset 31:16\r
739 .long 0 # offset 63:32\r
740 .long 0 # 0 for reserved\r
f3eb2131 741\r
742# overflow (INT 4)\r
743.equ OVERFLOW_SEL, .-IDT_BASE\r
b29a823d 744 .word 0 # offset 15:0\r
f3eb2131 745 .long SYS_CODE64_SEL # selector 15:0\r
746 .byte 0 # 0 for interrupt gate\r
747 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 748 .word 0 # offset 31:16\r
749 .long 0 # offset 63:32\r
750 .long 0 # 0 for reserved\r
f3eb2131 751\r
752# bounds check (INT 5)\r
753.equ BOUNDS_CHECK_SEL, .-IDT_BASE\r
b29a823d 754 .word 0 # offset 15:0\r
f3eb2131 755 .long SYS_CODE64_SEL # selector 15:0\r
756 .byte 0 # 0 for interrupt gate\r
757 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 758 .word 0 # offset 31:16\r
759 .long 0 # offset 63:32\r
760 .long 0 # 0 for reserved\r
f3eb2131 761\r
762# invalid opcode (INT 6)\r
763.equ INVALID_OPCODE_SEL, .-IDT_BASE\r
b29a823d 764 .word 0 # offset 15:0\r
f3eb2131 765 .long SYS_CODE64_SEL # selector 15:0\r
766 .byte 0 # 0 for interrupt gate\r
767 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 768 .word 0 # offset 31:16\r
769 .long 0 # offset 63:32\r
770 .long 0 # 0 for reserved\r
f3eb2131 771\r
772# device not available (INT 7)\r
773.equ DEV_NOT_AVAIL_SEL, .-IDT_BASE\r
b29a823d 774 .word 0 # offset 15:0\r
f3eb2131 775 .long SYS_CODE64_SEL # selector 15:0\r
776 .byte 0 # 0 for interrupt gate\r
777 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 778 .word 0 # offset 31:16\r
779 .long 0 # offset 63:32\r
780 .long 0 # 0 for reserved\r
f3eb2131 781\r
782# double fault (INT 8)\r
783.equ DOUBLE_FAULT_SEL, .-IDT_BASE\r
b29a823d 784 .word 0 # offset 15:0\r
f3eb2131 785 .long SYS_CODE64_SEL # selector 15:0\r
786 .byte 0 # 0 for interrupt gate\r
787 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 788 .word 0 # offset 31:16\r
789 .long 0 # offset 63:32\r
790 .long 0 # 0 for reserved\r
f3eb2131 791\r
792# Coprocessor segment overrun - reserved (INT 9)\r
793.equ RSVD_INTR_SEL1, .-IDT_BASE\r
b29a823d 794 .word 0 # offset 15:0\r
f3eb2131 795 .long SYS_CODE64_SEL # selector 15:0\r
796 .byte 0 # 0 for interrupt gate\r
797 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 798 .word 0 # offset 31:16\r
799 .long 0 # offset 63:32\r
800 .long 0 # 0 for reserved\r
f3eb2131 801\r
802# invalid TSS (INT 0ah)\r
803.equ INVALID_TSS_SEL, .-IDT_BASE\r
b29a823d 804 .word 0 # offset 15:0\r
f3eb2131 805 .long SYS_CODE64_SEL # selector 15:0\r
806 .byte 0 # 0 for interrupt gate\r
807 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 808 .word 0 # offset 31:16\r
809 .long 0 # offset 63:32\r
810 .long 0 # 0 for reserved\r
f3eb2131 811\r
812# segment not present (INT 0bh)\r
813.equ SEG_NOT_PRESENT_SEL, .-IDT_BASE\r
b29a823d 814 .word 0 # offset 15:0\r
f3eb2131 815 .long SYS_CODE64_SEL # selector 15:0\r
816 .byte 0 # 0 for interrupt gate\r
817 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 818 .word 0 # offset 31:16\r
819 .long 0 # offset 63:32\r
820 .long 0 # 0 for reserved\r
f3eb2131 821\r
822# stack fault (INT 0ch)\r
823.equ STACK_FAULT_SEL, .-IDT_BASE\r
b29a823d 824 .word 0 # offset 15:0\r
f3eb2131 825 .long SYS_CODE64_SEL # selector 15:0\r
826 .byte 0 # 0 for interrupt gate\r
827 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 828 .word 0 # offset 31:16\r
829 .long 0 # offset 63:32\r
830 .long 0 # 0 for reserved\r
f3eb2131 831\r
832# general protection (INT 0dh)\r
833.equ GP_FAULT_SEL, .-IDT_BASE\r
b29a823d 834 .word 0 # offset 15:0\r
f3eb2131 835 .long SYS_CODE64_SEL # selector 15:0\r
836 .byte 0 # 0 for interrupt gate\r
837 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 838 .word 0 # offset 31:16\r
839 .long 0 # offset 63:32\r
840 .long 0 # 0 for reserved\r
f3eb2131 841\r
842# page fault (INT 0eh)\r
843.equ PAGE_FAULT_SEL, .-IDT_BASE\r
b29a823d 844 .word 0 # offset 15:0\r
f3eb2131 845 .long SYS_CODE64_SEL # selector 15:0\r
846 .byte 0 # 0 for interrupt gate\r
847 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 848 .word 0 # offset 31:16\r
849 .long 0 # offset 63:32\r
850 .long 0 # 0 for reserved\r
f3eb2131 851\r
852# Intel reserved - do not use (INT 0fh)\r
853.equ RSVD_INTR_SEL2, .-IDT_BASE\r
b29a823d 854 .word 0 # offset 15:0\r
f3eb2131 855 .long SYS_CODE64_SEL # selector 15:0\r
856 .byte 0 # 0 for interrupt gate\r
857 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 858 .word 0 # offset 31:16\r
859 .long 0 # offset 63:32\r
860 .long 0 # 0 for reserved\r
f3eb2131 861\r
862# floating point error (INT 10h)\r
863.equ FLT_POINT_ERR_SEL, .-IDT_BASE\r
b29a823d 864 .word 0 # offset 15:0\r
f3eb2131 865 .long SYS_CODE64_SEL # selector 15:0\r
866 .byte 0 # 0 for interrupt gate\r
867 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 868 .word 0 # offset 31:16\r
869 .long 0 # offset 63:32\r
870 .long 0 # 0 for reserved\r
f3eb2131 871\r
872# alignment check (INT 11h)\r
873.equ ALIGNMENT_CHECK_SEL, .-IDT_BASE\r
b29a823d 874 .word 0 # offset 15:0\r
f3eb2131 875 .long SYS_CODE64_SEL # selector 15:0\r
876 .byte 0 # 0 for interrupt gate\r
877 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 878 .word 0 # offset 31:16\r
879 .long 0 # offset 63:32\r
880 .long 0 # 0 for reserved\r
f3eb2131 881\r
882# machine check (INT 12h)\r
883.equ MACHINE_CHECK_SEL, .-IDT_BASE\r
b29a823d 884 .word 0 # offset 15:0\r
f3eb2131 885 .long SYS_CODE64_SEL # selector 15:0\r
886 .byte 0 # 0 for interrupt gate\r
887 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 888 .word 0 # offset 31:16\r
889 .long 0 # offset 63:32\r
890 .long 0 # 0 for reserved\r
f3eb2131 891\r
892# SIMD floating-point exception (INT 13h)\r
893.equ SIMD_EXCEPTION_SEL, .-IDT_BASE\r
b29a823d 894 .word 0 # offset 15:0\r
f3eb2131 895 .long SYS_CODE64_SEL # selector 15:0\r
896 .byte 0 # 0 for interrupt gate\r
897 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 898 .word 0 # offset 31:16\r
899 .long 0 # offset 63:32\r
900 .long 0 # 0 for reserved\r
f3eb2131 901\r
902# 85 unspecified descriptors, First 12 of them are reserved, the rest are avail\r
b29a823d 903 .fill 85 * 16, 1, 0 # db (85 * 16) dup(0)\r
f3eb2131 904\r
905# IRQ 0 (System timer) - (INT 68h)\r
906.equ IRQ0_SEL, .-IDT_BASE\r
b29a823d 907 .word 0 # offset 15:0\r
f3eb2131 908 .long SYS_CODE64_SEL # selector 15:0\r
909 .byte 0 # 0 for interrupt gate\r
910 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 911 .word 0 # offset 31:16\r
912 .long 0 # offset 63:32\r
913 .long 0 # 0 for reserved\r
f3eb2131 914\r
915# IRQ 1 (8042 Keyboard controller) - (INT 69h)\r
916.equ IRQ1_SEL, .-IDT_BASE\r
b29a823d 917 .word 0 # offset 15:0\r
f3eb2131 918 .long SYS_CODE64_SEL # selector 15:0\r
919 .byte 0 # 0 for interrupt gate\r
920 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 921 .word 0 # offset 31:16\r
922 .long 0 # offset 63:32\r
923 .long 0 # 0 for reserved\r
f3eb2131 924\r
925# Reserved - IRQ 2 redirect (IRQ 2) - DO NOT USE!!! - (INT 6ah)\r
926.equ IRQ2_SEL, .-IDT_BASE\r
b29a823d 927 .word 0 # offset 15:0\r
f3eb2131 928 .long SYS_CODE64_SEL # selector 15:0\r
929 .byte 0 # 0 for interrupt gate\r
930 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 931 .word 0 # offset 31:16\r
932 .long 0 # offset 63:32\r
933 .long 0 # 0 for reserved\r
f3eb2131 934\r
935# IRQ 3 (COM 2) - (INT 6bh)\r
936.equ IRQ3_SEL, .-IDT_BASE\r
b29a823d 937 .word 0 # offset 15:0\r
f3eb2131 938 .long SYS_CODE64_SEL # selector 15:0\r
939 .byte 0 # 0 for interrupt gate\r
940 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 941 .word 0 # offset 31:16\r
942 .long 0 # offset 63:32\r
943 .long 0 # 0 for reserved\r
f3eb2131 944\r
945# IRQ 4 (COM 1) - (INT 6ch)\r
946.equ IRQ4_SEL, .-IDT_BASE\r
b29a823d 947 .word 0 # offset 15:0\r
f3eb2131 948 .long SYS_CODE64_SEL # selector 15:0\r
949 .byte 0 # 0 for interrupt gate\r
950 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 951 .word 0 # offset 31:16\r
952 .long 0 # offset 63:32\r
953 .long 0 # 0 for reserved\r
f3eb2131 954\r
955# IRQ 5 (LPT 2) - (INT 6dh)\r
956.equ IRQ5_SEL, .-IDT_BASE\r
b29a823d 957 .word 0 # offset 15:0\r
f3eb2131 958 .long SYS_CODE64_SEL # selector 15:0\r
959 .byte 0 # 0 for interrupt gate\r
960 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 961 .word 0 # offset 31:16\r
962 .long 0 # offset 63:32\r
963 .long 0 # 0 for reserved\r
f3eb2131 964\r
965# IRQ 6 (Floppy controller) - (INT 6eh)\r
966.equ IRQ6_SEL, .-IDT_BASE\r
b29a823d 967 .word 0 # offset 15:0\r
f3eb2131 968 .long SYS_CODE64_SEL # selector 15:0\r
969 .byte 0 # 0 for interrupt gate\r
970 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 971 .word 0 # offset 31:16\r
972 .long 0 # offset 63:32\r
973 .long 0 # 0 for reserved\r
f3eb2131 974\r
975# IRQ 7 (LPT 1) - (INT 6fh)\r
976.equ IRQ7_SEL, .-IDT_BASE\r
b29a823d 977 .word 0 # offset 15:0\r
f3eb2131 978 .long SYS_CODE64_SEL # selector 15:0\r
979 .byte 0 # 0 for interrupt gate\r
980 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 981 .word 0 # offset 31:16\r
982 .long 0 # offset 63:32\r
983 .long 0 # 0 for reserved\r
f3eb2131 984\r
985# IRQ 8 (RTC Alarm) - (INT 70h)\r
986.equ IRQ8_SEL, .-IDT_BASE\r
b29a823d 987 .word 0 # offset 15:0\r
f3eb2131 988 .long SYS_CODE64_SEL # selector 15:0\r
989 .byte 0 # 0 for interrupt gate\r
990 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 991 .word 0 # offset 31:16\r
992 .long 0 # offset 63:32\r
993 .long 0 # 0 for reserved\r
f3eb2131 994\r
995# IRQ 9 - (INT 71h)\r
996.equ IRQ9_SEL, .-IDT_BASE\r
b29a823d 997 .word 0 # offset 15:0\r
f3eb2131 998 .long SYS_CODE64_SEL # selector 15:0\r
999 .byte 0 # 0 for interrupt gate\r
1000 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1001 .word 0 # offset 31:16\r
1002 .long 0 # offset 63:32\r
1003 .long 0 # 0 for reserved\r
f3eb2131 1004\r
1005# IRQ 10 - (INT 72h)\r
1006.equ IRQ10_SEL, .-IDT_BASE\r
b29a823d 1007 .word 0 # offset 15:0\r
f3eb2131 1008 .long SYS_CODE64_SEL # selector 15:0\r
1009 .byte 0 # 0 for interrupt gate\r
1010 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1011 .word 0 # offset 31:16\r
1012 .long 0 # offset 63:32\r
1013 .long 0 # 0 for reserved\r
f3eb2131 1014\r
1015# IRQ 11 - (INT 73h)\r
1016.equ IRQ11_SEL, .-IDT_BASE\r
b29a823d 1017 .word 0 # offset 15:0\r
f3eb2131 1018 .long SYS_CODE64_SEL # selector 15:0\r
1019 .byte 0 # 0 for interrupt gate\r
1020 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1021 .word 0 # offset 31:16\r
1022 .long 0 # offset 63:32\r
1023 .long 0 # 0 for reserved\r
f3eb2131 1024\r
1025# IRQ 12 (PS/2 mouse) - (INT 74h)\r
1026.equ IRQ12_SEL, .-IDT_BASE\r
b29a823d 1027 .word 0 # offset 15:0\r
f3eb2131 1028 .long SYS_CODE64_SEL # selector 15:0\r
1029 .byte 0 # 0 for interrupt gate\r
1030 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1031 .word 0 # offset 31:16\r
1032 .long 0 # offset 63:32\r
1033 .long 0 # 0 for reserved\r
f3eb2131 1034\r
1035# IRQ 13 (Floating point error) - (INT 75h)\r
1036.equ IRQ13_SEL, .-IDT_BASE\r
b29a823d 1037 .word 0 # offset 15:0\r
f3eb2131 1038 .long SYS_CODE64_SEL # selector 15:0\r
1039 .byte 0 # 0 for interrupt gate\r
1040 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1041 .word 0 # offset 31:16\r
1042 .long 0 # offset 63:32\r
1043 .long 0 # 0 for reserved\r
f3eb2131 1044\r
1045# IRQ 14 (Secondary IDE) - (INT 76h)\r
1046.equ IRQ14_SEL, .-IDT_BASE\r
b29a823d 1047 .word 0 # offset 15:0\r
f3eb2131 1048 .long SYS_CODE64_SEL # selector 15:0\r
1049 .byte 0 # 0 for interrupt gate\r
1050 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1051 .word 0 # offset 31:16\r
1052 .long 0 # offset 63:32\r
1053 .long 0 # 0 for reserved\r
f3eb2131 1054\r
1055# IRQ 15 (Primary IDE) - (INT 77h)\r
1056.equ IRQ15_SEL, .-IDT_BASE\r
b29a823d 1057 .word 0 # offset 15:0\r
f3eb2131 1058 .long SYS_CODE64_SEL # selector 15:0\r
1059 .byte 0 # 0 for interrupt gate\r
1060 .byte 0x0e | 0x80 # type = 386 interrupt gate, present\r
b29a823d 1061 .word 0 # offset 31:16\r
1062 .long 0 # offset 63:32\r
1063 .long 0 # 0 for reserved\r
f3eb2131 1064\r
1065IDT_END: \r
1066\r
9811c392 1067 .p2align 1\r
f3eb2131 1068\r
1069MemoryMapSize: .long 0\r
1070MemoryMap: .long 0,0,0,0,0,0,0,0\r
1071 .long 0,0,0,0,0,0,0,0\r
1072 .long 0,0,0,0,0,0,0,0\r
1073 .long 0,0,0,0,0,0,0,0\r
1074 .long 0,0,0,0,0,0,0,0\r
1075 .long 0,0,0,0,0,0,0,0\r
1076 .long 0,0,0,0,0,0,0,0\r
1077 .long 0,0,0,0,0,0,0,0\r
1078 .long 0,0,0,0,0,0,0,0\r
1079 .long 0,0,0,0,0,0,0,0\r
1080 .long 0,0,0,0,0,0,0,0\r
1081 .long 0,0,0,0,0,0,0,0\r
1082 .long 0,0,0,0,0,0,0,0\r
1083 .long 0,0,0,0,0,0,0,0\r
1084 .long 0,0,0,0,0,0,0,0\r
1085 .long 0,0,0,0,0,0,0,0\r
1086 .long 0,0,0,0,0,0,0,0\r
1087 .long 0,0,0,0,0,0,0,0\r
1088 .long 0,0,0,0,0,0,0,0\r
1089 .long 0,0,0,0,0,0,0,0\r
1090 .long 0,0,0,0,0,0,0,0\r
1091 .long 0,0,0,0,0,0,0,0\r
1092 .long 0,0,0,0,0,0,0,0\r
1093 .long 0,0,0,0,0,0,0,0\r
1094 .long 0,0,0,0,0,0,0,0\r
1095 .long 0,0,0,0,0,0,0,0\r
1096 .long 0,0,0,0,0,0,0,0\r
1097 .long 0,0,0,0,0,0,0,0\r
1098 .long 0,0,0,0,0,0,0,0\r
1099 .long 0,0,0,0,0,0,0,0\r
1100\r
1101 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
1102 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r
1103\r
b29a823d 1104 #.org 0x0fe0 #Just for pass build\r
f3eb2131 1105MyStack: \r
1106 # below is the pieces of the IVT that is used to redirect INT 68h - 6fh\r
1107 # back to INT 08h - 0fh when in real mode... It is 'org'ed to a\r
1108 # known low address (20f00) so it can be set up by PlMapIrqToVect in\r
1109 # 8259.c\r
1110\r
1111 int $8\r
1112 iret\r
1113\r
1114 int $9\r
1115 iret\r
1116\r
1117 int $10\r
1118 iret\r
1119\r
1120 int $11\r
1121 iret\r
1122\r
1123 int $12\r
1124 iret\r
1125\r
1126 int $13\r
1127 iret\r
1128\r
1129 int $14\r
1130 iret\r
1131\r
1132 int $15\r
1133 iret\r
1134\r
1135\r
b29a823d 1136 #.org 0x0ffe #Just for pass build\r
f3eb2131 1137BlockSignature: \r
1138 .word 0xaa55\r
1139\r