Compare commits

...

10 Commits

Author SHA1 Message Date
Ciro Santilli
528ab2becc fix ps2 link 2021-05-14 01:00:00 +00:00
Ciro Santilli
f16fe745f2 china 2021-04-03 01:00:00 +00:00
Ciro Santilli,Opinions and content are my own, not my employer's,2020冠状病毒审查 2018新疆改造中心,1989六四事件,1999法轮功 ,2019 996.ICU, 2018包子露宪,2015 709大抓捕,2015巴拿马文件 邓家贵,2017低端人口,2008西藏骚乱scriptalert(1)/script
f60929da69 Merge pull request #14 from io12/master
Add BootMine boot sector game
2020-05-30 16:03:13 +01:00
io12
5075504373 Add BootMine boot sector game 2020-05-30 04:45:18 -04:00
Ciro Santilli
3a81b464c5 readd one paging comment 2020-05-06 01:00:00 +00:00
Junming Liu
f2a26f8e83 Refine paging related codes and comments 2020-05-06 05:56:19 +08:00
Ciro Santilli
cf4f2df43b paging.S: explain page table setup
https://github.com/cirosantilli/x86-bare-metal-examples/issues/12
2020-05-03 15:14:09 +00:00
Ciro Santilli
d2dabadb14 slightly better cirosantilli.com links 2020-05-03 14:14:08 +00:00
Ciro Santilli,Opinions and content are my own, not my employer's,2020冠状病毒审查 2018新疆改造中心,1989六四事件,1999法轮功 ,2019 996.ICU, 2018包子露宪,2015 709大抓捕,2015巴拿马文件 邓家贵,2017低端人口,2008西藏骚乱scriptalert(1)/script
9e8a511698 Merge pull request #11 from liujunming/link_fix
fix link typos
2020-05-03 13:14:07 +01:00
Junming Liu
e6a8496959 fix link typos 2020-05-04 03:58:41 +08:00
4 changed files with 37 additions and 17 deletions

View File

@@ -16,6 +16,16 @@ link:{logo}[image:{logo}[]]
toc::[] toc::[]
== China
Before <<getting-started>>, read this important pre-requisite: https://github.com/cirosantilli/china-dictatorship
Because human rights is more important than profit and technology.
image::https://raw.githubusercontent.com/cirosantilli/china-dictatorship-media/master/Hao_Haidong_kick.jpg[width=600]
image::https://raw.githubusercontent.com/cirosantilli/china-dictatorship-media/master/Xi_sadomasochist.jpg[width=600]
== Getting started == Getting started
First read this introduction: https://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system/32483545#32483545 First read this introduction: https://stackoverflow.com/questions/22054578/how-to-run-a-program-without-an-operating-system/32483545#32483545
@@ -1277,7 +1287,7 @@ Without segment manipulation, the output would be just: TODO
===== Segmentation introduction ===== Segmentation introduction
First read the paging tutorial, and in particular: http://www.cirosantilli.com/x86-paging/#segmentation to get a feel for the type of register and data structure manipulation required to configure the CPU, and how segmentation compares to paging. First read the paging tutorial, and in particular: https://cirosantilli.com/x86-paging#segmentation to get a feel for the type of register and data structure manipulation required to configure the CPU, and how segmentation compares to paging.
Segmentation modifies every memory access of a given segment by: Segmentation modifies every memory access of a given segment by:
@@ -1485,7 +1495,7 @@ Try commenting out waking up the second processor and see it not get printed.
==== Paging ==== Paging
Verbose beginner's tutorial: http://www.cirosantilli.com/x86-paging/ Verbose beginner's tutorial: https://cirosantilli.com/x86-paging
Change page tables and observe how that affects memory accesses: Change page tables and observe how that affects memory accesses:
@@ -2311,6 +2321,7 @@ Almost entirely in C `-nostdlib`, with very few inline `asm` commands, and a sma
* https://github.com/nanochess/fbird Flappy bird in the 512-byte boot sector. * https://github.com/nanochess/fbird Flappy bird in the 512-byte boot sector.
* https://github.com/Overv/MineAssemble Minecraft * https://github.com/Overv/MineAssemble Minecraft
* https://github.com/tsoding/pinpog Pong / Breakout * https://github.com/tsoding/pinpog Pong / Breakout
* https://github.com/io12/bootmine Minesweeper game in a 512-byte boot sector.
=== Tutorials === Tutorials
@@ -2423,7 +2434,7 @@ A list of ARM bare metal resources can be found at: https://github.com/cirosanti
== LICENSE == LICENSE
Copyright Ciro Santilli http://www.cirosantilli.com/ Copyright Ciro Santilli https://cirosantilli.com
https://www.gnu.org/licenses/gpl-3.0.txt[GPL v3] for executable computer program usage. https://www.gnu.org/licenses/gpl-3.0.txt[GPL v3] for executable computer program usage.

