* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: mon_pli.c
* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For the avoidance of doubt, and except that if any non-GPL license
* choice is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any
* software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later version
* may be used, or where a choice of which version of the GPL is applied is
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* ========== Copyright Header End ============================================
#include "ctype.h" /* for toupper */
#include "stdio.h" /* for sscanf.h */
#define MAX_STRING_LEN 1000
static char mon_name_buf
[64];
static char *mon_inst_path
[128];
static int mon_level
[128];
static char *diserr_arr
[64];
static char *diswarn_arr
[64];
static int monInit_done
= 0 ;
static int error_disable
= 0 ;
char format_buffer
[4096];
get_time (int *ms
, int *us
, int *ns
, int *ps
)
unsigned long long llx
, lly
;
time_lo
= tf_getlongtime (&time_hi
);
llx
= time_lo
; llx
= (llx
<< 32) >> 32;
lly
= time_hi
; lly
= (lly
<< 32);
*ps
= lly
% 1000; lly
/= 1000;
*ns
= lly
% 1000; lly
/= 1000;
*us
= lly
% 1000; lly
/= 1000;
char *format(char *mipname
)
int num_args
, cur_arg
, len
;
len
= sprintf (format_buffer
, " ");
fmt_str
= tf_getcstringp(ARG2
);
ptr
= format_buffer
+ len
;
len
= sprintf (ptr
, "%s", tf_strgetp(cur_arg
, 'b'));
len
= sprintf (ptr
, "%s", tf_strgetp(cur_arg
, 'o'));
len
= sprintf (ptr
, "%s", tf_strgetp(cur_arg
, 'd'));
len
= sprintf (ptr
, "%s", tf_strgetp(cur_arg
, 'h'));
len
= sprintf (ptr
, "%e", tf_getrealp(cur_arg
));
len
= sprintf (ptr
, "%e", tf_getrealp(cur_arg
));
len
= sprintf (ptr
, "%d", tf_gettime());
len
= sprintf (ptr
, "%s", tf_strgetp(cur_arg
, 'e'));
len
= sprintf (ptr
, "%s", mipname
);
int strmatch (char* s0
, char* s1
)
if (p0
== NULL
) return 1;
/************************************************************************/
/* $monInit check routine */
/************************************************************************/
void monInit_check(int data
, int reason
)
if (monInit_done
) return ;
* +mon0=cpu0:25 +mon1=ccx:35
sprintf (mon_name_buf
, "mon%d=\0", mon_path_num
);
string
= mc_scan_plusargs(mon_name_buf
);
strcpy(mon_name_buf
, string
);
ptr
= strtok (mon_name_buf
, ":");
tf_error("Syntax error in mon%i plus arg (instance path)\n", mon_path_num
);
mon_inst_path
[mon_path_num
] = strdup (ptr
);
ptr
= strtok (NULL
, ":");
tf_error("Syntax error in mon%i plus arg (level)\n", mon_path_num
);
mon_level
[mon_path_num
] = atoi (ptr
);
string
= mc_scan_plusargs("diserr=");
ptr
= strtok (string
, ":");
tf_error("Syntax error in diserr plus arg\n");
diserr_arr
[diserr_num
] = strdup (ptr
);
ptr
= strtok (NULL
, ":");
string
= mc_scan_plusargs("diswarn=");
ptr
= strtok (string
, ":");
tf_error("Syntax error in diswarn plus arg\n");
diswarn_arr
[diswarn_num
] = strdup (ptr
);
ptr
= strtok (NULL
, ":");
/************************************************************************/
/* $monInit call routine */
/************************************************************************/
void monInit_call(int data
, int reason
)
// /************************************************************************/
// /* $info check routine */
// /************************************************************************/
// void info_check(int data, int reason)
// /************************************************************************/
// /* $info call routine */
// /************************************************************************/
// void infow_call(int data, int reason)
// get_time (&ms, &us, &ns, &ps);
// ptr_mipname = tf_mipname();
// /* Requires at least two arguments */
// if (tf_nump() < ARG2) {
// tf_error("$info requires at least two arguments, info-level and format-string");
// /* First argument to $info() must be a value */
// if (tf_typep(ARG1) != tf_readonly) {
// tf_error("First argument to $info must be a value");
// /* Second argument to $info() must be a string */
// if (tf_typep(ARG2) != tf_string) {
// tf_error("Second argument to $info must be a formating string");
// level = tf_getp(ARG1);
// io_printf ("%05d.%03d.%03d.%03d: INFO (%d): %s:%s", ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
// for (i = 0; i < mon_path_num; i++) {
// if ((level <= mon_level[i]) &&
// (strmatch (mon_inst_path[i], ptr_mipname) == 0)
// io_printf ("%05d.%03d.%03d.%03d: INFO (%d): %s:%s", ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
// void info_call(int data, int reason)
// get_time (&ms, &us, &ns, &ps);
// ptr_mipname = tf_mipname();
// /* Requires at least two arguments */
// if (tf_nump() < ARG2) {
// tf_error("$info requires at least two arguments, info-level and format-string");
// /* First argument to $info() must be a value */
// if (tf_typep(ARG1) != tf_readonly) {
// tf_error("First argument to $info must be a value");
// /* Second argument to $info() must be a string */
// if (tf_typep(ARG2) != tf_string) {
// tf_error("Second argument to $info must be a formating string");
// level = tf_getp(ARG1);
// io_printf ("%05d.%03d.%03d.%03d: INFO(%d): %s:%s\n", ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
// for (i = 0; i < mon_path_num; i++) {
// if ((level <= mon_level[i]) &&
// (strmatch (mon_inst_path[i], ptr_mipname) == 0)
// io_printf ("%05d.%03d.%03d.%03d: INFO(%d): %s:%s\n", ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
/************************************************************************/
/* $error check routine */
/************************************************************************/
void error_check(int data
, int reason
)
/************************************************************************/
/* $error call routine */
/************************************************************************/
void error_call(int data
, int reason
)
get_time (&ms
, &us
, &ns
, &ps
);
ptr_mipname
= tf_mipname();
/* Requires at least two arguments */
tf_error("$error requires at least two arguments, error-disable-tag, and format-string");
/* First argument to $error() must be a string */
if (tf_typep(ARG1
) != tf_string
) {
tf_error("First argument to $error must be a value");
/* Second argument to $error() must be a string */
if (tf_typep(ARG2
) != tf_string
) {
tf_error("Second argument to $error must be a formating string");
for (i
= 0; i
< diserr_num
; i
++) {
ptr
= strchr(diserr_arr
[i
], '.');
if (strcmp (tf_getcstringp(ARG1
), diserr_arr
[i
]) == 0) {
io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms
,us
,ns
,ps
, ptr_mipname
, format(ptr_mipname
));
sprintf (format_buffer
, "%s.%s\0", tf_getcstringp(ARG1
), ptr_mipname
);
if (strcmp (format_buffer
, diserr_arr
[i
]) == 0) {
io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms
,us
,ns
,ps
, ptr_mipname
, format(ptr_mipname
));
io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n", ms
,us
,ns
,ps
, ptr_mipname
, format(ptr_mipname
));
if (!error_disable
) tf_dofinish();
// /************************************************************************/
// /* $warn check routine */
// /************************************************************************/
// void warn_check(int data, int reason)
// /************************************************************************/
// /* $warn call routine */
// /************************************************************************/
// void warn_call(int data, int reason)
// get_time (&ms, &us, &ns, &ps);
// ptr_mipname = tf_mipname();
// /* Requires at least two arguments */
// if (tf_nump() < ARG2) {
// tf_error("$warn requires at least two arguments, warn-disable-tag, and format-string");
// /* First argument to $warn() must be a string */
// if (tf_typep(ARG1) != tf_string) {
// tf_error("First argument to $warn must be a value");
// /* Second argument to $warn() must be a string */
// if (tf_typep(ARG2) != tf_string) {
// tf_error("Second argument to $warn must be a formating string");
// for (i = 0; i < diswarn_num; i++) {
// if (strcmp (tf_getcstringp(ARG1), diswarn_arr[i]) == 0) return;
// io_printf ("%05d.%03d.%03d.%03d: WARN: %s:%s\n", ms,us,ns,ps, ptr_mipname, format(ptr_mipname));
// /************************************************************************/
// /* disable exit on error during runtime */
// /************************************************************************/
// void monErrorDisable_call ()
// /************************************************************************/
// /* enable exit on error during runtime */
// /************************************************************************/
// void monErrorEnable_call ()