In legion build config, updated path to GNU tools and updated deprecated Sun CC flag...
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / common / include / csr_common.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: csr_common.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
#ifndef _CSR_COMMON_H
#define _CSR_COMMON_H
#include <iostream>
#include "types.h"
#include "module.h"
typedef int csr_reg_type_t;
typedef enum {
NO_ACCESS_T,
READ_ACCESS_T,
FULL_ACCESS_T
} csr_access_type_t;
typedef struct {
short l;
short r;
const char *name;
} csr_field_t;
typedef struct {
csr_reg_type_t reg_type;
const char *name;
uint64_t offset;
uint64_t read_mask;
uint64_t read_only_mask;
uint64_t write_mask;
uint64_t write_only_mask;
uint64_t set_mask;
uint64_t clear_mask;
uint64_t power_on_reset;
uint64_t *value;
csr_access_type_t sp_access;
csr_access_type_t jtag_access;
csr_access_type_t domain_access;
int depth;
int num_fields;
csr_field_t *fields;
void *next;
} csr_reg_t;
typedef struct csrtab {
const char *name;
csr_reg_type_t type;
uint64_t offset;
uint64_t read_mask;
uint64_t read_only_mask;
uint64_t write_mask;
uint64_t write_only_mask;
uint64_t clear_mask;
uint64_t set_mask;
uint64_t power_on_reset;
int depth;
int num_fields;
csr_access_type_t sp_access;
csr_access_type_t jtag_access;
csr_access_type_t domain_access;
} csrtab_t;
class common_csr{
protected:
virtual csr_reg_type_t csr_offset2reg (uint64_t offset)=0;
public:
void init_csr_reg (csr_reg_t *csr_reg, csr_reg_type_t reg_type,csrtab_t *csrtab ,csr_field_t *csr_fields,uint64_t *cumsum);
csr_reg_t *csr_get_reg (csr_reg_t **csr_list, uint64_t offset,csrtab_t *csrtab ,csr_field_t *csr_fields,uint64_t *cumsum);
csr_reg_type_t csr_get_reg_by_name (char *regname,csrtab_t *csr_tab,uint64_t ncsrtab);
csr_reg_t *csr_get_regtype (csr_reg_t **csr_list, csr_reg_type_t reg_type,csrtab_t *csrtab ,csr_field_t *csr_fields,uint64_t *cumsum);
uint64_t csr_get_field (Module *csr_obj, csr_reg_t *csr_reg, const char *field_name, uint64_t offset);
uint64_t csr_set_field (Module *csr_obj, csr_reg_t *csr_reg, const char *field_name, uint64_t field_value, uint64_t offset);
int csr_read_reg (Module *csr_obj, csr_reg_t *csr_reg, uint64_t offset,uint64_t *value);
int csr_write_reg (Module *csr_obj, csr_reg_t *csr_reg, uint64_t offset,uint64_t reg_value);
uint64_t csr_value_get_field(Module *err_log, csr_reg_t *csr_reg,
const char *field_name, uint64_t reg_value);
int csr_field_changed(Module *err_log, csr_reg_t *csr_reg, const char *field_name, uint64_t reg_value1, uint64_t reg_value2);
const char *csr_get_field_name(Module *csr_obj, csr_reg_t *csr_reg, int bit, uint64_t reg_value);
bool csr_reset_reg(Module *csr_obj, csr_reg_t **csr_list,uint64_t value, csr_reg_type_t type,csrtab_t *csrtab ,csr_field_t *csr_fields,uint64_t *cumsum, uint64_t offset);
bool csr_set_mask_field(Module *csr_obj,csr_reg_t **csr_list,csrtab_t *csrtab,csr_field_t *csr_fields,uint64_t *cumsum,csr_reg_t *csr_reg,const char *field_name,uint64_t field_value, csr_reg_type_t rw1c, csr_reg_type_t rw, uint64_t offset);
bool csr_write_mask_reg(Module *csr_obj, csr_reg_t **csr_list,csr_reg_type_t type,csrtab_t *csrtab,csr_field_t *csr_fields,uint64_t *cumsum ,uint64_t old_value, uint64_t *new_value, csr_reg_type_t rw1c, csr_reg_type_t rw1s, csr_reg_type_t rw, uint64_t offset);
};
#endif