Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / common / include / module.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: module.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 ============================================
*/
/*
* Copyright 2004 by Sun Microsystems, Inc.
* All rights reserved.
*
* W% 07/10/12
*/
#ifndef _BLAZE_MODULE_H
#define _BLAZE_MODULE_H
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "mmi.h"
#include "property.h"
#include "dev_registry.h"
// interface to any module
#define MODULE_INTERFACE "Module"
// debug format
#define HERE _here(__FILE__, __LINE__)
// base class for all modules
class Module {
public:
int debug_level;
void debug_err(const char *, ...);
void debug_info(const char *, ...);
void debug_more(const char *, ...);
static const uint8_t PHYSIO_BYTEMASK_ALL = 0xff;
SAM_DeviceId samId;
devRegistry ** mySamDevPtr;
protected:
const char *modname;
const char *instance_name;
mmi_instance_t instance;
char herebuf[80];
property_list *plist;
public:
mmi_instance_t getInstance() { return instance; };
const char *getName() { return instance_name; };
const char *get_mod_name() { return modname; };
const char *_here(const char *, int);
Module(const char *modname, const char *instance_name);
virtual ~Module();
public: // to be supplied by the subclass
static Module *create(const char *modname, const char *instance_name);
static const char *get_help_string();
virtual const char *get_help();
virtual const char *get_version();
virtual bool parse_arg(const char *);
virtual bool check_args();
virtual void init_done();
virtual void module_added(mmi_instance_t, const char*);
virtual void module_deleted(mmi_instance_t, const char*);
virtual void modinfo();
virtual void *get_interface(const char*);
virtual bool dump(FILE *fp);
virtual bool restore(FILE *fp);
virtual void stop();
virtual void restart();
virtual void get_dev_props();
};
extern "C" static void module_create_instance(const char *modname, const char *instance_name);
#endif /* _BLAZE_MODULE_H */