gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/mempfix.hbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      mempfix.h
   16:  *      Fixed Size Memory Pool
   17:  */
   18: 
   19: #ifndef _MEMPFIX_H_
   20: #define _MEMPFIX_H_
   21: 
   22: /*
   23:  * Fixed size memory pool control block
   24:  */
   25: typedef struct free_list {
   26:         struct free_list *next;
   27: } FREEL;
   28: 
   29: typedef struct fix_memorypool_control_block {
   30:         QUEUE  wait_queue;      /* Memory pool wait queue */
   31:         ID     mpfid;              /* Fixed size memory pool ID */
   32:         void   *exinf;           /* Extended information */
   33:         ATR    mpfatr;            /* Memory pool attribute */
   34:         W      mpfcnt;              /* Number of blocks in whole memory pool */
   35:         W      blfsz;               /* Fixed size memory block size */
   36:         W      mpfsz;               /* Whole memory pool size */
   37:         W      frbcnt;              /* Number of blocks in free area */
   38:         void   *mempool; /* Top address of memory pool */
   39:         void   *unused;          /* Top address of unused area */
   40:         FREEL  *freelist;       /* Free block list */
   41:         OBJLOCK        lock;          /* Lock for object exclusive access */
   42: #if USE_OBJECT_NAME
   43:         UB     name[OBJECT_NAME_LENGTH];   /* name */
   44: #endif
   45: } MPFCB;
   46: 
   47: IMPORT MPFCB knl_mpfcb_table[]; /* Fixed size memory pool control block */
   48: IMPORT QUEUE knl_free_mpfcb;    /* FreeQue */
   49: 
   50: #define get_mpfcb(id)   ( &knl_mpfcb_table[INDEX_MPF(id)] )
   51: 
   52: 
   53: #define MINSIZE         ( sizeof(FREEL) )
   54: #define MINSZ(sz)       ( ((UW)(sz) + (UW)(MINSIZE-1)) & ~(UW)(MINSIZE-1) )
   55: 
   56: /*
   57:  * Return end address in memory pool area
   58:  */
   59: Inline void *knl_mempool_end( MPFCB *mpfcb )
   60: {
   61:         return (VB*)mpfcb->mempool + mpfcb->mpfsz;
   62: }
   63: 
   64: 
   65: 
   66: #endif /* _MEMPFIX_H_ */