Did some stuff with partitions

added a floppy build script for freebsd
This commit is contained in:
Morten Delenk 2016-07-24 21:40:17 +02:00
parent d85ee2dee1
commit 166e49a100
15 changed files with 421 additions and 89 deletions

8
err Normal file
View file

@ -0,0 +1,8 @@
xz: Filter chain: --lzma2=dict=8MiB,lc=3,lp=0,pb=2,mode=normal,nice=273,mf=bt4,depth=512
xz: 94 MiB of memory is required. The limiter is disabled.
xz: Decompression will need 9 MiB of memory.
test.elf: 1,684 B / 14.5 KiB = 0.113
xz: Filter chain: --lzma2=dict=8MiB,lc=3,lp=0,pb=2,mode=normal,nice=273,mf=bt4,depth=512
xz: 94 MiB of memory is required. The limiter is disabled.
xz: Decompression will need 9 MiB of memory.
mtgos.fnt: 578.4 KiB / 2,122.7 KiB = 0.272

View file

@ -0,0 +1,50 @@
#include <partitions.hpp>
#include <base.hpp>
#include <blockdev.hpp>
namespace MBR {
struct PartEntry {
char status;
uint8_t CHS_start[3];
char partitionType;
uint8_t CHS_end[3];
uint32_t start;
uint32_t size;
}__attribute__((packed));
struct Mbr {
uint8_t bootstrap[446];
PartEntry entries[4];
short bootSignature;
}__attribute__((packed));
MBR::MBR(uint32_t drive_id):Partitions(drive_id) {
Mbr mbr;
MTGosHAL::disk.readSector(drive_id,0,(uint8_t*)&mbr);
for(int i=0;i<4;i++) {
if(mbr.entries[i].status&0x7F)
break;
count++;
beg[i]=mbr.entries[i].start;
end[i]=beg[i]+mbr.entries[i].size;
}
}
auto MBR::operator=(MBR &o) -> MBR&{
for(int i=0;i<4;i++) {
this->beg[i]=o.beg[i];
this->end[i]=o.end[i];
}
Partitions::operator=(o);
return *this;
}
auto MBR::getPartCount() -> int {
return count;
}
auto MBR::getPartBeg(int part) -> uint64_t {
if(part>=count)
return 0xFFFFFFFFFFFFFFFFull;
return beg[part];
}
auto MBR::getPartEnd(int part) -> uint64_t {
if(part>=count)
return 0xFFFFFFFFFFFFFFFFull;
return end[part];
}
}

View file

@ -0,0 +1,11 @@
/*#include <filesystem.hpp>
File::File(Filesystem &fs, String fname): fs(fs), fname(fname) {
size=getFileSize(fname);
};
auto Fileread(uint64_t offset, uint64_t length) -> uint8_t*; {
uint8_t *buf=new uint8_t[length];
if(offset+length>size)
return nullptr;
fs.readFile(fname, offset, offset+length)
}*/

View file

@ -0,0 +1,30 @@
#pragma once
#include <string.hpp>
#include <partitions.hpp>
class Filesystem {
protected:
Partitions parts;
int part;
virtual auto readSector(uint64_t num, uint8_t* buf) -> void = 0;
virtual auto readFile(String &name, uint64_t start, uint64_t end, uint8_t buf) -> void = 0;
virtual auto getFileSize(String &name) -> uint64_t = 0;
public:
friend class File;
friend class Directory;
Filesystem(Partitions &parts, int part): part(part) {
this->parts=parts;
}
virtual auto op(String directory) -> Directory& = 0;
virtual auto openFile(String file) -> File& = 0;
};
class File {
private:
String name;
Filesystem &fs;
uint64_t size;
File() {}
public:
File(Filesystem &fs, String fname)
auto read(uint64_t offset, uint64_t length) -> uint8_t*;
}

View file

@ -0,0 +1,60 @@
#pragma once
#include <stdint.h>
class Partitions {
protected:
uint32_t drive_id;
public:
Partitions(uint32_t drive_id):drive_id(drive_id) {};
virtual auto operator=(Partitions &o) -> Partitions& {this->drive_id=o.drive_id;return *this;}
virtual auto getPartCount() -> int = 0;
virtual auto getPartBeg(int) -> uint64_t = 0;
virtual auto getPartEnd(int) -> uint64_t = 0;
};
namespace MBR {
class MBR: public Partitions {
private:
int count;
uint64_t beg[4], end[4];
public:
MBR(uint32_t drive_id);
virtual auto operator=(MBR &o) -> MBR&;
virtual auto getPartCount() -> int;
virtual auto getPartBeg(int) -> uint64_t;
virtual auto getPartEnd(int) -> uint64_t;
};
class ModernMBR: public MBR {
private:
char seconds;
char minutes;
char hours;
uint32_t sig;
bool copyProtected;
public:
ModernMBR(uint32_t drive_id);
virtual auto getDiskSec() -> char;
virtual auto getDiskMins() -> char;
virtual auto getDiskHrs() -> char;
virtual auto getDiskSignature() -> char;
virtual auto isCopyProtected() -> bool;
};
class AST_MBR: public MBR {
private:
int count;
uint64_t beg[4], end[4];
public:
AST_MBR(uint32_t drive_id);
virtual auto getPartCount() -> int;
virtual auto getPartBeg(int) -> uint64_t;
virtual auto getPartEnd(int) -> uint64_t;
};
class DiskMGR: public MBR {
private:
int count;
uint64_t beg[12], end[12];
public:
DiskMGR(uint32_t drive_id);
virtual auto getPartCount() -> int;
virtual auto getPartBeg(int) -> uint64_t;
virtual auto getPartEnd(int) -> uint64_t;
};
}

View file

@ -1,3 +1,4 @@
#pragma once
#include <stdint.h> #include <stdint.h>
#include <pmm.hpp> #include <pmm.hpp>
class String { class String {
@ -12,5 +13,6 @@ public:
auto operator=(String &) -> String &; auto operator=(String &) -> String &;
auto size() -> size_t; auto size() -> size_t;
auto operator[](int) -> uint32_t; auto operator[](int) -> uint32_t;
operator char*();
}; };
String &operator""_s(const char *str, size_t len); String &operator""_s(const char *str, size_t len);

View file

@ -7,6 +7,7 @@
#include <blockdev.hpp> #include <blockdev.hpp>
#include <elf.hpp> #include <elf.hpp>
#include <pmm.hpp> #include <pmm.hpp>
#include <partitions.hpp>
void * operator new (size_t, void * p) { return p ; } void * operator new (size_t, void * p) { return p ; }
void * operator new[] (size_t, void * p) { return p ; } void * operator new[] (size_t, void * p) { return p ; }
void operator delete (void *, void *) { } void operator delete (void *, void *) { }
@ -42,4 +43,10 @@ void main(void ** files, MTGosHAL::Serial &debug, MTGosHAL::PMM &mm, MTGosHAL::S
continue; continue;
tasks.initTask(start); tasks.initTask(start);
} }
out << "checking ata0 partitions...\n";
MBR::MBR part(disk.getDriveNumByName("ATA0m"));
out << "Partition 1: beg=" << (int32_t) part.getPartBeg(0) << " end=" << (int32_t)part.getPartEnd(0) << "\n";
out << "Partition 2: beg=" << (int32_t)part.getPartBeg(1) << " end=" << (int32_t)part.getPartEnd(1) << "\n";
out << "Partition 3: beg=" << (int32_t)part.getPartBeg(2) << " end=" << (int32_t)part.getPartEnd(2) << "\n";
out << "Partition 4: beg=" << (int32_t)part.getPartBeg(3) << " end=" << (int32_t)part.getPartEnd(3) << "\n";
} }

View file

@ -78,3 +78,53 @@ auto String::operator[](int i) -> uint32_t {
String &operator""_s(const char *str, size_t len) { String &operator""_s(const char *str, size_t len) {
return *(new String(str)); return *(new String(str));
} }
String::operator char*() {
int strLen=1;
for(uint32_t i=0;i<length;i++) {
if(arr[i]<0x80)
strLen++;
else if(arr[i]<0x800)
strLen+=2;
else if(arr[i]<0x10000)
strLen+=3;
else if(arr[i]<0x200000)
strLen+=4;
else if(arr[i]<0x4000000)
strLen+=5;
else
strLen+=6;
}
uint8_t* str=new uint8_t[strLen];
int p=0;
for(uint32_t i=0;i<length;i++) {
if(arr[i]<0x80) {
str[p++]=(uint8_t)arr[i];
} else if(arr[i]<0x800) {
str[p++]=0xC0u|(uint8_t)(arr[i]>>6);
str[p++]=(uint8_t)((arr[i]&0x3F)|0x80);
} else if(arr[i]<0x1000) {
str[p++]=0xE0u|(uint8_t)(arr[i]>>12);
str[p++]=(uint8_t)(((arr[i]>>6)&0x3F)|0x80);
str[p++]=(uint8_t)((arr[i]&0x3F)|0x80);
} else if(arr[i]<0x20000) {
str[p++]=0xF0u|(uint8_t)(arr[i]>>18);
str[p++]=(uint8_t)(((arr[i]>>12)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>6)&0x3F)|0x80);
str[p++]=(uint8_t)((arr[i]&0x3F)|0x80);
} else if(arr[i]<0x400000) {
str[p++]=0xF8u|(uint8_t)(arr[i]>>24);
str[p++]=(uint8_t)(((arr[i]>>18)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>12)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>6)&0x3F)|0x80);
str[p++]=(uint8_t)((arr[i]&0x3F)|0x80);
} else {
str[p++]=0xFCu|(uint8_t)(arr[i]>>30);
str[p++]=(uint8_t)(((arr[i]>>24)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>18)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>12)&0x3F)|0x80);
str[p++]=(uint8_t)(((arr[i]>>6)&0x3F)|0x80);
str[p++]=(uint8_t)((arr[i]&0x3F)|0x80);
}
}
return (char*)str;
}

