[syslinux] Comboot Menu
H. Peter Anvin
hpa at zytor.com
Mon Jan 19 17:11:32 PST 2004
ganapathy murali krishnan wrote:
> So, the following should be a very simple memory manager?
>
>
> --- BEGIN PSEUDO CODE ---
>
> START = SS:SP+1 (1 byte above SS:SP)
> END = Value(DS:0002)-1
> myptr = pointer to START
>
> (void *) myalloc(int numbytes)
> {
> void * ans;
> ans = myptr;
> myptr = myptr + numbytes;
> }
>
> --- END PSEUDO CODE ---
>
> As long I never have to deallocated memory, the above should be a
> workable memory managing system?
>
No, that would trash your stack! Instead you need to do (DS+1000h):0 as
the beginning.
Instead you probably would want to do:
static void huge *myptr;
void farmalloc_init(void)
{
myptr = (void huge *)((unsigned long)(__DS + 0x1000) << 16);
}
void far * farmalloc(int bytes)
{
void far *ans;
ans = myptr;
myptr += bytes;
return ans;
}
More information about the Syslinux
mailing list