From 57451946d9d33ffad676de53e81b1b71d85f9db6 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 10 Aug 2024 21:20:34 +0300 Subject: [PATCH] prepare for `const (` deprecation in https://github.com/vlang/v/pull/22019 --- kernel/modules/block/partition/partition.v | 4 +- kernel/modules/dev/ahci/ahci.v | 42 ++-- kernel/modules/dev/console/console.v | 32 ++- kernel/modules/dev/nvme/nvme.v | 38 ++- kernel/modules/elf/elf.v | 40 ++- kernel/modules/errno/errno.v | 270 ++++++++++----------- kernel/modules/file/file.v | 46 ++-- kernel/modules/fs/vfs.v | 20 +- kernel/modules/initramfs/initramfs.v | 2 +- kernel/modules/limine/limine.v | 14 +- kernel/modules/memory/mmap/mmap.v | 20 +- kernel/modules/memory/virtual.v | 12 +- kernel/modules/resource/resource.v | 46 ++-- kernel/modules/socket/public/public.v | 20 +- kernel/modules/stat/stat.v | 40 ++- kernel/modules/term/term.v | 2 +- kernel/modules/time/pit.v | 4 +- kernel/modules/time/time.v | 8 +- kernel/modules/x86/apic/apic.v | 18 +- 19 files changed, 316 insertions(+), 362 deletions(-) diff --git a/kernel/modules/block/partition/partition.v b/kernel/modules/block/partition/partition.v index 4152c710f..af977c954 100644 --- a/kernel/modules/block/partition/partition.v +++ b/kernel/modules/block/partition/partition.v @@ -12,9 +12,7 @@ import resource import lib import fs -const ( - gpt_signature = u64(0x5452415020494645) -) +const gpt_signature = u64(0x5452415020494645) struct Partition { pub mut: diff --git a/kernel/modules/dev/ahci/ahci.v b/kernel/modules/dev/ahci/ahci.v index 6ff2a3a8f..4269c61f8 100644 --- a/kernel/modules/dev/ahci/ahci.v +++ b/kernel/modules/dev/ahci/ahci.v @@ -16,28 +16,26 @@ import fs import katomic import time.sys -const ( - ahci_class = 0x1 - ahci_subclass = 0x6 - ahci_progif = 0x1 - sata_ata = 0x101 - sata_atapi = u32(0xeb140101) - sata_semb = u32(0xc33C0101) - sata_pm = u32(0x96690101) - hba_cmd_st = 0x1 - hba_cmd_fre = 0x10 - hba_cmd_fr = 0x4000 - hba_cmd_cr = 0x8000 - fis_reg_h2d = 0x27 - fis_reg_d2h = 0x34 - fis_dma_enable = 0x39 - fis_dma_setup = 0x41 - fis_data = 0x46 - fis_bist = 0x58 - fis_pio_setup = 0x5f - fis_device_bits = 0xa1 - sector_size = 0x200 -) +const ahci_class = 0x1 +const ahci_subclass = 0x6 +const ahci_progif = 0x1 +const sata_ata = 0x101 +const sata_atapi = u32(0xeb140101) +const sata_semb = u32(0xc33C0101) +const sata_pm = u32(0x96690101) +const hba_cmd_st = 0x1 +const hba_cmd_fre = 0x10 +const hba_cmd_fr = 0x4000 +const hba_cmd_cr = 0x8000 +const fis_reg_h2d = 0x27 +const fis_reg_d2h = 0x34 +const fis_dma_enable = 0x39 +const fis_dma_setup = 0x41 +const fis_data = 0x46 +const fis_bist = 0x58 +const fis_pio_setup = 0x5f +const fis_device_bits = 0xa1 +const sector_size = 0x200 @[packed] struct AHCIRegisters { diff --git a/kernel/modules/dev/console/console.v b/kernel/modules/dev/console/console.v index e4ababe00..2c4a304de 100644 --- a/kernel/modules/dev/console/console.v +++ b/kernel/modules/dev/console/console.v @@ -21,23 +21,21 @@ import file import userland import proc import katomic -import flanterm - -const ( - max_scancode = 0x57 - capslock = 0x3a - numlock = 0x45 - left_alt = 0x38 - left_alt_rel = 0xb8 - right_shift = 0x36 - left_shift = 0x2a - right_shift_rel = 0xb6 - left_shift_rel = 0xaa - ctrl = 0x1d - ctrl_rel = 0x9d - console_buffer_size = 1024 - console_bigbuf_size = 4096 -) +import flanterm as _ + +const max_scancode = 0x57 +const capslock = 0x3a +const numlock = 0x45 +const left_alt = 0x38 +const left_alt_rel = 0xb8 +const right_shift = 0x36 +const left_shift = 0x2a +const right_shift_rel = 0xb6 +const left_shift_rel = 0xaa +const ctrl = 0x1d +const ctrl_rel = 0x9d +const console_buffer_size = 1024 +const console_bigbuf_size = 4096 __global ( console_convtab_numpad_numlock map[u8]u8 diff --git a/kernel/modules/dev/nvme/nvme.v b/kernel/modules/dev/nvme/nvme.v index c8469cb94..6a2b4fdad 100644 --- a/kernel/modules/dev/nvme/nvme.v +++ b/kernel/modules/dev/nvme/nvme.v @@ -19,28 +19,22 @@ import block.partition import fs import katomic -const ( - nvme_class = 0x1 - nvme_subclass = 0x8 - nvme_progif = 0x2 -) - -const ( - opcode_delete_sq = 0x0 - opcode_create_sq = 0x1 - opcode_delete_cq = 0x4 - opcode_create_cq = 0x5 - opcode_identify = 0x6 - opcode_abort = 0x8 - opcode_set_features = 0x9 - opcode_get_features = 0xa - opcode_ns_management = 0xd - opcode_format_cmd = 0x80 -) - -const ( - nvme_io_queue_cnt = 0x4 -) +const nvme_class = 0x1 +const nvme_subclass = 0x8 +const nvme_progif = 0x2 + +const opcode_delete_sq = 0x0 +const opcode_create_sq = 0x1 +const opcode_delete_cq = 0x4 +const opcode_create_cq = 0x5 +const opcode_identify = 0x6 +const opcode_abort = 0x8 +const opcode_set_features = 0x9 +const opcode_get_features = 0xa +const opcode_ns_management = 0xd +const opcode_format_cmd = 0x80 + +const nvme_io_queue_cnt = 0x4 @[packed] struct NVMERegisters { diff --git a/kernel/modules/elf/elf.v b/kernel/modules/elf/elf.v index ac30ba66d..5a5287f22 100644 --- a/kernel/modules/elf/elf.v +++ b/kernel/modules/elf/elf.v @@ -17,27 +17,25 @@ pub mut: at_phnum u64 } -pub const ( - et_dyn = 0x03 +pub const et_dyn = 0x03 - at_entry = 9 - at_phdr = 3 - at_phent = 4 - at_phnum = 5 +pub const at_entry = 9 +pub const at_phdr = 3 +pub const at_phent = 4 +pub const at_phnum = 5 - pt_load = 0x00000001 - pt_interp = 0x00000003 - pt_phdr = 0x00000006 +pub const pt_load = 0x00000001 +pub const pt_interp = 0x00000003 +pub const pt_phdr = 0x00000006 - abi_sysv = 0x00 - arch_x86_64 = 0x3e - bits_le = 0x01 +pub const abi_sysv = 0x00 +pub const arch_x86_64 = 0x3e +pub const bits_le = 0x01 - ei_class = 4 - ei_data = 5 - ei_version = 6 - ei_osabi = 7 -) +pub const ei_class = 4 +pub const ei_data = 5 +pub const ei_version = 6 +pub const ei_osabi = 7 pub struct Header { pub mut: @@ -57,11 +55,9 @@ pub mut: shstrndx u16 } -pub const ( - pf_x = 1 - pf_w = 2 - pf_r = 4 -) +pub const pf_x = 1 +pub const pf_w = 2 +pub const pf_r = 4 pub struct ProgramHdr { pub mut: diff --git a/kernel/modules/errno/errno.v b/kernel/modules/errno/errno.v index 6a8802185..a64f64b2c 100644 --- a/kernel/modules/errno/errno.v +++ b/kernel/modules/errno/errno.v @@ -8,142 +8,140 @@ import proc pub const err = u64(-1) -pub const ( - eperm = 1 - enoent = 2 - esrch = 3 - eintr = 4 - eio = 5 - enxio = 6 - e2big = 7 - enoexec = 8 - ebadf = 9 - echild = 10 - eagain = 11 - enomem = 12 - eacces = 13 - efault = 14 - enotblk = 15 - ebusy = 16 - eexist = 17 - exdev = 18 - enodev = 19 - enotdir = 20 - eisdir = 21 - einval = 22 - enfile = 23 - emfile = 24 - enotty = 25 - etxtbsy = 26 - efbig = 27 - enospc = 28 - espipe = 29 - erofs = 30 - emlink = 31 - epipe = 32 - edom = 33 - erange = 34 - edeadlk = 35 - enametoolong = 36 - enolck = 37 - enosys = 38 - enotempty = 39 - eloop = 40 - ewouldblock = eagain - enomsg = 42 - eidrm = 43 - echrng = 44 - el2nsync = 45 - el3hlt = 46 - el3rst = 47 - elnrng = 48 - eunatch = 49 - enocsi = 50 - el2hlt = 51 - ebade = 52 - ebadr = 53 - exfull = 54 - enoano = 55 - ebadrqc = 56 - ebadslt = 57 - edeadlock = edeadlk - ebfont = 59 - enostr = 60 - enodata = 61 - etime = 62 - enosr = 63 - enonet = 64 - enopkg = 65 - eremote = 66 - enolink = 67 - eadv = 68 - esrmnt = 69 - ecomm = 70 - eproto = 71 - emultihop = 72 - edotdot = 73 - ebadmsg = 74 - eoverflow = 75 - enotuniq = 76 - ebadfd = 77 - eremchg = 78 - elibacc = 79 - elibbad = 80 - elibscn = 81 - elibmax = 82 - elibexec = 83 - eilseq = 84 - erestart = 85 - estrpipe = 86 - eusers = 87 - enotsock = 88 - edestaddrreq = 89 - emsgsize = 90 - eprototype = 91 - enoprotoopt = 92 - eprotonosupport = 93 - esocktnosupport = 94 - eopnotsupp = 95 - enotsup = eopnotsupp - epfnosupport = 96 - eafnosupport = 97 - eaddrinuse = 98 - eaddrnotavail = 99 - enetdown = 100 - enetunreach = 101 - enetreset = 102 - econnaborted = 103 - econnreset = 104 - enobufs = 105 - eisconn = 106 - enotconn = 107 - eshutdown = 108 - etoomanyrefs = 109 - etimedout = 110 - econnrefused = 111 - ehostdown = 112 - ehostunreach = 113 - ealready = 114 - einprogress = 115 - estale = 116 - euclean = 117 - enotnam = 118 - enavail = 119 - eisnam = 120 - eremoteio = 121 - edquot = 122 - enomedium = 123 - emediumtype = 124 - ecanceled = 125 - enokey = 126 - ekeyexpired = 127 - ekeyrevoked = 128 - ekeyrejected = 129 - eownerdead = 130 - enotrecoverable = 131 - erfkill = 132 - ehwpoison = 133 -) +pub const eperm = 1 +pub const enoent = 2 +pub const esrch = 3 +pub const eintr = 4 +pub const eio = 5 +pub const enxio = 6 +pub const e2big = 7 +pub const enoexec = 8 +pub const ebadf = 9 +pub const echild = 10 +pub const eagain = 11 +pub const enomem = 12 +pub const eacces = 13 +pub const efault = 14 +pub const enotblk = 15 +pub const ebusy = 16 +pub const eexist = 17 +pub const exdev = 18 +pub const enodev = 19 +pub const enotdir = 20 +pub const eisdir = 21 +pub const einval = 22 +pub const enfile = 23 +pub const emfile = 24 +pub const enotty = 25 +pub const etxtbsy = 26 +pub const efbig = 27 +pub const enospc = 28 +pub const espipe = 29 +pub const erofs = 30 +pub const emlink = 31 +pub const epipe = 32 +pub const edom = 33 +pub const erange = 34 +pub const edeadlk = 35 +pub const enametoolong = 36 +pub const enolck = 37 +pub const enosys = 38 +pub const enotempty = 39 +pub const eloop = 40 +pub const ewouldblock = eagain +pub const enomsg = 42 +pub const eidrm = 43 +pub const echrng = 44 +pub const el2nsync = 45 +pub const el3hlt = 46 +pub const el3rst = 47 +pub const elnrng = 48 +pub const eunatch = 49 +pub const enocsi = 50 +pub const el2hlt = 51 +pub const ebade = 52 +pub const ebadr = 53 +pub const exfull = 54 +pub const enoano = 55 +pub const ebadrqc = 56 +pub const ebadslt = 57 +pub const edeadlock = edeadlk +pub const ebfont = 59 +pub const enostr = 60 +pub const enodata = 61 +pub const etime = 62 +pub const enosr = 63 +pub const enonet = 64 +pub const enopkg = 65 +pub const eremote = 66 +pub const enolink = 67 +pub const eadv = 68 +pub const esrmnt = 69 +pub const ecomm = 70 +pub const eproto = 71 +pub const emultihop = 72 +pub const edotdot = 73 +pub const ebadmsg = 74 +pub const eoverflow = 75 +pub const enotuniq = 76 +pub const ebadfd = 77 +pub const eremchg = 78 +pub const elibacc = 79 +pub const elibbad = 80 +pub const elibscn = 81 +pub const elibmax = 82 +pub const elibexec = 83 +pub const eilseq = 84 +pub const erestart = 85 +pub const estrpipe = 86 +pub const eusers = 87 +pub const enotsock = 88 +pub const edestaddrreq = 89 +pub const emsgsize = 90 +pub const eprototype = 91 +pub const enoprotoopt = 92 +pub const eprotonosupport = 93 +pub const esocktnosupport = 94 +pub const eopnotsupp = 95 +pub const enotsup = eopnotsupp +pub const epfnosupport = 96 +pub const eafnosupport = 97 +pub const eaddrinuse = 98 +pub const eaddrnotavail = 99 +pub const enetdown = 100 +pub const enetunreach = 101 +pub const enetreset = 102 +pub const econnaborted = 103 +pub const econnreset = 104 +pub const enobufs = 105 +pub const eisconn = 106 +pub const enotconn = 107 +pub const eshutdown = 108 +pub const etoomanyrefs = 109 +pub const etimedout = 110 +pub const econnrefused = 111 +pub const ehostdown = 112 +pub const ehostunreach = 113 +pub const ealready = 114 +pub const einprogress = 115 +pub const estale = 116 +pub const euclean = 117 +pub const enotnam = 118 +pub const enavail = 119 +pub const eisnam = 120 +pub const eremoteio = 121 +pub const edquot = 122 +pub const enomedium = 123 +pub const emediumtype = 124 +pub const ecanceled = 125 +pub const enokey = 126 +pub const ekeyexpired = 127 +pub const ekeyrevoked = 128 +pub const ekeyrejected = 129 +pub const eownerdead = 130 +pub const enotrecoverable = 131 +pub const erfkill = 132 +pub const ehwpoison = 133 pub fn get() u64 { return proc.current_thread().errno diff --git a/kernel/modules/file/file.v b/kernel/modules/file/file.v index 8d17a59a2..496cf93dd 100644 --- a/kernel/modules/file/file.v +++ b/kernel/modules/file/file.v @@ -15,21 +15,19 @@ import event.eventstruct import memory.mmap import time -pub const ( - f_dupfd = 0 - f_dupfd_cloexec = 1030 - f_getfd = 1 - f_setfd = 2 - f_getfl = 3 - f_setfl = 4 - f_getlk = 5 - f_setlk = 6 - f_setlkw = 7 - f_getown = 8 - f_setown = 9 - - fd_cloexec = 1 -) +pub const f_dupfd = 0 +pub const f_dupfd_cloexec = 1030 +pub const f_getfd = 1 +pub const f_setfd = 2 +pub const f_getfl = 3 +pub const f_setfl = 4 +pub const f_getlk = 5 +pub const f_setlk = 6 +pub const f_setlkw = 7 +pub const f_getown = 8 +pub const f_setown = 9 + +pub const fd_cloexec = 1 pub struct Handle { pub mut: @@ -51,16 +49,14 @@ mut: revents i16 } -pub const ( - pollin = 0x01 - pollout = 0x04 - pollpri = 0x02 - pollhup = 0x10 - pollerr = 0x08 - pollrdhup = 0x2000 - pollnval = 0x20 - pollwrnorm = 0x100 -) +pub const pollin = 0x01 +pub const pollout = 0x04 +pub const pollpri = 0x02 +pub const pollhup = 0x10 +pub const pollerr = 0x08 +pub const pollrdhup = 0x2000 +pub const pollnval = 0x20 +pub const pollwrnorm = 0x100 pub fn syscall_ppoll(_ voidptr, fds &PollFD, nfds u64, tmo_p &time.TimeSpec, sigmask &u64) (u64, u64) { mut t := proc.current_thread() diff --git a/kernel/modules/fs/vfs.v b/kernel/modules/fs/vfs.v index 34c05d000..34a30bafd 100644 --- a/kernel/modules/fs/vfs.v +++ b/kernel/modules/fs/vfs.v @@ -11,17 +11,15 @@ import proc import file import errno -pub const ( - at_fdcwd = -100 - at_empty_path = 0x1000 - at_symlink_follow = 0x400 - at_symlink_nofollow = 0x100 - at_removedir = 0x200 - at_eaccess = 0x200 - seek_cur = 1 - seek_end = 2 - seek_set = 0 -) +pub const at_fdcwd = -100 +pub const at_empty_path = 0x1000 +pub const at_symlink_follow = 0x400 +pub const at_symlink_nofollow = 0x100 +pub const at_removedir = 0x200 +pub const at_eaccess = 0x200 +pub const seek_cur = 1 +pub const seek_end = 2 +pub const seek_set = 0 interface FileSystem { mut: diff --git a/kernel/modules/initramfs/initramfs.v b/kernel/modules/initramfs/initramfs.v index e0e1c4702..80834cbe5 100644 --- a/kernel/modules/initramfs/initramfs.v +++ b/kernel/modules/initramfs/initramfs.v @@ -8,7 +8,7 @@ import lib import limine import fs import stat -import memory +import memory as _ struct USTARHeader { name [100]u8 diff --git a/kernel/modules/limine/limine.v b/kernel/modules/limine/limine.v index ec32aa492..f17c7b47b 100644 --- a/kernel/modules/limine/limine.v +++ b/kernel/modules/limine/limine.v @@ -144,10 +144,8 @@ pub mut: // Paging mode -pub const ( - limine_paging_mode_x86_64_4lvl = 0 - limine_paging_mode_x86_64_5lvl = 1 -) +pub const limine_paging_mode_x86_64_4lvl = 0 +pub const limine_paging_mode_x86_64_5lvl = 1 pub struct LiminePagingModeResponse { pub mut: @@ -201,11 +199,9 @@ pub mut: // Memory map -pub const ( - limine_memmap_usable = 0 - limine_memmap_bootloader_reclaimable = 5 - limine_memmap_kernel_and_modules = 6 -) +pub const limine_memmap_usable = 0 +pub const limine_memmap_bootloader_reclaimable = 5 +pub const limine_memmap_kernel_and_modules = 6 pub struct LimineMemmapEntry { pub mut: diff --git a/kernel/modules/memory/mmap/mmap.v b/kernel/modules/memory/mmap/mmap.v index dffccdde7..a618a0df6 100644 --- a/kernel/modules/memory/mmap/mmap.v +++ b/kernel/modules/memory/mmap/mmap.v @@ -12,17 +12,15 @@ import x86.cpu import x86.cpu.local as cpulocal import lib -pub const ( - prot_none = 0x00 - prot_read = 0x01 - prot_write = 0x02 - prot_exec = 0x04 - map_private = 0x02 - map_shared = 0x01 - map_fixed = 0x10 - map_anon = 0x20 - map_anonymous = 0x20 -) +pub const prot_none = 0x00 +pub const prot_read = 0x01 +pub const prot_write = 0x02 +pub const prot_exec = 0x04 +pub const map_private = 0x02 +pub const map_shared = 0x01 +pub const map_fixed = 0x10 +pub const map_anon = 0x20 +pub const map_anonymous = 0x20 pub struct MmapRangeLocal { pub mut: diff --git a/kernel/modules/memory/virtual.v b/kernel/modules/memory/virtual.v index 3966f2dab..644981c46 100644 --- a/kernel/modules/memory/virtual.v +++ b/kernel/modules/memory/virtual.v @@ -16,13 +16,11 @@ fn C.rodata_end() fn C.data_start() fn C.data_end() -pub const ( - pte_present = u64(1) << 0 - pte_writable = u64(1) << 1 - pte_user = u64(1) << 2 - pte_noexec = u64(1) << 63 - pte_flags_mask = ~(u64(0xfff) | pte_present | pte_writable | pte_user | pte_noexec) -) +pub const pte_present = u64(1) << 0 +pub const pte_writable = u64(1) << 1 +pub const pte_user = u64(1) << 2 +pub const pte_noexec = u64(1) << 63 +pub const pte_flags_mask = ~(u64(0xfff) | pte_present | pte_writable | pte_user | pte_noexec) __global ( page_size = u64(0x1000) diff --git a/kernel/modules/resource/resource.v b/kernel/modules/resource/resource.v index 318dd43e2..a0a41c566 100644 --- a/kernel/modules/resource/resource.v +++ b/kernel/modules/resource/resource.v @@ -10,32 +10,30 @@ import ioctl import errno import event.eventstruct -pub const ( - o_path = 0o10000000 +pub const o_path = 0o10000000 - o_accmode = (0o03 | o_path) - o_exec = o_path - o_rdonly = 0o00 - o_rdwr = 0o02 - o_search = o_path - o_wronly = 0o01 - o_append = 0o2000 - o_creat = 0o100 - o_directory = 0o200000 - o_excl = 0o200 - o_noctty = 0o400 - o_nofollow = 0o400000 - o_trunc = 0o1000 - o_nonblock = 0o4000 - o_dsync = 0o10000 - o_rsync = 0o4010000 - o_sync = 0o4010000 - o_cloexec = 0o2000000 +pub const o_accmode = (0o03 | o_path) +pub const o_exec = o_path +pub const o_rdonly = 0o00 +pub const o_rdwr = 0o02 +pub const o_search = o_path +pub const o_wronly = 0o01 +pub const o_append = 0o2000 +pub const o_creat = 0o100 +pub const o_directory = 0o200000 +pub const o_excl = 0o200 +pub const o_noctty = 0o400 +pub const o_nofollow = 0o400000 +pub const o_trunc = 0o1000 +pub const o_nonblock = 0o4000 +pub const o_dsync = 0o10000 +pub const o_rsync = 0o4010000 +pub const o_sync = 0o4010000 +pub const o_cloexec = 0o2000000 - file_creation_flags_mask = o_creat | o_directory | o_excl | o_noctty | o_nofollow | o_trunc - file_descriptor_flags_mask = o_cloexec - file_status_flags_mask = ~(file_creation_flags_mask | file_descriptor_flags_mask) -) +pub const file_creation_flags_mask = o_creat | o_directory | o_excl | o_noctty | o_nofollow | o_trunc +pub const file_descriptor_flags_mask = o_cloexec +pub const file_status_flags_mask = ~(file_creation_flags_mask | file_descriptor_flags_mask) pub interface Resource { mut: diff --git a/kernel/modules/socket/public/public.v b/kernel/modules/socket/public/public.v index 2aacb7cb3..c34c020be 100644 --- a/kernel/modules/socket/public/public.v +++ b/kernel/modules/socket/public/public.v @@ -6,17 +6,15 @@ module public import resource { Resource } -pub const ( - af_inet = 2 - af_inet6 = 10 - af_unix = 1 - af_local = 1 - af_unspec = 0 - af_netlink = 16 - - sock_nonblock = 0o4000 - sock_cloexec = 0o2000000 -) +pub const af_inet = 2 +pub const af_inet6 = 10 +pub const af_unix = 1 +pub const af_local = 1 +pub const af_unspec = 0 +pub const af_netlink = 16 + +pub const sock_nonblock = 0o4000 +pub const sock_cloexec = 0o2000000 pub interface Socket { Resource diff --git a/kernel/modules/stat/stat.v b/kernel/modules/stat/stat.v index 28324d6cd..fdc261025 100644 --- a/kernel/modules/stat/stat.v +++ b/kernel/modules/stat/stat.v @@ -6,17 +6,15 @@ module stat import time -pub const ( - ifmt = 0xf000 - ifblk = 0x6000 - ifchr = 0x2000 - ififo = 0x1000 - ifreg = 0x8000 - ifdir = 0x4000 - iflnk = 0xa000 - ifsock = 0xc000 - ifpipe = 0x3000 -) +pub const ifmt = 0xf000 +pub const ifblk = 0x6000 +pub const ifchr = 0x2000 +pub const ififo = 0x1000 +pub const ifreg = 0x8000 +pub const ifdir = 0x4000 +pub const iflnk = 0xa000 +pub const ifsock = 0xc000 +pub const ifpipe = 0x3000 pub fn isblk(mode u32) bool { return (mode & stat.ifmt) == stat.ifblk @@ -65,17 +63,15 @@ pub mut: pad1 [3]i64 } -pub const ( - dt_unknown = 0 - dt_fifo = 1 - dt_chr = 2 - dt_dir = 4 - dt_blk = 6 - dt_reg = 8 - dt_lnk = 10 - dt_sock = 12 - dt_wht = 14 -) +pub const dt_unknown = 0 +pub const dt_fifo = 1 +pub const dt_chr = 2 +pub const dt_dir = 4 +pub const dt_blk = 6 +pub const dt_reg = 8 +pub const dt_lnk = 10 +pub const dt_sock = 12 +pub const dt_wht = 14 pub struct Dirent { pub mut: diff --git a/kernel/modules/term/term.v b/kernel/modules/term/term.v index e573342b6..4008d3309 100644 --- a/kernel/modules/term/term.v +++ b/kernel/modules/term/term.v @@ -8,7 +8,7 @@ import klock import dev.fbdev.api import dev.fbdev.simple import limine -import flanterm +import flanterm as _ import memory __global ( diff --git a/kernel/modules/time/pit.v b/kernel/modules/time/pit.v index 49aca556e..14ec79e03 100644 --- a/kernel/modules/time/pit.v +++ b/kernel/modules/time/pit.v @@ -8,9 +8,7 @@ import x86.kio import x86.idt import x86.cpu.local as cpulocal -pub const ( - pit_dividend = u64(1193182) -) +pub const pit_dividend = u64(1193182) pub fn pit_get_current_count() u16 { kio.port_out(0x43, 0) diff --git a/kernel/modules/time/time.v b/kernel/modules/time/time.v index b417d11ef..d92a17be9 100644 --- a/kernel/modules/time/time.v +++ b/kernel/modules/time/time.v @@ -8,12 +8,10 @@ import event.eventstruct import klock import limine -pub const ( - timer_frequency = u64(1000) +pub const timer_frequency = u64(1000) - clock_type_realtime = 0 - clock_type_monotonic = 1 -) +pub const clock_type_realtime = 0 +pub const clock_type_monotonic = 1 pub struct TimeSpec { pub mut: diff --git a/kernel/modules/x86/apic/apic.v b/kernel/modules/x86/apic/apic.v index 8e0bc9798..a34d23158 100644 --- a/kernel/modules/x86/apic/apic.v +++ b/kernel/modules/x86/apic/apic.v @@ -9,16 +9,14 @@ import x86.msr import x86.cpu.local as cpulocal import time -const ( - lapic_reg_icr0 = 0x300 - lapic_reg_icr1 = 0x310 - lapic_reg_spurious = 0x0f0 - lapic_reg_eoi = 0x0b0 - lapic_reg_timer = 0x320 - lapic_reg_timer_initcnt = 0x380 - lapic_reg_timer_curcnt = 0x390 - lapic_reg_timer_div = 0x3e0 -) +const lapic_reg_icr0 = 0x300 +const lapic_reg_icr1 = 0x310 +const lapic_reg_spurious = 0x0f0 +const lapic_reg_eoi = 0x0b0 +const lapic_reg_timer = 0x320 +const lapic_reg_timer_initcnt = 0x380 +const lapic_reg_timer_curcnt = 0x390 +const lapic_reg_timer_div = 0x3e0 __global ( lapic_base = u64(0)