| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: module.h |
| 5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 7 | * |
| 8 | * The above named program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public |
| 10 | * License version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * The above named program is distributed in the hope that it will be |
| 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public |
| 18 | * License along with this work; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | * ========== Copyright Header End ============================================ |
| 22 | */ |
| 23 | /* |
| 24 | * Copyright 2004 by Sun Microsystems, Inc. |
| 25 | * All rights reserved. |
| 26 | * |
| 27 | * W% 07/10/12 |
| 28 | */ |
| 29 | #ifndef _BLAZE_MODULE_H |
| 30 | #define _BLAZE_MODULE_H |
| 31 | |
| 32 | #include <sys/types.h> |
| 33 | #include <stdio.h> |
| 34 | #include <stdlib.h> |
| 35 | |
| 36 | #include "mmi.h" |
| 37 | #include "property.h" |
| 38 | #include "dev_registry.h" |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | // interface to any module |
| 44 | #define MODULE_INTERFACE "Module" |
| 45 | |
| 46 | // debug format |
| 47 | #define HERE _here(__FILE__, __LINE__) |
| 48 | |
| 49 | // base class for all modules |
| 50 | class Module { |
| 51 | public: |
| 52 | int debug_level; |
| 53 | void debug_err(const char *, ...); |
| 54 | void debug_info(const char *, ...); |
| 55 | void debug_more(const char *, ...); |
| 56 | static const uint8_t PHYSIO_BYTEMASK_ALL = 0xff; |
| 57 | SAM_DeviceId samId; |
| 58 | devRegistry ** mySamDevPtr; |
| 59 | |
| 60 | protected: |
| 61 | const char *modname; |
| 62 | const char *instance_name; |
| 63 | mmi_instance_t instance; |
| 64 | char herebuf[80]; |
| 65 | property_list *plist; |
| 66 | |
| 67 | |
| 68 | public: |
| 69 | mmi_instance_t getInstance() { return instance; }; |
| 70 | const char *getName() { return instance_name; }; |
| 71 | const char *get_mod_name() { return modname; }; |
| 72 | const char *_here(const char *, int); |
| 73 | Module(const char *modname, const char *instance_name); |
| 74 | virtual ~Module(); |
| 75 | |
| 76 | public: // to be supplied by the subclass |
| 77 | static Module *create(const char *modname, const char *instance_name); |
| 78 | static const char *get_help_string(); |
| 79 | virtual const char *get_help(); |
| 80 | virtual const char *get_version(); |
| 81 | virtual bool parse_arg(const char *); |
| 82 | virtual bool check_args(); |
| 83 | virtual void init_done(); |
| 84 | virtual void module_added(mmi_instance_t, const char*); |
| 85 | virtual void module_deleted(mmi_instance_t, const char*); |
| 86 | virtual void modinfo(); |
| 87 | virtual void *get_interface(const char*); |
| 88 | virtual bool dump(FILE *fp); |
| 89 | virtual bool restore(FILE *fp); |
| 90 | virtual void stop(); |
| 91 | virtual void restart(); |
| 92 | virtual void get_dev_props(); |
| 93 | }; |
| 94 | |
| 95 | extern "C" static void module_create_instance(const char *modname, const char *instance_name); |
| 96 | #endif /* _BLAZE_MODULE_H */ |