j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: blueswirl Date: 2009-08-02 13:05:16 +0200 (Sun, 02 Aug 2009) New Revision: 525
Modified: trunk/openbios-devel/include/ofmem.h trunk/openbios-devel/modules/build.xml Log: extract ofmem module implementation (Igor Kovalenko)
Modified: trunk/openbios-devel/include/ofmem.h =================================================================== --- trunk/openbios-devel/include/ofmem.h 2009-08-02 11:05:00 UTC (rev 524) +++ trunk/openbios-devel/include/ofmem.h 2009-08-02 11:05:16 UTC (rev 525) @@ -17,25 +17,88 @@ #ifndef _H_OFMEM #define _H_OFMEM
+#include "openbios/stack.h" + +typedef struct alloc_desc { + struct alloc_desc *next; + ucell size; /* size (including) this struct */ +} alloc_desc_t; + +typedef struct mem_range { + struct mem_range *next; + ucell start; + ucell size; +} range_t; + +typedef struct trans { + struct trans *next; + ucell virt; /* chain is sorted by virt */ + ucell size; + ucell phys; + ucell mode; +} translation_t; + +/* ofmem private data */ +typedef struct { + ucell ramsize; + char *next_malloc; + alloc_desc_t *mfree; /* list of free malloc blocks */ + + range_t *phys_range; + range_t *virt_range; + + translation_t *trans; /* this is really a translation_t */ +} ofmem_t; + +/* TODO: temporary migration interface */ +extern ofmem_t* ofmem_arch_get_private(void); +extern void* ofmem_arch_get_malloc_base(void); +extern ucell ofmem_arch_get_heap_top(void); +extern ucell ofmem_arch_get_virt_top(void); +extern ucell ofmem_arch_default_translation_mode( ucell phys ); +extern void ofmem_arch_early_map_pages(ucell phys, ucell virt, ucell size, + ucell mode); +extern void ofmem_arch_unmap_pages(ucell virt, ucell size); +/* sparc64 uses this method */ +extern int ofmem_map_page_range( ucell phys, ucell virt, ucell size, + ucell mode ); + +/* malloc interface */ +extern void* ofmem_malloc( size_t size ); +extern void ofmem_free( void *ptr ); +extern void* ofmem_realloc( void *ptr, size_t size ); + +/* ofmem_common.c */ + extern void ofmem_cleanup( void ); extern void ofmem_init( void );
-extern ucell ofmem_claim( ucell addr, ucell size, ucell align ); -extern ucell ofmem_claim_phys( ucell mphys, ucell size, ucell align ); -extern ucell ofmem_claim_virt( ucell mvirt, ucell size, ucell align ); +/* + * register /memory and /virtual-memory handles + * ofmem module will update "available" and "translations" properties + * using these handles + * + * to disable updating /memory properties pass zero memory handle + */ +extern void ofmem_register( phandle_t ph_memory, phandle_t ph_mmu );
-extern int ofmem_map( ucell phys, ucell virt, ucell size, ucell mode ); +extern ucell ofmem_claim( ucell addr, ucell size, ucell align ); +extern ucell ofmem_claim_phys( ucell mphys, ucell size, ucell align ); +extern ucell ofmem_claim_virt( ucell mvirt, ucell size, ucell align );
-extern void ofmem_release( ucell virt, ucell size ); -extern ucell ofmem_translate( ucell virt, ucell *ret_mode ); +extern int ofmem_map( ucell phys, ucell virt, ucell size, ucell mode ); +extern int ofmem_unmap( ucell virt, ucell size );
+extern void ofmem_release_phys( ucell phys, ucell size ); +extern void ofmem_release_virt( ucell virt, ucell size ); +extern ucell ofmem_translate( ucell virt, ucell *ret_mode ); + #ifdef CONFIG_PPC #define PAGE_SHIFT 12
-ulong get_ram_size( void ); ulong get_ram_top( void ); ulong get_ram_bottom( void ); -void ofmem_register( phandle_t ph ); + #elif defined(CONFIG_SPARC32) #define PAGE_SHIFT 12
Modified: trunk/openbios-devel/modules/build.xml =================================================================== --- trunk/openbios-devel/modules/build.xml 2009-08-02 11:05:00 UTC (rev 524) +++ trunk/openbios-devel/modules/build.xml 2009-08-02 11:05:16 UTC (rev 525) @@ -23,6 +23,7 @@ <object source="sun-parts.c" condition="SUN_PARTS"/> <object source="font_8x8.c" condition="FONT_8X8"/> <object source="font_8x16.c" condition="FONT_8X16"/> + <object source="ofmem_common.c" condition="OFMEM"/> </library>
<dictionary name="openbios" target="forth">