aboutsummaryrefslogtreecommitdiff
path: root/src/util/status.c
blob: f111251efdb30ee6d1ac3854b2e6b3de231297dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <cpu.h>
#include <globals.h>
#include <graphics/lfb.h>
#include <symbols.h>
#include <lib/strings.h>
#include <lib/kmem.h>
#include <sys/core.h>
#include <sys/schedule.h>
#include <util/mutex.h>
#include <util/status.h>
#include <util/time.h>

void output_irq_status(void)
{
	// Basic IRQ
	unsigned long ib_val = load32(IRQ_BASIC_ENABLE);
	// IRQ 1
	unsigned long i1_val = load32(IRQ_ENABLE1);
	// IRQ 2
	unsigned long i2_val = load32(IRQ_ENABLE2);
	// FIQ
	unsigned long f_val = load32(FIQ_CONTROL);

	// Check GPU Interrupt Routing
	unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING);
	draw_cletter(0, 1, (g_val & 0b11) + 0x30, 0x1EA1A1);
	draw_cletter(1, 1, ((g_val >> 2) & 0b11) + 0x30, 0x1EA1A1);

	draw_chex32(4, 1, ib_val, 0x1EA1A1);
	draw_chex32(4+9, 1, i1_val, 0x1EA1A1);
	draw_chex32(4+9*2, 1, i2_val, 0x1EA1A1);
	draw_chex32(4+9*3, 1,  f_val, 0x1EA1A1);

	// Check UART IRQ
	if (i2_val & (1<<25)) {
		draw_cstring(0, 2, "UART", 0x00FF00);
	} else if (f_val == 57) {
		draw_cstring(0, 2, "UART", 0xFFA500);
	} else {
		draw_cstring(0, 2, "UART", 0xFF0000);
	}

	// Check UART IRQ
	if (i1_val & (1<<0)) {
		draw_cstring(5, 2, "STIMERCMP", 0x00FF00);
	} else if (f_val == 1) {
		draw_cstring(5, 2, "STIMERCMP", 0xFFA500);
	} else {
		draw_cstring(5, 2, "STIMERCMP", 0xFF0000);
	}

	if (load32(CORE0_TIMER_IRQCNTL) & 0xF) {
		draw_cstring(4+9+2, 2, "LTIMER", 0x00FF00);
	} else if (load32(CORE0_TIMER_IRQCNTL) & 0xF0) {
		draw_cstring(4+9+2, 2, "LTIMER", 0xFFA500);
	} else {
		draw_cstring(4+9+2, 2, "LTIMER", 0xFF0000);
	}
}

void status(void)
{
	// OS Info
	draw_cstring(7, 0, "v", 0x00FFFF);
	draw_cstring(0, 0, os_name, 0xFF0000);
	draw_cstring(8, 0, os_info_v, 0x00FFFF);

	// GPU IRQ Statuses
	output_irq_status();

	// Timer Status
	draw_cstring(0, 3, "TIMER", 0x00FF00);
	// Output the frequency
	draw_string(6, 3, "@");
	unsigned long frq = read_cntfrq()/1000;
	unsigned long fs_len = draw_u10(8, 3, frq) + 1;
	draw_string(8+fs_len, 3, "kHz");
	// Output the value
	unsigned long v = read_cntv_tval();
	unsigned long vs_len = draw_u10(8+fs_len+4, 3, v)+1;
	draw_string(8+fs_len+4 +vs_len, 3, "                           ");
	draw_letter(8+fs_len+4 +vs_len+1, 3, '|');
	draw_hex32(8+fs_len+7+vs_len, 3, v);

	// Video Status
	draw_cstring(0, 4, "VIDEO", 0x00FF00);
	unsigned long gw_len = draw_u10(6, 4, gwidth);
	unsigned long gh_len = draw_u10(6+gw_len+1, 4, gheight) + 1;
	draw_letter(6+gw_len, 4, 'x');
	if(gisrgb)
		draw_string(6+gw_len+gh_len + 1, 4, "RGB");
	else
		draw_string(6+gw_len+gh_len + 1, 4, "BGR");

	// Core Stacks
	draw_string(0, 5, "SVC      IRQ      FIQ      User/SYS\n");
	unsigned long sp = (unsigned long)getsvcstack();
	draw_hex32(0, 6, sp);
	sp = (unsigned long)getirqstack();
	draw_hex32(9, 6, sp);
	sp = (unsigned long)getfiqstack();
	draw_hex32(9*2, 6, sp);
	sp = (unsigned long)getsysstack();
	draw_hex32(9*3, 6, sp);

	// Report Core that updated status
	unsigned long coren;
	asm volatile (
		"mrc p15, #0, %0, c0, c0, #5\n"
		"and %0, %0, #3" : "=r"(coren) :: "cc");
	draw_string(0, 7, "Status Updated by Core #");
	draw_hex32(24, 7, coren);

	// Report Sys Timer Stataus
	draw_string(0, 8, "Sys Timer Status");
	coren = *(volatile unsigned long*)SYS_TIMER_CS;
	draw_hex32(17, 8, coren);
	draw_string(17+8, 8, ":");
	unsigned long long tval = get_time();
	draw_hex32(17+8, 8, (tval >> 32));
	draw_hex32(17+8+8, 8, tval);
	coren = *(volatile unsigned long*)SYS_TIMER_C0;
	draw_hex32(19+14+8+1, 8, coren);
	draw_string(19+14+9+8, 8, "|");
	draw_string(19+14+18, 8, "           ");
	draw_u10(19+14+18, 8, ((unsigned long)tval)/1000000);
}