Comments (5)
It will be helpful if you show the source code.
Talk is cheap, Show me the code
---- Linus Torvalds
from os-tutorial.
I fixed it by changing the amount of sector read based on #103
As the os-image
at this point is already pretty large (mine is 2244 bytes including boot sector), you will need to read more than 2 sectors (1024 bytes) to read the entire kernel into the memory.
In the bootsect.asm
, change the 2 in mov dh, 2
to something larger will solve the problem. It worked for me after I changed it to 8.
[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, 8 ; number of sectors (512 bytes per sector) <======This line======
mov dl, [BOOT_DRIVE]
call disk_load
ret
from os-tutorial.
from os-tutorial.
I have the same problem. The emu keep flickering when I run the code in chapter 16.
When I debug it with GDB, it seems like the whole thing reboot after the clear_screen
function is called even though clear_screen()
does successfully cleared the screen.
Execution log:
$ make debug
qemu-system-i386 -s -fda os-image.bin &
/usr/local/i386elfgcc/bin/i386-elf-gdb -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin18.2.0 --target=i386-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
/Users/lewisxy/.gdbinit:1: Error in sourced command file:
No symbol table is loaded. Use the "file" command.
WARNING: Image format was not specified for 'os-image.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.
Remote debugging using localhost:1234
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0xfffecf4c in ?? ()
Reading symbols from kernel.elf...done.
(gdb) b main
Breakpoint 1 at 0x1007: file kernel/kernel.c, line 3.
(gdb) c
Continuing.
Breakpoint 1, main () at kernel/kernel.c:3
3 void main() {
(gdb) s
4 clear_screen();
(gdb) s
clear_screen () at drivers/screen.c:108
108 int screen_size = MAX_COLS * MAX_ROWS;
(gdb) s
110 char *screen = VIDEO_ADDRESS;
(gdb) s
112 for (i = 0; i < screen_size; i++) {
(gdb) s
113 screen[i*2] = ' ';
(gdb) s
114 screen[i*2+1] = WHITE_ON_BLACK;
(gdb) s
112 for (i = 0; i < screen_size; i++) {
(gdb) b 116
Breakpoint 2 at 0x13ca: file drivers/screen.c, line 116.
(gdb) c
Continuing.
Breakpoint 2, clear_screen () at drivers/screen.c:116
116 set_cursor_offset(get_offset(0, 0));
(gdb) s
get_offset (col=0, row=0) at drivers/screen.c:120
120 int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); }
(gdb) s
get_offset_row (offset=5078) at drivers/screen.c:121
121 int get_offset_row(int offset) { return offset / (2 * MAX_COLS); }
(gdb) s
This step takes a while, the screen is already cleared at this point, but it rebooted (with the screen turned into the state before the call of clear_screen(). And gdb point the cursor at the first line of main() again as showed follows.
Breakpoint 1, main () at kernel/kernel.c:3
3 void main() {
(gdb)
Any ideas how to fix it?
from os-tutorial.
I made it 16 and somehow my code stopped working completely. It get's stuck at "Booting from Hard Disk". Strangely, it is working for a smaller values like 5.
Shall I load the kernel at a higher value, other than 0x1000?
from os-tutorial.
Related Issues (20)
- 14-checkpoint: Program received signal SIGTRAP, Trace/breakpoint trap HOT 4
- Problem with example 14 on real machine HOT 1
- cross-compiler for M1 MacBook? HOT 10
- Difference in binary code between the book and my PC HOT 2
- PLEASE CONTINUE !!!!!
- Multiple definition of 'idt' and 'idt_reg' HOT 1
- 3 - jump opcode causes a problem
- File driver fat32 HOT 4
- To whom it may concern! HOT 1
- Result displayed on the terminal itself HOT 1
- 11-Cross Compiler: GCC not compiling HOT 1
- I have a question about 13 kernel bare bones HOT 2
- Share my Makefile to everyone(macOS 13.5) HOT 1
- 05-bootsector-functions-strings/boot_sect_print_hex.asm
- [Open letter] long-standing problems with this tutorial and its consequences due to good SEO HOT 8
- Linker Error! HOT 1
- Print function will print to random locations
- Tut
- An OS from scratch started with this tutorial HOT 1
- Error: unable to disambiguate: -no-PIE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from os-tutorial.