git://scm.lunaixsky.com
/
lunaix-os.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b6ff3c7
)
chore: fix almost *ALL* warnings.
author
Minep
<lunaixsky@qq.com>
Sun, 16 Jul 2023 23:05:34 +0000
(
00:05
+0100)
committer
Minep
<lunaixsky@qq.com>
Sun, 16 Jul 2023 23:05:34 +0000
(
00:05
+0100)
106 files changed:
lunaix-os/arch/x86/hhk.c
patch
|
blob
|
history
lunaix-os/config/make-cc
patch
|
blob
|
history
lunaix-os/debug/bg_lsdbg.c
patch
|
blob
|
history
lunaix-os/debug/gdbstub.c
patch
|
blob
|
history
lunaix-os/hal/acpi/acpi.c
patch
|
blob
|
history
lunaix-os/hal/acpi/parser/madt_parser.c
patch
|
blob
|
history
lunaix-os/hal/acpi/parser/mcfg_parser.c
patch
|
blob
|
history
lunaix-os/hal/ahci/ahci.c
patch
|
blob
|
history
lunaix-os/hal/ahci/ata.c
patch
|
blob
|
history
lunaix-os/hal/ahci/atapi.c
patch
|
blob
|
history
lunaix-os/hal/ahci/io_event.c
patch
|
blob
|
history
lunaix-os/hal/ahci/utils.c
patch
|
blob
|
history
lunaix-os/hal/apic.c
patch
|
blob
|
history
lunaix-os/hal/cpu.c
patch
|
blob
|
history
lunaix-os/hal/ioapic.c
patch
|
blob
|
history
lunaix-os/hal/pci.c
patch
|
blob
|
history
lunaix-os/hal/rtc.c
patch
|
blob
|
history
lunaix-os/includes/arch/x86/interrupts.h
patch
|
blob
|
history
lunaix-os/includes/arch/x86/tss.h
patch
|
blob
|
history
lunaix-os/includes/hal/acpi/acpi.h
patch
|
blob
|
history
lunaix-os/includes/hal/acpi/fadt.h
patch
|
blob
|
history
lunaix-os/includes/hal/acpi/madt.h
patch
|
blob
|
history
lunaix-os/includes/hal/acpi/mcfg.h
patch
|
blob
|
history
lunaix-os/includes/hal/acpi/sdt.h
patch
|
blob
|
history
lunaix-os/includes/hal/ahci/ahci.h
patch
|
blob
|
history
lunaix-os/includes/hal/ahci/hba.h
patch
|
blob
|
history
lunaix-os/includes/hal/ahci/sata.h
patch
|
blob
|
history
lunaix-os/includes/hal/ahci/scsi.h
patch
|
blob
|
history
lunaix-os/includes/hal/cpu.h
patch
|
blob
|
history
lunaix-os/includes/hal/io.h
patch
|
blob
|
history
lunaix-os/includes/hal/ioapic.h
patch
|
blob
|
history
lunaix-os/includes/hal/pci.h
patch
|
blob
|
history
lunaix-os/includes/hal/rtc.h
patch
|
blob
|
history
lunaix-os/includes/klibc/stdio.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/clock.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/common.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/ds/fifo.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/ds/hashtable.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/exebi/elf32.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/exec.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/fs/iso9660.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/isrm.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/cake.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/mmap.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/mmio.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/page.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/pmm.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/mm/vmm.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/peripheral/ps2kbd.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/peripheral/serial.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/process.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/sched.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/signal.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/spike.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/timer.h
patch
|
blob
|
history
lunaix-os/includes/lunaix/types.h
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/gdt.c
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/i386_isrm.c
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/intr_routines.c
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/intrhnds.c
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/pfault.c
patch
|
blob
|
history
lunaix-os/kernel/asm/x86/syscall.S
patch
|
blob
|
history
lunaix-os/kernel/block/blkpart_gpt.c
patch
|
blob
|
history
lunaix-os/kernel/ds/fifo.c
patch
|
blob
|
history
lunaix-os/kernel/ds/hstr.c
patch
|
blob
|
history
lunaix-os/kernel/exe/elf32/elf32bfmt.c
patch
|
blob
|
history
lunaix-os/kernel/exe/elf32/ldelf32.c
patch
|
blob
|
history
lunaix-os/kernel/exe/exec.c
patch
|
blob
|
history
lunaix-os/kernel/fs/defaults.c
patch
|
blob
|
history
lunaix-os/kernel/fs/iso9660/directory.c
patch
|
blob
|
history
lunaix-os/kernel/fs/iso9660/mount.c
patch
|
blob
|
history
lunaix-os/kernel/fs/iso9660/rockridge.c
patch
|
blob
|
history
lunaix-os/kernel/fs/pcache.c
patch
|
blob
|
history
lunaix-os/kernel/fs/ramfs/ramfs.c
patch
|
blob
|
history
lunaix-os/kernel/fs/twifs/twifs.c
patch
|
blob
|
history
lunaix-os/kernel/fs/vfs.c
patch
|
blob
|
history
lunaix-os/kernel/fs/xattr.c
patch
|
blob
|
history
lunaix-os/kernel/k_init.c
patch
|
blob
|
history
lunaix-os/kernel/mm/cake.c
patch
|
blob
|
history
lunaix-os/kernel/mm/cow.c
patch
|
blob
|
history
lunaix-os/kernel/mm/dmm.c
patch
|
blob
|
history
lunaix-os/kernel/mm/mmap.c
patch
|
blob
|
history
lunaix-os/kernel/mm/mmio.c
patch
|
blob
|
history
lunaix-os/kernel/mm/pmm.c
patch
|
blob
|
history
lunaix-os/kernel/mm/vmap.c
patch
|
blob
|
history
lunaix-os/kernel/mm/vmm.c
patch
|
blob
|
history
lunaix-os/kernel/peripheral/ps2kbd.c
patch
|
blob
|
history
lunaix-os/kernel/peripheral/serial.c
patch
|
blob
|
history
lunaix-os/kernel/proc0.c
patch
|
blob
|
history
lunaix-os/kernel/process/process.c
patch
|
blob
|
history
lunaix-os/kernel/process/sched.c
patch
|
blob
|
history
lunaix-os/kernel/process/signal.c
patch
|
blob
|
history
lunaix-os/kernel/spike.c
patch
|
blob
|
history
lunaix-os/kernel/time/clock.c
patch
|
blob
|
history
lunaix-os/kernel/time/timer.c
patch
|
blob
|
history
lunaix-os/kernel/tty/lxconsole.c
patch
|
blob
|
history
lunaix-os/kernel/tty/tty.c
patch
|
blob
|
history
lunaix-os/libs/klibc/stdio/ksprintf.c
patch
|
blob
|
history
lunaix-os/libs/klibc/string/mem.c
patch
|
blob
|
history
lunaix-os/scripts/x86_idt_generator.py
patch
|
blob
|
history
lunaix-os/uprog/ls.c
patch
|
blob
|
history
lunaix-os/uprog/sh.c
patch
|
blob
|
history
lunaix-os/uprog/signal_demo.c
patch
|
blob
|
history
lunaix-os/usr/includes/sys/types.h
patch
|
blob
|
history
lunaix-os/usr/libc/_mystdio.h
patch
|
blob
|
history
lunaix-os/usr/libc/_vprintf.c
patch
|
blob
|
history
diff --git
a/lunaix-os/arch/x86/hhk.c
b/lunaix-os/arch/x86/hhk.c
index 5854b626b580f057ba92adc7d2115f85d5ec2aaa..49221222d3cb47a2b0285806475a37ca47ffcec3 100644
(file)
--- a/
lunaix-os/arch/x86/hhk.c
+++ b/
lunaix-os/arch/x86/hhk.c
@@
-7,7
+7,7
@@
#define SET_PDE(ptd, pde_index, pde) *((ptd_t*)ptd + pde_index) = pde;
#define SET_PTE(ptd, pt_index, pte_index, pte) \
*(PT_ADDR(ptd, pt_index) + pte_index) = pte;
#define SET_PDE(ptd, pde_index, pde) *((ptd_t*)ptd + pde_index) = pde;
#define SET_PTE(ptd, pt_index, pte_index, pte) \
*(PT_ADDR(ptd, pt_index) + pte_index) = pte;
-#define sym_val(sym) (
uint
ptr_t)(&sym)
+#define sym_val(sym) (ptr_t)(&sym)
#define KERNEL_PAGE_COUNT \
((sym_val(__kernel_end) - sym_val(__kernel_start) + 0x1000 - 1) >> 12);
#define KERNEL_PAGE_COUNT \
((sym_val(__kernel_end) - sym_val(__kernel_start) + 0x1000 - 1) >> 12);
@@
-24,10
+24,10
@@
#define PG_TABLE_STACK 8
// Provided by linker (see linker.ld)
#define PG_TABLE_STACK 8
// Provided by linker (see linker.ld)
-extern u
int
8_t __kernel_start;
-extern u
int
8_t __kernel_end;
-extern u
int
8_t __init_hhk_end;
-extern u
int
8_t _k_stack;
+extern u8_t __kernel_start;
+extern u8_t __kernel_end;
+extern u8_t __init_hhk_end;
+extern u8_t _k_stack;
void
_init_page(ptd_t* ptd)
void
_init_page(ptd_t* ptd)
@@
-79,7
+79,7
@@
_init_page(ptd_t* ptd)
}
// 计算内核.text段的物理地址
}
// 计算内核.text段的物理地址
-
uint
ptr_t kernel_pm = V2P(&__kernel_start);
+ ptr_t kernel_pm = V2P(&__kernel_start);
// 重映射内核至高半区地址(>=0xC0000000)
for (u32_t i = 0; i < kernel_pg_counts; i++) {
// 重映射内核至高半区地址(>=0xC0000000)
for (u32_t i = 0; i < kernel_pg_counts; i++) {
@@
-96,7
+96,7
@@
_init_page(ptd_t* ptd)
}
u32_t
}
u32_t
-__save_subset(u
int8_t* destination, uint
8_t* base, unsigned int size)
+__save_subset(u
8_t* destination, u
8_t* base, unsigned int size)
{
unsigned int i = 0;
for (; i < size; i++) {
{
unsigned int i = 0;
for (; i < size; i++) {
@@
-106,25
+106,23
@@
__save_subset(uint8_t* destination, uint8_t* base, unsigned int size)
}
void
}
void
-_save_multiboot_info(multiboot_info_t* info, u
int
8_t* destination)
+_save_multiboot_info(multiboot_info_t* info, u8_t* destination)
{
u32_t current = 0;
{
u32_t current = 0;
- u
int8_t* info_b = (uint
8_t*)info;
+ u
8_t* info_b = (u
8_t*)info;
for (; current < sizeof(multiboot_info_t); current++) {
*(destination + current) = *(info_b + current);
}
for (; current < sizeof(multiboot_info_t); current++) {
*(destination + current) = *(info_b + current);
}
- ((multiboot_info_t*)destination)->mmap_addr =
- (uintptr_t)destination + current;
+ ((multiboot_info_t*)destination)->mmap_addr = (ptr_t)destination + current;
current += __save_subset(
current += __save_subset(
- destination + current, (u
int
8_t*)info->mmap_addr, info->mmap_length);
+ destination + current, (u8_t*)info->mmap_addr, info->mmap_length);
if (present(info->flags, MULTIBOOT_INFO_DRIVE_INFO)) {
((multiboot_info_t*)destination)->drives_addr =
if (present(info->flags, MULTIBOOT_INFO_DRIVE_INFO)) {
((multiboot_info_t*)destination)->drives_addr =
- (uintptr_t)destination + current;
- current += __save_subset(destination + current,
- (uint8_t*)info->drives_addr,
- info->drives_length);
+ (ptr_t)destination + current;
+ current += __save_subset(
+ destination + current, (u8_t*)info->drives_addr, info->drives_length);
}
}
}
}
@@
-134,7
+132,7
@@
_hhk_init(ptd_t* ptd, u32_t kpg_size)
// 初始化 kpg 全为0
// P.s. 真没想到GRUB会在这里留下一堆垃圾! 老子的页表全乱套了!
// 初始化 kpg 全为0
// P.s. 真没想到GRUB会在这里留下一堆垃圾! 老子的页表全乱套了!
- u
int8_t* kpg = (uint
8_t*)ptd;
+ u
8_t* kpg = (u
8_t*)ptd;
for (u32_t i = 0; i < kpg_size; i++) {
*(kpg + i) = 0;
}
for (u32_t i = 0; i < kpg_size; i++) {
*(kpg + i) = 0;
}
diff --git
a/lunaix-os/config/make-cc
b/lunaix-os/config/make-cc
index 7915afe89a0949d305ea569d5c9664564b9c3e52..75b37f887688cc41a429f1ea525355c5aecc925e 100644
(file)
--- a/
lunaix-os/config/make-cc
+++ b/
lunaix-os/config/make-cc
@@
-7,9
+7,10
@@
ARCH_OPT := -D__ARCH_IA32 -include flags.h
O := -O2
W := -Wall -Wextra -Wno-unknown-pragmas \
-Wno-unused-function \
O := -O2
W := -Wall -Wextra -Wno-unknown-pragmas \
-Wno-unused-function \
+ -Wno-unused-variable\
-Wno-unused-but-set-variable \
-Wno-unused-parameter \
-Wno-unused-but-set-variable \
-Wno-unused-parameter \
- -Wno-
unused-variable
\
+ -Wno-
discarded-qualifiers
\
-Werror=incompatible-pointer-types
OFLAGS := -fno-gcse\
-Werror=incompatible-pointer-types
OFLAGS := -fno-gcse\
diff --git
a/lunaix-os/debug/bg_lsdbg.c
b/lunaix-os/debug/bg_lsdbg.c
index 9c428b2755c11877e1fc989cfcc3d94db310f011..c5072d7f5dec9419f9037df88be3de4b7ef8a2a2 100644
(file)
--- a/
lunaix-os/debug/bg_lsdbg.c
+++ b/
lunaix-os/debug/bg_lsdbg.c
@@
-7,7
+7,7
@@
LOG_MODULE("DBG");
LOG_MODULE("DBG");
-static volatile sdbg_state = 0;
+static volatile
int
sdbg_state = 0;
void
sdbg_printf(char* fmt, ...)
void
sdbg_printf(char* fmt, ...)
@@
-26,7
+26,7
@@
sdbg_printf(char* fmt, ...)
void
lunaix_sdbg_loop(isr_param* param)
{
void
lunaix_sdbg_loop(isr_param* param)
{
-
char
c;
+
u8_t
c;
if (sdbg_state == SDBG_STATE_WAIT_BRK) {
(param)->execp->eflags &= ~(1 << 8);
if (sdbg_state == SDBG_STATE_WAIT_BRK) {
(param)->execp->eflags &= ~(1 << 8);
@@
-37,7
+37,7
@@
lunaix_sdbg_loop(isr_param* param)
}
while (1) {
}
while (1) {
- c = serial_rx_byte(SERIAL_COM1);
+ c =
(u8_t)
serial_rx_byte(SERIAL_COM1);
if (c == SDBG_CLNT_QUIT) {
sdbg_state = SDBG_STATE_START;
break;
if (c == SDBG_CLNT_QUIT) {
sdbg_state = SDBG_STATE_START;
break;
@@
-66,9
+66,9
@@
lunaix_sdbg_loop(isr_param* param)
return;
case SDBG_CLNT_BRKP:
// the break point address
return;
case SDBG_CLNT_BRKP:
// the break point address
- // serial_rx_buffer(SERIAL_COM1, buffer, sizeof(
uint
ptr_t));
+ // serial_rx_buffer(SERIAL_COM1, buffer, sizeof(ptr_t));
- // asm("movl %0, %%dr0" ::"r"(*((
uint
ptr_t*)buffer)));
+ // asm("movl %0, %%dr0" ::"r"(*((ptr_t*)buffer)));
sdbg_state = SDBG_STATE_WAIT_BRK;
return;
sdbg_state = SDBG_STATE_WAIT_BRK;
return;
diff --git
a/lunaix-os/debug/gdbstub.c
b/lunaix-os/debug/gdbstub.c
index d87db19fa33cc46ad519da0f74287cd2a0eb8c41..38d35adf0b13e75a56aa771725a0abdb3ce3840d 100644
(file)
--- a/
lunaix-os/debug/gdbstub.c
+++ b/
lunaix-os/debug/gdbstub.c
@@
-42,8
+42,8
@@
****************************************************************************/
#ifndef GDBSTUB_DONT_DEFINE_STDINT_TYPES
****************************************************************************/
#ifndef GDBSTUB_DONT_DEFINE_STDINT_TYPES
-typedef unsigned char u
int
8_t;
-typedef unsigned short u
int
16_t;
+typedef unsigned char u8_t;
+typedef unsigned short u16_t;
typedef unsigned long uint32_t;
#endif
typedef unsigned long uint32_t;
#endif
@@
-1176,16
+1176,16
@@
gdb_main(struct gdb_state* state)
struct gdb_idtr
{
struct gdb_idtr
{
- u
int
16_t len;
+ u16_t len;
uint32_t offset;
} __attribute__((packed));
struct gdb_idt_gate
{
uint32_t offset;
} __attribute__((packed));
struct gdb_idt_gate
{
- u
int
16_t offset_low;
- u
int
16_t segment;
- u
int
16_t flags;
- u
int
16_t offset_high;
+ u16_t offset_low;
+ u16_t segment;
+ u16_t flags;
+ u16_t offset_high;
} __attribute__((packed));
/*****************************************************************************
} __attribute__((packed));
/*****************************************************************************
diff --git
a/lunaix-os/hal/acpi/acpi.c
b/lunaix-os/hal/acpi/acpi.c
index 419b1360fc17c16f7aaec63f795a2d632b3537c7..559befef9f2c76895ecfaab27ca9fa8b382227a3 100644
(file)
--- a/
lunaix-os/hal/acpi/acpi.c
+++ b/
lunaix-os/hal/acpi/acpi.c
@@
-58,6
+58,8
@@
acpi_init(multiboot_info_t* mb_info)
}
kprintf(KINFO "ACPI: %s\n", ctx->oem_id);
}
kprintf(KINFO "ACPI: %s\n", ctx->oem_id);
+
+ return 0;
}
acpi_context*
}
acpi_context*
@@
-70,8
+72,8
@@
acpi_get_context()
int
acpi_rsdp_validate(acpi_rsdp_t* rsdp)
{
int
acpi_rsdp_validate(acpi_rsdp_t* rsdp)
{
- u
int
8_t sum = 0;
- u
int8_t* rsdp_ptr = (uint
8_t*)rsdp;
+ u8_t sum = 0;
+ u
8_t* rsdp_ptr = (u
8_t*)rsdp;
for (size_t i = 0; i < 20; i++) {
sum += *(rsdp_ptr + i);
}
for (size_t i = 0; i < 20; i++) {
sum += *(rsdp_ptr + i);
}
@@
-79,14
+81,14
@@
acpi_rsdp_validate(acpi_rsdp_t* rsdp)
return sum == 0;
}
return sum == 0;
}
-u
int
8_t
-acpi_gistranslate(u
int
8_t old_irq)
+u8_t
+acpi_gistranslate(u8_t old_irq)
{
if (old_irq >= 24) {
return old_irq;
}
acpi_intso_t* int_override = ctx->madt.irq_exception[old_irq];
{
if (old_irq >= 24) {
return old_irq;
}
acpi_intso_t* int_override = ctx->madt.irq_exception[old_irq];
- return int_override ? (u
int
8_t)int_override->gsi : old_irq;
+ return int_override ? (u8_t)int_override->gsi : old_irq;
}
#define VIRTUAL_BOX_PROBLEM
}
#define VIRTUAL_BOX_PROBLEM
@@
-110,7
+112,7
@@
acpi_locate_rsdp(multiboot_info_t* mb_info)
continue;
}
continue;
}
- u
int
8_t* mem_start = entry.addr_low & ~0xf;
+ u8_t* mem_start = entry.addr_low & ~0xf;
size_t len = entry.len_low;
for (size_t j = 0; j < len; j += 16) {
u32_t sig_low = *((u32_t*)(mem_start + j));
size_t len = entry.len_low;
for (size_t j = 0; j < len; j += 16) {
u32_t sig_low = *((u32_t*)(mem_start + j));
@@
-123,13
+125,14
@@
acpi_locate_rsdp(multiboot_info_t* mb_info)
}
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
}
#else
// You know what, I just search the entire 1MiB for Celestia's sake.
-
uint8_t*
mem_start = 0x4000;
+
ptr_t
mem_start = 0x4000;
for (; mem_start < 0x100000; mem_start += 16) {
for (; mem_start < 0x100000; mem_start += 16) {
- u32_t sig_low = *((u32_t*)
(mem_start)
);
+ u32_t sig_low = *((u32_t*)
mem_start
);
// XXX: do we need to compare this as well?
// u32_t sig_high = *((u32_t*)(mem_start+j) + 1);
// XXX: do we need to compare this as well?
// u32_t sig_high = *((u32_t*)(mem_start+j) + 1);
+
if (sig_low == ACPI_RSDP_SIG_L) {
if (sig_low == ACPI_RSDP_SIG_L) {
- rsdp = (acpi_rsdp_t*)
(mem_start)
;
+ rsdp = (acpi_rsdp_t*)
mem_start
;
break;
}
}
break;
}
}
diff --git
a/lunaix-os/hal/acpi/parser/madt_parser.c
b/lunaix-os/hal/acpi/parser/madt_parser.c
index 7510d407ddfbc8d07c7e681ec927d9439f6f0383..3c05de1473649cdc41cf3c66e320c681a61682be 100644
(file)
--- a/
lunaix-os/hal/acpi/parser/madt_parser.c
+++ b/
lunaix-os/hal/acpi/parser/madt_parser.c
@@
-7,8
+7,8
@@
madt_parse(acpi_madt_t* madt, acpi_context* toc)
toc->madt.apic_addr = madt->apic_addr;
// FUTURE: make madt.{apic,ioapic} as array or linked list.
toc->madt.apic_addr = madt->apic_addr;
// FUTURE: make madt.{apic,ioapic} as array or linked list.
-
uint8_t* ics_start = (uint8_t*)((uintptr_t)madt + sizeof(acpi_madt_t)
);
-
uintptr_t ics_end = (uint
ptr_t)madt + madt->header.length;
+
ptr_t ics_start = (ptr_t)madt + sizeof(acpi_madt_t
);
+
ptr_t ics_end = (
ptr_t)madt + madt->header.length;
// Cosidering only one IOAPIC present (max 24 pins)
toc->madt.irq_exception =
// Cosidering only one IOAPIC present (max 24 pins)
toc->madt.irq_exception =
diff --git
a/lunaix-os/hal/acpi/parser/mcfg_parser.c
b/lunaix-os/hal/acpi/parser/mcfg_parser.c
index 49d04a79cb044f1aa1ba0eda7dbc1d4ab9e2b09b..9a9541dcfbf9af23bc0aed0fe0ea3f39005a7a93 100644
(file)
--- a/
lunaix-os/hal/acpi/parser/mcfg_parser.c
+++ b/
lunaix-os/hal/acpi/parser/mcfg_parser.c
@@
-10,7
+10,7
@@
mcfg_parse(acpi_sdthdr_t* mcfg, acpi_context* toc)
size_t alloc_num = (mcfg->length - sizeof(acpi_sdthdr_t) - 8) /
sizeof(struct acpi_mcfg_alloc);
struct acpi_mcfg_alloc* allocs =
size_t alloc_num = (mcfg->length - sizeof(acpi_sdthdr_t) - 8) /
sizeof(struct acpi_mcfg_alloc);
struct acpi_mcfg_alloc* allocs =
- (struct acpi_mcfg_alloc*)((
uint
ptr_t)mcfg + (sizeof(acpi_sdthdr_t) + 8));
+ (struct acpi_mcfg_alloc*)((ptr_t)mcfg + (sizeof(acpi_sdthdr_t) + 8));
toc->mcfg.alloc_num = alloc_num;
toc->mcfg.allocations = valloc(sizeof(struct mcfg_alloc_info) * alloc_num);
toc->mcfg.alloc_num = alloc_num;
toc->mcfg.allocations = valloc(sizeof(struct mcfg_alloc_info) * alloc_num);
diff --git
a/lunaix-os/hal/ahci/ahci.c
b/lunaix-os/hal/ahci/ahci.c
index c12244ecec6b9379b392fb1ad5a3a413538486fc..249b6992cfbd119dd57b6e88ceacf7a8991d8e8e 100644
(file)
--- a/
lunaix-os/hal/ahci/ahci.c
+++ b/
lunaix-os/hal/ahci/ahci.c
@@
-73,7
+73,7
@@
__hba_reset_port(hba_reg_t* port_reg)
}
// 如果port未响应,则继续执行重置
port_reg[HBA_RPxSCTL] = (port_reg[HBA_RPxSCTL] & ~0xf) | 1;
}
// 如果port未响应,则继续执行重置
port_reg[HBA_RPxSCTL] = (port_reg[HBA_RPxSCTL] & ~0xf) | 1;
- io_delay(100000); //等待至少一毫秒,差不多就行了
+ io_delay(100000); //
等待至少一毫秒,差不多就行了
port_reg[HBA_RPxSCTL] &= ~0xf;
}
port_reg[HBA_RPxSCTL] &= ~0xf;
}
@@
-128,7
+128,9
@@
ahci_driver_init(struct pci_device* ahci_dev)
hba->ports_bmp = pmap;
/* ------ HBA端口配置 ------ */
hba->ports_bmp = pmap;
/* ------ HBA端口配置 ------ */
- uintptr_t clb_pg_addr, fis_pg_addr, clb_pa, fis_pa;
+ ptr_t clb_pg_addr = 0, fis_pg_addr = 0;
+ ptr_t clb_pa = 0, fis_pa = 0;
+
for (size_t i = 0, fisp = 0, clbp = 0; i < 32;
i++, pmap >>= 1, fisp = (fisp + 1) % 16, clbp = (clbp + 1) % 4) {
if (!(pmap & 0x1)) {
for (size_t i = 0, fisp = 0, clbp = 0; i < 32;
i++, pmap >>= 1, fisp = (fisp + 1) % 16, clbp = (clbp + 1) % 4) {
if (!(pmap & 0x1)) {
@@
-147,25
+149,27
@@
ahci_driver_init(struct pci_device* ahci_dev)
if (!clbp) {
// 每页最多4个命令队列
clb_pa = pmm_alloc_page(KERNEL_PID, PP_FGLOCKED);
if (!clbp) {
// 每页最多4个命令队列
clb_pa = pmm_alloc_page(KERNEL_PID, PP_FGLOCKED);
- clb_pg_addr = ioremap(clb_pa, 0x1000);
- memset(clb_pg_addr, 0, 0x1000);
+ clb_pg_addr =
(ptr_t)
ioremap(clb_pa, 0x1000);
+ memset(
(void*)
clb_pg_addr, 0, 0x1000);
}
if (!fisp) {
// 每页最多16个FIS
fis_pa = pmm_alloc_page(KERNEL_PID, PP_FGLOCKED);
}
if (!fisp) {
// 每页最多16个FIS
fis_pa = pmm_alloc_page(KERNEL_PID, PP_FGLOCKED);
- fis_pg_addr = ioremap(fis_pa, 0x1000);
- memset(fis_pg_addr, 0, 0x1000);
+ fis_pg_addr =
(ptr_t)
ioremap(fis_pa, 0x1000);
+ memset(
(void*)
fis_pg_addr, 0, 0x1000);
}
/* 重定向CLB与FIS */
port_regs[HBA_RPxCLB] = clb_pa + clbp * HBA_CLB_SIZE;
port_regs[HBA_RPxFB] = fis_pa + fisp * HBA_FIS_SIZE;
}
/* 重定向CLB与FIS */
port_regs[HBA_RPxCLB] = clb_pa + clbp * HBA_CLB_SIZE;
port_regs[HBA_RPxFB] = fis_pa + fisp * HBA_FIS_SIZE;
- *port = (struct hba_port){ .regs = port_regs,
- .ssts = port_regs[HBA_RPxSSTS],
- .cmdlst = clb_pg_addr + clbp * HBA_CLB_SIZE,
- .fis = fis_pg_addr + fisp * HBA_FIS_SIZE,
- .hba = hba };
+ *port = (struct hba_port){
+ .regs = port_regs,
+ .ssts = port_regs[HBA_RPxSSTS],
+ .cmdlst = (struct hba_cmdh*)(clb_pg_addr + clbp * HBA_CLB_SIZE),
+ .fis = (void*)(fis_pg_addr + fisp * HBA_FIS_SIZE),
+ .hba = hba
+ };
/* 初始化端口,并置于就绪状态 */
port_regs[HBA_RPxCI] = 0;
/* 初始化端口,并置于就绪状态 */
port_regs[HBA_RPxCI] = 0;
@@
-226,9
+230,9
@@
__get_free_slot(struct hba_port* port)
void
sata_create_fis(struct sata_reg_fis* cmd_fis,
void
sata_create_fis(struct sata_reg_fis* cmd_fis,
- u
int
8_t command,
-
uint64
_t lba,
- u
int
16_t sector_count)
+ u8_t command,
+
lba
_t lba,
+ u16_t sector_count)
{
cmd_fis->head.type = SATA_REG_FIS_H2D;
cmd_fis->head.options = SATA_REG_FIS_COMMAND;
{
cmd_fis->head.type = SATA_REG_FIS_H2D;
cmd_fis->head.options = SATA_REG_FIS_COMMAND;
@@
-249,10
+253,13
@@
sata_create_fis(struct sata_reg_fis* cmd_fis,
int
hba_bind_sbuf(struct hba_cmdh* cmdh, struct hba_cmdt* cmdt, struct membuf mbuf)
{
int
hba_bind_sbuf(struct hba_cmdh* cmdh, struct hba_cmdt* cmdt, struct membuf mbuf)
{
- assert_msg(mbuf.size <= 0x400000, "HBA: Buffer too big");
+ assert_msg(mbuf.size <= 0x400000
U
, "HBA: Buffer too big");
cmdh->prdt_len = 1;
cmdh->prdt_len = 1;
- cmdt->entries[0] = (struct hba_prdte){ .data_base = vmm_v2p(mbuf.buffer),
- .byte_count = mbuf.size - 1 };
+ cmdt->entries[0] =
+ (struct hba_prdte){ .data_base = vmm_v2p((ptr_t)mbuf.buffer),
+ .byte_count = mbuf.size - 1 };
+
+ return 0;
}
int
}
int
@@
-263,15
+270,17
@@
hba_bind_vbuf(struct hba_cmdh* cmdh, struct hba_cmdt* cmdt, struct vecbuf* vbuf)
do {
assert_msg(i < HBA_MAX_PRDTE, "HBA: Too many PRDTEs");
do {
assert_msg(i < HBA_MAX_PRDTE, "HBA: Too many PRDTEs");
- assert_msg(pos->buf.size <= 0x400000, "HBA: Buffer too big");
+ assert_msg(pos->buf.size <= 0x400000
U
, "HBA: Buffer too big");
cmdt->entries[i++] =
cmdt->entries[i++] =
- (struct hba_prdte){ .data_base = vmm_v2p(pos->buf.buffer),
+ (struct hba_prdte){ .data_base = vmm_v2p(
(ptr_t)
pos->buf.buffer),
.byte_count = pos->buf.size - 1 };
pos = list_entry(pos->components.next, struct vecbuf, components);
} while (pos != vbuf);
cmdh->prdt_len = i + 1;
.byte_count = pos->buf.size - 1 };
pos = list_entry(pos->components.next, struct vecbuf, components);
} while (pos != vbuf);
cmdh->prdt_len = i + 1;
+
+ return 0;
}
int
}
int
@@
-289,7
+298,7
@@
hba_prepare_cmd(struct hba_port* port,
memset(cmd_header, 0, sizeof(*cmd_header));
// 将命令表挂到命令头上
memset(cmd_header, 0, sizeof(*cmd_header));
// 将命令表挂到命令头上
- cmd_header->cmd_table_base = vmm_v2p(cmd_table);
+ cmd_header->cmd_table_base = vmm_v2p(
(ptr_t)
cmd_table);
cmd_header->options =
HBA_CMDH_FIS_LEN(sizeof(struct sata_reg_fis)) | HBA_CMDH_CLR_BUSY;
cmd_header->options =
HBA_CMDH_FIS_LEN(sizeof(struct sata_reg_fis)) | HBA_CMDH_CLR_BUSY;
@@
-310,7
+319,7
@@
ahci_init_device(struct hba_port* port)
port->regs[HBA_RPxIE] &= ~HBA_MY_IE;
// 预备DMA接收缓存,用于存放HBA传回的数据
port->regs[HBA_RPxIE] &= ~HBA_MY_IE;
// 预备DMA接收缓存,用于存放HBA传回的数据
- u
int16_t* data_in = (uint
16_t*)valloc_dma(512);
+ u
16_t* data_in = (u
16_t*)valloc_dma(512);
int slot = hba_prepare_cmd(port, &cmd_table, &cmd_header);
hba_bind_sbuf(
int slot = hba_prepare_cmd(port, &cmd_table, &cmd_header);
hba_bind_sbuf(
diff --git
a/lunaix-os/hal/ahci/ata.c
b/lunaix-os/hal/ahci/ata.c
index de59eb93f0d8cd741e27d84307304e5f74706a10..c698348b1b7280403348818300ba15ba15c9c708 100644
(file)
--- a/
lunaix-os/hal/ahci/ata.c
+++ b/
lunaix-os/hal/ahci/ata.c
@@
-28,7
+28,7
@@
sata_submit(struct hba_device* dev, struct blkio_req* io_req)
header->options |= HBA_CMDH_WRITE * write;
header->options |= HBA_CMDH_WRITE * write;
- u
int
16_t count = ICEIL(vbuf_size(io_req->vbuf), port->device->block_size);
+ u16_t count = ICEIL(vbuf_size(io_req->vbuf), port->device->block_size);
struct sata_reg_fis* fis = (struct sata_reg_fis*)table->command_fis;
if ((port->device->flags & HBA_DEV_FEXTLBA)) {
struct sata_reg_fis* fis = (struct sata_reg_fis*)table->command_fis;
if ((port->device->flags & HBA_DEV_FEXTLBA)) {
diff --git
a/lunaix-os/hal/ahci/atapi.c
b/lunaix-os/hal/ahci/atapi.c
index 59733f0132b283db1e564851f571994872c9c80c..841ee3113a2e51bfc2b364d0279cde9b672801b9 100644
(file)
--- a/
lunaix-os/hal/ahci/atapi.c
+++ b/
lunaix-os/hal/ahci/atapi.c
@@
-11,7
+11,7
@@
void
scsi_create_packet12(struct scsi_cdb12* cdb,
void
scsi_create_packet12(struct scsi_cdb12* cdb,
- u
int
8_t opcode,
+ u8_t opcode,
u32_t lba,
u32_t alloc_size)
{
u32_t lba,
u32_t alloc_size)
{
@@
-23,8
+23,8
@@
scsi_create_packet12(struct scsi_cdb12* cdb,
void
scsi_create_packet16(struct scsi_cdb16* cdb,
void
scsi_create_packet16(struct scsi_cdb16* cdb,
- u
int
8_t opcode,
-
uint64
_t lba,
+ u8_t opcode,
+
lba
_t lba,
u32_t alloc_size)
{
memset(cdb, 0, sizeof(*cdb));
u32_t alloc_size)
{
memset(cdb, 0, sizeof(*cdb));
@@
-38,8
+38,8
@@
void
scsi_parse_capacity(struct hba_device* device, u32_t* parameter)
{
if (device->cbd_size == SCSI_CDB16) {
scsi_parse_capacity(struct hba_device* device, u32_t* parameter)
{
if (device->cbd_size == SCSI_CDB16) {
- device->max_lba =
-
SCSI_FLIP(*(parameter + 1)) | (
SCSI_FLIP(*parameter) << 32);
+ device->max_lba =
(lba_t)SCSI_FLIP(*(parameter + 1)) |
+
((lba_t)
SCSI_FLIP(*parameter) << 32);
device->block_size = SCSI_FLIP(*(parameter + 2));
} else {
// for READ_CAPACITY(10)
device->block_size = SCSI_FLIP(*(parameter + 2));
} else {
// for READ_CAPACITY(10)
@@
-82,7
+82,7
@@
scsi_submit(struct hba_device* dev, struct blkio_req* io_req)
}
// field: cdb->misc1
}
// field: cdb->misc1
- *((u
int
8_t*)cdb + 1) = 3 << 5; // RPROTECT=011b 禁用保护检查
+ *((u8_t*)cdb + 1) = 3 << 5; // RPROTECT=011b 禁用保护检查
// The async way...
struct hba_cmd_state* cmds = valloc(sizeof(struct hba_cmd_state));
// The async way...
struct hba_cmd_state* cmds = valloc(sizeof(struct hba_cmd_state));
diff --git
a/lunaix-os/hal/ahci/io_event.c
b/lunaix-os/hal/ahci/io_event.c
index c1bd6a5ad2f2cc9465aac2ab52beec962314c99c..bb3142b37aefedc6749835460d61b6bba80a4afa 100644
(file)
--- a/
lunaix-os/hal/ahci/io_event.c
+++ b/
lunaix-os/hal/ahci/io_event.c
@@
-15,7
+15,7
@@
__ahci_hba_isr(const isr_param* param)
struct ahci_driver *pos, *n;
llist_for_each(pos, n, &ahcis, ahci_drvs)
{
struct ahci_driver *pos, *n;
llist_for_each(pos, n, &ahcis, ahci_drvs)
{
- if (pos->id == param->execp->vector) {
+ if (pos->id ==
(int)
param->execp->vector) {
hba = &pos->hba;
goto proceed;
}
hba = &pos->hba;
goto proceed;
}
diff --git
a/lunaix-os/hal/ahci/utils.c
b/lunaix-os/hal/ahci/utils.c
index 923f916d78e52f1ccf0113ca712132c2c321134c..8c39971ee15a9c33901b46fe6e66ffc3b142e11a 100644
(file)
--- a/
lunaix-os/hal/ahci/utils.c
+++ b/
lunaix-os/hal/ahci/utils.c
@@
-21,12
+21,12
@@
static u32_t cdb_size[] = { SCSI_CDB12, SCSI_CDB16, 0, 0 };
void
static u32_t cdb_size[] = { SCSI_CDB12, SCSI_CDB16, 0, 0 };
void
-ahci_parse_dev_info(struct hba_device* dev_info, u
int
16_t* data)
+ahci_parse_dev_info(struct hba_device* dev_info, u16_t* data)
{
dev_info->max_lba = *((u32_t*)(data + IDDEV_OFFMAXLBA));
dev_info->block_size = *((u32_t*)(data + IDDEV_OFFLSECSIZE));
dev_info->cbd_size = cdb_size[(*data & 0x3)];
{
dev_info->max_lba = *((u32_t*)(data + IDDEV_OFFMAXLBA));
dev_info->block_size = *((u32_t*)(data + IDDEV_OFFLSECSIZE));
dev_info->cbd_size = cdb_size[(*data & 0x3)];
- dev_info->wwn = *(u
int
64_t*)(data + IDDEV_OFFWWN);
+ dev_info->wwn = *(u64_t*)(data + IDDEV_OFFWWN);
dev_info->block_per_sec = 1 << (*(data + IDDEV_OFFLPP) & 0xf);
dev_info->alignment_offset = *(data + IDDEV_OFFALIGN) & 0x3fff;
dev_info->capabilities = *((u32_t*)(data + IDDEV_OFFCAPABILITIES));
dev_info->block_per_sec = 1 << (*(data + IDDEV_OFFLPP) & 0xf);
dev_info->alignment_offset = *(data + IDDEV_OFFALIGN) & 0x3fff;
dev_info->capabilities = *((u32_t*)(data + IDDEV_OFFCAPABILITIES));
@@
-37,7
+37,7
@@
ahci_parse_dev_info(struct hba_device* dev_info, uint16_t* data)
if ((*(data + IDDEV_OFFADDSUPPORT) & 0x8) &&
(*(data + IDDEV_OFFA48SUPPORT) & 0x400)) {
if ((*(data + IDDEV_OFFADDSUPPORT) & 0x8) &&
(*(data + IDDEV_OFFA48SUPPORT) & 0x400)) {
- dev_info->max_lba = *((
uint64
_t*)(data + IDDEV_OFFMAXLBA_EXT));
+ dev_info->max_lba = *((
lba
_t*)(data + IDDEV_OFFMAXLBA_EXT));
dev_info->flags |= HBA_DEV_FEXTLBA;
}
dev_info->flags |= HBA_DEV_FEXTLBA;
}
@@
-46,11
+46,11
@@
ahci_parse_dev_info(struct hba_device* dev_info, uint16_t* data)
}
void
}
void
-ahci_parsestr(char* str, u
int
16_t* reg_start, int size_word)
+ahci_parsestr(char* str, u16_t* reg_start, int size_word)
{
int j = 0;
for (int i = 0; i < size_word; i++, j += 2) {
{
int j = 0;
for (int i = 0; i < size_word; i++, j += 2) {
- u
int
16_t reg = *(reg_start + i);
+ u16_t reg = *(reg_start + i);
str[j] = (char)(reg >> 8);
str[j + 1] = (char)(reg & 0xff);
}
str[j] = (char)(reg >> 8);
str[j + 1] = (char)(reg & 0xff);
}
diff --git
a/lunaix-os/hal/apic.c
b/lunaix-os/hal/apic.c
index 2f5b5be02afe5c092c16242a1c41bd8660bd2ceb..44385a475ca9b28ad020aff07ae0fbecec9f583c 100644
(file)
--- a/
lunaix-os/hal/apic.c
+++ b/
lunaix-os/hal/apic.c
@@
-39,7
+39,7
@@
apic_init()
// As we are going to use APIC, disable the old 8259 PIC
pic_disable();
// As we are going to use APIC, disable the old 8259 PIC
pic_disable();
- _apic_base = ioremap(__APIC_BASE_PADDR, 4096);
+ _apic_base =
(ptr_t)
ioremap(__APIC_BASE_PADDR, 4096);
// Hardware enable the APIC
// By setting bit 11 of IA32_APIC_BASE register
// Hardware enable the APIC
// By setting bit 11 of IA32_APIC_BASE register
diff --git
a/lunaix-os/hal/cpu.c
b/lunaix-os/hal/cpu.c
index b8a5e9b422f510dda9e226de403616606b6f7ccf..77059b603ba51009622921a1329ee3b737c23b4e 100644
(file)
--- a/
lunaix-os/hal/cpu.c
+++ b/
lunaix-os/hal/cpu.c
@@
-75,7
+75,7
@@
cpu_wrmsr(u32_t msr_idx, u32_t reg_high, u32_t reg_low)
int
rnd_is_supported()
{
int
rnd_is_supported()
{
- reg32 eax
, ebx, ecx, edx
;
+ reg32 eax
= 0, ebx = 0, ecx = 0, edx = 0
;
__get_cpuid(0x01, &eax, &ebx, &ecx, &edx);
return (ecx & (1 << 30));
}
\ No newline at end of file
__get_cpuid(0x01, &eax, &ebx, &ecx, &edx);
return (ecx & (1 << 30));
}
\ No newline at end of file
diff --git
a/lunaix-os/hal/ioapic.c
b/lunaix-os/hal/ioapic.c
index 004f889b18514c8d4a1abbc8e8ee32746010ee7f..3e64f524c8ef02b3768f11a0d937a3407909d46b 100644
(file)
--- a/
lunaix-os/hal/ioapic.c
+++ b/
lunaix-os/hal/ioapic.c
@@
-7,7
+7,7
@@
#define IOAPIC_REG_SEL *((volatile u32_t*)(_ioapic_base + IOAPIC_IOREGSEL))
#define IOAPIC_REG_WIN *((volatile u32_t*)(_ioapic_base + IOAPIC_IOWIN))
#define IOAPIC_REG_SEL *((volatile u32_t*)(_ioapic_base + IOAPIC_IOREGSEL))
#define IOAPIC_REG_WIN *((volatile u32_t*)(_ioapic_base + IOAPIC_IOWIN))
-static volatile
uint
ptr_t _ioapic_base;
+static volatile ptr_t _ioapic_base;
void
ioapic_init()
void
ioapic_init()
@@
-16,27
+16,28
@@
ioapic_init()
acpi_context* acpi_ctx = acpi_get_context();
acpi_context* acpi_ctx = acpi_get_context();
- _ioapic_base = ioremap(acpi_ctx->madt.ioapic->ioapic_addr & ~0xfff, 4096);
+ _ioapic_base =
+ (ptr_t)ioremap(acpi_ctx->madt.ioapic->ioapic_addr & ~0xfff, 4096);
}
void
}
void
-ioapic_write(u
int
8_t sel, u32_t val)
+ioapic_write(u8_t sel, u32_t val)
{
IOAPIC_REG_SEL = sel;
IOAPIC_REG_WIN = val;
}
u32_t
{
IOAPIC_REG_SEL = sel;
IOAPIC_REG_WIN = val;
}
u32_t
-ioapic_read(u
int
8_t sel)
+ioapic_read(u8_t sel)
{
IOAPIC_REG_SEL = sel;
return IOAPIC_REG_WIN;
}
void
{
IOAPIC_REG_SEL = sel;
return IOAPIC_REG_WIN;
}
void
-ioapic_redirect(u
int8_t irq, uint8_t vector, uint
8_t dest, u32_t flags)
+ioapic_redirect(u
8_t irq, u8_t vector, u
8_t dest, u32_t flags)
{
{
- u
int
8_t reg_sel = IOAPIC_IOREDTBL_BASE + irq * 2;
+ u8_t reg_sel = IOAPIC_IOREDTBL_BASE + irq * 2;
// Write low 32 bits
ioapic_write(reg_sel, (vector | flags) & 0x1FFFF);
// Write low 32 bits
ioapic_write(reg_sel, (vector | flags) & 0x1FFFF);
diff --git
a/lunaix-os/hal/pci.c
b/lunaix-os/hal/pci.c
index 8969224502e492c4141220c5b8f87be4772695e8..96cd676de3ef790de0e26b21fcbf42c66b8333f2 100644
(file)
--- a/
lunaix-os/hal/pci.c
+++ b/
lunaix-os/hal/pci.c
@@
-292,7
+292,7
@@
pci_setup_msi(struct pci_device* device, int vector)
}
struct pci_device*
}
struct pci_device*
-pci_get_device_by_id(u
int16_t vendorId, uint
16_t deviceId)
+pci_get_device_by_id(u
16_t vendorId, u
16_t deviceId)
{
u32_t dev_info = vendorId | (deviceId << 16);
struct pci_device *pos, *n;
{
u32_t dev_info = vendorId | (deviceId << 16);
struct pci_device *pos, *n;
diff --git
a/lunaix-os/hal/rtc.c
b/lunaix-os/hal/rtc.c
index 2ffe76b14e2b4bf6c41e4bdc63072b417feca3bc..bc2c2ef497ab2e7e33a01a179c3b427a7ef08515 100644
(file)
--- a/
lunaix-os/hal/rtc.c
+++ b/
lunaix-os/hal/rtc.c
@@
-13,7
+13,7
@@
void
rtc_init() {
void
rtc_init() {
- u
int
8_t regA = rtc_read_reg(RTC_REG_A | WITH_NMI_DISABLED);
+ u8_t regA = rtc_read_reg(RTC_REG_A | WITH_NMI_DISABLED);
regA = (regA & ~0x7f) | RTC_FREQUENCY_1024HZ | RTC_DIVIDER_33KHZ;
rtc_write_reg(RTC_REG_A | WITH_NMI_DISABLED, regA);
regA = (regA & ~0x7f) | RTC_FREQUENCY_1024HZ | RTC_DIVIDER_33KHZ;
rtc_write_reg(RTC_REG_A | WITH_NMI_DISABLED, regA);
@@
-21,22
+21,22
@@
rtc_init() {
rtc_disable_timer();
}
rtc_disable_timer();
}
-u
int
8_t
-rtc_read_reg(u
int
8_t reg_selector)
+u8_t
+rtc_read_reg(u8_t reg_selector)
{
io_outb(RTC_INDEX_PORT, reg_selector);
return io_inb(RTC_TARGET_PORT);
}
void
{
io_outb(RTC_INDEX_PORT, reg_selector);
return io_inb(RTC_TARGET_PORT);
}
void
-rtc_write_reg(u
int8_t reg_selector, uint
8_t val)
+rtc_write_reg(u
8_t reg_selector, u
8_t val)
{
io_outb(RTC_INDEX_PORT, reg_selector);
io_outb(RTC_TARGET_PORT, val);
}
{
io_outb(RTC_INDEX_PORT, reg_selector);
io_outb(RTC_TARGET_PORT, val);
}
-u
int
8_t
-bcd2dec(u
int
8_t bcd)
+u8_t
+bcd2dec(u8_t bcd)
{
return ((bcd & 0xF0) >> 1) + ((bcd & 0xF0) >> 3) + (bcd & 0xf);
}
{
return ((bcd & 0xF0) >> 1) + ((bcd & 0xF0) >> 3) + (bcd & 0xf);
}
@@
-44,12
+44,12
@@
bcd2dec(uint8_t bcd)
void
rtc_enable_timer() {
void
rtc_enable_timer() {
- u
int
8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED);
+ u8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED);
rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB | RTC_TIMER_ON);
}
void
rtc_disable_timer() {
rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB | RTC_TIMER_ON);
}
void
rtc_disable_timer() {
- u
int
8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED);
+ u8_t regB = rtc_read_reg(RTC_REG_B | WITH_NMI_DISABLED);
rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB & ~RTC_TIMER_ON);
}
\ No newline at end of file
rtc_write_reg(RTC_REG_B | WITH_NMI_DISABLED, regB & ~RTC_TIMER_ON);
}
\ No newline at end of file
diff --git
a/lunaix-os/includes/arch/x86/interrupts.h
b/lunaix-os/includes/arch/x86/interrupts.h
index f1684a8ad1398d52919a4a28d41c01457ecfb886..6d3c4b1183f1b8bec5be4d5f981b9f15338ac106 100644
(file)
--- a/
lunaix-os/includes/arch/x86/interrupts.h
+++ b/
lunaix-os/includes/arch/x86/interrupts.h
@@
-36,13
+36,13
@@
typedef struct
struct exec_param
{
isr_param saved_prev_ctx;
struct exec_param
{
isr_param saved_prev_ctx;
- u
nsigned in
t vector;
- u
nsigned in
t err_code;
- u
nsigned in
t eip;
- u
nsigned in
t cs;
- u
nsigned in
t eflags;
- u
nsigned in
t esp;
- u
nsigned in
t ss;
+ u
32_
t vector;
+ u
32_
t err_code;
+ u
32_
t eip;
+ u
32_
t cs;
+ u
32_
t eflags;
+ u
32_
t esp;
+ u
32_
t ss;
} __attribute__((packed));
#define ISR_PARAM_SIZE sizeof(isr_param)
} __attribute__((packed));
#define ISR_PARAM_SIZE sizeof(isr_param)
diff --git
a/lunaix-os/includes/arch/x86/tss.h
b/lunaix-os/includes/arch/x86/tss.h
index 6643344f9955019b1b71d1bbf2ea4b8d970954bd..c2a25351ff53bfecbdc6abdc0bd2fc56da33eb1e 100644
(file)
--- a/
lunaix-os/includes/arch/x86/tss.h
+++ b/
lunaix-os/includes/arch/x86/tss.h
@@
-6,8
+6,8
@@
struct x86_tss
{
u32_t link;
u32_t esp0;
{
u32_t link;
u32_t esp0;
- u
int
16_t ss0;
- u
int
8_t __padding[94];
+ u16_t ss0;
+ u8_t __padding[94];
} __attribute__((packed));
void
} __attribute__((packed));
void
diff --git
a/lunaix-os/includes/hal/acpi/acpi.h
b/lunaix-os/includes/hal/acpi/acpi.h
index a8d18bf7f86565595b7180a74e305d305aacaad9..0e93f20d4ceb7386f67b746a7a047a1b43640df2 100644
(file)
--- a/
lunaix-os/includes/hal/acpi/acpi.h
+++ b/
lunaix-os/includes/hal/acpi/acpi.h
@@
-26,14
+26,14
@@
typedef struct
{
u32_t signature_l;
u32_t signature_h;
{
u32_t signature_l;
u32_t signature_h;
- u
int
8_t chksum;
+ u8_t chksum;
char oem_id[6];
// Revision
char oem_id[6];
// Revision
- u
int
8_t rev;
+ u8_t rev;
acpi_rsdt_t* rsdt;
u32_t length;
acpi_sdthdr_t* xsdt;
acpi_rsdt_t* rsdt;
u32_t length;
acpi_sdthdr_t* xsdt;
- u
int
8_t x_chksum;
+ u8_t x_chksum;
char reserved[3]; // Reserved field
} __attribute__((packed)) acpi_rsdp_t;
char reserved[3]; // Reserved field
} __attribute__((packed)) acpi_rsdp_t;
@@
-56,7
+56,7
@@
acpi_init(multiboot_info_t* mb_info);
acpi_context*
acpi_get_context();
acpi_context*
acpi_get_context();
-u
int
8_t
-acpi_gistranslate(u
int
8_t old_irq);
+u8_t
+acpi_gistranslate(u8_t old_irq);
#endif /* __LUNAIX_ACPI_ACPI_H */
#endif /* __LUNAIX_ACPI_ACPI_H */
diff --git
a/lunaix-os/includes/hal/acpi/fadt.h
b/lunaix-os/includes/hal/acpi/fadt.h
index 21251e616600d9a6add96b5b7aee8568cfa9b2ab..339486d9d1678ec1d9d1ffb7c911c3c0a3ae355b 100644
(file)
--- a/
lunaix-os/includes/hal/acpi/fadt.h
+++ b/
lunaix-os/includes/hal/acpi/fadt.h
@@
-45,30
+45,30
@@
typedef struct acpi_fadt
acpi_sdthdr_t header;
u32_t firmware_controller_addr;
u32_t dsdt_addr;
acpi_sdthdr_t header;
u32_t firmware_controller_addr;
u32_t dsdt_addr;
- u
int
8_t reserved;
- u
int
8_t pm_profile;
- u
int
16_t sci_int;
+ u8_t reserved;
+ u8_t pm_profile;
+ u16_t sci_int;
u32_t smi_cmd_port_addr;
u32_t smi_cmd_port_addr;
- u
int
8_t smi_acpi_enable;
- u
int
8_t smi_acpi_disable;
- u
int
8_t smi_s4bios_state;
- u
int
8_t smi_pstate;
+ u8_t smi_acpi_enable;
+ u8_t smi_acpi_disable;
+ u8_t smi_s4bios_state;
+ u8_t smi_pstate;
u32_t pm_reg_ports[6];
u32_t gpe0_port_addr;
u32_t gpe1_port_addr;
u32_t pm_reg_ports[6];
u32_t gpe0_port_addr;
u32_t gpe1_port_addr;
- u
int
8_t pm_reg_lens[4];
- u
int
8_t gpe0_len;
- u
int
8_t gpe1_len;
- u
int
8_t gpe1_base;
- u
int
8_t cst_cnt;
- u
int
16_t p_lvl2_lat;
- u
int
16_t p_lvl3_lat;
- u
int
16_t flush_size;
- u
int
16_t flush_stride;
- u
int
8_t duty_offset;
- u
int
8_t duty_width;
- u
int
8_t time_info[3];
- u
int
16_t boot_arch;
+ u8_t pm_reg_lens[4];
+ u8_t gpe0_len;
+ u8_t gpe1_len;
+ u8_t gpe1_base;
+ u8_t cst_cnt;
+ u16_t p_lvl2_lat;
+ u16_t p_lvl3_lat;
+ u16_t flush_size;
+ u16_t flush_stride;
+ u8_t duty_offset;
+ u8_t duty_width;
+ u8_t time_info[3];
+ u16_t boot_arch;
} ACPI_TABLE_PACKED acpi_fadt_t;
// TODO: FADT parser & support
} ACPI_TABLE_PACKED acpi_fadt_t;
// TODO: FADT parser & support
diff --git
a/lunaix-os/includes/hal/acpi/madt.h
b/lunaix-os/includes/hal/acpi/madt.h
index 1dd0bca4015c61c5c7f0774fc25da0a15c4622b0..538e521837e12167c2fb25bfa53f5f60f2b75c9a 100644
(file)
--- a/
lunaix-os/includes/hal/acpi/madt.h
+++ b/
lunaix-os/includes/hal/acpi/madt.h
@@
-13,8
+13,8
@@
*/
typedef struct
{
*/
typedef struct
{
- u
int
8_t type;
- u
int
8_t length;
+ u8_t type;
+ u8_t length;
} ACPI_TABLE_PACKED acpi_ics_hdr_t;
/**
} ACPI_TABLE_PACKED acpi_ics_hdr_t;
/**
@@
-26,8
+26,8
@@
typedef struct
typedef struct
{
acpi_ics_hdr_t header;
typedef struct
{
acpi_ics_hdr_t header;
- u
int
8_t processor_id;
- u
int
8_t apic_id;
+ u8_t processor_id;
+ u8_t apic_id;
u32_t flags;
} ACPI_TABLE_PACKED acpi_apic_t;
u32_t flags;
} ACPI_TABLE_PACKED acpi_apic_t;
@@
-41,8
+41,8
@@
typedef struct
typedef struct
{
acpi_ics_hdr_t header;
typedef struct
{
acpi_ics_hdr_t header;
- u
int
8_t ioapic_id;
- u
int
8_t reserved;
+ u8_t ioapic_id;
+ u8_t reserved;
u32_t ioapic_addr;
// The global system interrupt offset for this IOAPIC. (Kind of IRQ offset
// for a slave IOAPIC)
u32_t ioapic_addr;
// The global system interrupt offset for this IOAPIC. (Kind of IRQ offset
// for a slave IOAPIC)
@@
-61,13
+61,13
@@
typedef struct
typedef struct
{
acpi_ics_hdr_t header;
typedef struct
{
acpi_ics_hdr_t header;
- u
int
8_t bus;
+ u8_t bus;
// source, which is the original IRQ back in the era of IBM PC/AT, the 8259
// PIC
// source, which is the original IRQ back in the era of IBM PC/AT, the 8259
// PIC
- u
int
8_t source;
+ u8_t source;
// global system interrupt. The override of source in APIC mode
u32_t gsi;
// global system interrupt. The override of source in APIC mode
u32_t gsi;
- u
int
16_t flags;
+ u16_t flags;
} ACPI_TABLE_PACKED acpi_intso_t;
typedef struct
} ACPI_TABLE_PACKED acpi_intso_t;
typedef struct
diff --git
a/lunaix-os/includes/hal/acpi/mcfg.h
b/lunaix-os/includes/hal/acpi/mcfg.h
index 5a40f26ac171e11aaf755c8c36c8788c616c44b9..c13abaf99af9ada0ab31c6ea42733477ec3453e8 100644
(file)
--- a/
lunaix-os/includes/hal/acpi/mcfg.h
+++ b/
lunaix-os/includes/hal/acpi/mcfg.h
@@
-7,18
+7,18
@@
struct acpi_mcfg_alloc
{
u32_t base_addr_lo;
u32_t base_addr_hi;
{
u32_t base_addr_lo;
u32_t base_addr_hi;
- u
int
16_t pci_seg_num;
- u
int
8_t pci_bus_start;
- u
int
8_t pci_bus_end;
+ u16_t pci_seg_num;
+ u8_t pci_bus_start;
+ u8_t pci_bus_end;
u32_t reserve;
} ACPI_TABLE_PACKED;
struct mcfg_alloc_info
{
u32_t base_addr;
u32_t reserve;
} ACPI_TABLE_PACKED;
struct mcfg_alloc_info
{
u32_t base_addr;
- u
int
16_t pci_seg_num;
- u
int
8_t pci_bus_start;
- u
int
8_t pci_bus_end;
+ u16_t pci_seg_num;
+ u8_t pci_bus_start;
+ u8_t pci_bus_end;
};
struct acpi_mcfg_toc
};
struct acpi_mcfg_toc
diff --git
a/lunaix-os/includes/hal/acpi/sdt.h
b/lunaix-os/includes/hal/acpi/sdt.h
index e5b1d11d233d7c56d84a713d88c3cfc27a2deb2b..b055aa3a3349375c1a67cccbe8736e67f8c88120 100644
(file)
--- a/
lunaix-os/includes/hal/acpi/sdt.h
+++ b/
lunaix-os/includes/hal/acpi/sdt.h
@@
-10,8
+10,8
@@
typedef struct acpi_sdthdr
u32_t signature;
u32_t length;
// Revision
u32_t signature;
u32_t length;
// Revision
- u
int
8_t rev;
- u
int
8_t chksum;
+ u8_t rev;
+ u8_t chksum;
char oem_id[6];
char oem_table_id[8];
u32_t oem_rev;
char oem_id[6];
char oem_table_id[8];
u32_t oem_rev;
diff --git
a/lunaix-os/includes/hal/ahci/ahci.h
b/lunaix-os/includes/hal/ahci/ahci.h
index 2ed135aba3d00a14f287b2c90a2a7b998337d4cf..fd22ffabe0eec9d2d6c3e6ff23e40cc31734a3a7 100644
(file)
--- a/
lunaix-os/includes/hal/ahci/ahci.h
+++ b/
lunaix-os/includes/hal/ahci/ahci.h
@@
-29,10
+29,10
@@
void
ahci_init();
void
ahci_init();
void
-ahci_parse_dev_info(struct hba_device* dev_info, u
int
16_t* data);
+ahci_parse_dev_info(struct hba_device* dev_info, u16_t* data);
void
void
-ahci_parsestr(char* str, u
int
16_t* reg_start, int size_word);
+ahci_parsestr(char* str, u16_t* reg_start, int size_word);
/**
* @brief Issue a HBA command (synchronized)
/**
* @brief Issue a HBA command (synchronized)
diff --git
a/lunaix-os/includes/hal/ahci/hba.h
b/lunaix-os/includes/hal/ahci/hba.h
index f6c63922f2d8c43c0dbf62e57d7131af55ebc84c..c3966281b6c919aaee943b5df3da8e7dd66e6516 100644
(file)
--- a/
lunaix-os/includes/hal/ahci/hba.h
+++ b/
lunaix-os/includes/hal/ahci/hba.h
@@
-79,8
+79,8
@@
typedef unsigned int hba_reg_t;
struct hba_cmdh
{
struct hba_cmdh
{
- u
int
16_t options;
- u
int
16_t prdt_len;
+ u16_t options;
+ u16_t prdt_len;
u32_t transferred_size;
u32_t cmd_table_base;
u32_t reserved[5];
u32_t transferred_size;
u32_t cmd_table_base;
u32_t reserved[5];
@@
-97,9
+97,9
@@
struct hba_prdte
struct hba_cmdt
{
struct hba_cmdt
{
- u
int
8_t command_fis[64];
- u
int
8_t atapi_cmd[16];
- u
int
8_t reserved[0x30];
+ u8_t command_fis[64];
+ u8_t atapi_cmd[16];
+ u8_t reserved[0x30];
struct hba_prdte entries[HBA_MAX_PRDTE];
} __HBA_PACKED__;
struct hba_prdte entries[HBA_MAX_PRDTE];
} __HBA_PACKED__;
@@
-114,16
+114,16
@@
struct hba_device
char serial_num[20];
char model[40];
u32_t flags;
char serial_num[20];
char model[40];
u32_t flags;
-
uint64
_t max_lba;
+
lba
_t max_lba;
u32_t block_size;
u32_t block_size;
- u
int
64_t wwn;
- u
int
8_t cbd_size;
+ u64_t wwn;
+ u8_t cbd_size;
struct
{
struct
{
- u
int
8_t sense_key;
- u
int
8_t error;
- u
int
8_t status;
- u
int
8_t reserve;
+ u8_t sense_key;
+ u8_t error;
+ u8_t status;
+ u8_t reserve;
} last_result;
u32_t alignment_offset;
u32_t block_per_sec;
} last_result;
u32_t alignment_offset;
u32_t block_per_sec;
diff --git
a/lunaix-os/includes/hal/ahci/sata.h
b/lunaix-os/includes/hal/ahci/sata.h
index d573a93030b9b88857fc32c0eb7fc2a88716eaa2..0edb5a3d6a7d4cf946e2fcc685222b5b1e060add 100644
(file)
--- a/
lunaix-os/includes/hal/ahci/sata.h
+++ b/
lunaix-os/includes/hal/ahci/sata.h
@@
-20,38
+20,38
@@
struct sata_fis_head
{
struct sata_fis_head
{
- u
int
8_t type;
- u
int
8_t options;
- u
int
8_t status_cmd;
- u
int
8_t feat_err;
+ u8_t type;
+ u8_t options;
+ u8_t status_cmd;
+ u8_t feat_err;
} __HBA_PACKED__;
struct sata_reg_fis
{
struct sata_fis_head head;
} __HBA_PACKED__;
struct sata_reg_fis
{
struct sata_fis_head head;
- u
int
8_t lba0, lba8, lba16;
- u
int
8_t dev;
- u
int
8_t lba24, lba32, lba40;
- u
int
8_t feature;
+ u8_t lba0, lba8, lba16;
+ u8_t dev;
+ u8_t lba24, lba32, lba40;
+ u8_t feature;
- u
int
16_t count;
+ u16_t count;
- u
int
8_t reserved[6];
+ u8_t reserved[6];
} __HBA_PACKED__;
struct sata_data_fis
{
struct sata_fis_head head;
} __HBA_PACKED__;
struct sata_data_fis
{
struct sata_fis_head head;
- u
int
8_t data[0];
+ u8_t data[0];
} __HBA_PACKED__;
void
sata_create_fis(struct sata_reg_fis* cmd_fis,
} __HBA_PACKED__;
void
sata_create_fis(struct sata_reg_fis* cmd_fis,
- u
int
8_t command,
-
uint64
_t lba,
- u
int
16_t sector_count);
+ u8_t command,
+
lba
_t lba,
+ u16_t sector_count);
void
sata_submit(struct hba_device* dev, struct blkio_req* io_req);
void
sata_submit(struct hba_device* dev, struct blkio_req* io_req);
diff --git
a/lunaix-os/includes/hal/ahci/scsi.h
b/lunaix-os/includes/hal/ahci/scsi.h
index d6582293470a59015c050912d7c36fdcc605339a..5d8d2dbb5828fa390c2716d36d737b09a89b5543 100644
(file)
--- a/
lunaix-os/includes/hal/ahci/scsi.h
+++ b/
lunaix-os/includes/hal/ahci/scsi.h
@@
-19,35
+19,35
@@
struct scsi_cdb12
{
struct scsi_cdb12
{
- u
int
8_t opcode;
- u
int
8_t misc1;
+ u8_t opcode;
+ u8_t misc1;
u32_t lba_be;
u32_t length;
u32_t lba_be;
u32_t length;
- u
int
8_t misc2;
- u
int
8_t ctrl;
+ u8_t misc2;
+ u8_t ctrl;
} __attribute__((packed));
struct scsi_cdb16
{
} __attribute__((packed));
struct scsi_cdb16
{
- u
int
8_t opcode;
- u
int
8_t misc1;
+ u8_t opcode;
+ u8_t misc1;
u32_t lba_be_hi;
u32_t lba_be_lo;
u32_t length;
u32_t lba_be_hi;
u32_t lba_be_lo;
u32_t length;
- u
int
8_t misc2;
- u
int
8_t ctrl;
+ u8_t misc2;
+ u8_t ctrl;
} __attribute__((packed));
void
scsi_create_packet12(struct scsi_cdb12* cdb,
} __attribute__((packed));
void
scsi_create_packet12(struct scsi_cdb12* cdb,
- u
int
8_t opcode,
+ u8_t opcode,
u32_t lba,
u32_t alloc_size);
void
scsi_create_packet16(struct scsi_cdb16* cdb,
u32_t lba,
u32_t alloc_size);
void
scsi_create_packet16(struct scsi_cdb16* cdb,
- u
int
8_t opcode,
-
uint64
_t lba,
+ u8_t opcode,
+
lba
_t lba,
u32_t alloc_size);
void
u32_t alloc_size);
void
diff --git
a/lunaix-os/includes/hal/cpu.h
b/lunaix-os/includes/hal/cpu.h
index ae9926b7c0e6e6bedfd8d497cea59dc9e6c67d63..93805d8b981d4220feba2d1d9d6269ff2428de00 100644
(file)
--- a/
lunaix-os/includes/hal/cpu.h
+++ b/
lunaix-os/includes/hal/cpu.h
@@
-39,7
+39,7
@@
cpu_has_apic();
static inline reg32
cpu_rcr0()
{
static inline reg32
cpu_rcr0()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr0,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr0,%0" : "=r"(val));
return val;
}
@@
-47,7
+47,7
@@
cpu_rcr0()
static inline reg32
cpu_rcr2()
{
static inline reg32
cpu_rcr2()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr2,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr2,%0" : "=r"(val));
return val;
}
@@
-55,7
+55,7
@@
cpu_rcr2()
static inline reg32
cpu_rcr3()
{
static inline reg32
cpu_rcr3()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("movl %%cr3,%0" : "=r"(val));
return val;
}
asm volatile("movl %%cr3,%0" : "=r"(val));
return val;
}
@@
-63,7
+63,7
@@
cpu_rcr3()
static inline reg32
cpu_reflags()
{
static inline reg32
cpu_reflags()
{
-
uint
ptr_t val;
+ ptr_t val;
asm volatile("pushf\n"
"popl %0\n"
: "=r"(val)::);
asm volatile("pushf\n"
"popl %0\n"
: "=r"(val)::);
@@
-90,9
+90,9
@@
cpu_lcr3(reg32 v)
}
static inline void
}
static inline void
-cpu_invplg(
void*
va)
+cpu_invplg(
ptr_t
va)
{
{
- asm volatile("invlpg (%0)" ::"r"(
(uintptr_t)
va) : "memory");
+ asm volatile("invlpg (%0)" ::"r"(va) : "memory");
}
static inline void
}
static inline void
diff --git
a/lunaix-os/includes/hal/io.h
b/lunaix-os/includes/hal/io.h
index f4f61920f4ad809b8d18821add13a0eff30c9f53..a3768cf38fa3b622c8b8c1c3d8d1c75b5188c38a 100644
(file)
--- a/
lunaix-os/includes/hal/io.h
+++ b/
lunaix-os/includes/hal/io.h
@@
-3,10
+3,10
@@
#include <lunaix/types.h>
#include <lunaix/types.h>
-static inline u
int
8_t
+static inline u8_t
io_inb(int port)
{
io_inb(int port)
{
- u
int
8_t data;
+ u8_t data;
asm volatile("inb %w1,%0" : "=a"(data) : "d"(port));
return data;
}
asm volatile("inb %w1,%0" : "=a"(data) : "d"(port));
return data;
}
@@
-22,10
+22,10
@@
io_insb(int port, void* addr, int cnt)
: "memory", "cc");
}
: "memory", "cc");
}
-static inline u
int
16_t
+static inline u16_t
io_inw(int port)
{
io_inw(int port)
{
- u
int
16_t data;
+ u16_t data;
asm volatile("inw %w1,%0" : "=a"(data) : "d"(port));
return data;
}
asm volatile("inw %w1,%0" : "=a"(data) : "d"(port));
return data;
}
@@
-61,7
+61,7
@@
io_insl(int port, void* addr, int cnt)
}
static inline void
}
static inline void
-io_outb(int port, u
int
8_t data)
+io_outb(int port, u8_t data)
{
asm volatile("outb %0, %w1" : : "a"(data), "d"(port));
}
{
asm volatile("outb %0, %w1" : : "a"(data), "d"(port));
}
@@
-78,7
+78,7
@@
io_outsb(int port, const void* addr, int cnt)
}
static inline void
}
static inline void
-io_outw(int port, u
int
16_t data)
+io_outw(int port, u16_t data)
{
asm volatile("outw %0,%w1" : : "a"(data), "d"(port));
}
{
asm volatile("outw %0,%w1" : : "a"(data), "d"(port));
}
diff --git
a/lunaix-os/includes/hal/ioapic.h
b/lunaix-os/includes/hal/ioapic.h
index ec749ef3befd357868d2ebb9d72be896cd69524f..4dccd7e7a227582e113669055f78204c3e65e9a6 100644
(file)
--- a/
lunaix-os/includes/hal/ioapic.h
+++ b/
lunaix-os/includes/hal/ioapic.h
@@
-26,12
+26,12
@@
void
ioapic_init();
void
ioapic_init();
void
-ioapic_write(u
int
8_t sel, u32_t val);
+ioapic_write(u8_t sel, u32_t val);
u32_t
u32_t
-ioapic_read(u
int
8_t sel);
+ioapic_read(u8_t sel);
void
void
-ioapic_redirect(u
int8_t irq, uint8_t vector, uint
8_t dest, u32_t flags);
+ioapic_redirect(u
8_t irq, u8_t vector, u
8_t dest, u32_t flags);
#endif /* __LUNAIX_IOAPIC_H */
#endif /* __LUNAIX_IOAPIC_H */
diff --git
a/lunaix-os/includes/hal/pci.h
b/lunaix-os/includes/hal/pci.h
index 56ca3df8810bbdd37425dcf92cdda46167c1099b..b95f89a3c4f935c19b39e3f82299b2046fd74978 100644
(file)
--- a/
lunaix-os/includes/hal/pci.h
+++ b/
lunaix-os/includes/hal/pci.h
@@
-77,7
+77,7
@@
struct pci_device
u32_t class_info;
u32_t cspace_base;
u32_t msi_loc;
u32_t class_info;
u32_t cspace_base;
u32_t msi_loc;
- u
int
16_t intr_info;
+ u16_t intr_info;
struct
{
struct pci_driver* type;
struct
{
struct pci_driver* type;
@@
-138,7
+138,7
@@
struct pci_device* pci_get_device_by_class(u32_t class);
* @return struct pci_device*
*/
struct pci_device*
* @return struct pci_device*
*/
struct pci_device*
-pci_get_device_by_id(u
int16_t vendorId, uint
16_t deviceId);
+pci_get_device_by_id(u
16_t vendorId, u
16_t deviceId);
/**
* @brief 初始化PCI设备的基地址寄存器。返回由该基地址代表的,
/**
* @brief 初始化PCI设备的基地址寄存器。返回由该基地址代表的,
@@
-174,4
+174,10
@@
pci_add_driver(const char* name,
int
pci_bind_driver(struct pci_device* pci_dev);
int
pci_bind_driver(struct pci_device* pci_dev);
+void
+pci_probe_bar_info(struct pci_device* device);
+
+void
+pci_probe_msi_info(struct pci_device* device);
+
#endif /* __LUNAIX_PCI_H */
#endif /* __LUNAIX_PCI_H */
diff --git
a/lunaix-os/includes/hal/rtc.h
b/lunaix-os/includes/hal/rtc.h
index 0742f0ce8f0abd47b3e3b25a88fa03be4ab12875..46283d09fbc18a3ca8dbb96bcad6ad1a061bf0c8 100644
(file)
--- a/
lunaix-os/includes/hal/rtc.h
+++ b/
lunaix-os/includes/hal/rtc.h
@@
-23,23
+23,26
@@
#define RTC_REG_C 0xC
#define RTC_REG_D 0xD
#define RTC_REG_C 0xC
#define RTC_REG_D 0xD
-#define RTC_BIN_ENCODED(reg)
(reg & 0x04)
-#define RTC_24HRS_ENCODED(reg)
(reg & 0x02)
+#define RTC_BIN_ENCODED(reg) (reg & 0x04)
+#define RTC_24HRS_ENCODED(reg) (reg & 0x02)
-#define RTC_TIMER_BASE_FREQUENCY
1024
-#define RTC_TIMER_ON
0x40
+#define RTC_TIMER_BASE_FREQUENCY 1024
+#define RTC_TIMER_ON 0x40
-#define RTC_FREQUENCY_1024HZ
0b110
-#define RTC_DIVIDER_33KHZ
(0b010 << 4)
+#define RTC_FREQUENCY_1024HZ 0b110
+#define RTC_DIVIDER_33KHZ (0b010 << 4)
void
rtc_init();
void
rtc_init();
-uint8_t
-rtc_read_reg(uint8_t reg_selector);
+u8_t
+rtc_read_reg(u8_t reg_selector);
+
+u8_t
+bcd2dec(u8_t bcd);
void
void
-rtc_write_reg(u
int8_t reg_selector, uint
8_t val);
+rtc_write_reg(u
8_t reg_selector, u
8_t val);
void
rtc_enable_timer();
void
rtc_enable_timer();
diff --git
a/lunaix-os/includes/klibc/stdio.h
b/lunaix-os/includes/klibc/stdio.h
index 9af99e9f811279dc477c4fa1e41b784f60d07022..f2c58db35dd2930d9007fe191cd8cedde27f75c2 100644
(file)
--- a/
lunaix-os/includes/klibc/stdio.h
+++ b/
lunaix-os/includes/klibc/stdio.h
@@
-4,7
+4,10
@@
#include <stddef.h>
size_t
#include <stddef.h>
size_t
-__ksprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs);
+__ksprintf_internal(char* buffer,
+ const char* fmt,
+ size_t max_len,
+ va_list vargs);
size_t
ksprintf(char* buffer, char* fmt, ...);
size_t
ksprintf(char* buffer, char* fmt, ...);
diff --git
a/lunaix-os/includes/lunaix/clock.h
b/lunaix-os/includes/lunaix/clock.h
index 889490e9af0fb54d14fa5668ca3f422c549931a4..f3c67d978470b43bb105c3910a3947c7577b4347 100644
(file)
--- a/
lunaix-os/includes/lunaix/clock.h
+++ b/
lunaix-os/includes/lunaix/clock.h
@@
-8,12
+8,12
@@
typedef u32_t time_t;
typedef struct
{
u32_t year; // use int32 as we need to store the 4-digit year
typedef struct
{
u32_t year; // use int32 as we need to store the 4-digit year
- u
int
8_t month;
- u
int
8_t day;
- u
int
8_t weekday;
- u
int
8_t hour;
- u
int
8_t minute;
- u
int
8_t second;
+ u8_t month;
+ u8_t day;
+ u8_t weekday;
+ u8_t hour;
+ u8_t minute;
+ u8_t second;
} datetime_t;
void
} datetime_t;
void
diff --git
a/lunaix-os/includes/lunaix/common.h
b/lunaix-os/includes/lunaix/common.h
index 3ed90f8cd54a4c01856405da9f5487e317e87f64..4b2880c4b31ae2ce701c1e7cf763366172fd5690 100644
(file)
--- a/
lunaix-os/includes/lunaix/common.h
+++ b/
lunaix-os/includes/lunaix/common.h
@@
-32,7
+32,7
@@
#define UMMAP_END (USTACK_END - MEM_4MB)
#ifndef __ASM__
#define UMMAP_END (USTACK_END - MEM_4MB)
#ifndef __ASM__
-#include <
stddef
.h>
+#include <
lunaix/types
.h>
// From Linux kernel v2.6.0 <kernel.h:194>
/**
* container_of - cast a member of a structure out to the containing structure
// From Linux kernel v2.6.0 <kernel.h:194>
/**
* container_of - cast a member of a structure out to the containing structure
diff --git
a/lunaix-os/includes/lunaix/ds/fifo.h
b/lunaix-os/includes/lunaix/ds/fifo.h
index b6c0dec765a78055ead1a00465085b95c66d4388..ecdbe5ebba220a8a3cc1c527e364036dbeed5f25 100644
(file)
--- a/
lunaix-os/includes/lunaix/ds/fifo.h
+++ b/
lunaix-os/includes/lunaix/ds/fifo.h
@@
-21,10
+21,10
@@
int
fifo_backone(struct fifo_buf* fbuf);
size_t
fifo_backone(struct fifo_buf* fbuf);
size_t
-fifo_putone(struct fifo_buf* fbuf, u
int
8_t data);
+fifo_putone(struct fifo_buf* fbuf, u8_t data);
size_t
size_t
-fifo_readone_async(struct fifo_buf* fbuf, u
int
8_t* data);
+fifo_readone_async(struct fifo_buf* fbuf, u8_t* data);
void
fifo_set_rdptr(struct fifo_buf* fbuf, size_t rdptr);
void
fifo_set_rdptr(struct fifo_buf* fbuf, size_t rdptr);
diff --git
a/lunaix-os/includes/lunaix/ds/hashtable.h
b/lunaix-os/includes/lunaix/ds/hashtable.h
index 0e8c691a47ebc1279177ed4559e0411766506243..c3aea3f451dd973d19802009307aafa92e812e1f 100644
(file)
--- a/
lunaix-os/includes/lunaix/ds/hashtable.h
+++ b/
lunaix-os/includes/lunaix/ds/hashtable.h
@@
-38,7
+38,7
@@
struct hbucket
#define hashtable_init(table) \
{ \
#define hashtable_init(table) \
{ \
- for (
int i = 0; i < (sizeof(table) / sizeof(table[0])); i++) {
\
+ for (
u32_t i = 0; i < (sizeof(table) / sizeof(table[0])); i++) {
\
table[i].head = 0; \
} \
}
table[i].head = 0; \
} \
}
diff --git
a/lunaix-os/includes/lunaix/exebi/elf32.h
b/lunaix-os/includes/lunaix/exebi/elf32.h
index d9f4f58308201141612decf0586bc929d9ad4225..634ccd6bd4cbe52355c9d5340d98eba178cb77e7 100644
(file)
--- a/
lunaix-os/includes/lunaix/exebi/elf32.h
+++ b/
lunaix-os/includes/lunaix/exebi/elf32.h
@@
-69,7
+69,7
@@
struct elf32_phdr
struct elf32
{
struct elf32
{
- void* elf_file;
+
const
void* elf_file;
struct elf32_ehdr eheader;
struct elf32_phdr* pheaders;
};
struct elf32_ehdr eheader;
struct elf32_phdr* pheaders;
};
@@
-77,11
+77,14
@@
struct elf32
#define declare_elf32(elf, elf_vfile) \
struct elf32 elf = { .elf_file = elf_vfile, .pheaders = (void*)0 }
#define declare_elf32(elf, elf_vfile) \
struct elf32 elf = { .elf_file = elf_vfile, .pheaders = (void*)0 }
+int
+elf32_check_exec(const struct elf32* elf);
+
int
elf32_open(struct elf32* elf, const char* path);
int
int
elf32_open(struct elf32* elf, const char* path);
int
-elf32_openat(struct elf32* elf, void* elf_vfile);
+elf32_openat(struct elf32* elf,
const
void* elf_vfile);
int
elf32_static_linked(const struct elf32* elf);
int
elf32_static_linked(const struct elf32* elf);
diff --git
a/lunaix-os/includes/lunaix/exec.h
b/lunaix-os/includes/lunaix/exec.h
index 2bc0d9439c60ebea89bba40a7c5ac3928ba0c3a5..f872271bb649a6667300bc9cfac0be490953b93a 100644
(file)
--- a/
lunaix-os/includes/lunaix/exec.h
+++ b/
lunaix-os/includes/lunaix/exec.h
@@
-28,7
+28,7
@@
struct exec_container
struct load_context exe;
// argv prependums
struct load_context exe;
// argv prependums
- char* argv_pp[2];
+ c
onst c
har* argv_pp[2];
const char** argv;
const char** envp;
const char** argv;
const char** envp;
diff --git
a/lunaix-os/includes/lunaix/fs/iso9660.h
b/lunaix-os/includes/lunaix/fs/iso9660.h
index 96e73385df2afa89361066db9d70f4a7abc1ceba..1a6aee233b6d5858187bd177faf5f5b37a769666 100644
(file)
--- a/
lunaix-os/includes/lunaix/fs/iso9660.h
+++ b/
lunaix-os/includes/lunaix/fs/iso9660.h
@@
-154,10
+154,10
@@
struct iso_drecord
u8_t xattr_len;
iso_bbo32_t extent_addr;
iso_bbo32_t data_size;
u8_t xattr_len;
iso_bbo32_t extent_addr;
iso_bbo32_t data_size;
- struct iso_datetime2
PACKED
mktime; // Time the record is made, see 9.1.5
+ struct iso_datetime2 mktime; // Time the record is made, see 9.1.5
u8_t flags;
u8_t flags;
- u8_t fu_sz;
// size of file unit (FU)
- u8_t gap_sz;
// size of gap if FU is interleaved.
+ u8_t fu_sz; // size of file unit (FU)
+ u8_t gap_sz; // size of gap if FU is interleaved.
iso_bbo16_t vol_seq;
struct iso_var_mdu name;
} PACKED;
iso_bbo16_t vol_seq;
struct iso_var_mdu name;
} PACKED;
diff --git
a/lunaix-os/includes/lunaix/isrm.h
b/lunaix-os/includes/lunaix/isrm.h
index afa8146a457143ea703b3baf154ec423dc13a630..c7be5ad2f0326b4b595d34937d6d98c066beb273 100644
(file)
--- a/
lunaix-os/includes/lunaix/isrm.h
+++ b/
lunaix-os/includes/lunaix/isrm.h
@@
-36,7
+36,7
@@
isrm_ivexalloc(isr_cb handler);
int
isrm_bindirq(int irq, isr_cb irq_handler);
int
isrm_bindirq(int irq, isr_cb irq_handler);
-int
+void
isrm_bindiv(int iv, isr_cb handler);
isr_cb
isrm_bindiv(int iv, isr_cb handler);
isr_cb
diff --git
a/lunaix-os/includes/lunaix/mm/cake.h
b/lunaix-os/includes/lunaix/mm/cake.h
index 81321f87b898c7ce1b6bd05b50f35d342dc5d8ff..18d67e0bf3659bae32488122ef6c930aa88d8fc8 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/cake.h
+++ b/
lunaix-os/includes/lunaix/mm/cake.h
@@
-17,12
+17,12
@@
struct cake_pile
struct llist_header full;
struct llist_header partial;
struct llist_header free;
struct llist_header full;
struct llist_header partial;
struct llist_header free;
- u
nsigned in
t offset;
- u
nsigned in
t piece_size;
- u
nsigned in
t cakes_count;
- u
nsigned in
t alloced_pieces;
- u
nsigned in
t pieces_per_cake;
- u
nsigned in
t pg_per_cake;
+ u
32_
t offset;
+ u
32_
t piece_size;
+ u
32_
t cakes_count;
+ u
32_
t alloced_pieces;
+ u
32_
t pieces_per_cake;
+ u
32_
t pg_per_cake;
char pile_name[PILE_NAME_MAXLEN];
pile_cb ctor;
char pile_name[PILE_NAME_MAXLEN];
pile_cb ctor;
@@
-30,7
+30,7
@@
struct cake_pile
typedef unsigned int piece_index_t;
typedef unsigned int piece_index_t;
-#define EO_FREE_PIECE (-1)
+#define EO_FREE_PIECE (
(u32_t)
-1)
struct cake_s
{
struct cake_s
{
diff --git
a/lunaix-os/includes/lunaix/mm/mmap.h
b/lunaix-os/includes/lunaix/mm/mmap.h
index f85302e339b8d14056b9a1b3661608c6ff933ace..44ae4699a9e3caba71554f1185b27e9ce928402c 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/mmap.h
+++ b/
lunaix-os/includes/lunaix/mm/mmap.h
@@
-25,12
+25,12
@@
mem_adjust_inplace(vm_regions_t* regions,
int
mem_map(void** addr_out,
struct mm_region** created,
int
mem_map(void** addr_out,
struct mm_region** created,
-
void*
addr,
+
ptr_t
addr,
struct v_file* file,
struct mmap_param* param);
int
struct v_file* file,
struct mmap_param* param);
int
-mem_unmap(ptr_t mnt, vm_regions_t* regions,
void*
addr, size_t length);
+mem_unmap(ptr_t mnt, vm_regions_t* regions,
ptr_t
addr, size_t length);
void
mem_unmap_region(ptr_t mnt, struct mm_region* region);
void
mem_unmap_region(ptr_t mnt, struct mm_region* region);
diff --git
a/lunaix-os/includes/lunaix/mm/mmio.h
b/lunaix-os/includes/lunaix/mm/mmio.h
index 710d4a4f08c4458bc781b4dbbf5996ee0e666390..18d1c4fa3dc73bdbb18920b3df92361297bf87cc 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/mmio.h
+++ b/
lunaix-os/includes/lunaix/mm/mmio.h
@@
-4,9
+4,9
@@
#include <lunaix/types.h>
void*
#include <lunaix/types.h>
void*
-ioremap(
uint
ptr_t paddr, u32_t size);
+ioremap(ptr_t paddr, u32_t size);
-void
*
-iounmap(
uint
ptr_t vaddr, u32_t size);
+void
+iounmap(ptr_t vaddr, u32_t size);
#endif /* __LUNAIX_MMIO_H */
#endif /* __LUNAIX_MMIO_H */
diff --git
a/lunaix-os/includes/lunaix/mm/page.h
b/lunaix-os/includes/lunaix/mm/page.h
index 959477f50ac29561c524446f02978e4ee9dc214a..099bf13094fe982a5f47bdb0f412aca2bb1a09ae 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/page.h
+++ b/
lunaix-os/includes/lunaix/mm/page.h
@@
-86,7
+86,7
@@
typedef struct
// 物理页地址(如果不存在映射,则为0)
ptr_t pa;
// 映射的flags
// 物理页地址(如果不存在映射,则为0)
ptr_t pa;
// 映射的flags
- u
int
16_t flags;
+ u16_t flags;
// PTE地址
x86_pte_t* pte;
} v_mapping;
// PTE地址
x86_pte_t* pte;
} v_mapping;
@@
-94,7
+94,7
@@
typedef struct
typedef struct
{
x86_pte_t entry[PG_MAX_ENTRIES];
typedef struct
{
x86_pte_t entry[PG_MAX_ENTRIES];
-} __attribute__((packed)) x86_page_table;
+} __attribute__((packed
, aligned(4)
)) x86_page_table;
extern void __pg_mount_point;
extern void __pg_mount_point;
diff --git
a/lunaix-os/includes/lunaix/mm/pmm.h
b/lunaix-os/includes/lunaix/mm/pmm.h
index 54365605a3d6cea18aed6f0c97793258e0fe9e90..81411139e44cfee8dafc9d2320c9863553ac26c1 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/pmm.h
+++ b/
lunaix-os/includes/lunaix/mm/pmm.h
@@
-36,7
+36,7
@@
struct pp_struct
* @param ppn page number
*/
void
* @param ppn page number
*/
void
-pmm_mark_page_free(
uint
ptr_t ppn);
+pmm_mark_page_free(ptr_t ppn);
/**
* @brief 标注物理页为已占用
/**
* @brief 标注物理页为已占用
@@
-44,7
+44,7
@@
pmm_mark_page_free(uintptr_t ppn);
* @param ppn
*/
void
* @param ppn
*/
void
-pmm_mark_page_occupied(pid_t owner,
uint
ptr_t ppn, pp_attr_t attr);
+pmm_mark_page_occupied(pid_t owner, ptr_t ppn, pp_attr_t attr);
/**
* @brief 标注多个连续的物理页为可用
/**
* @brief 标注多个连续的物理页为可用
@@
-53,7
+53,7
@@
pmm_mark_page_occupied(pid_t owner, uintptr_t ppn, pp_attr_t attr);
* @param page_count 数量
*/
void
* @param page_count 数量
*/
void
-pmm_mark_chunk_free(
uint
ptr_t start_ppn, size_t page_count);
+pmm_mark_chunk_free(ptr_t start_ppn, size_t page_count);
/**
* @brief 标注多个连续的物理页为已占用
/**
* @brief 标注多个连续的物理页为已占用
@@
-72,7
+72,7
@@
pmm_mark_chunk_occupied(pid_t owner,
*
* @return void* 可用的页地址,否则为 NULL
*/
*
* @return void* 可用的页地址,否则为 NULL
*/
-void*
+ptr_t
pmm_alloc_page(pid_t owner, pp_attr_t attr);
/**
pmm_alloc_page(pid_t owner, pp_attr_t attr);
/**
@@
-81,9
+81,9
@@
pmm_alloc_page(pid_t owner, pp_attr_t attr);
* @param owner
* @param num_pages 区域大小,单位为页
* @param attr
* @param owner
* @param num_pages 区域大小,单位为页
* @param attr
- * @return
void*
+ * @return
ptr_t
*/
*/
-void*
+ptr_t
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr);
/**
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr);
/**
@@
-92,10
+92,10
@@
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr);
* @param mem_upper_lim 最大可用内存地址
*/
void
* @param mem_upper_lim 最大可用内存地址
*/
void
-pmm_init(
uint
ptr_t mem_upper_lim);
+pmm_init(ptr_t mem_upper_lim);
struct pp_struct*
struct pp_struct*
-pmm_query(
void*
pa);
+pmm_query(
ptr_t
pa);
/**
* @brief 释放一个已分配的物理页,假若页地址不存在,则无操作。
/**
* @brief 释放一个已分配的物理页,假若页地址不存在,则无操作。
@@
-104,9
+104,9
@@
pmm_query(void* pa);
* @return 是否成功
*/
int
* @return 是否成功
*/
int
-pmm_free_page(pid_t owner,
void*
page);
+pmm_free_page(pid_t owner,
ptr_t
page);
int
int
-pmm_ref_page(pid_t owner,
void*
page);
+pmm_ref_page(pid_t owner,
ptr_t
page);
#endif /* __LUNAIX_PMM_H */
#endif /* __LUNAIX_PMM_H */
diff --git
a/lunaix-os/includes/lunaix/mm/vmm.h
b/lunaix-os/includes/lunaix/mm/vmm.h
index 9749255b4a2565d0b079c6159508f18f98b4d449..5822faf9744a7bf9b9449d5f9e07da21124063d0 100644
(file)
--- a/
lunaix-os/includes/lunaix/mm/vmm.h
+++ b/
lunaix-os/includes/lunaix/mm/vmm.h
@@
-49,11
+49,7
@@
vmm_init_pd();
* @return int
*/
int
* @return int
*/
int
-vmm_set_mapping(uintptr_t mnt,
- uintptr_t va,
- uintptr_t pa,
- pt_attr attr,
- int options);
+vmm_set_mapping(ptr_t mnt, ptr_t va, ptr_t pa, pt_attr attr, int options);
/**
* @brief 删除一个映射
/**
* @brief 删除一个映射
@@
-63,8
+59,8
@@
vmm_set_mapping(uintptr_t mnt,
* @param va
* @return int
*/
* @param va
* @return int
*/
-
uint
ptr_t
-vmm_del_mapping(
uintptr_t mnt, uint
ptr_t va);
+ptr_t
+vmm_del_mapping(
ptr_t mnt,
ptr_t va);
/**
* @brief 在当前虚拟地址空间里查找一个映射
/**
* @brief 在当前虚拟地址空间里查找一个映射
@@
-73,7
+69,7
@@
vmm_del_mapping(uintptr_t mnt, uintptr_t va);
* @param mapping 映射相关属性
*/
int
* @param mapping 映射相关属性
*/
int
-vmm_lookup(
uint
ptr_t va, v_mapping* mapping);
+vmm_lookup(ptr_t va, v_mapping* mapping);
/**
* @brief 在指定的虚拟地址空间里查找一个映射
/**
* @brief 在指定的虚拟地址空间里查找一个映射
@@
-84,7
+80,7
@@
vmm_lookup(uintptr_t va, v_mapping* mapping);
* @return int
*/
int
* @return int
*/
int
-vmm_lookupat(ptr_t mnt,
uint
ptr_t va, v_mapping* mapping);
+vmm_lookupat(ptr_t mnt, ptr_t va, v_mapping* mapping);
/**
* @brief (COW) 为虚拟页创建副本。
/**
* @brief (COW) 为虚拟页创建副本。
@@
-92,33
+88,33
@@
vmm_lookupat(ptr_t mnt, uintptr_t va, v_mapping* mapping);
* @return void* 包含虚拟页副本的物理页地址。
*
*/
* @return void* 包含虚拟页副本的物理页地址。
*
*/
-void*
-vmm_dup_page(pid_t pid,
void*
pa);
+ptr_t
+vmm_dup_page(pid_t pid,
ptr_t
pa);
-void*
+ptr_t
vmm_dup_vmspace(pid_t pid);
/**
* @brief 挂载另一个虚拟地址空间至当前虚拟地址空间
*
* @param pde 页目录的物理地址
vmm_dup_vmspace(pid_t pid);
/**
* @brief 挂载另一个虚拟地址空间至当前虚拟地址空间
*
* @param pde 页目录的物理地址
- * @return
void*
+ * @return
ptr_t
*/
*/
-void*
-vmm_mount_pd(
uintptr_t mnt, void*
pde);
+ptr_t
+vmm_mount_pd(
ptr_t mnt, ptr_t
pde);
/**
* @brief 卸载已挂载的虚拟地址空间
*
*/
/**
* @brief 卸载已挂载的虚拟地址空间
*
*/
-void*
-vmm_unmount_pd(
uint
ptr_t mnt);
+ptr_t
+vmm_unmount_pd(ptr_t mnt);
void*
void*
-vmm_ioremap(
uint
ptr_t paddr, size_t size);
+vmm_ioremap(ptr_t paddr, size_t size);
void*
void*
-vmm_next_free(
uint
ptr_t start, int options);
+vmm_next_free(ptr_t start, int options);
/**
* @brief 将连续的物理地址空间映射到内核虚拟地址空间
/**
* @brief 将连续的物理地址空间映射到内核虚拟地址空间
@@
-128,7
+124,7
@@
vmm_next_free(uintptr_t start, int options);
* @return void*
*/
void*
* @return void*
*/
void*
-vmm_vmap(
uint
ptr_t paddr, size_t size, pt_attr attr);
+vmm_vmap(ptr_t paddr, size_t size, pt_attr attr);
/**
* @brief 将当前地址空间的虚拟地址转译为物理地址。
/**
* @brief 将当前地址空间的虚拟地址转译为物理地址。
@@
-136,8
+132,8
@@
vmm_vmap(uintptr_t paddr, size_t size, pt_attr attr);
* @param va 虚拟地址
* @return void*
*/
* @param va 虚拟地址
* @return void*
*/
-void*
-vmm_v2p(
void*
va);
+ptr_t
+vmm_v2p(
ptr_t
va);
/**
* @brief 将指定地址空间的虚拟地址转译为物理地址
/**
* @brief 将指定地址空间的虚拟地址转译为物理地址
@@
-146,7
+142,7
@@
vmm_v2p(void* va);
* @param va 虚拟地址
* @return void*
*/
* @param va 虚拟地址
* @return void*
*/
-void*
-vmm_v2pat(ptr_t mnt,
void*
va);
+ptr_t
+vmm_v2pat(ptr_t mnt,
ptr_t
va);
#endif /* __LUNAIX_VMM_H */
#endif /* __LUNAIX_VMM_H */
diff --git
a/lunaix-os/includes/lunaix/peripheral/ps2kbd.h
b/lunaix-os/includes/lunaix/peripheral/ps2kbd.h
index 3ebaa984aa1770e69f43dc78c6b6b0d5f7fad07d..9a246ea8d1b41d23413dcd9d8eb11ea07205a5e0 100644
(file)
--- a/
lunaix-os/includes/lunaix/peripheral/ps2kbd.h
+++ b/
lunaix-os/includes/lunaix/peripheral/ps2kbd.h
@@
-77,8
+77,8
@@
struct ps2_cmd_queue
* @param cmd
* @param args
*/
* @param cmd
* @param args
*/
-static u
int
8_t
-ps2_issue_cmd(char cmd, u
int
16_t arg);
+static u8_t
+ps2_issue_cmd(char cmd, u16_t arg);
/**
* @brief 向PS/2控制器的编码器端口(0x60)发送指令并等待返回代码。
/**
* @brief 向PS/2控制器的编码器端口(0x60)发送指令并等待返回代码。
@@
-88,8
+88,8
@@
ps2_issue_cmd(char cmd, uint16_t arg);
* @param cmd
* @param args
*/
* @param cmd
* @param args
*/
-static u
int
8_t
-ps2_issue_dev_cmd(char cmd, u
int
16_t arg);
+static u8_t
+ps2_issue_dev_cmd(char cmd, u16_t arg);
/**
* @brief 向PS/2控制器发送指令,不等待返回代码。
/**
* @brief 向PS/2控制器发送指令,不等待返回代码。
@@
-100,7
+100,7
@@
ps2_issue_dev_cmd(char cmd, uint16_t arg);
* @return char
*/
static void
* @return char
*/
static void
-ps2_post_cmd(u
int8_t port, char cmd, uint
16_t arg);
+ps2_post_cmd(u
8_t port, char cmd, u
16_t arg);
void
ps2_device_post_cmd(char cmd, char arg);
void
ps2_device_post_cmd(char cmd, char arg);
diff --git
a/lunaix-os/includes/lunaix/peripheral/serial.h
b/lunaix-os/includes/lunaix/peripheral/serial.h
index a8cbed2b7d4b205fcd5daead59569757c69c7006..a935119c13529caed1df4eb0df391cf0d6f86ee0 100644
(file)
--- a/
lunaix-os/includes/lunaix/peripheral/serial.h
+++ b/
lunaix-os/includes/lunaix/peripheral/serial.h
@@
-26,24
+26,24
@@
void
serial_init();
char
serial_init();
char
-serial_rx_byte(
uint
ptr_t port);
+serial_rx_byte(ptr_t port);
void
void
-serial_rx_buffer(
uint
ptr_t port, char* data, size_t len);
+serial_rx_buffer(ptr_t port, char* data, size_t len);
void
void
-serial_tx_byte(
uint
ptr_t port, char data);
+serial_tx_byte(ptr_t port, char data);
void
void
-serial_tx_buffer(
uint
ptr_t port, char* data, size_t len);
+serial_tx_buffer(ptr_t port, char* data, size_t len);
void
void
-serial_clear_fifo(
uint
ptr_t port);
+serial_clear_fifo(ptr_t port);
void
void
-serial_disable_irq(
uint
ptr_t port);
+serial_disable_irq(ptr_t port);
void
void
-serial_enable_irq(
uint
ptr_t port);
+serial_enable_irq(ptr_t port);
#endif /* __LUNAIX_SERIAL_H */
#endif /* __LUNAIX_SERIAL_H */
diff --git
a/lunaix-os/includes/lunaix/process.h
b/lunaix-os/includes/lunaix/process.h
index 27137a103db53763d07f7c28d02b5f9a5107df29..974907d0d56ebfc1bbbd8f550cd8c500a0ff8e48 100644
(file)
--- a/
lunaix-os/includes/lunaix/process.h
+++ b/
lunaix-os/includes/lunaix/process.h
@@
-52,8
+52,8
@@
struct proc_info
pid_t pid; // offset = 0
struct proc_info* parent; // offset = 4
isr_param intr_ctx; // offset = 8
pid_t pid; // offset = 0
struct proc_info* parent; // offset = 4
isr_param intr_ctx; // offset = 8
-
uintptr_t ustack_top;
// offset = 84 -> 56 -> 60
-
void*
page_table; // offset = 88 -> 60 -> 64
+
ptr_t ustack_top;
// offset = 84 -> 56 -> 60
+
ptr_t
page_table; // offset = 88 -> 60 -> 64
void* fxstate; // offset = 92 -> 64 -> 68
/* ---- critical section end ---- */
void* fxstate; // offset = 92 -> 64 -> 68
/* ---- critical section end ---- */
@@
-73,7
+73,7
@@
struct proc_info
struct proc_mm mm;
time_t created;
struct proc_mm mm;
time_t created;
- u
int
8_t state;
+ u8_t state;
int32_t exit_code;
int32_t k_status;
sigset_t sig_pending;
int32_t exit_code;
int32_t k_status;
sigset_t sig_pending;
@@
-122,7
+122,7
@@
pid_t
destroy_process(pid_t pid);
void
destroy_process(pid_t pid);
void
-setup_proc_mem(struct proc_info* proc,
uint
ptr_t kstack_from);
+setup_proc_mem(struct proc_info* proc, ptr_t kstack_from);
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
diff --git
a/lunaix-os/includes/lunaix/sched.h
b/lunaix-os/includes/lunaix/sched.h
index f31eab52daa9ce7ddc34b2d220812b64c9a27985..7cb313025e3860cb7bd9871e6f5cdb57f7ee25f1 100644
(file)
--- a/
lunaix-os/includes/lunaix/sched.h
+++ b/
lunaix-os/includes/lunaix/sched.h
@@
-4,13
+4,13
@@
#define SCHED_TIME_SLICE 300
#define PROC_TABLE_SIZE 8192
#define SCHED_TIME_SLICE 300
#define PROC_TABLE_SIZE 8192
-#define MAX_PROCESS (PROC_TABLE_SIZE / sizeof(
uint
ptr_t))
+#define MAX_PROCESS (PROC_TABLE_SIZE / sizeof(ptr_t))
struct scheduler
{
struct proc_info** _procs;
int procs_index;
struct scheduler
{
struct proc_info** _procs;
int procs_index;
-
unsigned
int ptable_len;
+ int ptable_len;
};
void
};
void
diff --git
a/lunaix-os/includes/lunaix/signal.h
b/lunaix-os/includes/lunaix/signal.h
index c815c4f7cdf694332c77ba849cc5bc79facc5afa..16ec0336cb5024fb22d495cff475103a1455e999 100644
(file)
--- a/
lunaix-os/includes/lunaix/signal.h
+++ b/
lunaix-os/includes/lunaix/signal.h
@@
-28,4
+28,7
@@
#define _SIG_UNBLOCK SIG_UNBLOCK
#define _SIG_SETMASK SIG_SETMASK
#define _SIG_UNBLOCK SIG_UNBLOCK
#define _SIG_SETMASK SIG_SETMASK
+int
+signal_send(pid_t pid, int signum);
+
#endif /* __LUNAIX_SIGNAL_H */
#endif /* __LUNAIX_SIGNAL_H */
diff --git
a/lunaix-os/includes/lunaix/spike.h
b/lunaix-os/includes/lunaix/spike.h
index 5ea8d47b2b759068d41895ad1a622c7d9ce2fee7..2d718f5bda460e5f707d2ebdf4d4b65ab0c9236e 100644
(file)
--- a/
lunaix-os/includes/lunaix/spike.h
+++ b/
lunaix-os/includes/lunaix/spike.h
@@
-66,11
+66,14
@@
#define __USER__ __attribute__((section(".usrtext")))
#define __USER__ __attribute__((section(".usrtext")))
+#define DO_SPIN \
+ while (1) \
+ ;
+
inline static void
spin()
{
inline static void
spin()
{
- while (1)
- ;
+ DO_SPIN
}
#ifndef __LUNAIXOS_NASSERT__
}
#ifndef __LUNAIXOS_NASSERT__
diff --git
a/lunaix-os/includes/lunaix/timer.h
b/lunaix-os/includes/lunaix/timer.h
index cdf9ef477846bb31541e897c79eb6cfa3d57261d..5ab38644c24cf4b615dcc8760c31750f11f0a7a9 100644
(file)
--- a/
lunaix-os/includes/lunaix/timer.h
+++ b/
lunaix-os/includes/lunaix/timer.h
@@
-37,7
+37,7
@@
struct lx_timer
ticks_t counter;
void* payload;
void (*callback)(void*);
ticks_t counter;
void* payload;
void (*callback)(void*);
- u
int
8_t flags;
+ u8_t flags;
};
/**
};
/**
@@
-52,16
+52,16
@@
struct lx_timer*
timer_run_second(u32_t second,
void (*callback)(void*),
void* payload,
timer_run_second(u32_t second,
void (*callback)(void*),
void* payload,
- u
int
8_t flags);
+ u8_t flags);
struct lx_timer*
timer_run_ms(u32_t millisecond,
void (*callback)(void*),
void* payload,
struct lx_timer*
timer_run_ms(u32_t millisecond,
void (*callback)(void*),
void* payload,
- u
int
8_t flags);
+ u8_t flags);
struct lx_timer*
struct lx_timer*
-timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u
int
8_t flags);
+timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u8_t flags);
struct lx_timer_context*
timer_context();
struct lx_timer_context*
timer_context();
diff --git
a/lunaix-os/includes/lunaix/types.h
b/lunaix-os/includes/lunaix/types.h
index a98ae976c8e63615ce4da5073002861d6627b59e..5a6fb9095839576578065c623d6d164c6c0600a7 100644
(file)
--- a/
lunaix-os/includes/lunaix/types.h
+++ b/
lunaix-os/includes/lunaix/types.h
@@
-2,7
+2,7
@@
#define __LUNAIX_TYPES_H
#include <stdarg.h>
#define __LUNAIX_TYPES_H
#include <stdarg.h>
-#include <std
int
.h>
+#include <std
def
.h>
#include <sys/types.h>
#define PACKED __attribute__((packed))
#include <sys/types.h>
#define PACKED __attribute__((packed))
@@
-17,6
+17,11
@@
typedef unsigned int u32_t;
typedef unsigned long long u64_t;
typedef unsigned long ptr_t;
typedef unsigned long long u64_t;
typedef unsigned long ptr_t;
-typedef int64_t lba_t;
+typedef signed long ssize_t;
+typedef int pid_t;
+typedef unsigned long size_t;
+typedef unsigned long off_t;
+
+typedef u64_t lba_t;
#endif /* __LUNAIX_TYPES_H */
#endif /* __LUNAIX_TYPES_H */
diff --git
a/lunaix-os/kernel/asm/x86/gdt.c
b/lunaix-os/kernel/asm/x86/gdt.c
index 4c4dd54b330c61355260514cd42e445f3a367c33..f84df20cca47ce7c32585a60070858aee425cca1 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/gdt.c
+++ b/
lunaix-os/kernel/asm/x86/gdt.c
@@
-4,8
+4,8
@@
#define GDT_ENTRY 6
#define GDT_ENTRY 6
-u
int
64_t _gdt[GDT_ENTRY];
-u
int
16_t _gdt_limit = sizeof(_gdt) - 1;
+u64_t _gdt[GDT_ENTRY];
+u16_t _gdt_limit = sizeof(_gdt) - 1;
void
_set_gdt_entry(u32_t index, u32_t base, u32_t limit, u32_t flags)
void
_set_gdt_entry(u32_t index, u32_t base, u32_t limit, u32_t flags)
@@
-26,5
+26,5
@@
_init_gdt()
_set_gdt_entry(2, 0, 0xfffff, SEG_R0_DATA);
_set_gdt_entry(3, 0, 0xfffff, SEG_R3_CODE);
_set_gdt_entry(4, 0, 0xfffff, SEG_R3_DATA);
_set_gdt_entry(2, 0, 0xfffff, SEG_R0_DATA);
_set_gdt_entry(3, 0, 0xfffff, SEG_R3_CODE);
_set_gdt_entry(4, 0, 0xfffff, SEG_R3_DATA);
- _set_gdt_entry(5, &_tss, sizeof(struct x86_tss) - 1, SEG_TSS);
+ _set_gdt_entry(5,
(u32_t)
&_tss, sizeof(struct x86_tss) - 1, SEG_TSS);
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/asm/x86/i386_isrm.c
b/lunaix-os/kernel/asm/x86/i386_isrm.c
index 9c18637157d46f2d9aefdb2c2292ffef169f339b..a45ce7e2dfcc4d7f8a03389f445df3628225499e 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/i386_isrm.c
+++ b/
lunaix-os/kernel/asm/x86/i386_isrm.c
@@
-30,19
+30,26
@@
__ivalloc_within(size_t a, size_t b, isr_cb handler)
{
a = (a - IV_BASE) / 8;
b = (b - IV_BASE) / 8;
{
a = (a - IV_BASE) / 8;
b = (b - IV_BASE) / 8;
+
for (size_t i = a; i < b; i++) {
for (size_t i = a; i < b; i++) {
- char chunk = iv_bmp[i], j = 0;
+ u8_t chunk = iv_bmp[i], j = 0;
+
if (chunk == 0xff)
continue;
if (chunk == 0xff)
continue;
+
while ((chunk & 0x1)) {
chunk >>= 1;
j++;
}
while ((chunk & 0x1)) {
chunk >>= 1;
j++;
}
+
iv_bmp[i] |= 1 << j;
iv_bmp[i] |= 1 << j;
+
int iv = IV_BASE + i * 8 + j;
handlers[iv] = handler ? handler : intr_routine_fallback;
int iv = IV_BASE + i * 8 + j;
handlers[iv] = handler ? handler : intr_routine_fallback;
+
return iv;
}
return iv;
}
+
return 0;
}
return 0;
}
@@
-62,9
+69,11
@@
void
isrm_ivfree(int iv)
{
assert(iv < 256);
isrm_ivfree(int iv)
{
assert(iv < 256);
+
if (iv >= IV_BASE) {
iv_bmp[(iv - IV_BASE) / 8] &= ~(1 << ((iv - IV_BASE) % 8));
}
if (iv >= IV_BASE) {
iv_bmp[(iv - IV_BASE) / 8] &= ~(1 << ((iv - IV_BASE) % 8));
}
+
handlers[iv] = intr_routine_fallback;
}
handlers[iv] = intr_routine_fallback;
}
@@
-80,16
+89,19
@@
isrm_bindirq(int irq, isr_cb irq_handler)
// PC_AT_IRQ_RTC -> RTC_TIMER_IV, fixed, edge trigged, polarity=high,
// physical, APIC ID 0
ioapic_redirect(acpi_gistranslate(irq), iv, 0, IOAPIC_DELMOD_FIXED);
// PC_AT_IRQ_RTC -> RTC_TIMER_IV, fixed, edge trigged, polarity=high,
// physical, APIC ID 0
ioapic_redirect(acpi_gistranslate(irq), iv, 0, IOAPIC_DELMOD_FIXED);
+
return iv;
}
return iv;
}
-int
+void
isrm_bindiv(int iv, isr_cb handler)
{
assert(iv < 256);
isrm_bindiv(int iv, isr_cb handler)
{
assert(iv < 256);
+
if (iv >= IV_BASE) {
iv_bmp[(iv - IV_BASE) / 8] |= 1 << ((iv - IV_BASE) % 8);
}
if (iv >= IV_BASE) {
iv_bmp[(iv - IV_BASE) / 8] |= 1 << ((iv - IV_BASE) % 8);
}
+
handlers[iv] = handler;
}
handlers[iv] = handler;
}
@@
-97,5
+109,6
@@
isr_cb
isrm_get(int iv)
{
assert(iv < 256);
isrm_get(int iv)
{
assert(iv < 256);
+
return handlers[iv];
}
\ No newline at end of file
return handlers[iv];
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/asm/x86/intr_routines.c
b/lunaix-os/kernel/asm/x86/intr_routines.c
index f4bebae4159490173e9df5c693421ed503890121..ea7a3243b5b4786bc159c33777a2ba433d1da5bb 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/intr_routines.c
+++ b/
lunaix-os/kernel/asm/x86/intr_routines.c
@@
-22,7
+22,8
@@
extern u32_t debug_resv;
void
__print_panic_msg(const char* msg, const isr_param* param)
{
void
__print_panic_msg(const char* msg, const isr_param* param)
{
- struct exec_param* execp = param->execp;
+ volatile struct exec_param* execp = param->execp;
+
kprint_panic(" INT %u: (%x) [%p: %p] %s",
execp->vector,
execp->err_code,
kprint_panic(" INT %u: (%x) [%p: %p] %s",
execp->vector,
execp->err_code,
diff --git
a/lunaix-os/kernel/asm/x86/intrhnds.c
b/lunaix-os/kernel/asm/x86/intrhnds.c
index 1ae386069a6b5ce48d5b2c09d4aaa95be9c107c1..70b597f7982554bb8192b13d13f9d156e9f087df 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/intrhnds.c
+++ b/
lunaix-os/kernel/asm/x86/intrhnds.c
@@
-5,16
+5,16
@@
#define IDT_ENTRY 256
#define IDT_ENTRY 256
-u
int
64_t _idt[IDT_ENTRY];
-u
int
16_t _idt_limit = sizeof(_idt) - 1;
+u64_t _idt[IDT_ENTRY];
+u16_t _idt_limit = sizeof(_idt) - 1;
static inline void
_set_idt_entry(u32_t vector,
static inline void
_set_idt_entry(u32_t vector,
- u
int
16_t seg_selector,
+ u16_t seg_selector,
void (*isr)(),
void (*isr)(),
- u
int
8_t dpl,
- u
int
8_t type)
+ u8_t dpl,
+ u8_t type)
{
{
-
uintptr_t offset = (uint
ptr_t)isr;
+
ptr_t offset = (
ptr_t)isr;
_idt[vector] = (offset & 0xffff0000) | IDT_ATTR(dpl, type);
_idt[vector] <<= 32;
_idt[vector] |= (seg_selector << 16) | (offset & 0x0000ffff);
_idt[vector] = (offset & 0xffff0000) | IDT_ATTR(dpl, type);
_idt[vector] <<= 32;
_idt[vector] |= (seg_selector << 16) | (offset & 0x0000ffff);
diff --git
a/lunaix-os/kernel/asm/x86/pfault.c
b/lunaix-os/kernel/asm/x86/pfault.c
index 897a7dd2a197a6ac7c1f5d4b66bd8740a8181f9e..0d5a6fa661b908d901e625a5911f61dddabd6f3a 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/pfault.c
+++ b/
lunaix-os/kernel/asm/x86/pfault.c
@@
-28,7
+28,7
@@
__print_panic_msg(const char* msg, const isr_param* param);
void
intr_routine_page_fault(const isr_param* param)
{
void
intr_routine_page_fault(const isr_param* param)
{
-
uint
ptr_t ptr = cpu_rcr2();
+ ptr_t ptr = cpu_rcr2();
if (!ptr) {
goto segv_term;
}
if (!ptr) {
goto segv_term;
}
@@
-39,14
+39,11
@@
intr_routine_page_fault(const isr_param* param)
}
if (!SEL_RPL(param->execp->cs)) {
}
if (!SEL_RPL(param->execp->cs)) {
- // 如果是内核页错误……
- if (do_kernel(&mapping)) {
- return;
- }
- // 如果不是,那么看看内核是不是需要用户页。
+ // TODO if kernel pfault
}
}
- struct mm_region* hit_region = region_get(&__current->mm.regions, ptr);
+ vm_regions_t* vmr = (vm_regions_t*)&__current->mm.regions;
+ struct mm_region* hit_region = region_get(vmr, ptr);
if (!hit_region) {
// 当你凝视深渊时……
if (!hit_region) {
// 当你凝视深渊时……
@@
-57,11
+54,13
@@
intr_routine_page_fault(const isr_param* param)
if (PG_IS_PRESENT(*pte)) {
if ((hit_region->attr & COW_MASK) == COW_MASK) {
// normal page fault, do COW
if (PG_IS_PRESENT(*pte)) {
if ((hit_region->attr & COW_MASK) == COW_MASK) {
// normal page fault, do COW
- cpu_invplg(pte);
- uintptr_t pa =
- (uintptr_t)vmm_dup_page(__current->pid, PG_ENTRY_ADDR(*pte));
+ cpu_invplg((ptr_t)pte);
+
+ ptr_t pa = (ptr_t)vmm_dup_page(__current->pid, PG_ENTRY_ADDR(*pte));
+
pmm_free_page(__current->pid, *pte & ~0xFFF);
*pte = (*pte & 0xFFF & ~PG_DIRTY) | pa | PG_WRITE;
pmm_free_page(__current->pid, *pte & ~0xFFF);
*pte = (*pte & 0xFFF & ~PG_DIRTY) | pa | PG_WRITE;
+
goto resolved;
}
// impossible cases or accessing privileged page
goto resolved;
}
// impossible cases or accessing privileged page
@@
-72,14
+71,15
@@
intr_routine_page_fault(const isr_param* param)
// -> a new page need to be alloc
if ((hit_region->attr & REGION_ANON)) {
if (!PG_IS_PRESENT(*pte)) {
// -> a new page need to be alloc
if ((hit_region->attr & REGION_ANON)) {
if (!PG_IS_PRESENT(*pte)) {
- cpu_invplg(pte);
- uintptr_t pa = pmm_alloc_page(__current->pid, 0);
+ cpu_invplg((ptr_t)pte);
+
+ ptr_t pa = pmm_alloc_page(__current->pid, 0);
if (!pa) {
goto oom;
}
*pte = *pte | pa | PG_PRESENT;
if (!pa) {
goto oom;
}
*pte = *pte | pa | PG_PRESENT;
- memset(PG_ALIGN(ptr), 0, PG_SIZE);
+ memset(
(void*)
PG_ALIGN(ptr), 0, PG_SIZE);
goto resolved;
}
// permission denied on anon page (e.g., write on readonly page)
goto resolved;
}
// permission denied on anon page (e.g., write on readonly page)
@@
-94,20
+94,21
@@
intr_routine_page_fault(const isr_param* param)
u32_t mseg_off = (ptr - hit_region->start);
u32_t mfile_off = mseg_off + hit_region->foff;
u32_t mseg_off = (ptr - hit_region->start);
u32_t mfile_off = mseg_off + hit_region->foff;
-
uint
ptr_t pa = pmm_alloc_page(__current->pid, 0);
+ ptr_t pa = pmm_alloc_page(__current->pid, 0);
if (!pa) {
goto oom;
}
if (!pa) {
goto oom;
}
- cpu_invplg(pte);
+ cpu_invplg(
(ptr_t)
pte);
*pte = (*pte & 0xFFF) | pa | PG_PRESENT;
*pte = (*pte & 0xFFF) | pa | PG_PRESENT;
- memset(ptr, 0, PG_SIZE);
+ memset(
(void*)
ptr, 0, PG_SIZE);
int errno = 0;
if (mseg_off < hit_region->flen) {
int errno = 0;
if (mseg_off < hit_region->flen) {
- errno = file->ops->read_page(file->inode, ptr, PG_SIZE, mfile_off);
+ errno =
+ file->ops->read_page(file->inode, (void*)ptr, PG_SIZE, mfile_off);
}
if (errno < 0) {
}
if (errno < 0) {
@@
-142,16
+143,4
@@
segv_term:
resolved:
cpu_invplg(ptr);
return;
resolved:
cpu_invplg(ptr);
return;
-}
-
-int
-do_kernel(v_mapping* mapping)
-{
- uintptr_t addr = mapping->va;
-
- // TODO
-
- return 0;
-done:
- return 1;
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/asm/x86/syscall.S
b/lunaix-os/kernel/asm/x86/syscall.S
index 62e07212264d300aed2a80d7aaee2c0d0267d635..b48aeade91db4150136b9201f3872c5b616014e1 100644
(file)
--- a/
lunaix-os/kernel/asm/x86/syscall.S
+++ b/
lunaix-os/kernel/asm/x86/syscall.S
@@
-94,7
+94,7
@@
pushl 8(%ebp) /* ecx - #2 arg */
pushl 4(%ebp) /* ebx - #1 arg */
pushl 8(%ebp) /* ecx - #2 arg */
pushl 4(%ebp) /* ebx - #1 arg */
- call (%eax)
+ call
*
(%eax)
movl %eax, (%ebp) /* save the return value */
movl %eax, (%ebp) /* save the return value */
diff --git
a/lunaix-os/kernel/block/blkpart_gpt.c
b/lunaix-os/kernel/block/blkpart_gpt.c
index 22bb48b6d7bb61b9e9afd89d1fc8718446af9611..85c87e7e51e5a973d99fb08d60587e0c6f2eac12 100644
(file)
--- a/
lunaix-os/kernel/block/blkpart_gpt.c
+++ b/
lunaix-os/kernel/block/blkpart_gpt.c
@@
-25,7
+25,7
@@
blkpart_parse(struct device* master, struct gpt_header* header)
if (!bdev)
return ENODEV;
if (!bdev)
return ENODEV;
- int errno;
+ int errno
= 0
;
u32_t ent_lba = (u32_t)header->ents_lba;
struct gpt_entry* ents_parial = (struct gpt_entry*)valloc(GPT_BLKSIZE);
u32_t ent_lba = (u32_t)header->ents_lba;
struct gpt_entry* ents_parial = (struct gpt_entry*)valloc(GPT_BLKSIZE);
diff --git
a/lunaix-os/kernel/ds/fifo.c
b/lunaix-os/kernel/ds/fifo.c
index 252cd2dd7df55d290aa8270b588145a13eb50273..3741ac9d07fe8ee5418917d9f107a4466b17df68 100644
(file)
--- a/
lunaix-os/kernel/ds/fifo.c
+++ b/
lunaix-os/kernel/ds/fifo.c
@@
-44,7
+44,7
@@
fifo_backone(struct fifo_buf* fbuf)
}
size_t
}
size_t
-fifo_putone(struct fifo_buf* fbuf, u
int
8_t data)
+fifo_putone(struct fifo_buf* fbuf, u8_t data)
{
mutex_lock(&fbuf->lock);
{
mutex_lock(&fbuf->lock);
@@
-53,7
+53,7
@@
fifo_putone(struct fifo_buf* fbuf, uint8_t data)
return 0;
}
return 0;
}
- u
int
8_t* dest = fbuf->data;
+ u8_t* dest = fbuf->data;
dest[fbuf->wr_pos] = data;
fbuf->wr_pos = (fbuf->wr_pos + 1) % fbuf->size;
fbuf->free_len--;
dest[fbuf->wr_pos] = data;
fbuf->wr_pos = (fbuf->wr_pos + 1) % fbuf->size;
fbuf->free_len--;
@@
-64,13
+64,13
@@
fifo_putone(struct fifo_buf* fbuf, uint8_t data)
}
size_t
}
size_t
-fifo_readone_async(struct fifo_buf* fbuf, u
int
8_t* data)
+fifo_readone_async(struct fifo_buf* fbuf, u8_t* data)
{
if (fbuf->free_len == fbuf->size) {
return 0;
}
{
if (fbuf->free_len == fbuf->size) {
return 0;
}
- u
int
8_t* dest = fbuf->data;
+ u8_t* dest = fbuf->data;
*data = dest[fbuf->rd_pos];
fbuf->rd_pos = (fbuf->rd_pos + 1) % fbuf->size;
fbuf->free_len++;
*data = dest[fbuf->rd_pos];
fbuf->rd_pos = (fbuf->rd_pos + 1) % fbuf->size;
fbuf->free_len++;
diff --git
a/lunaix-os/kernel/ds/hstr.c
b/lunaix-os/kernel/ds/hstr.c
index 6c043f3513e87c625c0e3dd274ad51debba0fc16..4e64855dbeb3356b0270fa5af52c03def4a92fba 100644
(file)
--- a/
lunaix-os/kernel/ds/hstr.c
+++ b/
lunaix-os/kernel/ds/hstr.c
@@
-4,7
+4,7
@@
void
hstrcpy(struct hstr* dest, struct hstr* src)
{
void
hstrcpy(struct hstr* dest, struct hstr* src)
{
- strcpy(dest->value, src->value);
+ strcpy(
(char*)
dest->value, src->value);
dest->hash = src->hash;
dest->len = src->len;
}
\ No newline at end of file
dest->hash = src->hash;
dest->len = src->len;
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/exe/elf32/elf32bfmt.c
b/lunaix-os/kernel/exe/elf32/elf32bfmt.c
index 1079b06f85d12e0437a02b9a13a447bc4ae401b6..451c3946bd915dd23b5d0eaa631c092901f50a92 100644
(file)
--- a/
lunaix-os/kernel/exe/elf32/elf32bfmt.c
+++ b/
lunaix-os/kernel/exe/elf32/elf32bfmt.c
@@
-32,7
+32,7
@@
elf32_open(struct elf32* elf, const char* path)
}
int
}
int
-elf32_openat(struct elf32* elf, void* elf_vfile)
+elf32_openat(struct elf32* elf,
const
void* elf_vfile)
{
int status = 0;
elf->pheaders = NULL;
{
int status = 0;
elf->pheaders = NULL;
@@
-166,7
+166,7
@@
elf32_read_phdr(struct elf32* elf)
int
elf32_check_exec(const struct elf32* elf)
{
int
elf32_check_exec(const struct elf32* elf)
{
- struct elf32_ehdr* ehdr = &elf->eheader;
+
const
struct elf32_ehdr* ehdr = &elf->eheader;
return *(u32_t*)(ehdr->e_ident) == ELFMAGIC &&
ehdr->e_ident[EI_CLASS] == ELFCLASS32 &&
return *(u32_t*)(ehdr->e_ident) == ELFMAGIC &&
ehdr->e_ident[EI_CLASS] == ELFCLASS32 &&
diff --git
a/lunaix-os/kernel/exe/elf32/ldelf32.c
b/lunaix-os/kernel/exe/elf32/ldelf32.c
index 1204be4e1f8e0f760b48c03b2ca5e3d333a4d711..ec54a6538dc1b93e3ff1e297d44270bdb3bb1dbb 100644
(file)
--- a/
lunaix-os/kernel/exe/elf32/ldelf32.c
+++ b/
lunaix-os/kernel/exe/elf32/ldelf32.c
@@
-2,6
+2,7
@@
#include <lunaix/load.h>
#include <lunaix/mm/mmap.h>
#include <lunaix/mm/page.h>
#include <lunaix/load.h>
#include <lunaix/mm/mmap.h>
#include <lunaix/mm/page.h>
+#include <lunaix/mm/valloc.h>
#include <lunaix/spike.h>
int
#include <lunaix/spike.h>
int
diff --git
a/lunaix-os/kernel/exe/exec.c
b/lunaix-os/kernel/exe/exec.c
index 535f65978af69ade767718c7abc8b3a2f4de9a51..96559322ba485af625a60ad420e8ed12a440bd4f 100644
(file)
--- a/
lunaix-os/kernel/exe/exec.c
+++ b/
lunaix-os/kernel/exe/exec.c
@@
-64,7
+64,7
@@
exec_load(struct exec_container* container, struct v_file* executable)
size_t sz_argv = exec_str_size(argv, &argv_len);
size_t sz_envp = exec_str_size(envp, &envp_len);
size_t var_sz = ROUNDUP(sz_envp, PG_SIZE);
size_t sz_argv = exec_str_size(argv, &argv_len);
size_t sz_envp = exec_str_size(envp, &envp_len);
size_t var_sz = ROUNDUP(sz_envp, PG_SIZE);
- char** argv_extra = container->argv_pp;
+ c
onst c
har** argv_extra = container->argv_pp;
argv_extra[0] = executable->dnode->name.value;
argv_extra[0] = executable->dnode->name.value;
@@
-119,11
+119,11
@@
exec_load(struct exec_container* container, struct v_file* executable)
}
for (size_t i = 0; i < 2 && argv_extra[i]; i++, argv_len++) {
}
for (size_t i = 0; i < 2 && argv_extra[i]; i++, argv_len++) {
- char* extra_arg = argv_extra[i];
+ c
onst c
har* extra_arg = argv_extra[i];
size_t str_len = strlen(extra_arg);
ustack = (void*)((ptr_t)ustack - str_len);
size_t str_len = strlen(extra_arg);
ustack = (void*)((ptr_t)ustack - str_len);
- memcpy(ustack, (void*)extra_arg, str_len);
+ memcpy(ustack, (
const
void*)extra_arg, str_len);
}
// four args (arg{c|v}, env{c|p}) for main
}
// four args (arg{c|v}, env{c|p}) for main
@@
-183,7
+183,9
@@
exec_kexecve(const char* filename, const char* argv[], const char* envp[])
{
int errno = 0;
struct exec_container container;
{
int errno = 0;
struct exec_container container;
- exec_container(&container, __current, VMS_SELF, argv, envp);
+
+ exec_container(
+ &container, (struct proc_info*)__current, VMS_SELF, argv, envp);
errno = exec_load_byname(&container, filename);
errno = exec_load_byname(&container, filename);
@@
-212,7
+214,9
@@
__DEFINE_LXSYSCALL3(int,
{
int errno = 0;
struct exec_container container;
{
int errno = 0;
struct exec_container container;
- exec_container(&container, __current, VMS_SELF, argv, envp);
+
+ exec_container(
+ &container, (struct proc_info*)__current, VMS_SELF, argv, envp);
if ((errno = exec_load_byname(&container, filename))) {
goto done;
if ((errno = exec_load_byname(&container, filename))) {
goto done;
diff --git
a/lunaix-os/kernel/fs/defaults.c
b/lunaix-os/kernel/fs/defaults.c
index 145d9ca4c630ea5f9ac639c2f0f71c22bc465e75..878ec024a51b143ac6eeffdcd3bf85423ed44a63 100644
(file)
--- a/
lunaix-os/kernel/fs/defaults.c
+++ b/
lunaix-os/kernel/fs/defaults.c
@@
-44,6
+44,8
@@
default_file_readdir(struct v_file* file, struct dir_context* dctx)
dctx->read_complete_callback(dctx, pos->name.value, pos->name.len, 0);
break;
}
dctx->read_complete_callback(dctx, pos->name.value, pos->name.len, 0);
break;
}
+
+ return i;
}
int
}
int
diff --git
a/lunaix-os/kernel/fs/iso9660/directory.c
b/lunaix-os/kernel/fs/iso9660/directory.c
index 1d35978b06f84b3ead66688b1b661a875bb13a38..76262d2f5a5a53d64ec4542c1dca1340d51e00cf 100644
(file)
--- a/
lunaix-os/kernel/fs/iso9660/directory.c
+++ b/
lunaix-os/kernel/fs/iso9660/directory.c
@@
-52,10
+52,12
@@
done:
u32_t l = drec->name.len;
while (l < (u32_t)-1 && drec->name.content[l--] != ';')
;
u32_t l = drec->name.len;
while (l < (u32_t)-1 && drec->name.content[l--] != ';')
;
+
l = (l + 1) ? l : drec->name.len;
l = MIN(l, ISO9660_IDLEN - 1);
l = (l + 1) ? l : drec->name.len;
l = MIN(l, ISO9660_IDLEN - 1);
- strncpy(cache->name_val, drec->name.content, l);
+ strncpy(cache->name_val, (const char*)drec->name.content, l);
+
cache->name = HSTR(cache->name_val, l);
hstr_rehash(&cache->name, HSTR_FULL_HASH);
}
cache->name = HSTR(cache->name_val, l);
hstr_rehash(&cache->name, HSTR_FULL_HASH);
}
diff --git
a/lunaix-os/kernel/fs/iso9660/mount.c
b/lunaix-os/kernel/fs/iso9660/mount.c
index 35ebb4b3d53bc8219e909f27bee4f82e37fda265..724128f592c292cf389b17390831bff05201e631 100644
(file)
--- a/
lunaix-os/kernel/fs/iso9660/mount.c
+++ b/
lunaix-os/kernel/fs/iso9660/mount.c
@@
-93,6
+93,8
@@
int
iso9660_unmount(struct v_superblock* vsb)
{
vfree(vsb->data);
iso9660_unmount(struct v_superblock* vsb)
{
vfree(vsb->data);
+
+ return 0;
}
void
}
void
diff --git
a/lunaix-os/kernel/fs/iso9660/rockridge.c
b/lunaix-os/kernel/fs/iso9660/rockridge.c
index b211fdbd777441f9d42035156449a8504b7628d6..6dcb6108db6af7a90f4bea0829c24bb93408f282 100644
(file)
--- a/
lunaix-os/kernel/fs/iso9660/rockridge.c
+++ b/
lunaix-os/kernel/fs/iso9660/rockridge.c
@@
-1,3
+1,4
@@
+#include <klibc/string.h>
#include <lunaix/fs/iso9660.h>
int
#include <lunaix/fs/iso9660.h>
int
diff --git
a/lunaix-os/kernel/fs/pcache.c
b/lunaix-os/kernel/fs/pcache.c
index 0f30891669108f1a13d9eb544ce1b4910e1b0f02..d3e871eadc9e0ae831c3673e96d2366b2cedbca7 100644
(file)
--- a/
lunaix-os/kernel/fs/pcache.c
+++ b/
lunaix-os/kernel/fs/pcache.c
@@
-160,7
+160,7
@@
pcache_read(struct v_inode* inode, void* data, u32_t len, u32_t fpos)
fpos += rd_bytes;
}
fpos += rd_bytes;
}
- return errno < 0 ? errno : buf_off;
+ return errno < 0 ? errno :
(int)
buf_off;
}
void
}
void
@@
-180,7
+180,7
@@
int
pcache_commit(struct v_inode* inode, struct pcache_pg* page)
{
if (!(page->flags & PCACHE_DIRTY)) {
pcache_commit(struct v_inode* inode, struct pcache_pg* page)
{
if (!(page->flags & PCACHE_DIRTY)) {
- return;
+ return
0
;
}
int errno =
}
int errno =
diff --git
a/lunaix-os/kernel/fs/ramfs/ramfs.c
b/lunaix-os/kernel/fs/ramfs/ramfs.c
index 37f8869ac6ca3ec322d3f87e4dc4a610adcaa4a3..fece9b3ba503a369445896c781b13d58d1ae1414 100644
(file)
--- a/
lunaix-os/kernel/fs/ramfs/ramfs.c
+++ b/
lunaix-os/kernel/fs/ramfs/ramfs.c
@@
-41,7
+41,7
@@
'mountibility' for other fs.
*/
'mountibility' for other fs.
*/
-
volatile static
inode_t ino = 0;
+
static volatile
inode_t ino = 0;
extern const struct v_inode_ops ramfs_inode_ops;
extern const struct v_file_ops ramfs_file_ops;
extern const struct v_inode_ops ramfs_inode_ops;
extern const struct v_file_ops ramfs_file_ops;
@@
-119,8
+119,8
@@
void
ramfs_inode_init(struct v_superblock* vsb, struct v_inode* inode)
{
inode->id = ino++;
ramfs_inode_init(struct v_superblock* vsb, struct v_inode* inode)
{
inode->id = ino++;
- inode->ops = &ramfs_inode_ops;
- inode->default_fops = &ramfs_file_ops;
+ inode->ops =
(struct v_inode_ops*)
&ramfs_inode_ops;
+ inode->default_fops =
(struct v_file_ops*)
&ramfs_file_ops;
}
int
}
int
@@
-192,8
+192,10
@@
ramfs_unlink(struct v_inode* this)
if ((rinode->flags & RAMF_SYMLINK)) {
rinode->flags &= ~RAMF_SYMLINK;
this->itype &= ~VFS_IFSYMLINK;
if ((rinode->flags & RAMF_SYMLINK)) {
rinode->flags &= ~RAMF_SYMLINK;
this->itype &= ~VFS_IFSYMLINK;
+
vfree(rinode->symlink);
vfree(rinode->symlink);
- return;
+
+ return 0;
}
// TODO
}
// TODO
diff --git
a/lunaix-os/kernel/fs/twifs/twifs.c
b/lunaix-os/kernel/fs/twifs/twifs.c
index ca19c9dac145700ee82dbe9454a2a417469eb8ad..5cf47eeff413926fbc6ce87c83580fa38b493c6f 100644
(file)
--- a/
lunaix-os/kernel/fs/twifs/twifs.c
+++ b/
lunaix-os/kernel/fs/twifs/twifs.c
@@
-54,8
+54,8
@@
__twifs_new_node(struct twifs_node* parent,
void
__twifs_init_inode(struct v_superblock* vsb, struct v_inode* inode)
{
void
__twifs_init_inode(struct v_superblock* vsb, struct v_inode* inode)
{
- inode->ops = &twifs_inode_ops;
- inode->default_fops = &twifs_file_ops;
+ inode->ops =
(struct v_inode_ops*)
&twifs_inode_ops;
+ inode->default_fops =
(struct v_file_ops*)
&twifs_file_ops;
}
int
}
int
diff --git
a/lunaix-os/kernel/fs/vfs.c
b/lunaix-os/kernel/fs/vfs.c
index 6f4b3b09532bee8d9ca3dbdb98faade21aedeb40..988be639b242c4e048948c96fb4e3a5436baa20c 100644
(file)
--- a/
lunaix-os/kernel/fs/vfs.c
+++ b/
lunaix-os/kernel/fs/vfs.c
@@
-110,7
+110,7
@@
vfs_init()
atomic_fetch_add(&vfs_sysroot->ref_count, 1);
}
atomic_fetch_add(&vfs_sysroot->ref_count, 1);
}
-inline struct hbucket*
+
static
inline struct hbucket*
__dcache_hash(struct v_dnode* parent, u32_t* hash)
{
u32_t _hash = *hash;
__dcache_hash(struct v_dnode* parent, u32_t* hash)
{
u32_t _hash = *hash;
@@
-436,7
+436,7
@@
vfs_d_free(struct v_dnode* dnode)
vfs_dcache_remove(pos);
}
vfs_dcache_remove(pos);
}
- vfree(dnode->name.value);
+ vfree(
(void*)
dnode->name.value);
cake_release(dnode_pile, dnode);
}
cake_release(dnode_pile, dnode);
}
@@
-490,7
+490,6
@@
vfs_i_alloc(struct v_superblock* sb)
inode->atime = inode->ctime;
inode->mtime = inode->ctime;
inode->atime = inode->ctime;
inode->mtime = inode->ctime;
-done:
lru_use_one(inode_lru, &inode->lru);
return inode;
}
lru_use_one(inode_lru, &inode->lru);
return inode;
}
@@
-1210,7
+1209,7
@@
__DEFINE_LXSYSCALL2(int,
goto done;
}
goto done;
}
- if (
errno = vfs_check_writable(file
)) {
+ if (
(errno = vfs_check_writable(file)
)) {
goto done;
}
goto done;
}
@@
-1283,7
+1282,7
@@
__DEFINE_LXSYSCALL1(int, chdir, const char*, path)
goto done;
}
goto done;
}
- errno = vfs_do_chdir(__current, dnode);
+ errno = vfs_do_chdir(
(struct proc_info*)
__current, dnode);
done:
return DO_STATUS(errno);
done:
return DO_STATUS(errno);
@@
-1298,7
+1297,7
@@
__DEFINE_LXSYSCALL1(int, fchdir, int, fd)
goto done;
}
goto done;
}
- errno = vfs_do_chdir(__current, fd_s->file->dnode);
+ errno = vfs_do_chdir(
(struct proc_info*)
__current, fd_s->file->dnode);
done:
return DO_STATUS(errno);
done:
return DO_STATUS(errno);
@@
-1344,7
+1343,7
@@
vfs_do_rename(struct v_dnode* current, struct v_dnode* target)
return 0;
}
return 0;
}
- if (
errno = vfs_check_writable(current
)) {
+ if (
(errno = vfs_check_writable(current)
)) {
return errno;
}
return errno;
}
@@
-1428,6
+1427,6
@@
__DEFINE_LXSYSCALL2(int, rename, const char*, oldpath, const char*, newpath)
errno = vfs_do_rename(cur, target);
done:
errno = vfs_do_rename(cur, target);
done:
- vfree(name.value);
+ vfree(
(void*)
name.value);
return DO_STATUS(errno);
}
\ No newline at end of file
return DO_STATUS(errno);
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/fs/xattr.c
b/lunaix-os/kernel/fs/xattr.c
index 6fdb300727f574972c5c3b99d104956681111efd..3fa09a0a8e564ccd945cb066453a25a453cde992 100644
(file)
--- a/
lunaix-os/kernel/fs/xattr.c
+++ b/
lunaix-os/kernel/fs/xattr.c
@@
-15,7
+15,8
@@
xattr_new(struct hstr* name)
return NULL;
}
*entry =
return NULL;
}
*entry =
- (struct v_xattr_entry){ .name = HHSTR(valloc(VFS_NAME_MAXLEN), 0, 0) };
+ (struct v_xattr_entry){ .name = HHSTR(valloc(VFS_NAME_MAXLEN), 0, 0),
+ .value = NULL };
hstrcpy(&entry->name, name);
return entry;
hstrcpy(&entry->name, name);
return entry;
@@
-24,7
+25,7
@@
xattr_new(struct hstr* name)
void
xattr_free(struct v_xattr_entry* entry)
{
void
xattr_free(struct v_xattr_entry* entry)
{
- vfree(entry->name.value);
+ vfree(
(void*)
entry->name.value);
vfree(entry);
}
vfree(entry);
}
diff --git
a/lunaix-os/kernel/k_init.c
b/lunaix-os/kernel/k_init.c
index a2edf1a9d5c66007b5ada75b4e93aa0e80ad92cb..d399251960ee6421354c28d4d6a273f837a40d79 100644
(file)
--- a/
lunaix-os/kernel/k_init.c
+++ b/
lunaix-os/kernel/k_init.c
@@
-1,18
+1,20
@@
#include <lunaix/common.h>
#include <lunaix/common.h>
-#include <lunaix/tty/tty.h>
-
#include <lunaix/device.h>
#include <lunaix/foptions.h>
#include <lunaix/input.h>
#include <lunaix/isrm.h>
#include <lunaix/lxconsole.h>
#include <lunaix/device.h>
#include <lunaix/foptions.h>
#include <lunaix/input.h>
#include <lunaix/isrm.h>
#include <lunaix/lxconsole.h>
+#include <lunaix/mm/cake.h>
#include <lunaix/mm/mmio.h>
#include <lunaix/mm/page.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/mmio.h>
#include <lunaix/mm/page.h>
#include <lunaix/mm/pmm.h>
+#include <lunaix/mm/valloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/spike.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
#include <lunaix/spike.h>
+#include <lunaix/syscall.h>
+#include <lunaix/tty/tty.h>
#include <lunaix/types.h>
#include <arch/x86/boot/multiboot.h>
#include <lunaix/types.h>
#include <arch/x86/boot/multiboot.h>
@@
-22,9
+24,9
@@
#include <klibc/stdio.h>
#include <klibc/string.h>
#include <klibc/stdio.h>
#include <klibc/string.h>
-extern u
int
8_t __kernel_start;
-extern u
int
8_t __kernel_end;
-extern u
int
8_t __init_hhk_end;
+extern u8_t __kernel_start;
+extern u8_t __kernel_end;
+extern u8_t __init_hhk_end;
#define PP_KERN_SHARED (PP_FGSHARED | PP_TKERN)
#define PP_KERN_SHARED (PP_FGSHARED | PP_TKERN)
@@
-143,7
+145,7
@@
spawn_proc0()
// 为内核创建一个专属栈空间。
for (size_t i = 0; i < (KSTACK_SIZE >> PG_SIZE_BITS); i++) {
// 为内核创建一个专属栈空间。
for (size_t i = 0; i < (KSTACK_SIZE >> PG_SIZE_BITS); i++) {
-
uint
ptr_t pa = pmm_alloc_page(KERNEL_PID, 0);
+ ptr_t pa = pmm_alloc_page(KERNEL_PID, 0);
vmm_set_mapping(VMS_SELF,
KSTACK_START + (i << PG_SIZE_BITS),
pa,
vmm_set_mapping(VMS_SELF,
KSTACK_START + (i << PG_SIZE_BITS),
pa,
@@
-155,7
+157,7
@@
spawn_proc0()
(struct exec_param*)(KSTACK_TOP - sizeof(struct exec_param));
*execp = (struct exec_param){ .cs = KCODE_SEG,
(struct exec_param*)(KSTACK_TOP - sizeof(struct exec_param));
*execp = (struct exec_param){ .cs = KCODE_SEG,
- .eip = (
void*
)__proc0,
+ .eip = (
ptr_t
)__proc0,
.ss = KDATA_SEG,
.eflags = cpu_reflags() };
proc0->intr_ctx.execp = execp;
.ss = KDATA_SEG,
.eflags = cpu_reflags() };
proc0->intr_ctx.execp = execp;
@@
-177,8
+179,8
@@
spawn_proc0()
assert_msg(0, "Unexpected Return");
}
assert_msg(0, "Unexpected Return");
}
-extern
void
__usrtext_start;
-extern
void
__usrtext_end;
+extern
u8_t
__usrtext_start;
+extern
u8_t
__usrtext_end;
// 按照 Memory map 标识可用的物理页
void
// 按照 Memory map 标识可用的物理页
void
@@
-190,7
+192,7
@@
setup_memory(multiboot_memory_map_t* map, size_t map_size)
multiboot_memory_map_t mmap = map[i];
if (mmap.type == MULTIBOOT_MEMORY_AVAILABLE) {
// 整数向上取整除法
multiboot_memory_map_t mmap = map[i];
if (mmap.type == MULTIBOOT_MEMORY_AVAILABLE) {
// 整数向上取整除法
-
uint
ptr_t pg = map[i].addr_low + 0x0fffU;
+ ptr_t pg = map[i].addr_low + 0x0fffU;
pmm_mark_chunk_free(pg >> PG_SIZE_BITS,
map[i].len_low >> PG_SIZE_BITS);
}
pmm_mark_chunk_free(pg >> PG_SIZE_BITS,
map[i].len_low >> PG_SIZE_BITS);
}
@@
-200,7
+202,8
@@
setup_memory(multiboot_memory_map_t* map, size_t map_size)
size_t pg_count = V2P(&__kernel_end) >> PG_SIZE_BITS;
pmm_mark_chunk_occupied(KERNEL_PID, 0, pg_count, PP_FGLOCKED);
size_t pg_count = V2P(&__kernel_end) >> PG_SIZE_BITS;
pmm_mark_chunk_occupied(KERNEL_PID, 0, pg_count, PP_FGLOCKED);
- for (uintptr_t i = &__usrtext_start; i < &__usrtext_end; i += PG_SIZE) {
+ for (ptr_t i = (ptr_t)&__usrtext_start; i < (ptr_t)&__usrtext_end;
+ i += PG_SIZE) {
vmm_set_mapping(VMS_SELF, i, V2P(i), PG_PREM_UR, VMAP_NULL);
}
vmm_set_mapping(VMS_SELF, i, V2P(i), PG_PREM_UR, VMAP_NULL);
}
diff --git
a/lunaix-os/kernel/mm/cake.c
b/lunaix-os/kernel/mm/cake.c
index 5e03d347706c8943b08c9f2792aecb9d7765aad7..64343031c9a25478857e96f63f6c83b9dd6168e7 100644
(file)
--- a/
lunaix-os/kernel/mm/cake.c
+++ b/
lunaix-os/kernel/mm/cake.c
@@
-28,7
+28,7
@@
struct llist_header piles = { .next = &piles, .prev = &piles };
void*
__alloc_cake(unsigned int cake_pg)
{
void*
__alloc_cake(unsigned int cake_pg)
{
-
uintptr_t pa =
pmm_alloc_cpage(KERNEL_PID, cake_pg, 0);
+
ptr_t pa = (ptr_t)
pmm_alloc_cpage(KERNEL_PID, cake_pg, 0);
if (!pa) {
return NULL;
}
if (!pa) {
return NULL;
}
@@
-44,9
+44,11
@@
__new_cake(struct cake_pile* pile)
return NULL;
}
return NULL;
}
-
in
t max_piece = pile->pieces_per_cake;
+
u32_
t max_piece = pile->pieces_per_cake;
- cake->first_piece = (void*)((uintptr_t)cake + pile->offset);
+ assert(max_piece);
+
+ cake->first_piece = (void*)((ptr_t)cake + pile->offset);
cake->next_free = 0;
pile->cakes_count++;
cake->next_free = 0;
pile->cakes_count++;
@@
-154,7
+156,7
@@
cake_grab(struct cake_pile* pile)
}
void* ptr =
}
void* ptr =
- (void*)((
uint
ptr_t)pos->first_piece + found_index * pile->piece_size);
+ (void*)((ptr_t)pos->first_piece + found_index * pile->piece_size);
if (pile->ctor) {
pile->ctor(pile, ptr);
if (pile->ctor) {
pile->ctor(pile, ptr);
@@
-176,8
+178,7
@@
cake_release(struct cake_pile* pile, void* area)
if (pos->first_piece > area) {
continue;
}
if (pos->first_piece > area) {
continue;
}
- piece_index =
- (uintptr_t)(area - pos->first_piece) / pile->piece_size;
+ piece_index = (ptr_t)(area - pos->first_piece) / pile->piece_size;
if (piece_index < pile->pieces_per_cake) {
goto found;
}
if (piece_index < pile->pieces_per_cake) {
goto found;
}
diff --git
a/lunaix-os/kernel/mm/cow.c
b/lunaix-os/kernel/mm/cow.c
index 2350188f747c8e2bbd3f343b4449f314bd63b3e0..6b46e485ad80deab9b0794f6a8c4d18b13586b9e 100644
(file)
--- a/
lunaix-os/kernel/mm/cow.c
+++ b/
lunaix-os/kernel/mm/cow.c
@@
-1,9
+1,10
@@
+#include <lunaix/mm/pmm.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/mm/vmm.h>
-void*
-vmm_dup_page(pid_t pid,
void*
pa)
+ptr_t
+vmm_dup_page(pid_t pid,
ptr_t
pa)
{
{
-
void*
new_ppg = pmm_alloc_page(pid, 0);
+
ptr_t
new_ppg = pmm_alloc_page(pid, 0);
vmm_set_mapping(VMS_SELF, PG_MOUNT_3, new_ppg, PG_PREM_RW, VMAP_NULL);
vmm_set_mapping(VMS_SELF, PG_MOUNT_4, pa, PG_PREM_RW, VMAP_NULL);
vmm_set_mapping(VMS_SELF, PG_MOUNT_3, new_ppg, PG_PREM_RW, VMAP_NULL);
vmm_set_mapping(VMS_SELF, PG_MOUNT_4, pa, PG_PREM_RW, VMAP_NULL);
diff --git
a/lunaix-os/kernel/mm/dmm.c
b/lunaix-os/kernel/mm/dmm.c
index 3da8501f34aecdb43aa89a1fcd3270d15e9e6b6a..0fc2b6867d18ae2a031f788bc790292ae9c4b2aa 100644
(file)
--- a/
lunaix-os/kernel/mm/dmm.c
+++ b/
lunaix-os/kernel/mm/dmm.c
@@
-30,11
+30,13
@@
create_heap(struct proc_mm* pvms, ptr_t addr)
heap->region_copied = __heap_copied;
mm_index((void**)&pvms->heap, heap);
heap->region_copied = __heap_copied;
mm_index((void**)&pvms->heap, heap);
+
+ return status;
}
__DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
{
}
__DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
{
- struct proc_mm* pvms = &__current->mm;
+ struct proc_mm* pvms =
(struct proc_mm*)
&__current->mm;
struct mm_region* heap = pvms->heap;
assert(heap);
struct mm_region* heap = pvms->heap;
assert(heap);
@@
-47,11
+49,11
@@
__DEFINE_LXSYSCALL1(void*, sbrk, ssize_t, incr)
__DEFINE_LXSYSCALL1(int, brk, void*, addr)
{
__DEFINE_LXSYSCALL1(int, brk, void*, addr)
{
- struct proc_mm* pvms = &__current->mm;
+ struct proc_mm* pvms =
(struct proc_mm*)
&__current->mm;
struct mm_region* heap = pvms->heap;
if (!heap) {
struct mm_region* heap = pvms->heap;
if (!heap) {
- return DO_STATUS(create_heap(pvms, addr));
+ return DO_STATUS(create_heap(pvms,
(ptr_t)
addr));
}
assert(heap);
}
assert(heap);
diff --git
a/lunaix-os/kernel/mm/mmap.c
b/lunaix-os/kernel/mm/mmap.c
index 8eb7482b60af4b3bf7686a8e478ae0f54f1c7f52..f23ff60ab895702ee90271bcc5bc57e177db4bde 100644
(file)
--- a/
lunaix-os/kernel/mm/mmap.c
+++ b/
lunaix-os/kernel/mm/mmap.c
@@
-58,13
+58,13
@@
mem_adjust_inplace(vm_regions_t* regions,
int
mem_map(void** addr_out,
struct mm_region** created,
int
mem_map(void** addr_out,
struct mm_region** created,
-
void*
addr,
+
ptr_t
addr,
struct v_file* file,
struct mmap_param* param)
{
assert_msg(addr, "addr can not be NULL");
struct v_file* file,
struct mmap_param* param)
{
assert_msg(addr, "addr can not be NULL");
- ptr_t last_end = USER_START, found_loc =
(ptr_t)
addr;
+ ptr_t last_end = USER_START, found_loc = addr;
struct mm_region *pos, *n;
vm_regions_t* vm_regions = ¶m->pvms->regions;
struct mm_region *pos, *n;
vm_regions_t* vm_regions = ¶m->pvms->regions;
@@
-131,7
+131,7
@@
found:
}
if (addr_out) {
}
if (addr_out) {
- *addr_out = found_loc;
+ *addr_out =
(void*)
found_loc;
}
if (created) {
*created = region;
}
if (created) {
*created = region;
@@
-146,6
+146,9
@@
mem_remap(void** addr_out,
struct v_file* file,
struct mmap_param* param)
{
struct v_file* file,
struct mmap_param* param)
{
+ // TODO
+
+ return EINVAL;
}
void
}
void
@@
-168,9
+171,13
@@
mem_sync_pages(ptr_t mnt,
if (PG_IS_DIRTY(*mapping.pte)) {
size_t offset = mapping.va - region->start + region->foff;
struct v_inode* inode = region->mfile->inode;
if (PG_IS_DIRTY(*mapping.pte)) {
size_t offset = mapping.va - region->start + region->foff;
struct v_inode* inode = region->mfile->inode;
- region->mfile->ops->write_page(inode, mapping.va, PG_SIZE, offset);
+
+ region->mfile->ops->write_page(
+ inode, (void*)mapping.va, PG_SIZE, offset);
+
*mapping.pte &= ~PG_DIRTY;
*mapping.pte &= ~PG_DIRTY;
- cpu_invplg(mapping.pte);
+
+ cpu_invplg((ptr_t)mapping.pte);
} else if ((options & MS_INVALIDATE)) {
goto invalidate;
}
} else if ((options & MS_INVALIDATE)) {
goto invalidate;
}
@@
-184,7
+191,7
@@
mem_sync_pages(ptr_t mnt,
invalidate:
*mapping.pte &= ~PG_PRESENT;
pmm_free_page(KERNEL_PID, mapping.pa);
invalidate:
*mapping.pte &= ~PG_PRESENT;
pmm_free_page(KERNEL_PID, mapping.pa);
- cpu_invplg(mapping.pte);
+ cpu_invplg(
(ptr_t)
mapping.pte);
}
}
}
}
@@
-231,7
+238,7
@@
mem_unmap_region(ptr_t mnt, struct mm_region* region)
}
int
}
int
-mem_unmap(ptr_t mnt, vm_regions_t* regions,
void*
addr, size_t length)
+mem_unmap(ptr_t mnt, vm_regions_t* regions,
ptr_t
addr, size_t length)
{
length = ROUNDUP(length, PG_SIZE);
ptr_t cur_addr = PG_ALIGN(addr);
{
length = ROUNDUP(length, PG_SIZE);
ptr_t cur_addr = PG_ALIGN(addr);
@@
-289,14
+296,16
@@
__DEFINE_LXSYSCALL3(void*, sys_mmap, void*, addr, size_t, length, va_list, lst)
int errno = 0;
void* result = (void*)-1;
int errno = 0;
void* result = (void*)-1;
- if (!length || length > BS_SIZE || !PG_ALIGNED(addr)) {
+ ptr_t addr_ptr = (ptr_t)addr;
+
+ if (!length || length > BS_SIZE || !PG_ALIGNED(addr_ptr)) {
errno = EINVAL;
goto done;
}
errno = EINVAL;
goto done;
}
- if (!addr) {
- addr = UMMAP_START;
- } else if (addr
< UMMAP_START || add
r + length >= UMMAP_END) {
+ if (!addr
_ptr
) {
+ addr
_ptr
= UMMAP_START;
+ } else if (addr
_ptr < UMMAP_START || addr_pt
r + length >= UMMAP_END) {
if (!(options & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
errno = ENOMEM;
goto done;
if (!(options & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
errno = ENOMEM;
goto done;
@@
-323,19
+332,20
@@
__DEFINE_LXSYSCALL3(void*, sys_mmap, void*, addr, size_t, length, va_list, lst)
.offset = offset,
.type = REGION_TYPE_GENERAL,
.proct = proct,
.offset = offset,
.type = REGION_TYPE_GENERAL,
.proct = proct,
- .pvms = &__current->mm,
+ .pvms =
(struct proc_mm*)
&__current->mm,
.vms_mnt = VMS_SELF };
.vms_mnt = VMS_SELF };
- errno = mem_map(&result, NULL, addr, file, ¶m);
+ errno = mem_map(&result, NULL, addr
_ptr
, file, ¶m);
done:
__current->k_status = errno;
return result;
}
done:
__current->k_status = errno;
return result;
}
-__DEFINE_LXSYSCALL2(
void
, munmap, void*, addr, size_t, length)
+__DEFINE_LXSYSCALL2(
int
, munmap, void*, addr, size_t, length)
{
{
- return mem_unmap(VMS_SELF, &__current->mm.regions, addr, length);
+ return mem_unmap(
+ VMS_SELF, (vm_regions_t*)&__current->mm.regions, (ptr_t)addr, length);
}
__DEFINE_LXSYSCALL3(int, msync, void*, addr, size_t, length, int, flags)
}
__DEFINE_LXSYSCALL3(int, msync, void*, addr, size_t, length, int, flags)
@@
-344,8
+354,11
@@
__DEFINE_LXSYSCALL3(int, msync, void*, addr, size_t, length, int, flags)
return DO_STATUS(EINVAL);
}
return DO_STATUS(EINVAL);
}
- int status =
- mem_msync(VMS_SELF, &__current->mm.regions, addr, length, flags);
+ int status = mem_msync(VMS_SELF,
+ (vm_regions_t*)&__current->mm.regions,
+ (ptr_t)addr,
+ length,
+ flags);
return DO_STATUS(status);
}
\ No newline at end of file
return DO_STATUS(status);
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/mm/mmio.c
b/lunaix-os/kernel/mm/mmio.c
index e9843d64d9ade7273b7b8e845446515752283d7d..cac4a894a7f7c25552c2b779eaeb2de926792b6e 100644
(file)
--- a/
lunaix-os/kernel/mm/mmio.c
+++ b/
lunaix-os/kernel/mm/mmio.c
@@
-4,23
+4,25
@@
#include <lunaix/spike.h>
void*
#include <lunaix/spike.h>
void*
-ioremap(
uint
ptr_t paddr, u32_t size)
+ioremap(ptr_t paddr, u32_t size)
{
void* ptr = vmm_vmap(paddr, size, PG_PREM_RW | PG_DISABLE_CACHE);
{
void* ptr = vmm_vmap(paddr, size, PG_PREM_RW | PG_DISABLE_CACHE);
+
if (ptr) {
pmm_mark_chunk_occupied(KERNEL_PID,
paddr >> PG_SIZE_BITS,
CEIL(size, PG_SIZE_BITS),
PP_FGLOCKED);
}
if (ptr) {
pmm_mark_chunk_occupied(KERNEL_PID,
paddr >> PG_SIZE_BITS,
CEIL(size, PG_SIZE_BITS),
PP_FGLOCKED);
}
+
return ptr;
}
return ptr;
}
-void
*
-iounmap(
uint
ptr_t vaddr, u32_t size)
+void
+iounmap(ptr_t vaddr, u32_t size)
{
for (size_t i = 0; i < size; i += PG_SIZE) {
{
for (size_t i = 0; i < size; i += PG_SIZE) {
-
uint
ptr_t paddr = vmm_del_mapping(VMS_SELF, vaddr + i);
+ ptr_t paddr = vmm_del_mapping(VMS_SELF, vaddr + i);
pmm_free_page(KERNEL_PID, paddr);
}
}
\ No newline at end of file
pmm_free_page(KERNEL_PID, paddr);
}
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/mm/pmm.c
b/lunaix-os/kernel/mm/pmm.c
index 3ebe22a10d34fdcec5446283534a1e10e4ca0051..758926190be90537fcf7bdb61cec05e194fe21ad 100644
(file)
--- a/
lunaix-os/kernel/mm/pmm.c
+++ b/
lunaix-os/kernel/mm/pmm.c
@@
-5,23
+5,23
@@
// This is a very large array...
static struct pp_struct pm_table[PM_BMP_MAX_SIZE];
// This is a very large array...
static struct pp_struct pm_table[PM_BMP_MAX_SIZE];
-static
uint
ptr_t max_pg;
+static ptr_t max_pg;
void
void
-pmm_mark_page_free(
uint
ptr_t ppn)
+pmm_mark_page_free(ptr_t ppn)
{
pm_table[ppn].ref_counts = 0;
}
void
{
pm_table[ppn].ref_counts = 0;
}
void
-pmm_mark_page_occupied(pid_t owner,
uint
ptr_t ppn, pp_attr_t attr)
+pmm_mark_page_occupied(pid_t owner, ptr_t ppn, pp_attr_t attr)
{
pm_table[ppn] =
(struct pp_struct){ .owner = owner, .ref_counts = 1, .attr = attr };
}
void
{
pm_table[ppn] =
(struct pp_struct){ .owner = owner, .ref_counts = 1, .attr = attr };
}
void
-pmm_mark_chunk_free(
uint
ptr_t start_ppn, size_t page_count)
+pmm_mark_chunk_free(ptr_t start_ppn, size_t page_count)
{
for (size_t i = start_ppn; i < start_ppn + page_count && i < max_pg; i++) {
pm_table[i].ref_counts = 0;
{
for (size_t i = start_ppn; i < start_ppn + page_count && i < max_pg; i++) {
pm_table[i].ref_counts = 0;
@@
-46,7
+46,7
@@
pmm_mark_chunk_occupied(pid_t owner,
volatile size_t pg_lookup_ptr;
void
volatile size_t pg_lookup_ptr;
void
-pmm_init(
uint
ptr_t mem_upper_lim)
+pmm_init(ptr_t mem_upper_lim)
{
max_pg = (PG_ALIGN(mem_upper_lim) >> 12);
{
max_pg = (PG_ALIGN(mem_upper_lim) >> 12);
@@
-59,7
+59,7
@@
pmm_init(uintptr_t mem_upper_lim)
}
}
}
}
-void*
+ptr_t
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr)
{
size_t p1 = 0;
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr)
{
size_t p1 = 0;
@@
-70,7
+70,7
@@
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr)
}
if (p2 == max_pg && p2 - p1 < num_pages) {
}
if (p2 == max_pg && p2 - p1 < num_pages) {
- return NULL;
+ return NULL
PTR
;
}
pmm_mark_chunk_occupied(owner, p1, num_pages, attr);
}
pmm_mark_chunk_occupied(owner, p1, num_pages, attr);
@@
-78,11
+78,11
@@
pmm_alloc_cpage(pid_t owner, size_t num_pages, pp_attr_t attr)
return p1 << 12;
}
return p1 << 12;
}
-void*
+ptr_t
pmm_alloc_page(pid_t owner, pp_attr_t attr)
{
// Next fit approach. Maximize the throughput!
pmm_alloc_page(pid_t owner, pp_attr_t attr)
{
// Next fit approach. Maximize the throughput!
-
uintptr_t good_page_found = (uint
ptr_t)NULL;
+
ptr_t good_page_found = (
ptr_t)NULL;
size_t old_pg_ptr = pg_lookup_ptr;
size_t upper_lim = max_pg;
struct pp_struct* pm;
size_t old_pg_ptr = pg_lookup_ptr;
size_t upper_lim = max_pg;
struct pp_struct* pm;
@@
-111,16
+111,16
@@
pmm_alloc_page(pid_t owner, pp_attr_t attr)
if (!good_page_found) {
__current->k_status = LXOUTOFMEM;
}
if (!good_page_found) {
__current->k_status = LXOUTOFMEM;
}
- return
(void*)
good_page_found;
+ return good_page_found;
}
int
}
int
-pmm_free_page(pid_t owner,
void*
page)
+pmm_free_page(pid_t owner,
ptr_t
page)
{
{
- struct pp_struct* pm = &pm_table[
(intptr_t)
page >> 12];
+ struct pp_struct* pm = &pm_table[page >> 12];
// Is this a MMIO mapping or double free?
// Is this a MMIO mapping or double free?
- if ((
(intptr_t)
page >> 12) >= max_pg || !(pm->ref_counts)) {
+ if ((page >> 12) >= max_pg || !(pm->ref_counts)) {
return 0;
}
return 0;
}
@@
-136,11
+136,11
@@
pmm_free_page(pid_t owner, void* page)
}
int
}
int
-pmm_ref_page(pid_t owner,
void*
page)
+pmm_ref_page(pid_t owner,
ptr_t
page)
{
{
- (void
*
)owner; // TODO: do smth with owner
+ (void)owner; // TODO: do smth with owner
- u32_t ppn =
(uintptr_t)
page >> 12;
+ u32_t ppn = page >> 12;
if (ppn >= PM_BMP_MAX_SIZE) {
return 0;
if (ppn >= PM_BMP_MAX_SIZE) {
return 0;
@@
-156,9
+156,9
@@
pmm_ref_page(pid_t owner, void* page)
}
struct pp_struct*
}
struct pp_struct*
-pmm_query(
void*
pa)
+pmm_query(
ptr_t
pa)
{
{
- u32_t ppn =
(uintptr_t)
pa >> 12;
+ u32_t ppn = pa >> 12;
if (ppn >= PM_BMP_MAX_SIZE) {
return NULL;
if (ppn >= PM_BMP_MAX_SIZE) {
return NULL;
diff --git
a/lunaix-os/kernel/mm/vmap.c
b/lunaix-os/kernel/mm/vmap.c
index 285debce407359fbd5ef14654fab724e5a4d96fe..ad1a832a5a4dc8c80ff3ede81221f6ba41a15b5c 100644
(file)
--- a/
lunaix-os/kernel/mm/vmap.c
+++ b/
lunaix-os/kernel/mm/vmap.c
@@
-5,16
+5,16
@@
#define VMAP_START PG_MOUNT_BASE + MEM_4MB
#define VMAP_END VMS_SELF
#define VMAP_START PG_MOUNT_BASE + MEM_4MB
#define VMAP_END VMS_SELF
-static
uint
ptr_t start = VMAP_START;
+static ptr_t start = VMAP_START;
void*
void*
-vmm_vmap(
uint
ptr_t paddr, size_t size, pt_attr attr)
+vmm_vmap(ptr_t paddr, size_t size, pt_attr attr)
{
// next fit
assert_msg((paddr & 0xfff) == 0, "vmap: bad alignment");
size = ROUNDUP(size, PG_SIZE);
{
// next fit
assert_msg((paddr & 0xfff) == 0, "vmap: bad alignment");
size = ROUNDUP(size, PG_SIZE);
-
uint
ptr_t current_addr = start;
+ ptr_t current_addr = start;
size_t examed_size = 0, wrapped = 0;
x86_page_table* pd = (x86_page_table*)L1_BASE_VADDR;
size_t examed_size = 0, wrapped = 0;
x86_page_table* pd = (x86_page_table*)L1_BASE_VADDR;
@@
-54,7
+54,7
@@
vmm_vmap(uintptr_t paddr, size_t size, pt_attr attr)
return NULL;
done:
return NULL;
done:
-
uint
ptr_t alloc_begin = current_addr - examed_size;
+ ptr_t alloc_begin = current_addr - examed_size;
for (size_t i = 0; i < size; i += PG_SIZE) {
vmm_set_mapping(VMS_SELF, alloc_begin + i, paddr + i, PG_PREM_RW, 0);
pmm_ref_page(KERNEL_PID, paddr + i);
for (size_t i = 0; i < size; i += PG_SIZE) {
vmm_set_mapping(VMS_SELF, alloc_begin + i, paddr + i, PG_PREM_RW, 0);
pmm_ref_page(KERNEL_PID, paddr + i);
diff --git
a/lunaix-os/kernel/mm/vmm.c
b/lunaix-os/kernel/mm/vmm.c
index 8f67bd2d8237ad53d80a5ddd48f98f4b38e762b1..3340f114c895ea05bc153aed0f52a9ac88589d2a 100644
(file)
--- a/
lunaix-os/kernel/mm/vmm.c
+++ b/
lunaix-os/kernel/mm/vmm.c
@@
-29,16
+29,12
@@
vmm_init_pd()
}
int
}
int
-vmm_set_mapping(uintptr_t mnt,
- uintptr_t va,
- uintptr_t pa,
- pt_attr attr,
- int options)
+vmm_set_mapping(ptr_t mnt, ptr_t va, ptr_t pa, pt_attr attr, int options)
{
{
- assert((
uint
ptr_t)va % PG_SIZE == 0);
+ assert((ptr_t)va % PG_SIZE == 0);
-
uint
ptr_t l1_inx = L1_INDEX(va);
-
uint
ptr_t l2_inx = L2_INDEX(va);
+ ptr_t l1_inx = L1_INDEX(va);
+ ptr_t l2_inx = L2_INDEX(va);
x86_page_table* l1pt = (x86_page_table*)(mnt | (1023 << 12));
x86_page_table* l2pt = (x86_page_table*)(mnt | (l1_inx << 12));
x86_page_table* l1pt = (x86_page_table*)(mnt | (1023 << 12));
x86_page_table* l2pt = (x86_page_table*)(mnt | (l1_inx << 12));
@@
-46,7
+42,8
@@
vmm_set_mapping(uintptr_t mnt,
assert(attr <= 128);
if (!l1pt->entry[l1_inx]) {
assert(attr <= 128);
if (!l1pt->entry[l1_inx]) {
- x86_page_table* new_l1pt_pa = pmm_alloc_page(KERNEL_PID, PP_FGPERSIST);
+ x86_page_table* new_l1pt_pa =
+ (x86_page_table*)pmm_alloc_page(KERNEL_PID, PP_FGPERSIST);
// 物理内存已满!
if (!new_l1pt_pa) {
// 物理内存已满!
if (!new_l1pt_pa) {
@@
-58,7
+55,7
@@
vmm_set_mapping(uintptr_t mnt,
NEW_L1_ENTRY(attr | PG_WRITE | PG_PRESENT, new_l1pt_pa);
// make sure our new l2 table is visible to CPU
NEW_L1_ENTRY(attr | PG_WRITE | PG_PRESENT, new_l1pt_pa);
// make sure our new l2 table is visible to CPU
- cpu_invplg(l2pt);
+ cpu_invplg(
(ptr_t)
l2pt);
memset((void*)l2pt, 0, PG_SIZE);
} else {
memset((void*)l2pt, 0, PG_SIZE);
} else {
@@
-80,10
+77,10
@@
vmm_set_mapping(uintptr_t mnt,
return 1;
}
return 1;
}
-
uint
ptr_t
-vmm_del_mapping(
uintptr_t mnt, uint
ptr_t va)
+ptr_t
+vmm_del_mapping(
ptr_t mnt,
ptr_t va)
{
{
- assert(((
uint
ptr_t)va & 0xFFFU) == 0);
+ assert(((ptr_t)va & 0xFFFU) == 0);
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
@@
-111,13
+108,13
@@
vmm_del_mapping(uintptr_t mnt, uintptr_t va)
}
int
}
int
-vmm_lookup(
uint
ptr_t va, v_mapping* mapping)
+vmm_lookup(ptr_t va, v_mapping* mapping)
{
return vmm_lookupat(VMS_SELF, va, mapping);
}
int
{
return vmm_lookupat(VMS_SELF, va, mapping);
}
int
-vmm_lookupat(ptr_t mnt,
uint
ptr_t va, v_mapping* mapping)
+vmm_lookupat(ptr_t mnt, ptr_t va, v_mapping* mapping)
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
@@
-128,6
+125,7
@@
vmm_lookupat(ptr_t mnt, uintptr_t va, v_mapping* mapping)
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)(mnt | (l1_index << 12)))->entry[l2_index];
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)(mnt | (l1_index << 12)))->entry[l2_index];
+
if (l2pte) {
mapping->flags = PG_ENTRY_FLAGS(*l2pte);
mapping->pa = PG_ENTRY_ADDR(*l2pte);
if (l2pte) {
mapping->flags = PG_ENTRY_FLAGS(*l2pte);
mapping->pa = PG_ENTRY_ADDR(*l2pte);
@@
-137,11
+135,12
@@
vmm_lookupat(ptr_t mnt, uintptr_t va, v_mapping* mapping)
return 1;
}
}
return 1;
}
}
+
return 0;
}
return 0;
}
-void*
-vmm_v2p(
void*
va)
+ptr_t
+vmm_v2p(
ptr_t
va)
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
@@
-152,15
+151,16
@@
vmm_v2p(void* va)
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)L2_VADDR(l1_index))->entry[l2_index];
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)L2_VADDR(l1_index))->entry[l2_index];
+
if (l2pte) {
if (l2pte) {
- return PG_ENTRY_ADDR(*l2pte) | ((
uint
ptr_t)va & 0xfff);
+ return PG_ENTRY_ADDR(*l2pte) | ((ptr_t)va & 0xfff);
}
}
return 0;
}
}
}
return 0;
}
-void*
-vmm_v2pat(ptr_t mnt,
void*
va)
+ptr_t
+vmm_v2pat(ptr_t mnt,
ptr_t
va)
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
{
u32_t l1_index = L1_INDEX(va);
u32_t l2_index = L2_INDEX(va);
@@
-171,15
+171,16
@@
vmm_v2pat(ptr_t mnt, void* va)
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)(mnt | (l1_index << 12)))->entry[l2_index];
if (l1pte) {
x86_pte_t* l2pte =
&((x86_page_table*)(mnt | (l1_index << 12)))->entry[l2_index];
+
if (l2pte) {
if (l2pte) {
- return PG_ENTRY_ADDR(*l2pte) | ((
uint
ptr_t)va & 0xfff);
+ return PG_ENTRY_ADDR(*l2pte) | ((ptr_t)va & 0xfff);
}
}
return 0;
}
}
}
return 0;
}
-void*
-vmm_mount_pd(
uintptr_t mnt, void*
pde)
+ptr_t
+vmm_mount_pd(
ptr_t mnt, ptr_t
pde)
{
x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
l1pt->entry[(mnt >> 22)] = NEW_L1_ENTRY(T_SELF_REF_PERM, pde);
{
x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
l1pt->entry[(mnt >> 22)] = NEW_L1_ENTRY(T_SELF_REF_PERM, pde);
@@
-187,10
+188,11
@@
vmm_mount_pd(uintptr_t mnt, void* pde)
return mnt;
}
return mnt;
}
-void*
-vmm_unmount_pd(
uint
ptr_t mnt)
+ptr_t
+vmm_unmount_pd(ptr_t mnt)
{
x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
l1pt->entry[(mnt >> 22)] = 0;
cpu_invplg(mnt);
{
x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
l1pt->entry[(mnt >> 22)] = 0;
cpu_invplg(mnt);
+ return mnt;
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/peripheral/ps2kbd.c
b/lunaix-os/kernel/peripheral/ps2kbd.c
index 83ad3573190b7485060436a601ff4ae2fc52bd51..c31d73666b84fa4e7d849b97d80ef98720a562f3 100644
(file)
--- a/
lunaix-os/kernel/peripheral/ps2kbd.c
+++ b/
lunaix-os/kernel/peripheral/ps2kbd.c
@@
-86,8
+86,8
@@
static struct input_device* kbd_idev;
void
intr_ps2_kbd_handler(const isr_param* param);
void
intr_ps2_kbd_handler(const isr_param* param);
-static u
int
8_t
-ps2_issue_cmd_wretry(char cmd, u
int
16_t arg);
+static u8_t
+ps2_issue_cmd_wretry(char cmd, u16_t arg);
void
ps2_device_post_cmd(char cmd, char arg)
void
ps2_device_post_cmd(char cmd, char arg)
@@
-207,7
+207,6
@@
ps2_kbd_init()
*/
isrm_bindirq(PC_AT_IRQ_KBD, intr_ps2_kbd_handler);
*/
isrm_bindirq(PC_AT_IRQ_KBD, intr_ps2_kbd_handler);
-done:
cpu_enable_interrupt();
}
cpu_enable_interrupt();
}
@@
-231,7
+230,7
@@
ps2_process_cmd(void* arg)
// 处理队列排头的指令
struct ps2_cmd* pending_cmd = &cmd_q.cmd_queue[cmd_q.queue_ptr];
// 处理队列排头的指令
struct ps2_cmd* pending_cmd = &cmd_q.cmd_queue[cmd_q.queue_ptr];
-
char
result;
+
u8_t
result;
int attempts = 0;
// 尝试将命令发送至PS/2键盘(通过PS/2控制器)
int attempts = 0;
// 尝试将命令发送至PS/2键盘(通过PS/2控制器)
@@
-251,7
+250,7
@@
ps2_process_cmd(void* arg)
}
void
}
void
-kbd_buffer_key_event(kbd_keycode_t key, u
int
8_t scancode, kbd_kstate_t state)
+kbd_buffer_key_event(kbd_keycode_t key, u8_t scancode, kbd_kstate_t state)
{
/*
forgive me on these ugly bit-level tricks,
{
/*
forgive me on these ugly bit-level tricks,
@@
-306,7
+305,7
@@
intr_ps2_kbd_handler(const isr_param* param)
// check. But DO NOT. This chunk is in right place and right order. Moving
// it at your own risk This is to ensure we've cleared the output buffer
// everytime, so it won't pile up across irqs.
// check. But DO NOT. This chunk is in right place and right order. Moving
// it at your own risk This is to ensure we've cleared the output buffer
// everytime, so it won't pile up across irqs.
- u
int
8_t scancode = io_inb(PS2_PORT_ENC_DATA);
+ u8_t scancode = io_inb(PS2_PORT_ENC_DATA);
kbd_keycode_t key;
/*
kbd_keycode_t key;
/*
@@
-403,8
+402,8
@@
intr_ps2_kbd_handler(const isr_param* param)
}
}
}
}
-static u
int
8_t
-ps2_issue_cmd(char cmd, u
int
16_t arg)
+static u8_t
+ps2_issue_cmd(char cmd, u16_t arg)
{
ps2_post_cmd(PS2_PORT_CTRL_CMDREG, cmd, arg);
{
ps2_post_cmd(PS2_PORT_CTRL_CMDREG, cmd, arg);
@@
-416,10
+415,10
@@
ps2_issue_cmd(char cmd, uint16_t arg)
return io_inb(PS2_PORT_ENC_CMDREG);
}
return io_inb(PS2_PORT_ENC_CMDREG);
}
-static u
int
8_t
-ps2_issue_cmd_wretry(char cmd, u
int
16_t arg)
+static u8_t
+ps2_issue_cmd_wretry(char cmd, u16_t arg)
{
{
- u
int
8_t r, c = 0;
+ u8_t r, c = 0;
while ((r = ps2_issue_cmd(cmd, arg)) == PS2_RESULT_NAK && c < 5) {
c++;
}
while ((r = ps2_issue_cmd(cmd, arg)) == PS2_RESULT_NAK && c < 5) {
c++;
}
@@
-430,7
+429,7
@@
ps2_issue_cmd_wretry(char cmd, uint16_t arg)
}
static void
}
static void
-ps2_post_cmd(u
int8_t port, char cmd, uint
16_t arg)
+ps2_post_cmd(u
8_t port, char cmd, u
16_t arg)
{
// 等待PS/2输入缓冲区清空,这样我们才可以写入命令
while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
{
// 等待PS/2输入缓冲区清空,这样我们才可以写入命令
while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
@@
-443,13
+442,13
@@
ps2_post_cmd(uint8_t port, char cmd, uint16_t arg)
// 所有参数一律通过0x60传入。
while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
;
// 所有参数一律通过0x60传入。
while (io_inb(PS2_PORT_CTRL_STATUS) & PS2_STATUS_IFULL)
;
- io_outb(PS2_PORT_ENC_CMDREG, (u
int
8_t)(arg & 0x00ff));
+ io_outb(PS2_PORT_ENC_CMDREG, (u8_t)(arg & 0x00ff));
io_delay(PS2_DELAY);
}
}
io_delay(PS2_DELAY);
}
}
-static u
int
8_t
-ps2_issue_dev_cmd(char cmd, u
int
16_t arg)
+static u8_t
+ps2_issue_dev_cmd(char cmd, u16_t arg)
{
ps2_post_cmd(PS2_PORT_ENC_CMDREG, cmd, arg);
{
ps2_post_cmd(PS2_PORT_ENC_CMDREG, cmd, arg);
diff --git
a/lunaix-os/kernel/peripheral/serial.c
b/lunaix-os/kernel/peripheral/serial.c
index 5d3629c87efefb26e3b493c4bd0d5c54e95e7641..69fb290942ed942c1e6b89041de942378f696481 100644
(file)
--- a/
lunaix-os/kernel/peripheral/serial.c
+++ b/
lunaix-os/kernel/peripheral/serial.c
@@
-6,7
+6,7
@@
LOG_MODULE("UART")
void
LOG_MODULE("UART")
void
-serial_init_port(
uint
ptr_t port)
+serial_init_port(ptr_t port)
{
// disable interrupt, use irq instead
io_outb(COM_RIE(port), 0);
{
// disable interrupt, use irq instead
io_outb(COM_RIE(port), 0);
@@
-46,7
+46,7
@@
serial_init()
}
char
}
char
-serial_rx_byte(
uint
ptr_t port)
+serial_rx_byte(ptr_t port)
{
while (!(io_inb(COM_RSLINE(port)) & 0x01))
;
{
while (!(io_inb(COM_RSLINE(port)) & 0x01))
;
@@
-55,7
+55,7
@@
serial_rx_byte(uintptr_t port)
}
void
}
void
-serial_rx_buffer(
uint
ptr_t port, char* data, size_t len)
+serial_rx_buffer(ptr_t port, char* data, size_t len)
{
for (size_t i = 0; i < len; i++) {
data[i] = serial_rx_byte(port);
{
for (size_t i = 0; i < len; i++) {
data[i] = serial_rx_byte(port);
@@
-63,7
+63,7
@@
serial_rx_buffer(uintptr_t port, char* data, size_t len)
}
void
}
void
-serial_tx_byte(
uint
ptr_t port, char data)
+serial_tx_byte(ptr_t port, char data)
{
while (!(io_inb(COM_RSLINE(port)) & 0x20))
;
{
while (!(io_inb(COM_RSLINE(port)) & 0x20))
;
@@
-72,7
+72,7
@@
serial_tx_byte(uintptr_t port, char data)
}
void
}
void
-serial_tx_buffer(
uint
ptr_t port, char* data, size_t len)
+serial_tx_buffer(ptr_t port, char* data, size_t len)
{
for (size_t i = 0; i < len; i++) {
serial_tx_byte(port, data[i]);
{
for (size_t i = 0; i < len; i++) {
serial_tx_byte(port, data[i]);
@@
-80,7
+80,7
@@
serial_tx_buffer(uintptr_t port, char* data, size_t len)
}
void
}
void
-serial_clear_fifo(
uint
ptr_t port)
+serial_clear_fifo(ptr_t port)
{
io_outb(COM_RIE(port), 0x0);
io_outb(COM_RCFIFO(port), 0x00);
{
io_outb(COM_RIE(port), 0x0);
io_outb(COM_RCFIFO(port), 0x00);
@@
-90,13
+90,13
@@
serial_clear_fifo(uintptr_t port)
}
void
}
void
-serial_disable_irq(
uint
ptr_t port)
+serial_disable_irq(ptr_t port)
{
io_outb(COM_RIE(port), 0x0);
}
void
{
io_outb(COM_RIE(port), 0x0);
}
void
-serial_enable_irq(
uint
ptr_t port)
+serial_enable_irq(ptr_t port)
{
io_outb(COM_RIE(port), 0x1);
}
\ No newline at end of file
{
io_outb(COM_RIE(port), 0x1);
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/proc0.c
b/lunaix-os/kernel/proc0.c
index 2029bc593ccf9ccef10f896f4c38beb4464be184..379ebf53b87b591fa07a84be0d3bbffee7300253 100644
(file)
--- a/
lunaix-os/kernel/proc0.c
+++ b/
lunaix-os/kernel/proc0.c
@@
-102,9
+102,9
@@
__proc0()
}
}
}
}
-extern u
int8_t __kernel_start;
/* link/linker.ld */
-extern u
int8_t __kernel_end;
/* link/linker.ld */
-extern u
int8_t __init_hhk_end;
/* link/linker.ld */
+extern u
8_t __kernel_start;
/* link/linker.ld */
+extern u
8_t __kernel_end;
/* link/linker.ld */
+extern u
8_t __init_hhk_end;
/* link/linker.ld */
extern multiboot_info_t* _k_init_mb_info; /* k_init.c */
void
extern multiboot_info_t* _k_init_mb_info; /* k_init.c */
void
@@
-150,9
+150,9
@@
init_platform()
unlock_reserved_memory();
// clean up
unlock_reserved_memory();
// clean up
- for (size_t i = 0; i < (
uint
ptr_t)(&__init_hhk_end); i += PG_SIZE) {
- vmm_del_mapping(VMS_SELF, (
void*
)i);
- pmm_free_page(KERNEL_PID, (
void*
)i);
+ for (size_t i = 0; i < (ptr_t)(&__init_hhk_end); i += PG_SIZE) {
+ vmm_del_mapping(VMS_SELF, (
ptr_t
)i);
+ pmm_free_page(KERNEL_PID, (
ptr_t
)i);
}
}
}
}
@@
-171,26
+171,33
@@
unlock_reserved_memory()
void
__do_reserved_memory(int unlock)
{
void
__do_reserved_memory(int unlock)
{
- multiboot_memory_map_t* mmaps = _k_init_mb_info->mmap_addr;
+ multiboot_memory_map_t* mmaps =
+ (multiboot_memory_map_t*)_k_init_mb_info->mmap_addr;
+
size_t map_size =
_k_init_mb_info->mmap_length / sizeof(multiboot_memory_map_t);
size_t map_size =
_k_init_mb_info->mmap_length / sizeof(multiboot_memory_map_t);
+
// v_mapping mapping;
for (unsigned int i = 0; i < map_size; i++) {
multiboot_memory_map_t mmap = mmaps[i];
// v_mapping mapping;
for (unsigned int i = 0; i < map_size; i++) {
multiboot_memory_map_t mmap = mmaps[i];
- uint8_t* pa = PG_ALIGN(mmap.addr_low);
+ ptr_t pa = PG_ALIGN(mmap.addr_low);
+
if (mmap.type == MULTIBOOT_MEMORY_AVAILABLE || pa <= MEM_4MB) {
// Don't fuck up our kernel code or any free area!
continue;
}
if (mmap.type == MULTIBOOT_MEMORY_AVAILABLE || pa <= MEM_4MB) {
// Don't fuck up our kernel code or any free area!
continue;
}
+
size_t pg_num = CEIL(mmap.len_low, PG_SIZE_BITS);
size_t j = 0;
size_t pg_num = CEIL(mmap.len_low, PG_SIZE_BITS);
size_t j = 0;
+
if (!unlock) {
kprintf("mem: freeze: %p..%p type=%x\n",
pa,
pa + pg_num * PG_SIZE,
mmap.type);
if (!unlock) {
kprintf("mem: freeze: %p..%p type=%x\n",
pa,
pa + pg_num * PG_SIZE,
mmap.type);
+
for (; j < pg_num; j++) {
for (; j < pg_num; j++) {
-
uint
ptr_t _pa = pa + (j << PG_SIZE_BITS);
+ ptr_t _pa = pa + (j << PG_SIZE_BITS);
if (_pa >= KERNEL_MM_BASE) {
// Don't fuck up our kernel space!
break;
if (_pa >= KERNEL_MM_BASE) {
// Don't fuck up our kernel space!
break;
@@
-199,6
+206,7
@@
__do_reserved_memory(int unlock)
pmm_mark_page_occupied(
KERNEL_PID, _pa >> PG_SIZE_BITS, PP_FGLOCKED);
}
pmm_mark_page_occupied(
KERNEL_PID, _pa >> PG_SIZE_BITS, PP_FGLOCKED);
}
+
// Save the progress for later unmapping.
mmaps[i].len_low = j * PG_SIZE;
} else {
// Save the progress for later unmapping.
mmaps[i].len_low = j * PG_SIZE;
} else {
@@
-206,8
+214,9
@@
__do_reserved_memory(int unlock)
pa,
pa + pg_num * PG_SIZE,
mmap.type);
pa,
pa + pg_num * PG_SIZE,
mmap.type);
+
for (; j < pg_num; j++) {
for (; j < pg_num; j++) {
-
uint
ptr_t _pa = pa + (j << PG_SIZE_BITS);
+ ptr_t _pa = pa + (j << PG_SIZE_BITS);
vmm_del_mapping(VMS_SELF, _pa);
if (mmap.type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE) {
pmm_mark_page_free(_pa >> PG_SIZE_BITS);
vmm_del_mapping(VMS_SELF, _pa);
if (mmap.type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE) {
pmm_mark_page_free(_pa >> PG_SIZE_BITS);
diff --git
a/lunaix-os/kernel/process/process.c
b/lunaix-os/kernel/process/process.c
index 1b22219db4de2d8909237f2f0c735862a413933f..533c577436b0c2d448a7e85f8d8d62a0c44ef954 100644
(file)
--- a/
lunaix-os/kernel/process/process.c
+++ b/
lunaix-os/kernel/process/process.c
@@
-15,13
+15,13
@@
LOG_MODULE("PROC")
LOG_MODULE("PROC")
-void*
-__dup_pagetable(pid_t pid,
uint
ptr_t mount_point)
+ptr_t
+__dup_pagetable(pid_t pid, ptr_t mount_point)
{
{
-
void*
ptd_pp = pmm_alloc_page(pid, PP_FGPERSIST);
+
ptr_t
ptd_pp = pmm_alloc_page(pid, PP_FGPERSIST);
vmm_set_mapping(VMS_SELF, PG_MOUNT_1, ptd_pp, PG_PREM_RW, VMAP_NULL);
vmm_set_mapping(VMS_SELF, PG_MOUNT_1, ptd_pp, PG_PREM_RW, VMAP_NULL);
- x86_page_table* ptd = PG_MOUNT_1;
+ x86_page_table* ptd =
(x86_page_table*)
PG_MOUNT_1;
x86_page_table* pptd = (x86_page_table*)(mount_point | (0x3FF << 12));
size_t kspace_l1inx = L1_INDEX(KERNEL_MM_BASE);
x86_page_table* pptd = (x86_page_table*)(mount_point | (0x3FF << 12));
size_t kspace_l1inx = L1_INDEX(KERNEL_MM_BASE);
@@
-37,11
+37,11
@@
__dup_pagetable(pid_t pid, uintptr_t mount_point)
}
// 复制L2页表
}
// 复制L2页表
-
void*
pt_pp = pmm_alloc_page(pid, PP_FGPERSIST);
+
ptr_t
pt_pp = pmm_alloc_page(pid, PP_FGPERSIST);
vmm_set_mapping(VMS_SELF, PG_MOUNT_2, pt_pp, PG_PREM_RW, VMAP_NULL);
x86_page_table* ppt = (x86_page_table*)(mount_point | (i << 12));
vmm_set_mapping(VMS_SELF, PG_MOUNT_2, pt_pp, PG_PREM_RW, VMAP_NULL);
x86_page_table* ppt = (x86_page_table*)(mount_point | (i << 12));
- x86_page_table* pt = PG_MOUNT_2;
+ x86_page_table* pt =
(x86_page_table*)
PG_MOUNT_2;
for (size_t j = 0; j < PG_MAX_ENTRIES; j++) {
x86_pte_t pte = ppt->entry[j];
for (size_t j = 0; j < PG_MAX_ENTRIES; j++) {
x86_pte_t pte = ppt->entry[j];
@@
-49,7
+49,7
@@
__dup_pagetable(pid_t pid, uintptr_t mount_point)
pt->entry[j] = pte;
}
pt->entry[j] = pte;
}
- ptd->entry[i] = (
uint
ptr_t)pt_pp | PG_ENTRY_FLAGS(ptde);
+ ptd->entry[i] = (ptr_t)pt_pp | PG_ENTRY_FLAGS(ptde);
}
ptd->entry[PG_MAX_ENTRIES - 1] = NEW_L1_ENTRY(T_SELF_REF_PERM, ptd_pp);
}
ptd->entry[PG_MAX_ENTRIES - 1] = NEW_L1_ENTRY(T_SELF_REF_PERM, ptd_pp);
@@
-58,7
+58,7
@@
__dup_pagetable(pid_t pid, uintptr_t mount_point)
}
void
}
void
-__del_pagetable(pid_t pid,
uint
ptr_t mount_point)
+__del_pagetable(pid_t pid, ptr_t mount_point)
{
x86_page_table* pptd = (x86_page_table*)(mount_point | (0x3FF << 12));
{
x86_page_table* pptd = (x86_page_table*)(mount_point | (0x3FF << 12));
@@
-85,7
+85,7
@@
__del_pagetable(pid_t pid, uintptr_t mount_point)
pmm_free_page(pid, PG_ENTRY_ADDR(pptd->entry[PG_MAX_ENTRIES - 1]));
}
pmm_free_page(pid, PG_ENTRY_ADDR(pptd->entry[PG_MAX_ENTRIES - 1]));
}
-void*
+ptr_t
vmm_dup_vmspace(pid_t pid)
{
return __dup_pagetable(pid, VMS_SELF);
vmm_dup_vmspace(pid_t pid)
{
return __dup_pagetable(pid, VMS_SELF);
@@
-171,17
+171,19
@@
init_proc_user_space(struct proc_info* pcb)
}
void
}
void
-__mark_region(
uintptr_t start_vpn, uint
ptr_t end_vpn, int attr)
+__mark_region(
ptr_t start_vpn,
ptr_t end_vpn, int attr)
{
for (size_t i = start_vpn; i <= end_vpn; i++) {
x86_pte_t* curproc = &PTE_MOUNTED(VMS_SELF, i);
x86_pte_t* newproc = &PTE_MOUNTED(VMS_MOUNT_1, i);
{
for (size_t i = start_vpn; i <= end_vpn; i++) {
x86_pte_t* curproc = &PTE_MOUNTED(VMS_SELF, i);
x86_pte_t* newproc = &PTE_MOUNTED(VMS_MOUNT_1, i);
- cpu_invplg(newproc);
+
+ cpu_invplg((ptr_t)newproc);
if ((attr & REGION_MODE_MASK) == REGION_RSHARED) {
// 如果读共享,则将两者的都标注为只读,那么任何写入都将会应用COW策略。
if ((attr & REGION_MODE_MASK) == REGION_RSHARED) {
// 如果读共享,则将两者的都标注为只读,那么任何写入都将会应用COW策略。
- cpu_invplg(curproc);
- cpu_invplg(i << 12);
+ cpu_invplg((ptr_t)curproc);
+ cpu_invplg((ptr_t)(i << 12));
+
*curproc = *curproc & ~PG_WRITE;
*newproc = *newproc & ~PG_WRITE;
} else {
*curproc = *curproc & ~PG_WRITE;
*newproc = *newproc & ~PG_WRITE;
} else {
@@
-231,8
+233,8
@@
dup_proc()
continue;
}
continue;
}
-
uint
ptr_t start_vpn = pos->start >> 12;
-
uint
ptr_t end_vpn = pos->end >> 12;
+ ptr_t start_vpn = pos->start >> 12;
+ ptr_t end_vpn = pos->end >> 12;
__mark_region(start_vpn, end_vpn, pos->attr);
}
__mark_region(start_vpn, end_vpn, pos->attr);
}
@@
-249,11
+251,11
@@
dup_proc()
extern void __kernel_end;
void
extern void __kernel_end;
void
-setup_proc_mem(struct proc_info* proc,
uint
ptr_t usedMnt)
+setup_proc_mem(struct proc_info* proc, ptr_t usedMnt)
{
// copy the entire kernel page table
pid_t pid = proc->pid;
{
// copy the entire kernel page table
pid_t pid = proc->pid;
-
void*
pt_copy = __dup_pagetable(pid, usedMnt);
+
ptr_t
pt_copy = __dup_pagetable(pid, usedMnt);
vmm_mount_pd(VMS_MOUNT_1, pt_copy); // 将新进程的页表挂载到挂载点#2
vmm_mount_pd(VMS_MOUNT_1, pt_copy); // 将新进程的页表挂载到挂载点#2
@@
-269,12
+271,12
@@
setup_proc_mem(struct proc_info* proc, uintptr_t usedMnt)
In the name of Celestia our glorious goddess, I will fucking HATE
the TLB for the rest of my LIFE!
*/
In the name of Celestia our glorious goddess, I will fucking HATE
the TLB for the rest of my LIFE!
*/
- cpu_invplg(ppte);
+ cpu_invplg(
(ptr_t)
ppte);
x86_pte_t p = *ppte;
x86_pte_t p = *ppte;
-
void*
ppa = vmm_dup_page(pid, PG_ENTRY_ADDR(p));
+
ptr_t
ppa = vmm_dup_page(pid, PG_ENTRY_ADDR(p));
pmm_free_page(pid, PG_ENTRY_ADDR(p));
pmm_free_page(pid, PG_ENTRY_ADDR(p));
- *ppte = (p & 0xfff) |
(uintptr_t)
ppa;
+ *ppte = (p & 0xfff) | ppa;
}
// 我们不需要分配内核的区域,因为所有的内核代码和数据段只能通过系统调用来访问,任何非法的访问
}
// 我们不需要分配内核的区域,因为所有的内核代码和数据段只能通过系统调用来访问,任何非法的访问
diff --git
a/lunaix-os/kernel/process/sched.c
b/lunaix-os/kernel/process/sched.c
index edde8bc79f54f9c677207fce9813f5e79a88a6fa..b21d086ebce3667c7397cbb39da75575bfb0ba27 100644
(file)
--- a/
lunaix-os/kernel/process/sched.c
+++ b/
lunaix-os/kernel/process/sched.c
@@
-66,7
+66,7
@@
sched_init_dummy()
*execp = (struct exec_param){
.cs = KCODE_SEG,
.eflags = cpu_reflags() | 0x0200,
*execp = (struct exec_param){
.cs = KCODE_SEG,
.eflags = cpu_reflags() | 0x0200,
- .eip = (
void*
)my_dummy,
+ .eip = (
ptr_t
)my_dummy,
.ss = KDATA_SEG,
};
.ss = KDATA_SEG,
};
@@
-224,6
+224,8
@@
__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
block_current();
schedule();
block_current();
schedule();
+
+ return 0;
}
__DEFINE_LXSYSCALL1(unsigned int, alarm, unsigned int, seconds)
}
__DEFINE_LXSYSCALL1(unsigned int, alarm, unsigned int, seconds)
@@
-371,7
+373,7
@@
commit_process(struct proc_info* process)
// from <kernel/process.c>
extern void
// from <kernel/process.c>
extern void
-__del_pagetable(pid_t pid,
uint
ptr_t mount_point);
+__del_pagetable(pid_t pid, ptr_t mount_point);
pid_t
destroy_process(pid_t pid)
pid_t
destroy_process(pid_t pid)
@@
-379,8
+381,9
@@
destroy_process(pid_t pid)
int index = pid;
if (index <= 0 || index > sched_ctx.ptable_len) {
__current->k_status = EINVAL;
int index = pid;
if (index <= 0 || index > sched_ctx.ptable_len) {
__current->k_status = EINVAL;
- return;
+ return
-1
;
}
}
+
struct proc_info* proc = sched_ctx._procs[index];
sched_ctx._procs[index] = 0;
struct proc_info* proc = sched_ctx._procs[index];
sched_ctx._procs[index] = 0;
diff --git
a/lunaix-os/kernel/process/signal.c
b/lunaix-os/kernel/process/signal.c
index e8683a1b80f46ced290f989a8e60dc8c65712276..9e46976e36440e17ceb23b2a05a10e4a9c5cc6f5 100644
(file)
--- a/
lunaix-os/kernel/process/signal.c
+++ b/
lunaix-os/kernel/process/signal.c
@@
-9,6
+9,9
@@
extern struct scheduler sched_ctx; /* kernel/sched.c */
extern struct scheduler sched_ctx; /* kernel/sched.c */
+extern void
+_exit(int status);
+
void __USER__
default_sighandler_term(int signum)
{
void __USER__
default_sighandler_term(int signum)
{
@@
-53,7
+56,7
@@
signal_dispatch()
return 0;
}
return 0;
}
-
uint
ptr_t ustack = __current->ustack_top & ~0xf;
+ ptr_t ustack = __current->ustack_top & ~0xf;
if ((int)(ustack - USTACK_END) < (int)sizeof(struct proc_sig)) {
// 用户栈没有空间存放信号上下文
if ((int)(ustack - USTACK_END) < (int)sizeof(struct proc_sig)) {
// 用户栈没有空间存放信号上下文
@@
-150,6
+153,9
@@
__DEFINE_LXSYSCALL1(int, sigreturn, struct proc_sig, *sig_ctx)
__current->flags &= ~PROC_FINPAUSE;
__SIGCLEAR(__current->sig_inprogress, sig_ctx->sig_num);
schedule();
__current->flags &= ~PROC_FINPAUSE;
__SIGCLEAR(__current->sig_inprogress, sig_ctx->sig_num);
schedule();
+
+ // never reach!
+ return 0;
}
__DEFINE_LXSYSCALL3(int,
}
__DEFINE_LXSYSCALL3(int,
diff --git
a/lunaix-os/kernel/spike.c
b/lunaix-os/kernel/spike.c
index 860b201d8f2b6542b0990f34f0500a3478e64812..4686b12ce3667f3b51f26ae609b78a0acf246a1c 100644
(file)
--- a/
lunaix-os/kernel/spike.c
+++ b/
lunaix-os/kernel/spike.c
@@
-15,14
+15,14
@@
__assert_fail(const char* expr, const char* file, unsigned int line)
// kernel/asm/x86/interrupts.c)
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
// kernel/asm/x86/interrupts.c)
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
-
spin();
// never reach
+
DO_SPIN
// never reach
}
void
panick(const char* msg)
{
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(msg));
}
void
panick(const char* msg)
{
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(msg));
- spin();
+ DO_SPIN
}
void
}
void
@@
-34,5
+34,5
@@
panickf(const char* fmt, ...)
va_end(args);
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
va_end(args);
asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
- spin();
+ DO_SPIN
}
}
diff --git
a/lunaix-os/kernel/time/clock.c
b/lunaix-os/kernel/time/clock.c
index 0f0457530df0f70240de7a6dae5caa8adec0ec5d..e91be19ef18fd61ba2538079e1376247b2f1a397 100644
(file)
--- a/
lunaix-os/kernel/time/clock.c
+++ b/
lunaix-os/kernel/time/clock.c
@@
-4,6
+4,8
@@
#include <lunaix/spike.h>
#include <lunaix/timer.h>
#include <lunaix/spike.h>
#include <lunaix/timer.h>
+#include <klibc/string.h>
+
static volatile time_t sys_time;
void
static volatile time_t sys_time;
void
@@
-101,7
+103,7
@@
clock_walltime(datetime_t* datetime)
datetime->second = rtc_read_reg(RTC_REG_SEC);
} while (!clock_datatime_eq(datetime, ¤t));
datetime->second = rtc_read_reg(RTC_REG_SEC);
} while (!clock_datatime_eq(datetime, ¤t));
- u
int
8_t regbv = rtc_read_reg(RTC_REG_B);
+ u8_t regbv = rtc_read_reg(RTC_REG_B);
// Convert from bcd to binary when needed
if (!RTC_BIN_ENCODED(regbv)) {
// Convert from bcd to binary when needed
if (!RTC_BIN_ENCODED(regbv)) {
@@
-115,7
+117,7
@@
clock_walltime(datetime_t* datetime)
// To 24 hour format
if (!RTC_24HRS_ENCODED(regbv) && (datetime->hour >> 7)) {
// To 24 hour format
if (!RTC_24HRS_ENCODED(regbv) && (datetime->hour >> 7)) {
- datetime->hour =
(12 +
datetime->hour & 0x80);
+ datetime->hour =
12 + (
datetime->hour & 0x80);
}
datetime->year += RTC_CURRENT_CENTRY * 100;
}
datetime->year += RTC_CURRENT_CENTRY * 100;
diff --git
a/lunaix-os/kernel/time/timer.c
b/lunaix-os/kernel/time/timer.c
index d99aac49dafc211f8fb9bf9fd2465e4bc1a0c1eb..46b2e79920e548dc0972bce0c8d390a52b7c1046 100644
(file)
--- a/
lunaix-os/kernel/time/timer.c
+++ b/
lunaix-os/kernel/time/timer.c
@@
-41,7
+41,7
@@
static volatile struct lx_timer_context* timer_ctx = NULL;
// Don't optimize them! Took me an half hour to figure that out...
static volatile u32_t rtc_counter = 0;
// Don't optimize them! Took me an half hour to figure that out...
static volatile u32_t rtc_counter = 0;
-static volatile u
int
8_t apic_timer_done = 0;
+static volatile u8_t apic_timer_done = 0;
static volatile u32_t sched_ticks = 0;
static volatile u32_t sched_ticks_counter = 0;
static volatile u32_t sched_ticks = 0;
static volatile u32_t sched_ticks_counter = 0;
@@
-157,7
+157,7
@@
struct lx_timer*
timer_run_second(u32_t second,
void (*callback)(void*),
void* payload,
timer_run_second(u32_t second,
void (*callback)(void*),
void* payload,
- u
int
8_t flags)
+ u8_t flags)
{
return timer_run(
second * timer_ctx->running_frequency, callback, payload, flags);
{
return timer_run(
second * timer_ctx->running_frequency, callback, payload, flags);
@@
-167,7
+167,7
@@
struct lx_timer*
timer_run_ms(u32_t millisecond,
void (*callback)(void*),
void* payload,
timer_run_ms(u32_t millisecond,
void (*callback)(void*),
void* payload,
- u
int
8_t flags)
+ u8_t flags)
{
return timer_run(timer_ctx->running_frequency / 1000 * millisecond,
callback,
{
return timer_run(timer_ctx->running_frequency / 1000 * millisecond,
callback,
@@
-176,7
+176,7
@@
timer_run_ms(u32_t millisecond,
}
struct lx_timer*
}
struct lx_timer*
-timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u
int
8_t flags)
+timer_run(ticks_t ticks, void (*callback)(void*), void* payload, u8_t flags)
{
struct lx_timer* timer = (struct lx_timer*)cake_grab(timer_pile);
{
struct lx_timer* timer = (struct lx_timer*)cake_grab(timer_pile);
@@
-247,5
+247,5
@@
temp_intr_routine_apic_timer(const isr_param* param)
struct lx_timer_context*
timer_context()
{
struct lx_timer_context*
timer_context()
{
- return timer_ctx;
+ return
(struct lx_timer_context*)
timer_ctx;
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/lunaix-os/kernel/tty/lxconsole.c
b/lunaix-os/kernel/tty/lxconsole.c
index 0d7439be4542554b427ad998f9690d7c65fc9c85..67961b52def89799344dcf4b689e1307d4a7f65b 100644
(file)
--- a/
lunaix-os/kernel/tty/lxconsole.c
+++ b/
lunaix-os/kernel/tty/lxconsole.c
@@
-31,6
+31,9
@@
__tty_write(struct device* dev, void* buf, size_t offset, size_t len);
int
__tty_read(struct device* dev, void* buf, size_t offset, size_t len);
int
__tty_read(struct device* dev, void* buf, size_t offset, size_t len);
+void
+console_write(struct console* console, u8_t* data, size_t size);
+
void
console_flush();
void
console_flush();
@@
-162,6
+165,8
@@
__tty_write(struct device* dev, void* buf, size_t offset, size_t len)
{
struct console* console = (struct console*)dev->underlay;
console_write(console, buf, len);
{
struct console* console = (struct console*)dev->underlay;
console_write(console, buf, len);
+
+ return len;
}
int
}
int
@@
-204,6
+209,7
@@
__tty_read(struct device* dev, void* buf, size_t offset, size_t len)
break;
}
}
break;
}
}
+
return count + fifo_read(&console->input, buf + count, len - count);
}
return count + fifo_read(&console->input, buf + count, len - count);
}
@@
-285,15
+291,15
@@
console_flush()
}
void
}
void
-console_write(struct console* console, u
int
8_t* data, size_t size)
+console_write(struct console* console, u8_t* data, size_t size)
{
struct fifo_buf* fbuf = &console->output;
mutex_lock(&console->output.lock);
fifo_set_rdptr(fbuf, console->wnd_start);
{
struct fifo_buf* fbuf = &console->output;
mutex_lock(&console->output.lock);
fifo_set_rdptr(fbuf, console->wnd_start);
- u
int
8_t* buffer = fbuf->data;
-
uint
ptr_t ptr = fbuf->wr_pos;
-
uint
ptr_t rd_ptr = fbuf->rd_pos;
+ u8_t* buffer = fbuf->data;
+ ptr_t ptr = fbuf->wr_pos;
+ ptr_t rd_ptr = fbuf->rd_pos;
char c;
for (size_t i = 0; i < size; i++) {
char c;
for (size_t i = 0; i < size; i++) {
@@
-331,13
+337,13
@@
console_write(struct console* console, uint8_t* data, size_t size)
void
console_write_str(char* str)
{
void
console_write_str(char* str)
{
- console_write(&lx_console, str, strlen(str));
+ console_write(&lx_console,
(u8_t*)
str, strlen(str));
}
void
console_write_char(char str)
{
}
void
console_write_char(char str)
{
- console_write(&lx_console, &str, 1);
+ console_write(&lx_console,
(u8_t*)
&str, 1);
}
void
}
void
diff --git
a/lunaix-os/kernel/tty/tty.c
b/lunaix-os/kernel/tty/tty.c
index 399b28df6f3f23d474337709aa8ba0966ad31ac4..4c9631cefdeed0312a9d7a0d18de972ec06d3da2 100644
(file)
--- a/
lunaix-os/kernel/tty/tty.c
+++ b/
lunaix-os/kernel/tty/tty.c
@@
-33,6
+33,19
@@
tty_init(void* vga_buf)
io_outb(0x3D5, (io_inb(0x3D5) & 0xE0) | 15);
}
io_outb(0x3D5, (io_inb(0x3D5) & 0xE0) | 15);
}
+void
+tty_set_cursor(u8_t x, u8_t y)
+{
+ if (x >= TTY_WIDTH || y >= TTY_HEIGHT) {
+ x = y = 0;
+ }
+ u32_t pos = y * TTY_WIDTH + x;
+ io_outb(0x3D4, 14);
+ io_outb(0x3D5, pos / 256);
+ io_outb(0x3D4, 15);
+ io_outb(0x3D5, pos % 256);
+}
+
void
tty_set_theme(vga_attribute fg, vga_attribute bg)
{
void
tty_set_theme(vga_attribute fg, vga_attribute bg)
{
@@
-51,7
+64,7
@@
tty_flush_buffer(struct fifo_buf* buf)
int state = 0;
int g[2] = { 0, 0 };
vga_attribute current_theme = tty_theme_color;
int state = 0;
int g[2] = { 0, 0 };
vga_attribute current_theme = tty_theme_color;
- while (fifo_readone_async(buf, &chr)) {
+ while (fifo_readone_async(buf,
(u8_t*)
&chr)) {
if (state == 0 && chr == '\033') {
state = 1;
} else if (state == 1 && chr == '[') {
if (state == 0 && chr == '\033') {
state = 1;
} else if (state == 1 && chr == '[') {
@@
-107,19
+120,6
@@
tty_flush_buffer(struct fifo_buf* buf)
tty_set_cursor(x, y);
}
tty_set_cursor(x, y);
}
-void
-tty_set_cursor(uint8_t x, uint8_t y)
-{
- if (x >= TTY_WIDTH || y >= TTY_HEIGHT) {
- x = y = 0;
- }
- u32_t pos = y * TTY_WIDTH + x;
- io_outb(0x3D4, 14);
- io_outb(0x3D5, pos / 256);
- io_outb(0x3D4, 15);
- io_outb(0x3D5, pos % 256);
-}
-
void
tty_clear_line(int line_num)
{
void
tty_clear_line(int line_num)
{
diff --git
a/lunaix-os/libs/klibc/stdio/ksprintf.c
b/lunaix-os/libs/klibc/stdio/ksprintf.c
index 78c510a214761c8ab554a3c3066bd2ceb90196e9..24591dc43552dcd17b4853d24f6ced402901ff0f 100644
(file)
--- a/
lunaix-os/libs/klibc/stdio/ksprintf.c
+++ b/
lunaix-os/libs/klibc/stdio/ksprintf.c
@@
-20,7
+20,10
@@
static const char flag_chars[] = "#0- +";
#define FLAG_CAPS (1 << 9)
size_t
#define FLAG_CAPS (1 << 9)
size_t
-__ksprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs)
+__ksprintf_internal(char* buffer,
+ const char* fmt,
+ size_t max_len,
+ va_list vargs)
{
// This sprintf just a random implementation I found it on Internet . lol.
// Of course, with some modifications for porting to LunaixOS :)
{
// This sprintf just a random implementation I found it on Internet . lol.
// Of course, with some modifications for porting to LunaixOS :)
@@
-113,7
+116,7
@@
__ksprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs)
base = 16;
goto format_unsigned;
case 'p':
base = 16;
goto format_unsigned;
case 'p':
- num = (
uint
ptr_t)va_arg(vargs, void*);
+ num = (ptr_t)va_arg(vargs, void*);
base = 16;
flags |= FLAG_ALT | FLAG_ALT2 | FLAG_NUMERIC;
break;
base = 16;
flags |= FLAG_ALT | FLAG_ALT2 | FLAG_NUMERIC;
break;
diff --git
a/lunaix-os/libs/klibc/string/mem.c
b/lunaix-os/libs/klibc/string/mem.c
index ae56240eed91511c08a912b919bff04b84324866..3183f0288caa68b7d2f8e3946ead80aa62845905 100755
(executable)
--- a/
lunaix-os/libs/klibc/string/mem.c
+++ b/
lunaix-os/libs/klibc/string/mem.c
@@
-1,5
+1,5
@@
#include <klibc/string.h>
#include <klibc/string.h>
-#include <
stdint
.h>
+#include <
lunaix/types
.h>
void*
memcpy(void* dest, const void* src, size_t num)
void*
memcpy(void* dest, const void* src, size_t num)
@@
-17,8
+17,8
@@
memcpy(void* dest, const void* src, size_t num)
void*
memmove(void* dest, const void* src, size_t num)
{
void*
memmove(void* dest, const void* src, size_t num)
{
- u
int8_t* dest_ptr = (uint
8_t*)dest;
- const u
int8_t* src_ptr = (const uint
8_t*)src;
+ u
8_t* dest_ptr = (u
8_t*)dest;
+ const u
8_t* src_ptr = (const u
8_t*)src;
if (dest_ptr < src_ptr) {
for (size_t i = 0; i < num; i++) {
*(dest_ptr + i) = *(src_ptr + i);
if (dest_ptr < src_ptr) {
for (size_t i = 0; i < num; i++) {
*(dest_ptr + i) = *(src_ptr + i);
@@
-45,8
+45,8
@@
memset(void* ptr, int value, size_t num)
int
memcmp(const void* ptr1, const void* ptr2, size_t num)
{
int
memcmp(const void* ptr1, const void* ptr2, size_t num)
{
- u
int8_t* p1 = (uint
8_t*)ptr1;
- u
int8_t* p2 = (uint
8_t*)ptr2;
+ u
8_t* p1 = (u
8_t*)ptr1;
+ u
8_t* p2 = (u
8_t*)ptr2;
for (size_t i = 0; i < num; i++) {
int diff = *(p1 + i) - *(p2 + i);
if (diff != 0) {
for (size_t i = 0; i < num; i++) {
int diff = *(p1 + i) - *(p2 + i);
if (diff != 0) {
diff --git
a/lunaix-os/scripts/x86_idt_generator.py
b/lunaix-os/scripts/x86_idt_generator.py
index 7876ab1944f90f524c9d26c652046212d4afeb4c..b00d266fcac21af992cd477f359ff3a160cc666f 100644
(file)
--- a/
lunaix-os/scripts/x86_idt_generator.py
+++ b/
lunaix-os/scripts/x86_idt_generator.py
@@
-87,16
+87,16
@@
def export_c(src: Path):
#define IDT_ENTRY 256
#define IDT_ENTRY 256
-u
int
64_t _idt[IDT_ENTRY];
-u
int
16_t _idt_limit = sizeof(_idt) - 1;
+u64_t _idt[IDT_ENTRY];
+u16_t _idt_limit = sizeof(_idt) - 1;
static inline void
_set_idt_entry(u32_t vector,
static inline void
_set_idt_entry(u32_t vector,
- u
int
16_t seg_selector,
+ u16_t seg_selector,
void (*isr)(),
void (*isr)(),
- u
int
8_t dpl,
- u
int
8_t type)
+ u8_t dpl,
+ u8_t type)
{{
{{
-
uintptr_t offset = (uint
ptr_t)isr;
+
ptr_t offset = (
ptr_t)isr;
_idt[vector] = (offset & 0xffff0000) | IDT_ATTR(dpl, type);
_idt[vector] <<= 32;
_idt[vector] |= (seg_selector << 16) | (offset & 0x0000ffff);
_idt[vector] = (offset & 0xffff0000) | IDT_ATTR(dpl, type);
_idt[vector] <<= 32;
_idt[vector] |= (seg_selector << 16) | (offset & 0x0000ffff);
diff --git
a/lunaix-os/uprog/ls.c
b/lunaix-os/uprog/ls.c
index bac3c71eb2541e056fd8561b79e61d8d9ad2c31e..646dd6bddb219ba53d2205132070f6d0eba797de 100644
(file)
--- a/
lunaix-os/uprog/ls.c
+++ b/
lunaix-os/uprog/ls.c
@@
-5,7
+5,7
@@
int
main(int argc, const char* argv[])
{
int
main(int argc, const char* argv[])
{
- char* path = ".";
+ c
onst c
har* path = ".";
if (argc > 1) {
path = argv[1];
}
if (argc > 1) {
path = argv[1];
}
diff --git
a/lunaix-os/uprog/sh.c
b/lunaix-os/uprog/sh.c
index 10aed0b57ad4570f9222812bed4094291d840e60..616fa672ebf65a5797930e05f22a4e49b9a70cc0 100644
(file)
--- a/
lunaix-os/uprog/sh.c
+++ b/
lunaix-os/uprog/sh.c
@@
-3,6
+3,7
@@
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
+#include <sys/lunaix.h>
#include <unistd.h>
char pwd[512];
#include <unistd.h>
char pwd[512];
@@
-143,7
+144,7
@@
sh_loop()
while (1) {
getcwd(pwd, 512);
printf("[\033[2m%s\033[39;49m]$ ", pwd);
while (1) {
getcwd(pwd, 512);
printf("[\033[2m%s\033[39;49m]$ ", pwd);
-
size_
t sz = read(stdin, buf, 511);
+
in
t sz = read(stdin, buf, 511);
if (sz < 0) {
printf("fail to read user input (%d)\n", geterrno());
if (sz < 0) {
printf("fail to read user input (%d)\n", geterrno());
diff --git
a/lunaix-os/uprog/signal_demo.c
b/lunaix-os/uprog/signal_demo.c
index ef261ab89b4a70be93777b2f67b8727fbd4b75f5..8a9bdc6587bd7a3bd29b462d9adda43db6acf4fc 100644
(file)
--- a/
lunaix-os/uprog/signal_demo.c
+++ b/
lunaix-os/uprog/signal_demo.c
@@
-1,4
+1,7
@@
#include <signal.h>
#include <signal.h>
+#include <stdio.h>
+#include <sys/lunaix.h>
+#include <unistd.h>
void
sigchild_handler(int signum)
void
sigchild_handler(int signum)
diff --git
a/lunaix-os/usr/includes/sys/types.h
b/lunaix-os/usr/includes/sys/types.h
index 8b30318f83b7f3b68e6c8333e7e34cf38da94b0d..4c197f5ab12fdc37f8b85bc1df37245dbf034c22 100644
(file)
--- a/
lunaix-os/usr/includes/sys/types.h
+++ b/
lunaix-os/usr/includes/sys/types.h
@@
-1,7
+1,9
@@
#ifndef __LUNAIX_SYS_TYPES_H
#define __LUNAIX_SYS_TYPES_H
#ifndef __LUNAIX_SYS_TYPES_H
#define __LUNAIX_SYS_TYPES_H
+#undef NULL
#define NULL (void*)0
#define NULL (void*)0
+#define NULLPTR 0
#define PEXITTERM 0x100
#define PEXITSTOP 0x200
#define PEXITTERM 0x100
#define PEXITSTOP 0x200
diff --git
a/lunaix-os/usr/libc/_mystdio.h
b/lunaix-os/usr/libc/_mystdio.h
index d60fed37c07adbc4c264b98c1bf381aae30d718f..4f66563ba0b7ae5839df5ec4450a856f963f062c 100644
(file)
--- a/
lunaix-os/usr/libc/_mystdio.h
+++ b/
lunaix-os/usr/libc/_mystdio.h
@@
-5,6
+5,9
@@
#include <stddef.h>
int
#include <stddef.h>
int
-__vprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs);
+__vprintf_internal(char* buffer,
+ const char* fmt,
+ size_t max_len,
+ va_list vargs);
#endif /* __LUNAIX__MYSTDIO_H */
#endif /* __LUNAIX__MYSTDIO_H */
diff --git
a/lunaix-os/usr/libc/_vprintf.c
b/lunaix-os/usr/libc/_vprintf.c
index 1e563054a1a77917827d83e2e269410d35586399..28dea37c7db3c3314ad6a18b8cbac37a187f89f7 100644
(file)
--- a/
lunaix-os/usr/libc/_vprintf.c
+++ b/
lunaix-os/usr/libc/_vprintf.c
@@
-19,7
+19,7
@@
static const char flag_chars[] = "#0- +";
#define FLAG_CAPS (1 << 9)
int
#define FLAG_CAPS (1 << 9)
int
-__vprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs)
+__vprintf_internal(char* buffer, c
onst c
har* fmt, size_t max_len, va_list vargs)
{
// This sprintf just a random implementation I found it on Internet . lol.
// Of course, with some modifications for porting to LunaixOS :)
{
// This sprintf just a random implementation I found it on Internet . lol.
// Of course, with some modifications for porting to LunaixOS :)