rewrite the device subsystem interfaces (#48)
authorLunaixsky <lunaixsky@qq.com>
Wed, 20 Nov 2024 00:49:12 +0000 (00:49 +0000)
committerGitHub <noreply@github.com>
Wed, 20 Nov 2024 00:49:12 +0000 (00:49 +0000)
commit35a7d633d3f16c1e0539af6ca5d8e7482926cd93
tree5ab3f53de91a4104d85259886469546afd6a068a
parent99f2ed669601a61f4f0210e0b481ff877cd9bea7
rewrite the device subsystem interfaces (#48)

* add a new initfn stage for decoupling, adjust loading orders

* promote x86 intc to proper device rather than init fn

* add devtree compatible driver manager

* fix some issues in the devtree implementation

* rewrite pci device model for peripherals

* introduce changeling, or morphable. with main purpose of managing and
  decouple the objects that are passing around within the kernel,
  especially in device subsystem, things getting even more chaos.

* rewrite the pci device model such that it:
   1. provides unified way to export device driver, we completely remove
      the use of EXPORT_PCI_DEVICE
   2. better integration with devicetree assisted device initialisation
      and configuration.
   3. give the entire freedom to driver decide how to  spawn their
      struct device instance.

* re-organise the deivce_def to make the hooks more general and
  universal.

* refactor device_def and device numbering

* refactor the declaration of device_def more intuitive, enhance
  readbility
* rename the device capability into potens
* refactor the device numbering, using enum, remove the need of manually
  maintain the number. New macros allow developer to focus only on the
  name rather than prefixes/conventions.
* minor fixes.

* refactor the hwtimer/hwrtc with potens.

* load and init of hwtimer and hwrtc are now done through the potens.
* streamline the term dev creation by unifying with the potens.
* move the *.lst file to a dedicated directory
* minor cleanups

* glue the device objects into devfs using changelings.

* minor code cleanup

* cleanup: remove the lx_timer_context

* use safer method to resolve inode embedded device morpher

* rework the dtm and allow pattern based compat field matching

* add implementation for fast strlen and strnlen for x86

* use weak alias to decouple realm-specific impl. of hooks

* replace device interface with device vendor in devclass
* rename the weak to _weak for avoid accidential expansion
* enable small function inlining as default optimization

* move isrm_ivosalloc and isrm_ivexalloc to x86 specific

* add comment regarding the regular expr used by pattern matcher
83 files changed:
lunaix-os/arch/generic/arch.c
lunaix-os/arch/generic/includes/asm-generic/isrm.h
lunaix-os/arch/x86/arch.c
lunaix-os/arch/x86/exceptions/isrm.c
lunaix-os/arch/x86/hal/apic_timer.c
lunaix-os/arch/x86/hal/mc146818a.c
lunaix-os/arch/x86/hal/ps2kbd.c
lunaix-os/arch/x86/hal/rngx86.c
lunaix-os/arch/x86/includes/asm/x86_isrm.h
lunaix-os/arch/x86/klib/fast_str.c
lunaix-os/hal/LBuild
lunaix-os/hal/acpi/acpi.c
lunaix-os/hal/ahci/ahci.c
lunaix-os/hal/ahci/ahci_pci.c
lunaix-os/hal/bus/pci.c
lunaix-os/hal/char/devnull.c
lunaix-os/hal/char/devzero.c
lunaix-os/hal/char/lxconsole.c
lunaix-os/hal/char/serial.c
lunaix-os/hal/char/uart/16x50_dev.c [new file with mode: 0644]
lunaix-os/hal/char/uart/16x50_isa.c
lunaix-os/hal/char/uart/16x50_pci.c
lunaix-os/hal/char/uart/LBuild
lunaix-os/hal/devtree/LBuild [new file with mode: 0644]
lunaix-os/hal/devtree/devtree.h
lunaix-os/hal/devtree/dt.c
lunaix-os/hal/devtree/dt_interrupt.c
lunaix-os/hal/devtree/dtm.c [new file with mode: 0644]
lunaix-os/hal/gfxa/gfxm.c
lunaix-os/hal/gfxa/vga/vga_pci.c
lunaix-os/hal/rtc/rtc_device.c
lunaix-os/hal/term/console.c
lunaix-os/hal/term/default_ops.c
lunaix-os/hal/term/term.c
lunaix-os/hal/term/term_io.c
lunaix-os/hal/timer/timer_device.c
lunaix-os/includes/hal/devtree.h
lunaix-os/includes/hal/devtreem.h [new file with mode: 0644]
lunaix-os/includes/hal/hwrtc.h
lunaix-os/includes/hal/hwtimer.h
lunaix-os/includes/hal/pci.h
lunaix-os/includes/hal/serial.h
lunaix-os/includes/hal/term.h
lunaix-os/includes/listings/changeling.lst [new file with mode: 0644]
lunaix-os/includes/listings/device_potens.lst [new file with mode: 0644]
lunaix-os/includes/listings/devnum.lst [new file with mode: 0644]
lunaix-os/includes/listings/devnum_fn.lst [new file with mode: 0644]
lunaix-os/includes/listings/devnum_vn.lst [new file with mode: 0644]
lunaix-os/includes/lunaix/changeling.h [new file with mode: 0644]
lunaix-os/includes/lunaix/clock.h
lunaix-os/includes/lunaix/compiler.h
lunaix-os/includes/lunaix/device.h
lunaix-os/includes/lunaix/device_num.h
lunaix-os/includes/lunaix/ds/list.h [new file with mode: 0644]
lunaix-os/includes/lunaix/owloysius.h
lunaix-os/includes/lunaix/sections.h
lunaix-os/includes/lunaix/timer.h
lunaix-os/kernel/LBuild
lunaix-os/kernel/block/blkbuf.c
lunaix-os/kernel/changeling.c [new file with mode: 0644]
lunaix-os/kernel/device/LBuild
lunaix-os/kernel/device/capability.c [deleted file]
lunaix-os/kernel/device/devdb.c
lunaix-os/kernel/device/devfs.c
lunaix-os/kernel/device/device.c
lunaix-os/kernel/device/potentem.c [new file with mode: 0644]
lunaix-os/kernel/fs/mount.c
lunaix-os/kernel/fs/vfs.c
lunaix-os/kernel/kinit.c
lunaix-os/kernel/time/clock.c
lunaix-os/kernel/time/timer.c
lunaix-os/libs/crc.c
lunaix-os/libs/hash.c
lunaix-os/libs/klibc/string/mem.c [changed mode: 0755->0644]
lunaix-os/libs/klibc/string/strchr.c
lunaix-os/libs/klibc/string/strcmp.c
lunaix-os/libs/klibc/string/strcpy.c
lunaix-os/libs/klibc/string/strlen.c
lunaix-os/libs/klibc/string/trim.c
lunaix-os/link/lga.ldx
lunaix-os/live_debug.sh
lunaix-os/makefile
lunaix-os/makeinc/toolchain.mkinc