1. Introduction
1. Modified part of the c and assembly code, can be compiled by the latest version of GCC (my computer macOS Catalina 10.15; gcc).version 10.3.0 (GCC))
2. Learning materials are placed in the source code directory of the study, you can check with the
2. Compile the source code
- Download source code/galis/linux-0.12
- Modify the Makefile file in the root directory of the source code, change the following paths to your computer's
export KERNEL_INCLUDE = /Volumes/mac-code/linux-0.12/include
export GCC_PREFIX = /usr/local/opt/x86_64-elf-gcc/bin/x86_64-elf-
export BINUTILS_PREFIX = /usr/local/opt/x86_64-elf-binutils/bin/x86_64-elf-
- 1
- 2
- 3
- fulfillment
make clean && make
, you can get Image, located in the root directory of the source code
3. Operation and commissioning
- Make sure you have bochs installed on your computer to support gdb, please find out how to install bochs on your own, there is a lot of information on the internet.
- Unzip tools/root-0., get tools/root-0.... (git does not allow more than 100M files to be uploaded!)
- Modify the tools/scripts configuration to suit the situation
LINUX_CODE_PATH=/Volumes/mac-code/linux-0.12
BOCHS_EXE_PATH=/Volumes/mac-data/bochs-2.6.11/build-mac-gdb/bin/bochsdbg
BOCHS_CONFIG_PATH=${LINUX_CODE_PATH}/tools/bochsconfig_linux12.txt
- 1
- 2
- 3
- Modify the tools/bochsconfig_linux11.txt configuration as appropriate
romimage:file=/Volumes/mac-data/bochs-2.6.11/build-mac/share/bochs/BIOS-bochs-latest
vgaromimage:file=/Volumes/mac-data/bochs-2.6.11/build-mac/share/bochs/VGABIOS-lgpl-latest
floppya:1_44=/Volumes/mac-code/linux-0.12/Image,status=inserted
ata0-master: type=disk, mode=flat, path="/tmp/root-0.", cylinders=410, heads=16, spt=38
- 1
- 2
- 3
- 4
-
existClionCreate a script to execute the configuration, fill in the relevant parameters, click OK to create
parameters
Script Path
, select tools/ in the source code root directory.
parametersWorking Directory
,Select the path to the source code root directory
-
Create a GDB REMOTE DEBUG configuration in Clion, then fill in the relevant parameters, and click OK to create.
parameters
symbol file
, select the source code compiled from the tools/
parameterssysroot
, select the source code root directory.Before launch
Add the Shell Script you created in step 5.The goal is to compile and start bochs before debugging.
- At the point of interruption, click on the debug button to debug it
4. Notes and Revision Records
- Remove AS86 LD86 and replace it with gcc
- Compiling with as
- Delete seg, change some code. seg affects the next statement only.
- export variables for the next level of makefiles
- Delete the compilation clobber list
- Extending the assembly requires %%, not extending it requires %%.
- Merge redefinition symbols, using only the first symbol. ld
- lvalue required as left operand of assignment There's no good way to do this, just rewrite it.
- Remove the function modifier _. Change it yourself...BUILD irq lots of
- In Mac case-sensitive is very important, in the MAC compiler to pay attention to whether the partition support case.
- invalidate_buffers I can't find it.。Add a lineextern void invalidate_buffers(int dev);
- Outputs and memory variable inputs at the same time should be taken care of.
- HD controller not ready problem
The original statement:
163 int retries=10000;
165 while (–retries && (inb_p(HD_STATUS)&0xc0)!=0x40);
modify to
163 int retries=100000;
165 while (–retries && (inb_p(HD_STATUS)&0x80));
The reasoning is that whether the driver is ready or not is independent of the state of the controller, we only need to detect if the status register busy bit is 1, we don't need to care about the ready bit. `