Skip to content

Commit

Permalink
Solve #76 , and (#22 !)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanuel2 committed Dec 9, 2016
1 parent 931f45e commit 5b6163b
Show file tree
Hide file tree
Showing 24 changed files with 249 additions and 119 deletions.
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ INCDIRS := $(BUILDROOT)/include \
$(BUILDROOT)/include/apps \
$(BUILDROOT)/include/bin \
$(BUILDROOT)/include/libc \
$(BUILDROOT)/include/libc/string
$(BUILDROOT)/include/libc/string \
$(BUILDROOT)/arch/shared/x86

# Parameters
LDPARAMS := -melf_i386
CFLAGS := \
-m32 -std=c11 \
-O2 -g -Wall -Wextra -Wpedantic -Werror -g \
-Wno-error=missing-field-initializers -Wno-varargs \
-O0 -g -Wall -Wextra -Wpedantic -Werror -g \
-Wno-error=missing-field-initializers \
-Wno-unused-parameter -Wno-unused-but-set-parameter \
-nostdlib -ffreestanding $(patsubst %,-I%,$(INCDIRS))

Expand All @@ -111,7 +112,8 @@ libraries = \
libc/libc.a \
arch/$(ARCH)/libarch.a \
apps/libapps.a \
bin/libbin.a
bin/libbin.a \
arch/shared/$(ARCH_FAMILY)/libshared_arch.a
export libraries

# -----------------------------------------------
Expand Down Expand Up @@ -143,6 +145,8 @@ subdirs:
clean-subdirs:
(cd libc && $(MAKE) clean)
(cd arch && $(MAKE) clean)
(cd apps && $(MAKE) clean)
(cd bin && $(MAKE) clean)

.PHONY: subdirs clean-subdirs

Expand Down Expand Up @@ -198,10 +202,10 @@ debug_q:
-ex 'set radix 16' \

qemu_compile: $(BONEOS_BIN)
$(QEMU) -kernel $(BONEOS_BIN) -display sdl
$(QEMU) -kernel $(BONEOS_BIN) -display sdl -k en-us

qemu_iso: $(BONEOS_BIN) $(BONEOS_ISO)
$(QEMU) -cdrom $(BONEOS_ISO)
$(QEMU) -cdrom $(BONEOS_ISO) -k en-us

bochs: $(BONEOS_ISO)
$(BOCHS) -f bochsrc.bxrc -q
Expand Down
2 changes: 2 additions & 0 deletions arch/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
all:
(cd $(ARCH) && $(MAKE))
(cd shared/$(ARCH_FAMILY) && $(MAKE))

clean:
(cd $(ARCH) && $(MAKE) clean)
(cd shared/$(ARCH_FAMILY) && $(MAKE) clean)
12 changes: 12 additions & 0 deletions arch/amd64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BUILDROOT ?= ../..


CSRCS = \
init/main.c

cpu/interrupts/interrupts-asm.o: NASMFLAGS += -i cpu/interrupts/


LIBNAME := arch

include $(BUILDROOT)/library.mk
25 changes: 25 additions & 0 deletions arch/amd64/boot/boot.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
;
; This file is part of BoneOS.
;
; BoneOS is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.

; BoneOS is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
;
; @main_author : Amanuel Bogale
;
; @contributors:

; Amanuel Bogale <amanuel2> : start
;


; On Work
56 changes: 56 additions & 0 deletions arch/amd64/init/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
** This file is part of BoneOS.
**
** BoneOS is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** BoneOS is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/

#include <stdint.h>
#include <stddef.h>
#include <arch/shared/x86/misc/asm_util.h>


/*
* Calling all Global C Objects
* constructors , via attributes:
* @attribute __constructor__
* @attribute __deconstructor__
*/
typedef void (*constructor)();
extern constructor start_ctors;
extern constructor end_ctors;
extern void callConstructors()
{
for(constructor* i = &start_ctors;i != &end_ctors; i++)
(*i)();
}

/*
* @function kernelMain:
* Main function of the kernel,
* the function the GRUB bootloader
* calls when Loading the kernel.
*
*/
void kernelMain(multiboot_info_t* multiboot_structure,uint32_t magicnumber)
{
while(1)

}

3 changes: 3 additions & 0 deletions arch/amd64/link/linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
* On Work
*/
4 changes: 2 additions & 2 deletions arch/i386/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ CSRCS = \
cpu/interrupts/pic.c \
cpu/interrupts/idt.c \
cpu/interrupts/irq.c \
cpu/interrupts/isr.c \
cpu/cpu.c \
drv/video/video.c \
drv/video/$(VIDEO_DRIVER)/$(VIDEO_DRIVER_LOW).c \
drv/video/$(VIDEO_DRIVER)/$(VIDEO_DRIVER_MODE)/$(VIDEO_DRIVER_RES)/utils.c \
Expand All @@ -25,10 +27,8 @@ CSRCS = \
drv/video/$(VIDEO_DRIVER)/$(VIDEO_DRIVER_MODE)/$(VIDEO_DRIVER_RES)/term_scroll.c \
drv/video/$(VIDEO_DRIVER)/$(VIDEO_DRIVER_MODE)/vga_textmode.c \
drv/video/$(VIDEO_DRIVER)/$(VIDEO_DRIVER_MODE)/update_cursor.c \
misc/asm_util.c \
drv/pit/pit.c \
drv/ps2/kbd/kbd.c \
cpu/interrupts/isr.c \
drv/driver.c \
drv/ps2/kbd/scancodes.c \
drv/ps2/kbd/kbd_layouts/scancodes_usa.c \
Expand Down
43 changes: 43 additions & 0 deletions arch/i386/cpu/cpu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
** This file is part of BoneOS.
**
** BoneOS is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
** BoneOS is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Doug Gale
**
** @contributors:
** Doug Gale <doug65536> : start
**/

