header reorganization
This commit is contained in:
parent
ebb1a4e927
commit
2f35387e92
7
Makefile
7
Makefile
|
@ -84,8 +84,8 @@ NC='\033[1;37m'
|
|||
# Lib C sources + libbuf source
|
||||
LibCSources = libc/mem.c libc/ctype.c \
|
||||
libc/rand.c libc/sprintf.c \
|
||||
libc/errno.c libc/string.c \
|
||||
libc/strtol.c extras/argv.c \
|
||||
libc/errno.c libc/string.c \
|
||||
libc/strtol.c \
|
||||
libbuf/bopen.c libbuf/bputc.c libbuf/bscroll.c \
|
||||
libbuf/bprint.c libbuf/bgetc.c libbuf/bscan.c \
|
||||
libbuf/bflush.c libbuf/bwrite.c libbuf/bread.c \
|
||||
|
@ -108,7 +108,8 @@ KernSources = kernel/ke/cpuid.c kernel/mm/paging.c \
|
|||
kernel/ke/rtc.c kernel/io/keyb.c \
|
||||
kernel/io/spkr.c kernel/po/shtdwn.c \
|
||||
kernel/sh/shell.c kernel/sh/shcmds.c \
|
||||
kernel/sh/musage.c kernel/io/ata.c
|
||||
kernel/sh/musage.c kernel/io/ata.c \
|
||||
kernel/sh/argv.c
|
||||
|
||||
KernObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(KernSources))
|
||||
KernDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(KernSources))
|
||||
|
|
|
@ -1,299 +0,0 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Command line parsing utilities //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
// //
|
||||
// This file is part of OS/K. //
|
||||
// //
|
||||
// OS/K is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// any later version. //
|
||||
// //
|
||||
// OS/K is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _LIBC_H
|
||||
#include <libc.h>
|
||||
#endif
|
||||
|
||||
#ifndef _KALEXTRAS_ARGV_H
|
||||
#define _KALEXTRAS_ARGV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum CmdOptionFlag_t CmdOptionFlag_t;
|
||||
typedef enum CmdParserFlags_t CmdParserFlags_t;
|
||||
typedef enum CmdParserReturn_t CmdParserReturn_t;
|
||||
|
||||
typedef struct CmdOption_t CmdOption_t;
|
||||
typedef struct CmdDocStrings_t CmdDocStrings_t;
|
||||
typedef struct CmdParserState_t CmdParserState_t;
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
//
|
||||
// Maximal total size of argv, including the pointers,
|
||||
// the pointed-to strings and their null-terminators
|
||||
// This is a 32-bit integer
|
||||
//
|
||||
#define ARG_MAX (1 << 16) // 64 KB
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
//
|
||||
// Flags for options
|
||||
//
|
||||
enum CmdOptionFlag_t
|
||||
{
|
||||
// The option parameter is optional
|
||||
KALOPT_OPTIONAL = (1 << 0),
|
||||
|
||||
// Do not show option in any help message
|
||||
KALOPT_HIDDEN = (1 << 1),
|
||||
|
||||
// This option is an alias for the previous one
|
||||
KALOPT_ALIAS = (1 << 2),
|
||||
|
||||
// This isn't an option but a docstring
|
||||
KALOPT_DOCSTR = (1 << 3),
|
||||
|
||||
// Only show in long help messages
|
||||
KALOPT_LONGDOC = (1 << 4),
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Flags for KalParse(CmdLine|ArgVec)
|
||||
//
|
||||
enum CmdParserFlags_t
|
||||
{
|
||||
// Don't exit on errors
|
||||
KALOPT_NO_EXIT = (1 << 0),
|
||||
|
||||
// Don't react to --help
|
||||
KALOPT_NO_HELP = (1 << 1),
|
||||
|
||||
// Don't react to --version
|
||||
KALOPT_NO_VERSION = (1 << 2),
|
||||
|
||||
// Alias -h for --help and -V for --version
|
||||
KALOPT_ALIASES = (1 << 3),
|
||||
|
||||
// Don't print any error message
|
||||
// Implies KALOPT_NO_EXIT
|
||||
KALOPT_NO_ERRORS = (1 << 4) | KALOPT_NO_EXIT,
|
||||
|
||||
// Use KalGetProgName() instead of argv[0]
|
||||
// as program name
|
||||
KALOPT_DONT_USE_ARGV0 = (1 << 5),
|
||||
|
||||
// Call argument parser for non-options
|
||||
// Non-options arguments will be indicated by
|
||||
// a key of 0, the argument passed as a parameter
|
||||
KALOPT_PARSE_ALL = (1 << 6),
|
||||
|
||||
// Call argument parser with options and non-options in the
|
||||
// order they were found, instead of parsing options first
|
||||
KALOPT_IN_ORDER = (1 << 7) | KALOPT_PARSE_ALL,
|
||||
|
||||
// Stay silent all along
|
||||
KALOPT_SILENT = KALOPT_NO_EXIT | KALOPT_NO_ERRORS
|
||||
| KALOPT_NO_HELP | KALOPT_NO_VERSION,
|
||||
};
|
||||
|
||||
//
|
||||
// Return values for the command parser
|
||||
// These flags can be combined and are applied in order
|
||||
//
|
||||
// "Continue" and "Break" actions do not prevent
|
||||
// later actions from applying
|
||||
//
|
||||
enum CmdParserReturn_t
|
||||
{
|
||||
// Continue parsing new options
|
||||
KALOPT_CONTINUE = 0,
|
||||
|
||||
// Stop parsing further options
|
||||
KALOPT_BREAK = (1 << 0),
|
||||
|
||||
// Show help/version message (by default, continue parsing)
|
||||
KALOPT_SHOWHELP = (1 << 1),
|
||||
KALOPT_SHOWVERS = (1 << 2),
|
||||
};
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
//
|
||||
// An option for a command, e.g. "-o file" in "cc -o file"
|
||||
//
|
||||
struct CmdOption_t
|
||||
{
|
||||
// The option's name, e.g. "help" for "--help"
|
||||
// May be 0, but only if letter is not zero
|
||||
const char *longName;
|
||||
|
||||
// The option's letter, e.g. 'h' for '-h'
|
||||
int letter;
|
||||
|
||||
// Address of the variable to put the parameter into
|
||||
const char *param;
|
||||
|
||||
// Option flags, see above
|
||||
CmdOptionFlag_t flags;
|
||||
|
||||
// The option's help text
|
||||
// If this is 0, this option is hidden
|
||||
const char *helpText;
|
||||
|
||||
// The option's group, for sorting during --help
|
||||
// Must be positive and < 256, or option won't shop up
|
||||
// during help texts
|
||||
int group;
|
||||
};
|
||||
|
||||
//
|
||||
// Program help/documentation strings; any can be 0
|
||||
//
|
||||
// Help messages are printed in this format:
|
||||
// (letting "this" be a CmdDocStrings_t* variable)
|
||||
//
|
||||
// Usage: (this->usage)
|
||||
// (this->header)
|
||||
//
|
||||
// (this->groups[0])
|
||||
// -o, --option-name option description
|
||||
// ...
|
||||
// ...
|
||||
//
|
||||
// (this->bottom)
|
||||
//
|
||||
// XXX progname/version
|
||||
//
|
||||
struct CmdDocStrings_t
|
||||
{
|
||||
const char *usage;
|
||||
const char *header;
|
||||
const char *bottom;
|
||||
|
||||
// Groups documentation
|
||||
// groups[n] should be either 0 or contain the
|
||||
// description of the option group n
|
||||
const char **groups;
|
||||
};
|
||||
|
||||
//
|
||||
// The state variable passed to the parser containing useful infos
|
||||
//
|
||||
struct CmdParserState_t {
|
||||
|
||||
// Option we're currently parsing
|
||||
const CmdOption_t *option;
|
||||
|
||||
// Index (in argv) of the option we're parsing
|
||||
int argvIndex;
|
||||
|
||||
// Flags passed to KalParse(CmdLine|ArgV)
|
||||
CmdParserFlags_t flags;
|
||||
|
||||
// Has help/version messages been displayed already?
|
||||
bool shownHelp;
|
||||
bool shownVersion;
|
||||
|
||||
// Output streams (may be NULL)
|
||||
/*FILE*/ void *outStream;
|
||||
/*FILE*/ void *errStream;
|
||||
|
||||
// Private, internal data; do not touch
|
||||
void *priv;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// The argument parser function
|
||||
//
|
||||
typedef CmdParserReturn_t (*CmdParser_t)(int key,
|
||||
const char *param,
|
||||
CmdParserState_t *state);
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
//
|
||||
// Misc. simple functions
|
||||
//
|
||||
int KalComputeArgCount(const char **argv);
|
||||
size_t KalComputeArgVecSize(const char **argv);
|
||||
|
||||
//
|
||||
// Command line to argument vector
|
||||
//
|
||||
error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr,
|
||||
bool doEscaping);
|
||||
|
||||
//
|
||||
// KalCmdLineToArgVecEx but doEscaping = false
|
||||
//
|
||||
error_t KalCmdLineToArgVec(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr);
|
||||
|
||||
//
|
||||
// Argument vector to command line
|
||||
//
|
||||
error_t KalArgVecToCmdLineEx(char *cmdLine,
|
||||
size_t lengthMax,
|
||||
int argc,
|
||||
const char **argv,
|
||||
bool doUnEscaping);
|
||||
|
||||
//
|
||||
// KalArgVecToCmdLineEx but doUnEscapign = false
|
||||
//
|
||||
error_t KalArgVecToCmdLine(char *cmdLine,
|
||||
size_t lengthMax,
|
||||
int argc,
|
||||
const char **argv);
|
||||
//
|
||||
// Command line parser; only takes an argument vector
|
||||
// The argv argument *will* be modified and all parsed
|
||||
// options and arguments will be removed, except argv[0]
|
||||
// which is guanranteed to be left
|
||||
//
|
||||
error_t KalParseArgVecEx(int argc,
|
||||
char **argv,
|
||||
const CmdOption_t *options,
|
||||
const CmdDocStrings_t *docStrings,
|
||||
CmdParserFlags_t *flags,
|
||||
CmdParser_t *parser,
|
||||
/*FILE*/ void *outStream,
|
||||
/*FILE*/ void *errStream);
|
||||
//
|
||||
// KalParseArgVecEx(argc, argv, options, docString, stdin, stdout, parser, NULL)
|
||||
//
|
||||
error_t KalParseArgVec(int argc,
|
||||
char **argv,
|
||||
const CmdOption_t *options,
|
||||
const CmdDocStrings_t *docStrings,
|
||||
CmdParserFlags_t *flags,
|
||||
CmdParser_t *parser);
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -26,6 +26,10 @@
|
|||
#include <kernel.h>
|
||||
#endif
|
||||
|
||||
#ifndef MULTIBOOT_HEADER
|
||||
#include <init/mboot.h>
|
||||
#endif
|
||||
|
||||
#ifndef _INIT_BOOT_H
|
||||
#define _INIT_BOOT_H
|
||||
|
||||
|
@ -115,4 +119,9 @@ extern volatile BootInfo_t BtBootTab;
|
|||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
void BtDoSanityChecks(uint);
|
||||
void BtInitBootInfo(multiboot_info_t *, void *);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,15 +58,14 @@ extern const char *RtlColorNames[VGA_COLOR_WHITE+1];
|
|||
#define RtlColorToChar(c) ((c) + 130)
|
||||
#define RtlCharToColor(c) ((c) - 130)
|
||||
|
||||
void IoScrollDown(void);
|
||||
uint IoGetScroll(void);
|
||||
void IoScrollUp(void);
|
||||
void IoScrollDown(void);
|
||||
|
||||
void IoChangeTermColor(int, int);
|
||||
|
||||
error_t IoInitVGABuffer(void);
|
||||
|
||||
uint IoGetScroll(void);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
|
|
@ -165,7 +165,9 @@ extern CpuCore_t _KeCPUTable[NCPUS];
|
|||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _ASM_H
|
||||
#include <asm.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Command line parsing utilities //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
// //
|
||||
// This file is part of OS/K. //
|
||||
// //
|
||||
// OS/K is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// any later version. //
|
||||
// //
|
||||
// OS/K is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KERNEL_H
|
||||
#include <kernel.h>
|
||||
#endif
|
||||
|
||||
#ifndef _SH_ARGV_H
|
||||
#define _SH_ARGV_H
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
// See kaleid/sh/argv.h
|
||||
#define ARG_MAX (1 << 16) // 64 KB
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
//
|
||||
// Command line to argument vector
|
||||
// Assumes sizeof(bufptr) >= ARG_MAX * 2
|
||||
//
|
||||
error_t ShCmdLineToArgVecEx(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr,
|
||||
bool doEscaping);
|
||||
|
||||
//
|
||||
// ShCmdLineToArgVecEx but doEscaping = false
|
||||
//
|
||||
error_t ShCmdLineToArgVec(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr);
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Kernel entry point //
|
||||
// Desc: Kernel shell //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
|
@ -22,33 +22,38 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <init/mboot.h>
|
||||
#include <lib/buf.h>
|
||||
#include <ke/time.h>
|
||||
#include <ke/idt.h>
|
||||
#include <io/spkr.h>
|
||||
#include <io/keyb.h>
|
||||
#include <io/cursor.h>
|
||||
#include <po/shtdwn.h>
|
||||
#include <mm/heap.h>
|
||||
#include <mm/mm.h>
|
||||
#include <io/vga.h>
|
||||
#include <ke/cpuid.h>
|
||||
#include <io/ata.h>
|
||||
#ifndef _KERNEL_H
|
||||
#include <kernel.h>
|
||||
#endif
|
||||
|
||||
// info.c
|
||||
extern void BtDoSanityChecks(uint mbMagic);
|
||||
extern void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg);
|
||||
#ifndef _SH_SHELL_H
|
||||
#define _SH_SHELL_H
|
||||
|
||||
// io/vga.c
|
||||
extern error_t IoInitVGABuffer(void);
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// ke/shell.c
|
||||
extern void KeStartShell(void);
|
||||
void ShStartShell(void);
|
||||
|
||||
// ps/proc.c test function
|
||||
extern void pstest(void);
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// interrupts tests
|
||||
extern void divideByZero(void);
|
||||
#define CMDBUFSIZE 256
|
||||
|
||||
typedef struct Command_t Command_t;
|
||||
|
||||
struct Command_t
|
||||
{
|
||||
const char *name;
|
||||
error_t (*func)(int argc, char **argv, char *cmdline);
|
||||
const char *help;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
extern int shcol;
|
||||
extern int shargc;
|
||||
extern char **shargv;
|
||||
extern Command_t shcmdtable[];
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
||||
|
|
@ -23,7 +23,6 @@
|
|||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <init/boot.h>
|
||||
#include <init/mboot.h>
|
||||
|
||||
//
|
||||
// BootInfo_t initialization. It is necessary because grub will potentially be
|
||||
|
|
|
@ -22,7 +22,17 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "init.h"
|
||||
#include <mm/mm.h>
|
||||
#include <mm/heap.h>
|
||||
#include <ke/idt.h>
|
||||
#include <ke/time.h>
|
||||
#include <ke/cpuid.h>
|
||||
#include <sh/shell.h>
|
||||
#include <io/vga.h>
|
||||
#include <io/keyb.h>
|
||||
#include <io/cursor.h>
|
||||
#include <po/shtdwn.h>
|
||||
#include <init/boot.h>
|
||||
|
||||
//
|
||||
// Entry point of the Kaleid kernel
|
||||
|
@ -66,7 +76,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
|||
IoEnableKeyb();
|
||||
MmActivatePageHandler();
|
||||
|
||||
KeStartShell();
|
||||
ShStartShell();
|
||||
|
||||
PoShutdown();
|
||||
}
|
||||
|
|
|
@ -22,37 +22,9 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <ex/argv.h>
|
||||
#include <sh/argv.h>
|
||||
#include <ex/malloc.h>
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
//
|
||||
// Computes argument count, the least N such
|
||||
// that argv[N] == NULL
|
||||
//
|
||||
int KalComputeArgCount(const char **argv)
|
||||
{
|
||||
int argc = 0;
|
||||
|
||||
while (argv[argc]) argc++;
|
||||
|
||||
return argc;
|
||||
}
|
||||
|
||||
//
|
||||
// Computes the total size of argv, including
|
||||
// the null-terminators
|
||||
//
|
||||
size_t KalComputeArgVecSize(const char *argv[])
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = 0; *argv; len += strlen(*argv) + 1, argv++);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts command line to an argument vector
|
||||
//
|
||||
|
@ -61,13 +33,10 @@ size_t KalComputeArgVecSize(const char *argv[])
|
|||
// with the address of the nth string stored in the first half,
|
||||
// specifically at argv[n-1]
|
||||
//
|
||||
// TODO long escape sequences
|
||||
// get program command line if cmdLine == NULL
|
||||
//
|
||||
error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr,
|
||||
bool doEscaping)
|
||||
error_t ShCmdLineToArgVecEx(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr,
|
||||
bool doEscaping)
|
||||
{
|
||||
int argc = 0;
|
||||
char quotes = 0;
|
||||
|
@ -213,9 +182,9 @@ error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
|||
#undef ISBLANK
|
||||
#undef NULLTERM_AND_SAVE
|
||||
|
||||
error_t KalCmdLineToArgVec(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr)
|
||||
error_t ShCmdLineToArgVec(const char *cmdLine,
|
||||
int *argcPtr,
|
||||
char *bufptr)
|
||||
{
|
||||
return KalCmdLineToArgVecEx(cmdLine, argcPtr, bufptr, false);
|
||||
return ShCmdLineToArgVecEx(cmdLine, argcPtr, bufptr, false);
|
||||
}
|
|
@ -22,7 +22,10 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "shell.h"
|
||||
#include <io/vga.h>
|
||||
#include <mm/heap.h>
|
||||
#include <sh/shell.h>
|
||||
#include <init/boot.h>
|
||||
|
||||
error_t CmdMemUsage(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
|
|
|
@ -22,8 +22,15 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#include <vers.h>
|
||||
#include <mm/mm.h>
|
||||
#include <io/ata.h>
|
||||
#include <io/vga.h>
|
||||
#include <io/spkr.h>
|
||||
#include <ke/time.h>
|
||||
#include <lib/buf.h>
|
||||
#include <sh/shell.h>
|
||||
#include <po/shtdwn.h>
|
||||
|
||||
int ShAtoi(char* str)
|
||||
{
|
||||
|
@ -173,7 +180,7 @@ error_t CmdHelp(int argc, char **argv, char *cmdline)
|
|||
|
||||
if (argc == 1) {
|
||||
KernLog("List of all shell built-ins:\n");
|
||||
for (cmd = cmdtable; cmd->name != NULL; cmd++, count++) {
|
||||
for (cmd = shcmdtable; cmd->name != NULL; cmd++, count++) {
|
||||
KernLog("\t%s", cmd->name);
|
||||
for (i = strlen(cmd->name)/4; i<3; i++) {
|
||||
KernLog("\t");
|
||||
|
@ -224,7 +231,7 @@ error_t CmdReloadPage(int argc, char **argv, char *cmdline)
|
|||
|
||||
error_t CmdShell(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
KeStartShell();
|
||||
ShStartShell();
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
@ -285,7 +292,8 @@ error_t CmdVersion(int argc, char **argv, char *cmdline)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
Command_t cmdtable[] =
|
||||
|
||||
Command_t shcmdtable[] =
|
||||
{
|
||||
{ "args", CmdArgs, "Print command line" },
|
||||
{ "beep", CmdBeep, "Make a beep" },
|
||||
|
|
|
@ -22,15 +22,21 @@
|
|||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
int shcol = VGA_COLOR_LIGHT_GREY;
|
||||
#include <io/vga.h>
|
||||
#include <io/keyb.h>
|
||||
#include <io/spkr.h>
|
||||
#include <lib/buf.h>
|
||||
#include <sh/argv.h>
|
||||
#include <sh/shell.h>
|
||||
#include <po/shtdwn.h>
|
||||
|
||||
int shargc = 0;
|
||||
char *argvbuf = 0;
|
||||
char **shargv = 0;
|
||||
int shcol = VGA_COLOR_LIGHT_GREY;
|
||||
|
||||
void ExecuteCommand(char *cmdbuf)
|
||||
static char *argvbuf = 0;
|
||||
|
||||
static void ExecuteCommand(char *cmdbuf)
|
||||
{
|
||||
error_t rc;
|
||||
Command_t *cmd;
|
||||
|
@ -40,10 +46,10 @@ void ExecuteCommand(char *cmdbuf)
|
|||
return;
|
||||
|
||||
memzero(*shargv, ARG_MAX);
|
||||
rc = KalCmdLineToArgVec(cmdbuf, &shargc, argvbuf);
|
||||
rc = ShCmdLineToArgVec(cmdbuf, &shargc, argvbuf);
|
||||
if (rc) KeStartPanic("Shell: Couldn't parse command line: %d", rc);
|
||||
|
||||
for (cmd = cmdtable; cmd->name != NULL; cmd++) {
|
||||
for (cmd = shcmdtable; cmd->name != NULL; cmd++) {
|
||||
if (!strcmp(cmd->name, shargv[0])) {
|
||||
cmd->func(shargc, shargv, cmdbuf);
|
||||
found = true;
|
||||
|
@ -59,7 +65,7 @@ void ExecuteCommand(char *cmdbuf)
|
|||
}
|
||||
}
|
||||
|
||||
void KeStartShell(void)
|
||||
void ShStartShell(void)
|
||||
{
|
||||
uchar ch;
|
||||
error_t rc;
|
||||
|
|
|
@ -32,29 +32,9 @@
|
|||
#include <mm/heap.h>
|
||||
#include <io/spkr.h>
|
||||
#include <io/keyb.h>
|
||||
#include <io/vga.h>
|
||||
#include <po/shtdwn.h>
|
||||
#include <ke/cpuid.h>
|
||||
#include <io/ata.h>
|
||||
|
||||
void KeStartShell(void);
|
||||
void pstest(void);
|
||||
|
||||
extern int shcol;
|
||||
extern int shargc;
|
||||
extern char *argv0;
|
||||
extern char **shargv;
|
||||
|
||||
#define CMDBUFSIZE 256
|
||||
|
||||
typedef struct Command_t Command_t;
|
||||
|
||||
struct Command_t
|
||||
{
|
||||
const char *name;
|
||||
error_t (*func)(int argc, char **argv, char *cmdline);
|
||||
const char *help;
|
||||
};
|
||||
|
||||
extern Command_t cmdtable[];
|
||||
|
||||
|
|
Loading…
Reference in New Issue