Changeset b43eaba0 in mainline


Ignore:
Timestamp:
2006-12-25T11:38:48Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
66eb2c8
Parents:
b2e5e25
Message:

Improve indentation and formatting.

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/buddy.h

    rb2e5e25 rb43eaba0  
    4343/** Buddy system operations to be implemented by each implementation. */
    4444struct buddy_system_operations {
    45         link_t *(* find_buddy)(buddy_system_t *, link_t *);             /**< Return pointer to left-side or right-side buddy for block passed as argument. */
    46         link_t *(* bisect)(buddy_system_t *, link_t *);                 /**< Bisect the block passed as argument and return pointer to the new right-side buddy. */
    47         link_t *(* coalesce)(buddy_system_t *, link_t *, link_t *);     /**< Coalesce two buddies into a bigger block. */
    48         void (*set_order)(buddy_system_t *, link_t *, uint8_t);         /**< Set order of block passed as argument. */
    49         uint8_t (*get_order)(buddy_system_t *, link_t *);                       /**< Return order of block passed as argument. */
    50         void (*mark_busy)(buddy_system_t *, link_t *);                  /**< Mark block as busy. */
    51         void (*mark_available)(buddy_system_t *, link_t *);             /**< Mark block as available. */
     45        /** Return pointer to left-side or right-side buddy for block passed as
     46          * argument. */
     47        link_t *(* find_buddy)(buddy_system_t *, link_t *);
     48        /** Bisect the block passed as argument and return pointer to the new
     49          * right-side buddy. */
     50        link_t *(* bisect)(buddy_system_t *, link_t *);
     51        /** Coalesce two buddies into a bigger block. */
     52        link_t *(* coalesce)(buddy_system_t *, link_t *, link_t *);
     53        /** Set order of block passed as argument. */
     54        void (*set_order)(buddy_system_t *, link_t *, uint8_t);
     55        /** Return order of block passed as argument. */
     56        uint8_t (*get_order)(buddy_system_t *, link_t *);
     57        /** Mark block as busy. */
     58        void (*mark_busy)(buddy_system_t *, link_t *);
     59        /** Mark block as available. */
     60        void (*mark_available)(buddy_system_t *, link_t *);
    5261        /** Find parent of block that has given order  */
    5362        link_t *(* find_block)(buddy_system_t *, link_t *, uint8_t);
     
    5665
    5766struct buddy_system {
    58         uint8_t max_order;              /**< Maximal order of block which can be stored by buddy system. */
     67        /** Maximal order of block which can be stored by buddy system. */
     68        uint8_t max_order;
    5969        link_t *order;
    6070        buddy_system_operations_t *op;
    61         void *data;                     /**< Pointer to be used by the implementation. */
     71        /** Pointer to be used by the implementation. */
     72        void *data;
    6273};
    6374
    64 extern void buddy_system_create(buddy_system_t *b,
    65                                 uint8_t max_order,
    66                                 buddy_system_operations_t *op, void *data);
     75extern void buddy_system_create(buddy_system_t *b, uint8_t max_order,
     76        buddy_system_operations_t *op, void *data);
    6777extern link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i);
    6878extern bool buddy_system_can_alloc(buddy_system_t *b, uint8_t order);
  • kernel/generic/include/mm/frame.h

    rb2e5e25 rb43eaba0  
    5454#endif
    5555
    56 #define ZONES_MAX       16      /**< Maximum number of zones in system */
     56/** Maximum number of zones in system. */
     57#define ZONES_MAX               16
    5758
    58 #define ZONE_JOIN       0x1     /**< If possible, merge with neighbouring zones */
     59/** If possible, merge with neighbouring zones. */
     60#define ZONE_JOIN               0x1
    5961
    60 #define FRAME_KA                0x1     /* convert the frame address to kernel va */
    61 #define FRAME_ATOMIC            0x2     /* do not panic and do not sleep on failure */
    62 #define FRAME_NO_RECLAIM        0x4     /* do not start reclaiming when no free memory */
     62/** Convert the frame address to kernel va. */
     63#define FRAME_KA                0x1
     64/** Do not panic and do not sleep on failure. */
     65#define FRAME_ATOMIC            0x2
     66/** Do not start reclaiming when no free memory. */
     67#define FRAME_NO_RECLAIM        0x4
    6368
    6469static inline uintptr_t PFN2ADDR(pfn_t frame)
    6570{
    66         return (uintptr_t)(frame << FRAME_WIDTH);
     71        return (uintptr_t) (frame << FRAME_WIDTH);
    6772}
    6873
    6974static inline pfn_t ADDR2PFN(uintptr_t addr)
    7075{
    71         return (pfn_t)(addr >> FRAME_WIDTH);
     76        return (pfn_t) (addr >> FRAME_WIDTH);
    7277}
    7378
     
    7681        if (!size)
    7782                return 0;
    78         return (count_t)((size-1) >> FRAME_WIDTH)+1;
     83        return (count_t) ((size - 1) >> FRAME_WIDTH) + 1;
    7984}
    8085
    81 #define IS_BUDDY_ORDER_OK(index, order)         ((~(((unative_t) -1) << (order)) & (index)) == 0)
    82 #define IS_BUDDY_LEFT_BLOCK(zone, frame)        (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
    83 #define IS_BUDDY_RIGHT_BLOCK(zone, frame)       (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
    84 #define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame)    (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
    85 #define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame)   (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
     86#define IS_BUDDY_ORDER_OK(index, order)         \
     87        ((~(((unative_t) -1) << (order)) & (index)) == 0)
     88#define IS_BUDDY_LEFT_BLOCK(zone, frame)        \
     89        (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
     90#define IS_BUDDY_RIGHT_BLOCK(zone, frame)       \
     91        (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
     92#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame)    \
     93        (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
     94#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame)   \
     95        (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
    8696
    87 #define frame_alloc(order, flags)               frame_alloc_generic(order, flags, NULL)
     97#define frame_alloc(order, flags)               \
     98        frame_alloc_generic(order, flags, NULL)
    8899
    89100extern void frame_init(void);
    90 extern void * frame_alloc_generic(uint8_t order, int flags, int *pzone);
     101extern void *frame_alloc_generic(uint8_t order, int flags, int *pzone);
    91102extern void frame_free(uintptr_t frame);
    92103extern void frame_reference_add(pfn_t pfn);
    93104
    94105extern int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags);
    95 void * frame_get_parent(pfn_t frame, int hint);
     106void *frame_get_parent(pfn_t frame, int hint);
    96107void frame_set_parent(pfn_t frame, void *data, int hint);
    97108void frame_mark_unavailable(pfn_t start, count_t count);
  • kernel/generic/src/mm/frame.c

    rb2e5e25 rb43eaba0  
    8484        count_t busy_count;     /**< number of busy frame_t structures */
    8585       
    86         buddy_system_t * buddy_system; /**< buddy system for the zone */
     86        buddy_system_t *buddy_system; /**< buddy system for the zone */
    8787        int flags;
    8888} zone_t;
     
    177177/**
    178178 * Try to find a zone where can we find the frame
    179  *
     179 
     180 * Assume interrupts are disabled.
     181 
    180182 * @param frame Frame number contained in zone
    181183 * @param pzone If not null, it is used as zone hint. Zone index
    182184 *              is filled into the variable on success.
    183  * @return Pointer to LOCKED zone containing frame
    184  *
    185  * Assume interrupts disable
     185 * @return Pointer to locked zone containing frame
    186186 */
    187187static zone_t * find_zone_and_lock(pfn_t frame, int *pzone)
     
    223223}
    224224
    225 /**
    226  * Find AND LOCK zone that can allocate order frames
    227  *
    228  * Assume interrupts are disabled!!
     225/** Find and lock zone that can allocate order frames.
     226 *
     227 * Assume interrupts are disabled.
    229228 *
    230229 * @param order Size (2^order) of free space we are trying to find
     
    261260}
    262261
    263 /********************************************/
     262/**************************/
    264263/* Buddy system functions */
     264/**************************/
    265265
    266266/** Buddy system find_block implementation
     
    437437};
    438438
    439 /*************************************/
     439/******************/
    440440/* Zone functions */
     441/******************/
    441442
    442443/** Allocate frame in particular zone
     
    535536 * @param z2 Zone to merge
    536537 */
    537 
    538538static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2)
    539539{
Note: See TracChangeset for help on using the changeset viewer.