This commit is contained in:
2021-09-14 18:46:50 +03:00
parent d605c6a016
commit b6ddeca1c3
180 changed files with 5909 additions and 2039 deletions

View File

@@ -11,9 +11,11 @@ const char *apps_lst[] = {
/*7*/ "help",
/*8*/ "cpuid",
/*9*/ "memstat",
/*A*/ "read"
/*A*/ "read",
/*B*/ "mount",
/*C*/ "write"
};
int apps_count = 11;
int apps_count = 13;
void apps_osver()
@@ -24,7 +26,7 @@ void apps_osver()
void apps_time()
{
TIME _internal_clock = i86_pit_get_time();
TIME _internal_clock = ClockGetTime();
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);
@@ -44,11 +46,15 @@ void apps_clrscr()
void apps_dump(const int pn, const char* param[])
{
unsigned pause=0, i=0;
if (pn<3) {
cprintf ("%#0CCorrect syntax: %#07dump %#0F[start_address] %#0F[end_address] %#0C(in hex)\n\r");
return;
}
if (pn==4 && strcmp(param[3], "--p") == 0)
pause=1;
unsigned char *start, *end;
start = (unsigned char *) atox (param[1]);
end = (unsigned char *) atox (param[2]);
@@ -69,7 +75,15 @@ void apps_dump(const int pn, const char* param[])
}
cprintf("\n\r");
start+=16;
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");
}
}
}
@@ -124,7 +138,7 @@ void apps_help(const int pn, const char* param[])
case 3: cprintf("time"); break;
case 4: cprintf("%#08Nobody knows. And %#07nobody %#08should ever do."); break;
case 5: cprintf("cls"); break;
case 6: cprintf("dump %#0E[start] [end]"); break;
case 6: cprintf("dump %#0E[start] [end] %#0B(optional: --p to pause scrolling)"); break;
case 7: cprintf("help %#0E[command]"); break;
case 8: cprintf("cpuid"); break;
case 9: cprintf("memstat"); break;
@@ -151,8 +165,6 @@ void apps_help(const int pn, const char* param[])
}
extern void detect_cpu();
void apps_memory_status()
{
cprintf ("Memory available: %#0F%u KB \n\r", pmmngr_get_memory_size ());
@@ -164,11 +176,32 @@ void apps_memory_status()
void apps_read(const int pn, const char *param[])
{
static unsigned char buffer[0x170000];
if (pn <= 1) {
cprintf ("%#0CParameter missing: %#0F[sectorLBA]\n\r");
return;
}
cprintf ("Sector read, located at address %#0F0x%x.\n\r", i86_read_sector ((unsigned*) 0x7E00, 0, atoi(param[1])));
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");
}
/*void apps_mount()
{
FloppyMount(0);
}*/

View File

@@ -2,7 +2,7 @@
rem NASM and DJGPP executable paths:
set nasm_path=C:\nasm
set djgpp_path=C:\DJGPP\bin
set djgpp_path=C:\mingw\bin
set objpath=..\objects
set incpath=../include

View File

@@ -1,10 +1,17 @@
#include <conio.h>
#include <hal.h>
#include <system.h>
#include <drivers/keyboard.h>
#include "../drivers/drivers.h"
#include "../drivers/cpu/cpu.h"
#include <drivers/floppy.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include "../memory/mmngr_ph.h"
#include "../drivers/filesys/fat.h"
#include "apps.h"
void shell()
{
apps_osver();
@@ -36,16 +43,18 @@ void shell()
for (i = 0; strcmp(apps_lst[i], param[0])!=0 && i<apps_count; i++);
switch (i) {
case 0: cprintf("%#0CYou must enter a command!\n\r"); break;
case 1: reboot();
case 1: SystemReboot();
case 2: apps_osver(); break;
case 3: apps_time(); break;
case 4: apps_place(); break;
case 5: apps_clrscr(); break;
case 6: apps_dump(params, (const char**)param); break;
case 7: apps_help(params, (const char**)param); break;
case 8: cprintf("%#0A%s\n\r", (char*)get_cpu_vender()); break;
case 8: cprintf("%#0A%s\n\r", (char*)i86_CpuGetVendor()); break;
case 9: apps_memory_status(); break;
case 10: apps_read (params, (const char**)param); break;
//case 11: apps_mount(); break;
case 12: apps_write (params, (const char**)param); break;
default: cprintf("%#0CInvalid function: %s\n\r", param[0]);
break;
}