Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a52d15dd8 | ||
|
|
9b6afdeee0 | ||
|
|
be1841d633 | ||
|
|
12033fe1b2 | ||
|
|
05734c710a | ||
|
|
feeadfd1fa | ||
|
|
457a8c0a43 | ||
|
|
337d806183 | ||
|
|
fd44a945fb | ||
|
|
1235929f17 |
@@ -28,6 +28,7 @@ KERNEL_OBJS := \
|
|||||||
$(BUILD)/arch/x86_64/interrupts.o \
|
$(BUILD)/arch/x86_64/interrupts.o \
|
||||||
$(BUILD)/arch/x86_64/cpu.o \
|
$(BUILD)/arch/x86_64/cpu.o \
|
||||||
$(BUILD)/kernel/main.o \
|
$(BUILD)/kernel/main.o \
|
||||||
|
$(BUILD)/kernel/bootlog.o \
|
||||||
$(BUILD)/kernel/panic.o \
|
$(BUILD)/kernel/panic.o \
|
||||||
$(BUILD)/kernel/printk.o \
|
$(BUILD)/kernel/printk.o \
|
||||||
$(BUILD)/kernel/memory.o \
|
$(BUILD)/kernel/memory.o \
|
||||||
@@ -54,8 +55,16 @@ $(BUILD):
|
|||||||
$(BUILD)/boot/boot.bin: boot/boot.asm | $(BUILD)
|
$(BUILD)/boot/boot.bin: boot/boot.asm | $(BUILD)
|
||||||
$(AS) -f bin $< -o $@
|
$(AS) -f bin $< -o $@
|
||||||
|
|
||||||
$(BUILD)/boot/stage2.bin: boot/stage2.asm boot/disk.asm | $(BUILD)
|
$(BUILD)/boot/kernel_sectors.inc: $(BUILD)/kernel.bin | $(BUILD)
|
||||||
$(AS) -I boot/ -f bin $< -o $@
|
mkdir -p $(dir $@)
|
||||||
|
@size=$$(wc -c < $(BUILD)/kernel.bin); \
|
||||||
|
sectors=$$(( (size + 511) / 512 )); \
|
||||||
|
if [ $$sectors -lt 1 ]; then sectors=1; fi; \
|
||||||
|
echo "; auto-generated from build/kernel.bin" > $@; \
|
||||||
|
echo "KERNEL_SECTORS equ $$sectors" >> $@
|
||||||
|
|
||||||
|
$(BUILD)/boot/stage2.bin: boot/stage2.asm boot/disk.asm $(BUILD)/boot/kernel_sectors.inc | $(BUILD)
|
||||||
|
$(AS) -I boot/ -I $(BUILD)/boot/ -f bin $< -o $@
|
||||||
|
|
||||||
$(BUILD)/arch/x86_64/%.o: arch/x86_64/%.asm | $(BUILD)
|
$(BUILD)/arch/x86_64/%.o: arch/x86_64/%.asm | $(BUILD)
|
||||||
$(AS) -f elf64 $< -o $@
|
$(AS) -f elf64 $< -o $@
|
||||||
|
|||||||
+1
-1
@@ -11,8 +11,8 @@
|
|||||||
jmp start2
|
jmp start2
|
||||||
|
|
||||||
%include "disk.asm"
|
%include "disk.asm"
|
||||||
|
%include "kernel_sectors.inc"
|
||||||
|
|
||||||
KERNEL_SECTORS equ 256
|
|
||||||
KERNEL_START_LBA equ 17
|
KERNEL_START_LBA equ 17
|
||||||
KERNEL_LOAD_SEG equ 0x1000
|
KERNEL_LOAD_SEG equ 0x1000
|
||||||
PML4_ADDR equ 0x00070000
|
PML4_ADDR equ 0x00070000
|
||||||
|
|||||||
+55
-17
@@ -38,8 +38,6 @@
|
|||||||
#define ASTERFS_MAGIC "ASTERFS1"
|
#define ASTERFS_MAGIC "ASTERFS1"
|
||||||
#define ASTERFS_VERSION 1U
|
#define ASTERFS_VERSION 1U
|
||||||
|
|
||||||
#define ASTERFS_NODE_BYTES (ASTERFS_NAME_LEN + 1 + 2 + 1 + ASTERFS_DATA_LEN)
|
|
||||||
#define ASTERFS_NODE_SECTORS (((ASTERFS_MAX_FILES * ASTERFS_NODE_BYTES) + 511) / 512)
|
|
||||||
#define ASTERFS_DISK_START_LBA 1U
|
#define ASTERFS_DISK_START_LBA 1U
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -56,7 +54,12 @@ typedef struct {
|
|||||||
u16 size;
|
u16 size;
|
||||||
u8 reserved;
|
u8 reserved;
|
||||||
u8 data[ASTERFS_DATA_LEN];
|
u8 data[ASTERFS_DATA_LEN];
|
||||||
} asterfs_disk_node_t;
|
} __attribute__((packed)) asterfs_disk_node_t;
|
||||||
|
|
||||||
|
#define ASTERFS_NODE_BYTES ((usize)sizeof(asterfs_disk_node_t))
|
||||||
|
#define ASTERFS_NODE_SECTORS (((ASTERFS_MAX_FILES * ASTERFS_NODE_BYTES) + 511) / 512)
|
||||||
|
_Static_assert(sizeof(asterfs_disk_node_t) == (ASTERFS_NAME_LEN + 1 + 2 + 1 + ASTERFS_DATA_LEN),
|
||||||
|
"asterfs_disk_node_t layout mismatch");
|
||||||
|
|
||||||
static asterfs_node_t nodes[ASTERFS_MAX_FILES];
|
static asterfs_node_t nodes[ASTERFS_MAX_FILES];
|
||||||
static int nodes_used = 0;
|
static int nodes_used = 0;
|
||||||
@@ -222,31 +225,39 @@ static void fs_reset_memory(void) {
|
|||||||
nodes_used = 0;
|
nodes_used = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fs_encode_nodes(u8 *out) {
|
static void fs_encode_nodes(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ASTERFS_MAX_FILES; ++i) {
|
for (i = 0; i < ASTERFS_MAX_FILES; ++i) {
|
||||||
asterfs_disk_node_t d;
|
asterfs_disk_node_t d;
|
||||||
usize off = (usize)i * ASTERFS_NODE_BYTES;
|
usize off = (usize)i * ASTERFS_NODE_BYTES;
|
||||||
|
|
||||||
|
if (off + ASTERFS_NODE_BYTES > sizeof(g_nodes_blob)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
aster_memset(&d, 0, sizeof(d));
|
aster_memset(&d, 0, sizeof(d));
|
||||||
aster_memcpy(d.name, nodes[i].name, ASTERFS_NAME_LEN);
|
aster_memcpy(d.name, nodes[i].name, ASTERFS_NAME_LEN);
|
||||||
d.is_dir = nodes[i].is_dir;
|
d.is_dir = nodes[i].is_dir;
|
||||||
d.size = nodes[i].size;
|
d.size = nodes[i].size;
|
||||||
aster_memcpy(d.data, nodes[i].data, ASTERFS_DATA_LEN);
|
aster_memcpy(d.data, nodes[i].data, ASTERFS_DATA_LEN);
|
||||||
|
|
||||||
aster_memcpy(out + off, &d, ASTERFS_NODE_BYTES);
|
aster_memcpy(g_nodes_blob + off, &d, ASTERFS_NODE_BYTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fs_decode_nodes(const u8 *in) {
|
static void fs_decode_nodes(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ASTERFS_MAX_FILES; ++i) {
|
for (i = 0; i < ASTERFS_MAX_FILES; ++i) {
|
||||||
asterfs_disk_node_t d;
|
asterfs_disk_node_t d;
|
||||||
usize off = (usize)i * ASTERFS_NODE_BYTES;
|
usize off = (usize)i * ASTERFS_NODE_BYTES;
|
||||||
|
|
||||||
aster_memcpy(&d, in + off, ASTERFS_NODE_BYTES);
|
if (off + ASTERFS_NODE_BYTES > sizeof(g_nodes_blob)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
aster_memcpy(&d, g_nodes_blob + off, ASTERFS_NODE_BYTES);
|
||||||
|
|
||||||
aster_memset(nodes[i].name, 0, ASTERFS_NAME_LEN);
|
aster_memset(nodes[i].name, 0, ASTERFS_NAME_LEN);
|
||||||
aster_memcpy(nodes[i].name, d.name, ASTERFS_NAME_LEN);
|
aster_memcpy(nodes[i].name, d.name, ASTERFS_NAME_LEN);
|
||||||
@@ -287,7 +298,7 @@ static int fs_flush_disk(void) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs_encode_nodes(g_nodes_blob);
|
fs_encode_nodes();
|
||||||
for (sector = 0; sector < ASTERFS_NODE_SECTORS; ++sector) {
|
for (sector = 0; sector < ASTERFS_NODE_SECTORS; ++sector) {
|
||||||
usize off = (usize)sector * 512;
|
usize off = (usize)sector * 512;
|
||||||
aster_memset(g_sector_buffer, 0, sizeof(g_sector_buffer));
|
aster_memset(g_sector_buffer, 0, sizeof(g_sector_buffer));
|
||||||
@@ -337,7 +348,7 @@ static int fs_load_disk(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs_decode_nodes(g_nodes_blob);
|
fs_decode_nodes();
|
||||||
if (super.nodes_used > ASTERFS_MAX_FILES) {
|
if (super.nodes_used > ASTERFS_MAX_FILES) {
|
||||||
nodes_used = ASTERFS_MAX_FILES;
|
nodes_used = ASTERFS_MAX_FILES;
|
||||||
} else {
|
} else {
|
||||||
@@ -519,7 +530,10 @@ int asterfs_create_file(const char *name) {
|
|||||||
nodes[nodes_used].size = 0;
|
nodes[nodes_used].size = 0;
|
||||||
nodes[nodes_used].is_dir = 0;
|
nodes[nodes_used].is_dir = 0;
|
||||||
++nodes_used;
|
++nodes_used;
|
||||||
(void)fs_flush_disk();
|
if (fs_flush_disk() != 0) {
|
||||||
|
--nodes_used;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,7 +562,10 @@ int asterfs_create_dir(const char *name) {
|
|||||||
nodes[nodes_used].size = 0;
|
nodes[nodes_used].size = 0;
|
||||||
nodes[nodes_used].is_dir = 1;
|
nodes[nodes_used].is_dir = 1;
|
||||||
++nodes_used;
|
++nodes_used;
|
||||||
(void)fs_flush_disk();
|
if (fs_flush_disk() != 0) {
|
||||||
|
--nodes_used;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +587,9 @@ int asterfs_remove_file(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--nodes_used;
|
--nodes_used;
|
||||||
(void)fs_flush_disk();
|
if (fs_flush_disk() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,7 +622,9 @@ int asterfs_remove_dir(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--nodes_used;
|
--nodes_used;
|
||||||
(void)fs_flush_disk();
|
if (fs_flush_disk() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,13 +651,30 @@ int asterfs_write_file(const char *name, const u8 *data, u16 len) {
|
|||||||
len = ASTERFS_DATA_LEN;
|
len = ASTERFS_DATA_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
aster_memset(nodes[idx].data, 0, ASTERFS_DATA_LEN);
|
{
|
||||||
aster_memcpy(nodes[idx].data, data, len);
|
u8 old_data[ASTERFS_DATA_LEN];
|
||||||
nodes[idx].size = len;
|
u16 old_size = nodes[idx].size;
|
||||||
(void)fs_flush_disk();
|
|
||||||
|
aster_memcpy(old_data, nodes[idx].data, ASTERFS_DATA_LEN);
|
||||||
|
|
||||||
|
aster_memset(nodes[idx].data, 0, ASTERFS_DATA_LEN);
|
||||||
|
aster_memcpy(nodes[idx].data, data, len);
|
||||||
|
nodes[idx].size = len;
|
||||||
|
|
||||||
|
if (fs_flush_disk() != 0) {
|
||||||
|
aster_memcpy(nodes[idx].data, old_data, ASTERFS_DATA_LEN);
|
||||||
|
nodes[idx].size = old_size;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int asterfs_sync(void) {
|
||||||
|
return fs_flush_disk();
|
||||||
|
}
|
||||||
|
|
||||||
int asterfs_read_file(const char *name, u8 *out, u16 max_len) {
|
int asterfs_read_file(const char *name, u8 *out, u16 max_len) {
|
||||||
int idx;
|
int idx;
|
||||||
u16 len;
|
u16 len;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* AsterOS Kernel
|
||||||
|
* Autor: Pavel Kalas
|
||||||
|
* Rok: 2026
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Header deklaruje jednoduche API pro jednotne stavove vypisy
|
||||||
|
* ve stylu [ STAV ] zprava, pouzivane hlavne pri boot/setup toku.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASTER_BOOTLOG_H
|
||||||
|
#define ASTER_BOOTLOG_H
|
||||||
|
|
||||||
|
void bootlog_state(const char *state, unsigned char state_color, const char *msg);
|
||||||
|
void bootlog_ok(const char *msg);
|
||||||
|
void bootlog_error(const char *msg);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -35,6 +35,7 @@ int asterfs_remove_dir(const char *name);
|
|||||||
int asterfs_write_file(const char *name, const u8 *data, u16 len);
|
int asterfs_write_file(const char *name, const u8 *data, u16 len);
|
||||||
int asterfs_read_file(const char *name, u8 *out, u16 max_len);
|
int asterfs_read_file(const char *name, u8 *out, u16 max_len);
|
||||||
int asterfs_get_type(const char *name);
|
int asterfs_get_type(const char *name);
|
||||||
|
int asterfs_sync(void);
|
||||||
void asterfs_list(void (*cb)(const char *name, u8 is_dir, u16 size));
|
void asterfs_list(void (*cb)(const char *name, u8 is_dir, u16 size));
|
||||||
void asterfs_list_dir(const char *path, void (*cb)(const char *name, u8 is_dir, u16 size));
|
void asterfs_list_dir(const char *path, void (*cb)(const char *name, u8 is_dir, u16 size));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* AsterOS Kernel
|
||||||
|
* Autor: Pavel Kalas
|
||||||
|
* Rok: 2026
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runtime registr pro sysapps: kazda app je mapovana na prikaz podle
|
||||||
|
* nazvu souboru a spousti se pres init(void).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ASTER_SYSAPPS_RUNTIME_H
|
||||||
|
#define ASTER_SYSAPPS_RUNTIME_H
|
||||||
|
|
||||||
|
typedef void (*sysapp_init_fn_t)(void);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
sysapp_init_fn_t entry;
|
||||||
|
} sysapp_entry_t;
|
||||||
|
|
||||||
|
extern const sysapp_entry_t g_sysapps[];
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* AsterOS Kernel
|
||||||
|
* Autor: Pavel Kalas
|
||||||
|
* Rok: 2026
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tento modul sjednocuje stavove vypisy jadra ve formatu [ STAV ] zprava.
|
||||||
|
* Poskytuje jednoduche helpery pro bezne uspesne a chybove hlaseni,
|
||||||
|
* aby byly boot/setup logy konzistentni na jednom miste.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "bootlog.h"
|
||||||
|
|
||||||
|
#include "display.h"
|
||||||
|
#include "printk.h"
|
||||||
|
|
||||||
|
void bootlog_state(const char *state, unsigned char state_color, const char *msg) {
|
||||||
|
display_set_color(0x0F, 0x00);
|
||||||
|
aster_print("[ ");
|
||||||
|
display_set_color(state_color, 0x00);
|
||||||
|
aster_print(state ? state : "NEZNAMY");
|
||||||
|
display_set_color(0x0F, 0x00);
|
||||||
|
aster_print(" ] ");
|
||||||
|
printk("%s\n", msg ? msg : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootlog_ok(const char *msg) {
|
||||||
|
bootlog_state("HOTOVO", 0x0A, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootlog_error(const char *msg) {
|
||||||
|
bootlog_state("CHYBA", 0x0C, msg);
|
||||||
|
}
|
||||||
+139
-18
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
#include "bootlog.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@@ -20,10 +21,12 @@
|
|||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "sysapps_runtime.h"
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
void app_tetris_main(void);
|
void app_tetris_main(void);
|
||||||
|
extern const sysapp_entry_t g_sysapps[];
|
||||||
|
|
||||||
static char g_cwd[ASTERFS_NAME_LEN] = "/";
|
static char g_cwd[ASTERFS_NAME_LEN] = "/";
|
||||||
static unsigned long g_timer_hz = 100UL;
|
static unsigned long g_timer_hz = 100UL;
|
||||||
@@ -63,6 +66,9 @@ static void auth_readline_plain(char *out, int max_len);
|
|||||||
static void auth_readline_secret(char *out, int max_len);
|
static void auth_readline_secret(char *out, int max_len);
|
||||||
static void auth_clear_users(void);
|
static void auth_clear_users(void);
|
||||||
static int auth_add_user(const char *name, const char *pass);
|
static int auth_add_user(const char *name, const char *pass);
|
||||||
|
static void cmd_reboot(void);
|
||||||
|
static int installer_detach_medium(void);
|
||||||
|
static int run_sysapp_by_name(const char *name);
|
||||||
static char g_fm_names[FM_MAX_ENTRIES][ASTERFS_NAME_LEN];
|
static char g_fm_names[FM_MAX_ENTRIES][ASTERFS_NAME_LEN];
|
||||||
static u8 g_fm_types[FM_MAX_ENTRIES];
|
static u8 g_fm_types[FM_MAX_ENTRIES];
|
||||||
static u16 g_fm_sizes[FM_MAX_ENTRIES];
|
static u16 g_fm_sizes[FM_MAX_ENTRIES];
|
||||||
@@ -464,7 +470,7 @@ static void boot_step_finish(const char *label, const char *state, u8 state_colo
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void boot_step_ok(const char *label) {
|
static void boot_step_ok(const char *label) {
|
||||||
boot_step_finish(label, "OK", 0x0A);
|
boot_step_finish(label, "Uspesne", 0x0A);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void boot_step_skip(const char *label) {
|
static void boot_step_skip(const char *label) {
|
||||||
@@ -614,6 +620,33 @@ static int system_is_installed(void) {
|
|||||||
return asterfs_get_type(INSTALL_FLAG_FILE) == 0;
|
return asterfs_get_type(INSTALL_FLAG_FILE) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int run_sysapp_by_name(const char *name) {
|
||||||
|
usize i;
|
||||||
|
|
||||||
|
if (!name || name[0] == '\0') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; g_sysapps[i].name; ++i) {
|
||||||
|
if (aster_strcmp(g_sysapps[i].name, name) == 0) {
|
||||||
|
g_sysapps[i].entry();
|
||||||
|
render_shell_statusbar();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int installer_detach_medium(void) {
|
||||||
|
if (asterfs_sync() != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Removable install medium is not controllable in current runtime. */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_setup_install(void) {
|
static void cmd_setup_install(void) {
|
||||||
static const char readme[] =
|
static const char readme[] =
|
||||||
"AsterOS base install\n"
|
"AsterOS base install\n"
|
||||||
@@ -631,6 +664,7 @@ static void cmd_setup_install(void) {
|
|||||||
char setup_user[AUTH_NAME_LEN];
|
char setup_user[AUTH_NAME_LEN];
|
||||||
char setup_pass[AUTH_PASS_LEN];
|
char setup_pass[AUTH_PASS_LEN];
|
||||||
char user_home[ASTERFS_NAME_LEN];
|
char user_home[ASTERFS_NAME_LEN];
|
||||||
|
int k;
|
||||||
usize p = 0;
|
usize p = 0;
|
||||||
|
|
||||||
aster_print("Setup: instalace systemu na AsterFS disk...\n");
|
aster_print("Setup: instalace systemu na AsterFS disk...\n");
|
||||||
@@ -648,19 +682,6 @@ static void cmd_setup_install(void) {
|
|||||||
aster_print("Setup heslo (prazdne = auto-login): ");
|
aster_print("Setup heslo (prazdne = auto-login): ");
|
||||||
auth_readline_secret(setup_pass, sizeof(setup_pass));
|
auth_readline_secret(setup_pass, sizeof(setup_pass));
|
||||||
|
|
||||||
auth_clear_users();
|
|
||||||
if (auth_add_user(setup_user, setup_pass) != 0 || auth_save_users() != 0) {
|
|
||||||
print_error("Setup error: nelze ulozit uzivatele");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aster_memset(g_current_user, 0, sizeof(g_current_user));
|
|
||||||
p = aster_strlen(setup_user);
|
|
||||||
if (p >= sizeof(g_current_user)) {
|
|
||||||
p = sizeof(g_current_user) - 1;
|
|
||||||
}
|
|
||||||
aster_memcpy(g_current_user, setup_user, p);
|
|
||||||
|
|
||||||
if (fs_ensure_dir("/etc") != 0) {
|
if (fs_ensure_dir("/etc") != 0) {
|
||||||
print_error("Setup error: nelze pripravit slozku /etc");
|
print_error("Setup error: nelze pripravit slozku /etc");
|
||||||
return;
|
return;
|
||||||
@@ -714,9 +735,43 @@ static void cmd_setup_install(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auth_clear_users();
|
||||||
|
if (auth_add_user(setup_user, setup_pass) != 0 || auth_save_users() != 0) {
|
||||||
|
print_error("Setup error: nelze ulozit uzivatele");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aster_memset(g_current_user, 0, sizeof(g_current_user));
|
||||||
|
p = aster_strlen(setup_user);
|
||||||
|
if (p >= sizeof(g_current_user)) {
|
||||||
|
p = sizeof(g_current_user) - 1;
|
||||||
|
}
|
||||||
|
aster_memcpy(g_current_user, setup_user, p);
|
||||||
|
|
||||||
ensure_aliases_file();
|
ensure_aliases_file();
|
||||||
|
|
||||||
aster_print("Setup complete: system nainstalovan na disk\n");
|
aster_print("Setup complete: system nainstalovan na disk\n");
|
||||||
|
aster_print("Restartovat system nyni? [y/N] ");
|
||||||
|
k = keyboard_read_key();
|
||||||
|
if (k != '\n') {
|
||||||
|
display_putc((char)k);
|
||||||
|
}
|
||||||
|
display_putc('\n');
|
||||||
|
|
||||||
|
if (k == 'y' || k == 'Y') {
|
||||||
|
if (installer_detach_medium() != 0) {
|
||||||
|
bootlog_error("Nelze odpojit instalacni medium, stiskni ENTER pro pokracovani");
|
||||||
|
for (;;) {
|
||||||
|
int kk = keyboard_read_key();
|
||||||
|
if (kk == '\n') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_sleep_ms(1500);
|
||||||
|
cmd_reboot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_welcome_banner(void) {
|
static void show_welcome_banner(void) {
|
||||||
@@ -804,6 +859,7 @@ static const char g_help_lines[][80] = {
|
|||||||
"edit filename - editor (Ctrl+S, ESC)",
|
"edit filename - editor (Ctrl+S, ESC)",
|
||||||
"calc A op B - vypocet (+ - * /)",
|
"calc A op B - vypocet (+ - * /)",
|
||||||
"tetris - testovaci hra nad app API",
|
"tetris - testovaci hra nad app API",
|
||||||
|
"<sysapps nazvy> - appka ze slozky sysapps",
|
||||||
"echo text - vypis textu",
|
"echo text - vypis textu",
|
||||||
"ticks - pocet tiknuti casovace",
|
"ticks - pocet tiknuti casovace",
|
||||||
"alloc N - alokovat N bajtu",
|
"alloc N - alokovat N bajtu",
|
||||||
@@ -1127,6 +1183,7 @@ static void auth_login_screen(void) {
|
|||||||
auth_readline_plain(name, sizeof(name));
|
auth_readline_plain(name, sizeof(name));
|
||||||
aster_print("Heslo: ");
|
aster_print("Heslo: ");
|
||||||
auth_readline_secret(pass, sizeof(pass));
|
auth_readline_secret(pass, sizeof(pass));
|
||||||
|
timer_sleep_ms(1000);
|
||||||
|
|
||||||
{
|
{
|
||||||
int idx = auth_find_user(name);
|
int idx = auth_find_user(name);
|
||||||
@@ -1137,8 +1194,8 @@ static void auth_login_screen(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_error("Spatny login nebo heslo");
|
print_error("Spatny login nebo heslo, zkus to znovu...");
|
||||||
timer_sleep_ms(1000);
|
timer_sleep_ms(4000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2394,7 +2451,34 @@ static void show_calc_ui(long a, long b, char op, long r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_reboot(void) {
|
static void cmd_reboot(void) {
|
||||||
aster_print("Reboot...\n");
|
display_clear();
|
||||||
|
display_set_color(0x0F, 0x00);
|
||||||
|
aster_print("System restart sequence\n\n");
|
||||||
|
|
||||||
|
boot_step_begin("Stopping user session");
|
||||||
|
aster_memset(g_current_user, 0, sizeof(g_current_user));
|
||||||
|
boot_step_ok("Stopping user session");
|
||||||
|
|
||||||
|
boot_step_begin("Unloading modules");
|
||||||
|
keyboard_set_refresh_callback(0, 0);
|
||||||
|
boot_step_ok("Unloading modules");
|
||||||
|
|
||||||
|
boot_step_begin("Freeing memory");
|
||||||
|
g_status_marquee_only = 0;
|
||||||
|
status_clear_marquee();
|
||||||
|
status_clear_left_hint();
|
||||||
|
boot_step_ok("Freeing memory");
|
||||||
|
|
||||||
|
boot_step_begin("Syncing filesystems");
|
||||||
|
if (asterfs_sync() == 0) {
|
||||||
|
boot_step_ok("Syncing filesystems");
|
||||||
|
} else {
|
||||||
|
boot_step_finish("Syncing filesystems", "CHYBA", 0x0C);
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_sleep_ms(2000);
|
||||||
|
|
||||||
|
boot_step_begin("Issuing hardware reset");
|
||||||
__asm__ volatile ("cli");
|
__asm__ volatile ("cli");
|
||||||
|
|
||||||
if (kbc_wait_input_clear()) {
|
if (kbc_wait_input_clear()) {
|
||||||
@@ -2864,6 +2948,8 @@ static void shell_loop(void) {
|
|||||||
cmd_reboot();
|
cmd_reboot();
|
||||||
} else if (aster_strcmp(exec_cmd, "shutdown") == 0) {
|
} else if (aster_strcmp(exec_cmd, "shutdown") == 0) {
|
||||||
cmd_shutdown();
|
cmd_shutdown();
|
||||||
|
} else if (run_sysapp_by_name(exec_cmd) == 0) {
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
print_error("Neznamy prikaz. Zadej help.");
|
print_error("Neznamy prikaz. Zadej help.");
|
||||||
}
|
}
|
||||||
@@ -2873,21 +2959,56 @@ static void shell_loop(void) {
|
|||||||
void kmain(void) {
|
void kmain(void) {
|
||||||
display_init();
|
display_init();
|
||||||
|
|
||||||
|
boot_step_begin("Serial ovladac");
|
||||||
serial_init();
|
serial_init();
|
||||||
if (serial_is_ready()) {
|
if (serial_is_ready()) {
|
||||||
printk("[serial] COM1 initialized\n");
|
boot_step_ok("Serial ovladac");
|
||||||
|
} else {
|
||||||
|
boot_step_skip("Serial ovladac");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boot_step_begin("CPU jadro");
|
||||||
cpu_init();
|
cpu_init();
|
||||||
|
boot_step_ok("CPU jadro");
|
||||||
|
|
||||||
|
boot_step_begin("Spravce pameti nacten");
|
||||||
memory_init();
|
memory_init();
|
||||||
|
boot_step_ok("Spravce pameti nacten");
|
||||||
|
|
||||||
|
boot_step_begin("Spravce procesu");
|
||||||
process_init();
|
process_init();
|
||||||
|
boot_step_ok("Spravce procesu");
|
||||||
|
|
||||||
|
boot_step_begin("Planovac");
|
||||||
scheduler_init();
|
scheduler_init();
|
||||||
|
boot_step_ok("Planovac");
|
||||||
|
|
||||||
|
boot_step_begin("Vrstva syscalls");
|
||||||
syscall_init();
|
syscall_init();
|
||||||
|
boot_step_ok("Vrstva syscalls");
|
||||||
|
|
||||||
|
boot_step_begin("Klavesnicovy ovladac");
|
||||||
keyboard_init();
|
keyboard_init();
|
||||||
|
boot_step_ok("Klavesnicovy ovladac");
|
||||||
|
|
||||||
|
boot_step_begin("Casovac");
|
||||||
timer_init((unsigned int)g_timer_hz);
|
timer_init((unsigned int)g_timer_hz);
|
||||||
|
boot_step_ok("Casovac");
|
||||||
|
|
||||||
|
boot_step_begin("Obnova shellu");
|
||||||
keyboard_set_refresh_callback(shell_status_refresh_callback, g_timer_hz ? g_timer_hz : 100UL);
|
keyboard_set_refresh_callback(shell_status_refresh_callback, g_timer_hz ? g_timer_hz : 100UL);
|
||||||
|
boot_step_ok("Obnova shellu");
|
||||||
|
|
||||||
|
boot_step_begin("Diskovy ovladac");
|
||||||
storage_init();
|
storage_init();
|
||||||
|
boot_step_ok("Diskovy ovladac");
|
||||||
|
|
||||||
|
boot_step_begin("Preruseni");
|
||||||
interrupts_init();
|
interrupts_init();
|
||||||
|
boot_step_ok("Preruseni");
|
||||||
|
|
||||||
|
aster_print("\nBoot sekvence dokoncena\n");
|
||||||
|
timer_sleep_ms(1500);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auth_login_screen();
|
auth_login_screen();
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#include "aster_api.h"
|
||||||
|
|
||||||
|
void init(void) {
|
||||||
|
aster_api_print("Hello, world!");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user