mirror of
https://github.com/0xAX/linux-insides.git
synced 2025-01-03 12:20:56 +00:00
Merge pull request #326 from c0riolis/linux-bootstrap-2-fix
Fix linux-bootstrap-2.md
This commit is contained in:
commit
aedaaf6d97
@ -41,7 +41,7 @@ As you can read in the previous part, addresses consist of two parts in real mod
|
||||
And we can get the physical address if we know these two parts by:
|
||||
|
||||
```
|
||||
PhysicalAddress = Segment * 16 + Offset
|
||||
PhysicalAddress = Segment Selector * 16 + Offset
|
||||
```
|
||||
|
||||
Memory segmentation was completely redone in protected mode. There are no 64 Kilobyte fixed-size segments. Instead, the size and location of each segment is described by an associated data structure called _Segment Descriptor_. The segment descriptors are stored in a data structure called `Global Descriptor Table` (GDT).
|
||||
@ -135,9 +135,10 @@ As we can see the first bit(bit 43) is `0` for a _data_ segment and `1` for a _c
|
||||
|
||||
8. D/B flag(bit 54) - Default/Big flag represents the operand size i.e 16/32 bits. If it is set then 32 bit otherwise 16.
|
||||
|
||||
Segment registers don't contain the base address of the segment as in real mode. Instead they contain a special structure - `Segment Selector`. Each Segment Descriptor has an associated Segment Selector. `Segment Selector` is a 16-bit structure:
|
||||
Segment registers contain segment selectors as in real mode. However, in protected mode, a segment selector is handled differently. Each Segment Descriptor has an associated Segment Selector which is a 16-bit structure:
|
||||
|
||||
```
|
||||
15 3 2 1 0
|
||||
-----------------------------
|
||||
| Index | TI | RPL |
|
||||
-----------------------------
|
||||
@ -213,8 +214,8 @@ memcpy(&boot_params.hdr, &hdr, sizeof hdr);
|
||||
```
|
||||
|
||||
So,
|
||||
* `ax` will contain the address of the `boot_params.hdr` in bytes
|
||||
* `dx` will contain the address of `hdr` in bytes
|
||||
* `ax` will contain the address of the `boot_params.hdr`
|
||||
* `dx` will contain the address of `hdr`
|
||||
* `cx` will contain the size of `hdr` in bytes.
|
||||
|
||||
`memcpy` puts the address of `boot_params.hdr` into `si` and saves the size on the stack. After this it shifts to the right on 2 size (or divide on 4) and copies from `si` to `di` by 4 bytes. After this we restore the size of `hdr` again, align it by 4 bytes and copy the rest of the bytes from `si` to `di` byte by byte (if there is more). Restore `si` and `di` values from the stack in the end and after this copying is finished.
|
||||
@ -226,9 +227,9 @@ After `hdr` is copied into `boot_params.hdr`, the next step is console initializ
|
||||
|
||||
It tries to find the `earlyprintk` option in the command line and if the search was successful, it parses the port address and baud rate of the serial port and initializes the serial port. Value of `earlyprintk` command line option can be one of these:
|
||||
|
||||
* serial,0x3f8,115200
|
||||
* serial,ttyS0,115200
|
||||
* ttyS0,115200
|
||||
* serial,0x3f8,115200
|
||||
* serial,ttyS0,115200
|
||||
* ttyS0,115200
|
||||
|
||||
After serial port initialization we can see the first output:
|
||||
|
||||
@ -343,10 +344,10 @@ The next step as we can see is cpu validation by `validate_cpu` from [arch/x86/b
|
||||
It calls the [`check_cpu`](https://github.com/torvalds/linux/blob/master/arch/x86/boot/cpucheck.c#L102) function and passes cpu level and required cpu level to it and checks that the kernel launches on the right cpu level.
|
||||
```c
|
||||
check_cpu(&cpu_level, &req_level, &err_flags);
|
||||
if (cpu_level < req_level) {
|
||||
if (cpu_level < req_level) {
|
||||
...
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
```
|
||||
`check_cpu` checks the cpu's flags, presence of [long mode](http://en.wikipedia.org/wiki/Long_mode) in case of x86_64(64-bit) CPU, checks the processor's vendor and makes preparation for certain vendors like turning off SSE+SSE2 for AMD if they are missing, etc.
|
||||
|
||||
@ -446,7 +447,7 @@ int query_mca(void)
|
||||
It fills the `ah` register with `0xc0` and calls the `0x15` BIOS interruption. After the interrupt execution it checks the [carry flag](http://en.wikipedia.org/wiki/Carry_flag) and if it is set to 1, the BIOS doesn't support (**MCA**)[https://en.wikipedia.org/wiki/Micro_Channel_architecture]. If carry flag is set to 0, `ES:BX` will contain a pointer to the system information table, which looks like this:
|
||||
|
||||
```
|
||||
Offset Size Description )
|
||||
Offset Size Description
|
||||
00h WORD number of bytes following
|
||||
02h BYTE model (see #00515)
|
||||
03h BYTE submodel (see #00515)
|
||||
@ -506,7 +507,7 @@ First of all it reads the [edd](https://github.com/torvalds/linux/blob/master/Do
|
||||
If EDD is enabled, `query_edd` goes over BIOS-supported hard disks and queries EDD information in the following loop:
|
||||
|
||||
```C
|
||||
for (devno = 0x80; devno < 0x80+EDD_MBR_SIG_MAX; devno++) {
|
||||
for (devno = 0x80; devno < 0x80+EDD_MBR_SIG_MAX; devno++) {
|
||||
if (!get_edd_info(devno, &ei) && boot_params.eddbuf_entries < EDDMAXNR) {
|
||||
memcpy(edp, &ei, sizeof ei);
|
||||
edp++;
|
||||
|
Loading…
Reference in New Issue
Block a user