sysregs_gr740.c
1.4 KB
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
/* -----------------------------------------------------------------------------
* Copyright (C) 2020 daiteq s.r.o. http://www.daiteq.com
*
* This program is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
*
* -----------------------------------------------------------------------------
* Filename : sysregs.c
* Authors : Martin Danek
* Description : system register definitions
* Release :
* Version : 1.0
* Date : 14.6.2020
* -----------------------------------------------------------------------------
*/
#include "asi.h"
#include "asm.h"
#include "sysregs_gr740.h"
#define cpu_reg_write(adr,byData) ((*(unsigned int volatile *)(adr))=byData)
void sysregs740_init() {
wr_asr(GR740_UPCOUNTER_MSW_ASR, UPCOUNTER_RST);
wr_asr(GR740_UPCOUNTER_MSW_ASR, UPCOUNTER_START);
// cpu_reg_write(0xe0000040, (unsigned)0x00000040);
}
void sysregs740_start() {
wr_asr(GR740_UPCOUNTER_MSW_ASR, UPCOUNTER_START);
}
void sysregs740_stop() {
wr_asr(GR740_UPCOUNTER_MSW_ASR, UPCOUNTER_STOP);
}
void sysregs740_read(unsigned *ticks_lo, unsigned *ticks_hi, unsigned *insns_lo, unsigned *insns_hi) {
static unsigned ti=0;
rd_asr(GR740_UPCOUNTER_MSW_ASR, *ticks_hi);
*ticks_hi &= 0x7fffffff;
rd_asr(GR740_UPCOUNTER_LSW_ASR, *ticks_lo);
*insns_lo=ti;
*insns_hi=0;
ti++;
}