/* * QEMU monitor * * Copyright (c) 2003-2004 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "vl.h" #include //#define DEBUG //#define DEBUG_COMPLETION #ifndef offsetof #define offsetof(type, field) ((size_t) &((type *)0)->field) #endif /* * Supported types: * * 'F' filename * 'B' block device name * 's' string (accept optional quote) * 'i' integer * '/' optional gdb-like print format (like "/10x") * * '?' optional type (for 'F', 's' and 'i') * */ typedef struct term_cmd_t { const char *name; const char *args_type; void (*handler)(); const char *params; const char *help; } term_cmd_t; static CharDriverState *monitor_hd; static term_cmd_t term_cmds[]; static term_cmd_t info_cmds[]; static char term_outbuf[1024]; static int term_outbuf_index; static void monitor_start_input(void); void term_flush(void) { if (term_outbuf_index > 0) { if(monitor_hd) qemu_chr_write(monitor_hd, term_outbuf, term_outbuf_index); else fwrite(term_outbuf, term_outbuf_index, 1, stderr); term_outbuf_index = 0; } } /* flush at every end of line or if the buffer is full */ void term_puts(const char *str) { int c; for(;;) { c = *str++; if (c == '\0') break; term_outbuf[term_outbuf_index++] = c; if (term_outbuf_index >= sizeof(term_outbuf) || c == '\n') term_flush(); } } void term_vprintf(const char *fmt, va_list ap) { char buf[4096]; vsnprintf(buf, sizeof(buf), fmt, ap); term_puts(buf); } void term_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); term_vprintf(fmt, ap); va_end(ap); } static int compare_cmd(const char *name, const char *list) { const char *p, *pstart; int len; len = strlen(name); p = list; for(;;) { pstart = p; p = strchr(p, '|'); if (!p) p = pstart + strlen(pstart); if ((p - pstart) == len && !memcmp(pstart, name, len)) return 1; if (*p == '\0') break; p++; } return 0; } static void help_cmd1(term_cmd_t *cmds, const char *prefix, const char *name) { term_cmd_t *cmd; for(cmd = cmds; cmd->name != NULL; cmd++) { if (!name || !strcmp(name, cmd->name)) term_printf("%s%s %s -- %s\n", prefix, cmd->name, cmd->params, cmd->help); } } static void help_cmd(const char *name) { if (name && !strcmp(name, "info")) { help_cmd1(info_cmds, "info ", NULL); } else { help_cmd1(term_cmds, "", name); if (name && !strcmp(name, "log")) { CPULogItem *item; term_printf("Log items (comma separated):\n"); term_printf("%-10s %s\n", "none", "remove all logs"); for(item = cpu_log_items; item->mask != 0; item++) { term_printf("%-10s %s\n", item->name, item->help); } } } } static void do_help(const char *name) { help_cmd(name); } static void do_commit(void) { int i; for (i = 0; i < MAX_DISKS; i++) { if (bs_table[i]) { bdrv_commit(bs_table[i]); } } } static void do_info(const char *item) { term_cmd_t *cmd; if (!item) goto help; for(cmd = info_cmds; cmd->name != NULL; cmd++) { if (compare_cmd(item, cmd->name)) goto found; } help: help_cmd("info"); return; found: cmd->handler(); } static void do_info_version(void) { term_printf("%s\n", QEMU_VERSION); } static void do_info_network(void) { int i, j; NetDriverState *nd; for(i = 0; i < nb_nics; i++) { nd = &nd_table[i]; term_printf("%d: ifname=%s macaddr=", i, nd->ifname); for(j = 0; j < 6; j++) { if (j > 0) term_printf(":"); term_printf("%02x", nd->macaddr[j]); } term_printf("\n"); } } static void do_info_block(void) { bdrv_info(); } static void do_info_history (void) { int i; const char *str; i = 0; for(;;) { str = readline_get_history(i); if (!str) break; term_printf("%d: '%s'\n", i, str); i++; } } extern void destroy_vmx_domain(void); static void do_quit(void) { destroy_vmx_domain(); exit(0); } static int eject_device(BlockDriverState *bs, int force) { if (bdrv_is_inserted(bs)) { if (!force) { if (!bdrv_is_removable(bs)) { term_printf("device is not removable\n"); return -1; } if (bdrv_is_locked(bs)) { term_printf("device is locked\n"); return -1; } } bdrv_close(bs); } return 0; } static void do_eject(int force, const char *filename) { BlockDriverState *bs; bs = bdrv_find(filename); if (!bs) { term_printf("device not found\n"); return; } eject_device(bs, force); } static void do_change(const char *device, const char *filename) { BlockDriverState *bs; #if 0 int i; char password[256]; #endif bs = bdrv_find(device); if (!bs) { term_printf("device not found\n"); return; } if (eject_device(bs, 0) < 0) return; bdrv_open(bs, filename, 0); #if 0 if (bdrv_is_encrypted(bs)) { term_printf("%s is encrypted.\n", device); for(i = 0; i < 3; i++) { monitor_readline("Password: ", 1, password, sizeof(password)); if (bdrv_set_key(bs, password) == 0) break; term_printf("invalid password\n"); } } #endif } static void do_screen_dump(const char *filename) { vga_screen_dump(filename); } static void do_log(const char *items) { int mask; if (!strcmp(items, "none")) { mask = 0; } else { mask = cpu_str_to_log_mask(items); if (!mask) { help_cmd("log"); return; } } cpu_set_log(mask); } static term_cmd_t term_cmds[] = { { "help|?", "s?", do_help, "[cmd]", "show the help" }, { "commit", "", do_commit, "", "commit changes to the disk images (if -snapshot is used)" }, { "info", "s?", do_info, "subcommand", "show various information about the system state" }, { "q|quit", "", do_quit, "", "quit the emulator" }, { "eject", "-fB", do_eject, "[-f] device", "eject a removable media (use -f to force it)" },
// Emacs style mode select   -*- C++ -*- 
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// DESCRIPTION:
//	Refresh/render internal state variables (global).
//
//-----------------------------------------------------------------------------


#ifndef __R_STATE__
#define __R_STATE__

// Need data structure definitions.
#include "d_player.h"
#include "r_data.h"



#ifdef __GNUG__
#pragma interface
#endif



//
// Refresh internal data structures,
//  for rendering.
//

// needed for texture pegging
extern fixed_t*		textureheight;

// needed for pre rendering (fracs)
extern fixed_t*		spritewidth;

extern fixed_t*		spriteoffset;
extern fixed_t*		spritetopoffset;

extern lighttable_t*	colormaps;

extern int		viewwidth;
extern int		scaledviewwidth;
extern int		viewheight;

extern int		firstflat;

// for global animation
extern int*		flattranslation;	
extern int*		texturetranslation;	


// Sprite....
extern int		firstspritelump;
extern int		lastspritelump;
extern int		numspritelumps;



//
// Lookup tables for map data.
//
extern int		numsprites;
extern spritedef_t*	sprites;

extern int		numvertexes;
extern vertex_t*	vertexes;

extern int		numsegs;
extern seg_t*		segs;

extern int		numsectors;
extern sector_t*	sectors;

extern int		numsubsectors;
extern subsector_t*	subsectors;

extern int		numnodes;
extern node_t*		nodes;

extern int		numlines;
extern line_t*		lines;

extern int		numsides;
extern side_t*		sides;


//
// POV data.
//
extern fixed_t		viewx;
extern fixed_t		viewy;
extern fixed_t		viewz;

extern angle_t		viewangle;
extern player_t*	viewplayer;


// ?
extern angle_t		clipangle;

extern int		viewangletox[FINEANGLES/2];
extern angle_t		xtoviewangle[SCREENWIDTH+1];
//extern fixed_t		finetangent[FINEANGLES/2];

extern fixed_t		rw_distance;
extern angle_t		rw_normalangle;



// angle to line origin
extern int		rw_angle1;

// Segs count?
extern int		sscount;

extern visplane_t*	floorplane;
extern visplane_t*	ceilingplane;


#endif
//-----------------------------------------------------------------------------
//
// $Log:$
//
//-----------------------------------------------------------------------------