Skip to content

ETOgaosion/Linux-0.11-MacOS

Repository files navigation

Linux-0.11 on MacOS

The old Linux kernel source ver 0.11 runnable on MacOS, codes were modified to be compiled by modern i386 elf toolkit.

Tested on MacOS Sonoma 14.2.

TOC

I. Clone Repo

Clone instruction:

git lfs clone https://github.com/ETOgaosion/Linux-0.11-MacOS.git

Or, if you have cloned already, use:

git lfs pull origin main

To download some important large files.

II. Installation

Build on MacOS

MacOS Setup

  1. Install cross compiler gcc, gdb and binutils
brew tap nativeos/i386-elf-toolchain
brew install i386-elf-binutils i386-elf-gcc
brew install i386-elf-gdb
  1. Install qemu
brew install qemu
  1. [optional] A linux-0.11 hardware image file(we have offered one): hdc-0.11.img, you can download it from http://www.oldlinux.org, or http://mirror.lzu.edu.cn/os/oldlinux.org/, and put it in the root directory.
  2. [optional] Download inkscape, and to use command-line tool:
ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \
      /usr/local/bin/inkscape
  1. [optional] Download imagemagick, but don't follow their command line instructions(without X11 support), use below commands:
brew tap tlk/imagemagick-x11
brew install tlk/imagemagick-x11/imagemagick

set DISPLAY env variable:

echo 'export DISPLAY=:0' > ~/.[shell]rc
source ~/.[shell]rc

Remember to Download XQuartz, and open it in background.

Then verify installation, as offically documented:

magick logo: logo.gif
identify logo.gif
display logo.gif

III. Quick Start

make help           // get help
make                // compile
make start          // boot it on qemu

IV. Advanced Usage

If you hope to dive deeper into linux, rather than just run and use, check below instructions. Notice that all scripts shall be executed in root directory.

1. Debug

In one terminal:

make debug          // debug it via qemu & gdb, you'd start gdb to connect it.

In the other:

gdb tools/system
(gdb) add-symbol-file boot/bootsect.o
(gdb) b start
(gdb) c
(gdb) remove-symbol-file boot/bootsect.o
(gdb) b main
(gdb) c

2. Call Graph

2.1 Trial

Use make cg to generate main function's call graph like below:

call graph

2.2 Usage

./scripts/callgraph.sh -f [func_name] \
                       -d [directory] \
                       -F [filterstr] \
                       -D [depth] \
                       -o [directory] \
                       -t [output_format_type]

# Output: out/func.dir_file_name.svg

If you want to directly convert picture to other format, we recommand you try inkscape

inkscape -w [width] -h [height] \
         out/[src_image].[src_type] \
         -o out/[dest_image].[dest_type]

Or if you only installed imagemagick

convert -density [density] \
        -background none \
        -resize [width]x[height] \
        out/[src_image].[src_type] \
        out/[dest_image].[dest_type]

And if you want to display image:

display out/[image].[type]

If you encounter errors, please make sure your installation correct. Open issues freely.

V. References

  1. https://gitee.com/ethan-net/linux-0.11-lab
  2. https://github.com/yuan-xy/Linux-0.11

About

linux source codes runnable on MacOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published