Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / system / blaze / include / ui_utils.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: ui_utils.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 (C) 1996, Sun Microsystems, Inc.
*/
#ident "@(#)1.7 06/01/23 SMI ui_utils.h"
#ifndef _UI_UTILS_H_
#define _UI_UTILS_H_
#include <thread.h>
#include <sys/time.h>
#include "types.h"
char* ui_parse_delimiter (char*, char**, char);
char* ui_parsew (char*, char**); // 2nd arg is not const (UGH)
void ui_remove_trailing_whitespace (char*);
int escaped (char*, char*);
int back_slash (char*, char*);
int in_braces (char*, char*);
int ui_get_cmdlist (char*, char**, int*);
bool_t is_string_all_digits (char *str);
char* get_env_name (char *str);
void ui_print_all_var (void);
bool_t ui_set_var (char* var, char* val);
bool_t ui_dump_all_var (FILE* fp);
bool_t ui_restore_all_var (FILE* fp);
char * extract_string (char * cmd_str);
// ui_argv_argc tokenizes a command string using space as the separator
// it allocates an array of char* as well as strings that are the elements of
// this array. This array has to be explicitly freed by the caller by calling
// ui_argv_free().
extern char ** ui_argv_argc_parse (char *cmd, int *neval);
extern void ui_argv_free(int argc, char **argv);
#define CMPSTR(s,t) (strcmp(s,t) == NULL)
#define CMDDUP(s,t,i) {for(i=0;(t[i] != ' ') || (t[i] != '\0'); i++) *(s+i) = *(t+i);}
#define UI_CMD_DONE 1
#define MAX_PATH_LEN 1024
/*
* For time_cmd
*/
struct timeusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
};
/*
* result = a + b;
*/
#define ADDTIMES(result, a, b) { \
(result).tv_sec = (a).tv_sec + (b).tv_sec; \
if (((result).tv_usec = ((a).tv_nsec + (b).tv_nsec)/1000) >= 1000000){\
(result).tv_sec++; \
(result).tv_usec -= 1000000; \
} \
}
typedef struct wd_thread
{
mutex_t wd_lock;
volatile uint64_t wd_cycles;
} wd_thread_t;
typedef struct time_thread
{
mutex_t time_lock;
volatile struct timeval beg_time;
volatile struct timeval end_time;
volatile uint64_t beg_icount;
volatile uint64_t end_icount;
volatile uint32_t stop_time;
} time_thread_t;
extern void init_cycles_wd ();
extern void init_time_wd ();
extern void cycles_wd_run (uint64_t cycles);
extern void time_wd_run (uint64_t cycles);
extern void time_wd_stop ();
extern int update_remote_ui();
/*
* ASM/DISASM Preprocessing Routines
*/
int pp_asm_cmd (char** cp, LWord* address);
#endif