Changeset deaf8d5 in mainline


Ignore:
Timestamp:
2008-06-22T19:21:07Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
08a19ba
Parents:
69eac4aa
Message:

cstyle for frame.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/frame.c

    r69eac4aa rdeaf8d5  
    130130}
    131131
    132 /** Initialize frame structure
    133  *
    134  * Initialize frame structure.
    135  *
    136  * @param frame Frame structure to be initialized.
     132/** Initialize frame structure.
     133 *
     134 * @param framei        Frame structure to be initialized.
    137135 */
    138136static void frame_initialize(frame_t *frame)
     
    146144/**********************/
    147145
    148 /**
    149  * Insert-sort zone into zones list
    150  *
    151  * @param newzone New zone to be inserted into zone list
    152  * @return zone number on success, -1 on error
     146/** Insert-sort zone into zones list.
     147 *
     148 * @param newzone       New zone to be inserted into zone list.
     149 * @return              Zone number on success, -1 on error.
    153150 */
    154151static int zones_add_zone(zone_t *newzone)
     
    172169                /* Check for overflow */
    173170                z = zones.info[i];
    174                 if (overlaps(newzone->base, newzone->count, z->base, z->count)) {
     171                if (overlaps(newzone->base, newzone->count, z->base,
     172                    z->count)) {
    175173                        printf("Zones overlap!\n");
    176174                        return -1;
     
    194192
    195193/**
    196  * Try to find a zone where can we find the frame
     194 * Try to find a zone where can we find the frame.
    197195 *
    198196 * Assume interrupts are disabled.
    199197 *
    200  * @param frame Frame number contained in zone
    201  * @param pzone If not null, it is used as zone hint. Zone index
    202  *              is filled into the variable on success.
    203  * @return Pointer to locked zone containing frame
    204  */
    205 static zone_t * find_zone_and_lock(pfn_t frame, unsigned int *pzone)
     198 * @param frame         Frame number contained in zone.
     199 * @param pzone         If not null, it is used as zone hint. Zone index is
     200 *                      filled into the variable on success.
     201 * @return              Pointer to locked zone containing frame.
     202 */
     203static zone_t *find_zone_and_lock(pfn_t frame, unsigned int *pzone)
    206204{
    207205        unsigned int i;
     
    246244 * Assume interrupts are disabled.
    247245 *
    248  * @param order Size (2^order) of free space we are trying to find
    249  * @param pzone Pointer to preferred zone or NULL, on return contains zone
    250  *              number
    251  */
    252 static zone_t * find_free_zone_and_lock(uint8_t order, unsigned int *pzone)
     246 * @param order         Size (2^order) of free space we are trying to find.
     247 * @param pzone         Pointer to preferred zone or NULL, on return contains
     248 *                      zone number.
     249 */
     250static zone_t *find_free_zone_and_lock(uint8_t order, unsigned int *pzone)
    253251{
    254252        unsigned int i;
     
    284282/**************************/
    285283
    286 /** Buddy system find_block implementation
     284/** Buddy system find_block implementation.
    287285 *
    288286 * Find block that is parent of current list.
    289287 * That means go to lower addresses, until such block is found
    290288 *
    291  * @param order - Order of parent must be different then this parameter!!
     289 * @param order         Order of parent must be different then this
     290 *                      parameter!!
    292291 */
    293292static link_t *zone_buddy_find_block(buddy_system_t *b, link_t *child,
     
    322321}                                   
    323322
    324 /** Buddy system find_buddy implementation
    325  *
    326  * @param b Buddy system.
    327  * @param block Block for which buddy should be found
    328  *
    329  * @return Buddy for given block if found
     323/** Buddy system find_buddy implementation.
     324 *
     325 * @param b             Buddy system.
     326 * @param block         Block for which buddy should be found.
     327 *
     328 * @return              Buddy for given block if found.
    330329 */
    331330static link_t *zone_buddy_find_buddy(buddy_system_t *b, link_t *block)
     
    346345        ASSERT(is_left ^ is_right);
    347346        if (is_left) {
    348                 index = (frame_index(zone, frame)) + (1 << frame->buddy_order);
     347                index = (frame_index(zone, frame)) +
     348                    (1 << frame->buddy_order);
    349349        } else {        /* if (is_right) */
    350                 index = (frame_index(zone, frame)) - (1 << frame->buddy_order);
     350                index = (frame_index(zone, frame)) -
     351                    (1 << frame->buddy_order);
    351352        }
    352353       
     
    361362}
    362363
    363 /** Buddy system bisect implementation
    364  *
    365  * @param b Buddy system.
    366  * @param block Block to bisect
    367  *
    368  * @return right block
    369  */
    370 static link_t * zone_buddy_bisect(buddy_system_t *b, link_t *block) {
     364/** Buddy system bisect implementation.
     365 *
     366 * @param b             Buddy system.
     367 * @param block         Block to bisect.
     368 *
     369 * @return              Right block.
     370 */
     371static link_t *zone_buddy_bisect(buddy_system_t *b, link_t *block)
     372{
    371373        frame_t *frame_l, *frame_r;
    372374
     
    377379}
    378380
    379 /** Buddy system coalesce implementation
    380  *
    381  * @param b Buddy system.
    382  * @param block_1 First block
    383  * @param block_2 First block's buddy
    384  *
    385  * @return Coalesced block (actually block that represents lower address)
     381/** Buddy system coalesce implementation.
     382 *
     383 * @param b             Buddy system.
     384 * @param block_1       First block.
     385 * @param block_2       First block's buddy.
     386 *
     387 * @return              Coalesced block (actually block that represents lower
     388 *                      address).
    386389 */
    387390static link_t *zone_buddy_coalesce(buddy_system_t *b, link_t *block_1,
     
    396399}
    397400
    398 /** Buddy system set_order implementation
    399  *
    400  * @param b Buddy system.
    401  * @param block Buddy system block
    402  * @param order Order to set
     401/** Buddy system set_order implementation.
     402 *
     403 * @param b             Buddy system.
     404 * @param block         Buddy system block.
     405 * @param order         Order to set.
    403406 */
    404407static void zone_buddy_set_order(buddy_system_t *b, link_t *block,
    405     uint8_t order) {
     408    uint8_t order)
     409{
    406410        frame_t *frame;
    407411        frame = list_get_instance(block, frame_t, buddy_link);
     
    409413}
    410414
    411 /** Buddy system get_order implementation
    412  *
    413  * @param b Buddy system.
    414  * @param block Buddy system block
    415  *
    416  * @return Order of block
    417  */
    418 static uint8_t zone_buddy_get_order(buddy_system_t *b, link_t *block) {
     415/** Buddy system get_order implementation.
     416 *
     417 * @param b             Buddy system.
     418 * @param block         Buddy system block.
     419 *
     420 * @return              Order of block.
     421 */
     422static uint8_t zone_buddy_get_order(buddy_system_t *b, link_t *block)
     423{
    419424        frame_t *frame;
    420425        frame = list_get_instance(block, frame_t, buddy_link);
     
    422427}
    423428
    424 /** Buddy system mark_busy implementation
    425  *
    426  * @param b Buddy system
    427  * @param block Buddy system block
    428  *
    429  */
    430 static void zone_buddy_mark_busy(buddy_system_t *b, link_t * block) {
     429/** Buddy system mark_busy implementation.
     430 *
     431 * @param b             Buddy system.
     432 * @param block         Buddy system block.
     433 */
     434static void zone_buddy_mark_busy(buddy_system_t *b, link_t * block)
     435{
    431436        frame_t * frame;
    432437
     
    435440}
    436441
    437 /** Buddy system mark_available implementation
    438  *
    439  * @param b Buddy system
    440  * @param block Buddy system block
    441  *
    442  */
    443 static void zone_buddy_mark_available(buddy_system_t *b, link_t *block) {
     442/** Buddy system mark_available implementation.
     443 *
     444 * @param b             Buddy system.
     445 * @param block         Buddy system block.
     446 */
     447static void zone_buddy_mark_available(buddy_system_t *b, link_t *block)
     448{
    444449        frame_t *frame;
    445450        frame = list_get_instance(block, frame_t, buddy_link);
     
    463468/******************/
    464469
    465 /** Allocate frame in particular zone
    466  *
    467  * Assume zone is locked
     470/** Allocate frame in particular zone.
     471 *
     472 * Assume zone is locked.
    468473 * Panics if allocation is impossible.
    469474 *
    470  * @param zone  Zone to allocate from.
    471  * @param order Allocate exactly 2^order frames.
    472  *
    473  * @return Frame index in zone
     475 * @param zone          Zone to allocate from.
     476 * @param order         Allocate exactly 2^order frames.
     477 *
     478 * @return              Frame index in zone.
    474479 *
    475480 */
     
    497502}
    498503
    499 /** Free frame from zone
    500  *
    501  * Assume zone is locked
    502  *
    503  * @param zone Pointer to zone from which the frame is to be freed
    504  * @param frame_idx Frame index relative to zone
     504/** Free frame from zone.
     505 *
     506 * Assume zone is locked.
     507 *
     508 * @param zone          Pointer to zone from which the frame is to be freed.
     509 * @param frame_idx     Frame index relative to zone.
    505510 */
    506511static void zone_frame_free(zone_t *zone, index_t frame_idx)
     
    525530}
    526531
    527 /** Return frame from zone */
     532/** Return frame from zone. */
    528533static frame_t * zone_get_frame(zone_t *zone, index_t frame_idx)
    529534{
     
    532537}
    533538
    534 /** Mark frame in zone unavailable to allocation */
     539/** Mark frame in zone unavailable to allocation. */
    535540static void zone_mark_unavailable(zone_t *zone, index_t frame_idx)
    536541{
     
    547552}
    548553
    549 /**
    550  * Join 2 zones
    551  *
    552  * Expect zone_t *z to point to space at least zone_conf_size large
    553  *
    554  * Assume z1 & z2 are locked
    555  *
    556  * @param z Target zone structure pointer
    557  * @param z1 Zone to merge
    558  * @param z2 Zone to merge
     554/** Join two zones.
     555 *
     556 * Expect zone_t *z to point to space at least zone_conf_size large.
     557 *
     558 * Assume z1 & z2 are locked.
     559 *
     560 * @param z             Target zone structure pointer.
     561 * @param z1            Zone to merge.
     562 * @param z2            Zone to merge.
    559563 */
    560564static void _zone_merge(zone_t *z, zone_t *z1, zone_t *z2)
     
    630634}
    631635
    632 /** Return old configuration frames into the zone
     636/** Return old configuration frames into the zone.
    633637 *
    634638 * We have several cases
     
    637641 *   updated with reduce_region -> free every frame
    638642 *
    639  * @param newzone The actual zone where freeing should occur
    640  * @param oldzone Pointer to old zone configuration data that should
    641  *                be freed from new zone
     643 * @param newzone       The actual zone where freeing should occur.
     644 * @param oldzone       Pointer to old zone configuration data that should
     645 *                      be freed from new zone.
    642646 */
    643647static void return_config_frames(zone_t *newzone, zone_t *oldzone)
     
    663667}
    664668
    665 /** Reduce allocated block to count of order 0 frames
     669/** Reduce allocated block to count of order 0 frames.
    666670 *
    667671 * The allocated block need 2^order frames of space. Reduce all frames
     
    671675 *
    672676 * @param zone
    673  * @param frame_idx Index to block
    674  * @param count Allocated space in block
     677 * @param frame_idx             Index to block.
     678 * @param count                 Allocated space in block.
    675679 */
    676680static void zone_reduce_region(zone_t *zone, pfn_t frame_idx, count_t count)
     
    699703}
    700704
    701 /** Merge zones z1 and z2
     705/** Merge zones z1 and z2.
    702706 *
    703707 * - the zones must be 2 zones with no zone existing in between,
     
    774778}
    775779
    776 /**
    777  * Merge all zones into one big zone
     780/** Merge all zones into one big zone.
    778781 *
    779782 * It is reasonable to do this on systems whose bios reports parts in chunks,
     
    790793}
    791794
    792 /** Create frame zone
    793  *
    794  * Create new frame zone.
    795  *
    796  * @param start Physical address of the first frame within the zone.
    797  * @param count Count of frames in zone
    798  * @param z Address of configuration information of zone
    799  * @param flags Zone flags.
    800  *
    801  * @return Initialized zone.
     795/** Create new frame zone.
     796 *
     797 * @param start         Physical address of the first frame within the zone.
     798 * @param count         Count of frames in zone.
     799 * @param z             Address of configuration information of zone.
     800 * @param flags         Zone flags.
     801 *
     802 * @return              Initialized zone.
    802803 */
    803804static void zone_construct(pfn_t start, count_t count, zone_t *z, int flags)
     
    820821       
    821822        buddy_system_create(z->buddy_system, max_order,
    822                             &zone_buddy_system_operations,
    823                             (void *) z);
     823            &zone_buddy_system_operations, (void *) z);
    824824       
    825825        /* Allocate frames _after_ the conframe */
     
    838838}
    839839
    840 /** Compute configuration data size for zone
    841  *
    842  * @param count Size of zone in frames
    843  * @return Size of zone configuration info (in bytes)
     840/** Compute configuration data size for zone.
     841 *
     842 * @param count         Size of zone in frames.
     843 * @return              Size of zone configuration info (in bytes).
    844844 */
    845845uintptr_t zone_conf_size(count_t count)
     
    853853}
    854854
    855 /** Create and add zone to system
    856  *
    857  * @param start First frame number (absolute)
    858  * @param count Size of zone in frames
    859  * @param confframe Where configuration frames are supposed to be.
    860  *                  Automatically checks, that we will not disturb the
    861  *                  kernel and possibly init.
    862  *                  If confframe is given _outside_ this zone, it is expected,
    863  *                  that the area is already marked BUSY and big enough
    864  *                  to contain zone_conf_size() amount of data.
    865  *                  If the confframe is inside the area, the zone free frame
    866  *                  information is modified not to include it.
    867  *
    868  * @return Zone number or -1 on error
     855/** Create and add zone to system.
     856 *
     857 * @param start         First frame number (absolute).
     858 * @param count         Size of zone in frames.
     859 * @param confframe     Where configuration frames are supposed to be.
     860 *                      Automatically checks, that we will not disturb the
     861 *                      kernel and possibly init.  If confframe is given
     862 *                      _outside_ this zone, it is expected, that the area is
     863 *                      already marked BUSY and big enough to contain
     864 *                      zone_conf_size() amount of data.  If the confframe is
     865 *                      inside the area, the zone free frame information is
     866 *                      modified not to include it.
     867 *
     868 * @return              Zone number or -1 on error.
    869869 */
    870870int zone_create(pfn_t start, count_t count, pfn_t confframe, int flags)
     
    931931/* Frame functions */
    932932
    933 /** Set parent of frame */
     933/** Set parent of frame. */
    934934void frame_set_parent(pfn_t pfn, void *data, unsigned int hint)
    935935{
     
    956956/** Allocate power-of-two frames of physical memory.
    957957 *
    958  * @param order  Allocate exactly 2^order frames.
    959  * @param flags  Flags for host zone selection and address processing.
    960  * @param pzone  Preferred zone
    961  *
    962  * @return Physical address of the allocated frame.
    963  *
    964  */
    965 void * frame_alloc_generic(uint8_t order, int flags, unsigned int *pzone)
     958 * @param order         Allocate exactly 2^order frames.
     959 * @param flags         Flags for host zone selection and address processing.
     960 * @param pzone         Preferred zone.
     961 *
     962 * @return              Physical address of the allocated frame.
     963 *
     964 */
     965void *frame_alloc_generic(uint8_t order, int flags, unsigned int *pzone)
    966966{
    967967        ipl_t ipl;
     
    10201020 * If it drops to zero, move the frame structure to free list.
    10211021 *
    1022  * @param Frame Physical Address of of the frame to be freed.
     1022 * @param frame         Physical Address of of the frame to be freed.
    10231023 */
    10241024void frame_free(uintptr_t frame)
     
    10471047 * increment frame reference count.
    10481048 *
    1049  * @param pfn Frame number of the frame to be freed.
     1049 * @param pfn           Frame number of the frame to be freed.
    10501050 */
    10511051void frame_reference_add(pfn_t pfn)
     
    10601060         * First, find host frame zone for addr.
    10611061         */
    1062         zone = find_zone_and_lock(pfn,NULL);
     1062        zone = find_zone_and_lock(pfn, NULL);
    10631063        ASSERT(zone);
    10641064       
    1065         frame = &zone->frames[pfn-zone->base];
     1065        frame = &zone->frames[pfn - zone->base];
    10661066        frame->refcount++;
    10671067       
     
    10701070}
    10711071
    1072 /** Mark given range unavailable in frame zones */
     1072/** Mark given range unavailable in frame zones. */
    10731073void frame_mark_unavailable(pfn_t start, count_t count)
    10741074{
     
    10871087}
    10881088
    1089 /** Initialize physical memory management
    1090  *
    1091  * Initialize physical memory managemnt.
    1092  */
     1089/** Initialize physical memory management. */
    10931090void frame_init(void)
    10941091{
     
    11231120
    11241121
    1125 /** Return total size of all zones
    1126  *
    1127  */
    1128 uint64_t zone_total_size(void) {
     1122/** Return total size of all zones. */
     1123uint64_t zone_total_size(void)
     1124{
    11291125        zone_t *zone = NULL;
    11301126        unsigned int i;
     
    11481144}
    11491145
    1150 
    1151 
    1152 /** Prints list of zones
    1153  *
    1154  */
    1155 void zone_print_list(void) {
     1146/** Prints list of zones. */
     1147void zone_print_list(void)
     1148{
    11561149        zone_t *zone = NULL;
    11571150        unsigned int i;
     
    11761169
    11771170#ifdef __32_BITS__
    1178                 printf("%-2u   %10p %12" PRIc " %12" PRIc "\n", i, PFN2ADDR(zone->base),
    1179                     zone->free_count, zone->busy_count);
     1171                printf("%-2u   %10p %12" PRIc " %12" PRIc "\n",
     1172                    i, PFN2ADDR(zone->base), zone->free_count,
     1173                    zone->busy_count);
    11801174#endif
    11811175
    11821176#ifdef __64_BITS__
    1183                 printf("%-2u   %18p %12" PRIc " %12" PRIc "\n", i, PFN2ADDR(zone->base),
    1184                     zone->free_count, zone->busy_count);
     1177                printf("%-2u   %18p %12" PRIc " %12" PRIc "\n", i,
     1178                    PFN2ADDR(zone->base), zone->free_count, zone->busy_count);
    11851179#endif
    11861180               
     
    11941188/** Prints zone details.
    11951189 *
    1196  * @param num Zone base address or zone number.
    1197  */
    1198 void zone_print_one(unsigned int num) {
     1190 * @param num           Zone base address or zone number.
     1191 */
     1192void zone_print_one(unsigned int num)
     1193{
    11991194        zone_t *zone = NULL;
    12001195        ipl_t ipl;
     
    12191214        printf("Zone base address: %p\n", PFN2ADDR(zone->base));
    12201215        printf("Zone size: %" PRIc " frames (%" PRIs " KB)\n", zone->count,
    1221                 SIZE2KB(FRAMES2SIZE(zone->count)));
    1222         printf("Allocated space: %" PRIc " frames (%" PRIs " KB)\n", zone->busy_count,
    1223                 SIZE2KB(FRAMES2SIZE(zone->busy_count)));
    1224         printf("Available space: %" PRIc " frames (%" PRIs " KB)\n", zone->free_count,
    1225                 SIZE2KB(FRAMES2SIZE(zone->free_count)));
     1216            SIZE2KB(FRAMES2SIZE(zone->count)));
     1217        printf("Allocated space: %" PRIc " frames (%" PRIs " KB)\n",
     1218            zone->busy_count, SIZE2KB(FRAMES2SIZE(zone->busy_count)));
     1219        printf("Available space: %" PRIc " frames (%" PRIs " KB)\n",
     1220            zone->free_count, SIZE2KB(FRAMES2SIZE(zone->free_count)));
    12261221        buddy_system_structure_print(zone->buddy_system, FRAME_SIZE);
    12271222        spinlock_unlock(&zone->lock);
Note: See TracChangeset for help on using the changeset viewer.