OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [examples/] [instrument-test.c] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
/* this is a program which uses eCos instrumentation buffers; it needs
2
   to be linked with a kernel which was compiled with support for
3
   instrumentation */
4
 
5
#include <stdio.h>
6
#include <pkgconf/kernel.h>
7
#include <cyg/kernel/instrmnt.h>
8
#include <cyg/kernel/kapi.h>
9
 
10
#ifndef CYGVAR_KERNEL_INSTRUMENT_EXTERNAL_BUFFER
11
# error You must configure eCos with CYGVAR_KERNEL_INSTRUMENT_EXTERNAL_BUFFER
12
#endif
13
 
14
struct Instrument_Record
15
{
16
    CYG_WORD16  type;                   // record type
17
    CYG_WORD16  thread;                 // current thread id
18
    CYG_WORD    timestamp;              // 32 bit timestamp
19
    CYG_WORD    arg1;                   // first arg
20
    CYG_WORD    arg2;                   // second arg
21
};
22
 
23
struct Instrument_Record instrument_buffer[20];
24
cyg_uint32        instrument_buffer_size = 20;
25
 
26
int main(void)
27
{
28
  int i;
29
 
30
  cyg_instrument_enable(CYG_INSTRUMENT_CLASS_CLOCK, 0);
31
  cyg_instrument_enable(CYG_INSTRUMENT_CLASS_THREAD, 0);
32
  cyg_instrument_enable(CYG_INSTRUMENT_CLASS_ALARM, 0);
33
 
34
  printf("Program to play with instrumentation buffer\n");
35
 
36
  cyg_thread_delay(2);
37
 
38
  cyg_instrument_disable(CYG_INSTRUMENT_CLASS_CLOCK, 0);
39
  cyg_instrument_disable(CYG_INSTRUMENT_CLASS_THREAD, 0);
40
  cyg_instrument_disable(CYG_INSTRUMENT_CLASS_ALARM, 0);
41
 
42
  for (i = 0; i < instrument_buffer_size; ++i) {
43
    printf("Record %02d: type 0x%04x, thread %d, ",
44
           i, instrument_buffer[i].type, instrument_buffer[i].thread);
45
    printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
46
           instrument_buffer[i].timestamp, instrument_buffer[i].arg1,
47
           instrument_buffer[i].arg2);
48
  }
49
  return 0;
50
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.