Re: [OSDev] How to switch to long mode in x86 CPUs?

Liste des GroupesRevenir à cl c 
Sujet : Re: [OSDev] How to switch to long mode in x86 CPUs?
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.lang.c alt.os.development
Suivi-à : alt.os.development
Date : 01. Mar 2025, 14:34:42
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vpv2di$5t5$1@reader1.panix.com>
References : 1 2 3
User-Agent : trn 4.0-test77 (Sep 1, 2010)
[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.


Date Sujet#  Auteur
27 Feb 25 * [OSDev] How to switch to long mode in x86 CPUs?29Ar Rakin
27 Feb 25 +* Re: [OSDev] How to switch to long mode in x86 CPUs?14Keith Thompson
28 Feb 25 i`* Re: [OSDev] How to switch to long mode in x86 CPUs?13Ar Rakin
28 Feb 25 i +- Re: [OSDev] How to switch to long mode in x86 CPUs?1Waldek Hebisch
28 Feb 25 i `* OT: (Was: How to switch to long mode in x86 CPUs?)11Salvador Mirzo
28 Feb 25 i  +* Re: OT: USENET9Salvador Mirzo
1 Mar 25 i  i+* Re: OT: USENET7Richard Harnden
1 Mar 25 i  ii+* Re: OT: USENET2Ar Rakin
5 Mar 25 i  iii`- Re: OT: USENET1candycanearter07
2 Mar 25 i  ii`* Re: OT: USENET4Salvador Mirzo
2 Mar 25 i  ii `* Re: OT: USENET3Ar Rakin
2 Mar 25 i  ii  +- Re: OT: USENET1yeti
9 Mar 25 i  ii  `- Re: OT: USENET1Salvador Mirzo
1 Mar 25 i  i`- Re: OT: USENET1Ar Rakin
1 Mar 25 i  `- Re: OT:1Ar Rakin
28 Feb 25 +* Re: [OSDev] How to switch to long mode in x86 CPUs?12David Brown
28 Feb 25 i+* Re: [OSDev] How to switch to long mode in x86 CPUs?2Ar Rakin
1 Mar 25 ii`- Re: [OSDev] How to switch to long mode in x86 CPUs?1Dan Cross
1 Mar 25 i`* Re: [OSDev] How to switch to long mode in x86 CPUs?9Paul Edwards
2 Mar 25 i +* Re: [OSDev] How to switch to long mode in x86 CPUs?3Salvador Mirzo
2 Mar 25 i i+- Re: PC BIOS (was [OSDev] How to switch to long mode in x86 CPUs?)1Dan Cross
2 Mar 25 i i`- Re: [OSDev] How to switch to long mode in x86 CPUs?1Dan Cross
2 Mar 25 i `* Re: [OSDev] How to switch to long mode in x86 CPUs?5Paul Edwards
2 Mar 25 i  `* Re: [OSDev] How to switch to long mode in x86 CPUs?4bart
4 Mar 25 i   `* Re: [OSDev] How to switch to long mode in x86 CPUs?3Paul Edwards
4 Mar 25 i    `* Re: [OSDev] How to switch to long mode in x86 CPUs?2bart
5 Mar 25 i     `- Re: [OSDev] How to switch to long mode in x86 CPUs?1Paul Edwards
1 Mar 25 +- Re: [OSDev] How to switch to long mode in x86 CPUs?1Dan Cross
2 Mar 25 `- Re: [OSDev] How to switch to long mode in x86 CPUs?1Andy Valencia

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal