cfenollosa / os-tutorial Goto Github PK
View Code? Open in Web Editor NEWHow to create an OS from scratch
License: BSD 3-Clause "New" or "Revised" License
How to create an OS from scratch
License: BSD 3-Clause "New" or "Revised" License
There is a behaviour (maybe) related to qemu I don't understand.
I just tried the first lesson, and I wanted to see what would happen to the V.M. if the infinite loop "guard" was removed.
bootsector.asm
:
jmp $ ; <--<--<--<--<-- the infinite loop i'm talking about
times 510-($-$$) db 0
dw 0xaa55
Qemu crashes.
Nothing changes visually. No error or warning is issued.
I don't understand what happens behind the scene. Is the presence of an infinite loop at the end of a boot-sector optional? Or is qemu some sort of wizard that knows magically when to stop the execution of the boot-sector?
When I run the code in lesson 17, everything works fine except that the cursor is gone. This happens only when a scroll occurs. Any idea about this? Thanks.
I'm following this tutorial on Linux (ubuntu), and it worked until chapter 15. First thing is that when I want to write a character on screen I have to offset the character by 1 and the color by 2. When I copied the code it was flickering so I debugged it and managed to make the clear_screen() work (with the offset).
If anyone has an idea on what's the problem I'll be glad to hear it.
Thanks
boot_sect_main.asm:error: Can't find valid values for all labels after 1004 passes, giving up.
boot_sect_main.asm:error: Possible causes: recursive EQUs, macro abuse.
All of the other files needed are made and ready, but whenever I nasm boot_sect_main.asm -o boot_sect_main.bin
it gives this error message.
When I pass a string to kprint or kprint_at it always points to null. I have to first declare the string as an array, and then pass it. Why is this happening? I copied/pasted the code.
char msg[] = "test";
kprint_at(msg, 1, 2);
the above works but the below does not
kprint_at("test", 1, 2);
Change the link in 14 lesson README to http://ftp.rediris.es/mirror/GNU/gdb/gdb-7.8.tar.gz
because of 404 error
In 01-bootsector-barebones/README.md there is typo.
(beware of indianness, x86 is little-endian).
should read
(beware of endianness, x86 is little-endian).
If so, would you please provide links to download the necessary files?
qemu-system-x86_64 boot_sect_simple.bin WARNING: Image format was not specified for 'boot_sect_simple.bin' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5] Could not initialize SDL(No available video device) - exiting
I receive this error when attempting to run the basic bootsector. Is there something I have to specify?
Hello. I'm following the steps from: 11-kernel-crosscompiler
I've installed successfully binutils following your steps. But I'm having problems installing GCC:
In the step:
make all-target-libgcc
I'm getting the next error:
/tmp/ccP9qmbP.s:15: Error: invalid instruction suffix for push' /tmp/ccP9qmbP.s:45: Error: invalid instruction suffix for
pop'
I was reading, and I found that is because of the instructions. I don't know how to force to 32 bits mode.
Details:
make[2]: se sale del directorio '/tmp/src/gcc-build/i386-elf/libgcc'
/tmp/src/gcc-build/./gcc/xgcc -B/tmp/src/gcc-build/./gcc/ -B/usr/local/i386elfgcc/i386-elf/bin/ -B/usr/local/i386elfgcc/i386-elf/lib/ -isystem /usr/local/i386elfgcc/i386-elf/include -isystem /usr/local/i386elfgcc/i386-elf/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -fpic -I. -I. -I../.././gcc -I../../../gcc-8.1.0/libgcc -I../../../gcc-8.1.0/libgcc/. -I../../../gcc-8.1.0/libgcc/../gcc -I../../../gcc-8.1.0/libgcc/../include -DUSE_EMUTLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c ../../../gcc-8.1.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/ccP9qmbP.s: Assembler messages:
/tmp/ccP9qmbP.s:15: Error: invalid instruction suffix for push' /tmp/ccP9qmbP.s:45: Error: invalid instruction suffix for
pop'
Makefile:494: recipe for target '_muldi3.o' failed
make[1]: *** [_muldi3.o] Error 1
make[1]: se sale del directorio '/tmp/src/gcc-build/i386-elf/libgcc'
Makefile:11670: recipe for target 'all-target-libgcc' failed
make: *** [all-target-libgcc] Error 2
Installed qemu and nasm on ubuntu. The later commands are not working. I'm not exactly clear on how to open the software to write code.
Hello, it would be nice to have a license on all of this so we know the conditions to share it.
Hi, I'm a Chinese university student. I got a lot of benefit from your code 'os-tutorial'.It occurred to me that maybe I could translate them to Chinese in recent days.Therefore, I suppose I should ask your permission for the rights of translation.Likewise, I have several understandings on my own, so I'm thinking whether I can add some code lines to your finished codes. I will appreciate it if you allow me to do that. Hoping for your response. Thanks so much! 谢谢!!
Is this still active and being updated. The last commit was over 4 months ago.
I download the code to check if it was not me that I make a mistake but no the code is not correcte.
In the 32bit-main/gdt/print Idk but its not printing "Loaded 32-bit protected mode".
Can someone help me?
I have a usb with os-image.bin on it and it wont boot from physicall machine
In the first chapter, it tells me to run qemu boot_sect_simple. However, the actual command is qemu-system-x86 (or something similar).
"Probably we will go through them in that order, however it's too soon to tell."
I am studying os-dev by recoding this repo.
Then I found here have a bug in function hex_to_ascii
.
In string.c:32, it is
32 if (tmp > 0xA) append(str, tmp - 0xA + 'a');
33 else append(str, tmp + '0');
When the input int is 0xAA. Then the string of this will be "0x:A".
It should be modified the condition of tmp > 0xA
to tmp >= 0xA
.
Finally, thank you for this repository gave me great help!
Unix clone? Implement Unix v6?
Minix? BSDs?
Go for a totally different path? (templeOS, MSDOS, MikeOS, other)
I have completed the whole set of tutorial currently to 21-malloc. But I want to extend it to VGA and SVGA modules. I googled that we have to use int 0x10 for VGA Display, but it's only available for BIOS. Can I simply put them into bootsect before we are ever jumping to Protected Mode ?
I also tried to put int 0x10 before jump to pm, but the display turns black.
When trying to run nasm -f bin boot_sect_simple.asm -o boot_sect_simple.bin
I got two exceptions of the same type: expression syntax error.
I searched the Internet and managed to fix the problem, I had to rename the loop variable to loop1 and then it worked!
hey @cfenollosa ! I am working on this on my own, and really close to getting a Dockerized emulator up and running, and hitting this issue:
I've put and organized everything into a Github repo, and I would be so grateful for your help!
Specifically, I'm building the docker image, and then running (booting) the image with running it!
It's a disk read error, so maybe the issue is in the disk.asm?
If you can't help directly, could you tell me how to debug this? Thank you!
Does this tutorial assume a 32 bit environment, are the instructions mostly the same in 64 as well?
can you continue that project to make full featured kernel at the end , it is very useful repo
Hello,
When i am running 32bit_main in qemu, in lesson 10, is not working properly.
The screen is flickering, like is constantly rebooting. This only happens when i got 32 bit enabled.
When i comment out all 32bit code, and keep only 16bit is working properly.. any fixes for that?
I am sure that the problem is something about 32bit, but dont know exactly what.
Ok, first of all i only tested this with qemu.
I am compiling with gcc and linking with ld, basically because i wasn't able to install the crosscompiler for windows.
The first kernel barebones thing worked perfectly. It just printed an "X" at the top of the screen as it should. But here comes the problem: i just exacly copypasted the kprint code (it didn't work with my version of it) and it does nothing. Nothing appears at the screen at all. Surprisinhly enough, clear_screen() function works just fine, and i can change the color of it and it still does work just fine.
Please can someone help me?
When learning 18-interrupts
, content of exception_messages
in cpu/isr.c
is empty. All items are 0x0
. It seems that ld
don't replace the string constants with real address.
I do this tutorial on Gentoo
with gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0
, GNU ld (Gentoo 2.30 p5) 2.30.0
.
CFLAGS
is -m32 -fno-pie -g
. There would be errors if I don't use -fno-pie
.
I'm pretty sure I have to have this here, right?
https://github.com/Menotdan/DripOS/blob/master/LICENSE
just double checking, i want to have as little restriction as possible
The following link is mentioned in Chapter 18-Interrupts and is not available
http://www.jamesmolloy.co.uk/tutorial_html/index.html
The last update was 6 months ago. Is this tutorial discontinued?
Been following this series happily, been having fun experimenting and adding new features to the OS.
However, I've run into the issue of File I/O, which I can't find any easy-to-follow info on, mostly just tech docs and the likes. Will you be releasing a tutorial on making a File I/O API soon?
Great work regardless, thanks for making this. :)
EDIT: After extreme amounts of googling, it sounds like the standard for tutorials is FAT12, but SFS (SimpleFS) might be easier to implement/more stable.
I would love to help more, but I'm really only good at high-level languages with already-made APIs and the likes - this is my first adventure into the low-level lands of Assembly and OS development.
Location:
https://github.com/cfenollosa/os-tutorial/tree/master/05-bootsector-functions-strings
cmp ax, 4 ; if ax = 4
je ax_is_four ; do something (by jumping to that label)
jmp else ; else, do another thing
jmp endif ; finally, resume the normal flow ######### control never gets here, delete this line pls
ax_is_four:
.....
jmp endif
else:
.....
jmp endif ; not actually necessary but printed here for completeness
endif:
You should remove line marked with "#"s.
I'm at this step: https://github.com/cfenollosa/os-tutorial/tree/master/13-kernel-barebones
And I'm building in a Docker container, and I continually see the error that it cannot find the hard disk, but then is using floppy? I haven't a clue how to debug or investigate this - would there be a difference doing this in a container than locally? Please help.
I can't get a working cross compiler... Please help!
In14th lesson README, GDB build fails if guile
version is above 2.0. So add --with-guile=guile-2.0
to configure
call
when I was using ld to link kernel.o and kernel_entry.o, the error below happens
make \n kernel.o: In function ' dummy_test_entrypoint': \n kernel.c (.text+0x9): undefined reference to '_GLOBAL_OFFSET_TABLE_' \n
Any workarounds?
I follow all the instructions (I even tried the updated ones) and I get this:
checking build system type... i386-apple-darwin16.0.0
checking host system type... i386-apple-darwin16.0.0
checking target system type... i386-pc-elf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for gcc... /usr/local/bin/gcc-6.3.0_1
checking for C compiler default output file name...
configure: error: in `/tmp/src/binutils-build':
configure: error: C compiler cannot create executables
See `config.log' for more details.
How do I fix this?
../binutils-2.24/configure --target=$TARGET --enable-interwork --enable-multilib --disable-nls --disable-werror --prefix=$PREFIX 2>&1 | tee configure.log
on executing above command I'm getting these errors. what am I doing wrong ?
checking build system type... i386-apple-darwin17.4.0
checking host system type... i386-apple-darwin17.4.0
checking target system type... i386-pc-elf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for gcc... /usr/local/bin/gcc-4.9
checking for C compiler default output file name...
configure: error: in '/tmp/src/binutils-build':
configure: error: C compiler cannot create executables
See config.log' for more details.
How to ?
Disclaimer: This is a bot
It looks like your repo is trending. The github_trending_videos Instgram account automatically shows the demo gifs of trending repos in Github.
Your README doesn't seem to have any demo gifs. Add one and the next time the parser runs it will pick it up and post it on its Instagram feed. If you don't want to just close this issue we won't bother you again.
follow configure step is right for me
./configure --prefix=$PREFIX \
--target=$TARGET \
--disable-nls \
--enable-languages=c,c++ --without-headers \
--enable-interwork --enable-multilib \
--with-gmp=/usr/local/Cellar --with-mpc=/usr/local/Cellar --with-mpfr=/usr/local/Cellar
the gmp mpc mpfr must target to /usr/local/Cellar.because they are install with brew
First of all, thanks for this awesome tutorial.
I am having problems in the 13th lesson. The qemu screen just flickers. By placing some jmp $ here and there, I find that everything is fine untill the "call KERNEL_OFFSET" in BEGIN_PM in the bootsect.asm.That is control never reaches the first line of kernel_entry.asm.
There are no disk read errors (using fda) and no trouble in reaching 32 bit protected mode. Any ideas?
How exactly do I verify that the kernel binary is placed at 0x1000? Both ndisasm and xxd do not seem to show this.
How will graphics be handled?
Because the drivers for graphics cards are written per-OS.
My code hangs after loading kernel into memory.
; Identical to lesson 13's boot sector, but the %included files have new paths
[org 0x7c00]
KERNEL_OFFSET equ 0x1000 ; The same one we used when linking the kernel
mov [BOOT_DRIVE], dl ; Remember that the BIOS sets us the boot drive in 'dl' on boot
mov bp, 0x9000
mov sp, bp
mov bx, MSG_REAL_MODE
call print
call print_nl
call load_kernel ; read the kernel from disk
call switch_to_pm ; disable interrupts, load GDT, etc. Finally jumps to 'BEGIN_PM'
jmp $ ; Never executed
%include "print.asm"
%include "hexprint.asm"
%include "disk.asm"
%include "32bit-gdt.asm"
%include "32bit-print.asm"
%include "32bit-switch.asm"
[bits 16]
load_kernel:
mov bx, MSG_LOAD_KERNEL
call print
call print_nl
mov bx, KERNEL_OFFSET ; Read from disk and store in 0x1000
mov dh, 64 ; Our future kernel will be larger, make this big
mov dl, [BOOT_DRIVE]
call disk_load
ret
[bits 32]
BEGIN_PM:
mov ebx, MSG_PROT_MODE
call print_string_pm
call KERNEL_OFFSET ; Give control to the kernel
jmp $ ; Stay here when the kernel returns control to us (if ever)
BOOT_DRIVE db 0 ; It is a good idea to store it in memory because 'dl' may get overwritten
MSG_REAL_MODE db "Started in 16-bit Real Mode", 0
MSG_PROT_MODE db "Landed in 32-bit Protected Mode", 0
MSG_LOAD_KERNEL db "Loading kernel into memory", 0
; padding
times 510 - (
dw 0xaa55
thats the boot sector
Perhaps create a bootable USB flash drive?
For the future
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.