Main Page | Directories | File List | Globals

counters_core.c File Reference

#include <agnix/agnix.h>
#include <agnix/spinlock.h>
#include <agnix/math64.h>
#include <agnix/resources.h>
#include <agnix/console.h>
#include <agnix/counters.h>
#include <asm/atomic.h>

Include dependency graph for counters_core.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "CNT: "
#define COUNTER_LOCK(cnt)   u32 flags; do { spin_lock_irqsave(&cnt->cnt_lock, flags); } while(0)
#define COUNTER_UNLOCK(cnt)   do { spin_unlock_irqrestore(&cnt->cnt_lock, flags); } while(0)

Functions

void counter_32_bit_read (struct counter_s *counter, u32 *counter_val)
void counter_32_bit_write (struct counter_s *counter, u32 *counter_new)
void counter_32_bit_add (struct counter_s *counter, u32 *counter_add)
void counter_32_bit_sub (struct counter_s *counter, u32 *counter_sub)
void counter_32_bit_inc (struct counter_s *counter)
void counter_32_bit_dec (struct counter_s *counter)
void counter_64_bit_read (struct counter_s *counter, u32 *counter_val)
void counter_64_bit_write (struct counter_s *counter, u32 *counter_new)
void counter_64_bit_add (struct counter_s *counter, u32 *counter_add)
void counter_64_bit_sub (struct counter_s *counter, u32 *counter_sub)
void counter_64_bit_inc (struct counter_s *counter)
void counter_64_bit_dec (struct counter_s *counter)
int put_free_counter (int counter_desc)
int get_free_counter (void)
int register_counter (int counter_type, const char *counter_name)
int counters_init (void)

Variables

int counters_resource_desc
counter_s counters [MAX_COUNTERS]
u32 counters_bitmap [COUNTERS_BITMAP_LEN]
resource_s counters_resource
counter_ops_s counter_32_bit_ops
counter_ops_s counter_64_bit_ops


Define Documentation

#define COUNTER_LOCK cnt   )     u32 flags; do { spin_lock_irqsave(&cnt->cnt_lock, flags); } while(0)
 

Definition at line 24 of file counters_core.c.

Referenced by counter_64_bit_add(), counter_64_bit_dec(), counter_64_bit_inc(), counter_64_bit_read(), counter_64_bit_sub(), and counter_64_bit_write().

#define COUNTER_UNLOCK cnt   )     do { spin_unlock_irqrestore(&cnt->cnt_lock, flags); } while(0)
 

Definition at line 25 of file counters_core.c.

Referenced by counter_64_bit_add(), counter_64_bit_dec(), counter_64_bit_inc(), counter_64_bit_read(), counter_64_bit_sub(), and counter_64_bit_write().

#define MOD_NAME   "CNT: "
 

Definition at line 22 of file counters_core.c.


Function Documentation

void counter_32_bit_add struct counter_s *  counter,
u32 counter_add
 

Definition at line 49 of file counters_core.c.

00050 {
00051     atomic_add(counter->cnt_val, counter_add[0]);
00052 }

void counter_32_bit_dec struct counter_s *  counter  ) 
 

Definition at line 64 of file counters_core.c.

00065 {
00066     atomic_dec(counter->cnt_val);
00067 }

void counter_32_bit_inc struct counter_s *  counter  ) 
 

Definition at line 59 of file counters_core.c.

00060 {
00061     atomic_inc(counter->cnt_val);
00062 }

void counter_32_bit_read struct counter_s *  counter,
u32 counter_val
 

Definition at line 39 of file counters_core.c.

00040 {
00041     counter_val[0] = atomic_read(counter->cnt_val);
00042 }

void counter_32_bit_sub struct counter_s *  counter,
u32 counter_sub
 

Definition at line 54 of file counters_core.c.

00055 {
00056     atomic_sub(counter->cnt_val, counter_sub[0]);
00057 }

void counter_32_bit_write struct counter_s *  counter,
u32 counter_new
 

Definition at line 44 of file counters_core.c.

00045 {
00046     atomic_write(counter->cnt_val, counter_new[0]);
00047 }

void counter_64_bit_add struct counter_s *  counter,
u32 counter_add
 

Definition at line 85 of file counters_core.c.

References add_64_64(), COUNTER_LOCK, and COUNTER_UNLOCK.

00086 {
00087     COUNTER_LOCK(counter);
00088     add_64_64(counter->cnt_val, counter->cnt_val, counter_add);
00089     COUNTER_UNLOCK(counter);
00090 }

Here is the call graph for this function:

void counter_64_bit_dec struct counter_s *  counter  ) 
 

Definition at line 106 of file counters_core.c.

References COUNTER_LOCK, COUNTER_UNLOCK, and sub_64_32().

00107 {
00108     COUNTER_LOCK(counter);
00109     sub_64_32(counter->cnt_val, counter->cnt_val, 1);
00110     COUNTER_UNLOCK(counter);
00111 }

Here is the call graph for this function:

void counter_64_bit_inc struct counter_s *  counter  ) 
 

Definition at line 99 of file counters_core.c.

References add_64_32(), COUNTER_LOCK, and COUNTER_UNLOCK.

