1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00

Merge branch 'shell' of gitlab.os-k.eu:os-k-team/os-k into shell

This commit is contained in:
Julian Barathieu 2020-02-06 15:01:07 +01:00
commit f340f7698f
104 changed files with 212 additions and 428 deletions

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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)

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. #
# #

View File

@ -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. #
# #

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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)

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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 *);

View File

@ -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. //
// //

View File

@ -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);
//----------------------------------------------------------------------------//

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //
@ -73,11 +73,11 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
// Interrupts
KeSetupIDT();
KeEnableIRQs();
KeEnableRTC();
KeEnablePIT();
// Interrupt handlers
MmActivatePageHandler();
KeEnableRTC();
KeEnablePIT();
KeGetCpuInfos();
IoEnableKeyb();

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. ;
; ;

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. ;
; ;

View File

@ -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. ;
; ;

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. ;
; ;

View File

@ -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. //
// //

View File

@ -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 <ke/proc.h>
#include <io/vga.h>
error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap);
extern bool KeIdtIsInitialized;
//

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. ;
; ;

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. ;
; ;

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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
}

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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;
}

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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 <lib/buf.h>
//
// 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;
}

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

View File

@ -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. //
// //

Some files were not shown because too many files have changed in this diff Show More