sysregs_gr740.c 1.4 KB
/* -----------------------------------------------------------------------------
 *  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++;
}