When you compile your kernel you could define a couple of bytes, or a couple of words even, like a boot signature scheme determines a valid bootsector, and stick it at the very end of your compiled kernel image. Start at address 0x00000000 and scan up, looking for that signature, counting from the start of your kernel. Increment counter at each byte, store somewhere how big your kernel is. Skip over BIOS/ROM areas at 640K, up to 1MB, which is address 0xFFFFF, click over at 0x100000 (XXX?) and that's the first byte over 1MB (I think) with which you can begin to allocate memory from. (Assuming your kernel is occupying all memory below 640K).
Are you using paging in your kernel? If so, you have all memory mapped into pages and you need a different algorithm to Pype.Clicker's, and it will need to allocate PAGE_SIZE chunks, usually 4KB in Intel arch systems. You can set the page size you want that is allowed by the Intel architecture. A process may like to ask for X bytes, and you can determine the number of free pages of memory the process will be allocated.
If no paging, e.g. segments, um, you can use a simple algorithm like Pype.Clicker's, that should work fine. You keep a list of free blocks of memory, allocate from there, stick the list of allocated blocks in an allocated memory list, and when the process exits, add the allocated blocks of that exited process back to the list of free blocks.
Let's say you aren't using paging, and simply setup a linked list with each node representing a block of say 4KB. Those in the list are allocated, and the list can be sorted, so the last block in the list plus one is your first block of free memory, do some sanity checks with the last 4KB block based on how much memory is in the system, add it to the list of allocated blocks, and return the pointer to the requesting process, and ... done. Well, that's a rather crude way of doing it. If you aren't using paging then those pointers are physical addresses. (XXX?)
Experienced kernel devers, can you correct any mistakes above?
These are some thoughts off the top of my head to hopefully get you thinking about possible ways to do this... have fun