Espresso 0.0.2c
This commit is contained in:
48
drivers/exec/secf.c
Normal file
48
drivers/exec/secf.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Simple Executable Code Format
|
||||
|
||||
SECF is a executable format for any platform (though designed with x86(-32) in mind.)
|
||||
that makes use of registers, syscalls/interrupts, and other tables/structures instead of libraries.
|
||||
|
||||
register map:
|
||||
(unused means the program can use the register without any issue, no data used/passed by the SECF will be there)
|
||||
|
||||
EAX: unused
|
||||
EBX: unused
|
||||
ECX: arg string length
|
||||
EDX: variable area size (bytes)
|
||||
ESI: pointer to arg string
|
||||
EDI: unused
|
||||
ESP: unused, normal function
|
||||
EBP: pointer to variable area
|
||||
|
||||
|
||||
|
||||
The variable area is a area of a specific size (size in EDX) that can be used for storing variables/temporary data.
|
||||
Any additional memory space needed can be aquired via malloc.
|
||||
The minimum size of the variable area is 16 bytes and a maximum size of 64KiB.
|
||||
|
||||
|
||||
Use syscall/int (number TBT) to call functions
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void* init_var_area(size_t size)
|
||||
{
|
||||
if (size == (size_t) 0)
|
||||
{
|
||||
return NULL; /* size 0 is invalid. */
|
||||
}
|
||||
else if (size >= 65536)
|
||||
{
|
||||
return NULL; /* size above 65,536 is invalid. */
|
||||
}
|
||||
else if (size < 16)
|
||||
{
|
||||
size = 16;
|
||||
}
|
||||
|
||||
return malloc(size); /* No need to check for null because we'd return null in that case */
|
||||
}
|
||||
Reference in New Issue
Block a user