mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-09 04:22:04 -04:00
Prepare new programs
This commit is contained in:
parent
bf52b10ac8
commit
96083e7559
10
Makefile
10
Makefile
@ -20,6 +20,12 @@ programs/hello/a.out: force_look
|
||||
programs/long/a.out: force_look
|
||||
cd programs/long; ${MAKE} a.out
|
||||
|
||||
programs/longone/a.out: force_look
|
||||
cd programs/longone; ${MAKE} a.out
|
||||
|
||||
programs/longtwo/a.out: force_look
|
||||
cd programs/longtwo; ${MAKE} a.out
|
||||
|
||||
programs/loop/a.out: force_look
|
||||
cd programs/loop; ${MAKE} a.out
|
||||
|
||||
@ -27,7 +33,7 @@ hdd.img:
|
||||
dd if=/dev/zero of=hdd.img bs=516096c count=1000
|
||||
(echo n; echo p; echo 1; echo ""; echo ""; echo t; echo c; echo a; echo 1; echo w;) | sudo fdisk -u -C1000 -S63 -H16 hdd.img
|
||||
|
||||
thor.flp: hdd.img bootloader/stage1.bin bootloader/stage2.bin kernel/kernel.bin programs/one/a.out programs/hello/a.out programs/long/a.out programs/loop/a.out
|
||||
thor.flp: hdd.img bootloader/stage1.bin bootloader/stage2.bin kernel/kernel.bin programs/one/a.out programs/hello/a.out programs/long/a.out programs/loop/a.out programs/longone/a.out programs/longtwo/a.out
|
||||
mkdir -p mnt/fake/
|
||||
dd if=bootloader/stage1.bin of=hdd.img conv=notrunc
|
||||
dd if=bootloader/stage2.bin of=hdd.img seek=1 conv=notrunc
|
||||
@ -38,6 +44,8 @@ thor.flp: hdd.img bootloader/stage1.bin bootloader/stage2.bin kernel/kernel.bin
|
||||
sudo /bin/cp programs/one/a.out mnt/fake/one
|
||||
sudo /bin/cp programs/hello/a.out mnt/fake/hello
|
||||
sudo /bin/cp programs/long/a.out mnt/fake/long
|
||||
sudo /bin/cp programs/longone/a.out mnt/fake/longone
|
||||
sudo /bin/cp programs/longtwo/a.out mnt/fake/longtwo
|
||||
sudo /bin/cp programs/loop/a.out mnt/fake/loop
|
||||
sleep 0.1
|
||||
sudo /bin/umount mnt/fake/
|
||||
|
15
programs/longone/Makefile
Normal file
15
programs/longone/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
.PHONY: default clean
|
||||
|
||||
default: a.out
|
||||
|
||||
include ../../cpp.mk
|
||||
|
||||
%.cpp.o: src/%.cpp
|
||||
$(CC) $(PROGRAM_FLAGS) $(CPP_FLAGS_64) $(WARNING_FLAGS) -c $< -o $@
|
||||
|
||||
a.out: main.cpp.o
|
||||
$(CC) $(PROGRAM_LINK_FLAGS) $(CPP_FLAGS_64) -o a.out main.cpp.o
|
||||
|
||||
clean:
|
||||
rm *.cpp.o
|
||||
rm -rf a.out
|
30
programs/longone/src/main.cpp
Normal file
30
programs/longone/src/main.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013-2014.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include <print.hpp>
|
||||
#include <system.hpp>
|
||||
|
||||
volatile uint64_t current = 45;
|
||||
|
||||
uint64_t fibonacci_slow(uint64_t s){
|
||||
if(s == 1 || s == 2){
|
||||
return current;
|
||||
}
|
||||
|
||||
return fibonacci_slow(s - 1) + fibonacci_slow(s - 2);
|
||||
}
|
||||
|
||||
auto message = "I'm one";
|
||||
|
||||
int main(){
|
||||
while(true){
|
||||
fibonacci_slow(current);
|
||||
print_line(message);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
15
programs/longtwo/Makefile
Normal file
15
programs/longtwo/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
.PHONY: default clean
|
||||
|
||||
default: a.out
|
||||
|
||||
include ../../cpp.mk
|
||||
|
||||
%.cpp.o: src/%.cpp
|
||||
$(CC) $(PROGRAM_FLAGS) $(CPP_FLAGS_64) $(WARNING_FLAGS) -c $< -o $@
|
||||
|
||||
a.out: main.cpp.o
|
||||
$(CC) $(PROGRAM_LINK_FLAGS) $(CPP_FLAGS_64) -o a.out main.cpp.o
|
||||
|
||||
clean:
|
||||
rm *.cpp.o
|
||||
rm -rf a.out
|
30
programs/longtwo/src/main.cpp
Normal file
30
programs/longtwo/src/main.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013-2014.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include <print.hpp>
|
||||
#include <system.hpp>
|
||||
|
||||
volatile uint64_t current = 45;
|
||||
|
||||
uint64_t fibonacci_slow(uint64_t s){
|
||||
if(s == 1 || s == 2){
|
||||
return current;
|
||||
}
|
||||
|
||||
return fibonacci_slow(s - 1) + fibonacci_slow(s - 2);
|
||||
}
|
||||
|
||||
auto message = "I'm two";
|
||||
|
||||
int main(){
|
||||
while(true){
|
||||
fibonacci_slow(current);
|
||||
print_line(message);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user