Changeset da1bafb in mainline for kernel/generic/src/cpu/cpu.c


Ignore:
Timestamp:
2010-05-24T18:57:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/cpu/cpu.c

    r666f492 rda1bafb  
    3333/**
    3434 * @file
    35  * @brief       CPU subsystem initialization and listing.
     35 * @brief CPU subsystem initialization and listing.
    3636 */
    37  
     37
    3838#include <cpu.h>
    3939#include <arch.h>
     
    5858 */
    5959void cpu_init(void) {
    60         unsigned int i, j;
    61        
    6260#ifdef CONFIG_SMP
    6361        if (config.cpu_active == 1) {
    6462#endif /* CONFIG_SMP */
     63               
    6564                cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count,
    66                                         FRAME_ATOMIC);
     65                    FRAME_ATOMIC);
    6766                if (!cpus)
    6867                        panic("Cannot allocate CPU structures.");
    69 
    70                 /* initialize everything */
     68               
     69                /* Initialize everything */
    7170                memsetb(cpus, sizeof(cpu_t) * config.cpu_count, 0);
    72 
     71               
     72                size_t i;
    7373                for (i = 0; i < config.cpu_count; i++) {
    74                         cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_ATOMIC);
    75                        
     74                        cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES,
     75                            FRAME_KA | FRAME_ATOMIC);
    7676                        cpus[i].id = i;
    7777                       
    78                         spinlock_initialize(&cpus[i].lock, "cpu_t.lock");
    79 
     78                        irq_spinlock_initialize(&cpus[i].lock, "cpus[].lock");
     79                       
     80                        unsigned int j;
    8081                        for (j = 0; j < RQ_COUNT; j++) {
    81                                 spinlock_initialize(&cpus[i].rq[j].lock, "rq_t.lock");
     82                                irq_spinlock_initialize(&cpus[i].rq[j].lock, "cpus[].rq[].lock");
    8283                                list_initialize(&cpus[i].rq[j].rq_head);
    8384                        }
     
    8788        }
    8889#endif /* CONFIG_SMP */
    89 
     90       
    9091        CPU = &cpus[config.cpu_active - 1];
    9192       
    92         CPU->active = 1;
    93         CPU->tlb_active = 1;
     93        CPU->active = true;
     94        CPU->tlb_active = true;
    9495       
    9596        cpu_identify();
     
    100101void cpu_list(void)
    101102{
    102         unsigned int i;
    103 
     103        size_t i;
     104       
    104105        for (i = 0; i < config.cpu_count; i++) {
    105106                if (cpus[i].active)
Note: See TracChangeset for help on using the changeset viewer.