OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 3:49 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: ISSUES WITH ENTERING RING3
PostPosted: Thu Aug 17, 2023 1:30 am 
Offline

Joined: Thu Aug 17, 2023 1:04 am
Posts: 1
Hello,
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:
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


However, my bochs emulator spits out the following and stops running:
Code:
(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


Moreover, I have noticed that it stops running on the first line of the label "user_entry", regardless of what it may be. Also, I disabled the interrupts in the beginning in hopes of not having to deal with a tss (yet). Just trying to get a simple user program to run first.

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.


Last edited by osdoom on Wed Aug 23, 2023 8:23 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: ISSUES WITH ENTERING RING3
PostPosted: Wed Aug 23, 2023 8:22 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
This question was asked and answered elsewhere.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group