Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix building with scas #195

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
10 changes: 8 additions & 2 deletions .build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
image: archlinux
packages:
- mono
- make
- sass
- mktiupgrade
- genkfs
- mkrom
- patchrom
sources:
- https://github.com/KnightOS/kernel
- https://github.com/KnightOS/scas
environment:
project: kernel
tasks:
- scas: |
cd scas
mkdir build
cd build
cmake ..
make
sudo make install
- ti73: |
cd ${project}
make TI73
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 The KnightOS Group
Copyright (c) 2014-2020 The KnightOS Group

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
30 changes: 11 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Makefile for KnightOS kernel
AS=sass
ASFLAGS=--encoding "Windows-1252"
AS=scas
ASFLAGS=-v
.DEFAULT_GOAL=TI84pSE
PLATFORM:=TI84pSE
TAG:=$(shell git describe --abbrev=0)
TAG:=$(shell git describe --abbrev=0 --dirty=+)
OUTDIR=bin/

KERNEL_VERSION = -DKERNEL_VERSION=$(TAG)

# Platforms:
# Variables (all in hex):
# PRIVILEGED: The address of the privileged page
Expand Down Expand Up @@ -65,7 +67,7 @@ TI84pCSE: BOOT := 3FC000
TI84pCSE: LENGTH := 0x400000
TI84pCSE: kernel $(OUTDIR)

DEFINES=--define $(PLATFORM)
DEFINES=--define $(PLATFORM) $(KERNEL_VERSION)
BINDIR=$(OUTDIR)$(PLATFORM)/
INCLUDE=include/;$(BINDIR)

Expand Down Expand Up @@ -109,28 +111,18 @@ baserom:
mkdir -p $(BINDIR)
mkrom $(BINDIR)kernel.rom $(LENGTH) /dev/null:0x00

$(OUTDIR)$(PLATFORM)/00.bin: src/00/*.asm include/constants.asm src/00/jumptable.config
@mkdir -p $(BINDIR)
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/00/" --symbols $(BINDIR)00.sym --listing $(BINDIR)00.list src/00/base.asm $(BINDIR)00.bin
patchrom src/00/jumptable.config $(BINDIR)kernel.rom 00 < $(BINDIR)00.sym > $(BINDIR)00.inc

$(OUTDIR)$(PLATFORM)/01.bin: $(OUTDIR)$(PLATFORM)/00.bin src/01/*.asm include/constants.asm src/01/jumptable.config
$(OUTDIR)$(PLATFORM)/%.bin: src/%/*.asm include/constants.asm src/%/jumptable.config
@mkdir -p $(BINDIR)
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/01/" --symbols $(BINDIR)01.sym --listing $(BINDIR)01.list src/01/base.asm $(BINDIR)01.bin
patchrom src/01/jumptable.config $(BINDIR)kernel.rom 01 < $(BINDIR)01.sym > $(BINDIR)01.inc

$(OUTDIR)$(PLATFORM)/02.bin: $(OUTDIR)$(PLATFORM)/00.bin src/02/*.asm include/constants.asm src/02/jumptable.config
@mkdir -p $(BINDIR)
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/02/" --symbols $(BINDIR)02.sym --listing $(BINDIR)02.list src/02/base.asm $(BINDIR)02.bin
patchrom src/02/jumptable.config $(BINDIR)kernel.rom 02 < $(BINDIR)02.sym > $(BINDIR)02.inc
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/$*/" --symbols $(BINDIR)$*.sym --listing $(BINDIR)$*.list src/$*/base.asm -o $(BINDIR)$*.bin
patchrom src/$*/jumptable.config $(BINDIR)kernel.rom $* < $(BINDIR)$*.sym > $(BINDIR)$*.inc

