beep and commands
This commit is contained in:
parent
1213055aff
commit
df479e6336
|
@ -25,6 +25,8 @@
|
|||
#include <ex/argv.h>
|
||||
#include <ex/malloc.h>
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
//
|
||||
// Computes argument count, the least N such
|
||||
// that argv[N] == NULL
|
||||
|
@ -75,7 +77,7 @@ error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
|||
char **argv,
|
||||
bool doEscaping)
|
||||
{
|
||||
int argc;
|
||||
int argc = 0;
|
||||
char quotes = 0;
|
||||
bool started = false;
|
||||
bool escaping = false;
|
||||
|
@ -92,7 +94,7 @@ error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
|||
// Macro'd to avoid copypasting code
|
||||
#define NULLTERM_AND_SAVE \
|
||||
*buffer = 0; \
|
||||
argv[++argc] = buffer++ + 1; \
|
||||
argv[++argc] = ++buffer; \
|
||||
written += sizeof(char *) + 1; \
|
||||
|
||||
// Is character a blank character?
|
||||
|
@ -106,7 +108,7 @@ error_t KalCmdLineToArgVecEx(const char *cmdLine,
|
|||
|
||||
|
||||
// Go through the command line
|
||||
for (argc = 0; *cmdLine; cmdLine++) {
|
||||
for (; *cmdLine; cmdLine++) {
|
||||
|
||||
// Make sure we don't go beyond ARG_MAX bytes
|
||||
if (written >= ARG_MAX - (1 + sizeof(char *))) {
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
void IoStartSpeaker(int freq)
|
||||
{
|
||||
char temp;
|
||||
int pitf = 1193180 / freq;
|
||||
uchar temp;
|
||||
uint pitf = 1193180 / freq;
|
||||
|
||||
ulong flags = KePauseIRQs();
|
||||
IoWriteByteOnPort(0x43, 0xB6);
|
||||
IoWriteByteOnPort(0x42, (char)pitf);
|
||||
IoWriteByteOnPort(0x42, (char)(pitf >> 8));
|
||||
IoWriteByteOnPort(0x42, (uchar)pitf);
|
||||
IoWriteByteOnPort(0x42, (uchar)(pitf >> 8));
|
||||
|
||||
temp = IoReadByteFromPort(0x61);
|
||||
if (temp != (temp | 3)) {
|
||||
|
@ -44,14 +44,9 @@ void IoStartSpeaker(int freq)
|
|||
|
||||
void IoQuietSpeaker(void)
|
||||
{
|
||||
ulong flags = KePauseIRQs();
|
||||
IoWriteByteOnPort(0x61, IoReadByteFromPort(0x61) & 0xFC);
|
||||
}
|
||||
|
||||
void IoDoBeep(void)
|
||||
{
|
||||
IoStartSpeaker(1000);
|
||||
KeDelayExecution(100);
|
||||
IoQuietSpeaker();
|
||||
KeRestoreIRQs(flags);
|
||||
}
|
||||
|
||||
void IoDoTone(uint tone, uint time)
|
||||
|
@ -61,14 +56,21 @@ void IoDoTone(uint tone, uint time)
|
|||
IoQuietSpeaker();
|
||||
}
|
||||
|
||||
void IoDoBeep(void)
|
||||
{
|
||||
IoDoTone(1000, 100);
|
||||
}
|
||||
|
||||
void IoDoStarWars(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
struct Note {
|
||||
uint tone;
|
||||
uint time;
|
||||
};
|
||||
|
||||
struct Note Score[40] = { {440, 200}, {110, 200}, {440, 200}, {110, 200},
|
||||
struct Note score[] = { {440, 200}, {110, 200}, {440, 200}, {110, 200},
|
||||
{440, 200}, {110, 200}, {349, 140}, {87, 100},
|
||||
{523, 60}, {87, 100}, {440, 200}, {110, 200},
|
||||
{349, 140}, {87, 100}, {523, 60}, {87, 100},
|
||||
|
@ -81,8 +83,7 @@ void IoDoStarWars(void)
|
|||
{440, 200}, {110, 200}, {110, 200}, {110, 200}
|
||||
};
|
||||
|
||||
for (int i=0; i<40 ; i++) {
|
||||
IoDoTone(Score[i].tone, Score[i].time);
|
||||
KePauseCPU();
|
||||
for (i = 0; i < sizeof(score)/sizeof(struct Note); i++) {
|
||||
IoDoTone(score[i].tone, score[i].time);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,7 @@
|
|||
|
||||
error_t CmdBeep(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
if (rand() % 64 == 0 || (argc > 1 && !strcmp(argv[1], "starwars"))) {
|
||||
IoDoStarWars();
|
||||
}
|
||||
|
||||
else IoDoBeep();
|
||||
|
||||
IoDoBeep();
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
@ -240,6 +235,19 @@ error_t CmdPF(int argc, char **argv, char *cmdline)
|
|||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdArgs(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
int i;
|
||||
|
||||
KernLog("cmdline: '%s'\nargc: %d\n", cmdline, argc);
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
KernLog("argv[%d]: '%s'\n", i, argv[i]);
|
||||
}
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
void MmInitPaging(void);
|
||||
|
||||
error_t CmdReloadPage(int argc, char **argv, char *cmdline)
|
||||
|
@ -249,6 +257,13 @@ error_t CmdReloadPage(int argc, char **argv, char *cmdline)
|
|||
}
|
||||
|
||||
extern void KeStartShell(void);
|
||||
|
||||
error_t CmdShell(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
KeStartShell();
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdStackOverflow(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
CmdStackOverflow(0, 0, 0);
|
||||
|
@ -259,6 +274,7 @@ error_t CmdStackOverflow(int argc, char **argv, char *cmdline)
|
|||
|
||||
Command_t cmdtable[] =
|
||||
{
|
||||
{ "args", CmdArgs, "Print command line" },
|
||||
{ "beep", CmdBeep, "Make a beep" },
|
||||
{ "cls", CmdClear, "Clears standard output" },
|
||||
{ "date", CmdDate, "Print date" },
|
||||
|
@ -272,7 +288,8 @@ Command_t cmdtable[] =
|
|||
{ "pfault", CmdPF, "Provoke a PF. Usage : pfault <address>" },
|
||||
{ "pstest", CmdPsTest, "Scheduler test routine" },
|
||||
{ "quit", CmdQuit, "Alias for 'exit'" },
|
||||
{ "so", CmdStackOverflow, "Provoke a stack overflow" },
|
||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||
{ "time", CmdTime, "Print time" },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -96,7 +96,7 @@ void KeStartShell(void)
|
|||
break;
|
||||
|
||||
case KEY_BEL:
|
||||
if (rand() % 64 == 0) {
|
||||
if (rand() % 16 == 0) {
|
||||
IoDoStarWars();
|
||||
}
|
||||
else IoDoBeep();
|
||||
|
|
Loading…
Reference in New Issue