Groups | Search | Server Info | Login | Register
Groups > comp.lang.c > #390602
| From | cross@spitfire.i.gajendra.net (Dan Cross) |
|---|---|
| Newsgroups | comp.lang.c, alt.os.development |
| Subject | Re: [OSDev] How to switch to long mode in x86 CPUs? |
| Followup-To | alt.os.development |
| Date | 2025-03-01 13:34 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <vpv2di$5t5$1@reader1.panix.com> (permalink) |
| References | <871pvje5yq.fsf@onesoftnet.eu.org> <vprtt6$3jah9$1@dont-email.me> <875xkughgw.fsf@onesoftnet.eu.org> |
Cross-posted to 2 groups.
Followups directed to: alt.os.development
[Note: Followup-To: alt.os.development] In article <875xkughgw.fsf@onesoftnet.eu.org>, Ar Rakin <rakinar2@onesoftnet.eu.org> wrote: >On 28 Feb 2025 09:59, David Brown <david.brown@hesbynett.no> wrote: >[snip] >> On the other hand, if you are interested in learning the intricacies >> of the x86 world, you need to look elsewhere for information - as >> Keith says, it is not really C related when you are writing >> assembly. comp.arch might be a helpful group. > >Looks like comp.arch might be the group I needed to find! Thanks. Comp.arch is not a good choice here. It's for discussion of computer architecutre generally, specifics of how to boot an x86 core would be mostly tangential. alt.os.development is probably your best bet, but please try not to feed the troll there. >[snip] >Also just to clarify, from what I know, since the x86 processors start >in 16-bit real mode for the sake of compatibility, you'd have to start >writing 16-bit code first, then switch to 32-bit protected mode, then >finally switch to 64-bit long mode. However if you use an existing >bootloader such as GRUB, then you usually would not need to worry about >16-bit code since GRUB drops you in 32-bit protected mode. But still, >if you wish to switch to 64-bit long mode, you *will* have to mix 64-bit >and 32-bit code together. > >Either I don't know how to, or I just don't feel comfortable mixing >32-bit and 64-bit code together *when in C* because you will have a hard >time linking those together. Please correct me if I am wrong. Eh...It can be done, but I don't see the point. Even starting from the reset vector (e.g., in 16-bit 8086 mode) it's not that many instructions to get yourself into long mode with paging enabled. To see an example of how this is done, have a look at: https://github.com/oxidecomputer/phbl/blob/main/src/start.S It's sufficient straight-forward, and so low-level, that doing this in a high-level language doesn't seem worth it from a cost/benefit perspective. - Dan C.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
[OSDev] How to switch to long mode in x86 CPUs? Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-02-27 21:57 +0600
Re: [OSDev] How to switch to long mode in x86 CPUs? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-02-27 14:02 -0800
Re: [OSDev] How to switch to long mode in x86 CPUs? Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-02-28 22:18 +0600
Re: [OSDev] How to switch to long mode in x86 CPUs? antispam@fricas.org (Waldek Hebisch) - 2025-02-28 18:25 +0000
OT: (Was: How to switch to long mode in x86 CPUs?) Salvador Mirzo <smirzo@example.com> - 2025-02-28 19:56 -0300
Re: OT: USENET Salvador Mirzo <smirzo@example.com> - 2025-02-28 19:57 -0300
Re: OT: USENET Richard Harnden <richard.nospam@gmail.invalid> - 2025-02-28 23:38 +0000
Re: OT: USENET Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-03-01 15:09 +0600
Re: OT: USENET candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> - 2025-03-05 19:30 +0000
Re: OT: USENET Salvador Mirzo <smirzo@example.com> - 2025-03-01 23:34 -0300
Re: OT: USENET Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-03-02 16:48 +0600
Re: OT: USENET yeti <yeti@tilde.institute> - 2025-03-02 17:27 +0042
Re: OT: USENET Salvador Mirzo <smirzo@example.com> - 2025-03-08 20:06 -0300
Re: OT: USENET Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-03-01 15:08 +0600
Re: OT: Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-03-01 15:07 +0600
Re: [OSDev] How to switch to long mode in x86 CPUs? David Brown <david.brown@hesbynett.no> - 2025-02-28 09:59 +0100
Re: [OSDev] How to switch to long mode in x86 CPUs? Ar Rakin <rakinar2@onesoftnet.eu.org> - 2025-02-28 22:30 +0600
Re: [OSDev] How to switch to long mode in x86 CPUs? cross@spitfire.i.gajendra.net (Dan Cross) - 2025-03-01 13:34 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? "Paul Edwards" <mutazilah@gmail.com> - 2025-03-01 15:50 +1100
Re: [OSDev] How to switch to long mode in x86 CPUs? scott@slp53.sl.home (Scott Lurndal) - 2025-03-01 14:55 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? Salvador Mirzo <smirzo@example.com> - 2025-03-01 23:37 -0300
Re: PC BIOS (was [OSDev] How to switch to long mode in x86 CPUs?) cross@spitfire.i.gajendra.net (Dan Cross) - 2025-03-02 16:01 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? scott@slp53.sl.home (Scott Lurndal) - 2025-03-02 16:42 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? cross@spitfire.i.gajendra.net (Dan Cross) - 2025-03-02 20:26 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? "Paul Edwards" <mutazilah@gmail.com> - 2025-03-02 19:22 +1100
Re: [OSDev] How to switch to long mode in x86 CPUs? bart <bc@freeuk.com> - 2025-03-02 16:16 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? "Paul Edwards" <mutazilah@gmail.com> - 2025-03-05 05:31 +1100
Re: [OSDev] How to switch to long mode in x86 CPUs? bart <bc@freeuk.com> - 2025-03-04 20:27 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? "Paul Edwards" <mutazilah@gmail.com> - 2025-03-05 16:38 +1100
Re: [OSDev] How to switch to long mode in x86 CPUs? cross@spitfire.i.gajendra.net (Dan Cross) - 2025-03-01 13:15 +0000
Re: [OSDev] How to switch to long mode in x86 CPUs? Andy Valencia <vandys@vsta.org> - 2025-03-01 20:02 -0800
csiph-web