2020-02-24 10:00:23 +01:00
|
|
|
#=----------------------------------------------------------------------------=#
|
2020-09-27 17:33:48 +02:00
|
|
|
# OS on Kaleid Documentation #
|
2020-02-24 10:00:23 +01:00
|
|
|
# #
|
|
|
|
# Desc: OS/K Loader : CPU Management functions #
|
|
|
|
# #
|
|
|
|
# #
|
2021-02-18 19:54:35 +01:00
|
|
|
# Copyright © 2018-2021 The OS/K Team #
|
2020-02-24 10:00:23 +01:00
|
|
|
# #
|
|
|
|
# Permission is granted to copy, distribute and/or modify this #
|
|
|
|
# document under the terms of the GNU Free Documentation License, #
|
|
|
|
# Version 1.3 or any later version published by the Free Software #
|
|
|
|
# Foundation; with no Invariant Sections, no Front-Cover Texts, and #
|
|
|
|
# no Back-Cover Texts. A copy of the license is included in the #
|
|
|
|
# file entitled "COPYING.GFDL" #
|
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
|
|
|
|
|
|
|
|
This folder contains two files, `boot/loader/cpu/cpu.inc` and
|
|
|
|
boot/loader/cpu/cpu32.inc`.
|
|
|
|
|
|
|
|
The `boot/loader/cpu/cpu32.inc` is intented to provide 32 bits protected mode
|
|
|
|
function that can control wether the CPU is qualified to run the OS/K code.
|
|
|
|
|
|
|
|
The `boot/loader/cpu/cpu3.inc` provides 64 bits long mode temporization function
|
|
|
|
used by the loader when necessary.
|
|
|
|
|
|
|
|
|
|
|
|
There is two functions in `cpu32.inc` :
|
|
|
|
- Is64Bits(), intented to check if the CPU is "ok" with 64 bit code,
|
|
|
|
if it supports long mode and will not burn if we ask it to execute OS/K
|
|
|
|
(i.e trigger a #UD fault).
|
|
|
|
|
|
|
|
For this check, we use first the 0x80000000 function of the CPUID instruction
|
|
|
|
that returns the highest CPUID function available. It must return at least
|
|
|
|
0x80000001, otherwise we can't check the long mode presence and it is most
|
|
|
|
likely absent. We pass the function number in the eax register.
|
|
|
|
|
|
|
|
As soon as 0x80000001 is available, we use it and verify it flips to 1 the bit
|
|
|
|
29 in edx.
|
|
|
|
|
|
|
|
|
|
|
|
- Check_cpuid(), that check if the CPUID instruction is supported by the CPU
|
|
|
|
before use it (don't want #UD).
|
|
|
|
|
|
|
|
For this, we use the FLAGS register and check if we can flip (overwrite with
|
|
|
|
a 1 persistantly) the bit 21. If it is possible, then CPUID is supported.
|
|
|
|
|
|
|
|
|
|
|
|
The temporize(), bitemporize() and tritemporize() functions in `cpu.inc`
|
|
|
|
are juste loops that make the cpu busy to wait. These temporization are not
|
|
|
|
precise at all, and are not intented to wait for a determined time lapse.
|