Okay, on further searching I came across pcmcia/k_compat.h
<http://xref.plausible.coop/source/xref/haiku/headers/os/drivers/pcmcia/k_compat.h>
It reads:
/* Memory allocation. BeOS doesn't have an atomic malloc. */
#define kmalloc(s,f) malloc(s)
#define kfree(p) free(p)
#define kfree_s(p,s) free(p)
void *malloc();
void free(void *);
So I should ignore all flags and just do a malloc(sizeof(kobj)) ?
On Wed, Jun 28, 2017 at 4:42 AM, Vivek Roy <vivekroyandroid@xxxxxxxxx>
wrote:
Okay, so I was trying to allocate physically non-contiguous memory. I was
looking at Kernel Kit's create_area() to be used in place of kzalloc.
A few things I noted (please let me know if I am wrong):
1. A call to kzalloc expects the memory to be zero-ed out. create_area
doesn't have any such flag so it has to be done by making a call to memset
(We can use memset on the memory returned from create_area right?)
2. I am using the B_ANY_KERNEL_ADDRESS constant for addr_spec parameter of
create_area
3. The size alllocated has to be a multiple of B_PAGE_SIZE. So for
allocating sizeof(kobj) bytes, I will have to allocate [(sizeof(kobj) +
B_PAGE_SIZE
- 1) / B_PAGE_SIZE] bytes of memory.
4. For locking constant I think B_LAZY_LOCK should be okay
5. Protection is B_READ_AREA | B_WRITE_AREA
Thanks