Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "shared"]
path = shared
url = ../redlib
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all: kshared modules kernel shared user utils bins
./createfs

kshared:
$(MAKE) -C shared SH_FLAGS=-DKERNEL BUILD_DIR=./kbuild TARGET=klibshared.a
$(MAKE) -C shared kern

modules: kshared
$(MAKE) -C modules XHCI_CTX_SIZE=$(XHCI_CTX_SIZE) QEMU=$(QEMU) TEST=$(TEST) DRIVER_TARGET=$(MODE)
Expand Down Expand Up @@ -52,9 +52,6 @@ clean:
@echo "removing images"
$(RM) kernel.img kernel.elf disk.img dump

cross:
$(MAKE) -C shared ARCH= SH_FLAGS=-DCROSS BUILD_DIR=./cbuild TARGET=clibshared.a

raspi:
$(MAKE) LOAD_ADDR=0x80000 XHCI_CTX_SIZE=64 QEMU=true MODE=raspi all
./run_raspi
Expand All @@ -76,7 +73,7 @@ dump:

install:
$(MAKE) clean
$(MAKE) LOAD_ADDR=0x80000 XHCI_CTX_SIZE=64 QEMU=false all
$(MAKE) LOAD_ADDR=0x80000 XHCI_CTX_SIZE=64 QEMU=false MODE=raspi all
cp kernel.img $(BOOTFS)/kernel8.img
cp kernel.img $(BOOTFS)/kernel_2712.img
cp config.txt $(BOOTFS)/config.txt
Expand Down
2 changes: 1 addition & 1 deletion kernel/bin/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static bool parse_args(int argc, char *argv[], ping_opts_t *o) {
o->src_set = false;
o->host = NULL;

for (int i = 0; i < argc; ++i) {
for (int i = 1; i < argc; ++i) {
const char *a = argv[i];
if (a && a[0] == '-') {
if (strcmp_case(a, "-4",true) == 0) o->ver = IP_VER4;
Expand Down
2 changes: 1 addition & 1 deletion kernel/bin/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int run_shutdown(int argc, char* argv[]){

int mode = -1;

for (int i = 0; i < argc; ++i){
for (int i = 1; i < argc; ++i){
const char *a = argv[i];
if (!a || a[0] == 0) continue;

Expand Down
2 changes: 1 addition & 1 deletion kernel/bin/tracert.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static bool parse_args(int argc, char *argv[], tr_opts_t *o) {
o->src_set = false;
o->host = NULL;

for (int i = 0; i < argc; i++) {
for (int i = 1; i < argc; i++) {
const char *a = argv[i];
if (a && a[0] == '-') {
if (strcmp_case(a, "-4",true) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/console/kio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "memory/page_allocator.h"
#include "std/memory.h"
#include "math/math.h"
#include "data_struct/ring_buffer.h"
#include "data/struct/ring_buffer.h"

static bool use_visual = false;

Expand Down
2 changes: 1 addition & 1 deletion kernel/dev/driver_base.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "driver_base.h"
#include "data_struct/hashmap.h"
#include "data/struct/hashmap.h"
#include "std/string.h"

uint64_t fd_id = 256;//First byte reserved
Expand Down
2 changes: 1 addition & 1 deletion kernel/dev/module_loader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "driver_base.h"
#include "data_struct/linked_list.h"
#include "data/struct/linked_list.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion kernel/filesystem/fat32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "types.h"
#include "std/string.h"
#include "fsdriver.hpp"
#include "data_struct/hashmap.h"
#include "data/struct/hashmap.h"

typedef struct fat32_mbs {
uint8_t jumpboot[3];//3
Expand Down
4 changes: 2 additions & 2 deletions kernel/filesystem/pipe.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "pipe.h"
#include "filesystem.h"
#include "memory/page_allocator.h"
#include "data_struct/hashmap.h"
#include "data_struct/linked_list.h"
#include "data/struct/hashmap.h"
#include "data/struct/linked_list.h"
#include "process/scheduler.h"

static void *pipe_page;
Expand Down
2 changes: 1 addition & 1 deletion kernel/filesystem/virtio_9p_pci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "fsdriver.hpp"
#include "virtio/virtio_pci.h"
#include "data_struct/hashmap.h"
#include "data/struct/hashmap.h"

typedef struct p9_packet_header {
uint32_t size;
Expand Down
54 changes: 50 additions & 4 deletions kernel/gpio.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,62 @@
#include "gpio.h"
#include "hw/hw.h"
#include "async.h"
#include "std/memory_access.h"
#include "memory/mmu.h"
#include "std/memory_access.h"

void reset_gpio(){
register_device_memory(GPIO_BASE, GPIO_BASE);
register_device_memory(GPIO_BASE, GPIO_BASE);
write32(GPIO_BASE + GPIO_PIN_BASE + 0x94, 0x0);
delay(150);
}

#define GPIOFSEL0 0
#define GPIOSET0 0x1C
#define GPIOCLR0 0x28
#define GPIOPUPPDN0 0xE4

#define GPIO_PULL_NONE 0
#define GPIO_PULL_DOWN 2
#define GPIO_PULL_UP 1

#define GPIO_FUNCTION_IN 0
#define GPIO_FUNCTION_OUT 1
#define GPIO_FUNCTION_ALT5 2
#define GPIO_FUNCTION_ALT3 7
#define GPIO_FUNCTION_ALT0 4

bool call_gpio(unsigned long pin, unsigned long value, uint32_t base, unsigned long field_size)
{
unsigned long field_mask = (1 << field_size) - 1;

if (pin > field_mask && value > field_mask)
return false;

unsigned long num_fields = 32 / field_size;
unsigned long regist = GPIO_BASE + base + ((pin / num_fields) * 4);
unsigned long shift = (pin % num_fields) * field_size;

unsigned long finalval = read32(regist);
finalval &= ~(field_mask << shift);
finalval |= value << shift;

write32(regist, finalval);

return true;
}

bool pull_gpio(unsigned long pin, uint32_t pull)
{
return call_gpio(pin, pull, GPIOPUPPDN0, 2);
}

bool set_gpio_func(unsigned long pin, uint32_t func)
{
return call_gpio(pin, func, GPIOFSEL0, 3);
}

void enable_gpio_pin(uint8_t pin){
uint32_t v = read32(GPIO_BASE + GPIO_PIN_BASE + 0x98);
write32(GPIO_BASE + GPIO_PIN_BASE + 0x98, v | (1 << pin));
pull_gpio(pin, GPIO_PULL_NONE);
set_gpio_func(pin, GPIO_FUNCTION_ALT0);
pull_gpio(pin, GPIO_PULL_NONE);
}
2 changes: 1 addition & 1 deletion kernel/graph/tres.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "types.h"
#include "ui/draw/draw.h"
#include "data_struct/linked_list.h"
#include "data/struct/linked_list.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions kernel/kernel_processes/windows/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "graph/tres.h"
#include "process/scheduler.h"
#include "exceptions/irq.h"
#include "math/math.h"

#define MAX_COLS 3
#define MAX_ROWS 3
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel_processes/windows/launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "types.h"
#include "graph/graphics.h"
#include "process/process.h"
#include "std/std.h"
#include "data/struct/array.hpp"
#include "process/loading/package_info.h"

struct LaunchEntry {
Expand Down
1 change: 1 addition & 0 deletions kernel/memory/page_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void* palloc_inner(uint64_t size, uint8_t level, uint8_t attributes, bool full,
end = count_pages(get_user_ram_end(),PAGE_SIZE);
mem_bitmap = (uintptr_t*)(start * PAGE_SIZE);
start += count_pages(65536*8,PAGE_SIZE);
memset(mem_bitmap, 0, 65536*8);
heap_end = start*PAGE_SIZE;
}
uint64_t page_count = count_pages(size,PAGE_SIZE);
Expand Down
2 changes: 1 addition & 1 deletion kernel/networking/application_layer/dhcpv6_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "process/scheduler.h"
#include "math/rng.h"

#include "data_struct/linked_list.h"
#include "data/struct/linked_list.h"

#include "networking/interface_manager.h"
#include "networking/network.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/networking/network_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "net/network_types.h"
#include "networking/internet_layer/ipv4.h"
#include "interface_manager.h"
#include "data_struct/data_struct.hpp"
#include "data/struct/data_struct.hpp"

class NetworkDispatch {
public:
Expand Down
2 changes: 1 addition & 1 deletion kernel/networking/transport_layer/csocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "csocket_udp.h"
#include "memory/page_allocator.h"
#include "console/kio.h"
#include "data_struct/hashmap.h"
#include "data/struct/hashmap.h"

uint16_t socket_ids;

Expand Down
2 changes: 1 addition & 1 deletion kernel/networking/transport_layer/socket_tcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "networking/internet_layer/ipv4.h"
#include "networking/application_layer/dns/dns.h"
#include "types.h"
#include "data_struct/ring_buffer.hpp"
#include "data/struct/ring_buffer.hpp"
#include "net/socket_types.h"
#include "networking/internet_layer/ipv4_route.h"
#include "networking/internet_layer/ipv6_route.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/process/loading/package_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "std/string.h"
#include "syscalls/syscalls.h"
#include "console/kio.h"
#include "data/toml.h"
#include "data/format/toml.h"

static inline void handle_package_kvp(string_slice key, string_slice value, void* ctx){
package_info *pkg_info = (package_info*)ctx;
Expand Down
2 changes: 1 addition & 1 deletion kernel/process/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "exceptions/timer.h"
#include "console/kconsole/kconsole.h"
#include "std/string.h"
#include "data_struct/hashmap.h"
#include "data/struct/hashmap.h"
#include "std/memory.h"
#include "math/math.h"
#include "memory/mmu.h"
Expand Down
2 changes: 1 addition & 1 deletion kernel/theme/theme.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "theme.h"
#include "syscalls/syscalls.h"
#include "data/toml.h"
#include "data/format/toml.h"
#include "default.h"
#include "console/kio.h"
#include "math/math.h"
Expand Down
1 change: 1 addition & 0 deletions kernel/usb/USBDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "usb_types.h"
#include "std/std.h"
#include "console/kio.h"
#include "data/struct/indexmap.hpp"

class USBDriver;

Expand Down
3 changes: 3 additions & 0 deletions modules/serial/common/uart_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define UART0_FBRD (UART0_BASE + 0x28)
#define UART0_LCRH (UART0_BASE + 0x2C)
#define UART0_CR (UART0_BASE + 0x30)
#define UART0_IMSC (UART0_BASE + 0x38)

#define UART_FIFO 4
#define UART_WLEN 5
Expand Down Expand Up @@ -42,6 +43,8 @@ void enable_uart() {
write32(UART0_LCRH, (1 << UART_FIFO) | (UART_8B_WLEN << UART_WLEN));

write32(UART0_CR, (1 << UART_EN) | (1 << UART_TXE) | (1 << UART_RXE));

write32(UART0_IMSC, 1 << 4);
}

void uart_raw_putc(const char c) {
Expand Down
1 change: 1 addition & 0 deletions shared
Submodule shared added at 322b1e
47 changes: 0 additions & 47 deletions shared/Makefile

This file was deleted.

Loading
Loading