summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k/stand/bugexec/hello.c
blob: 08ab75d2a271ab773f2cdcf84263f3a407149bbc (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
#include "bug.h"
#include "bugio.h"

void	putchar	__P((char));
int	bcd2int	__P((unsigned int));

void
putchar(char c)
{
	bugoutchr(c);
}

main(struct bugenv *env)
{
	struct bugrtc rtc;
	struct bugbrdid brdid;

	bugrtcrd(&rtc);
	printf("From RTC:\n");
	printf("Year %d\tMonth %d\tDay %d\tDay of Week %d\n",
		bcd2int(rtc.Y), bcd2int(rtc.M), bcd2int(rtc.D), bcd2int(rtc.d));
	printf("Hour %d\tMin %d\tSec %d\tCal %d\n",
		bcd2int(rtc.H), bcd2int(rtc.m), bcd2int(rtc.s), bcd2int(rtc.c));
	printf("From BRDID:\n");
	bugbrdid(&brdid);
/*	printf("Eye catcher %c%c%c%c\n", brdid.eye[0], brdid.eye[1],
			brdid.eye[2], brdid.eye[3]); */
	printf("Board no %d (%d) \tsuffix %c%c\n", bcd2int(brdid.brdno),
		 brdid.brdno, brdid.brdsuf[0], brdid.brdsuf[1]);
/*	printf("Clun %x\tdlun %x\n", brdid.clun, brdid.dlun); */
	return 0;
}

ipow(int base, int i)
{
	int cnt = 1;
	while (i--) {
		cnt *= base;
	}
	return cnt;	
}

int
bcd2int(unsigned int i)
{
	unsigned val = 0;
	int	cnt = 0;
	while (i) {
		val += (i&0xf) * ipow(10,cnt);
		cnt++;
		i >>= 4;
	}
	return val;
}