refactor: replace all stdint::uint32_t into short and more manageable u32_t
authorMinep <zelong56@gmail.com>
Sun, 13 Nov 2022 22:20:45 +0000 (22:20 +0000)
committerMinep <zelong56@gmail.com>
Sun, 13 Nov 2022 22:20:45 +0000 (22:20 +0000)
58 files changed:
lunaix-os/arch/x86/hhk.c
lunaix-os/hal/acpi/acpi.c
lunaix-os/hal/ahci/ahci.c
lunaix-os/hal/ahci/ata.c
lunaix-os/hal/ahci/atapi.c
lunaix-os/hal/ahci/hbadev_export.c
lunaix-os/hal/ahci/utils.c
lunaix-os/hal/apic.c
lunaix-os/hal/cpu.c
lunaix-os/hal/ioapic.c
lunaix-os/hal/pci.c
lunaix-os/includes/arch/x86/tss.h
lunaix-os/includes/hal/acpi/acpi.h
lunaix-os/includes/hal/acpi/fadt.h
lunaix-os/includes/hal/acpi/madt.h
lunaix-os/includes/hal/acpi/mcfg.h
lunaix-os/includes/hal/acpi/sdt.h
lunaix-os/includes/hal/ahci/hba.h
lunaix-os/includes/hal/ahci/scsi.h
lunaix-os/includes/hal/cpu.h
lunaix-os/includes/hal/io.h
lunaix-os/includes/hal/ioapic.h
lunaix-os/includes/hal/pci.h
lunaix-os/includes/lib/hash.h
lunaix-os/includes/lunaix/block.h
lunaix-os/includes/lunaix/clock.h
lunaix-os/includes/lunaix/device.h
lunaix-os/includes/lunaix/ds/btrie.h
lunaix-os/includes/lunaix/ds/hstr.h
lunaix-os/includes/lunaix/ds/lru.h
lunaix-os/includes/lunaix/fs.h
lunaix-os/includes/lunaix/fs/twifs.h
lunaix-os/includes/lunaix/input.h
lunaix-os/includes/lunaix/mm/dmm.h
lunaix-os/includes/lunaix/mm/mmio.h
lunaix-os/includes/lunaix/mm/page.h
lunaix-os/includes/lunaix/mm/pmm.h
lunaix-os/includes/lunaix/timer.h
lunaix-os/kernel/asm/x86/gdt.c
lunaix-os/kernel/asm/x86/intr_routines.c
lunaix-os/kernel/asm/x86/intrhnds.c
lunaix-os/kernel/asm/x86/tss.c
lunaix-os/kernel/device/device.c
lunaix-os/kernel/ds/btrie.c
lunaix-os/kernel/fs/iso9660/mount.c
lunaix-os/kernel/fs/pcache.c
lunaix-os/kernel/fs/twifs/twifs.c
lunaix-os/kernel/fs/vfs.c
lunaix-os/kernel/mm/kalloc.c
lunaix-os/kernel/mm/mmio.c
lunaix-os/kernel/mm/pmm.c
lunaix-os/kernel/mm/vmm.c
lunaix-os/kernel/time/timer.c
lunaix-os/kernel/tty/lxconsole.c
lunaix-os/kernel/tty/tty.c
lunaix-os/libs/hash.c
lunaix-os/libs/klibc/stdio/ksprintf.c
lunaix-os/scripts/x86_idt_generator.py

index 997bbdf86bcd886a84c0f37179f8aa2f8fc181bf..5854b626b580f057ba92adc7d2115f85d5ec2aaa 100644 (file)
@@ -36,7 +36,7 @@ _init_page(ptd_t* ptd)
 
     // 对低1MiB空间进行对等映射(Identity
     // mapping),也包括了我们的VGA,方便内核操作。
