Initial import
This commit is contained in:
commit
94aad4b8e1
77 changed files with 4414 additions and 0 deletions
38
boot/include/arch/aarch64/arch/mm/paging.h
Normal file
38
boot/include/arch/aarch64/arch/mm/paging.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: paging.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _MM_PAGING_H
|
||||
#define _MM_PAGING_H
|
||||
|
||||
#include <firmware/memmap.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
int paging_init(struct memory_map_info *memmap);
|
||||
|
||||
void paging_identity_map(uint64_t addr);
|
||||
void paging_map(uint64_t phys, uint64_t virt);
|
||||
void paging_unmap(uint64_t virt);
|
||||
|
||||
void *paging_allocate(size_t np);
|
||||
|
||||
#endif /* _MM_PAGING_H */
|
0
boot/include/arch/aarch64/uefi/.gitkeep
Normal file
0
boot/include/arch/aarch64/uefi/.gitkeep
Normal file
0
boot/include/arch/i686/arch/.gitkeep
Normal file
0
boot/include/arch/i686/arch/.gitkeep
Normal file
0
boot/include/arch/i686/uefi/.gitkeep
Normal file
0
boot/include/arch/i686/uefi/.gitkeep
Normal file
116
boot/include/arch/x86_64/arch/cpu/cpu.h
Normal file
116
boot/include/arch/x86_64/arch/cpu/cpu.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: cpu.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _ARCH_CPU_CPU_H
|
||||
#define _ARCH_CPU_CPU_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
////
|
||||
// Utilities
|
||||
///
|
||||
|
||||
static inline void cpu_disable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile("cli" ::: "memory");
|
||||
}
|
||||
|
||||
static inline uint64_t read_cr0()
|
||||
{
|
||||
uint64_t val;
|
||||
__asm__ volatile("mov %%cr0, %0"
|
||||
: "=r"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline uint64_t read_cr2()
|
||||
{
|
||||
uint64_t val;
|
||||
__asm__ volatile("mov %%cr2, %0"
|
||||
: "=r"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline uint64_t read_cr3()
|
||||
{
|
||||
uint64_t val;
|
||||
__asm__ volatile("mov %%cr3, %0"
|
||||
: "=r"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline uint64_t read_cr4()
|
||||
{
|
||||
uint64_t val;
|
||||
__asm__ volatile("mov %%cr4, %0"
|
||||
: "=r"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline uint64_t read_cr8()
|
||||
{
|
||||
uint64_t val;
|
||||
__asm__ volatile("mov %%cr8, %0"
|
||||
: "=r"(val));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline void write_cr0(uint64_t val)
|
||||
{
|
||||
__asm__ volatile("mov %0, %%cr0"
|
||||
:: "r"(val));
|
||||
}
|
||||
|
||||
static inline void write_cr2(uint64_t val)
|
||||
{
|
||||
__asm__ volatile("mov %0, %%cr2"
|
||||
:: "r"(val));
|
||||
}
|
||||
|
||||
static inline void write_cr3(uint64_t val)
|
||||
{
|
||||
__asm__ volatile("mov %0, %%cr3"
|
||||
:: "r"(val) : "memory");
|
||||
}
|
||||
|
||||
static inline void write_cr4(uint64_t val)
|
||||
{
|
||||
__asm__ volatile("mov %0, %%cr4"
|
||||
:: "r"(val));
|
||||
}
|
||||
|
||||
static inline void write_cr8(uint64_t val)
|
||||
{
|
||||
__asm__ volatile("mov %0, %%cr8"
|
||||
:: "r"(val));
|
||||
}
|
||||
|
||||
static inline uint8_t inb(uint16_t port)
|
||||
{
|
||||
uint8_t ret;
|
||||
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val)
|
||||
{
|
||||
__asm__ volatile("outb %b0, %w1" :: "a"(val), "Nd"(port) : "memory");
|
||||
}
|
||||
|
||||
#endif /* _ARCH_CPU_CPU_H */
|
67
boot/include/arch/x86_64/arch/cpu/gdt.h
Normal file
67
boot/include/arch/x86_64/arch/cpu/gdt.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: gdt.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _ARCH_CPU_GDT_H
|
||||
#define _ARCH_CPU_GDT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct gdt_descriptor {
|
||||
uint16_t limit_low;
|
||||
uint16_t base_low;
|
||||
uint8_t base_mid;
|
||||
uint8_t access;
|
||||
uint8_t limit_high : 4;
|
||||
uint8_t flags : 4;
|
||||
uint8_t base_high;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct tss_descriptor {
|
||||
struct gdt_descriptor gdt;
|
||||
uint32_t base_high;
|
||||
uint32_t reserved;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct tss {
|
||||
uint32_t reserved;
|
||||
uint32_t rsp0[2];
|
||||
uint32_t rsp1[2];
|
||||
uint32_t rsp2[2];
|
||||
uint32_t reserved0[2];
|
||||
uint32_t ist0[2];
|
||||
uint32_t ist1[2];
|
||||
uint32_t ist2[2];
|
||||
uint32_t ist3[2];
|
||||
uint32_t ist4[2];
|
||||
uint32_t ist5[2];
|
||||
uint32_t ist6[2];
|
||||
uint32_t ist7[2];
|
||||
uint32_t reserved1[4];
|
||||
uint16_t iomap_base;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct gdtr {
|
||||
uint16_t limit;
|
||||
uint64_t base;
|
||||
} __attribute__((packed));
|
||||
|
||||
void gdt_set_entry(struct gdt_descriptor *entry, uint32_t base, uint32_t limit, uint8_t access,
|
||||
uint8_t flags);
|
||||
|
||||
#endif /* _ARCH_CPU_GDT_H */
|
29
boot/include/arch/x86_64/arch/mm/paging.h
Normal file
29
boot/include/arch/x86_64/arch/mm/paging.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: paging.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _MM_PAGING_H
|
||||
#define _MM_PAGING_H
|
||||
|
||||
#include <firmware/memmap.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
#endif /* _MM_PAGING_H */
|
0
boot/include/arch/x86_64/uefi/.gitkeep
Normal file
0
boot/include/arch/x86_64/uefi/.gitkeep
Normal file
32
boot/include/axboot.h
Normal file
32
boot/include/axboot.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: axboot.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _AXBOOT_H
|
||||
#define _AXBOOT_H
|
||||
|
||||
#include <utils.h>
|
||||
|
||||
#define BOOTLOADER_NAME_STR "AxBoot"
|
||||
#define BOOTLOADER_VERSION_STR "0.1"
|
||||
|
||||
#ifndef UNREACHABLE
|
||||
#define UNREACHABLE()
|
||||
#endif
|
||||
|
||||
#endif /* _AXBOOT_H */
|
1137
boot/include/nanoprintf.h
Normal file
1137
boot/include/nanoprintf.h
Normal file
File diff suppressed because it is too large
Load diff
32
boot/include/print.h
Normal file
32
boot/include/print.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: print.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _PRINT_H
|
||||
#define _PRINT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void log(const char *fmt, ...);
|
||||
void debug(const char *fmt, ...);
|
||||
|
||||
void printstr(const char *str);
|
||||
|
||||
#endif /* _PRINT_H */
|
28
boot/include/utils.h
Normal file
28
boot/include/utils.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: utils.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _UTILS_H
|
||||
#define _UTILS_H
|
||||
|
||||
#define ARRAY_LENGTH(x) ((sizeof(x)) / (sizeof((x[0]))))
|
||||
|
||||
#define ROUND_DOWN(x, a) (((x)) & (~((a) - 1)))
|
||||
#define ROUND_UP(x, a) ((((x)) + (a) - 1) & (~((a) - 1)))
|
||||
|
||||
#endif /* _UTILS_H */
|
Loading…
Add table
Add a link
Reference in a new issue