| View previous topic :: View next topic |
| Author |
Message |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Tue Nov 11, 2008 3:26 am Post subject: Kernel mode malloc library |
|
|
Here is a bit modified library to use normally the malloc function in kernel mode!
The library was writed by Hellcat, I've only compiled and a bit modified it!
Maybe anyone can add this or another library to use the malloc functions in kernel mode to svn...
Can be useful!
http://www.megaupload.com/?d=3EEF4F71 |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Wed Nov 12, 2008 7:06 am Post subject: |
|
|
Great stuff
But MallocList[32] is a table limitted to 32 entry and in the malloc code
there is no code present to handle if more than 32 malloc has been asked
so memory corruption ;)
Another question : what is the purpose of the flag PSP_SMEM_Low ?
reserve memory compatible FAT & SLIM aka < 32 Méga ? |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Thu Nov 13, 2008 4:11 am Post subject: |
|
|
| PSP_SMEM_Low have no purpose, it search for a free area and allocate the memory from the lowest memory available address, it works for the Slims only if you compile your program with PSP_LARGE_MEMORY = 1! |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Thu Nov 13, 2008 4:21 am Post subject: |
|
|
| I'm rewriting the library to resolve this "array overflow" problem! |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Thu Nov 13, 2008 5:21 am Post subject: |
|
|
I've rewrited it using a dinamical list, I've tryed it and it works, but can anyone try this? I'm not really sure that it works perfect! Is not finished, I've to add some things...
http://www.megaupload.com/?d=4UYQ9TB6
Anyway, how to printf with kernel libc??
There's a way to do it? I won't use formatting... |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Thu Nov 13, 2008 8:13 am Post subject: |
|
|
Tested but why are you doing 2 allocations you can per alloc allocated 1 block
the list struct + the memory size asked.
example i do a malloc of 1024 the strucutre of the list is let say 16 bytes
i do one alloc of 16 bytes+1024 in the first bytes i put the next pointer and the id
and i return adrs allocate+16 to the application ;)
And another thing when you do a allocation always check de return code
if you've got a error (like out of memory) return null. Even with a linked list
you must be aware of error that can occur with the OS of the psp |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Thu Nov 13, 2008 1:51 pm Post subject: |
|
|
I don't mean to bash, but the last thing you need in the kernel partition is a contiguous lump of pre-allocated memory, half of which will probably lie unused by the application.
Either stick to allocating your bytes as an when you need them with the SCE functions, or allocate an intelligently calculated lump of memory and split it up yourself.
Otherwise you'll end with with ppl writing kernel plugins with PSP_HEAP_SIZE_KB(2048) and crap like that. |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Fri Nov 14, 2008 12:24 am Post subject: |
|
|
| sauron_le_noir, yes, I've to add some check and improve the code, this is because I've writed "Is not finished, I've to add some things... "! |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Fri Nov 14, 2008 1:14 am Post subject: |
|
|
Ok, I've improved it to allocate one memory block, it works for me...
Take a look in the src, maybe there's something wrong...
http://www.megaupload.com/?d=EJTU4K1K |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Sat Nov 15, 2008 4:15 am Post subject: |
|
|
Lets start with the basics , first ...
Your code looks like you have messed up linked lists with dynamic arrays ...mixed together , somehow... |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Sat Nov 15, 2008 5:07 am Post subject: |
|
|
| Everyone can correct the code... |
|
| Back to top |
|
 |
|