View File

@@ -212,8 +212,9 @@ protected_mode:
mov %ebp, %esp mov %ebp, %esp
.endm .endm
/* Setup a single page directory, which give us 2^10 * 2^12 == 4MiB /* Setup the first Page Directory entry, which gives us a 4MB(2^10 * 2^12) memory region.
* of identity memory starting at address 0. * The memory region starts at 0, and the virtual address and physical address are identical.
*
* The currently executing code is inside that range, or else we'd jump somewhere and die. * The currently executing code is inside that range, or else we'd jump somewhere and die.
*/ */
.equ page_directory, __end_align_4k .equ page_directory, __end_align_4k
@@ -222,15 +223,15 @@ protected_mode:
LOCAL page_setup_start page_setup_end LOCAL page_setup_start page_setup_end
PUSH_EADX PUSH_EADX
/* Page directory steup. */ /* Page Directory setup. */
/* Set the top 20 address bits. */ /* Set the top 20 address bits. */
mov $page_table, %eax mov $page_table, %eax
/* Zero out the 4 low flag bits of the second byte (top 20 are address). */ /* Clear the low 12 bits of the first Page Directory entry. */
and $0xF000, %ax and $0xF000, %ax
mov %eax, page_directory /* Set the P, R/W, U/S, and A bits of the first Page Directory entry. */
/* Set flags for the first byte. */
mov $0b00100111, %al mov $0b00100111, %al
mov %al, page_directory /* Setup the first Page Directory entry. */
mov %eax, page_directory
/* Page table setup. */ /* Page table setup. */
mov $0, %eax mov $0, %eax
@@ -241,14 +242,15 @@ page_setup_start:
/* Top 20 address bits. */ /* Top 20 address bits. */
mov %eax, %edx mov %eax, %edx
shl $12, %edx shl $12, %edx
/* Set flag bits 0-7. We only set to 1: /* For flag bits 0-7. We only set bit 0 and bit 1:
* * bit 0: Page present * - bit 0: Page present
* * bit 1: Page is writable. * - bit 1: Page is writable.
* Might work without this as the permission also depends on CR0.WP. * Might work without this as the permission also depends on CR0.WP.
*/ */
mov $0b00000011, %dl mov $0b00000011, %dl
/* Zero flag bits 8-11 */ /* Zero flag bits 8-11 */
and $0xF0, %dh and $0xF0, %dh
/* Setup the PTE(Page Table Entry). */
mov %edx, (%ebx) mov %edx, (%ebx)
inc %eax inc %eax
add $4, %ebx add $4, %ebx

View File

@@ -1,4 +1,4 @@
/* https://github.com/cirosantilli/x86-bare-metal-examples#ps-2-keyboard */ /* https://github.com/cirosantilli/x86-bare-metal-examples#ps2-keyboard */
#include "common.h" #include "common.h"
BEGIN BEGIN

View File

@@ -1,4 +1,4 @@
/* https://github.com/cirosantilli/x86-bare-metal-examples#paging.S */ /* https://github.com/cirosantilli/x86-bare-metal-examples#paging */
#include "common.h" #include "common.h"
@@ -14,8 +14,15 @@ BEGIN
/* Print the canary to make sure it is really there. */ /* Print the canary to make sure it is really there. */
VGA_PRINT_HEX_4 0x1000 VGA_PRINT_HEX_4 0x1000
/* Make page 0 point to 4KiB. */ /* Make page 0 point to page frame 1(i.e. virtual address 0 points to physical address 4KB)
orb $0x10, page_table + 1 * by setting bit 12 of the Page Table Entry structure.
*
* At SETUP_PAGING_4M, page_table has been setup to
* point page frame 0(i.e. page 0 point to page frame 0).
* Bit 12 is the lowest bit of the "Address of 4KB page frame" field,
* By setting it, can relocate page 0 point to page frame 1.
*/
orw $0x1000, page_table
PAGING_ON PAGING_ON