Entering Unreal Mode
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife
I did in fact ask where to find precofigured GRUB images, I DID install bochs. Anyway it doesn't matter now here is the new code, this does not cause a triple fault, I wonder should I be doing a jmp kernel or a jmp 0x0:kernel
- Attachments
-
- kanu.tar.bz2
- (1.17 KiB) Downloaded 55 times
Kanu Operating System
Working on:Paging and Multitasking
BURN /\/\1(40$0|=7
Working on:Paging and Multitasking
BURN /\/\1(40$0|=7
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
You edited that in just before I posted the reply. Nevertheless, you boot on a real PC, so somehow you have a bootable medium with your kernel on it. Why would you need to build a separate image from scratch.I did in fact ask where to find precofigured GRUB images, I DID install bochs.
Debugging is *not* to make random changes and asking what's wrong with the code.Anyway it doesn't matter now here is the new code, this does not cause a triple fault,
I would consider that a good example of being completely clueless about what happens in either case. A far jump reloads CS, including the side-effects. A near jump doesn't. I dunno if you were the one I told last time to read the intel manuals end-to-end five times, but this is a textbook example of a stupid question, if not begging for a RTFM.I wonder should I be doing a jmp kernel or a jmp 0x0:kernel
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife
I did NOT edit that post.Combuster wrote:You edited that in just before I posted the reply. Nevertheless, you boot on a real PC, so somehow you have a bootable medium with your kernel on it. Why would you need to build a separate image from scratch.I did in fact ask where to find precofigured GRUB images, I DID install bochs.
Debugging is *not* to make random changes and asking what's wrong with the code.Anyway it doesn't matter now here is the new code, this does not cause a triple fault,
I would consider that a good example of being completely clueless about what happens in either case. A far jump reloads CS, including the side-effects. A near jump doesn't. I dunno if you were the one I told last time to read the intel manuals end-to-end five times, but this is a textbook example of a stupid question, if not begging for a RTFM.I wonder should I be doing a jmp kernel or a jmp 0x0:kernel
Kanu Operating System
Working on:Paging and Multitasking
BURN /\/\1(40$0|=7
Working on:Paging and Multitasking
BURN /\/\1(40$0|=7
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife
This code works fine to set Unreal Mode at boot time:
Code: Select all
;;INIT: Unreal Mode
;;INIT: Unreal Mode
;;INIT: Unreal Mode
;Unreal Mode is an "unofficial" processor mode
;in which practically we are running half real
;mode and half protected mode.
;
;In this operation mode, we can address 32-bit
;memory linearily, without having to address a
;location with an explicit segment register as
;DS or ES; at least with extreme caution.
;
;At the same time, data protection is disabled.
;
;The trick is that the segments are cached and
;thus the segment registers can be disregarded
;thereafter; although for 16-bit addressing we
;will always be affected for the default value
;of the data segments, mainly DS and then ES.
;
;The difference is now can reach 32-bit memory
;by an instruction such as:
;
; mov [eax],ebx
; OR
; a32 rep movsd
;
;Where the "a32" prefix is a 0x67 byte that we
;use to tell the processor that the next bytes
;encode an instruction that will use registers
;32-bit wide that otherwise would be 16-bit.
;
;Note that, in unreal mode, this instruction:
;
; mov byte[_32_bit_pointer],0
;
;Can't be encoded because we are trying to use
;a 32-bit offset in a 16-bit instruction. This
;is a case where we need a 32-bit register for
;the addressing, as in:
;
; mov [eax],ebx
; OR
; a32 mov byte[_32_bit_pointer],0
;
;Step 1: Load GDT
;Step 1: Load GDT
lgdt[cs:GDT] ;{6}
;Step 2: Enable PE Bit for Entering Protected Mode
;Step 2: Enable PE Bit for Entering Protected Mode
mov eax,cr0 ;{3}
inc ax ;{1}
mov cr0,eax ;{3}
;Step 3: Load any Data Segments with 32-bit Selector
;Step 3: Load any Data Segments with 32-bit Selector
push byte SELDat32 ;{2}
pop ds ;{1}
push ds ;{1}
pop es ;{1}
;Step 4: Back to Real Mode with 32-bit Segments/GDT
;Step 4: Back to Real Mode with 32-bit Segments/GDT
dec ax ;{1}
mov cr0,eax ;{3}
;;END: Unreal Mode
;;END: Unreal Mode
;;END: Unreal Mode
JMP $ ;This should be replaced by code that won't reach the GDT data
;INIT: GDT
;INIT: GDT
;INIT: GDT
GDT:
SELNull equ 0 ;As you may see, we have used
GDT_size: ;the Null Selector as the GDT
dw GDTsize ;pointer to load with LGDT.
GDT_actualPtr: ;
dd GDT ;You can see that the WORD at
dw 0x0000 ;the end of these 8 bytes are
;2 padding bytes with 0x0000.
SELCod32 equ 8
dw 0FFFFh ; bits 0-15 length (Bytes 0-1)
dw 00000h ; bits 0-15 base addr (Bytes 2-3)
db 0 ; bits 16-23 base addr (Byte 4)
db 10011010b ; bits 0-3 Type, 4 DT, 5-6 DPL & 7 P (Byte 5)
db 11001111b ; bits 16-19 length into 0-3, 6 D & 7 G (Byte 6)
db 0 ; bits 24-31 base addr (Byte 7)
SELDat32 equ 16
dw 0FFFFh ; bits 0-15 length (Bytes 0-1)
dw 00000h ; bits 0-15 base addr (Bytes 2-3)
db 0 ; bits 16-23 base addr (Byte 4)
db 10010010b ; bits 0-3 Type, 4 DT, 5-6 DPL & 7 P (Byte 5)
db 11001111b ; bits 16-19 length into 0-3, 6 D & 7 G (Byte 6)
db 0 ; bits 24-31 base addr (Byte 7)
GDT_end:
GDTsize equ (GDT_end-GDT)-1
;END: GDT
;END: GDT
;END: GDT
YouTube:
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
http://youtube.com/@AltComp126
My x86 OS/software:
https://sourceforge.net/projects/api-simple-completa/
Donate to get more food/programming resources/computers:
https://www.paypal.com/donate/?hosted_b ... QS2YTW3V64
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
RTFM, search google, and get over your laziness:
I'm true to my word.
And you wonder why it doesn't work?I understand with the kprint, I'm too lazy to change it.
I'm true to my word.
- os.hacker64
- Member
- Posts: 149
- Joined: Mon Feb 11, 2008 4:43 pm
- Location: Limbo City,Afterlife