50 changed files with 1203 additions and 828 deletions
@ -1 +1 @@ |
|||
Elias Löwe <elias@lowenware.com> |
|||
Ilja Kartaschoff <ik@lowenware.com> |
|||
|
@ -1,2 +0,0 @@ |
|||
# Lion's Share License -> LSL |
|||
# Löwenware Software Distribution -> LSD |
@ -0,0 +1,39 @@ |
|||
# License |
|||
|
|||
Leos (the "Software") is an intellectual property of Löwenware s.r.o. |
|||
distributed under terms of [Attribution-NoDerivatives 4.0 International](https://creativecommons.org/licenses/by-nd/4.0/legalcode) |
|||
**(CC BY-ND 4.0)** license. |
|||
|
|||
## Highlights |
|||
|
|||
Information below highlights only key features and terms of the |
|||
[license](https://creativecommons.org/licenses/by-nd/4.0/legalcode). It is |
|||
recommended to read its full text before using licensed Software. |
|||
|
|||
### You are free to: |
|||
|
|||
**Share** — copy and redistribute the Software in any medium or format |
|||
for any purpose, even commercially. The licensor cannot revoke these freedoms |
|||
as long as you follow the license terms. |
|||
|
|||
|
|||
### Under the following terms: |
|||
**Attribution** — You must give appropriate credit, provide a link to the license, |
|||
and indicate if changes were made. You may do so in any reasonable manner, but |
|||
not in any way that suggests the licensor endorses you or your use. |
|||
|
|||
**NoDerivatives** — If you remix, transform, or build upon the Software, you may |
|||
not distribute the modified material. |
|||
|
|||
**No additional restrictions** — You may not apply legal terms or technological |
|||
measures that legally restrict others from doing anything the license permits. |
|||
|
|||
### Disclaimer |
|||
The Software is provided "AS IS" without warranty of any kind. In no |
|||
event shall the authors or copyright holders be liable for any claim, damages |
|||
or other liability, whether out of or in connection with the Software or its |
|||
usage. |
|||
|
|||
The license may not give you all of the permissions necessary for your |
|||
intended use. For example, other rights such as publicity, privacy, |
|||
or moral rights may limit how you use the material. |
@ -1,3 +1,88 @@ |
|||
# Löwe OS |
|||
Operating System for ARMv8 (aarch64) architecture. |
|||
# Leos |
|||
Operating System for ARMv8 (aarch64) Architecture |
|||
|
|||
* [The Idea](#The Idea) |
|||
* [Hardware](#Hardware) |
|||
* [Documentation](#Documentation) |
|||
* [Compilation](#Compilation) |
|||
* [Run](#Run) |
|||
* [Debug](#Debug) |
|||
* [Roadmap](#Roadmap) |
|||
* [Contribution](#Contribution) |
|||
|
|||
--- |
|||
|
|||
## The Idea |
|||
|
|||
Löwe OS is being developed to be a lightweight desktop operating system for |
|||
ARM-based computers, tablets, mobile phones etc. Here are some concepts behind |
|||
it: |
|||
|
|||
1. The OS is free with open source codes, distributed under terms of [CC BY-ND 4.0](LICENSE.md). |
|||
2. The OS will have POSIX-compliant API. |
|||
3. The OS will include graphical system, shell and generic utilities as a part |
|||
of it, being designed to work as a solid product. |
|||
4. The OS will respect user's privacy and will not track his/her actions and data. |
|||
5. The OS will stive to be secure and robust. |
|||
|
|||
## Hardware |
|||
|
|||
Early development is going for **Raspberry PI3** board and its emulation using |
|||
**QEMU**. |
|||
|
|||
## Documentation |
|||
|
|||
* [Project structure](docs/project-structure.md) |
|||
* [Naming convention](docs/naming-convention.md) |
|||
* [Task scheduling](docs/task-scheduling.md) |
|||
* [Memory management](docs/memory-management.md) |
|||
|
|||
## Compilation |
|||
|
|||
To compile Löwe OS run `make` from repository root, make sure |
|||
[Clang](https://clang.llvm.org/) compiler is installed on your system. |
|||
|
|||
``` |
|||
$ make |
|||
``` |
|||
|
|||
Output files will be stored inside newly created `build` folder. |
|||
|
|||
## Run |
|||
|
|||
To run Löwe OS on QEMU, execute `make run` command for the repository root. |
|||
|
|||
To run Löwe OS on Raspberry PI3, follow these steps: |
|||
|
|||
1. Compile project and copy `build/kernel8.img` and `config.txt` files to |
|||
Micro SD card |
|||
2. Make sure latest boot code is installed on the SD card |
|||
3. Insert SD card into your Raspberry PI3 and power it up |
|||
|
|||
## Debug |
|||
|
|||
If you have `gdb-multiarch` and **QEMU** installed, then debugging should be as |
|||
easy as `make debug`. |
|||
|
|||
## Roadmap |
|||
|
|||
1. Generic kernel features: |
|||
[x] Loadable Kernel file |
|||
[x] UART logging |
|||
[x] Memory pages avalability bitmap |
|||
[x] Interrupt vectors table |
|||
[x] Basic task scheduler |
|||
[ ] Context switching |
|||
[ ] Memory Mapping Unit |
|||
2. Input/output: |
|||
[ ] Graphical driver |
|||
[ ] USB driver |
|||
[ ] Keyboard input driver |
|||
[ ] Mouse input driver |
|||
3. Graphical system |
|||
4. Shell and utilities |
|||
5. Networking |
|||
6. Sound system |
|||
|
|||
|
|||
## Contribution |
|||
|
@ -1,65 +0,0 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2019 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file main.c |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#include <core/log.h> |
|||
#include <core/arch.h> |
|||
#include <core/irq.h> |
|||
#include <core/timer.h> |
|||
|
|||
|
|||
|
|||
void |
|||
k_main(void); |
|||
|
|||
|
|||
void |
|||
k_main(void) |
|||
{ |
|||
k_log_init(); |
|||
|
|||
k_logs("Starting Lowe OS (EL"); |
|||
k_logi(aarch64_get_el(), 10); |
|||
k_logs(")\r\n"); |
|||
|
|||
if (k_arch_init()) |
|||
goto panic; |
|||
|
|||
k_timer_init(); |
|||
k_irq_enable_controller(); |
|||
k_irq_enable(); |
|||
|
|||
goto ok; |
|||
/*
|
|||
k_logs("\tclock"); |
|||
if (k_clock_init()) |
|||
goto panic; |
|||
|
|||
k_logs(" - ok\n\tscheduler"); |
|||
if (k_scheduler_init()) |
|||
goto panic; |
|||
|
|||
k_logs(" - ok\n"); |
|||
|
|||
k_scheduler_run(); |
|||
*/ |
|||
|
|||
panic: |
|||
k_logs(" - ERROR\n"); |
|||
ok: |
|||
for (;;) { |
|||
__asm__("WFE"); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,42 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2019 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file main.c |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#include <leos/log.h> |
|||
#include <leos/arch.h> |
|||
#include <leos/irq.h> |
|||
#include <leos/timer.h> |
|||
#include <leos/leos.h> |
|||
|
|||
|
|||
void |
|||
Leos_run(void) |
|||
{ |
|||
Log_init(); |
|||
|
|||
Log_putS("Starting Lowe OS (EL"); |
|||
Log_putI(AArch64_getEL(), 10); |
|||
Log_putS(")\r\n"); |
|||
|
|||
Arch_init(); |
|||
|
|||
Timer_init(); |
|||
IRQ_init(); |
|||
IRQ_enable(); |
|||
|
|||
for (;;) { |
|||
__asm__("WFE"); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,22 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2020 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file leos.h |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#ifndef LEOS_H_7087F58B_BDEB_433B_A013_5B5F854922AF |
|||
#define LEOS_H_7087F58B_BDEB_433B_A013_5B5F854922AF |
|||
|
|||
void |
|||
Leos_run(void); |
|||
|
|||
#endif /* !LEOS_H */ |
@ -0,0 +1,54 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2020 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
unsigned |
|||
* @file memory.c |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#include <stdlib.h> |
|||
#include <aarch64/bcm2837.h> |
|||
#include "memory.h" |
|||
|
|||
static unsigned long m_map[MEMORY_PAGE_COUNT / sizeof(unsigned long) / 8] = {0,}; |
|||
static int m_ix = 0; |
|||
|
|||
void * |
|||
Memory_getPage(void) |
|||
{ |
|||
int i, j; |
|||
unsigned long map; |
|||
|
|||
|
|||
for (i = m_ix; i < sizeof(m_map) / sizeof(m_map[0]); i++) { |
|||
map = m_map[i]; |
|||
for (j = 0; j < 8 * sizeof(map); j++) { |
|||
if (!(map & (1 << j))) { |
|||
m_map[i] |= (1 << j); |
|||
return (void *) ((i * sizeof(map) * 8 + j) * MEMORY_PAGE_SIZE); |
|||
} |
|||
} |
|||
m_ix = i; |
|||
} |
|||
|
|||
return NULL; |
|||
} |
|||
|
|||
void |
|||
Memory_freePage(void *p_addr) |
|||
{ |
|||
int i, j, c; |
|||
|
|||
c = ((unsigned long) p_addr) / MEMORY_PAGE_SIZE; |
|||
i = c / sizeof(m_map[0]); |
|||
j = c % sizeof(m_map[0]); |
|||
m_map[i] &= ~(1 << j); |
|||
} |
@ -0,0 +1,26 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2020 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file memory.h |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#ifndef MEMORY_H_C583E24E_55B0_49EF_99C9_5A36B04468AC |
|||
#define MEMORY_H_C583E24E_55B0_49EF_99C9_5A36B04468AC |
|||
|
|||
void * |
|||
Memory_getPage(void); |
|||
|
|||
void |
|||
Memory_freePage(void *p_addr); |
|||
|
|||
|
|||
#endif /* !MEMORY_H */ |
@ -0,0 +1,92 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2020 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file scheduler.c |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#include "scheduler.h" |
|||
|
|||
|
|||
static struct KTask *m_first = NULL, *m_last, *m_current = NULL; |
|||
static KPid m_pid = 0; |
|||
|
|||
static void |
|||
_disable_preempt(void) |
|||
{ |
|||
m_current->preempt++; |
|||
} |
|||
|
|||
static void |
|||
_enable_preempt(void) |
|||
{ |
|||
m_current->preempt--; |
|||
} |
|||
|
|||
static void |
|||
_switch(void) |
|||
{ |
|||
struct KTask *i, *next; |
|||
long p = 0; |
|||
|
|||
_disable_preempt(); |
|||
|
|||
for (;;) { |
|||
/* check urgent tasks */ |
|||
for (i = m_first; i != NULL; i = i->next) { |
|||
if (!i->state && i->counter > p) { |
|||
p = i->counter; |
|||
next = i; |
|||
} |
|||
i = i->next; |
|||
} |
|||
|
|||
if (p) { |
|||
break; |
|||
} |
|||
|
|||
i = m_first; |
|||
for (i = m_first; i != NULL; i = i->next) { |
|||
i->counter = i->priority; |
|||
} |
|||
} |
|||
|
|||
aarch64_switch(m_current, next); |
|||
_enable_preempt(); |
|||
} |
|||
|
|||
void |
|||
scheduler_init(void) |
|||
{ |
|||
|
|||
} |
|||
|
|||
KPid |
|||
scheduler_add(struct KTask *task) |
|||
{ |
|||
KPid result = ++m_pid; |
|||
task->pid = result; |
|||
task->prev = m_last; |
|||
m_last->next = task; |
|||
return result; |
|||
} |
|||
|
|||
void |
|||
scheduler_switch(void) |
|||
{ |
|||
|
|||
} |
|||
|
|||
void |
|||
scheduler_switch_from_isr(void) |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,38 @@ |
|||
/******************************************************************************
|
|||
* |
|||
* Copyright (c) 2017-2019 by Löwenware Ltd |
|||
* Please, refer LICENSE file for legal information |
|||
* |
|||
******************************************************************************/ |
|||
|
|||
/**
|
|||
* @file scheduler.h |
|||
* @author Ilja Kartašov <ik@lowenware.com> |
|||
* @brief |
|||
* |
|||
* @see https://lowenware.com/
|
|||
*/ |
|||
|
|||
#ifndef SCHEDULER_H_AE39DBC8_E643_4857_B319_9732123728A4 |
|||
#define SCHEDULER_H_AE39DBC8_E643_4857_B319_9732123728A4 |
|||
|
|||
void |
|||
scheduler_init(void); |
|||
|
|||
void |
|||
scheduler_run(void); |
|||
|
|||
void |
|||
scheduler_switch(void); |
|||
|
|||
KPid |
|||
scheduler_add(struct KTask *task); |
|||
|
|||
KRetCode |
|||
scheduler_remove(struct KTask *task); |
|||
|
|||
KRetCode |
|||
scheduler_remove_pid(KPid pid); |
|||
|
|||
|
|||
#endif /* !SCHEDULER_H */ |
Loading…
Reference in new issue