IlanVinograd / OS_32Bit

32 Bit Operation System
GNU General Public License v3.0
3 stars 1 forks source link

Create WorkFlow.md #1

Closed IlanVinograd closed 2 months ago

IlanVinograd commented 2 months ago

BOOT FLOW

BIOS

step 1. POST - (Power-On Self-Test) Done

step 2. MBR - (Master Boot Record)

danielLublinsky commented 2 months ago

@IlanVinograd - WorkFlow.md: will be the work - flow meaning how development will be made, branching pushing, commiting..... TECHNICAL_GUIDE.md will be where all of the boot flow, kernal flow... all of the technical documentation

IlanVinograd commented 2 months ago

CS:IP Solution

Register CS (Code Segment) Register IP (Instruction Pointer)

The CS:IP, in Briefly, the syntax is segment:offset A simple analogy could be chapter : verse.

When the BIOS loads the boot sector into memory, it places it at address 0x0000:0x7C00 (segment 0x0000, offset 0x7C00) or 0x07C0:0x0000 (segment 0x07C0, offset 0x0000). These two variants point to the same physical address.

here's why:

Physical Address = Segment × 16 + Offset

Physical Address = 0x0000×16 + 0x7C00 = 0x00000 + 0x7C00 = 0x7C00 Physical Address = 0x07C0 × 16 + 0x0000 = 0x07C00 + 0x0000 = 0x7C00

We should explicit CS:IP, in some cases, the BIOS may load the boot sector using CS:IP as 0x07C0:0x0000, which also gives the physical address 0x7C00. However, the processor may interpret instructions and data differently if the segment is not explicitly set.

Example of code for explicitly set:

ljmp 0x07C0, start
start:
        ; Code to execute after the jump

This code is used to explicitly set a new code segment (CS) and instruction pointer (IP) to continue execution in segment 0x07C0 at the specified offset (start).

ljmp 0x07C0, start is used for explicitly setting the segment and offset during execution.

Use of org not give explicitly set:

org 0x7C00

This code is used to instruct the assembler that the entire program is loaded at the physical address 0x7C00, and all offsets in the program will be calculated relative to this address. This simplifies the code as it doesn't require explicitly setting the segment.

org 0x7C00 does not change the segment during execution, it only informs the assembler about the starting address for calculating offsets. Therefore, ljmp is the explicit method for setting CS:IP during program execution.

danielLublinsky commented 2 months ago

@IlanVinograd - awesome job, add it to the technical guide under boot loader - > stage 1.

danielLublinsky commented 2 months ago

We should split the technical guide into multiple documents, like bootloader technical guide, kernal technical guide.... so add Bootloader_Technical_guide.md, and it will be all things related bootloader

This is just to keep things short....

IlanVinograd commented 2 months ago

ok, do we need BIOS guide?

danielLublinsky commented 2 months ago

@IlanVinograd - I don't want to make a tutorial on OS's And the Bios is not part of the os.

But you can write something about the interrupts and why we need protected mode,

For now, keep bios out of the docs