www.pudn.com > r&s1.10°æ±¾£«Îĵµ.rar > memory.h


/* 
=============================================================================== 
| Copyright (C) 2004 RuanHaiShen, All rights reserved. 
| SUMMARY:  
|   Memory management functions and structures definitions. 
| 
| DESCRIPTION: 
|   See http://www.01s.org for documentation, latest information, license  
|   and contact details. 
|   email:ruanhaishen@01s.org 
=============================================================================*/ 
#ifndef __MEMORY_H__ 
#define __MEMORY_H__  
/*===========================================================================*/ 
#if CFG_MM_EN > 0  
/*=============================================*/ 
 
#define MMSIZE(x)       (_mms[x].size) 
#define MMTOTAL(x)      (_mms[x].blocks) 
#define MMFREE(x)       (_mms[x].nfrees) 
#define MMFIRST(x)      (_mms[x].firstfree) 
 
#define PTR_SIZE        sizeof(void*) 
 
#if ARCH_MM_BYTEORDER == LITTLE_ENDIAN 
struct block_struct 
{ 
    union { 
        struct used { 
#if PTR_SIZE > 2 
            u8  res[PTR_SIZE - 2]; 
#endif 
            u8  page; 
            u8  flags; 
        } used; 
        struct block_struct* next; 
    } u; 
}; 
#elif ARCH_MM_BYTEORDER == BIG_ENDIAN 
struct block_struct 
{ 
    union { 
        struct used { 
            u8  flags; 
            u8  page; 
#if PTR_SIZE > 2 
            u8  res[PTR_SIZE - 2]; 
#endif 
        } used; 
        struct block_struct* next; 
    } u; 
}; 
#endif 
typedef struct block_struct block_t; 
 
struct mm_struct 
{ 
    mmsz_t      size; 
    mmsz_t      blocks; 
    block_t*    firstfree; 
    mmsz_t      nfrees; 
}; 
typedef struct mm_struct mm_t; 
 
void  __mm_init(void); 
 
 
/*=============================================*/ 
#endif  
/*===========================================================================*/ 
#endif