I am in the process of writing a small os in x86_32. I am currently trying to enter user mode. I'm using https://wiki.osdev.org/Getting_to_Ring_ ... ing_Ring_3 as a reference and this is my current assembly code:
Code: Select all
global enter_user_mode
USER_MODE_CODE_SEGMENT equ (0x18 | 0x3)
USER_MODE_DATA_SEGMENT equ (0x20| 0x3)
enter_user_mode:
cli ; disable interrupts
mov eax, esp
push USER_MODE_DATA_SEGMENT
push eax
pushf
push USER_MODE_CODE_SEGMENT
mov eax, user_entry
push eax
mov eax, USER_MODE_DATA_SEGMENT
mov ds, eax
mov gs, eax
mov es, eax
mov fs, eax
iret
user_entry:
mov eax, 0xc00b8000 ;framebuffer address
mov byte [eax], 'U'
mov eax, 0xc00b8001
mov byte [eax], 0xE
Code: Select all
(0).[310881190] [0x0000000000102710] 001b:00000000c0102710 (unk. ctxt): mov eax, 0xc00b8000 ; b800800bc0
Next at t=310881191
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
I have been super stuck on this for a while and would appreciate any help/leads regarding this.
I'm relatively new to this and still learning, so I would greatly appreciate your patience with any gaps in my understanding.
Thanks!
UPDATE:
There was quite a bit of delay between me posting this and it getting approved (probably because this was my first post here) but this issue has been resolved. For anyone curious, I had not set the U/S flag bit on my pdt.