1 /* $Id: palloc.c,v 1.4 1996/04/25 06:09:48 davem Exp $
2 * palloc.c: Memory allocation from the Sun PROM.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
7 #include <asm/openprom.h>
10 /* You should not call these routines after memory management
11 * has been initialized in the kernel, if fact you should not
12 * use these if at all possible in the kernel. They are mainly
13 * to be used for a bootloader for temporary allocations which
14 * it will free before jumping into the kernel it has loaded.
16 * Also, these routines don't work on V0 proms, only V2 and later.
19 /* Allocate a chunk of memory of size 'num_bytes' giving a suggestion
20 * of virtual_hint as the preferred virtual base address of this chunk.
21 * There are no guarantees that you will get the allocation, or that
22 * the prom will abide by your "hint". So check your return value.
25 prom_alloc(char *virtual_hint, unsigned int num_bytes)
27 if(prom_vers == PROM_V0) return (char *) 0x0;
28 if(num_bytes == 0x0) return (char *) 0x0;
29 return (*(romvec->pv_v2devops.v2_dumb_mem_alloc))(virtual_hint, num_bytes);
32 /* Free a previously allocated chunk back to the prom at virtual address
33 * 'vaddr' of size 'num_bytes'. NOTE: This vaddr is not the hint you
34 * used for the allocation, but the virtual address the prom actually
35 * returned to you. They may be have been the same, they may have not,
39 prom_free(char *vaddr, unsigned int num_bytes)
41 if((prom_vers == PROM_V0) || (num_bytes == 0x0)) return;
42 (*(romvec->pv_v2devops.v2_dumb_mem_free))(vaddr, num_bytes);