Annotation of qemu/roms/openbios/include/libopenbios/ofmem.h, revision 1.1.1.2

1.1       root        1: /*
                      2:  *   Creation Date: <1999/11/16 00:47:06 samuel>
                      3:  *   Time-stamp: <2003/10/18 13:28:14 samuel>
                      4:  *
                      5:  *     <ofmem.h>
                      6:  *
                      7:  *
                      8:  *
                      9:  *   Copyright (C) 1999, 2002 Samuel Rydh ([email protected])
                     10:  *
                     11:  *   This program is free software; you can redistribute it and/or
                     12:  *   modify it under the terms of the GNU General Public License
                     13:  *   as published by the Free Software Foundation
                     14:  *
                     15:  */
                     16: 
                     17: #ifndef _H_OFMEM
                     18: #define _H_OFMEM
                     19: 
                     20: #include "kernel/stack.h"
                     21: 
                     22: typedef struct alloc_desc {
                     23:        struct alloc_desc       *next;
                     24:        ucell                   size;                   /* size (including) this struct */
                     25: } alloc_desc_t;
                     26: 
                     27: typedef struct mem_range {
                     28:        struct mem_range        *next;
                     29:        phys_addr_t             start;                  /* sizeof(phys) >= sizeof(virt), e.g SPARC32 */
                     30:        ucell                   size;
                     31: } range_t;
                     32: 
                     33: typedef struct trans {
                     34:        struct trans            *next;
                     35:        ucell                   virt;                   /* chain is sorted by virt */
                     36:        ucell                   size;
                     37:        phys_addr_t             phys;
                     38:        ucell                   mode;
                     39: } translation_t;
                     40: 
                     41: /* ofmem private data */
                     42: typedef struct {
                     43:        ucell                   ramsize;
                     44:        char                    *next_malloc;
                     45:        alloc_desc_t    *mfree;         /* list of free malloc blocks */
                     46: 
                     47:        range_t                 *phys_range;
                     48:        range_t                 *virt_range;
                     49:        range_t                 *io_range;
                     50: 
                     51:        translation_t   *trans;         /* this is really a translation_t */
                     52: } ofmem_t;
                     53: 
                     54: /* structure for retained data */
                     55: typedef struct {
                     56:        ucell                   magic;
                     57:        ucell                   numentries;
                     58:        range_t                 retain_phys_range[8];   /* physical memory that should survive a warm reset */
                     59: } retain_t;
                     60: 
                     61: /* TODO: temporary migration interface */
                     62: extern ofmem_t*        ofmem_arch_get_private(void);
                     63: extern void*           ofmem_arch_get_malloc_base(void);
                     64: extern ucell           ofmem_arch_get_heap_top(void);
                     65: extern ucell           ofmem_arch_get_virt_top(void);
                     66: extern phys_addr_t     ofmem_arch_get_phys_top(void);
                     67: extern ucell           ofmem_arch_get_iomem_base(void);
                     68: extern ucell           ofmem_arch_get_iomem_top(void);
                     69: extern retain_t*       ofmem_arch_get_retained(void);
1.1.1.2 ! root       70: extern int             ofmem_arch_get_physaddr_cellsize(void);
        !            71: extern int             ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value);
1.1       root       72: extern int             ofmem_arch_get_available_entry_size(phandle_t ph);
                     73: extern void            ofmem_arch_create_available_entry(phandle_t ph, ucell *availentry, phys_addr_t start, ucell size);
                     74: extern int             ofmem_arch_get_translation_entry_size(void);
                     75: extern void            ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t);
                     76: extern ucell           ofmem_arch_default_translation_mode( phys_addr_t phys );
                     77: extern ucell           ofmem_arch_io_translation_mode( phys_addr_t phys );
1.1.1.2 ! root       78: extern void            ofmem_arch_map_pages(phys_addr_t phys, ucell virt, ucell size,
1.1       root       79:                                            ucell mode);
                     80: extern void            ofmem_arch_unmap_pages(ucell virt, ucell size);
                     81: /* sparc64 uses this method */
                     82: extern int             ofmem_map_page_range( phys_addr_t phys, ucell virt, ucell size,
                     83:                                       ucell mode );
                     84: 
                     85: /* Private functions for mapping between physical/virtual addresses */ 
                     86: extern phys_addr_t va2pa(unsigned long va);
                     87: extern unsigned long pa2va(phys_addr_t pa);
                     88:                                      
                     89: /* malloc interface */
                     90: extern int ofmem_posix_memalign( void **memptr, size_t alignment, size_t size );
                     91: extern void* ofmem_malloc( size_t size );
                     92: extern void  ofmem_free( void *ptr );
                     93: extern void* ofmem_realloc( void *ptr, size_t size );
                     94: 
                     95: /* ofmem_common.c */
                     96: 
                     97: extern void    ofmem_cleanup( void );
                     98: extern void    ofmem_init( void );
                     99: 
                    100: /*
                    101:  * register /memory and /virtual-memory handles
                    102:  * ofmem module will update "available" and "translations" properties
                    103:  * using these handles
                    104:  *
                    105:  * to disable updating /memory properties  pass zero memory handle
                    106:  */
                    107: extern void ofmem_register( phandle_t ph_memory, phandle_t ph_mmu );
                    108: 
                    109: extern ucell ofmem_claim( ucell addr, ucell size, ucell align );
                    110: extern phys_addr_t ofmem_claim_phys( phys_addr_t mphys, ucell size, ucell align );
                    111: extern ucell ofmem_claim_virt( ucell mvirt, ucell size, ucell align );
                    112: extern ucell ofmem_claim_io( ucell virt, ucell size, ucell align );
                    113: 
                    114: extern phys_addr_t ofmem_retain( phys_addr_t phys, ucell size, ucell align );
                    115: 
                    116: extern int   ofmem_map( phys_addr_t phys, ucell virt, ucell size, ucell mode );
                    117: extern int   ofmem_unmap( ucell virt, ucell size );
                    118: extern ucell ofmem_map_io( phys_addr_t phys, ucell size );
                    119: 
                    120: extern void  ofmem_release( ucell virt, ucell size );
                    121: extern void  ofmem_release_phys( phys_addr_t phys, ucell size );
                    122: extern void  ofmem_release_virt( ucell virt, ucell size );
                    123: extern phys_addr_t ofmem_translate( ucell virt, ucell *ret_mode );
                    124: 
                    125: /* memory and virtual-memory nodes */
                    126: extern phandle_t s_phandle_memory;
                    127: extern phandle_t s_phandle_mmu;
                    128: 
                    129: /* Currently the same for all architectures */
                    130: #define PAGE_SHIFT   12
                    131: 
                    132: #define PAGE_SIZE    (1 << PAGE_SHIFT)
                    133: #define PAGE_MASK    (~(PAGE_SIZE - 1))
                    134: #define PAGE_ALIGN(addr)  (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
                    135: 
                    136: #if defined(CONFIG_DEBUG_OFMEM)
                    137: # define OFMEM_TRACE(fmt, ...) do { printk("OFMEM: " fmt, ## __VA_ARGS__); } while (0)
                    138: #else
                    139: # define OFMEM_TRACE(fmt, ...) do {} while(0)
                    140: #endif
                    141: 
                    142: #endif   /* _H_OFMEM */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.