00100 {
00101     COUNTER_LOCK(counter);
00102     add_64_32(counter->cnt_val, counter->cnt_val, 1);
00103     COUNTER_UNLOCK(counter);
00104 }

Here is the call graph for this function:

void counter_64_bit_read struct counter_s *  counter,
u32 counter_val
 

Definition at line 69 of file counters_core.c.

References COUNTER_LOCK, and COUNTER_UNLOCK.

00070 {
00071     COUNTER_LOCK(counter);
00072     counter_val[0] = counter->cnt_val[0];
00073     counter_val[1] = counter->cnt_val[1];
00074     COUNTER_UNLOCK(counter);
00075 }

void counter_64_bit_sub struct counter_s *  counter,
u32 counter_sub
 

Definition at line 92 of file counters_core.c.

References COUNTER_LOCK, COUNTER_UNLOCK, and sub_64_64().

00093 {
00094     COUNTER_LOCK(counter);
00095     sub_64_64(counter->cnt_val, counter->cnt_val, counter_sub);
00096     COUNTER_UNLOCK(counter);
00097 }

Here is the call graph for this function:

void counter_64_bit_write struct counter_s *  counter,
u32 counter_new
 

Definition at line 77 of file counters_core.c.

References COUNTER_LOCK, and COUNTER_UNLOCK.

00078 {
00079     COUNTER_LOCK(counter);
00080     counter->cnt_val[0] = counter_new[0];
00081     counter->cnt_val[1] = counter_new[1];
00082     COUNTER_UNLOCK(counter);
00083 }

int counters_init void   ) 
 

Definition at line 169 of file counters_core.c.

References counters_resource, counters_resource_desc, counters_sys_init(), MOD_NAME, printk(), and register_resource().

Referenced by start_kernel().

00170 {
00171     printk(MOD_NAME "initializing system counters\n");
00172 
00173     counters_resource_desc = register_resource(&counters_resource);
00174     counters_sys_init();
00175     
00176     return 0;
00177 }

Here is the call graph for this function:

int get_free_counter void   ) 
 

Definition at line 136 of file counters_core.c.

References counters_resource_desc, and get_free_resource().

Referenced by register_counter().

00137 {
00138     return get_free_resource(counters_resource_desc);
00139 }

Here is the call graph for this function:

int put_free_counter int  counter_desc  ) 
 

Definition at line 131 of file counters_core.c.

References counters_resource_desc, and put_free_resource().

00132 {
00133     return put_free_resource(counters_resource_desc, counter_desc);
00134 }

Here is the call graph for this function:

int register_counter int  counter_type,
const char *  counter_name
 

Definition at line 141 of file counters_core.c.

References counter_32_bit_ops, counter_64_bit_ops, counters, get_free_counter(), MOD_NAME, and printk().

Referenced by counters_sys_init().

00142 {
00143     int counter_desc;
00144     
00145     if ((counter_desc = get_free_counter()) < 0)
00146         return -1;
00147 
00148     switch(counter_type) {
00149         case COUNTER_TYPE_32_BIT:
00150             printk(MOD_NAME "registering 32 bit ");
00151             counters[counter_desc].cnt_ops = &counter_32_bit_ops;
00152             break;
00153         
00154         case COUNTER_TYPE_64_BIT:
00155             printk(MOD_NAME "registering 64 bit ");
00156             counters[counter_desc].cnt_ops = &counter_64_bit_ops;
00157             break;
00158         
00159         default:
00160             return -1;
00161     }    
00162 
00163     printk("%s counter\n", counter_name);
00164     counters[counter_desc].cnt_name = counter_name;
00165     
00166     return counter_desc;
00167 }

Here is the call graph for this function:


Variable Documentation

struct counter_ops_s counter_32_bit_ops
 

Initial value:

 {
    .cnt_read   = counter_32_bit_read,
    .cnt_write  = counter_32_bit_write,
    .cnt_add    = counter_32_bit_add,
    .cnt_sub    = counter_32_bit_sub,
    .cnt_inc    = counter_32_bit_inc,
    .cnt_dec    = counter_32_bit_dec
}

Definition at line 113 of file counters_core.c.

Referenced by register_counter().

struct counter_ops_s counter_64_bit_ops
 

Initial value:

 {
    .cnt_read   = counter_64_bit_read,
    .cnt_write  = counter_64_bit_write,
    .cnt_add    = counter_64_bit_add,
    .cnt_sub    = counter_64_bit_sub,
    .cnt_inc    = counter_64_bit_inc,
    .cnt_dec    = counter_64_bit_dec
}

Definition at line 122 of file counters_core.c.

Referenced by register_counter().

struct counter_s counters[MAX_COUNTERS]
 

Definition at line 29 of file counters_core.c.

Referenced by register_counter().

u32 counters_bitmap[COUNTERS_BITMAP_LEN]
 

Definition at line 31 of file counters_core.c.

struct resource_s counters_resource
 

Initial value:

 {
    .resource_name      = "counters",
    .resource_bitmap    = counters_bitmap,
    .resource_len       = COUNTERS_BITMAP_LEN,
}

Definition at line 33 of file counters_core.c.

Referenced by counters_init().

int counters_resource_desc
 

Definition at line 27 of file counters_core.c.

Referenced by counters_init(), get_free_counter(), and put_free_counter().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix