Reorganized source tree. Started using autotools.
This commit is contained in:
23
.gitignore
vendored
23
.gitignore
vendored
@@ -1,7 +1,26 @@
|
|||||||
quark.iso
|
quark.iso
|
||||||
src/quark-kernel
|
quark-kernel
|
||||||
src/interrupts/libinterrupts.a
|
|
||||||
|
autom4te.cache/
|
||||||
|
.deps
|
||||||
|
aclocal.m4
|
||||||
|
ar-lib
|
||||||
|
compile
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
install-sh
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
missing
|
||||||
|
stamp-h1
|
||||||
|
*.Po
|
||||||
|
*.a
|
||||||
*.o
|
*.o
|
||||||
*~
|
*~
|
||||||
|
|
||||||
rootfs/
|
rootfs/
|
||||||
test/
|
test/
|
||||||
14
Makefile
14
Makefile
@@ -1,14 +0,0 @@
|
|||||||
.PHONY: all
|
|
||||||
all: quark.iso
|
|
||||||
|
|
||||||
quark.iso: src/quark-kernel
|
|
||||||
cp src/quark-kernel rootfs/apps
|
|
||||||
grub-mkrescue -o $@ rootfs
|
|
||||||
|
|
||||||
src/quark-kernel:
|
|
||||||
make -C src
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
make -C src clean
|
|
||||||
rm -f quark.iso
|
|
||||||
1
Makefile.am
Normal file
1
Makefile.am
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SUBDIRS = src
|
||||||
32
configure.ac
Normal file
32
configure.ac
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- Autoconf -*-
|
||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
|
AC_PREREQ([2.69])
|
||||||
|
AC_INIT([quark-kernel], [pre-alpha])
|
||||||
|
AM_INIT_AUTOMAKE([-Wall foreign])
|
||||||
|
AC_CONFIG_SRCDIR([src/tty.cpp])
|
||||||
|
AC_CONFIG_HEADERS([src/config.h])
|
||||||
|
|
||||||
|
# Checks for programs.
|
||||||
|
AC_PROG_CXX
|
||||||
|
AC_PROG_CC
|
||||||
|
AM_PROG_AS
|
||||||
|
AM_PROG_AR
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
|
||||||
|
# Checks for header files.
|
||||||
|
AC_CHECK_HEADERS([stddef.h stdint.h])
|
||||||
|
|
||||||
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
AC_CHECK_HEADER_STDBOOL
|
||||||
|
AC_C_INLINE
|
||||||
|
AC_TYPE_SIZE_T
|
||||||
|
AC_TYPE_UINT16_T
|
||||||
|
AC_TYPE_UINT32_T
|
||||||
|
AC_TYPE_UINT64_T
|
||||||
|
AC_TYPE_UINT8_T
|
||||||
|
|
||||||
|
AM_CONDITIONAL([x86], [test $host = i686-elf])
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([Makefile src/Makefile src/mmgr/Makefile src/interrupts/Makefile])
|
||||||
|
AC_OUTPUT
|
||||||
18
src/Makefile
18
src/Makefile
@@ -1,18 +0,0 @@
|
|||||||
objs = addressspace.o tty.o buddyallocator.o math.o cstring.o pagetableentry.o multiboot2header.o systeminfo.o memorymap.o pio.o entry.o quarkkernel.o
|
|
||||||
|
|
||||||
CXX = i686-elf-g++
|
|
||||||
CC = i686-elf-gcc
|
|
||||||
|
|
||||||
CXXFLAGS = -ffreestanding -mgeneral-regs-only -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
|
||||||
LDFLAGS = -T linker.ld -lgcc -nostdlib
|
|
||||||
|
|
||||||
quark-kernel: $(objs) linker.ld interrupts/libinterrupts.a
|
|
||||||
$(CXX) -o $@ $(LDFLAGS) interrupts/libinterrupts.a $(objs)
|
|
||||||
|
|
||||||
interrupts/libinterrupts.a:
|
|
||||||
make -C interrupts CXX="$(CXX)" CC="$(CC)" CXXFLAGS="$(CXXFLAGS)"
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
make -C interrupts clean
|
|
||||||
rm -f $(objs) quark-kernel
|
|
||||||
8
src/Makefile.am
Normal file
8
src/Makefile.am
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
SUBDIRS = interrupts mmgr
|
||||||
|
noinst_PROGRAMS = quark-kernel
|
||||||
|
quark_kernel_SOURCES = quarkkernel.cpp tty.cpp systeminfo.cpp util.cpp entry.S pio.S multiboot2header.S
|
||||||
|
quark_kernel_LDADD = -lgcc mmgr/libmmgr.a interrupts/libinterrupts.a
|
||||||
|
quark_kernel_CPPFLAGS = -ffreestanding -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
||||||
|
quark_kernel_LDFLAGS = -T linker.ld -nostdlib
|
||||||
|
quark_kernel_DEPENDENCIES = linker.ld
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* cstring.h
|
|
||||||
*
|
|
||||||
* Created on: Jun 13, 2019
|
|
||||||
* Author: nathan
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SRC_CSTRING_H_
|
|
||||||
#define SRC_CSTRING_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
|
|
||||||
void* memcpy(void* destination, const void* source, size_t num);
|
|
||||||
|
|
||||||
void* memmove(void* destination, const void* source, size_t num);
|
|
||||||
|
|
||||||
int memcmp(const void* ptr1, const void* ptr2, size_t num);
|
|
||||||
|
|
||||||
void* memset (void* ptr, int value, size_t num);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SRC_CSTRING_H_ */
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
objs = x86/inthandlers.o x86/interruptdescriptor.o x86/idt.o x86/interrupts.o
|
|
||||||
archive = libinterrupts.a
|
|
||||||
|
|
||||||
$(archive): $(objs)
|
|
||||||
i686-elf-ar rcs $@ $^
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f $(archive) $(objs)
|
|
||||||
6
src/interrupts/Makefile.am
Normal file
6
src/interrupts/Makefile.am
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
noinst_LIBRARIES = libinterrupts.a
|
||||||
|
libinterrupts_a_CPPFLAGS = -ffreestanding -mgeneral-regs-only -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
||||||
|
|
||||||
|
if x86
|
||||||
|
libinterrupts_a_SOURCES = x86/interrupts.cpp x86/inthandlers.cpp x86/interruptdescriptor.cpp x86/idt.S
|
||||||
|
endif
|
||||||
27
src/math.cpp
27
src/math.cpp
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* math.cpp
|
|
||||||
*
|
|
||||||
* Created on: May 23, 2019
|
|
||||||
* Author: nathan
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
uint32_t ilog2(uint32_t n, bool roundUp)
|
|
||||||
{
|
|
||||||
uint32_t m = n;
|
|
||||||
uint32_t count = 0;
|
|
||||||
bool isPowerOfTwo = true;
|
|
||||||
while(m)
|
|
||||||
{
|
|
||||||
if((m & 1) == 1 && m > 1)
|
|
||||||
{
|
|
||||||
isPowerOfTwo = false;
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
m >>= 1;
|
|
||||||
}
|
|
||||||
return count - (isPowerOfTwo ? 1 : (roundUp ? 0 : 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
22
src/math.h
22
src/math.h
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* math.h
|
|
||||||
*
|
|
||||||
* Created on: May 23, 2019
|
|
||||||
* Author: nathan
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SRC_MATH_H_
|
|
||||||
#define SRC_MATH_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes the logarithm in base 2 of a given integer, returning an integer as
|
|
||||||
* the result. For n = -1, returns unsigned -1.
|
|
||||||
*
|
|
||||||
* @returns floor(log2(n)), where n > 0. Else unsigned -1.
|
|
||||||
*/
|
|
||||||
uint32_t ilog2(uint32_t n, bool roundUp = false);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_MATH_H_ */
|
|
||||||
7
src/mmgr/Makefile.am
Normal file
7
src/mmgr/Makefile.am
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
noinst_LIBRARIES = libmmgr.a
|
||||||
|
libmmgr_a_SOURCES = memorymap.cpp buddyallocator.cpp addressspace.cpp
|
||||||
|
libmmgr_a_CPPFLAGS = -ffreestanding -O0 -Wall -fno-exceptions -fno-rtti -ggdb
|
||||||
|
|
||||||
|
if x86
|
||||||
|
libmmgr_a_SOURCES += x86/pagetableentry.cpp
|
||||||
|
endif
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "memoryallocator.hpp"
|
#include "memoryallocator.hpp"
|
||||||
#include "pagetableentry.hpp"
|
#include "x86/pagetableentry.hpp"
|
||||||
#include "systypes.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
@@ -1,10 +1,26 @@
|
|||||||
#include "buddyallocator.hpp"
|
#include "buddyallocator.hpp"
|
||||||
#include "math.h"
|
#include "types.hpp"
|
||||||
#include "systypes.hpp"
|
|
||||||
#include "memorymap.hpp"
|
#include "memorymap.hpp"
|
||||||
|
|
||||||
#define roundUp(n, m) ((n % m == 0) ? n : (n + m - (n % m)))
|
#define roundUp(n, m) ((n % m == 0) ? n : (n + m - (n % m)))
|
||||||
|
|
||||||
|
uint32_t ilog2(uint32_t n, bool roundUp)
|
||||||
|
{
|
||||||
|
uint32_t m = n;
|
||||||
|
uint32_t count = 0;
|
||||||
|
bool isPowerOfTwo = true;
|
||||||
|
while(m)
|
||||||
|
{
|
||||||
|
if((m & 1) == 1 && m > 1)
|
||||||
|
{
|
||||||
|
isPowerOfTwo = false;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
m >>= 1;
|
||||||
|
}
|
||||||
|
return count - (isPowerOfTwo ? 1 : (roundUp ? 0 : 1));
|
||||||
|
}
|
||||||
|
|
||||||
kernel::BuddyAllocator::BuddyAllocator()
|
kernel::BuddyAllocator::BuddyAllocator()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#define __MEMORYALLOCATOR_H_
|
#define __MEMORYALLOCATOR_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "systypes.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
namespace kernel
|
namespace kernel
|
||||||
{
|
{
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "systypes.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
namespace kernel
|
namespace kernel
|
||||||
{
|
{
|
||||||
15
src/mmgr/types.hpp
Normal file
15
src/mmgr/types.hpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef MEM_TYPES_H
|
||||||
|
#define MEM_TYPES_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#if defined __i386__
|
||||||
|
typedef uint32_t physaddr_t;
|
||||||
|
#elif defined __amd64__
|
||||||
|
typedef uint64_t physaddr_t;
|
||||||
|
#else
|
||||||
|
typedef uint64_t physaddr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#define SRC_PAGETABLEENTRY_H_
|
#define SRC_PAGETABLEENTRY_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "systypes.hpp"
|
#include "../types.hpp"
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
@@ -3,22 +3,18 @@
|
|||||||
|
|
||||||
#include "systypes.hpp"
|
#include "systypes.hpp"
|
||||||
#include "systeminfo.hpp"
|
#include "systeminfo.hpp"
|
||||||
#include "memorymap.hpp"
|
#include "mmgr/memorymap.hpp"
|
||||||
#include "buddyallocator.hpp"
|
#include "mmgr/buddyallocator.hpp"
|
||||||
#include "addressspace.hpp"
|
#include "mmgr/addressspace.hpp"
|
||||||
#include "pio.hpp"
|
#include "pio.hpp"
|
||||||
#include "tty.h"
|
#include "tty.hpp"
|
||||||
|
#include "util.hpp"
|
||||||
|
|
||||||
using namespace kernel;
|
using namespace kernel;
|
||||||
|
|
||||||
extern SystemInfo system_info;
|
extern SystemInfo system_info;
|
||||||
extern MemoryMap::Region memory_map;
|
extern MemoryMap::Region memory_map;
|
||||||
|
|
||||||
extern "C" void __cxa_pure_virtual()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(char* cmdline)
|
void main(char* cmdline)
|
||||||
{
|
{
|
||||||
TTY tty((char*) 0xC00B8000);
|
TTY tty((char*) 0xC00B8000);
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
#ifndef SYSTYPES_H
|
#ifndef SYSTYPES_H
|
||||||
#define SYSTYPES_H
|
#define SYSTYPES_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "mmgr/types.hpp"
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
typedef uint32_t physaddr_t;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "tty.h"
|
#include "tty.hpp"
|
||||||
|
|
||||||
kernel::TTY::TTY(char* vga)
|
kernel::TTY::TTY(char* vga)
|
||||||
{
|
{
|
||||||
|
|||||||
16
src/cstring.cpp → src/util.cpp
Executable file → Normal file
16
src/cstring.cpp → src/util.cpp
Executable file → Normal file
@@ -1,13 +1,6 @@
|
|||||||
/*
|
|
||||||
* cstring.cpp
|
|
||||||
*
|
|
||||||
* Created on: Jun 13, 2019
|
|
||||||
* Author: nathan
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include "cstring.h"
|
#include "util.hpp"
|
||||||
|
|
||||||
void* memcpy(void* destination, const void* source, size_t num)
|
void* memcpy(void* destination, const void* source, size_t num)
|
||||||
{
|
{
|
||||||
@@ -82,4 +75,7 @@ void* memset (void* ptr, int value, size_t num)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __cxa_pure_virtual()
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
16
src/util.hpp
Normal file
16
src/util.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef UTIL_H
|
||||||
|
#define UTIL_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
extern "C" void __cxa_pure_virtual();
|
||||||
|
|
||||||
|
extern "C" void* memcpy(void* destination, const void* source, size_t num);
|
||||||
|
|
||||||
|
extern "C" void* memmove(void* destination, const void* source, size_t num);
|
||||||
|
|
||||||
|
extern "C" int memcmp(const void* ptr1, const void* ptr2, size_t num);
|
||||||
|
|
||||||
|
extern "C" void* memset(void* ptr, int value, size_t num);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user