Xen Test Framework
exlog.c
Go to the documentation of this file.
1 #include <xtf/lib.h>
2 #include <xtf/exlog.h>
3 #include <xtf/numbers.h>
4 
5 static bool logging = false;
6 static unsigned int log_entries;
7 
8 static exlog_entry_t log[8];
9 
10 void xtf_exlog_start(void)
11 {
12  logging = true;
13  log_entries = 0;
14 }
15 
16 void xtf_exlog_reset(void)
17 {
18  log_entries = 0;
19 }
20 
21 void xtf_exlog_stop(void)
22 {
23  logging = false;
24 }
25 
26 
27 unsigned int xtf_exlog_entries(void)
28 {
29  return log_entries;
30 }
31 
33 {
34  if ( idx < ARRAY_SIZE(log) && idx < log_entries )
35  return &log[idx];
36  return NULL;
37 }
38 
39 void xtf_exlog_log_exception(struct cpu_regs *regs)
40 {
41  if ( !logging )
42  return;
43 
44  if ( log_entries < ARRAY_SIZE(log) )
45  {
46  exlog_entry_t *e = &log[log_entries];
47 
48  e->ip = regs->ip;
49  e->cs = regs->cs;
50  e->ec = regs->error_code;
51  e->ev = regs->entry_vector;
52  }
53  else
54  {
55  printk("Exception log full\n");
57  panic("Exception log full\n");
58  }
59 
60  log_entries++;
61 }
62 
64 {
65  unsigned int i;
66 
67  if ( log_entries == 0 )
68  printk("No exception log entries\n");
69  else
70  for ( i = 0; i < ARRAY_SIZE(log) && i < log_entries; ++i )
71  printk(" exlog[%02u] %04x:%p vec %u[%04x]\n",
72  i, log[i].cs, _p(log[i].ip), log[i].ev, log[i].ec);
73 }
74 
75 /*
76  * Local variables:
77  * mode: C
78  * c-file-style: "BSD"
79  * c-basic-offset: 4
80  * tab-width: 4
81  * indent-tabs-mode: nil
82  * End:
83  */
unsigned long ip
Definition: exlog.h:13
exlog_entry_t * xtf_exlog_entry(unsigned int idx)
Definition: exlog.c:32
void xtf_exlog_dump_log(void)
Definition: exlog.c:63
#define ARRAY_SIZE(a)
Definition: lib.h:8
static bool logging
Definition: exlog.c:5
void panic(const char *fmt,...)
Definition: lib.c:15
Primatives for number manipulation.
void printk(const char *fmt,...)
Definition: console.c:134
unsigned int xtf_exlog_entries(void)
Definition: exlog.c:27
void xtf_exlog_reset(void)
Definition: exlog.c:16
Definition: exlog.h:11
#define NULL
Definition: stddef.h:12
static exlog_entry_t log[8]
Definition: exlog.c:8
uint16_t cs
Definition: exlog.h:14
uint16_t ev
Definition: exlog.h:14
void xtf_exlog_stop(void)
Definition: exlog.c:21
#define _p(v)
Express an abitrary integer v as void *.
Definition: numbers.h:48
void xtf_exlog_start(void)
Definition: exlog.c:10
uint16_t ec
Definition: exlog.h:14
void xtf_exlog_log_exception(struct cpu_regs *regs)
Definition: exlog.c:39
unsigned long idx
Definition: memory.h:34
static unsigned int log_entries
Definition: exlog.c:6