$(OUTDIR)$(PLATFORM)/privileged.bin: src/privileged/*.asm include/constants.asm $(OUTDIR)$(PLATFORM)/00.bin
@mkdir -p $(BINDIR)
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/privileged/" --listing $(BINDIR)priviledged.list src/privileged/base.asm $(BINDIR)privileged.bin
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/privileged/" --listing $(BINDIR)priviledged.list src/privileged/base.asm -o $(BINDIR)privileged.bin

$(OUTDIR)$(PLATFORM)/boot.bin: src/boot/*.asm include/constants.asm
@mkdir -p $(BINDIR)
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/boot/" --listing $(BINDIR)boot.list src/boot/base.asm $(BINDIR)boot.bin
$(AS) $(ASFLAGS) $(DEFINES) --include "$(INCLUDE);src/boot/" --listing $(BINDIR)boot.list src/boot/base.asm -o $(BINDIR)boot.bin

clean:
rm -rf $(OUTDIR)
39 changes: 39 additions & 0 deletions mkfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PLATFORM=TI73
TAG=0.6.12
AS=knightos/scas

OUTDIR=bin/$PLATFORM
ASFLAGS=-D$PLATFORM -DKERNEL_VERSION=$TAG -I include/ -I $OUTDIR/

LENGTH=`{switch($PLATFORM){case TI84pCSE; echo 400000; case *pSE; echo 200000; case TI84p; echo 100000; case * ; echo 80000}}
BOOT=`{echo 'ibase=16;obase=10;'^$LENGTH^'-4000'|bc}
PRIV=`{echo 'ibase=16;obase=10;'^$LENGTH^'-10000'|bc}

$OUTDIR/kernel.inc: include/kernel.inc include/defines.inc include/kernelmem.inc $OUTDIR/00.inc $OUTDIR/01.inc $OUTDIR/02.inc
cat $prereq > $target

kernel:V: $OUTDIR/00.inc $OUTDIR/02.inc $OUTDIR/01.inc $OUTDIR/kernel.inc

$OUTDIR/kernel.rom: $OUTDIR/00.bin $OUTDIR/01.bin $OUTDIR/02.bin $OUTDIR/boot.bin $OUTDIR/privileged.bin
knightos/mkrom $OUTDIR/kernel.rom 0x$LENGTH $OUTDIR/00.bin:0x00 $OUTDIR/01.bin:0x4000 $OUTDIR/02.bin:0x8000 $OUTDIR/boot.bin:0x$BOOT $OUTDIR/privileged.bin:0x$PRIV

$OUTDIR/01.bin: $OUTDIR/00.bin
$OUTDIR/02.bin: $OUTDIR/00.bin
$OUTDIR/boot.bin: $OUTDIR/00.bin
$OUTDIR/privileged.bin: $OUTDIR/00.bin

00_SOURCES:V:src/00/base.asm src/00/boot.asm src/00/concurrency.asm src/00/crc.asm src/00/display-color.asm src/00/display.asm src/00/filestreams.asm src/00/filesystem.asm src/00/flash.asm src/00/header.asm src/00/interrupt.asm src/00/jumptable.config src/00/keyboard.asm src/00/libraries.asm src/00/link.asm src/00/locks.asm src/00/math.asm src/00/memory.asm src/00/panic.asm src/00/random.asm src/00/restarts.asm src/00/signals.asm src/00/strings.asm src/00/thread.asm src/00/util.asm
01_SOURCES:V:src/01/base.asm src/01/font.asm src/01/jumptable.config src/01/text.asm
02_SOURCES:V:src/02/base.asm src/02/compression.asm src/02/crypto.asm src/02/fp-math.asm src/02/graphics.asm src/02/jumptable.config src/02/sort.asm src/02/strings.asm src/02/time.asm
boot_SOURCES:V:src/boot/base.asm
privileged_SOURCES:V:src/privileged/base.asm

$OUTDIR/%.inc: $OUTDIR/%.bin $OUTDIR/kernel.rom
knightos/patchrom src/$stem/jumptable.config $OUTDIR/kernel.rom $stem < $OUTDIR/$stem.sym > $OUTDIR/$stem.inc

$OUTDIR/%.bin:D:%_SOURCES include/constants.asm
mkdir -p $OUTDIR
$AS $ASFLAGS -I src/$stem/ --symbols $OUTDIR/$stem.sym --listing $OUTDIR/$stem.list src/$stem/base.asm -o $OUTDIR/$stem.bin

clean:V:
rm -r $OUTDIR
3 changes: 1 addition & 2 deletions src/00/header.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ rlcall:
; 0x0056
.db 0xFF, 0xA5, 0xFF
.fill 0x64-$
.exec git describe --dirty=+ ; Version string
.db 0
.asciiz "KERNEL_VERSION"
2 changes: 1 addition & 1 deletion src/00/locks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ hasUSBLock:
push hl
push af
call getCurrentThreadId
ld hl, hwLockUsb
ld hl, hwLockUSB
cp (hl)
pop hl
ld a, h
Expand Down
2 changes: 1 addition & 1 deletion src/00/random.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ getRandom:
add hl, hl \ rl c \ rl b
ld (random_seed+6), bc
sbc a, a
and %11000101
and 0b11000101
xor l
ld l, a
ld (random_seed+4), hl
Expand Down
14 changes: 7 additions & 7 deletions src/02/crypto.asm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sha1Init:
.defaultMemblock:

; Holds the completed hash.
sha1_hash .equ $ - .defaultMemblock
.equ sha1_hash, $ - .defaultMemblock
.db 0x67,0x45,0x23,0x01
.db 0xEF,0xCD,0xAB,0x89
.db 0x98,0xBA,0xDC,0xFE
Expand Down Expand Up @@ -107,13 +107,13 @@ sha1Pad_noPush:
; append the bit '1' to the message
; append 0 <= k < 512 bits '0', so that the resulting message length (in bits)
; is congruent to 448 = -64 (mod 512)
ld a, $80
ld a, 0x80
.zero:
call sha1AddByte_noLength
ld a, (ix + sha1_block_front_ptr)
add a, 56
cp (ix + sha1_block_ptr)
ld a, $00
ld a, 0x00
jr nz, .zero
; append length of message (before padding), in bits, as 64-bit big-endian integer
push ix \ pop hl
Expand Down Expand Up @@ -223,10 +223,10 @@ sha1ProcessBlock:
dec hl
ld (ix + sha1_block_ptr), l
ld (ix + sha1_block_ptr + 1), h
ld hl, sha1Operation_mux \ call sha1Do20Rounds \ .db $5A,$82,$79,$99
ld hl, sha1Operation_xor \ call sha1Do20Rounds \ .db $6E,$D9,$EB,$A1
ld hl, sha1Operation_maj \ call sha1Do20Rounds \ .db $8F,$1B,$BC,$DC
ld hl, sha1Operation_xor \ call sha1Do20Rounds \ .db $CA,$62,$C1,$D6
ld hl, sha1Operation_mux \ call sha1Do20Rounds \ .db 0x5A,0x82,0x79,0x99
ld hl, sha1Operation_xor \ call sha1Do20Rounds \ .db 0x6E,0xD9,0xEB,0xA1
ld hl, sha1Operation_maj \ call sha1Do20Rounds \ .db 0x8F,0x1B,0xBC,0xDC
ld hl, sha1Operation_xor \ call sha1Do20Rounds \ .db 0xCA,0x62,0xC1,0xD6

; Add this chunk's hash to result so far
; h0 += a
Expand Down
2 changes: 1 addition & 1 deletion src/boot/base.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "constants.asm"
; Dummy boot page to get emulators to boot the OS
jr _
.fill 0x0F - $
.block 0x0F - $
.db "Emulated", 0
_:
in a, (PORT_FLASHRAMSIZE)
Expand Down