-    for (uint32_t i = 0; i < 256; i++) {
+    for (u32_t i = 0; i < 256; i++) {
         SET_PTE(ptd,
                 PG_TABLE_IDENTITY,
                 i,
@@ -46,7 +46,7 @@ _init_page(ptd_t* ptd)
     // 对等映射我们的hhk_init,这样一来,当分页与地址转换开启后,我们依然能够照常执行最终的
     // jmp 指令来跳转至
     //  内核的入口点
-    for (uint32_t i = 0; i < HHK_PAGE_COUNT; i++) {
+    for (u32_t i = 0; i < HHK_PAGE_COUNT; i++) {
         SET_PTE(ptd,
                 PG_TABLE_IDENTITY,
                 256 + i,
@@ -57,14 +57,14 @@ _init_page(ptd_t* ptd)
 
     // 这里是一些计算,主要是计算应当映射进的 页目录 与 页表 的条目索引(Entry
     // Index)
-    uint32_t kernel_pde_index = L1_INDEX(sym_val(__kernel_start));
-    uint32_t kernel_pte_index = L2_INDEX(sym_val(__kernel_start));
-    uint32_t kernel_pg_counts = KERNEL_PAGE_COUNT;
+    u32_t kernel_pde_index = L1_INDEX(sym_val(__kernel_start));
+    u32_t kernel_pte_index = L2_INDEX(sym_val(__kernel_start));
+    u32_t kernel_pg_counts = KERNEL_PAGE_COUNT;
 
     // 将内核所需要的页表注册进页目录
     //  当然,就现在而言,我们的内核只占用不到50个页(每个页表包含1024个页)
     //  这里分配了3个页表(12MiB),未雨绸缪。
-    for (uint32_t i = 0; i < PG_TABLE_STACK - PG_TABLE_KERNEL; i++) {
+    for (u32_t i = 0; i < PG_TABLE_STACK - PG_TABLE_KERNEL; i++) {
         SET_PDE(ptd,
                 kernel_pde_index + i,
                 NEW_L1_ENTRY(PG_PREM_URW, PT_ADDR(ptd, PG_TABLE_KERNEL + i)))
@@ -82,7 +82,7 @@ _init_page(ptd_t* ptd)
     uintptr_t kernel_pm = V2P(&__kernel_start);
 
     // 重映射内核至高半区地址(>=0xC0000000)
-    for (uint32_t i = 0; i < kernel_pg_counts; i++) {
+    for (u32_t i = 0; i < kernel_pg_counts; i++) {
         // FIXME: 只是用作用户模式(R3)测试!
         //        在实际中,内核代码除了极少部分需要暴露给R3(如从信号返回),其余的应为R0。
         SET_PTE(ptd,
@@ -95,7 +95,7 @@ _init_page(ptd_t* ptd)
     SET_PDE(ptd, PG_MAX_ENTRIES - 1, NEW_L1_ENTRY(T_SELF_REF_PERM, ptd));
 }
 
-uint32_t
+u32_t
 __save_subset(uint8_t* destination, uint8_t* base, unsigned int size)
 {
     unsigned int i = 0;
@@ -108,7 +108,7 @@ __save_subset(uint8_t* destination, uint8_t* base, unsigned int size)
 void
 _save_multiboot_info(multiboot_info_t* info, uint8_t* destination)
 {
-    uint32_t current = 0;
+    u32_t current = 0;
     uint8_t* info_b = (uint8_t*)info;
     for (; current < sizeof(multiboot_info_t); current++) {
         *(destination + current) = *(info_b + current);
@@ -129,13 +129,13 @@ _save_multiboot_info(multiboot_info_t* info, uint8_t* destination)
 }
 
 void
-_hhk_init(ptd_t* ptd, uint32_t kpg_size)
+_hhk_init(ptd_t* ptd, u32_t kpg_size)
 {
 
     // 初始化 kpg 全为0
     //      P.s. 真没想到GRUB会在这里留下一堆垃圾! 老子的页表全乱套了!
     uint8_t* kpg = (uint8_t*)ptd;
-    for (uint32_t i = 0; i < kpg_size; i++) {
+    for (u32_t i = 0; i < kpg_size; i++) {
         *(kpg + i) = 0;
     }
 
index 67f5adebcd0c0ccf4e0255b5575292e466cf7129..419b1360fc17c16f7aaec63f795a2d632b3537c7 100644 (file)
@@ -113,8 +113,8 @@ acpi_locate_rsdp(multiboot_info_t* mb_info)
         uint8_t* mem_start = entry.addr_low & ~0xf;
         size_t len = entry.len_low;
         for (size_t j = 0; j < len; j += 16) {
-            uint32_t sig_low = *((uint32_t*)(mem_start + j));
-            // uint32_t sig_high = *((uint32_t*)(mem_start+j) + 1);
+            u32_t sig_low = *((u32_t*)(mem_start + j));
+            // u32_t sig_high = *((u32_t*)(mem_start+j) + 1);
             if (sig_low == ACPI_RSDP_SIG_L) {
                 rsdp = (acpi_rsdp_t*)(mem_start + j);
                 break;
@@ -125,9 +125,9 @@ acpi_locate_rsdp(multiboot_info_t* mb_info)
     // You know what, I just search the entire 1MiB for Celestia's sake.
     uint8_t* mem_start = 0x4000;
     for (; mem_start < 0x100000; mem_start += 16) {
-        uint32_t sig_low = *((uint32_t*)(mem_start));
+        u32_t sig_low = *((u32_t*)(mem_start));
         // XXX: do we need to compare this as well?
-        // uint32_t sig_high = *((uint32_t*)(mem_start+j) + 1);
+        // u32_t sig_high = *((u32_t*)(mem_start+j) + 1);
         if (sig_low == ACPI_RSDP_SIG_L) {
             rsdp = (acpi_rsdp_t*)(mem_start);
             break;
index e07200ed2c942feea50b5d91de8f1653f56c8aa6..c12244ecec6b9379b392fb1ad5a3a413538486fc 100644 (file)
@@ -192,7 +192,7 @@ ahci_driver_init(struct pci_device* ahci_dev)
                 i,
                 hbadev->model,
                 hbadev->block_size,
-                (uint32_t)hbadev->max_lba);
+                (u32_t)hbadev->max_lba);
 
         ahci_register_device(hbadev);
     }
@@ -218,7 +218,7 @@ __get_free_slot(struct hba_port* port)
     hba_reg_t pxsact = port->regs[HBA_RPxSACT];
     hba_reg_t pxci = port->regs[HBA_RPxCI];
     hba_reg_t free_bmp = pxsact | pxci;
-    uint32_t i = 0;
+    u32_t i = 0;
     for (; i <= port->hba->cmd_slots && (free_bmp & 0x1); i++, free_bmp >>= 1)
         ;
     return i | -(i > port->hba->cmd_slots);
@@ -393,7 +393,7 @@ ahci_init_device(struct hba_port* port)
         goto fail;
     }
 
-    scsi_parse_capacity(port->device, (uint32_t*)data_in);
+    scsi_parse_capacity(port->device, (u32_t*)data_in);
 
 done:
     // reset interrupt status and unmask D2HR interrupt
index 877ed86c6f52f4cb39e73cf4f6ff355f719e54b8..de59eb93f0d8cd741e27d84307304e5f74706a10 100644 (file)
@@ -9,7 +9,7 @@
 void
 sata_read_error(struct hba_port* port)
 {
-    uint32_t tfd = port->regs[HBA_RPxTFD];
+    u32_t tfd = port->regs[HBA_RPxTFD];
     port->device->last_result.sense_key = (tfd & 0xf000) >> 12;
     port->device->last_result.error = (tfd & 0x0f00) >> 8;
     port->device->last_result.status = tfd & 0x00ff;
index bf3e8c92fb26046434c424e735d2c751a4d0f42b..59733f0132b283db1e564851f571994872c9c80c 100644 (file)
@@ -12,8 +12,8 @@
 void
 scsi_create_packet12(struct scsi_cdb12* cdb,
                      uint8_t opcode,
-                     uint32_t lba,
-                     uint32_t alloc_size)
+                     u32_t lba,
+                     u32_t alloc_size)
 {
     memset(cdb, 0, sizeof(*cdb));
     cdb->opcode = opcode;
@@ -25,17 +25,17 @@ void
 scsi_create_packet16(struct scsi_cdb16* cdb,
                      uint8_t opcode,
                      uint64_t lba,
-                     uint32_t alloc_size)
+                     u32_t alloc_size)
 {
     memset(cdb, 0, sizeof(*cdb));
     cdb->opcode = opcode;
-    cdb->lba_be_hi = SCSI_FLIP((uint32_t)(lba >> 32));
-    cdb->lba_be_lo = SCSI_FLIP((uint32_t)lba);
+    cdb->lba_be_hi = SCSI_FLIP((u32_t)(lba >> 32));
+    cdb->lba_be_lo = SCSI_FLIP((u32_t)lba);
     cdb->length = SCSI_FLIP(alloc_size);
 }
 
 void
-scsi_parse_capacity(struct hba_device* device, uint32_t* parameter)
+scsi_parse_capacity(struct hba_device* device, u32_t* parameter)
 {
     if (device->cbd_size == SCSI_CDB16) {
         device->max_lba =
@@ -62,7 +62,7 @@ scsi_submit(struct hba_device* dev, struct blkio_req* io_req)
     header->options |= (HBA_CMDH_WRITE * (write == 1)) | HBA_CMDH_ATAPI;
 
     size_t size = vbuf_size(io_req->vbuf);
-    uint32_t count = ICEIL(size, port->device->block_size);
+    u32_t count = ICEIL(size, port->device->block_size);
 
     struct sata_reg_fis* fis = (struct sata_reg_fis*)table->command_fis;
     void* cdb = table->atapi_cmd;
index d193937c8376ff1ae68deb899ae490c697f11fb7..3fea81d9c4c736f0c944a66a4ec904faf2ad341c 100644 (file)
@@ -38,8 +38,8 @@ void
 __blk_rd_wwid(struct twimap* map)
 {
     struct hba_device* hbadev = twimap_data(map, struct hba_device*);
-    uint32_t h = hbadev->wwn >> 32;
-    uint32_t l = (uint32_t)hbadev->wwn;
+    u32_t h = hbadev->wwn >> 32;
+    u32_t l = (u32_t)hbadev->wwn;
     if ((h | l)) {
         twimap_printf(map, "wwn:%x%x", h, l);
     } else {
index f11ffb4fd05325cff6e31879b15d2483c143e2b7..4a86cc3fe2e3bf98dc8a43670f27eb0ce0ec789f 100644 (file)
 #define IDDEV_OFFLPP 106
 #define IDDEV_OFFCAPABILITIES 49
 
-static uint32_t cdb_size[] = { SCSI_CDB12, SCSI_CDB16, 0, 0 };
+static u32_t cdb_size[] = { SCSI_CDB12, SCSI_CDB16, 0, 0 };
 
 void
 ahci_parse_dev_info(struct hba_device* dev_info, uint16_t* data)
 {
-    dev_info->max_lba = *((uint32_t*)(data + IDDEV_OFFMAXLBA));
-    dev_info->block_size = *((uint32_t*)(data + IDDEV_OFFLSECSIZE));
+    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 = *(uint64_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 = *((uint32_t*)(data + IDDEV_OFFCAPABILITIES));
+    dev_info->capabilities = *((u32_t*)(data + IDDEV_OFFCAPABILITIES));
 
     if (!dev_info->block_size) {
         dev_info->block_size = 512;
index 00995252120892cde34712677f641795ea390634..2f5b5be02afe5c092c16242a1c41bd8660bd2ceb 100644 (file)
@@ -53,8 +53,8 @@ apic_init()
                  : "eax", "ecx", "edx");
 
     // Print the basic information of our current local APIC
-    uint32_t apic_id = apic_read_reg(APIC_IDR) >> 24;
-    uint32_t apic_ver = apic_read_reg(APIC_VER);
+    u32_t apic_id = apic_read_reg(APIC_IDR) >> 24;
+    u32_t apic_ver = apic_read_reg(APIC_VER);
 
     kprintf(KINFO "ID: %x, Version: %x, Max LVT: %u\n",
             apic_id,
@@ -74,7 +74,7 @@ apic_init()
     apic_write_reg(APIC_TPR, APIC_PRIORITY(2, 0));
 
     // enable APIC
-    uint32_t spiv = apic_read_reg(APIC_SPIVR);
+    u32_t spiv = apic_read_reg(APIC_SPIVR);
 
     // install our handler for spurious interrupt.
     spiv = (spiv & ~0xff) | APIC_SPIV_APIC_ENABLE | APIC_SPIV_IV;
index ab5432c9642402556c0282eb8f0ee5982d22d9fb..9517445e1e2b31938391c86254f3ffffd9fb4452 100644 (file)
@@ -1,11 +1,13 @@
+#include <cpuid.h>
 #include <hal/cpu.h>
 #include <stdint.h>
-#include <cpuid.h>
 
-void cpu_get_model(char* model_out) {
-    uint32_t* out = (uint32_t*)model_out;
+void
+cpu_get_model(char* model_out)
+{
+    u32_t* out = (u32_t*)model_out;
     reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
-    
+
     __get_cpuid(0, &eax, &ebx, &ecx, &edx);
 
     out[0] = ebx;
@@ -16,44 +18,47 @@ void cpu_get_model(char* model_out) {
 
 #define BRAND_LEAF 0x80000000UL
 
-int cpu_brand_string_supported() {
+int
+cpu_brand_string_supported()
+{
     reg32 supported = __get_cpuid_max(BRAND_LEAF, 0);
     return (supported >= 0x80000004UL);
 }
 
-void cpu_get_brand(char* brand_out) {
-    if(!cpu_brand_string_supported()) {
+void
+cpu_get_brand(char* brand_out)
+{
+    if (!cpu_brand_string_supported()) {
         brand_out[0] = '?';
         brand_out[1] = '\0';
     }
-    uint32_t* out = (uint32_t*) brand_out;
+    u32_t* out = (u32_t*)brand_out;
     reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
-    for (uint32_t i = 2, j = 0; i < 5; i++)
-    {
+    for (u32_t i = 2, j = 0; i < 5; i++) {
         __get_cpuid(BRAND_LEAF + i, &eax, &ebx, &ecx, &edx);
         out[j] = eax;
         out[j + 1] = ebx;
         out[j + 2] = ecx;
         out[j + 3] = edx;
-        j+=4;
+        j += 4;
     }
     brand_out[48] = '\0';
 }
 
-
 int
-cpu_has_apic() {
+cpu_has_apic()
+{
     // reference: Intel manual, section 10.4.2
     reg32 eax = 0, ebx = 0, edx = 0, ecx = 0;
     __get_cpuid(1, &eax, &ebx, &ecx, &edx);
-    
+
     return (edx & 0x100);
 }
 
 void
-cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low)
+cpu_rdmsr(u32_t msr_idx, u32_t* reg_high, u32_t* reg_low)
 {
-    uint32_t h = 0, l = 0;
+    u32_t h = 0, l = 0;
     asm volatile("rdmsr" : "=d"(h), "=a"(l) : "c"(msr_idx));
 
     *reg_high = h;
@@ -61,7 +66,7 @@ cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low)
 }
 
 void
-cpu_wrmsr(uint32_t msr_idx, uint32_t reg_high, uint32_t reg_low)
+cpu_wrmsr(u32_t msr_idx, u32_t reg_high, u32_t reg_low)
 {
     asm volatile("wrmsr" : : "d"(reg_high), "a"(reg_low), "c"(msr_idx));
 }
\ No newline at end of file
index edd374fcc2056936283e1cfb52d0a8fcae70a002..004f889b18514c8d4a1abbc8e8ee32746010ee7f 100644 (file)
@@ -4,8 +4,8 @@
 #include <lunaix/common.h>
 #include <lunaix/mm/mmio.h>
 
-#define IOAPIC_REG_SEL *((volatile uint32_t*)(_ioapic_base + IOAPIC_IOREGSEL))
-#define IOAPIC_REG_WIN *((volatile uint32_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 uintptr_t _ioapic_base;
 
@@ -20,13 +20,13 @@ ioapic_init()
 }
 
 void
-ioapic_write(uint8_t sel, uint32_t val)
+ioapic_write(uint8_t sel, u32_t val)
 {
     IOAPIC_REG_SEL = sel;
     IOAPIC_REG_WIN = val;
 }
 
-uint32_t
+u32_t
 ioapic_read(uint8_t sel)
 {
     IOAPIC_REG_SEL = sel;
@@ -34,7 +34,7 @@ ioapic_read(uint8_t sel)
 }
 
 void
-ioapic_redirect(uint8_t irq, uint8_t vector, uint8_t dest, uint32_t flags)
+ioapic_redirect(uint8_t irq, uint8_t vector, uint8_t dest, u32_t flags)
 {
     uint8_t reg_sel = IOAPIC_IOREDTBL_BASE + irq * 2;
 
index cb7cfe75351ca7ad6e1b48f14298827c7bd70f34..8969224502e492c4141220c5b8f87be4772695e8 100644 (file)
@@ -28,7 +28,7 @@ pci_probe_msi_info(struct pci_device* device);
 void
 pci_probe_device(int bus, int dev, int funct)
 {
-    uint32_t base = PCI_ADDRESS(bus, dev, funct);
+    u32_t base = PCI_ADDRESS(bus, dev, funct);
     pci_reg_t reg1 = pci_read_cspace(base, 0);
 
     // Vendor=0xffff则表示设备不存在
@@ -102,7 +102,7 @@ pci_probe()
 void
 pci_probe_bar_info(struct pci_device* device)
 {
-    uint32_t bar;
+    u32_t bar;
     struct pci_base_addr* ba;
     for (size_t i = 0; i < 6; i++) {
         ba = &device->bar[i];
@@ -132,7 +132,7 @@ pci_probe_msi_info(struct pci_device* device)
     }
 
     pci_reg_t cap_ptr = pci_read_cspace(device->cspace_base, 0x34) & 0xff;
-    uint32_t cap_hdr;
+    u32_t cap_hdr;
 
     while (cap_ptr) {
         cap_hdr = pci_read_cspace(device->cspace_base, cap_ptr);
@@ -242,7 +242,7 @@ pci_build_fsmapping()
 }
 
 size_t
-pci_bar_sizing(struct pci_device* dev, uint32_t* bar_out, uint32_t bar_num)
+pci_bar_sizing(struct pci_device* dev, u32_t* bar_out, u32_t bar_num)
 {
     pci_reg_t bar = pci_read_cspace(dev->cspace_base, PCI_REG_BAR(bar_num));
     if (!bar) {
@@ -265,10 +265,10 @@ void
 pci_setup_msi(struct pci_device* device, int vector)
 {
     // Dest: APIC#0, Physical Destination, No redirection
-    uint32_t msi_addr = (__APIC_BASE_PADDR);
+    u32_t msi_addr = (__APIC_BASE_PADDR);
 
     // Edge trigger, Fixed delivery
-    uint32_t msi_data = vector;
+    u32_t msi_data = vector;
 
     pci_write_cspace(
       device->cspace_base, PCI_MSI_ADDR(device->msi_loc), msi_addr);
@@ -294,7 +294,7 @@ pci_setup_msi(struct pci_device* device, int vector)
 struct pci_device*
 pci_get_device_by_id(uint16_t vendorId, uint16_t deviceId)
 {
-    uint32_t dev_info = vendorId | (deviceId << 16);
+    u32_t dev_info = vendorId | (deviceId << 16);
     struct pci_device *pos, *n;
     llist_for_each(pos, n, &pci_devices, dev_chain)
     {
@@ -307,7 +307,7 @@ pci_get_device_by_id(uint16_t vendorId, uint16_t deviceId)
 }
 
 struct pci_device*
-pci_get_device_by_class(uint32_t class)
+pci_get_device_by_class(u32_t class)
 {
     struct pci_device *pos, *n;
     llist_for_each(pos, n, &pci_devices, dev_chain)
index d8256f7b721cbee5a2885001e80cf5a9e8780794..6643344f9955019b1b71d1bbf2ea4b8d970954bd 100644 (file)
@@ -1,14 +1,16 @@
 #ifndef __LUNAIX_TSS_H
 #define __LUNAIX_TSS_H
-#include <stdint.h>
+#include <lunaix/types.h>
 
-struct x86_tss {
-    uint32_t link;
-    uint32_t esp0;
+struct x86_tss
+{
+    u32_t link;
+    u32_t esp0;
     uint16_t ss0;
     uint8_t __padding[94];
 } __attribute__((packed));
 
-void tss_update_esp(uint32_t esp0);
+void
+tss_update_esp(u32_t esp0);
+
 #endif /* __LUNAIX_TSS_H */
index 46713b8f54f618fed20db0bed74bed181831dd13..a8d18bf7f86565595b7180a74e305d305aacaad9 100644 (file)
 
 typedef struct
 {
-    uint32_t signature_l;
-    uint32_t signature_h;
+    u32_t signature_l;
+    u32_t signature_h;
     uint8_t chksum;
     char oem_id[6];
     // Revision
     uint8_t rev;
     acpi_rsdt_t* rsdt;
-    uint32_t length;
+    u32_t length;
     acpi_sdthdr_t* xsdt;
     uint8_t x_chksum;
     char reserved[3]; // Reserved field
index e0b99431f584f070a3e1dc7006b76379d91ad9ba..21251e616600d9a6add96b5b7aee8568cfa9b2ab 100644 (file)
@@ -5,7 +5,8 @@
 
 // Pulled from ACPI Specification (v6.4) section 5.2.9
 
-enum PMProfile {
+enum PMProfile
+{
     Desktop = 1,
     Mobile = 2,
     Workstation = 3,
@@ -32,28 +33,29 @@ enum PMProfile {
 #define ITIME_MON_ALARM 1
 #define ITIME_CENTURY 2
 
-#define IAPC_ARCH_LEGACY   0x1
-#define IAPC_ARCH_8042     0x2
-#define IAPC_ARCH_NO_VGA   0x4
-#define IAPC_ARCH_NO_MSI   0x8
-#define IAPC_ARCH_ASPM     0x10
-#define IAPC_ARCH_NO_RTC   0x20
+#define IAPC_ARCH_LEGACY 0x1
+#define IAPC_ARCH_8042 0x2
+#define IAPC_ARCH_NO_VGA 0x4
+#define IAPC_ARCH_NO_MSI 0x8
+#define IAPC_ARCH_ASPM 0x10
+#define IAPC_ARCH_NO_RTC 0x20
 
-typedef struct acpi_fadt {
+typedef struct acpi_fadt
+{
     acpi_sdthdr_t header;
-    uint32_t firmware_controller_addr;
-    uint32_t dsdt_addr;
+    u32_t firmware_controller_addr;
+    u32_t dsdt_addr;
     uint8_t reserved;
     uint8_t pm_profile;
     uint16_t sci_int;
-    uint32_t smi_cmd_port_addr;
+    u32_t smi_cmd_port_addr;
     uint8_t smi_acpi_enable;
     uint8_t smi_acpi_disable;
     uint8_t smi_s4bios_state;
     uint8_t smi_pstate;
-    uint32_t pm_reg_ports[6];
-    uint32_t gpe0_port_addr;
-    uint32_t gpe1_port_addr;
+    u32_t pm_reg_ports[6];
+    u32_t gpe0_port_addr;
+    u32_t gpe1_port_addr;
     uint8_t pm_reg_lens[4];
     uint8_t gpe0_len;
     uint8_t gpe1_len;
index ef03bfd5b013dc74ef97dec0c60e3d394faec940..1dd0bca4015c61c5c7f0774fc25da0a15c4622b0 100644 (file)
@@ -28,7 +28,7 @@ typedef struct
     acpi_ics_hdr_t header;
     uint8_t processor_id;
     uint8_t apic_id;
-    uint32_t flags;
+    u32_t flags;
 } ACPI_TABLE_PACKED acpi_apic_t;
 
 /**
@@ -43,9 +43,10 @@ typedef struct
     acpi_ics_hdr_t header;
     uint8_t ioapic_id;
     uint8_t reserved;
-    uint32_t ioapic_addr;
-    // The global system interrupt offset for this IOAPIC. (Kind of IRQ offset for a slave IOAPIC)
-    uint32_t gis_offset;
+    u32_t ioapic_addr;
+    // The global system interrupt offset for this IOAPIC. (Kind of IRQ offset
+    // for a slave IOAPIC)
+    u32_t gis_offset;
 } ACPI_TABLE_PACKED acpi_ioapic_t;
 
 /**
@@ -65,7 +66,7 @@ typedef struct
     // PIC
     uint8_t source;
     // global system interrupt. The override of source in APIC mode
-    uint32_t gsi;
+    u32_t gsi;
     uint16_t flags;
 } ACPI_TABLE_PACKED acpi_intso_t;
 
@@ -73,7 +74,7 @@ typedef struct
 {
     acpi_sdthdr_t header;
     void* apic_addr;
-    uint32_t flags;
+    u32_t flags;
     // Here is a bunch of packed ICS reside here back-to-back.
 } ACPI_TABLE_PACKED acpi_madt_t;
 
index 0ff86e08a187ef1f400367c438aa5f68bb7b84a3..5a40f26ac171e11aaf755c8c36c8788c616c44b9 100644 (file)
@@ -5,17 +5,17 @@
 
 struct acpi_mcfg_alloc
 {
-    uint32_t base_addr_lo;
-    uint32_t base_addr_hi;
+    u32_t base_addr_lo;
+    u32_t base_addr_hi;
     uint16_t pci_seg_num;
     uint8_t pci_bus_start;
     uint8_t pci_bus_end;
-    uint32_t reserve;
+    u32_t reserve;
 } ACPI_TABLE_PACKED;
 
 struct mcfg_alloc_info
 {
-    uint32_t base_addr;
+    u32_t base_addr;
     uint16_t pci_seg_num;
     uint8_t pci_bus_start;
     uint8_t pci_bus_end;
index fc4a332428e4424da18c4a1088ffc1b9dfaacc1f..e5b1d11d233d7c56d84a713d88c3cfc27a2deb2b 100644 (file)
@@ -1,22 +1,22 @@
 #ifndef __LUNAIX_ACPI_SDT_H
 #define __LUNAIX_ACPI_SDT_H
 
-#include <stdint.h>
+#include <lunaix/types.h>
 
-#define ACPI_TABLE_PACKED   __attribute__((packed))
+#define ACPI_TABLE_PACKED __attribute__((packed))
 
 typedef struct acpi_sdthdr
 {
-    uint32_t signature;
-    uint32_t length;
+    u32_t signature;
+    u32_t length;
     // Revision
     uint8_t rev;
     uint8_t chksum;
     char oem_id[6];
     char oem_table_id[8];
-    uint32_t oem_rev;
-    uint32_t vendor_id;
-    uint32_t vendor_rev;
+    u32_t oem_rev;
+    u32_t vendor_id;
+    u32_t vendor_rev;
 } ACPI_TABLE_PACKED acpi_sdthdr_t;
 
 typedef struct acpi_rsdt
index 9bebe8e3cd81dfab94900ec7e08c02adc0f3a5e9..f6c63922f2d8c43c0dbf62e57d7131af55ebc84c 100644 (file)
@@ -81,18 +81,18 @@ struct hba_cmdh
 {
     uint16_t options;
     uint16_t prdt_len;
-    uint32_t transferred_size;
-    uint32_t cmd_table_base;
-    uint32_t reserved[5];
+    u32_t transferred_size;
+    u32_t cmd_table_base;
+    u32_t reserved[5];
 } __HBA_PACKED__;
 
 #define HBA_PRDTE_BYTE_CNT(cnt) ((cnt & 0x3FFFFF) | 0x1)
 
 struct hba_prdte
 {
-    uint32_t data_base;
-    uint32_t reserved[2];
-    uint32_t byte_count;
+    u32_t data_base;
+    u32_t reserved[2];
+    u32_t byte_count;
 } __HBA_PACKED__;
 
 struct hba_cmdt
@@ -113,9 +113,9 @@ struct hba_device
 {
     char serial_num[20];
     char model[40];
-    uint32_t flags;
+    u32_t flags;
     uint64_t max_lba;
-    uint32_t block_size;
+    u32_t block_size;
     uint64_t wwn;
     uint8_t cbd_size;
     struct
@@ -125,9 +125,9 @@ struct hba_device
         uint8_t status;
         uint8_t reserve;
     } last_result;
-    uint32_t alignment_offset;
-    uint32_t block_per_sec;
-    uint32_t capabilities;
+    u32_t alignment_offset;
+    u32_t block_per_sec;
+    u32_t capabilities;
     struct hba_port* port;
     struct ahci_hba* hba;
 
index e1bbb713e2b99c3ae73050f29679275e73d30187..d6582293470a59015c050912d7c36fdcc605339a 100644 (file)
@@ -21,8 +21,8 @@ struct scsi_cdb12
 {
     uint8_t opcode;
     uint8_t misc1;
-    uint32_t lba_be;
-    uint32_t length;
+    u32_t lba_be;
+    u32_t length;
     uint8_t misc2;
     uint8_t ctrl;
 } __attribute__((packed));
@@ -31,9 +31,9 @@ struct scsi_cdb16
 {
     uint8_t opcode;
     uint8_t misc1;
-    uint32_t lba_be_hi;
-    uint32_t lba_be_lo;
-    uint32_t length;
+    u32_t lba_be_hi;
+    u32_t lba_be_lo;
+    u32_t length;
     uint8_t misc2;
     uint8_t ctrl;
 } __attribute__((packed));
@@ -41,19 +41,19 @@ struct scsi_cdb16
 void
 scsi_create_packet12(struct scsi_cdb12* cdb,
                      uint8_t opcode,
-                     uint32_t lba,
-                     uint32_t alloc_size);
+                     u32_t lba,
+                     u32_t alloc_size);
 
 void
 scsi_create_packet16(struct scsi_cdb16* cdb,
                      uint8_t opcode,
                      uint64_t lba,
-                     uint32_t alloc_size);
+                     u32_t alloc_size);
 
 void
 scsi_submit(struct hba_device* dev, struct blkio_req* io_req);
 
 void
-scsi_parse_capacity(struct hba_device* device, uint32_t* parameter);
+scsi_parse_capacity(struct hba_device* device, u32_t* parameter);
 
 #endif /* __LUNAIX_ATAPI_H */
index 5789d4a41430f955d8c939f4e79d168d445a26cd..ae9926b7c0e6e6bedfd8d497cea59dc9e6c67d63 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_CPU_H
 #define __LUNAIX_CPU_H
 
-#include <stdint.h>
+#include <lunaix/types.h>
 
 #define SEL_RPL(selector) ((selector)&0x3)
 
@@ -124,9 +124,9 @@ cpu_int(int vect)
 }
 
 void
-cpu_rdmsr(uint32_t msr_idx, uint32_t* reg_high, uint32_t* reg_low);
+cpu_rdmsr(u32_t msr_idx, u32_t* reg_high, u32_t* reg_low);
 
 void
-cpu_wrmsr(uint32_t msr_idx, uint32_t reg_high, uint32_t reg_low);
+cpu_wrmsr(u32_t msr_idx, u32_t reg_high, u32_t reg_low);
 
 #endif
\ No newline at end of file
index dd445098bf7240b7c64e623457005e3aa898f6ce..f4f61920f4ad809b8d18821add13a0eff30c9f53 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_IO_H
 #define __LUNAIX_IO_H
 
-#include <stdint.h>
+#include <lunaix/types.h>
 
 static inline uint8_t
 io_inb(int port)
@@ -41,10 +41,10 @@ io_insw(int port, void* addr, int cnt)
                  : "memory", "cc");
 }
 
-static inline uint32_t
+static inline u32_t
 io_inl(int port)
 {
-    uint32_t data;
+    u32_t data;
     asm volatile("inl %w1,%0" : "=a"(data) : "d"(port));
     return data;
 }
@@ -106,19 +106,18 @@ io_outsl(int port, const void* addr, int cnt)
 }
 
 static inline void
-io_outl(int port, uint32_t data)
+io_outl(int port, u32_t data)
 {
     asm volatile("outl %0,%w1" : : "a"(data), "d"(port));
 }
 static inline void
 io_delay(int counter)
 {
-    asm volatile (
-        "   test %0, %0\n"
-        "   jz 1f\n"
-        "2: dec %0\n"
-        "   jnz 2b\n"
-        "1: dec %0"::"a"(counter));
+    asm volatile("   test %0, %0\n"
+                 "   jz 1f\n"
+                 "2: dec %0\n"
+                 "   jnz 2b\n"
+                 "1: dec %0" ::"a"(counter));
 }
 
 #endif /* __LUNAIX_IO_H */
index 76e515269d691c9b3c7403863a1365b5952da7d5..ec749ef3befd357868d2ebb9d72be896cd69524f 100644 (file)
@@ -26,12 +26,12 @@ void
 ioapic_init();
 
 void
-ioapic_write(uint8_t sel, uint32_t val);
+ioapic_write(uint8_t sel, u32_t val);
 
-uint32_t
+u32_t
 ioapic_read(uint8_t sel);
 
 void
-ioapic_redirect(uint8_t irq, uint8_t vector, uint8_t dest, uint32_t flags);
+ioapic_redirect(uint8_t irq, uint8_t vector, uint8_t dest, u32_t flags);
 
 #endif /* __LUNAIX_IOAPIC_H */
index 21952f2c6a828e22bb2f3e5ac819eafeb4f163a7..56ca3df8810bbdd37425dcf92cdda46167c1099b 100644 (file)
@@ -65,18 +65,18 @@ struct pci_driver;
 
 struct pci_base_addr
 {
-    uint32_t start;
-    uint32_t size;
-    uint32_t type;
+    u32_t start;
+    u32_t size;
+    u32_t type;
 };
 
 struct pci_device
 {
     struct llist_header dev_chain;
-    uint32_t device_info;
-    uint32_t class_info;
-    uint32_t cspace_base;
-    uint32_t msi_loc;
+    u32_t device_info;
+    u32_t class_info;
+    u32_t cspace_base;
+    u32_t msi_loc;
     uint16_t intr_info;
     struct
     {
@@ -101,14 +101,14 @@ struct pci_driver
 //      Refer to "PCI Local Bus Specification, Rev.3, Section 3.2.2.3.2"
 
 static inline pci_reg_t
-pci_read_cspace(uint32_t base, int offset)
+pci_read_cspace(u32_t base, int offset)
 {
     io_outl(PCI_CONFIG_ADDR, base | (offset & ~0x3));
     return io_inl(PCI_CONFIG_DATA);
 }
 
 static inline void
-pci_write_cspace(uint32_t base, int offset, pci_reg_t data)
+pci_write_cspace(u32_t base, int offset, pci_reg_t data)
 {
     io_outl(PCI_CONFIG_ADDR, base | (offset & ~0x3));
     io_outl(PCI_CONFIG_DATA, data);
@@ -128,7 +128,7 @@ pci_init();
  *
  * @return struct pci_device*
  */
-struct pci_device* pci_get_device_by_class(uint32_t class);
+struct pci_device* pci_get_device_by_class(u32_t class);
 
 /**
  * @brief 根据设备商ID和设备ID,在拓扑中寻找一个设备
@@ -151,7 +151,7 @@ pci_get_device_by_id(uint16_t vendorId, uint16_t deviceId);
  * @return size_t
  */
 size_t
-pci_bar_sizing(struct pci_device* dev, uint32_t* bar_out, uint32_t bar_num);
+pci_bar_sizing(struct pci_device* dev, u32_t* bar_out, u32_t bar_num);
 
 /**
  * @brief 配置并启用设备MSI支持。
index f98fe28e24200d07e6792749d8ae1ca6f844527d..69df34b8a1233c053b0819db6b3789734e5c8753 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef __LUNAIX_HASH_H
 #define __LUNAIX_HASH_H
 
-#include <stdint.h>
+#include <lunaix/types.h>
 
 #define HASH_SIZE_BITS 32
 
-uint32_t
-strhash_32(const char* str, uint32_t truncate_to);
+u32_t
+strhash_32(const char* str, u32_t truncate_to);
 
 /**
  * @brief Simple generic hash function
@@ -15,10 +15,10 @@ strhash_32(const char* str, uint32_t truncate_to);
  * https://elixir.bootlin.com/linux/v5.18.12/source/include/linux/hash.h#L60
  *
  * @param val
- * @return uint32_t
+ * @return u32_t
  */
-inline uint32_t
-hash_32(const uint32_t val, uint32_t truncate_to)
+inline u32_t
+hash_32(const u32_t val, u32_t truncate_to)
 {
     return (val * 0x61C88647u) >> (HASH_SIZE_BITS - truncate_to);
 }
index c574dd346d32e9d789b3f29680530e1af3e39047..0ddd00058cb585a22fdf6b17095d26582c85b00c 100644 (file)
@@ -44,7 +44,7 @@ struct lpt_header
 } __attribute__((packed));
 
 typedef u64_t partition_t;
-typedef uint32_t bdev_t;
+typedef u32_t bdev_t;
 typedef void (*devfs_exporter)(struct block_dev* bdev, void* fsnode);
 
 void
index 8c9ab15a5eecdcbd28fd01ce3ed2c6428fb8dae5..889490e9af0fb54d14fa5668ca3f422c549931a4 100644 (file)
@@ -3,11 +3,11 @@
 
 #include <lunaix/types.h>
 
-typedef uint32_t time_t;
+typedef u32_t time_t;
 
 typedef struct
 {
-    uint32_t year; // use int32 as we need to store the 4-digit year
+    u32_t year; // use int32 as we need to store the 4-digit year
     uint8_t month;
     uint8_t day;
     uint8_t weekday;
index fd234f0d91a8880bdba11d2c0d582b1bef21b69a..1c2445b04f84930b86f699d34daab3d3964670d0 100644 (file)
@@ -19,7 +19,7 @@ typedef unsigned int dev_t;
 
 struct device
 {
-    uint32_t magic;
+    u32_t magic;
     struct llist_header siblings;
     struct llist_header children;
     struct device* parent;
@@ -32,14 +32,14 @@ struct device
     int (*write)(struct device* dev, void* buf, size_t offset, size_t len);
     int (*read_page)(struct device* dev, void* buf, size_t offset);
     int (*write_page)(struct device* dev, void* buf, size_t offset);
-    int (*exec_cmd)(struct device* dev, uint32_t req, va_list args);
+    int (*exec_cmd)(struct device* dev, u32_t req, va_list args);
 };
 
 struct device*
 device_add(struct device* parent,
            void* underlay,
            char* name_fmt,
-           uint32_t type,
+           u32_t type,
            va_list args);
 
 struct device*
index ad3d04c3917eae9da7c1891ee55417aec2cffa91..c902c4858d016c4e1fe4abee1967de40b4508b8d 100644 (file)
@@ -18,21 +18,21 @@ struct btrie_node
     struct llist_header siblings;
     struct llist_header nodes;
     struct btrie_node* parent;
-    uint32_t index;
+    u32_t index;
     void* data;
 };
 
 void
-btrie_init(struct btrie* btrie, uint32_t trunc_bits);
+btrie_init(struct btrie* btrie, u32_t trunc_bits);
 
 void*
-btrie_get(struct btrie* root, uint32_t index);
+btrie_get(struct btrie* root, u32_t index);
 
 void
-btrie_set(struct btrie* root, uint32_t index, void* data);
+btrie_set(struct btrie* root, u32_t index, void* data);
 
 void*
-btrie_remove(struct btrie* root, uint32_t index);
+btrie_remove(struct btrie* root, u32_t index);
 
 void
 btrie_release(struct btrie* tree);
index 5dab1cbbeb559a9ebb8a6c484e1322ade1a4ded6..d954103ce44f797024133d41f2189e37c97bc4ca 100644 (file)
@@ -7,8 +7,8 @@
 
 struct hstr
 {
-    uint32_t hash;
-    uint32_t len;
+    u32_t hash;
+    u32_t len;
     const char* value;
 };
 
@@ -27,7 +27,7 @@ struct hstr
 #define HSTR_EQ(str1, str2) ((str1)->hash == (str2)->hash)
 
 inline void
-hstr_rehash(struct hstr* hash_str, uint32_t truncate_to)
+hstr_rehash(struct hstr* hash_str, u32_t truncate_to)
 {
     hash_str->hash = strhash_32(hash_str->value, truncate_to);
 }
index 63660c22e72a3aaa9f17c59d03d7273da0dfbdfa..76c959749c69b7675daeebd5c792db8752001084 100644 (file)
@@ -15,7 +15,7 @@ struct lru_zone
 {
     struct llist_header lead_node;
     struct llist_header zones;
-    uint32_t objects;
+    u32_t objects;
     evict_cb try_evict;
 };
 
index 075cc017fe33966b0e5b704d4e8b0116f761fd91..8e6961d6adc7d43ba2d6db97a72211c434a9690b 100644 (file)
@@ -60,7 +60,7 @@
         lru_use_one(dnode_lru, &dnode->lru);                                   \
     })
 
-typedef uint32_t inode_t;
+typedef u32_t inode_t;
 
 struct v_dnode;
 struct v_inode;
@@ -83,7 +83,7 @@ struct filesystem
 {
     struct hlist_node fs_list;
     struct hstr fs_name;
-    uint32_t types;
+    u32_t types;
     int fs_id;
     int (*mount)(struct v_superblock* vsb, struct v_dnode* mount_point);
     int (*unmount)(struct v_superblock* vsb);
@@ -95,13 +95,13 @@ struct v_superblock
     struct device* dev;
     struct v_dnode* root;
     struct filesystem* fs;
-    uint32_t iobuf_size;
+    u32_t iobuf_size;
     struct hbucket* i_cache;
     void* data;
     struct
     {
-        uint32_t (*read_capacity)(struct v_superblock* vsb);
-        uint32_t (*read_usage)(struct v_superblock* vsb);
+        u32_t (*read_capacity)(struct v_superblock* vsb);
+        u32_t (*read_usage)(struct v_superblock* vsb);
         void (*init_inode)(struct v_superblock* vsb, struct v_inode* inode);
     } ops;
 };
@@ -172,7 +172,7 @@ struct v_file
     struct v_inode* inode;
     struct v_dnode* dnode;
     struct llist_header* f_list;
-    uint32_t f_pos;
+    u32_t f_pos;
     atomic_ulong ref_count;
     struct v_file_ops* ops; // for caching
 };
@@ -200,15 +200,15 @@ struct v_inode
 {
     inode_t id;
     mutex_t lock;
-    uint32_t itype;
+    u32_t itype;
     time_t ctime;
     time_t mtime;
     time_t atime;
     lba_t lb_addr;
-    uint32_t open_count;
-    uint32_t link_count;
-    uint32_t lb_usage;
-    uint32_t fsize;
+    u32_t open_count;
+    u32_t link_count;
+    u32_t lb_usage;
+    u32_t fsize;
     void* data; // 允许底层FS绑定他的一些专有数据
     struct llist_header aka_dnodes;
     struct llist_header xattrs;
@@ -229,7 +229,7 @@ struct v_mount
     struct v_mount* parent;
     struct v_dnode* mnt_point;
     struct v_superblock* super_block;
-    uint32_t busy_counter;
+    u32_t busy_counter;
     int flags;
 };
 
@@ -262,8 +262,8 @@ struct pcache
     struct btrie tree;
     struct llist_header pages;
     struct llist_header dirty;
-    uint32_t n_dirty;
-    uint32_t n_pages;
+    u32_t n_dirty;
+    u32_t n_pages;
 };
 
 struct pcache_pg
@@ -273,9 +273,9 @@ struct pcache_pg
     struct lru_node lru;
     struct pcache* holder;
     void* pg;
-    uint32_t flags;
-    uint32_t fpos;
-    uint32_t len;
+    u32_t flags;
+    u32_t fpos;
+    u32_t len;
 };
 
 void
@@ -376,7 +376,7 @@ void
 vfs_d_free(struct v_dnode* dnode);
 
 struct v_inode*
-vfs_i_find(struct v_superblock* sb, uint32_t i_id);
+vfs_i_find(struct v_superblock* sb, u32_t i_id);
 
 void
 vfs_i_addhash(struct v_inode* inode);
@@ -412,22 +412,22 @@ void
 pcache_release_page(struct pcache* pcache, struct pcache_pg* page);
 
 struct pcache_pg*
-pcache_new_page(struct pcache* pcache, uint32_t index);
+pcache_new_page(struct pcache* pcache, u32_t index);
 
 void
 pcache_set_dirty(struct pcache* pcache, struct pcache_pg* pg);
 
 int
 pcache_get_page(struct pcache* pcache,
-                uint32_t index,
-                uint32_t* offset,
+                u32_t index,
+                u32_t* offset,
                 struct pcache_pg** page);
 
 int
-pcache_write(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos);
+pcache_write(struct v_inode* inode, void* data, u32_t len, u32_t fpos);
 
 int
-pcache_read(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos);
+pcache_read(struct v_inode* inode, void* data, u32_t len, u32_t fpos);
 
 void
 pcache_release(struct pcache* pcache);
index a8117ef7cddb61ff4c67b59598c45365ef128691..2ee5390b65cfe240e787fcfc53d22dbee5714797 100644 (file)
@@ -10,7 +10,7 @@ struct twifs_node
     struct hstr name;
     inode_t ino_id;
     void* data;
-    uint32_t itype;
+    u32_t itype;
     char name_val[VFS_NAME_MAXLEN];
     struct llist_header children;
     struct llist_header siblings;
index 872ea04a6ea8e17386581805da3b8e2eade63cb8..76eee9ed33a804690e8338c9f282c88194e6a1dc 100644 (file)
 
 struct input_evt_pkt
 {
-    uint32_t pkt_type;  // packet type
-    uint32_t scan_code; // hardware raw code
-    uint32_t sys_code;  // driver translated code
-    time_t timestamp;   // event timestamp
+    u32_t pkt_type;   // packet type
+    u32_t scan_code;  // hardware raw code
+    u32_t sys_code;   // driver translated code
+    time_t timestamp; // event timestamp
 };
 
 struct input_device
index 0a79cdc07ba75d7a5c4a25c5972905a84481ad6e..346c4794d9ecad2edba4358245d5e9f34cd83bec 100644 (file)
 
 #define PACK(size, flags) (((size) & ~0x3) | (flags))
 
-#define SW(p, w) (*((uint32_t*)(p)) = w)
-#define LW(p) (*((uint32_t*)(p)))
+#define SW(p, w) (*((u32_t*)(p)) = w)
+#define LW(p) (*((u32_t*)(p)))
 
-#define HPTR(bp) ((uint32_t*)(bp)-1)
+#define HPTR(bp) ((u32_t*)(bp)-1)
 #define BPTR(bp) ((uint8_t*)(bp) + WSIZE)
-#define FPTR(hp, size) ((uint32_t*)(hp + size - WSIZE))
+#define FPTR(hp, size) ((u32_t*)(hp + size - WSIZE))
 #define NEXT_CHK(hp) ((uint8_t*)(hp) + CHUNK_S(LW(hp)))
 
 #define BOUNDARY 4
index c3f0d66fa7c3517d6fe45143c74d7d5182103557..710d4a4f08c4458bc781b4dbbf5996ee0e666390 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef __LUNAIX_MMIO_H
 #define __LUNAIX_MMIO_H
 
-#include <stdint.h>
+#include <lunaix/types.h>
 
 void*
-ioremap(uintptr_t paddr, uint32_t size);
+ioremap(uintptr_t paddr, u32_t size);
 
 void*
-iounmap(uintptr_t vaddr, uint32_t size);
+iounmap(uintptr_t vaddr, u32_t size);
 
 #endif /* __LUNAIX_MMIO_H */
index 781a4cee34468291985fbf49cb0f1e876822b33f..f2c45de00bcfd0e81b365759cf5c5e818a81b14a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_PAGE_H
 #define __LUNAIX_PAGE_H
 #include <lunaix/common.h>
-#include <stdint.h>
+#include <lunaix/types.h>
 
 #define PG_MAX_ENTRIES 1024U
 #define PG_LAST_TABLE PG_MAX_ENTRIES - 1
@@ -14,9 +14,9 @@
 
 #define PG_ALIGN(addr) ((uintptr_t)(addr)&0xFFFFF000UL)
 
-#define L1_INDEX(vaddr) (uint32_t)(((uintptr_t)(vaddr)&0xFFC00000UL) >> 22)
-#define L2_INDEX(vaddr) (uint32_t)(((uintptr_t)(vaddr)&0x003FF000UL) >> 12)
-#define PG_OFFSET(vaddr) (uint32_t)((uintptr_t)(vaddr)&0x00000FFFUL)
+#define L1_INDEX(vaddr) (u32_t)(((uintptr_t)(vaddr)&0xFFC00000UL) >> 22)
+#define L2_INDEX(vaddr) (u32_t)(((uintptr_t)(vaddr)&0x003FF000UL) >> 12)
+#define PG_OFFSET(vaddr) (u32_t)((uintptr_t)(vaddr)&0x00000FFFUL)
 
 #define GET_PT_ADDR(pde) PG_ALIGN(pde)
 #define GET_PG_ADDR(pte) PG_ALIGN(pte)
@@ -66,7 +66,7 @@
 typedef unsigned long ptd_t;
 typedef unsigned long pt_t;
 typedef unsigned int pt_attr;
-typedef uint32_t x86_pte_t;
+typedef u32_t x86_pte_t;
 
 /**
  * @brief 虚拟映射属性
@@ -77,7 +77,7 @@ typedef struct
     // 虚拟页地址
     uintptr_t va;
     // 物理页码(如果不存在映射,则为0)
-    uint32_t pn;
+    u32_t pn;
     // 物理页地址(如果不存在映射,则为0)
     uintptr_t pa;
     // 映射的flags
index 44aa99d7b0f2e8120b970ecc1343aedd45031320..54365605a3d6cea18aed6f0c97793258e0fe9e90 100644 (file)
  */
 #define PP_FGLOCKED 0x2
 
-typedef uint32_t pp_attr_t;
+typedef u32_t pp_attr_t;
 
 struct pp_struct
 {
     pid_t owner;
-    uint32_t ref_counts;
+    u32_t ref_counts;
     pp_attr_t attr;
 };
 
@@ -63,7 +63,7 @@ pmm_mark_chunk_free(uintptr_t start_ppn, size_t page_count);
  */
 void
 pmm_mark_chunk_occupied(pid_t owner,
-                        uintptr_t start_ppn,
+                        u32_t start_ppn,
                         size_t page_count,
                         pp_attr_t attr);
 
index b499f3fb70402dcd75af5e419a2897b440f885f9..cdf9ef477846bb31541e897c79eb6cfa3d57261d 100644 (file)
@@ -8,7 +8,7 @@
 
 #define TIMER_MODE_PERIODIC 0x1
 
-typedef uint32_t ticks_t;
+typedef u32_t ticks_t;
 
 struct lx_timer_context
 {
@@ -22,7 +22,7 @@ struct lx_timer_context
      * @brief Desired system running frequency
      *
      */
-    uint32_t running_frequency;
+    u32_t running_frequency;
     /**
      * @brief Ticks per hertz
      *
@@ -46,16 +46,16 @@ struct lx_timer
  * @param frequency The frequency that timer should run in Hz.
  */
 void
-timer_init(uint32_t frequency);
+timer_init(u32_t frequency);
 
 struct lx_timer*
-timer_run_second(uint32_t second,
+timer_run_second(u32_t second,
                  void (*callback)(void*),
                  void* payload,
                  uint8_t flags);
 
 struct lx_timer*
-timer_run_ms(uint32_t millisecond,
+timer_run_ms(u32_t millisecond,
              void (*callback)(void*),
              void* payload,
              uint8_t flags);
index 1bd1c0028a77679cbfe7a439584c3b83d7682659..4c4dd54b330c61355260514cd42e445f3a367c33 100644 (file)
@@ -1,14 +1,17 @@
 #include <arch/x86/gdt.h>
 #include <arch/x86/tss.h>
-#include <stdint.h>
+#include <lunaix/types.h>
 
 #define GDT_ENTRY 6
 
 uint64_t _gdt[GDT_ENTRY];
 uint16_t _gdt_limit = sizeof(_gdt) - 1;
 
-void _set_gdt_entry(uint32_t index, uint32_t base, uint32_t limit, uint32_t flags) {
-    _gdt[index] = SEG_BASE_H(base) | flags | SEG_LIM_H(limit) | SEG_BASE_M(base);
+void
+_set_gdt_entry(u32_t index, u32_t base, u32_t limit, u32_t flags)
+{
+    _gdt[index] =
+      SEG_BASE_H(base) | flags | SEG_LIM_H(limit) | SEG_BASE_M(base);
     _gdt[index] <<= 32;
     _gdt[index] |= SEG_BASE_L(base) | SEG_LIM_L(limit);
 }
@@ -16,7 +19,8 @@ void _set_gdt_entry(uint32_t index, uint32_t base, uint32_t limit, uint32_t flag
 extern struct x86_tss _tss;
 
 void
-_init_gdt() {
+_init_gdt()
+{
     _set_gdt_entry(0, 0, 0, 0);
     _set_gdt_entry(1, 0, 0xfffff, SEG_R0_CODE);
     _set_gdt_entry(2, 0, 0xfffff, SEG_R0_DATA);
index 285356f8aa9753aa84daaf258bffb53acf9c972f..97903cffebfdc5c1e3e145485e71825605527e90 100644 (file)
@@ -17,7 +17,7 @@ LOG_MODULE("INTR")
 extern void
 intr_routine_page_fault(const isr_param* param);
 
-extern uint32_t debug_resv;
+extern u32_t debug_resv;
 
 void
 __print_panic_msg(const char* msg, const isr_param* param)
@@ -79,7 +79,7 @@ intr_routine_apic_spi(const isr_param* param)
 void
 intr_routine_apic_error(const isr_param* param)
 {
-    uint32_t error_reg = apic_read_reg(APIC_ESR);
+    u32_t error_reg = apic_read_reg(APIC_ESR);
     char buf[32];
     ksprintf(buf, "APIC error, ESR=0x%x", error_reg);
     console_flush();
index 8aa0a72a343de67a06ef9352647f50eed418b54f..1ae386069a6b5ce48d5b2c09d4aaa95be9c107c1 100644 (file)
@@ -1,14 +1,14 @@
 
 #include <arch/x86/idt.h>
-#include <stdint.h>
 #include <arch/x86/intrhnds.h>
+#include <lunaix/types.h>
 
 #define IDT_ENTRY 256
 
 uint64_t _idt[IDT_ENTRY];
 uint16_t _idt_limit = sizeof(_idt) - 1;
 static inline void
-_set_idt_entry(uint32_t vector,
+_set_idt_entry(u32_t vector,
                uint16_t seg_selector,
                void (*isr)(),
                uint8_t dpl,
@@ -20,7 +20,9 @@ _set_idt_entry(uint32_t vector,
     _idt[vector] |= (seg_selector << 16) | (offset & 0x0000ffff);
 }
 
-void _init_idt() {
+void
+_init_idt()
+{
     _set_idt_entry(0, 8, _asm_isr0, 0, IDT_INTERRUPT);
     _set_idt_entry(1, 8, _asm_isr1, 0, IDT_INTERRUPT);
     _set_idt_entry(2, 8, _asm_isr2, 0, IDT_INTERRUPT);
index c871613d6e145f57eb70b6aa889425cbc07cad6c..45c01ee21939ab76198649b667d97077583bc7d3 100644 (file)
@@ -6,7 +6,7 @@ volatile struct x86_tss _tss = { .link = 0,
                                  .ss0 = KDATA_SEG };
 
 void
-tss_update_esp(uint32_t esp0)
+tss_update_esp(u32_t esp0)
 {
     _tss.esp0 = esp0;
 }
\ No newline at end of file
index 6b901a6593958ac2a38fd4ea35009fd62d67c141..b784fdbf4c3649bfcf49d99781dfa139da9a2846 100644 (file)
@@ -15,7 +15,7 @@ struct device*
 device_add(struct device* parent,
            void* underlay,
            char* name_fmt,
-           uint32_t type,
+           u32_t type,
            va_list args)
 {
     struct device* dev = vzalloc(sizeof(struct device));
index 8a4380e4c19da2320979f8462a71c5ee367c9b1b..5ce7687da18247862821ce0166b7d9521e3f5215 100644 (file)
 #define BTRIE_INSERT 1
 
 struct btrie_node*
-__btrie_traversal(struct btrie* root, uint32_t index, int options)
+__btrie_traversal(struct btrie* root, u32_t index, int options)
 {
     index = index >> root->truncated;
-    uint32_t lz = index ? ROUNDDOWN(31 - __builtin_clz(index), BTRIE_BITS) : 0;
-    uint32_t bitmask = ((1 << BTRIE_BITS) - 1) << lz;
-    uint32_t i = 0;
+    u32_t lz = index ? ROUNDDOWN(31 - __builtin_clz(index), BTRIE_BITS) : 0;
+    u32_t bitmask = ((1 << BTRIE_BITS) - 1) << lz;
+    u32_t i = 0;
     struct btrie_node* tree = root->btrie_root;
 
     // Time complexity: O(log_2(log_2(N))) where N is the index to lookup
@@ -57,7 +57,7 @@ __btrie_traversal(struct btrie* root, uint32_t index, int options)
 }
 
 void
-btrie_init(struct btrie* btrie, uint32_t trunc_bits)
+btrie_init(struct btrie* btrie, u32_t trunc_bits)
 {
     btrie->btrie_root = vzalloc(sizeof(struct btrie_node));
     llist_init_head(&btrie->btrie_root->nodes);
@@ -66,7 +66,7 @@ btrie_init(struct btrie* btrie, uint32_t trunc_bits)
 }
 
 void*
-btrie_get(struct btrie* root, uint32_t index)
+btrie_get(struct btrie* root, u32_t index)
 {
     struct btrie_node* node = __btrie_traversal(root, index, 0);
     if (!node) {
@@ -76,7 +76,7 @@ btrie_get(struct btrie* root, uint32_t index)
 }
 
 void
-btrie_set(struct btrie* root, uint32_t index, void* data)
+btrie_set(struct btrie* root, u32_t index, void* data)
 {
     struct btrie_node* node = __btrie_traversal(root, index, BTRIE_INSERT);
     node->data = data;
@@ -98,7 +98,7 @@ __btrie_rm_recursive(struct btrie_node* node)
 }
 
 void*
-btrie_remove(struct btrie* root, uint32_t index)
+btrie_remove(struct btrie* root, u32_t index)
 {
     struct btrie_node* node = __btrie_traversal(root, index, 0);
     if (!node) {
index 51679ca0757913cbcecd6995eb73109e67c431fc..5d7fdc957d4b842c573a3068d435ad32e76af082 100644 (file)
@@ -11,7 +11,7 @@ struct cake_pile* drec_cache_pile;
 extern void
 iso9660_init_inode(struct v_superblock* vsb, struct v_inode* inode);
 
-uint32_t
+u32_t
 iso9660_rd_capacity(struct v_superblock* vsb)
 {
     struct iso_superblock* isovsb = (struct iso_superblock*)vsb->data;
index a6c4c31d34993b9ba9b8da91a195f51b886ad655..0f30891669108f1a13d9eb544ce1b4910e1b0f02 100644 (file)
@@ -41,7 +41,7 @@ pcache_release_page(struct pcache* pcache, struct pcache_pg* page)
 }
 
 struct pcache_pg*
-pcache_new_page(struct pcache* pcache, uint32_t index)
+pcache_new_page(struct pcache* pcache, u32_t index)
 {
     struct pcache_pg* ppg = vzalloc(sizeof(struct pcache_pg));
     void* pg = valloc(PG_SIZE);
@@ -78,8 +78,8 @@ pcache_set_dirty(struct pcache* pcache, struct pcache_pg* pg)
 
 int
 pcache_get_page(struct pcache* pcache,
-                uint32_t index,
-                uint32_t* offset,
+                u32_t index,
+                u32_t* offset,
                 struct pcache_pg** page)
 {
     struct pcache_pg* pg = btrie_get(&pcache->tree, index);
@@ -98,9 +98,9 @@ pcache_get_page(struct pcache* pcache,
 }
 
 int
-pcache_write(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
+pcache_write(struct v_inode* inode, void* data, u32_t len, u32_t fpos)
 {
-    uint32_t pg_off, buf_off = 0;
+    u32_t pg_off, buf_off = 0;
     struct pcache* pcache = inode->pg_cache;
     struct pcache_pg* pg;
 
@@ -110,7 +110,7 @@ pcache_write(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
             return ENOMEM;
         }
 
-        uint32_t wr_bytes = MIN(PG_SIZE - pg_off, len - buf_off);
+        u32_t wr_bytes = MIN(PG_SIZE - pg_off, len - buf_off);
         memcpy(pg->pg + pg_off, (data + buf_off), wr_bytes);
 
         pcache_set_dirty(pcache, pg);
@@ -124,9 +124,9 @@ pcache_write(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
 }
 
 int
-pcache_read(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
+pcache_read(struct v_inode* inode, void* data, u32_t len, u32_t fpos)
 {
-    uint32_t pg_off, buf_off = 0, new_pg = 0;
+    u32_t pg_off, buf_off = 0, new_pg = 0;
     int errno = 0;
     struct pcache* pcache = inode->pg_cache;
     struct pcache_pg* pg;
@@ -149,7 +149,7 @@ pcache_read(struct v_inode* inode, void* data, uint32_t len, uint32_t fpos)
             }
             pg->len = errno;
         }
-        uint32_t rd_bytes = MIN(pg->len - pg_off, len - buf_off);
+        u32_t rd_bytes = MIN(pg->len - pg_off, len - buf_off);
 
         if (!rd_bytes)
             break;
index fcadafdef4b47d270739f2113f9d0195ef58df72..ca19c9dac145700ee82dbe9454a2a417469eb8ad 100644 (file)
@@ -22,7 +22,7 @@ static struct twifs_node* fs_root;
 
 static struct cake_pile* twi_pile;
 
-static volatile uint32_t inode_id = 0;
+static volatile u32_t inode_id = 0;
 
 extern const struct v_file_ops twifs_file_ops;
 extern const struct v_inode_ops twifs_inode_ops;
@@ -31,7 +31,7 @@ struct twifs_node*
 __twifs_new_node(struct twifs_node* parent,
                  const char* name,
                  int name_len,
-                 uint32_t itype)
+                 u32_t itype)
 {
     struct twifs_node* node = cake_grab(twi_pile);
     memset(node, 0, sizeof(*node));
index f5b650653cf20e57bac2b41b95e85093b565014b..cc751b60e3537990f20c12358fd2123917dbd21b 100644 (file)
@@ -109,13 +109,13 @@ vfs_init()
 }
 
 inline struct hbucket*
-__dcache_hash(struct v_dnode* parent, uint32_t* hash)
+__dcache_hash(struct v_dnode* parent, u32_t* hash)
 {
-    uint32_t _hash = *hash;
+    u32_t _hash = *hash;
     // 确保低位更加随机
     _hash = _hash ^ (_hash >> VFS_HASHBITS);
     // 与parent的指针值做加法,来减小碰撞的可能性。
-    _hash += (uint32_t)parent;
+    _hash += (u32_t)parent;
     *hash = _hash;
     return &dnode_cache[_hash & VFS_HASH_MASK];
 }
@@ -130,7 +130,7 @@ vfs_dcache_lookup(struct v_dnode* parent, struct hstr* str)
         return parent->parent;
     }
 
-    uint32_t hash = str->hash;
+    u32_t hash = str->hash;
     struct hbucket* slot = __dcache_hash(parent, &hash);
 
     struct v_dnode *pos, *n;
@@ -439,7 +439,7 @@ vfs_d_free(struct v_dnode* dnode)
 }
 
 struct v_inode*
-vfs_i_find(struct v_superblock* sb, uint32_t i_id)
+vfs_i_find(struct v_superblock* sb, u32_t i_id)
 {
     struct hbucket* slot = &sb->i_cache[i_id & VFS_HASH_MASK];
     struct v_inode *pos, *n;
index aec1001a6cf3bde3e7974aeb109bf4ce4bfaf62e..0ce97e9a51ea47725eb6b86aa3636f5ff43f23bc 100644 (file)
 //     mutex_lock(&kheap.lock);
 
 //     uint8_t* chunk_ptr = (uint8_t*)ptr - WSIZE;
-//     uint32_t hdr = LW(chunk_ptr);
+//     u32_t hdr = LW(chunk_ptr);
 //     size_t sz = CHUNK_S(hdr);
 //     uint8_t* next_hdr = chunk_ptr + sz;
 
 //     //  and space for header
 //     size = ROUNDUP(size + WSIZE, BOUNDARY);
 //     while (ptr < (uint8_t*)heap->brk) {
-//         uint32_t header = *((uint32_t*)ptr);
+//         u32_t header = *((u32_t*)ptr);
 //         size_t chunk_size = CHUNK_S(header);
 //         if (!chunk_size && CHUNK_A(header)) {
 //             break;
 // void
 // place_chunk(uint8_t* ptr, size_t size)
 // {
-//     uint32_t header = *((uint32_t*)ptr);
+//     u32_t header = *((u32_t*)ptr);
 //     size_t chunk_size = CHUNK_S(header);
-//     *((uint32_t*)ptr) = PACK(size, CHUNK_PF(header) | M_ALLOCATED);
+//     *((u32_t*)ptr) = PACK(size, CHUNK_PF(header) | M_ALLOCATED);
 //     uint8_t* n_hdrptr = (uint8_t*)(ptr + size);
-//     uint32_t diff = chunk_size - size;
+//     u32_t diff = chunk_size - size;
 
 //     if (!diff) {
 //         // if the current free block is fully occupied
-//         uint32_t n_hdr = LW(n_hdrptr);
+//         u32_t n_hdr = LW(n_hdrptr);
 //         // notify the next block about our avaliability
 //         SW(n_hdrptr, n_hdr & ~0x2);
 //     } else {
 //         // if there is remaining free space left
-//         uint32_t remainder_hdr = PACK(diff, M_NOT_ALLOCATED |
+//         u32_t remainder_hdr = PACK(diff, M_NOT_ALLOCATED |
 //         M_PREV_ALLOCATED); SW(n_hdrptr, remainder_hdr); SW(FPTR(n_hdrptr,
 //         diff), remainder_hdr);
 
 // void*
 // coalesce(uint8_t* chunk_ptr)
 // {
-//     uint32_t hdr = LW(chunk_ptr);
-//     uint32_t pf = CHUNK_PF(hdr);
-//     uint32_t sz = CHUNK_S(hdr);
+//     u32_t hdr = LW(chunk_ptr);
+//     u32_t pf = CHUNK_PF(hdr);
+//     u32_t sz = CHUNK_S(hdr);
 
-//     uint32_t n_hdr = LW(chunk_ptr + sz);
+//     u32_t n_hdr = LW(chunk_ptr + sz);
 
 //     if (CHUNK_A(n_hdr) && pf) {
 //         // case 1: prev is free
-//         uint32_t prev_ftr = LW(chunk_ptr - WSIZE);
+//         u32_t prev_ftr = LW(chunk_ptr - WSIZE);
 //         size_t prev_chunk_sz = CHUNK_S(prev_ftr);
-//         uint32_t new_hdr = PACK(prev_chunk_sz + sz, CHUNK_PF(prev_ftr));
+//         u32_t new_hdr = PACK(prev_chunk_sz + sz, CHUNK_PF(prev_ftr));
 //         SW(chunk_ptr - prev_chunk_sz, new_hdr);
 //         SW(FPTR(chunk_ptr, sz), new_hdr);
 //         chunk_ptr -= prev_chunk_sz;
 //     } else if (!CHUNK_A(n_hdr) && !pf) {
 //         // case 2: next is free
 //         size_t next_chunk_sz = CHUNK_S(n_hdr);
-//         uint32_t new_hdr = PACK(next_chunk_sz + sz, pf);
+//         u32_t new_hdr = PACK(next_chunk_sz + sz, pf);
 //         SW(chunk_ptr, new_hdr);
 //         SW(FPTR(chunk_ptr, sz + next_chunk_sz), new_hdr);
 //     } else if (!CHUNK_A(n_hdr) && pf) {
 //         // case 3: both free
-//         uint32_t prev_ftr = LW(chunk_ptr - WSIZE);
+//         u32_t prev_ftr = LW(chunk_ptr - WSIZE);
 //         size_t next_chunk_sz = CHUNK_S(n_hdr);
 //         size_t prev_chunk_sz = CHUNK_S(prev_ftr);
-//         uint32_t new_hdr =
+//         u32_t new_hdr =
 //           PACK(next_chunk_sz + prev_chunk_sz + sz, CHUNK_PF(prev_ftr));
 //         SW(chunk_ptr - prev_chunk_sz, new_hdr);
 //         SW(FPTR(chunk_ptr, sz + next_chunk_sz), new_hdr);
 //     // minus the overhead for epilogue, keep the invariant.
 //     heap->brk -= WSIZE;
 
-//     uint32_t old_marker = *((uint32_t*)start);
-//     uint32_t free_hdr = PACK(sz, CHUNK_PF(old_marker));
+//     u32_t old_marker = *((u32_t*)start);
+//     u32_t free_hdr = PACK(sz, CHUNK_PF(old_marker));
 //     SW(start, free_hdr);
 //     SW(FPTR(start, sz), free_hdr);
 //     SW(NEXT_CHK(start), PACK(0, M_ALLOCATED | M_PREV_FREE));
index a52dc1bf93251138ccde1670aad6058765dd5d54..99e8fb8e36298d3b45c394e2eb3a5246377a7c4b 100644 (file)
@@ -4,7 +4,7 @@
 #include <lunaix/spike.h>
 
 void*
-ioremap(uintptr_t paddr, uint32_t size)
+ioremap(uintptr_t paddr, u32_t size)
 {
     void* ptr = vmm_vmap(paddr, size, PG_PREM_RW | PG_DISABLE_CACHE);
     if (ptr) {
@@ -17,7 +17,7 @@ ioremap(uintptr_t paddr, uint32_t size)
 }
 
 void*
-iounmap(uintptr_t vaddr, uint32_t size)
+iounmap(uintptr_t vaddr, u32_t size)
 {
     for (size_t i = 0; i < size; i += PG_SIZE) {
         uintptr_t paddr = vmm_del_mapping(PD_REFERENCED, vaddr + i);
index 91f5460ab175680273ccb5e8082ce979dcc09188..3ebe22a10d34fdcec5446283534a1e10e4ca0051 100644 (file)
@@ -30,7 +30,7 @@ pmm_mark_chunk_free(uintptr_t start_ppn, size_t page_count)
 
 void
 pmm_mark_chunk_occupied(pid_t owner,
-                        uint32_t start_ppn,
+                        u32_t start_ppn,
                         size_t page_count,
                         pp_attr_t attr)
 {
@@ -140,7 +140,7 @@ pmm_ref_page(pid_t owner, void* page)
 {
     (void*)owner; // TODO: do smth with owner
 
-    uint32_t ppn = (uintptr_t)page >> 12;
+    u32_t ppn = (uintptr_t)page >> 12;
 
     if (ppn >= PM_BMP_MAX_SIZE) {
         return 0;
@@ -158,7 +158,7 @@ pmm_ref_page(pid_t owner, void* page)
 struct pp_struct*
 pmm_query(void* pa)
 {
-    uint32_t ppn = (uintptr_t)pa >> 12;
+    u32_t ppn = (uintptr_t)pa >> 12;
 
     if (ppn >= PM_BMP_MAX_SIZE) {
         return NULL;
index 3b28bd980eefb5bdb54d6439871c8c964d3ad75a..445071c39483a7a94a211be9600a345f1ebdc281 100644 (file)
@@ -85,8 +85,8 @@ vmm_del_mapping(uintptr_t mnt, uintptr_t va)
 {
     assert(((uintptr_t)va & 0xFFFU) == 0);
 
-    uint32_t l1_index = L1_INDEX(va);
-    uint32_t l2_index = L2_INDEX(va);
+    u32_t l1_index = L1_INDEX(va);
+    u32_t l2_index = L2_INDEX(va);
 
     // prevent unmap of recursive mapping region
     if (l1_index == 1023) {
@@ -113,8 +113,8 @@ vmm_del_mapping(uintptr_t mnt, uintptr_t va)
 int
 vmm_lookup(uintptr_t va, v_mapping* mapping)
 {
-    uint32_t l1_index = L1_INDEX(va);
-    uint32_t l2_index = L2_INDEX(va);
+    u32_t l1_index = L1_INDEX(va);
+    u32_t l2_index = L2_INDEX(va);
 
     x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
     x86_pte_t l1pte = l1pt->entry[l1_index];
@@ -137,8 +137,8 @@ vmm_lookup(uintptr_t va, v_mapping* mapping)
 void*
 vmm_v2p(void* va)
 {
-    uint32_t l1_index = L1_INDEX(va);
-    uint32_t l2_index = L2_INDEX(va);
+    u32_t l1_index = L1_INDEX(va);
+    u32_t l2_index = L2_INDEX(va);
 
     x86_page_table* l1pt = (x86_page_table*)L1_BASE_VADDR;
     x86_pte_t l1pte = l1pt->entry[l1_index];
index 989256feb9052bc980c349aa8149ef6f42d3e348..d99aac49dafc211f8fb9bf9fd2465e4bc1a0c1eb 100644 (file)
@@ -40,11 +40,11 @@ static volatile struct lx_timer_context* timer_ctx = NULL;
 
 // Don't optimize them! Took me an half hour to figure that out...
 
-static volatile uint32_t rtc_counter = 0;
+static volatile u32_t rtc_counter = 0;
 static volatile uint8_t apic_timer_done = 0;
 
-static volatile uint32_t sched_ticks = 0;
-static volatile uint32_t sched_ticks_counter = 0;
+static volatile u32_t sched_ticks = 0;
+static volatile u32_t sched_ticks_counter = 0;
 
 static struct cake_pile* timer_pile;
 
@@ -64,7 +64,7 @@ timer_init_context()
 }
 
 void
-timer_init(uint32_t frequency)
+timer_init(u32_t frequency)
 {
     timer_init_context();
 
@@ -79,8 +79,8 @@ timer_init(uint32_t frequency)
     //       mapping config.
 
     // grab ourselves these irq numbers
-    uint32_t iv_rtc = isrm_bindirq(PC_AT_IRQ_RTC, temp_intr_routine_rtc_tick);
-    uint32_t iv_timer = isrm_ivexalloc(temp_intr_routine_apic_timer);
+    u32_t iv_rtc = isrm_bindirq(PC_AT_IRQ_RTC, temp_intr_routine_rtc_tick);
+    u32_t iv_timer = isrm_ivexalloc(temp_intr_routine_apic_timer);
 
     // Setup a one-shot timer, we will use this to measure the bus speed. So we
     // can then calibrate apic timer to work at *nearly* accurate hz
@@ -154,7 +154,7 @@ timer_init(uint32_t frequency)
 }
 
 struct lx_timer*
-timer_run_second(uint32_t second,
+timer_run_second(u32_t second,
                  void (*callback)(void*),
                  void* payload,
                  uint8_t flags)
@@ -164,7 +164,7 @@ timer_run_second(uint32_t second,
 }
 
 struct lx_timer*
-timer_run_ms(uint32_t millisecond,
+timer_run_ms(u32_t millisecond,
              void (*callback)(void*),
              void* payload,
              uint8_t flags)
index 80a7be6de25fd2b3140a54ff95da5eba0295f0d4..21802bed7a66f84bc2234f1bd4ff131d38163015 100644 (file)
@@ -39,8 +39,8 @@ print_control_code(const char cntrl)
 int
 __lxconsole_listener(struct input_device* dev)
 {
-    uint32_t key = dev->current_pkt.sys_code;
-    uint32_t type = dev->current_pkt.pkt_type;
+    u32_t key = dev->current_pkt.sys_code;
+    u32_t type = dev->current_pkt.pkt_type;
     kbd_kstate_t state = key >> 16;
     ttychr = key & 0xff;
     key = key & 0xffff;
@@ -86,7 +86,7 @@ done:
 }
 
 int
-__tty_exec_cmd(struct device* dev, uint32_t req, va_list args)
+__tty_exec_cmd(struct device* dev, u32_t req, va_list args)
 {
     switch (req) {
         case TIOCGPGRP:
index b8631b6482c935cf313702746ac045033caa87a3..399b28df6f3f23d474337709aa8ba0966ad31ac4 100644 (file)
@@ -113,7 +113,7 @@ tty_set_cursor(uint8_t x, uint8_t y)
     if (x >= TTY_WIDTH || y >= TTY_HEIGHT) {
         x = y = 0;
     }
-    uint32_t pos = y * TTY_WIDTH + x;
+    u32_t pos = y * TTY_WIDTH + x;
     io_outb(0x3D4, 14);
     io_outb(0x3D5, pos / 256);
     io_outb(0x3D4, 15);
index dc1b3ccb1c1af2f9e537457a6fc8b01637b472c5..41fa4b19dd9726610cc255927d3f8c673fcabf69 100644 (file)
@@ -8,13 +8,13 @@
  * @param str
  * @return unsigned int
  */
-uint32_t
-strhash_32(const char* str, uint32_t truncate_to)
+u32_t
+strhash_32(const char* str, u32_t truncate_to)
 {
     if (!str)
         return 0;
 
-    uint32_t hash = 5381;
+    u32_t hash = 5381;
     int c;
 
     while ((c = *str++))
index 2497e107b7821eba1ebe3eb7f09d49a2d3ce8b10..78c510a214761c8ab554a3c3066bd2ceb90196e9 100644 (file)
@@ -2,7 +2,7 @@
 #include <klibc/stdio.h>
 #include <klibc/stdlib.h>
 #include <klibc/string.h>
-#include <stdint.h>
+#include <lunaix/types.h>
 
 #define NUMBUFSIZ 24
 
@@ -26,7 +26,7 @@ __ksprintf_internal(char* buffer, char* fmt, size_t max_len, va_list vargs)
     //      Of course, with some modifications for porting to LunaixOS :)
 
     char numbuf[NUMBUFSIZ];
-    uint32_t ptr = 0;
+    u32_t ptr = 0;
     for (; *fmt; ++fmt) {
         if (max_len && ptr >= max_len - 1) {
             break;
index a9af92ce486ddf54337bccfd33978dbf0a9f6bd9..7876ab1944f90f524c9d26c652046212d4afeb4c 100644 (file)
@@ -90,7 +90,7 @@ def export_c(src: Path):
 uint64_t _idt[IDT_ENTRY];
 uint16_t _idt_limit = sizeof(_idt) - 1;
 static inline void
-_set_idt_entry(uint32_t vector,
+_set_idt_entry(u32_t vector,
                uint16_t seg_selector,
                void (*isr)(),
                uint8_t dpl,