2021-09-14 15:35:52 +00:00
|
|
|
#define hex(x) (x < 10) ? x+'0' : x-10+'a'
|
|
|
|
|
2021-09-14 15:34:14 +00:00
|
|
|
const char *apps_lst[] = {
|
2021-09-14 15:35:52 +00:00
|
|
|
/*0*/ "",
|
|
|
|
/*1*/ "reboot",
|
|
|
|
/*2*/ "osver",
|
|
|
|
/*3*/ "time",
|
|
|
|
/*4*/ "place",
|
|
|
|
/*5*/ "cls",
|
|
|
|
/*6*/ "dump",
|
|
|
|
/*7*/ "help",
|
|
|
|
/*8*/ "cpuid",
|
|
|
|
/*9*/ "memstat",
|
2021-09-14 15:46:50 +00:00
|
|
|
/*A*/ "read",
|
|
|
|
/*B*/ "mount",
|
|
|
|
/*C*/ "write"
|
2021-09-14 15:34:14 +00:00
|
|
|
};
|
2021-09-14 15:46:50 +00:00
|
|
|
int apps_count = 13;
|
2021-09-14 15:34:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void apps_osver()
|
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf ("%#0BC%#0CT%#0AA %#0F32bit Operating System v0.1\n\r");
|
|
|
|
cprintf ("(c) CTA 2010\n\r");
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void apps_time()
|
|
|
|
{
|
2021-09-14 15:46:50 +00:00
|
|
|
TIME _internal_clock = ClockGetTime();
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf ("Today is %#0F%s%#07, %#0F%u %#07of %#0F%s%#07, %#0F%u%u%#07.\n\r", clock_weekday[_internal_clock.weekday],
|
|
|
|
(unsigned) _internal_clock.day, clock_month[_internal_clock.month],
|
|
|
|
(unsigned) _internal_clock.century, (unsigned) _internal_clock.year);
|
|
|
|
cprintf ("%#07Now is %#0F%u%#87:%#0F%u%#87:%#0F%u%#07.\n\r", (unsigned) _internal_clock.hour,
|
|
|
|
(unsigned) _internal_clock.minute, (unsigned) _internal_clock.second);
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void apps_place()
|
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf ("%#0FOn your desk, %#07if you didn't notice... \n\r");
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void apps_clrscr()
|
|
|
|
{
|
|
|
|
clrscr();
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
void apps_dump(const int pn, const char* param[])
|
2021-09-14 15:34:14 +00:00
|
|
|
{
|
2021-09-14 15:46:50 +00:00
|
|
|
unsigned pause=0, i=0;
|
2021-09-14 15:34:14 +00:00
|
|
|
if (pn<3) {
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf ("%#0CCorrect syntax: %#07dump %#0F[start_address] %#0F[end_address] %#0C(in hex)\n\r");
|
2021-09-14 15:34:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-14 15:46:50 +00:00
|
|
|
if (pn==4 && strcmp(param[3], "--p") == 0)
|
|
|
|
pause=1;
|
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
unsigned char *start, *end;
|
|
|
|
start = (unsigned char *) atox (param[1]);
|
|
|
|
end = (unsigned char *) atox (param[2]);
|
|
|
|
unsigned char* count;
|
2021-09-14 15:34:14 +00:00
|
|
|
|
|
|
|
while (start <= end) {
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf("%#0D%x%#07: ", (unsigned int) start);
|
2021-09-14 15:34:14 +00:00
|
|
|
|
|
|
|
for (count = start; count < start+16; count++) {
|
2021-09-14 15:35:52 +00:00
|
|
|
if (*count == 0) cprintf ("%#0800 ");
|
|
|
|
else cprintf ("%#0F%c%c ", hex(*count/16), hex(*count%16));
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
2021-09-14 15:35:52 +00:00
|
|
|
|
|
|
|
cprintf(" ");
|
2021-09-14 15:34:14 +00:00
|
|
|
for (count = start; count < start+16; count++) {
|
2021-09-14 15:35:52 +00:00
|
|
|
if (*count < 32) cprintf(".");
|
|
|
|
else cprintf("%#0A%c", *count);
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf("\n\r");
|
2021-09-14 15:46:50 +00:00
|
|
|
start+=16; i++;
|
|
|
|
|
|
|
|
if ((i%22 == 0) && (pause==1)) {
|
|
|
|
cprintf("\n\r%#08Press %#07any key %#08to continue scrolling, %#07Esc %#08to exit.");
|
|
|
|
KeyboardKey t;
|
|
|
|
t = GetKey();
|
|
|
|
if (t.Scancode == KeyboardKeyEscape) return;
|
|
|
|
cprintf("\n\n\r");
|
|
|
|
}
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
2021-09-14 15:35:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int apps_help_sort(const void* a, const void* b)
|
|
|
|
{
|
|
|
|
return strcmp(apps_lst[*(short *)a], apps_lst[*(short *)b]);
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void apps_help(const int pn, const char* param[])
|
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
short arr[apps_count];
|
2021-09-14 15:34:14 +00:00
|
|
|
int i;
|
2021-09-14 15:35:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < apps_count; i++)
|
|
|
|
arr[i] = i;
|
|
|
|
|
|
|
|
qsort((void*)arr, apps_count, sizeof(short), apps_help_sort);
|
|
|
|
|
2021-09-14 15:34:14 +00:00
|
|
|
if (pn==1) {
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf("%#0BC%#0CT%#0AA %#0FShell %#07commands:\n\r");
|
|
|
|
for (i = 1; i < apps_count; i++)
|
|
|
|
cprintf("%#0F\t%c %s\n\r", 0x7 ,apps_lst[arr[i]]);
|
|
|
|
|
|
|
|
cprintf("\n\rUse help %#0E[command]%#07 for help on individual commands.\n\r");
|
2021-09-14 15:34:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; strcmp(apps_lst[i], param[1])!=0 && i<apps_count; i++);
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf("\n\r[%#0Bc%#0Ct%#0Aa %#0APreALphA%#07] Showing help for command: %#0E%s", apps_lst[i]);
|
|
|
|
|
|
|
|
// DESCRIPTION:
|
|
|
|
cprintf ("\n\r%#0FDescription:\t");
|
|
|
|
switch (i) {
|
|
|
|
case 1: cprintf("Restarts the system."); break;
|
|
|
|
case 2: cprintf("Shows information about the operating system."); break;
|
|
|
|
case 3: cprintf("Displays the current time and date."); break;
|
|
|
|
case 4: cprintf("%#08A little easter egg (shhhh... don't tell anyone."); break;
|
|
|
|
case 5: cprintf("Clears the screen.");break;
|
|
|
|
case 6: cprintf("Shows the virtual memory content between the specified\n\r\t\taddresses. ");break;
|
|
|
|
case 7: cprintf("Displays instructions for each command, or the list of\n\r\t\tcommands if none specified."); break;
|
|
|
|
case 8: cprintf("Shows the CPU's vendor."); break;
|
|
|
|
case 9: cprintf("Displays the current status of the memory, reported by\n\r\t\tthe memory manager."); break;
|
|
|
|
case 0xA: cprintf ("Reads one sector from floppy disk."); break;
|
|
|
|
default: cprintf("%#0CInvalid function, or help not implemented. "); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// USAGE:
|
|
|
|
cprintf ("\n\r%#0FUsage:\t\t");
|
|
|
|
switch (i) {
|
|
|
|
case 1: cprintf("reboot"); break;
|
|
|
|
case 2: cprintf("osver"); break;
|
|
|
|
case 3: cprintf("time"); break;
|
|
|
|
case 4: cprintf("%#08Nobody knows. And %#07nobody %#08should ever do."); break;
|
|
|
|
case 5: cprintf("cls"); break;
|
2021-09-14 15:46:50 +00:00
|
|
|
case 6: cprintf("dump %#0E[start] [end] %#0B(optional: --p to pause scrolling)"); break;
|
2021-09-14 15:35:52 +00:00
|
|
|
case 7: cprintf("help %#0E[command]"); break;
|
|
|
|
case 8: cprintf("cpuid"); break;
|
|
|
|
case 9: cprintf("memstat"); break;
|
|
|
|
case 0xA: cprintf("read %#0e[sector]"); break;
|
|
|
|
default: cprintf("%#0CInvalid function, or help not implemented. "); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTES:
|
|
|
|
cprintf ("\n\r%#0FNotes:\t");
|
2021-09-14 15:34:14 +00:00
|
|
|
switch (i) {
|
2021-09-14 15:35:52 +00:00
|
|
|
case 1: cprintf("\t%c Use wisely.", 0x7); break;
|
|
|
|
case 2: cprintf("%#08\t%c (None)", 0x7); break;
|
|
|
|
case 3: cprintf("%#08\t%c (None)", 0x7); break;
|
|
|
|
case 4: cprintf("%#08\t%c (None)", 0x7); break;
|
|
|
|
case 5: cprintf("%#08\t%c (None)", 0x7); break;
|
|
|
|
case 6: cprintf("\t%c %#0E[start]%#07 and %#0E[end]%#07 are virtual addresses in %#0Ahexadecimal%#07.", 0x7); break;
|
|
|
|
case 7: cprintf("\t%c The %#0E[command]%#07 parameter is optional.", 0x7); break;
|
|
|
|
case 8: cprintf("\t%c Shows CPU vendor returned by CPUID function.", 0x7); break;
|
|
|
|
case 9: cprintf("%#08\t%c (None)", 0x7); break;
|
|
|
|
case 0xA: cprintf("\t%c Sector is in decimal, starts from 0.", 0x7); break;
|
|
|
|
default: cprintf("%#0C\t%c Invalid function, or help not implemented. ", 0x7); break;
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf("\n\r");
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void apps_memory_status()
|
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
cprintf ("Memory available: %#0F%u KB \n\r", pmmngr_get_memory_size ());
|
|
|
|
cprintf ("Total blocks: %#0F%u %#07Used: %#0F%u %#07Free: %#0F%u\n\r", pmmngr_get_block_count (), pmmngr_get_use_block_count (), pmmngr_get_free_block_count ());
|
|
|
|
cprintf ("Block size: %#0F%u %#07bytes\n\rPaging is ", pmmngr_get_block_size());
|
|
|
|
cprintf ( pmmngr_is_paging() ? "%#0Aenabled%#07.\n\r" : "%#0Cdisabled%#07.\n\r");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void apps_read(const int pn, const char *param[])
|
|
|
|
{
|
2021-09-14 15:46:50 +00:00
|
|
|
static unsigned char buffer[0x170000];
|
2021-09-14 15:35:52 +00:00
|
|
|
if (pn <= 1) {
|
|
|
|
cprintf ("%#0CParameter missing: %#0F[sectorLBA]\n\r");
|
|
|
|
return;
|
|
|
|
}
|
2021-09-14 15:46:50 +00:00
|
|
|
FloppyReadSectors ((unsigned*) buffer, 0, atoi(param[1]), 2440);
|
|
|
|
cprintf ("All Sectors read, located at address %#0F0x%x.\n\r", buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void apps_write(const int pn, const char *param[])
|
|
|
|
{
|
|
|
|
unsigned char buffer[0x400];
|
|
|
|
|
|
|
|
memset(buffer, 0xC7, 0x200);
|
|
|
|
memset(&buffer[0x200], 0x21, 0x200);
|
|
|
|
|
|
|
|
if (pn <= 1) {
|
|
|
|
cprintf ("%#0CParameter missing: %#0F[sectorLBA]\n\r");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FloppyWriteSectors ((unsigned*) buffer, 0, atoi(param[1]), 2);
|
|
|
|
cprintf ("2 Sectors written.\n\r");
|
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 15:46:50 +00:00
|
|
|
/*void apps_mount()
|
|
|
|
{
|
|
|
|
FloppyMount(0);
|
|
|
|
}*/
|