Skip to content

Commit

Permalink
Menuconfig Implementation and auto-qemu refactoring (#44)
Browse files Browse the repository at this point in the history
* unify the chardev backend definitions

* add --dry option for dry-running
* allow supply extra raw qemu options

* implement ncurses based tui framework

* basic lunamenu framework built on top libtui

* (libtui) add scrollable, list, textbox
* (menu) add listview, dialogue

* interface LunaConfig into menuconfig

* remove flickering when new context being added and redrawn
* add ability to navigate, edit the config node
* adjust the layout parameters
* some refactors

* add help dialogue

* layout refinement
* add <BACKSPACE> as hot key to navigate up level
* add confirmation dialogue for exiting
* refactors

* add user friendly alias to LConfig terms

* fix the focusing problem with textbox

* bypass the configuration for user program generation

* bypass the showing of config view during usr program generation, use
  default value instead
* house keeping stuff

* add terminal dimension check and fallback to prompt based

* replenish the help messages
* fix: udiv64 is not used when doing u64 division
  • Loading branch information
Minep authored Aug 25, 2024
1 parent a136ca3 commit 50b4ecf
Show file tree
Hide file tree
Showing 20 changed files with 2,259 additions and 122 deletions.
4 changes: 2 additions & 2 deletions lunaix-os/LConfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include("kernel")
include("arch")
include("hal")

@Term("Version")
@Term("Kernel Version")
@ReadOnly
def lunaix_ver():
"""
Expand All @@ -16,7 +16,7 @@ def lunaix_ver():
seq_num = int(time.time() / 3600)
default("%s dev-2024_%d"%(v(arch), seq_num))

@Collection
@Collection("Kernel Debug and Testing")
def debug_and_testing():
"""
General settings for kernel debugging feature
Expand Down
22 changes: 16 additions & 6 deletions lunaix-os/arch/LConfig
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
include("x86/LConfig")

@Collection
@Collection("Platform")
def architecture_support():
"""
Config ISA related features
"""

@Term
@Term("Architecture")
def arch():
""" Config ISA support """
type(["i386", "x86_64", "aarch64", "rv64"])
default("i386")
"""
Config ISA support
"""
# type(["i386", "x86_64", "aarch64", "rv64"])
type(["i386", "x86_64"])
default("x86_64")

env_val = env("ARCH")
if env_val:
set_value(env_val)

@Term
@Term("Base operand size")
@ReadOnly
def arch_bits():
"""
Defines the base size of a general register of the
current selected ISA.

This the 'bits' part when we are talking about a CPU
"""

type(["64", "32"])
match v(arch):
case "i386":
Expand Down
8 changes: 4 additions & 4 deletions lunaix-os/arch/x86/LConfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def x86_configurations():

add_to_collection(architecture_support)

@Term
@Term("Use SSE2/3/4 extension")
def x86_enable_sse_feature():
"""
Config whether to allow using SSE feature for certain
Expand All @@ -15,14 +15,14 @@ def x86_configurations():
default(False)


@Term
@Term("Bootloader Model")
def x86_bl():
"""
Select the bootloader interface

Supported interface
mb: multiboot compliant
mb2: multiboot2 compliant
mb: multiboot compliance
mb2: multiboot2 compliance
none: do not use any interface
"""

Expand Down
2 changes: 1 addition & 1 deletion lunaix-os/hal/LConfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include("char")
include("bus")
include("ahci")

@Collection
@Collection("Devices & Peripherials")
def hal():
""" Lunaix hardware asbtraction layer """

Expand Down
4 changes: 2 additions & 2 deletions lunaix-os/hal/ahci/LConfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

@Collection
@Collection("AHCI")
def sata_ahci():

add_to_collection(hal)

@Term
@Term("Enable AHCI support")
def ahci_enable():
""" Enable the support of SATA AHCI.
Must require PCI at current stage """
Expand Down
8 changes: 4 additions & 4 deletions lunaix-os/hal/bus/LConfig
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

@Collection
@Collection("Buses & Interconnects")
def bus_if():
""" System/platform bus interface """

add_to_collection(hal)

@Term
@Term("PCI")
def pci_enable():
""" Peripheral Component Interconnect (PCI) Bus """
type(bool)
default(True)

@Term
@Term("PCI Express")
def pcie_ext():
""" Enable support of PCI-Express extension """
type(bool)
default(False)

return v(pci_enable)

@Term
@Term("Use PMIO for PCI")
def pci_pmio():
""" Use port-mapped I/O interface for controlling PCI """
type(bool)
Expand Down
12 changes: 8 additions & 4 deletions lunaix-os/hal/char/LConfig
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
include("uart")

@Collection
@Collection("Character Devices")
def char_device():
""" Controlling support of character devices """

add_to_collection(hal)

@Term
@Term("VGA 80x25 text-mode console")
def vga_console():
""" Enable VGA console device (text mode only) """

type(bool)
default(True)

@Term
@Term("VGA character game device")
def chargame_console():
""" Enable VGA Charactor Game console device (text mode only) """
"""
Enable VGA Charactor Game console device (text mode only)

You normally don't need to include this, unless you want some user space fun ;)
"""

type(bool)
default(False)
4 changes: 3 additions & 1 deletion lunaix-os/kernel/block/blkbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <lunaix/mm/valloc.h>
#include <lunaix/owloysius.h>
#include <lunaix/syslog.h>
#include <sys/muldiv64.h>

LOG_MODULE("blkbuf")

Expand All @@ -17,7 +18,8 @@ static struct cake_pile* bb_pile;
static inline u64_t
__tolba(struct blkbuf_cache* cache, unsigned int blk_id)
{
return ((u64_t)cache->blksize * (u64_t)blk_id) / cache->blkdev->blk_size;
return udiv64(((u64_t)cache->blksize * (u64_t)blk_id),
cache->blkdev->blk_size);
}

static void
Expand Down
6 changes: 3 additions & 3 deletions lunaix-os/kernel/fs/LConfig
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

@Collection
@Collection("File Systems")
def file_system():
""" Config feature related to file system supports """

add_to_collection(kernel_feature)

@Term
@Term("ext2 support")
def fs_ext2():
""" Enable ext2 file system support """

type(bool)
default(True)

@Term
@Term("iso9660 support")
def fs_iso9660():
""" Enable iso9660 file system support """

Expand Down
28 changes: 14 additions & 14 deletions lunaix-os/kernel/mm/LConfig
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@

@Collection
@Collection("Memory Management")
def memory_subsystem():
""" Config the memory subsystem """

@Collection
@Collection("Physical Memory")
def physical_mm():
""" Physical memory manager """

@Term
@Term("Allocation policy")
def pmalloc_method():
""" Allocation policy for phiscal memory """

type(["simple", "buddy", "ncontig"])
default("simple")

@Group
@Group("Simple")
def pmalloc_simple_po_thresholds():

@Term
@Term("Maximum cached order-0 free pages")
def pmalloc_simple_max_po0():
""" free list capacity for order-0 pages """

type(int)
default(4096)

@Term
@Term("Maximum cached order-1 free pages")
def pmalloc_simple_max_po1():
""" free list capacity for order-1 pages """

type(int)
default(2048)

@Term
@Term("Maximum cached order-2 free pages")
def pmalloc_simple_max_po2():
""" free list capacity for order-2 pages """

type(int)
default(2048)

@Term
@Term("Maximum cached order-3 free pages")
def pmalloc_simple_max_po3():
""" free list capacity for order-3 pages """

type(int)
default(2048)

@Term
@Term("Maximum cached order-4 free pages")
def pmalloc_simple_max_po4():
""" free list capacity for order-4 pages """

type(int)
default(512)

@Term
@Term("Maximum cached order-5 free pages")
def pmalloc_simple_max_po5():
""" free list capacity for order-5 pages """

type(int)
default(512)

@Term
@Term("Maximum cached order-6 free pages")
def pmalloc_simple_max_po6():
""" free list capacity for order-6 pages """

type(int)
default(128)

@Term
@Term("Maximum cached order-7 free pages")
def pmalloc_simple_max_po7():
""" free list capacity for order-7 pages """

type(int)
default(128)

@Term
@Term("Maximum cached order-8 free pages")
def pmalloc_simple_max_po8():
""" free list capacity for order-8 pages """

type(int)
default(64)

@Term
@Term("Maximum cached order-9 free pages")
def pmalloc_simple_max_po9():
""" free list capacity for order-9 pages """

Expand Down
9 changes: 5 additions & 4 deletions lunaix-os/makeinc/lunabuild.mkinc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ lbuild_opts := --lconfig-file LConfig

all_lconfigs = $(shell find $(CURDIR) -name "LConfig")

LCONFIG_FLAGS += --config $(lbuild_opts) --config-save $(lconfig_save)

export
$(lconfig_save): $(all_lconfigs)
@echo restarting configuration...
@$(LBUILD) --config $(lbuild_opts) --config-save $(lconfig_save) --force\
-o $(lbuild_dir)/
@$(LBUILD) $(LCONFIG_FLAGS) --force -o $(lbuild_dir)/

export
$(lbuild_config_h): $(lconfig_save)
@$(LBUILD) --config $(lbuild_opts) --config-save $(lconfig_save) -o $(@D)
@$(LBUILD) $(LCONFIG_FLAGS) -o $(@D)

export
$(lbuild_mkinc): $(lbuild_config_h)
Expand All @@ -24,5 +25,5 @@ $(lbuild_mkinc): $(lbuild_config_h)
.PHONY: config
export
config: $(all_lconfigs)
@$(LBUILD) --config $(lbuild_opts) --config-save $(lconfig_save) --force\
@$(LBUILD) $(LCONFIG_FLAGS) --force\
-o $(lbuild_dir)/
Loading

0 comments on commit 50b4ecf

Please sign in to comment.