gbowne1 / ClassicOS

An x86 32 biit Operating System for 386, 486, Pentium class (P-60 to 233MHz, Pentium II, P3, P4, etc)
9 stars 0 forks source link

Bootloader issue #42

Open gbowne1 opened 1 year ago

gbowne1 commented 1 year ago

The 2nd stage bootloader asm file loops.

Not sure what the cause is.

We are using nasm and QEMU.

Also not sure that we are dealing with bootloader properly.

Notes:

gbowne1 commented 1 year ago

As far as I can tell, in a 2 stage bootloader system:

1st bootloader:

@Karutoh

gbowne1 commented 1 year ago

My reference is: https://github.com/gotoco/PE_Bootloader_x86/blob/master/src/Stage2.asm and https://github.com/gotoco/PE_Bootloader_x86/blob/master/src/Stage1FDD.asm

gbowne1 commented 1 year ago

In x86 IA-32 boot loaders, the common practice of starting at 0x7C00 and then jumping to either 0x0000, 0x1000, or 0x2000 by a jmp instruction in NASM serves several crucial purposes:

Real Mode Execution: When the BIOS finds a bootable floppy or hard disk, it loads the 512-byte boot sector into memory at physical addresses 0x7C00 through 0x7DFF. The jmp instruction is then used to set the CS:IP to 0000:7C00, passing control to the boot loader

Transition to Protected Mode: The boot loader switches the processor from real mode to 32-bit protected mode, enabling software to access more memory and utilize advanced features

Memory Addressing: The jmp instruction is used to transfer control to a specific memory address, allowing the boot loader to execute code located at different memory locations, such as 0x0000, 0x1000, or 0x2000, depending on the specific requirements of the bootstrapping process.

Serialization of the Processor: The jmp or call instruction immediately after the MOV CR0 instruction changes the flow of execution and serializes the processor, ensuring proper execution of subsequent instructions

gbowne1 commented 3 months ago

Here are some references for making bootloaders

https://medium.com/@prithivimaruthachalam/building-a-glorified-bootloader-in-c-part-1-bf0ffb5eb382 https://medium.com/@prithivimaruthachalam/building-a-glorified-bootloader-part-2-4dd17c9917f2 https://wiki.osdev.org/Bootloader https://github.com/tuhdo/os-study/blob/master/bootloader/boot_loader.asm https://github.com/tuhdo/os-study/blob/master/bootloader/stage2.asm https://stackoverflow.com/questions/2065370/how-to-load-second-stage-boot-loader-from-first-stage https://forum.osdev.org/viewtopic.php?p=305833 https://blog.ghaiklor.com/2017/10/21/how-to-implement-your-own-hello-world-boot-loader/ https://blog.ghaiklor.com/2017/11/02/how-to-implement-a-second-stage-boot-loader/ https://en.wikibooks.org/wiki/X86_Assembly/Bootloaders http://3zanders.co.uk/2017/10/13/writing-a-bootloader/ https://www.sqlpassion.at/archive/2022/02/03/the-boot-process-of-a-pc-and-how-to-write-your-own-boot-loader/ https://539kernel.com/book/Chapter_1:_Let%27s_Start_with_the_Bootloader.html https://www.cs.unc.edu/~porter/courses/comp630/s24/lab1.html https://medium.com/@g33konaut/writing-an-x86-hello-world-boot-loader-with-assembly-3e4c5bdd96cf https://www.cs.princeton.edu/courses/archive/fall17/cos318/projects/project1/project1 https://doc.redox-os.org/book/ch04-03-boot-process.html https://coditva.github.io/Jazz/boot-loader.html https://dev.to/frosnerd/writing-my-own-boot-loader-3mld https://www.robopenguins.com/x86-boot-loading/ https://github.com/matlo607/simple-x86-bootloader https://alamot.github.io/os_stage1/ https://alessandropellegrini.it/didattica/2018/aosv/3.x86-boot.pdf https://www.viralpatel.net/taj/tutorial/hello_world_bootloader.php http://www.cs.cmu.edu/~410-s07/p4/p4-boot.pdf https://arjunsreedharan.org/post/82710718100/kernels-101-lets-write-a-kernel

If for some reason you need more.. we can work on that.

gbowne1 commented 3 months ago

More resources

There's a Libera.chat osdev channel #osdev but it seems to mainly young people who don't say much in there related to osdev.

Theres a reddit https://www.reddit.com/r/osdev/

https://wiki.osdev.org/Creating_an_Operating_System

https://wiki.osdev.org/Bare_Bones A "bare bones" example https://wiki.osdev.org/Category:Bare_bones_tutorials Some bare bones tutorials in various languages https://wiki.osdev.org/Required_Knowledge required knowledge https://wiki.osdev.org/Beginner_Mistakes#Teamwork Beginner mistakes https://wiki.osdev.org/Introduction https://wiki.osdev.org/Tutorials https://wiki.osdev.org/Getting_Started https://wiki.osdev.org/Resources

https://www.informit.com/articles/article.aspx?p=26396

Some notes: https://github.com/dreamportdev/Osdev-Notes

A few videos https://www.youtube.com/playlist?list=PLKbvCgwMcH7BX6Z8Bk1EuFwDa0WGkMnrz

https://mikeos.sourceforge.net/write-your-own-os.html the MikeOS tutorital

Other resources https://davmac.org/osdev/index.html

A big meaty skeleton OS which has a lot of stuff already done https://wiki.osdev.org/Meaty_Skeleton

https://createyourownos.blogspot.com/p/32-bit-operating-system.html

some kinda OS https://en.wikiversity.org/wiki/Disk_Operating_System/Hello,_World!

search Google, etc. for Ralph Brown's Interrupt List for BIOS interrupts. https://www.google.com/search?q=bios+interrupt+list

https://web.archive.org/web/20121125205058/http://www.nondot.org/sabre/os/articles/TheBootProcess/****

gbowne1 commented 2 months ago

found a bunch more links in my stash

https://www.youtube.com/watch?v=IE2-w_kxhyY https://www.reddit.com/r/osdev/comments/ny48xh/osdevelopment_in_c_with_cmake_or_make/ https://www.alanfoster.me/posts/writing-a-bootloader/ https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf very very interesting PDF https://raw.githubusercontent.com/tuhdo/os01/master/Operating_Systems_From_0_to_1.pdf another very interesting pdf https://intermezzos.github.io/book/first-edition/multiboot-headers.html

If you're gonna do kernel stuff. .https://wiki.osdev.org/Kernel_Debugging https://wiki.osdev.org/QEMU some stuff on Interrupts https://sites.google.com/site/masumzh/articles/x86-architecture-basics/interrupts-faults-and-traps

This is important stuff https://wiki.osdev.org/Global_Descriptor_Table https://wiki.osdev.org/GDT_Tutorial https://en.wikipedia.org/wiki/Global_Descriptor_Table

https://samypesse.gitbook.io/how-to-create-an-operating-system/chapter-1 http://www.osdever.net/ Great looking OS with some issues.. mostly typos, etc. on YouTube https://github.com/AlgorithMan-de/wyoos/ https://www.youtube.com/@codewithmartin this guy streamed on Twitch a while back doing OSDev. vods on this channel https://www.cs.cmu.edu/~410/doc/minimal_boot.pdf https://wiki.osdev.org/Detecting_Memory_(x86) https://stanislavs.org/helppc/

gbowne1 commented 2 months ago

https://wiki.osdev.org/Paging https://wiki.osdev.org/Interrupts https://en.wikipedia.org/wiki/Interrupt_vector_table https://theretroweb.com/motherboard/manual/p2bb-102-615e01519b833164803606.pdf ASUS P2B manual https://datasheet.octopart.com/FW82443BX-Intel-datasheet-5334749.p[df http://www.o3one.org/hwdocs/ethernet/intel/intel_82558_29736001.pdf https://datasheets.chipdb.org/Intel/x86/Pentium/24143004.PDF https://www.ardent-tool.com/CPU/docs/Intel/Pentium/241428-004.pdf http://flint.cs.yale.edu/cs421/papers/x86-manual/vol3-prog-guide.pdf https://www.lpthe.jussieu.fr/~talon/pentiumII.pdf https://ardent-tool.com/CPU/docs/Intel/IA/241799-001.pdf https://forum.nasm.us/index.php?topic=3887.0 https://github.com/dreamportdev/Osdev-Notes/blob/master/00_Introduction/03_AboutTheAuthors.md https://pdos.csail.mit.edu/6.828/2005/lec/lec8-slides.pdf https://github.com/littleosbook/littleosbook/blob/master/ https://www.cs.unc.edu/~porter/courses/cse506/f12/slides/interrupts.pdf PDF on interrupts https://www.felixcloutier.com/x86/iret:iretd:iretq https://alamot.github.io/os_isr/ https://en.wikibooks.org/wiki/X86_Assembly/Advanced_Interrupts https://www.youtube.com/watch?v=NqSE_aVCJXg https://alex.dzyoba.com/blog/os-interrupts/ https://pdos.csail.mit.edu/6.1810/2004/lec/l8.html https://en.wikipedia.org/wiki/INT_(x86_instruction) https://www.cs.uaf.edu/2012/fall/cs301/lecture/10_05_syscall.html https://www.reddit.com/r/osdev/comments/1848tqz/need_some_help_understanding_the_idt/ https://www.cs.uaf.edu/2012/fall/cs301/lecture/10_05_syscall.html https://c9x.me/x86/html/file_module_x86_id_156.html https://notes.shichao.io/asm/ https://www.felixcloutier.com/x86/intn:into:int3:int1 Reverse https://faculty.etsu.edu/tarnoff/labs4717/interrupts/interrupts.htm https://sites.google.com/site/masumzh/articles/x86-architecture-basics/x86-architecture-basics

gbowne1 commented 2 months ago

https://ics.uci.edu/~aburtsev/238P/2020spring/lectures/lecture09-interrupts/lecture09-interrupts.pdf https://www.cs.unc.edu/~porter/courses/cse506/f12/slides/interrupts-handout.pdf http://69.63.68.22:8181/wikibooks_en_all_2017-02/A/X86_Assembly_Advanced_Interrupts.html https://pages.cs.wisc.edu/~gerald/cs537/Summer17/handouts/traps.pdf https://www.cs.bham.ac.uk/~exr/lectures/opsys/15_16/examples/ https://en.wikipedia.org/wiki/X86_debug_register https://pdos.csail.mit.edu/6.828/2016/readings/boot-cdrom.pdf Booting on CD

Yeah I tried a 64 bit OS https://gitea.eventhorizonstudio.io/gbowne1/64os/src/branch/main/src/impl/x86_64/boot/header.asm

gbowne1 commented 2 months ago

https://github.com/leo007er1/FeatherOS FeatherOS https://littleosbook.github.io/ The Little OS Book https://hasinisama.medium.com/building-your-own-operating-system-2-e66425adb084 https://www.osdev.org/howtos/1/ Theres 3 of these pages https://dev.to/frosnerd/writing-my-own-boot-loader-3mld https://www.reddit.com/r/programming/comments/if3z1x/making_an_os_x86_part_1_cpu_assembly_booting/ https://isu-rathnayaka.medium.com/develop-your-own-x86-operating-system-os-1-c4d5f9eafa1b theres 10+ of these https://github.com/FRosner/FrOS/tree/minimal-c-kernel https://www.cse.iitd.ernet.in/~sbansal/os/ OS development labs https://techiefood4u.wordpress.com/wp-content/uploads/2020/02/operating_systems_three_easy_pieces.pdf https://people.eecs.berkeley.edu/~prabal/resources/osprelim/ALB+91.pdf https://www.c-sharpcorner.com/article/creating-your-own-operating-system/ https://www.codeproject.com/Articles/664165/Writing-a-boot-loader-in-Assembly-and-C-Part Part1 https://csc-knu.github.io/sys-prog/books/Andrew%20S.%20Tanenbaum%20-%20Modern%20Operating%20Systems.pdf https://www.youtube.com/watch?v=6zPBNEDKbpk&list=PL2EF13wm-hWAglI8rRbdsCPq_wRpYvQQy has a OSDev playlist https://people.cs.rutgers.edu/~pxk/416/notes/ https://www.sigops.org/s/conferences/sosp/2009/papers/porter-sosp09.pdf https://539kernel.com/A_Journey_in_Creating_an_Operating_System_Kernel_The_539kernel_Book.pdf https://csc-knu.github.io/sys-prog/books/Andrew%20S.%20Tanenbaum%20-%20Operating%20Systems.%20Design%20and%20Implementation.pdf
https://www.cs.utexas.edu/~lin/papers/usenix16.pdf https://littleosbook.github.io/book.pdf https://abhyass.wordpress.com/wp-content/uploads/2016/09/thedesignofunixoperatingsystem_m_bach.pdf https://github.com/xing1357/SimpleOS http://www.osdever.net/tutorials/ https://github.com/garciart/hello-os

gbowne1 commented 2 months ago

https://udos-project.github.io/osdev.html https://wiki.osdev.org/Meaty_Skeleton