Skip to content
Branch: master
Go to file
Code

Latest commit

spevans committed 7f77a68 Sep 10, 2019
- Dockerfile: Update to copy in a local kstdlib.tgz if available.

- debug: Add a 'dumpswiftstring' comand to lldb to show Swift Strings
  from 2 registers.

- Add an 'lldb-cmds' script to run when using lldb and rename '.gdbinit'
  to 'gdb-cmds' to provide the gdb verison.

- Add a check and oops if there is no initial free memory to add at
  startup.

- kernel: Add all the free pages to the free list before setting up the
  symbol table as the sort may require more memory then is initially
  available.

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
doc
 
 
 
 
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

project1 - Implementing a minimal bare metal kernel in Swift

What is it?

A project to write a kernel in Swift that can boot on a Mac or PC. The main aim is to get a simple kernel booting up with a CLI with full concurrency/thread support.

There is a short writeup about it here.

Current status

  • Boots up under QEMU, Bochs and VMWare. Also boots on Macbook 3,1 (13inch Late 2007)
  • Installs interrupts and exception/fault handlers
  • Sets up paging
  • Scans ACPI/SMBIOS tables
  • Parses ACPI tables including AML bytecode in DSDT, SSDT tables
  • Initialises the APIC and IO/APIC (or PIC)
  • Traverses the ACPI device tree adding known devices according to topology.
  • Scans PCI bus (MMIO or PIO) to show vendor/device IDs
  • Initialises the PIT and PS/2 keyboard controller
  • Sets up an APIC and PIT timers and shows a test message with interrupt counts.
  • Runs a simple task reading keyboard scan codes from a circular buffer and translates them to ASCII codes to show on the screen. The Macbook doesn't have an i8042 PS/2 keyboard controller so the keyboard will not work.

Currently working on enabling ACPI to process ACPI events and setting up more devices including the Realtime Clock and PCI interrupts.

The next major tasks are:

  • USB controller and USB keyboard driver for the keyboard on Macbook 3,1

How to build it

Use Docker to build a container that includes the swift compiler with the modified stdlib using the Dockerfile in Docker/Dockerfile.

# Build the docker container
$ docker build Docker

To build the kernel and disk images from the command line:

$ docker run --rm -v `pwd`:`pwd` -w `pwd` -t swift-kstdlib make iso

or using Xcode, open project1.xcodeproj, select kernel in the target menu and then Product → Build or ⌘-B to build it.

How to run it

To run under qemu with a copy of the console output being sent to a virtual serial port use:

./run_qemu.sh

There is a bochsrc to specify the HD image so it can be run with:

bochs -q

(then press c to run)

Screenshot

Copyright (c) 2015 - 2019 Simon Evans

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.