#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>

#include <cpu/gdt/gdt.h>
#include <cpu/interrupts/idt.h>
#include <cpu/interrupts/isr.h>
#define KERNEL_CALL
#include <cpu/interrupts/irq.h>
#undef KERNEL_CALL
#include <libc/string/string.h>

void init_cpu()
{
init_gdt();
init_idt();
init_isr();
init_irq();
}
12 changes: 6 additions & 6 deletions arch/i386/drv/pit/pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ volatile bool status_pit = STATUS_DRIVER_OK;
* Sends Operation Command Word
* to PIT.
*/
inline void send_pit_command(uint8_t cmd)
static void send_pit_command(uint8_t cmd)
{
outb8(I386_PIT_CONTROL_WORD_REG, cmd);
}
Expand All @@ -49,7 +49,7 @@ inline void send_pit_command(uint8_t cmd)
* Sends Messages to Counter
* 0 of PIT's Internal Registers.
*/
inline void send_msg_counter_0(uint8_t cmd)
static void send_msg_counter_0(uint8_t cmd)
{
outb8(I386_PIT_COUNTER_0_REG,cmd);
}
Expand All @@ -60,7 +60,7 @@ inline void send_msg_counter_0(uint8_t cmd)
* with the number of IRQ's per
* second specified.
*/
void pit_phase(int htz)
static void pit_phase(int htz)
{
//1.19MHz / htz
//dictates how any times
Expand All @@ -85,7 +85,7 @@ void pit_phase(int htz)
* @if 0 == RETURN_OK
* @if !0 == RETURN_ERROR
*/
int pit_handler_nest()
static int pit_handler_nest()
{
//printk("%d SECONDS\n", (pit_ticks/IRQ_SEC_HIT));

Expand All @@ -98,7 +98,7 @@ int pit_handler_nest()
* that calls the nested handler
* if second pass.
*/
void pit_handler(int_regs *r)
static void pit_handler(int_regs *r)
{
pit_ticks++;
if (pit_ticks % IRQ_SEC_HIT == 0)
Expand All @@ -125,4 +125,4 @@ int uninit_pit()
initalized_pit = false;
uninstall_irq_handler(IRQ_NUM_PIT);
return STATUS_OK;
}
}
14 changes: 7 additions & 7 deletions arch/i386/drv/ps2/kbd/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <misc/status_codes.h>


struct kbd_info_t kbd_info;
volatile struct kbd_info_t kbd_info;
volatile bool initalized_ps2_kbd = false;
volatile bool status_ps2_kbd;

Expand All @@ -58,7 +58,7 @@ volatile bool status_ps2_kbd;
*/
int key_press(uint8_t scancode)
{
if(kbd_info.is_shift == true)
if(kbd_info.is_shift)
return (kbd_layouts[kbd_info.current_kbd_layout]->scancode_shift[scancode]);
else
return (kbd_layouts[kbd_info.current_kbd_layout]->scancode_no_shift[scancode]);
Expand All @@ -75,10 +75,11 @@ int key_press(uint8_t scancode)
*/
void key_release(uint8_t scancode)
{
// printk("SCANCODE : %d" , scancode);
if (kbd_layouts[kbd_info.current_kbd_layout]->scancode_no_shift[scancode] == KBD_QWERTY_LEFT_SHIFT_PRESS ||
kbd_layouts[kbd_info.current_kbd_layout]->scancode_no_shift[scancode] == KBD_QWERTY_RIGHT_SHIFT_PRESS)
{
printk("SHIFT RELEASE");
//printk("SHIFT RELEASE");
kbd_info.is_shift = false;
}
}
Expand Down Expand Up @@ -163,9 +164,8 @@ void key_handler()
{
case KBD_QWERTY_LEFT_SHIFT_PRESS:
case KBD_QWERTY_RIGHT_SHIFT_PRESS:
printk("SHIFT PRESS");
kbd_info.is_shift = true;
break;
kbd_info.is_shift = true;
break;
case KBD_QWERTY_CAPS_PRESS:
led_light(false,false,true);
if(kbd_info.is_caps == true)
Expand Down Expand Up @@ -275,4 +275,4 @@ int uninit_kbd()
initalized_ps2_kbd = false;
uninstall_irq_handler(IRQ_NUM_KBD);
return STATUS_OK;
}
}
14 changes: 3 additions & 11 deletions arch/i386/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@
#include <stddef.h>
#include <GlobalDefintions.h>
#include <libc/stdio/stdio.h>
#include <misc/asm_util.h>
#include <arch/shared/x86/misc/asm_util.h>
#include <boot/multiboot/multiboot.h>
#include <cpu/gdt/gdt.h>
#include <cpu/interrupts/idt.h>
#include <cpu/interrupts/isr.h>
#define KERNEL_CALL
#include <cpu/interrupts/irq.h>
#undef KERNEL_CALL
#include <cpu/cpu.h>
#include <libc/string/string.h>
#include <drv/pit/pit.h>
#include <drv/ps2/kbd/kbd.h>
Expand Down Expand Up @@ -82,10 +77,7 @@ void crash_me()
*/
void kernelMain(multiboot_info_t* multiboot_structure,uint32_t magicnumber)
{
init_gdt();
init_idt();
init_isr();
init_irq();
init_cpu();
setup_driver_handler();
init_all_drivers();
sti();
Expand Down
9 changes: 9 additions & 0 deletions arch/shared/x86/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BUILDROOT ?= ../../../

CSRCS = \
misc/asm_util.c


LIBNAME := shared_arch

include $(BUILDROOT)/library.mk
Loading

0 comments on commit 5b6163b

Please sign in to comment.