View file

@ -7,12 +7,14 @@ ScreenOut::ScreenOut(bool err): err(err) {
} }
auto ScreenOut::operator<<(char *text) -> ScreenOut & { auto ScreenOut::operator<<(char *text) -> ScreenOut & {
String *tmp = new String(text);
if(!text) if(!text)
return *this; return *this;
if(err) if(err)
MTGosHAL::err << String(text); MTGosHAL::err << *tmp;
else else
MTGosHAL::out << String(text); MTGosHAL::out << *tmp;
delete tmp;
return *this; return *this;
} }
auto ScreenOut::clrscr() -> ScreenOut & { auto ScreenOut::clrscr() -> ScreenOut & {

Binary file not shown.

69
log Normal file
View file

@ -0,0 +1,69 @@
Cleaning build...
gmake -C kernel clean
gmake[1]: Entering directory '/usr/home/morten/sources/MTGos/kernel'
gmake -C hal clean
gmake[2]: Entering directory '/usr/home/morten/sources/MTGos/kernel/hal'
rm -rf hal.o
gmake -C x86 clean
gmake[3]: Entering directory '/usr/home/morten/sources/MTGos/kernel/hal/x86'
rm -rf ./init/idt.o ./init/Multitasking.o ./init/gdt.o ./init/init.o ./asm/snippets.o ./mm/pmm2.o ./mm/pmm.o ./mm/vmm3.o ./mm/pmm3.o ./io/keyboard.o ./io/textDISP.o ./io/serial.o ./io/output.o ./boot/boot.o ./blk/BlockDevice.o ./blk/ide.o
gmake[3]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/hal/x86'
gmake[2]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/hal'
gmake -C kernel clean
gmake[2]: Entering directory '/usr/home/morten/sources/MTGos/kernel/kernel'
rm -rf ./stdstring.o ./Multitasking.o ./filesystem.o ./init.o ./disk/partitions.o ./elf.o ./syscall.o ./string.o
gmake[2]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/kernel'
gmake[1]: Leaving directory '/usr/home/morten/sources/MTGos/kernel'
rm -rf mtgos
find . -name '*.o' -delete
Building...
gmake -C kernel
gmake[1]: Entering directory '/usr/home/morten/sources/MTGos/kernel'
gmake -C hal
gmake[2]: Entering directory '/usr/home/morten/sources/MTGos/kernel/hal'
gmake -C x86
gmake[3]: Entering directory '/usr/home/morten/sources/MTGos/kernel/hal/x86'
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o init/idt.o init/idt.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o init/Multitasking.o init/Multitasking.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o init/gdt.o init/gdt.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o init/init.o init/init.cpp
i686-elf-gcc -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../kernel/c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fpie -c -o asm/snippets.o asm/snippets.S
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o mm/pmm2.o mm/pmm2.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o mm/pmm.o mm/pmm.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o mm/vmm3.o mm/vmm3.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o mm/pmm3.o mm/pmm3.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o io/keyboard.o io/keyboard.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o io/textDISP.o io/textDISP.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o io/serial.o io/serial.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o io/output.o io/output.cpp
i686-elf-gcc -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../kernel/c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fpie -c -o boot/boot.o boot/boot.S
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o blk/BlockDevice.o blk/BlockDevice.cpp
i686-elf-g++ -g3 -DDEBUG -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../kernel/c_include -I../../kernel/include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fno-pie -Wno-reorder -c -o blk/ide.o blk/ide.cpp
gmake[3]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/hal/x86'
ar rcs ../libhal.a x86/init/idt.o x86/init/Multitasking.o x86/init/gdt.o x86/init/init.o x86/asm/snippets.o x86/mm/pmm2.o x86/mm/pmm.o x86/mm/vmm3.o x86/mm/pmm3.o x86/io/keyboard.o x86/io/textDISP.o x86/io/serial.o x86/io/output.o x86/boot/boot.o x86/blk/BlockDevice.o x86/blk/ide.o
gmake[2]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/hal'
gmake -C kernel
gmake[2]: Entering directory '/usr/home/morten/sources/MTGos/kernel/kernel'
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o stdstring.o stdstring.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o Multitasking.o Multitasking.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o filesystem.o filesystem.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o init.o init.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o disk/partitions.o disk/partitions.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o elf.o elf.cpp
i686-elf-g++ -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o syscall.o syscall.cpp
i686-elf-gcc -g3 -DDEBUG -Wall -fno-stack-protector -nostdinc -Ic_include/ -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fpie -c -o string.o string.c
gmake[2]: Leaving directory '/usr/home/morten/sources/MTGos/kernel/kernel'
i686-elf-g++ -nostdlib -nodefaultlibs -nostdlib -fno-builtin -T kernel-x86.ld -z max-page-size=0x1000 -o mtgos kernel/stdstring.o kernel/Multitasking.o kernel/filesystem.o kernel/init.o kernel/disk/partitions.o kernel/elf.o kernel/syscall.o kernel/string.o libhal.a -lgcc
gmake[1]: Leaving directory '/usr/home/morten/sources/MTGos/kernel'
mv kernel/mtgos mtgos
gmake -C user
gmake[1]: Entering directory '/usr/home/morten/sources/MTGos/user'
i686-elf-g++ -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o mtgos.o mtgos.cpp
i686-elf-g++ -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie -c -o test.o test.cpp
i686-elf-gcc -c -o x86/syscall.o x86/syscall.S
i686-elf-ld -Ttest-x86.ld -L/opt/lib/gcc/i686-elf/6.1.0/ -o test.elf mtgos.o test.o x86/syscall.o -lgcc
gmake[1]: Leaving directory '/usr/home/morten/sources/MTGos/user'
mv user/*.elf .
stripping
Compressing...
How many megabytes should the image be?

54
makeimage.sh Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
unamestr=`uname`
if [[ "$unamestr" != 'FreeBSD' ]]; then
echo "This script only works on FreeBSD"
exit -1
fi
echo "Cleaning build..."
gmake clean
echo "Building..."
gmake
echo "stripping"
strip --strip-debug mtgos
strip --strip-debug test.elf
echo "Compressing..."
xz -vv9e mtgos
xz -vv9e test.elf
xz -vv9ek mtgos.fnt
echo "How many kilobytes should the image be?"
read length
echo "OK. Creating image..."
dd if=/dev/zero of=mtgos.img bs=1K count=$length
echo "Enter your password for the remaining part of the executable."
sudo id
echo "Mounting image..."
dev=$(sudo mdconfig -a -t vnode mtgos.img)
echo "Partitioning image..."
sudo gpart create -s MBR $dev
sudo gpart add -t freebsd -b 512 ${dev}
echo "Formatting partition..."
sudo mkfs.ext2 /dev/${dev}s1
echo "Mounting image..."
mkdir mount
sudo mount -t ext2fs /dev/${dev}s1 mount
echo "Installing grub... (May take some time)"
sudo grub-install --target=i386-pc --boot-directory=mount /dev/$dev --compress=xz --install-modules="normal part_msdos ext2 multiboot biosdisk xzio" --modules="normal part_msdos ext2 multiboot biosdisk xzio" --locales="" --force
echo "Copying files..."
sudo mv mtgos.xz mtgos.fnt.xz test.elf.xz mount
echo "Creating grub.cfg"
cat > grub.cfg << "EOF"
menuentry "MTGos" {
multiboot /mtgos.xz
module /test.elf.xz
module /mtgos.fnt.xz
}
EOF
sudo mv grub.cfg mount/grub
echo "Unmounting everything"
sync
sleep 0.5
sudo umount mount
sudo mdconfig -d -u ${dev#md}
echo "Finalizing..."
rm -rf mount
echo "Done!"

BIN
test.elf

Binary file not shown.

View file

@ -10,17 +10,6 @@ void main()
{ {
char arr[4]="123"; char arr[4]="123";
ScreenOut out=ScreenOut(false); ScreenOut out=ScreenOut(false);
int i; out << "Hallo! Ich bin ein Testprogramm, welches sämtliche Funktionen von MTGos, die vom Usermode zugreifbar sind, testet.\nHello! This is a test program which tests every function from MTGos that is accessable from userspace.\n";
out.setColor(BGColor::BLUE, FGColor::YELLOW); out << "Bonjour! Je suis une programme de test. Je teste toute la fonction de MTGos, que est accessible pour le mode d'utilisateur.\nこんにちは。私はテストのプログラムです。全てのアクセス可能な関数は試します。\näöüßÄÖÜẞ\n";
for(;;) {
long double a;
long double b=a;
out << a;
a+=0.5;
if(a!=b+0.5)
out << " ";
else
out << "=";
out << a;
}
} }