//----------------------------------------------------------------------------// // GNU GPL OS/K // // // // Desc: Kernel shell // // // // // // 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 . // //----------------------------------------------------------------------------// #include "shell.h" Command_t cmdtable[] = { { "beep", CmdBeep, "Make a beep" }, { "exit", CmdQuit, "Initiate shutdown" }, { "help", CmdHelp, "Show this message" }, { "quit", CmdQuit, "Alias for 'exit'" }, { NULL, NULL, NULL } }; error_t CmdBeep(int argc, char **argv, char *cmdline) { if (rand() % 64 == 0 || (argc > 1 && !strcmp(argv[1], "starwars"))) { IoDoStarWars(); } else IoDoBeep(); return EOK; } error_t CmdQuit(int argc, char **argv, char *cmdline) { PoShutdownQemu(); return EOK; } error_t CmdHelp(int argc, char **argv, char *cmdline) { uint count = 0; Command_t *cmd; if (argc == 1) { KernLog("List of all shell built-ins:\n"); for (cmd = cmdtable; cmd->name != NULL; cmd++, count++) { KernLog("\t%s\t%s\n", cmd->name, cmd->help); } KernLog("End of list; %u commands total\n\n", count); } return EOK; }