Added a way to manually test the Malloc function from the shell's command line.
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
#ifndef BUILD_NUMBER
|
#ifndef BUILD_NUMBER
|
||||||
#define BUILD_NUMBER "117"
|
#define BUILD_NUMBER "276"
|
||||||
#endif
|
#endif
|
||||||
#ifndef VERSION_STR
|
#ifndef VERSION_STR
|
||||||
#define VERSION_STR "0.0.2+117 - Sat Feb 9 21:35:00 CST 2019"
|
#define VERSION_STR "0.0.2+276 - Sat 31 Aug 2019 05:43:54 PM CDT"
|
||||||
#endif
|
#endif
|
||||||
#ifndef VERSION_STR_SHORT
|
#ifndef VERSION_STR_SHORT
|
||||||
#define VERSION_STR_SHORT "0.0.2+117"
|
#define VERSION_STR_SHORT
|
||||||
|
unsigned char* version_str_short = "0.0.2+276";
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ typedef struct MemoryChunk
|
|||||||
bool Allocated;
|
bool Allocated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct MemoryChunk* First;
|
||||||
|
|
||||||
void MemoryManager(size_t start, size_t size);
|
void MemoryManager(size_t start, size_t size);
|
||||||
|
|
||||||
void* Malloc(size_t size);
|
void* Malloc(size_t size);
|
||||||
|
|||||||
+2
-1
@@ -19,7 +19,8 @@ echo "#define VERSION_STR \"$version`sed 's/^ *//' build.number` - `date`\"" >>
|
|||||||
echo "#endif" >> include/buildnumber.h
|
echo "#endif" >> include/buildnumber.h
|
||||||
|
|
||||||
echo "#ifndef VERSION_STR_SHORT" >> include/buildnumber.h
|
echo "#ifndef VERSION_STR_SHORT" >> include/buildnumber.h
|
||||||
echo "#define VERSION_STR_SHORT \"$version`sed 's/^ *//' build.number`\"" >> include/buildnumber.h
|
echo "#define VERSION_STR_SHORT" >> include/buildnumber.h
|
||||||
|
echo "unsigned char* version_str_short = \"$version`sed 's/^ *//' build.number`\";" >> include/buildnumber.h
|
||||||
echo "#endif" >> include/buildnumber.h
|
echo "#endif" >> include/buildnumber.h
|
||||||
|
|
||||||
#echo "#ifndef COMPILE_DATE" >> include/buildnumber.h
|
#echo "#ifndef COMPILE_DATE" >> include/buildnumber.h
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ kernel.iso: kernel.bin
|
|||||||
mkdir iso/boot
|
mkdir iso/boot
|
||||||
mkdir iso/boot/grub
|
mkdir iso/boot/grub
|
||||||
cp obj/bin/kernel.bin iso/boot/kernel.bin
|
cp obj/bin/kernel.bin iso/boot/kernel.bin
|
||||||
echo 'menuentry SDOS {' > iso/boot/grub/grub.cfg
|
echo 'set timeout=0' > iso/boot/grub/grub.cfg
|
||||||
|
echo 'set default=0' >> iso/boot/grub/grub.cfg
|
||||||
|
echo '' >> iso/boot/grub/grub.cfg
|
||||||
|
echo 'menuentry "SDOS" {' >> iso/boot/grub/grub.cfg
|
||||||
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
|
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
|
||||||
echo ' boot' >> iso/boot/grub/grub.cfg
|
echo ' boot' >> iso/boot/grub/grub.cfg
|
||||||
echo '}' >> iso/boot/grub/grub.cfg
|
echo '}' >> iso/boot/grub/grub.cfg
|
||||||
|
|||||||
+87
-33
@@ -12,7 +12,7 @@ unsigned char *memcpy(unsigned char *dest, const unsigned char *src, int count)
|
|||||||
{
|
{
|
||||||
/* Add code here to copy 'count' bytes of data from 'src' to
|
/* Add code here to copy 'count' bytes of data from 'src' to
|
||||||
* 'dest', finally return 'dest' */
|
* 'dest', finally return 'dest' */
|
||||||
const char *sp = (const char *)src;
|
const char *sp = (const char *)src;
|
||||||
char *dp = (char *)dest;
|
char *dp = (char *)dest;
|
||||||
for(; count != 0; count--) *dp++ = *sp++;
|
for(; count != 0; count--) *dp++ = *sp++;
|
||||||
return dest;
|
return dest;
|
||||||
@@ -60,6 +60,18 @@ bool strcmp(char* str1, char* str2)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool strcmpstart(char* str1, char* str2)
|
||||||
|
{
|
||||||
|
int len2 = strlen(str2);
|
||||||
|
|
||||||
|
for(int i = 0; i < len2; i++)
|
||||||
|
{
|
||||||
|
if(str1[i] != str2[i]) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
//Code reference:
|
//Code reference:
|
||||||
//http://www.strudel.org.uk/itoa/
|
//http://www.strudel.org.uk/itoa/
|
||||||
char* int_to_string(unsigned int value, int base)
|
char* int_to_string(unsigned int value, int base)
|
||||||
@@ -82,25 +94,44 @@ char* int_to_string(unsigned int value, int base)
|
|||||||
return &buf[i+1];
|
return &buf[i+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not working
|
int string_to_int(char* str)
|
||||||
unsigned char strconcat(unsigned char *dest, unsigned char* src)
|
|
||||||
{
|
{
|
||||||
|
int i=0, sum=0;
|
||||||
|
|
||||||
|
while(str[i]!='\0'){
|
||||||
|
if(str[i]< 48 || str[i] > 57){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
sum = sum*10 + (str[i] - 48);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Not working
|
||||||
|
unsigned char strconcat(unsigned char* dest, unsigned char* src)
|
||||||
|
{
|
||||||
|
//char *temp = (char *)dest;
|
||||||
int dest_length = strlen(dest);
|
int dest_length = strlen(dest);
|
||||||
int src_length = strlen(src);
|
int src_length = strlen(src);
|
||||||
unsigned char* buffer = (unsigned char*)Malloc(dest_length + src_length + 1);
|
unsigned char* buffer = (unsigned char*)Malloc(1024);//dest_length + src_length + 1);
|
||||||
|
|
||||||
for(uint32_t i = 0; i < dest_length; i++)
|
for(uint32_t i = dest_length; i != 0; i--)
|
||||||
{
|
{
|
||||||
*buffer++ = dest[i];
|
buffer[i] = dest - i;
|
||||||
|
puts(dest--);
|
||||||
}
|
}
|
||||||
|
puts("\n");
|
||||||
for(uint32_t j = 0; j < src_length; j++)
|
for(uint32_t j = 0; j < src_length; j++)
|
||||||
{
|
{
|
||||||
*buffer++ = src[j];
|
buffer[j + dest_length - 1] = src + j;
|
||||||
|
puts(src--);
|
||||||
}
|
}
|
||||||
*buffer++ = '\0';
|
puts("\n");
|
||||||
|
return buffer;// - (dest_length + src_length + 1);
|
||||||
return *buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We will use this later on for reading from the I/O ports to get data
|
/* We will use this later on for reading from the I/O ports to get data
|
||||||
@@ -122,9 +153,21 @@ void outportb (unsigned short _port, unsigned char _data)
|
|||||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//extern void* _sys_stack;
|
||||||
|
|
||||||
extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
||||||
{
|
{
|
||||||
init_video();
|
init_video();
|
||||||
|
puts("Video initialized.\n");
|
||||||
|
register int base asm("ebp");
|
||||||
|
puts("Base pointer address: ");
|
||||||
|
puts(int_to_string(base, 10));
|
||||||
|
puts("\n");
|
||||||
|
register int pointer asm("esp");
|
||||||
|
puts("Instruction pointer address: 0x");
|
||||||
|
puts(int_to_string(pointer, 16));
|
||||||
|
puts("\n");
|
||||||
|
//Only for testing if the multiboot structure can be read or not.
|
||||||
if(multiboot_magic == 0x2BADB002)
|
if(multiboot_magic == 0x2BADB002)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -137,15 +180,16 @@ extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
|||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
else if (multiboot_magic == 0x36d76289)
|
else if (multiboot_magic == 0x36d76289)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html
|
https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html
|
||||||
*/
|
*/
|
||||||
puts("Multiboot 2 compliant bootloader detected.\n");
|
puts("Multiboot 2 compliant bootloader detected.\n");
|
||||||
}
|
//panic();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
puts("Unkown bootloader magic number detected:");
|
puts("Unkown bootloader magic number detected: ");
|
||||||
puts(int_to_string(multiboot_magic, 16));
|
puts(int_to_string(multiboot_magic, 16));
|
||||||
puts("\n");
|
puts("\n");
|
||||||
//panic();
|
//panic();
|
||||||
@@ -158,27 +202,36 @@ extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
|||||||
puts(int_to_string((*videoBuffer), 16));
|
puts(int_to_string((*videoBuffer), 16));
|
||||||
puts("\n");
|
puts("\n");
|
||||||
uint32_t* totalMem = (uint32_t*)(((size_t)multiboot_structure) + 8);
|
uint32_t* totalMem = (uint32_t*)(((size_t)multiboot_structure) + 8);
|
||||||
puts(int_to_string((*totalMem), 10));
|
puts(int_to_string((*totalMem) * 1024, 10));
|
||||||
puts(" kilobytes of RAM installed on the system\n");
|
puts(" kilobytes of RAM installed on the system\n");
|
||||||
puts("Video initialized.\n");
|
|
||||||
gdt_install();
|
gdt_install();
|
||||||
puts("Global Descriptor Table initialized.\n");
|
puts("Global Descriptor Table initialized.\n");
|
||||||
//size_t heap = 10 * 1024 * 1024;
|
//Set a new heap to the same size as the total system memory, in bytes.
|
||||||
//MemoryManager(heap, (*memupper)*1024 - heap - 10*1024); //second needs to be an address not size
|
size_t heap = ((*totalMem) - 10240) * 1024;
|
||||||
//puts("heap: 0x");
|
MemoryManager(heap, heap);//(*totalMem)*1024 - heap - 10*1024); //second needs to be an address not size
|
||||||
//puts(strconcat(int_to_string(heap, 16), "\n"));
|
//puts("Mem lower: 0x");
|
||||||
|
//puts(int_to_string(*(uint32_t*)(((size_t)multiboot_structure) + 4), 10));
|
||||||
|
puts("Heap size: ");
|
||||||
|
puts(int_to_string(heap / 1024, 10));
|
||||||
|
puts(" in kilobytes.\n");
|
||||||
//struct MemoryChunk* allocated = (struct MemoryChunk*) Malloc(2048);
|
//struct MemoryChunk* allocated = (struct MemoryChunk*) Malloc(2048);
|
||||||
//size_t size = allocated->Next->Size;
|
//size_t size = allocated->Next->Size;
|
||||||
//if(allocated->Prev->Size) puts("Yes");
|
//if(First) puts("Yes");
|
||||||
//else puts("no");
|
//else puts("no");
|
||||||
//puts("\nAllocated: 0x");
|
puts("First next address: 0x");
|
||||||
//puts(int_to_string(size, 16));
|
puts(int_to_string(First->Next, 16));
|
||||||
//puts("\n");
|
//puts("\n");
|
||||||
|
puts("\nFirst Size: 0x");
|
||||||
|
puts(int_to_string(First->Size, 16));
|
||||||
|
puts("\n");
|
||||||
|
|
||||||
//void* al = Malloc(3096);
|
struct MemoryChunk* al = (struct MemoryChunk*) (Malloc(3096) - sizeof(struct MemoryChunk));
|
||||||
///puts("\nAllocated: 0x");
|
puts("AL size: (0x)");
|
||||||
//puts(int_to_string(al, 16));
|
puts(int_to_string(al->Size, 10));
|
||||||
//puts("\n");
|
puts("\n");
|
||||||
|
puts("First next address: 0x");
|
||||||
|
puts(int_to_string(First->Next, 16));
|
||||||
|
puts("\n");
|
||||||
|
|
||||||
idt_install();
|
idt_install();
|
||||||
puts("Interrupt Descriptor Table initialized.\n");
|
puts("Interrupt Descriptor Table initialized.\n");
|
||||||
@@ -187,15 +240,15 @@ extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
|||||||
irq_install();
|
irq_install();
|
||||||
__asm__ __volatile__ ("sti");
|
__asm__ __volatile__ ("sti");
|
||||||
puts("Interrupt Requests now allowed.\n");
|
puts("Interrupt Requests now allowed.\n");
|
||||||
//puts("Probing PCI subsystem for devices.\n");
|
puts("Probing PCI subsystem for devices.\n");
|
||||||
//EnumPCISubsystem();
|
EnumPCISubsystem();
|
||||||
//puts("Finished probing PCI subsystem.\n");
|
//puts("Finished probing PCI subsystem.\n");
|
||||||
//timer_install();
|
//timer_install();
|
||||||
//puts("Installed Timer.\n");
|
//puts("Installed Timer.\n");
|
||||||
kb_install();
|
kb_install();
|
||||||
puts("Keyboard installed.\n");
|
puts("Keyboard installed.\n");
|
||||||
puts("SDOS Version ");
|
puts("SDOS Version ");
|
||||||
puts(VERSION_STR_SHORT);
|
puts(version_str_short);
|
||||||
puts(" Initialized.\n");
|
puts(" Initialized.\n");
|
||||||
puts("Compile Date ");
|
puts("Compile Date ");
|
||||||
puts(__DATE__);
|
puts(__DATE__);
|
||||||
@@ -213,7 +266,8 @@ extern void main(uint32_t multiboot_magic, const void* multiboot_structure)
|
|||||||
//puts(5 / 0);
|
//puts(5 / 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void idle()
|
void idle(void)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__ ("hlt");
|
asm("hlt");
|
||||||
}
|
//__asm__ __volatile__ ("hlt");
|
||||||
|
}
|
||||||
|
|||||||
+31
-2
@@ -1,5 +1,6 @@
|
|||||||
#include "../include/memorymanager.h"
|
#include "../include/memorymanager.h"
|
||||||
#include "../include/system.h"
|
#include "../include/system.h"
|
||||||
|
#include "../include/scrn.h"
|
||||||
|
|
||||||
static struct MemoryChunk* First;
|
static struct MemoryChunk* First;
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ void MemoryManager(size_t start, size_t size)
|
|||||||
if(size < sizeof(struct MemoryChunk))
|
if(size < sizeof(struct MemoryChunk))
|
||||||
{
|
{
|
||||||
First = 0;
|
First = 0;
|
||||||
|
puts("First memory block is null\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +21,9 @@ void MemoryManager(size_t start, size_t size)
|
|||||||
First->Prev = 0;
|
First->Prev = 0;
|
||||||
First->Next = 0;
|
First->Next = 0;
|
||||||
First->Size = size - sizeof(struct MemoryChunk);
|
First->Size = size - sizeof(struct MemoryChunk);
|
||||||
|
puts("First block size ");
|
||||||
|
puts(int_to_string(First->Size, 10));
|
||||||
|
puts(" bytes.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Malloc(size_t size)
|
void* Malloc(size_t size)
|
||||||
@@ -28,7 +33,9 @@ void* Malloc(size_t size)
|
|||||||
for(struct MemoryChunk* chunk = First; chunk != 0 && freeChunk == 0; chunk = chunk->Next)
|
for(struct MemoryChunk* chunk = First; chunk != 0 && freeChunk == 0; chunk = chunk->Next)
|
||||||
{
|
{
|
||||||
if(chunk->Size > size && !chunk->Allocated)
|
if(chunk->Size > size && !chunk->Allocated)
|
||||||
|
{
|
||||||
freeChunk = chunk;
|
freeChunk = chunk;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(freeChunk == 0)
|
if(freeChunk == 0)
|
||||||
@@ -51,7 +58,9 @@ void* Malloc(size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
freeChunk->Allocated = true;
|
freeChunk->Allocated = true;
|
||||||
|
puts("Address of new chunk: 0x");
|
||||||
|
puts(int_to_string((size_t)freeChunk + sizeof(struct MemoryChunk), 16));
|
||||||
|
puts("\n");
|
||||||
return (void*)(((size_t) freeChunk) + sizeof(struct MemoryChunk));
|
return (void*)(((size_t) freeChunk) + sizeof(struct MemoryChunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,4 +76,24 @@ void Free(void* ptr)
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListBlocks()
|
||||||
|
{
|
||||||
|
struct MemoryChunk *freeChunk = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for(struct MemoryChunk* chunk = First; chunk != 0 && freeChunk == 0; chunk = chunk->Next)
|
||||||
|
{
|
||||||
|
puts("\nChunk ");
|
||||||
|
puts(int_to_string(count, 10));
|
||||||
|
puts(" is ");
|
||||||
|
puts(int_to_string(chunk->Size, 10));
|
||||||
|
puts(" bytes. Allocated? ");
|
||||||
|
if(chunk->Allocated)
|
||||||
|
puts("True");
|
||||||
|
else
|
||||||
|
puts("False");
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
uint32_t Read(uint16_t busNumber, uint16_t deviceNumber, uint16_t functionNumber, uint32_t registerOffset)
|
uint32_t Read(uint16_t busNumber, uint16_t deviceNumber, uint16_t functionNumber, uint32_t registerOffset)
|
||||||
{
|
{
|
||||||
puts("Read ");
|
//puts("Read ");
|
||||||
puts(int_to_string(functionNumber, 10));
|
//puts(int_to_string(functionNumber, 10));
|
||||||
puts("\n");
|
// puts("\n");
|
||||||
uint32_t id =
|
uint32_t id =
|
||||||
0x1 << 31
|
0x1 << 31
|
||||||
| ((busNumber & 0xFF) << 16)
|
| ((busNumber & 0xFF) << 16)
|
||||||
@@ -39,6 +39,7 @@ bool DeviceHasFunctions(uint16_t bus, uint16_t device)
|
|||||||
|
|
||||||
void EnumPCISubsystem()
|
void EnumPCISubsystem()
|
||||||
{
|
{
|
||||||
|
int lastId = 0;
|
||||||
for(int bus = 0; bus < 8; bus++)
|
for(int bus = 0; bus < 8; bus++)
|
||||||
{
|
{
|
||||||
for(int device = 0; device < 32; device++)
|
for(int device = 0; device < 32; device++)
|
||||||
@@ -53,7 +54,17 @@ void EnumPCISubsystem()
|
|||||||
dev = GetDeviceDescriptor(bus, device, function);
|
dev = GetDeviceDescriptor(bus, device, function);
|
||||||
|
|
||||||
if(dev.VendorId == 0x0000 || dev.VendorId == 0xFFFF)
|
if(dev.VendorId == 0x0000 || dev.VendorId == 0xFFFF)
|
||||||
|
{
|
||||||
|
puts("Vendor ID empty.\n");
|
||||||
break;//Break loop, no more funcitons.
|
break;//Break loop, no more funcitons.
|
||||||
|
}
|
||||||
|
else if(dev.VendorId != lastId)
|
||||||
|
{
|
||||||
|
puts("Vendor ID not empty: ");
|
||||||
|
puts(int_to_string(dev.VendorId, 10));
|
||||||
|
puts("\n");
|
||||||
|
lastId = dev.VendorId;
|
||||||
|
}
|
||||||
//puts("PCI BUS ");
|
//puts("PCI BUS ");
|
||||||
//puts(int_to_string(bus, 16));
|
//puts(int_to_string(bus, 16));
|
||||||
//puts("Device ");
|
//puts("Device ");
|
||||||
|
|||||||
+32
-8
@@ -9,10 +9,14 @@
|
|||||||
|
|
||||||
0.0.2.0: Fixed a bug allowing the user to delete all screen
|
0.0.2.0: Fixed a bug allowing the user to delete all screen
|
||||||
content by simply holding the backspace key.
|
content by simply holding the backspace key.
|
||||||
|
|
||||||
|
0.0.2.1: Added in the ability to manually call Malloc()
|
||||||
|
for testing purposes.
|
||||||
*/
|
*/
|
||||||
#include "../include/shell.h"
|
#include "../include/shell.h"
|
||||||
#include "../include/scrn.h"
|
#include "../include/scrn.h"
|
||||||
#include "../include/system.h"
|
#include "../include/system.h"
|
||||||
|
#include "../include/memorymanager.h"
|
||||||
|
|
||||||
static char* Prompt = "\n#>";
|
static char* Prompt = "\n#>";
|
||||||
|
|
||||||
@@ -44,17 +48,17 @@ void key_pressed(unsigned char* character)
|
|||||||
//Do not delete the shell prompt, simply return.
|
//Do not delete the shell prompt, simply return.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Otherwise clear the last character from the command
|
//Otherwise clear the last character from the command buffer.
|
||||||
//buffer.
|
|
||||||
commandbuffer[len - 1] = '\0';
|
commandbuffer[len - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
putch(character);
|
putch(character);
|
||||||
|
//putch(221);
|
||||||
}
|
}
|
||||||
|
|
||||||
void execmd()
|
void execmd()
|
||||||
{
|
{
|
||||||
proccess_command(commandbuffer);
|
//proccess_command(commandbuffer);
|
||||||
if(strlen(commandbuffer) == 0)
|
if(strlen(commandbuffer) == 0)
|
||||||
{
|
{
|
||||||
puts(Prompt);
|
puts(Prompt);
|
||||||
@@ -62,17 +66,37 @@ void execmd()
|
|||||||
}
|
}
|
||||||
if(strcmp(commandbuffer, "version"))
|
if(strcmp(commandbuffer, "version"))
|
||||||
{
|
{
|
||||||
puts("\nInteractive Shell Version 0.0.2.0");
|
puts("\nInteractive Shell Version 0.0.2.1");
|
||||||
}
|
}
|
||||||
else if(strcmp(commandbuffer,"cls"))
|
else if(strcmp(commandbuffer,"cls"))
|
||||||
{
|
{
|
||||||
cls();
|
cls();
|
||||||
}
|
}
|
||||||
|
else if(strcmp(commandbuffer, "list"))
|
||||||
|
{
|
||||||
|
ListBlocks();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
puts("\nUnknown command: ");
|
if(strcmpstart(commandbuffer, "malloc"))
|
||||||
puts(commandbuffer);
|
{
|
||||||
puts(".");
|
int length = strlen(commandbuffer);
|
||||||
|
static char string_num[32];
|
||||||
|
for(int i = 7; i <= length; i++)
|
||||||
|
{
|
||||||
|
string_num[i - 7] = commandbuffer[i];
|
||||||
|
}
|
||||||
|
string_num[(length - 8) + 1] = '\0';
|
||||||
|
|
||||||
|
int allocAmount = string_to_int(string_num);
|
||||||
|
Malloc(allocAmount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
puts("\nUnknown command: ");
|
||||||
|
puts(commandbuffer);
|
||||||
|
puts(".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
puts(Prompt);
|
puts(Prompt);
|
||||||
commandbuffer[0] = '\0';
|
commandbuffer[0] = '\0';
|
||||||
@@ -110,4 +134,4 @@ void proccess_command(char *text)
|
|||||||
puts('\n');
|
puts('\n');
|
||||||
puts(array[currentArrayIndex]);
|
puts(array[currentArrayIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user