diff --git a/.stylehlp b/.stylehlp index 0a8b519..5823947 100644 --- a/.stylehlp +++ b/.stylehlp @@ -4,7 +4,7 @@ // Desc: // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -28,7 +28,7 @@ ; Desc: ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; @@ -52,7 +52,7 @@ # Desc: # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/.stylehlp_sh b/.stylehlp_sh index d7e2004..1289bfb 100644 --- a/.stylehlp_sh +++ b/.stylehlp_sh @@ -4,7 +4,7 @@ # Desc: # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/AUTHORS b/AUTHORS index ddebb5a..3d91e65 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,7 +4,7 @@ # Desc: Project Authors File # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/Makefile b/Makefile index 6a19b98..eb556e1 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Desc: Project Makefile # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/ProjectTree b/ProjectTree index d352829..c510093 100644 --- a/ProjectTree +++ b/ProjectTree @@ -4,7 +4,7 @@ # Desc: # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/README.md b/README.md index 7103772..2cdd656 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,8 @@ To compile and test, simply use at the root of this project : make test ``` -To compile and install, simply use at the root of this project, with XXX the image or block file you want to use : -``` -make install installdisk=XXX -``` - #### Screenshot -![OS/K Started](https://www.os-k.eu/images/screen6.png) +![OS/K Started](https://www.os-k.eu/images/screen44.png) diff --git a/boot/folder.desc b/boot/folder.desc index e4a46a5..b18f2e4 100644 --- a/boot/folder.desc +++ b/boot/folder.desc @@ -4,7 +4,7 @@ # Desc: Folder description - "boot" # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/boot/grub/grub.cfg b/boot/grub/grub.cfg index b893821..7c24af0 100755 --- a/boot/grub/grub.cfg +++ b/boot/grub/grub.cfg @@ -4,7 +4,7 @@ # Desc: Grub 2 configuration file for OS/K boot # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/boot/loader/cpu/cpu.inc b/boot/loader/cpu/cpu.inc index f0fbc95..f653ab1 100644 --- a/boot/loader/cpu/cpu.inc +++ b/boot/loader/cpu/cpu.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/cpu/cpu32.inc b/boot/loader/cpu/cpu32.inc index 9eaa036..e2831e6 100644 --- a/boot/loader/cpu/cpu32.inc +++ b/boot/loader/cpu/cpu32.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/io/terminal.inc b/boot/loader/io/terminal.inc index 312f0e2..6003b7a 100644 --- a/boot/loader/io/terminal.inc +++ b/boot/loader/io/terminal.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 4247928..ed12c2b 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/mem/management.inc b/boot/loader/mem/management.inc index 961478f..6b122c4 100644 --- a/boot/loader/mem/management.inc +++ b/boot/loader/mem/management.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/mem/structures.inc b/boot/loader/mem/structures.inc index de8013d..2e0a444 100644 --- a/boot/loader/mem/structures.inc +++ b/boot/loader/mem/structures.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/multiboot/check.inc b/boot/loader/multiboot/check.inc index c045e64..03a4c9f 100644 --- a/boot/loader/multiboot/check.inc +++ b/boot/loader/multiboot/check.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/boot/loader/multiboot/header.inc b/boot/loader/multiboot/header.inc index 1115298..5a0fe5c 100644 --- a/boot/loader/multiboot/header.inc +++ b/boot/loader/multiboot/header.inc @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/build/create_disk.sh b/build/create_disk.sh index f2af324..0318a8d 100755 --- a/build/create_disk.sh +++ b/build/create_disk.sh @@ -4,7 +4,7 @@ # Desc: OS/K image maker script # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/build/install-os-k.sh b/build/install-os-k.sh index 6705e69..68a58f5 100755 --- a/build/install-os-k.sh +++ b/build/install-os-k.sh @@ -4,7 +4,7 @@ # Desc: Grub installation script for the OS/K image # # # # # -# Copyright © 2018-2019 The OS/K Team # +# Copyright © 2018-2020 The OS/K Team # # # # This file is part of OS/K. # # # diff --git a/build/kernel.ld b/build/kernel.ld index 7604bd8..b21fb85 100644 --- a/build/kernel.ld +++ b/build/kernel.ld @@ -5,7 +5,7 @@ // (x86_64 architecture only) // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/asm.h b/include/asm.h index 936ae50..ab05cdd 100644 --- a/include/asm.h +++ b/include/asm.h @@ -4,7 +4,7 @@ // Desc: Inline assembly functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/errno.h b/include/errno.h index 9d3c83c..1256114 100644 --- a/include/errno.h +++ b/include/errno.h @@ -4,7 +4,7 @@ // Desc: Values for error_t and errno // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ex/malloc.h b/include/ex/malloc.h index f63ea44..c8f1202 100644 --- a/include/ex/malloc.h +++ b/include/ex/malloc.h @@ -4,7 +4,7 @@ // Desc: Memory allocation functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/init/boot.h b/include/init/boot.h index 5594870..13dd9df 100644 --- a/include/init/boot.h +++ b/include/init/boot.h @@ -4,7 +4,7 @@ // Desc: Kaleid kernel base include file // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/init/mboot.h b/include/init/mboot.h index a68cb0a..d81f92d 100644 --- a/include/init/mboot.h +++ b/include/init/mboot.h @@ -5,7 +5,7 @@ // // // // // Copyright © 1999,2003,2007-2010 Free Software Foundation, Inc. // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/acpi.h b/include/io/acpi.h index f33bfcb..1c4bb30 100644 --- a/include/io/acpi.h +++ b/include/io/acpi.h @@ -4,7 +4,7 @@ // Desc: ACPI, Hardware detection related // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/ata.h b/include/io/ata.h index 73ff34b..c8d16af 100644 --- a/include/io/ata.h +++ b/include/io/ata.h @@ -4,7 +4,7 @@ // Desc: Basic Read Only ATA Long mode Driver // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/cursor.h b/include/io/cursor.h index 72494b0..452b6d9 100644 --- a/include/io/cursor.h +++ b/include/io/cursor.h @@ -4,7 +4,7 @@ // Desc: Cursor-related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/keyb.h b/include/io/keyb.h index b5802f5..24790b3 100644 --- a/include/io/keyb.h +++ b/include/io/keyb.h @@ -4,7 +4,7 @@ // Desc: Keyboard related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/spkr.h b/include/io/spkr.h index be9eea5..c80df3c 100644 --- a/include/io/spkr.h +++ b/include/io/spkr.h @@ -4,7 +4,7 @@ // Desc: Speaker functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/io/vga.h b/include/io/vga.h index 9736124..12d7dba 100644 --- a/include/io/vga.h +++ b/include/io/vga.h @@ -4,7 +4,7 @@ // Desc: VGA terminal // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ke/cpuid.h b/include/ke/cpuid.h index c250d83..18dc75b 100644 --- a/include/ke/cpuid.h +++ b/include/ke/cpuid.h @@ -4,7 +4,7 @@ // Desc: CPUID related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ke/idt.h b/include/ke/idt.h index 6e705bf..b312e0b 100644 --- a/include/ke/idt.h +++ b/include/ke/idt.h @@ -4,7 +4,7 @@ // Desc: Interrupt related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ke/proc.h b/include/ke/proc.h index e7b4364..bb150a5 100644 --- a/include/ke/proc.h +++ b/include/ke/proc.h @@ -4,7 +4,7 @@ // Desc: Process-related structs and functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ke/sched.h b/include/ke/sched.h index 32856e4..f63f1f0 100644 --- a/include/ke/sched.h +++ b/include/ke/sched.h @@ -4,7 +4,7 @@ // Desc: Scheduler-related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -61,8 +61,8 @@ extern const char *PsPrioClassesNames[]; // Re-scheduling and preemption // XXX atomic operations // -#define PsRequestReSched() do { ++KeCurCPU->needReSched; } while (0) -#define PsDisablePreemption() do { ++KeCurCPU->preemptCount; } while (0) +#define PsRequestReSched() (++KeCurCPU->needReSched) +#define PsDisablePreemption() (++KeCurCPU->preemptCount) #define PsEnablePreemption() do { assert(KeCurCPU->preemptCount > 0); \ --KeCurCPU->preemptCount; } while(0) diff --git a/include/ke/spinlock.h b/include/ke/spinlock.h index f1e09b1..b8f50e1 100644 --- a/include/ke/spinlock.h +++ b/include/ke/spinlock.h @@ -4,7 +4,7 @@ // Desc: Spinlocks // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/ke/time.h b/include/ke/time.h index 8407312..e04b1ac 100644 --- a/include/ke/time.h +++ b/include/ke/time.h @@ -4,7 +4,7 @@ // Desc: Time-related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/kernel.h b/include/kernel.h index 8b9638e..a74978f 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -4,7 +4,7 @@ // Desc: Kaleid kernel base include file // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/lib/buf.h b/include/lib/buf.h index 8255d2b..58808a9 100644 --- a/include/lib/buf.h +++ b/include/lib/buf.h @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -138,18 +138,14 @@ int BGetState(Buffer_t *); error_t BFlushBuf(Buffer_t *); error_t BPutOnBuf(Buffer_t *, uchar); +error_t BWriteOnBuf(Buffer_t *, uchar *, size_t); +error_t BPrintOnBuf(Buffer_t *, const char *, ...); +error_t BPrintOnBufV(Buffer_t *, const char *, va_list); + error_t BGetFromBuf(Buffer_t *, uchar *); - -// The following functions return the number of bytes written to the buffer -size_t BWriteOnBuf(Buffer_t *, uchar *, size_t); -size_t BPrintOnBuf(Buffer_t *, const char *, ...); -size_t BPrintOnBufV(Buffer_t *, const char *, va_list); - -// The following functions return the number of elements from their -// va_list's their wrote too, e.g. successful bscanf("%d %d", &a, &b) == 2 -size_t BReadFromBuf(Buffer_t *, uchar *, size_t); -size_t BScanFromBuf(Buffer_t *, const char *, ...); -size_t BScanFromBufV(Buffer_t *, const char *, va_list); +error_t BReadBuf(Buffer_t *, uchar *, size_t); +error_t BScanBuf(Buffer_t *, const char *, ...); +error_t BScanBufV(Buffer_t *, const char *, va_list); void BLockBuf(Buffer_t *); void BUnlockBuf(Buffer_t *); @@ -161,14 +157,14 @@ bool BTrylockBuf(Buffer_t *); // error_t bputc(Buffer_t *, uchar); -size_t bwrite(Buffer_t *, uchar *, size_t); -size_t bprintf(Buffer_t *, const char *, ...); -size_t vbprintf(Buffer_t *, const char *, va_list); +error_t bwrite(Buffer_t *, uchar *, size_t); +error_t bprintf(Buffer_t *, const char *, ...); +error_t vbprintf(Buffer_t *, const char *, va_list); error_t bgetc(Buffer_t *, uchar *); -size_t bread(Buffer_t *, uchar *, size_t); -size_t bscanf(Buffer_t *, const char *, ...); -size_t vbscanf(Buffer_t *, const char *, va_list); +error_t bread(Buffer_t *, uchar *, size_t); +error_t bscanf(Buffer_t *, const char *, ...); +error_t vbscanf(Buffer_t *, const char *, va_list); error_t bemptybuf(Buffer_t *); error_t bscrolldown(Buffer_t *); diff --git a/include/lib/list.h b/include/lib/list.h index dda6e77..7613fd2 100644 --- a/include/lib/list.h +++ b/include/lib/list.h @@ -4,7 +4,7 @@ // Desc: Doubly linked lists implementation // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/libc.h b/include/libc.h index f35ae16..4ede37b 100644 --- a/include/libc.h +++ b/include/libc.h @@ -4,7 +4,7 @@ // Desc: C Runtime Library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -146,12 +146,8 @@ char *strrev(char *restrict, const char *restrict); char *strrev2(char *); size_t sprintf(char *, const char *, ...); -size_t vsprintf(char *, const char *, va_list); - -// These return the number of bytes **written** -// not the number of bytes which would have been -// written had the buffer been large enough size_t snprintf(char *, size_t, const char *, ...); +size_t vsprintf(char *, const char *, va_list); size_t vsnprintf(char *, size_t, const char *, va_list); //----------------------------------------------------------------------------// diff --git a/include/mm/gdt.h b/include/mm/gdt.h index 289f911..94bddcb 100644 --- a/include/mm/gdt.h +++ b/include/mm/gdt.h @@ -4,7 +4,7 @@ // Desc: GDT related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/mm/heap.h b/include/mm/heap.h index 9342ffa..e822ca6 100644 --- a/include/mm/heap.h +++ b/include/mm/heap.h @@ -4,7 +4,7 @@ // Desc: Heap management functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/mm/malloc.h b/include/mm/malloc.h index 44531ad..bb34b7d 100644 --- a/include/mm/malloc.h +++ b/include/mm/malloc.h @@ -4,7 +4,7 @@ // Desc: Memory allocation functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/mm/map.h b/include/mm/map.h index 5aa1c5e..941d810 100644 --- a/include/mm/map.h +++ b/include/mm/map.h @@ -4,7 +4,7 @@ // Desc: Mapping and checking memory related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/mm/paging.h b/include/mm/paging.h index c4f2845..9e4d9b4 100644 --- a/include/mm/paging.h +++ b/include/mm/paging.h @@ -4,7 +4,7 @@ // Desc: Paging memory related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/mm/palloc.h b/include/mm/palloc.h index 51fda80..64dda39 100644 --- a/include/mm/palloc.h +++ b/include/mm/palloc.h @@ -4,7 +4,7 @@ // Desc: Page allocator related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/po/shtdwn.h b/include/po/shtdwn.h index f7dbf81..48493a6 100644 --- a/include/po/shtdwn.h +++ b/include/po/shtdwn.h @@ -4,7 +4,7 @@ // Desc: Shutdown facilities // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/sh/argv.h b/include/sh/argv.h index 843b2c7..169fad3 100644 --- a/include/sh/argv.h +++ b/include/sh/argv.h @@ -4,7 +4,7 @@ // Desc: Command line parsing utilities // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/sh/shell.h b/include/sh/shell.h index e9cd8b0..41a1e44 100644 --- a/include/sh/shell.h +++ b/include/sh/shell.h @@ -4,7 +4,7 @@ // Desc: Kernel shell // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/include/vers.h b/include/vers.h index 40f219a..58e43a2 100644 --- a/include/vers.h +++ b/include/vers.h @@ -4,7 +4,7 @@ // Desc: Kaleid version // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/init/info.c b/kaleid/kernel/init/info.c index a93f8b8..3ed7397 100644 --- a/kaleid/kernel/init/info.c +++ b/kaleid/kernel/init/info.c @@ -4,7 +4,7 @@ // Desc: Initialization of boot info // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 410a490..f211ca7 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -4,7 +4,7 @@ // Desc: Kernel entry point // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/init/ssp.c b/kaleid/kernel/init/ssp.c index bf2d70d..a4a1c25 100644 --- a/kaleid/kernel/init/ssp.c +++ b/kaleid/kernel/init/ssp.c @@ -4,7 +4,7 @@ // Desc: Stack smashing protection // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -24,7 +24,7 @@ #include -ulong __stack_chk_guard = 0xec0ffec0ffec0ffe; +ulong __stack_chk_guard = 0xc0ffeb4b37a7adcc; noreturn void __stack_chk_fail(void) { diff --git a/kaleid/kernel/init/table.c b/kaleid/kernel/init/table.c index 912a62a..75d200a 100644 --- a/kaleid/kernel/init/table.c +++ b/kaleid/kernel/init/table.c @@ -4,7 +4,7 @@ // Desc: Global variables // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/acpi.c b/kaleid/kernel/io/acpi.c index 43064bc..d939bf1 100644 --- a/kaleid/kernel/io/acpi.c +++ b/kaleid/kernel/io/acpi.c @@ -4,7 +4,7 @@ // Desc: ACPI, Hardware detection related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/ata.asm b/kaleid/kernel/io/ata.asm index 40dcc08..ac15741 100644 --- a/kaleid/kernel/io/ata.asm +++ b/kaleid/kernel/io/ata.asm @@ -5,7 +5,7 @@ ; (x86_64 architecture only) ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/io/ata.c b/kaleid/kernel/io/ata.c index e92e4fa..3df1fae 100644 --- a/kaleid/kernel/io/ata.c +++ b/kaleid/kernel/io/ata.c @@ -4,7 +4,7 @@ // Desc: Basic Read Only ATA Long mode Driver // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/cursor.c b/kaleid/kernel/io/cursor.c index 5095d36..8b7defe 100644 --- a/kaleid/kernel/io/cursor.c +++ b/kaleid/kernel/io/cursor.c @@ -4,7 +4,7 @@ // Desc: Cursor-related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/keyb.c b/kaleid/kernel/io/keyb.c index c66e8d8..7c91e58 100644 --- a/kaleid/kernel/io/keyb.c +++ b/kaleid/kernel/io/keyb.c @@ -4,7 +4,7 @@ // Desc: Basic Keyboard Driver // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/scan.c b/kaleid/kernel/io/scan.c index ed28c4d..066c264 100644 --- a/kaleid/kernel/io/scan.c +++ b/kaleid/kernel/io/scan.c @@ -4,7 +4,7 @@ // Desc: Basic Scancode Tables // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/io/vga.c b/kaleid/kernel/io/vga.c index 41d9662..dc673ff 100644 --- a/kaleid/kernel/io/vga.c +++ b/kaleid/kernel/io/vga.c @@ -4,7 +4,7 @@ // Desc: VGA terminal functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ke/cpuf.asm b/kaleid/kernel/ke/cpuf.asm index 8120a52..a447db1 100644 --- a/kaleid/kernel/ke/cpuf.asm +++ b/kaleid/kernel/ke/cpuf.asm @@ -4,7 +4,7 @@ ; Desc: CPU management related functions ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/ke/cpuf.inc b/kaleid/kernel/ke/cpuf.inc index be4d109..8ffd688 100644 --- a/kaleid/kernel/ke/cpuf.inc +++ b/kaleid/kernel/ke/cpuf.inc @@ -4,7 +4,7 @@ ; Desc: Interrupt Descriptor Table related macros ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/ke/cpuid.c b/kaleid/kernel/ke/cpuid.c index debbfbb..fd9e461 100644 --- a/kaleid/kernel/ke/cpuid.c +++ b/kaleid/kernel/ke/cpuid.c @@ -4,7 +4,7 @@ // Desc: CPU detection // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ke/idt.c b/kaleid/kernel/ke/idt.c index 4060b88..1e0749d 100644 --- a/kaleid/kernel/ke/idt.c +++ b/kaleid/kernel/ke/idt.c @@ -4,7 +4,7 @@ // Desc: Interrupt related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ke/isr.asm b/kaleid/kernel/ke/isr.asm index 7c07e6f..ec57073 100644 --- a/kaleid/kernel/ke/isr.asm +++ b/kaleid/kernel/ke/isr.asm @@ -4,7 +4,7 @@ ; Desc: Interrupt Descriptor Table related functions ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/ke/log.c b/kaleid/kernel/ke/log.c index c57fe00..7695991 100644 --- a/kaleid/kernel/ke/log.c +++ b/kaleid/kernel/ke/log.c @@ -4,7 +4,7 @@ // Desc: KernLog() and DebugLog() // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ke/panic.c b/kaleid/kernel/ke/panic.c index 0b95652..63773fa 100644 --- a/kaleid/kernel/ke/panic.c +++ b/kaleid/kernel/ke/panic.c @@ -4,7 +4,7 @@ // Desc: How NOT to panic 101 // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -26,6 +26,7 @@ #include #include +error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap); extern bool KeIdtIsInitialized; // diff --git a/kaleid/kernel/ke/pit.c b/kaleid/kernel/ke/pit.c index f5902fc..e02852b 100644 --- a/kaleid/kernel/ke/pit.c +++ b/kaleid/kernel/ke/pit.c @@ -4,7 +4,7 @@ // Desc: PIT Time related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ke/rtc.c b/kaleid/kernel/ke/rtc.c index 16bda2b..1736019 100644 --- a/kaleid/kernel/ke/rtc.c +++ b/kaleid/kernel/ke/rtc.c @@ -4,7 +4,7 @@ // Desc: RTC Time related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/gdt.asm b/kaleid/kernel/mm/gdt.asm index 616da73..ed68dcc 100644 --- a/kaleid/kernel/mm/gdt.asm +++ b/kaleid/kernel/mm/gdt.asm @@ -4,7 +4,7 @@ ; Desc: Interrupt Descriptor Table related functions ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index 61ecced..5fdf3d7 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -4,7 +4,7 @@ // Desc: GDT related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/heap.c b/kaleid/kernel/mm/heap.c index b4c0c58..8e94ebe 100644 --- a/kaleid/kernel/mm/heap.c +++ b/kaleid/kernel/mm/heap.c @@ -4,7 +4,7 @@ // Desc: Early and very dumb heap managment // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/malloc.c b/kaleid/kernel/mm/malloc.c index f513660..36d7e09 100644 --- a/kaleid/kernel/mm/malloc.c +++ b/kaleid/kernel/mm/malloc.c @@ -4,7 +4,7 @@ // Desc: Early and very dumb memory managment // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 201567a..ce4e443 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -4,7 +4,7 @@ // Desc: Mapping and checking memory related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/paging.asm b/kaleid/kernel/mm/paging.asm index a1a9669..2e83484 100644 --- a/kaleid/kernel/mm/paging.asm +++ b/kaleid/kernel/mm/paging.asm @@ -4,7 +4,7 @@ ; Desc: Paging related functions ; ; ; ; ; -; Copyright © 2018-2019 The OS/K Team ; +; Copyright © 2018-2020 The OS/K Team ; ; ; ; This file is part of OS/K. ; ; ; diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 0ef38b2..ca658cb 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -4,7 +4,7 @@ // Desc: Paging memory related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/mm/palloc.c b/kaleid/kernel/mm/palloc.c index 2b4255e..a9a2148 100644 --- a/kaleid/kernel/mm/palloc.c +++ b/kaleid/kernel/mm/palloc.c @@ -4,7 +4,7 @@ // Desc: Page allocator related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/po/shtdwn.c b/kaleid/kernel/po/shtdwn.c index 88c6b49..2fa9a88 100644 --- a/kaleid/kernel/po/shtdwn.c +++ b/kaleid/kernel/po/shtdwn.c @@ -4,7 +4,7 @@ // Desc: Shutdown related function // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/ps/sched.c b/kaleid/kernel/ps/sched.c index 89fe03a..737944e 100644 --- a/kaleid/kernel/ps/sched.c +++ b/kaleid/kernel/ps/sched.c @@ -4,7 +4,7 @@ // Desc: Process scheduler // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/sh/argv.c b/kaleid/kernel/sh/argv.c index 8e132d3..f0b3355 100644 --- a/kaleid/kernel/sh/argv.c +++ b/kaleid/kernel/sh/argv.c @@ -4,7 +4,7 @@ // Desc: Command line parsing utilities // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/sh/musage.c b/kaleid/kernel/sh/musage.c index 47f51ef..d8d5524 100644 --- a/kaleid/kernel/sh/musage.c +++ b/kaleid/kernel/sh/musage.c @@ -4,7 +4,7 @@ // Desc: Kernel shell // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/sh/shell.c b/kaleid/kernel/sh/shell.c index 6ad2fd8..8d04c75 100644 --- a/kaleid/kernel/sh/shell.c +++ b/kaleid/kernel/sh/shell.c @@ -4,7 +4,7 @@ // Desc: Kernel shell // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/sh/shell.h b/kaleid/kernel/sh/shell.h index e2f9b18..7362e4c 100644 --- a/kaleid/kernel/sh/shell.h +++ b/kaleid/kernel/sh/shell.h @@ -4,7 +4,7 @@ // Desc: Kernel shell // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index cc322a7..6156629 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -4,7 +4,7 @@ // Desc: Kernel shell // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bclose.c b/kaleid/libbuf/bclose.c index 21255bd..a4d8446 100644 --- a/kaleid/libbuf/bclose.c +++ b/kaleid/libbuf/bclose.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bflush.c b/kaleid/libbuf/bflush.c index 08c7495..c71efaf 100644 --- a/kaleid/libbuf/bflush.c +++ b/kaleid/libbuf/bflush.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bgetc.c b/kaleid/libbuf/bgetc.c index ef53d4c..9aa4726 100644 --- a/kaleid/libbuf/bgetc.c +++ b/kaleid/libbuf/bgetc.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -43,9 +43,6 @@ error_t BGetFromBuf(Buffer_t *buf, uchar *ch) ExReleaseLock(&buf->lock); return rc; } - -// Note: any change to this must be done while -// keeping in mind vbscanf()'s workaround for ungetc() error_t bgetc(Buffer_t *buf, uchar *ch) { error_t rc = EOK; @@ -73,9 +70,6 @@ error_t bgetc(Buffer_t *buf, uchar *ch) while (buf->rp >= buf->wp) { #ifdef _KALEID_KERNEL KeSleep(1); // XXX synchronization with keyboard driver -#else - buf->flags |= BF_EOF; - return EENDF; // Currently empty #endif } diff --git a/kaleid/libbuf/bmisc.c b/kaleid/libbuf/bmisc.c index 96f9fa9..eb34fcb 100644 --- a/kaleid/libbuf/bmisc.c +++ b/kaleid/libbuf/bmisc.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bopen.c b/kaleid/libbuf/bopen.c index 8fa6397..cc37f1c 100644 --- a/kaleid/libbuf/bopen.c +++ b/kaleid/libbuf/bopen.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bprint.c b/kaleid/libbuf/bprint.c index c407cf4..56faeb9 100644 --- a/kaleid/libbuf/bprint.c +++ b/kaleid/libbuf/bprint.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -31,41 +31,73 @@ // // Prints formatted string on buf according to fmt // -size_t BPrintOnBuf(Buffer_t *buf, const char *fmt, ...) +error_t BPrintOnBuf(Buffer_t *buf, const char *fmt, ...) { - size_t sz; + error_t rc; va_list ap; va_start(ap, fmt); ExAcquireLock(&buf->lock); - sz = vbprintf(buf, fmt, ap); + rc = vbprintf(buf, fmt, ap); ExReleaseLock(&buf->lock); va_end(ap); - return sz; + return rc; } -size_t BPrintOnBufV(Buffer_t *buf, const char *fmt, va_list ap) +error_t BPrintOnBufV(Buffer_t *buf, const char *fmt, va_list ap) { - size_t sz; + error_t rc; ExAcquireLock(&buf->lock); - sz = vbprintf(buf, fmt, ap); + rc = vbprintf(buf, fmt, ap); ExReleaseLock(&buf->lock); - return sz; + return rc; } -size_t bprintf(Buffer_t *buf, const char *fmt, ...) +error_t bprintf(Buffer_t *buf, const char *fmt, ...) { - size_t sz; + error_t rc; va_list ap; va_start(ap, fmt); - sz = vbprintf(buf, fmt, ap); + rc = vbprintf(buf, fmt, ap); va_end(ap); - return sz; + return rc; +} + +// +// Prints 0 for octal, 0x for hexadecimal, 0b for binary +// +static error_t bprinthash(Buffer_t *buf, int base, int cap) +{ + error_t rc; + + if (base != 2 && base != 8 && base != 16) { + return EOK; + } + + rc = bputc(buf, '0'); + + if (!rc && base != 8) { + rc = bputc(buf, (base == 2 ? 'b' : (cap ? 'X' : 'x'))); + } + + return rc; +} + +static error_t bdopadding(Buffer_t *buf, size_t width, size_t len, + char filler) +{ + error_t rc = EOK; + + for (; !rc && width > len ; width--) { + rc = bputc(buf, filler); + } + + return rc; } #define CONVBUFSIZE 100 @@ -74,10 +106,9 @@ size_t bprintf(Buffer_t *buf, const char *fmt, ...) // Actually does BPrintOnBuf's job; doesn't lock anything // Quite a long function // -size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) +error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) { error_t rc = 0; - size_t written = 0; ssize_t width, prec, len; char type; @@ -103,11 +134,10 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // Base int base; - if (!buf || !fmt) { seterrno(EINVAL); return 0; } - if (buf->flags & (BF_EOF|BF_ERR)) { seterrno(EENDF); return 0; } + if (!buf || !fmt) return EINVAL; + if (buf->flags & (BF_EOF|BF_ERR)) return EENDF; if (buf->state != BS_RDWR && buf->state != BS_WRONLY) { - seterrno(EBADF); - return 0; + return EBADF; } // Progress in format string @@ -116,14 +146,14 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // Deal with all non-'%' characters if (*fmt != '%') { rc = bputc(buf, *fmt); - written++; + fmt++; - continue; } // - // %[flags][width|*][.precision|*][length]type + // %[parameter][flags][width|*][.precision|*][length]type + // We aren't dealing with parameters and floating stuff just yet // // Skip the '%' @@ -132,9 +162,8 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // "%%" modifier if (*fmt == '%') { rc = bputc(buf, '%'); - written++; + fmt++; - continue; } @@ -224,7 +253,6 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) if (type == 'c') { uch = (uchar)va_arg(ap, int); rc = bputc(buf, uch); - written++; continue; } @@ -233,10 +261,8 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) if (type == 'C') { base = va_arg(ap, int); - if (!(base < 0 || base > VGA_COLOR_WHITE)) { + if (!(base < 0 || base > VGA_COLOR_WHITE)) rc = bputc(buf, RtlColorToChar(base)); - written++; - } assert(!rc && 1); @@ -255,7 +281,7 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // Zero/nonspecified precision means unlimited amount if (prec == 0) prec = INT_MAX; - for (; !rc && *s && prec-- ; s++) { + for (; *s && prec-- ; s++) { rc = bputc(buf, (uchar)*s); } @@ -266,7 +292,6 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // Make sure width and prec aren't too big // (We didn't do that earlier because %s uses width) if (width > CONVBUFSIZE || prec > CONVBUFSIZE) { - written++; // Work around "if (rc) return written - 1;" rc = EINVAL; break; } @@ -288,16 +313,16 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) // End of string too soon else if (type == '\0') { + bputc(buf, '%'); rc = EINVAL; - written++; // fool the line "if (rc) return written-1;" break; } // Unknown/unsupported modifier else { - rc = bputc(buf, '%'); - written++; - + bputc(buf, '%'); + bputc(buf, '?'); + rc = bputc(buf, type); continue; } @@ -357,63 +382,36 @@ size_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap) } // When padding with spaces, we pad before +/-'s etc - if (!minus && !zero && width > len) { - for (; !rc && width > len ; width--) { - rc = bputc(buf, ' '); - written++; - } - } + if (!minus && !zero && width > len) + bdopadding(buf, width, len, ' '); // Deal with signs and the hash flag - if (*s == '-') { rc = bputc(buf, '-'); s++, len--; written++; } - else if (sgn && plus) { rc = bputc(buf, '+'); written++; } - else if (sgn && space) { rc = bputc(buf, ' '); written++; } - - // Print 0 for octal, 0x for hexadecimal, 0b for binary - else if (hash && (base == 2 || base == 8 || base == 16)) { - rc = bputc(buf, '0'); - written++; - - if (!rc && base != 8) { - rc = bputc(buf, (base == 2 ? 'b' : (cap ? 'X' : 'x'))); - written++; - } - } + if (*s == '-') { rc = bputc(buf, '-'); s++, len--; } + else if (sgn && plus) rc = bputc(buf, '+'); + else if (sgn && space) rc = bputc(buf, ' '); + else if (hash) bprinthash(buf, base, cap); // Deal with padding by zeroes // The 'minus' flag makes no sense with the 'zero' one - if (zero && width > len) { - for (; !rc && width > len ; width--) { - rc = bputc(buf, '0'); - written++; - } - } + if (zero && width > len) + bdopadding(buf, width, len, '0'); // Output the actual number for (; !rc && *s ; s++) { rc = bputc(buf, (uchar)*s); - written++; } // 'minus' padding, only with spaces - if (minus && !zero && width > len) { - for (; !rc && width > len ; width--) { - rc = bputc(buf, ' '); - written++; - } - } - + if (minus && !zero && width > len) + bdopadding(buf, width, base, ' '); + // Carry on to next modifier - } + } + + // For debugging purposes + if(rc)KeStartPanic("%s",strerror(rc)); + assert(!rc && "vbprintf() error"); - // For debugging purposes - assert(!rc && "vbprintf() error"); - seterrno(rc); - - if (rc) - return written - 1; // "- 1" because last bputc() must have failed - - else - return written; + return rc; } diff --git a/kaleid/libbuf/bputc.c b/kaleid/libbuf/bputc.c index fe14e35..33d8740 100644 --- a/kaleid/libbuf/bputc.c +++ b/kaleid/libbuf/bputc.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bread.c b/kaleid/libbuf/bread.c index 9c383cd..d3305e6 100644 --- a/kaleid/libbuf/bread.c +++ b/kaleid/libbuf/bread.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bscan.c b/kaleid/libbuf/bscan.c index f7b5c25..f85037f 100644 --- a/kaleid/libbuf/bscan.c +++ b/kaleid/libbuf/bscan.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -23,206 +23,4 @@ //----------------------------------------------------------------------------// #include - -// -// Builds string reading from buf according to fmt -// -size_t BScanFromBuf(Buffer_t *buf, const char *fmt, ...) -{ - size_t sz; - va_list ap; - - va_start(ap, fmt); - ExAcquireLock(&buf->lock); - sz = vbscanf(buf, fmt, ap); - ExReleaseLock(&buf->lock); - va_end(ap); - - return sz; -} - -size_t BScanFromBufV(Buffer_t *buf, const char *fmt, va_list ap) -{ - size_t sz; - - ExAcquireLock(&buf->lock); - sz = vbscanf(buf, fmt, ap); - ExReleaseLock(&buf->lock); - - return sz; -} - -size_t bscanf(Buffer_t *buf, const char *fmt, ...) -{ - size_t sz; - va_list ap; - - va_start(ap, fmt); - sz = vbscanf(buf, fmt, ap); - va_end(ap); - - return sz; -} - -size_t vbscanf(Buffer_t *buf, const char *fmt, va_list ap) -{ - error_t rc = EOK; - - size_t readcnt = 0; - uchar ch = 0; - char *chptr; - - bool l, h; - - size_t width; - bool ignore; // '*' modifier, don't write to va_list for current mod - - if (!buf || !fmt) { seterrno(EINVAL); return 0; } - if (buf->flags & (BF_EOF|BF_ERR)) { seterrno(EENDF); return 0; } - if (buf->state != BS_RDWR && buf->state != BS_WRONLY) { - seterrno(EBADF); - return 0; - } - - // Progress in format string - while (*fmt && !rc) { - - // Skip all kinds of whitespaces - if (isspace(*fmt)) { - - another_space: - rc = bgetc(buf, &ch); - - if (!rc) break; - - // Put back non-whitespaces and progress - if (!isspace(ch)) { - buf->rp--; - do { fmt++; } while (isspace(*fmt)); - continue; - } - - else goto another_space; - } - - // Deal with all non-'%' non-whitespace characters - if (*fmt != '%') { - rc = bgetc(buf, &ch); - - // Is it what we expected? - if (!rc && ch != *fmt) { - // No, so put it back - buf->rp--; - break; - } - - // We don't do anything with these characters - continue; - } - - // - // %[*][width][modifier]type - // - - // Skip the % - fmt++; - - // '%%' type - if (*fmt == '%') { - rc = bgetc(buf, &ch); - - if (!rc && ch != '%') { - buf->rp--; - break; - } - - continue; - } - - l = h = 0; - width = 0; - ignore = 0; - - // Don't write to variable - if (*fmt == '*') { - ignore = 1; - fmt++; - } - - // Extract width field - while (isdigit(*fmt)) { - width = 10 * width + (*fmt - '0'); - fmt++; - } - - // - // Extract length field - // - - if (*fmt == 'l') { - l = 1; - fmt++; - } - - else if (*fmt == 'h') { - h = 1; - fmt++; - } - - // - // Types - // - - // Read character(s) - if (*fmt == 'c') { - if (width == 0) width = 1; - - // For >1 width, read that many characters - // then store them in successive argument pointers - for (; width; width--) { - rc = bgetc(buf, &ch); - if (!rc) break; - if (ignore) continue; - - chptr = va_arg(ap, char *); - *chptr = (char)ch; - readcnt++; - } - } - - // Decimal integer - else if (*fmt == 'd') { - ; - } - } - - // For debugging purposes - assert(!rc && "vbscanf() error"); - seterrno(rc); - - return readcnt; -} - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kaleid/libbuf/bscroll.c b/kaleid/libbuf/bscroll.c index 0a50ae8..1c1b8c4 100644 --- a/kaleid/libbuf/bscroll.c +++ b/kaleid/libbuf/bscroll.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libbuf/bwrite.c b/kaleid/libbuf/bwrite.c index e6df43c..f85037f 100644 --- a/kaleid/libbuf/bwrite.c +++ b/kaleid/libbuf/bwrite.c @@ -4,7 +4,7 @@ // Desc: Buffer library // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/atoi.c b/kaleid/libc/atoi.c index f2e32c3..42d3153 100644 --- a/kaleid/libc/atoi.c +++ b/kaleid/libc/atoi.c @@ -4,7 +4,7 @@ // Desc: Convertion utilities - atoi() family // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/ctype.c b/kaleid/libc/ctype.c index f0482d4..74d6bca 100644 --- a/kaleid/libc/ctype.c +++ b/kaleid/libc/ctype.c @@ -4,7 +4,7 @@ // Desc: Character types // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/errno.c b/kaleid/libc/errno.c index e35315a..4a0b287 100644 --- a/kaleid/libc/errno.c +++ b/kaleid/libc/errno.c @@ -4,7 +4,7 @@ // Desc: strerror() & co. // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/mem.c b/kaleid/libc/mem.c index 46772d2..8e0eb96 100644 --- a/kaleid/libc/mem.c +++ b/kaleid/libc/mem.c @@ -4,7 +4,7 @@ // Desc: mem*() family // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/rand.c b/kaleid/libc/rand.c index 4eb2ea3..1dae354 100644 --- a/kaleid/libc/rand.c +++ b/kaleid/libc/rand.c @@ -4,7 +4,7 @@ // Desc: Random related functions // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/sprintf.c b/kaleid/libc/sprintf.c index bbee9b0..ab5a98f 100644 --- a/kaleid/libc/sprintf.c +++ b/kaleid/libc/sprintf.c @@ -4,7 +4,7 @@ // Desc: *s*printf() family // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // @@ -35,7 +35,7 @@ // Once libbuf is supports dynamic buffers, the only changes necessary // will be to change the value below to and add a line to vsnprintf() // -#define VSNPRINTF_MAX 4096 +#define VSNPRINTF_MAX 512 // // Format str according to fmt using ellipsed arguments @@ -77,8 +77,8 @@ size_t snprintf(char *str, size_t n, const char *fmt, ...) size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) { - error_t rc; - size_t ret, sz; + size_t ret; + error_t rc = EOK; Buffer_t *buf = NULL; assert(str && fmt); @@ -96,11 +96,16 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) goto fail; } - sz = vbprintf(buf, fmt, ap); + rc = vbprintf(buf, fmt, ap); // We don't mind EOFs, just just return how much was successfully written - if (sz == 0) { - if (!(buf->flags & BF_EOF)) { + if (rc != EOK) { + if (rc == EENDF) { + if (!(buf->flags & BF_EOF)) { + goto fail; + } + } + else { goto fail; } } @@ -108,6 +113,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap) ret = (size_t)buf->wp - (size_t)buf->buf; if (ret > 0) { + // To be changed to memcpy() memmove(str, (char *)buf->buf, ret); } diff --git a/kaleid/libc/string.c b/kaleid/libc/string.c index 3d1c340..2b50b20 100644 --- a/kaleid/libc/string.c +++ b/kaleid/libc/string.c @@ -4,7 +4,7 @@ // Desc: String manipulation utilities // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // // diff --git a/kaleid/libc/strtol.c b/kaleid/libc/strtol.c index 09354d5..03bdc8f 100644 --- a/kaleid/libc/strtol.c +++ b/kaleid/libc/strtol.c @@ -4,7 +4,7 @@ // Desc: strto*l() family // // // // // -// Copyright © 2018-2019 The OS/K Team // +// Copyright © 2018-2020 The OS/K Team // // // // This file is part of OS/K. // // //