Change comment style, and more commenting
This commit is contained in:
		
							parent
							
								
									4f9a4292e5
								
							
						
					
					
						commit
						bb25b7ea35
					
				| @ -11,7 +11,7 @@ BootStack: | |||||||
| 
 | 
 | ||||||
| .code32 | .code32 | ||||||
| error: | error: | ||||||
|   // Print "ERR!" in upper left corner |   //; Print "ERR!" in upper left corner
 | ||||||
|   mov [0xb8000], dword ptr 0x4f004f00 |   mov [0xb8000], dword ptr 0x4f004f00 | ||||||
|   mov [0xb8004], dword ptr 0x4f004f00 |   mov [0xb8004], dword ptr 0x4f004f00 | ||||||
|   mov [0xb8000], byte ptr 'E' |   mov [0xb8000], byte ptr 'E' | ||||||
| @ -21,39 +21,39 @@ error: | |||||||
|   jmp $ |   jmp $ | ||||||
| 
 | 
 | ||||||
| check_cpuid: | check_cpuid: | ||||||
|   // Save EFLAGS |   //; Save EFLAGS
 | ||||||
|   pushfd |   pushfd | ||||||
| 
 | 
 | ||||||
|   // Try to modify EFLAGS.ID |   //; Try to modify EFLAGS.ID
 | ||||||
|   pushfd |   pushfd | ||||||
|   xor dword ptr [esp], 1<<21 |   xor dword ptr [esp], 1<<21 | ||||||
|   popfd |   popfd | ||||||
| 
 | 
 | ||||||
|   //Read EFLAGS into eax |   //;Read EFLAGS into eax
 | ||||||
|   pushfd |   pushfd | ||||||
|   pop eax |   pop eax | ||||||
| 
 | 
 | ||||||
|   // Restore original EFLAGS |   //; Restore original EFLAGS
 | ||||||
|   popfd |   popfd | ||||||
| 
 | 
 | ||||||
|   // Check if EFLAGS.ID was modified |   //; Check if EFLAGS.ID was modified
 | ||||||
|   xor eax, [esp+4] |   xor eax, [esp+4] | ||||||
|   and eax, 1<<21 |   and eax, 1<<21 | ||||||
|   jz error |   jz error | ||||||
|   ret |   ret | ||||||
| 
 | 
 | ||||||
| check_longmode: | check_longmode: | ||||||
|   // cpuid 0x8000 0000 |   //; cpuid 0x8000 0000
 | ||||||
|   mov eax, 0x80000000 |   mov eax, 0x80000000 | ||||||
|   cpuid |   cpuid | ||||||
|   cmp eax, 0x80000001 |   cmp eax, 0x80000001 | ||||||
|   jb error |   jb error | ||||||
| 
 | 
 | ||||||
|   // cpuid 0x8000 0001 |   //; cpuid 0x8000 0001
 | ||||||
|   mov eax, 0x80000001 |   mov eax, 0x80000001 | ||||||
|   cpuid |   cpuid | ||||||
| 
 | 
 | ||||||
|   // Test for long mode flag |   //; Test for long mode flag
 | ||||||
|   test edx, 1<<29 |   test edx, 1<<29 | ||||||
|   jz error |   jz error | ||||||
|   ret |   ret | ||||||
| @ -67,29 +67,39 @@ _start: | |||||||
|   call check_cpuid |   call check_cpuid | ||||||
|   call check_longmode |   call check_longmode | ||||||
| 
 | 
 | ||||||
|  |   //; Set CR4.PAE
 | ||||||
|  |   //; enabling Page Address Extension
 | ||||||
|   mov eax, cr4 |   mov eax, cr4 | ||||||
|   or eax, 1<<5 |   or eax, 1<<5 | ||||||
|   mov cr4, eax |   mov cr4, eax | ||||||
| 
 | 
 | ||||||
|  |   //; Load a P4 page table
 | ||||||
|   mov eax, offset BootP4 |   mov eax, offset BootP4 | ||||||
|   mov cr3, eax |   mov cr3, eax | ||||||
| 
 | 
 | ||||||
|  |   //; Set EFER.LME
 | ||||||
|  |   //; enabling Long Mode
 | ||||||
|   mov ecx, 0x0C0000080 |   mov ecx, 0x0C0000080 | ||||||
|   rdmsr |   rdmsr | ||||||
|   or eax, 1<<8 |   or eax, 1<<8 | ||||||
|   wrmsr |   wrmsr | ||||||
| 
 | 
 | ||||||
|  |   //; Set CR0.PG
 | ||||||
|  |   //; enabling Paging
 | ||||||
|   mov eax, cr0 |   mov eax, cr0 | ||||||
|   or eax, 1<<31 |   or eax, 1<<31 | ||||||
|   mov cr0, eax |   mov cr0, eax | ||||||
| 
 | 
 | ||||||
|  |   //; Load a new GDT
 | ||||||
|   lgdt [BootGDTp] |   lgdt [BootGDTp] | ||||||
| 
 | 
 | ||||||
|  |   //; and update the code selector by a long jump
 | ||||||
|   jmp 0x8:long_mode_start |   jmp 0x8:long_mode_start | ||||||
| 
 | 
 | ||||||
| .code64 | .code64 | ||||||
|   long_mode_start: |   long_mode_start: | ||||||
| 
 | 
 | ||||||
|  |   //; Clear out all other selectors
 | ||||||
|   mov eax, 0x0 |   mov eax, 0x0 | ||||||
|   mov ss, eax |   mov ss, eax | ||||||
|   mov ds, eax |   mov ds, eax | ||||||
| @ -97,4 +107,5 @@ _start: | |||||||
|   mov fs, eax |   mov fs, eax | ||||||
|   mov gs, eax |   mov gs, eax | ||||||
| 
 | 
 | ||||||
|  |   //; Loop infinitely
 | ||||||
|   jmp $ |   jmp $ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user