whispace, tab2space, indent, dos2unix and other cleanups

This commit is contained in:
Stanislav Shwartsman 2008-02-15 22:05:43 +00:00
parent cdcd7522aa
commit a459a64f3e
66 changed files with 4010 additions and 4233 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: dbg_main.cc,v 1.112 2008-02-15 19:03:53 sshwarts Exp $ // $Id: dbg_main.cc,v 1.113 2008-02-15 22:05:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -375,8 +375,8 @@ void bx_get_command(void)
} }
// look for first non-whitespace character // look for first non-whitespace character
while (((*tmp_buf_ptr == ' ') || (*tmp_buf_ptr == '\t')) && while (((*tmp_buf_ptr == ' ') || (*tmp_buf_ptr == '\t')) &&
(*tmp_buf_ptr != '\n') && (*tmp_buf_ptr != 0) ) (*tmp_buf_ptr != '\n') && (*tmp_buf_ptr != 0))
{ {
tmp_buf_ptr++; tmp_buf_ptr++;
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.131 2008-02-15 19:03:52 sshwarts Exp $ // $Id: config.cc,v 1.132 2008-02-15 22:05:37 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -1774,7 +1774,7 @@ static const char *get_builtin_variable(const char *varname)
data[0] = 0; data[0] = 0;
size = MAX_PATH; size = MAX_PATH;
if (RegQueryValueEx(hkey, "", NULL, (LPDWORD)&type, (LPBYTE)data, if (RegQueryValueEx(hkey, "", NULL, (LPDWORD)&type, (LPBYTE)data,
(LPDWORD)&size ) == ERROR_SUCCESS) { (LPDWORD)&size) == ERROR_SUCCESS) {
RegCloseKey(hkey); RegCloseKey(hkey);
return data; return data;
} else { } else {
@ -3047,7 +3047,7 @@ static Bit32s parse_line_formatted(const char *context, int num_params, char *pa
} }
else else
{ {
PARSE_ERR(( "%s: directive '%s' not understood", context, params[0])); PARSE_ERR(("%s: directive '%s' not understood", context, params[0]));
} }
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cpu.cc,v 1.206 2008-02-02 21:46:49 sshwarts Exp $ // $Id: cpu.cc,v 1.207 2008-02-15 22:05:39 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -531,12 +531,12 @@ unsigned BX_CPU_C::handleAsyncEvent(void)
// will be processed on the next boundary. // will be processed on the next boundary.
BX_CPU_THIS_PTR inhibit_mask = 0; BX_CPU_THIS_PTR inhibit_mask = 0;
if ( !(BX_CPU_INTR || if (!(BX_CPU_INTR ||
BX_CPU_THIS_PTR debug_trap || BX_CPU_THIS_PTR debug_trap ||
BX_HRQ || BX_HRQ ||
BX_CPU_THIS_PTR get_TF() BX_CPU_THIS_PTR get_TF()
#if BX_X86_DEBUGGER #if BX_X86_DEBUGGER
|| (BX_CPU_THIS_PTR dr7 & 0xff) || (BX_CPU_THIS_PTR dr7 & 0xff)
#endif #endif
)) ))
BX_CPU_THIS_PTR async_event = 0; BX_CPU_THIS_PTR async_event = 0;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.427 2008-02-15 19:03:53 sshwarts Exp $ // $Id: cpu.h,v 1.428 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -941,13 +941,13 @@ public: // for now...
#define ArithmeticalFlag(flag, lfMask, eflagsBitShift) \ #define ArithmeticalFlag(flag, lfMask, eflagsBitShift) \
BX_SMF bx_bool get_##flag##Lazy(void); \ BX_SMF bx_bool get_##flag##Lazy(void); \
BX_SMF bx_bool getB_##flag(void) { \ BX_SMF bx_bool getB_##flag(void) { \
if ( (BX_CPU_THIS_PTR lf_flags_status & (lfMask)) == 0) \ if ((BX_CPU_THIS_PTR lf_flags_status & (lfMask)) == 0) \
return (BX_CPU_THIS_PTR eflags >> eflagsBitShift) & 1; \ return (BX_CPU_THIS_PTR eflags >> eflagsBitShift) & 1; \
else \ else \
return !!get_##flag##Lazy(); \ return !!get_##flag##Lazy(); \
} \ } \
BX_SMF bx_bool get_##flag(void) { \ BX_SMF bx_bool get_##flag(void) { \
if ( (BX_CPU_THIS_PTR lf_flags_status & (lfMask)) == 0) \ if ((BX_CPU_THIS_PTR lf_flags_status & (lfMask)) == 0) \
return BX_CPU_THIS_PTR eflags & (lfMask); \ return BX_CPU_THIS_PTR eflags & (lfMask); \
else \ else \
return get_##flag##Lazy(); \ return get_##flag##Lazy(); \
@ -966,7 +966,7 @@ public: // for now...
BX_CPU_THIS_PTR eflags |= (lfMask); \ BX_CPU_THIS_PTR eflags |= (lfMask); \
} \ } \
BX_SMF void force_##flag(void) { \ BX_SMF void force_##flag(void) { \
if ( (BX_CPU_THIS_PTR lf_flags_status & (lfMask)) != 0) { \ if ((BX_CPU_THIS_PTR lf_flags_status & (lfMask)) != 0) { \
set_##flag(!!get_##flag##Lazy()); \ set_##flag(!!get_##flag##Lazy()); \
} \ } \
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: exception.cc,v 1.100 2008-02-02 21:46:50 sshwarts Exp $ // $Id: exception.cc,v 1.101 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -71,7 +71,7 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
// interrupt vector must be within IDT table limits, // interrupt vector must be within IDT table limits,
// else #GP(vector number*16 + 2 + EXT) // else #GP(vector number*16 + 2 + EXT)
idtindex = vector*16; idtindex = vector*16;
if ( (idtindex + 15) > BX_CPU_THIS_PTR idtr.limit) { if ((idtindex + 15) > BX_CPU_THIS_PTR idtr.limit) {
BX_ERROR(("interrupt(long mode): vector > idtr.limit")); BX_ERROR(("interrupt(long mode): vector > idtr.limit"));
BX_ERROR(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit)); BX_ERROR(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit));
BX_ERROR(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base)); BX_ERROR(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base));
@ -295,7 +295,7 @@ void BX_CPU_C::protected_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error
// interrupt vector must be within IDT table limits, // interrupt vector must be within IDT table limits,
// else #GP(vector number*8 + 2 + EXT) // else #GP(vector number*8 + 2 + EXT)
if ( (vector*8 + 7) > BX_CPU_THIS_PTR idtr.limit) { if ((vector*8 + 7) > BX_CPU_THIS_PTR idtr.limit) {
BX_DEBUG(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit)); BX_DEBUG(("IDT.limit = %04x", (unsigned) BX_CPU_THIS_PTR idtr.limit));
BX_DEBUG(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base)); BX_DEBUG(("IDT.base = %06x", (unsigned) BX_CPU_THIS_PTR idtr.base));
BX_DEBUG(("interrupt vector must be within IDT table limits")); BX_DEBUG(("interrupt vector must be within IDT table limits"));

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: io_pro.cc,v 1.28 2008-02-02 21:46:51 sshwarts Exp $ // $Id: io_pro.cc,v 1.29 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -132,7 +132,7 @@ bx_bool BX_CPU_C::allow_io(Bit16u addr, unsigned len)
return(0); return(0);
} }
if ( (Bit32s) (addr/8) >= (Bit32s) (BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled - io_base)) { if ((Bit32s) (addr/8) >= (Bit32s) (BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled - io_base)) {
BX_ERROR(("allow_io(): IO addr %x (len %d) outside TSS IO permission map (base=%x, limit=%x) #GP(0)", BX_ERROR(("allow_io(): IO addr %x (len %d) outside TSS IO permission map (base=%x, limit=%x) #GP(0)",
addr, len, io_base, BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled)); addr, len, io_base, BX_CPU_THIS_PTR tr.cache.u.system.limit_scaled));
return(0); return(0);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: proc_ctrl.cc,v 1.202 2008-02-15 19:03:53 sshwarts Exp $ // $Id: proc_ctrl.cc,v 1.203 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -301,24 +301,24 @@ void BX_CPU_C::MOV_DdRd(bxInstruction_c *i)
// Note: processor clears GD upon entering debug exception // Note: processor clears GD upon entering debug exception
// handler, to allow access to the debug registers // handler, to allow access to the debug registers
} }
if ( (((val_32>>16) & 3)==2) || if ((((val_32>>16) & 3)==2) ||
(((val_32>>20) & 3)==2) || (((val_32>>20) & 3)==2) ||
(((val_32>>24) & 3)==2) || (((val_32>>24) & 3)==2) ||
(((val_32>>28) & 3)==2)) { (((val_32>>28) & 3)==2)) {
// IO breakpoints (10b) are not yet supported. // IO breakpoints (10b) are not yet supported.
BX_PANIC(("MOV_DdRd: write of %08x contains IO breakpoint", val_32)); BX_PANIC(("MOV_DdRd: write of %08x contains IO breakpoint", val_32));
} }
if ( (((val_32>>18) & 3)==2) || if ((((val_32>>18) & 3)==2) ||
(((val_32>>22) & 3)==2) || (((val_32>>22) & 3)==2) ||
(((val_32>>26) & 3)==2) || (((val_32>>26) & 3)==2) ||
(((val_32>>30) & 3)==2)) { (((val_32>>30) & 3)==2)) {
// LEN0..3 contains undefined length specifier (10b) // LEN0..3 contains undefined length specifier (10b)
BX_PANIC(("MOV_DdRd: write of %08x contains undefined LENx", val_32)); BX_PANIC(("MOV_DdRd: write of %08x contains undefined LENx", val_32));
} }
if ( ((((val_32>>16) & 3)==0) && (((val_32>>18) & 3)!=0)) || if (((((val_32>>16) & 3)==0) && (((val_32>>18) & 3)!=0)) ||
((((val_32>>20) & 3)==0) && (((val_32>>22) & 3)!=0)) || ((((val_32>>20) & 3)==0) && (((val_32>>22) & 3)!=0)) ||
((((val_32>>24) & 3)==0) && (((val_32>>26) & 3)!=0)) || ((((val_32>>24) & 3)==0) && (((val_32>>26) & 3)!=0)) ||
((((val_32>>28) & 3)==0) && (((val_32>>30) & 3)!=0))) ((((val_32>>28) & 3)==0) && (((val_32>>30) & 3)!=0)))
{ {
// Instruction breakpoint with LENx not 00b (1-byte length) // Instruction breakpoint with LENx not 00b (1-byte length)
BX_PANIC(("MOV_DdRd: write of %08x, R/W=00b LEN!=00b", val_32)); BX_PANIC(("MOV_DdRd: write of %08x, R/W=00b LEN!=00b", val_32));
@ -486,28 +486,28 @@ void BX_CPU_C::MOV_DqRq(bxInstruction_c *i)
// Note: processor clears GD upon entering debug exception // Note: processor clears GD upon entering debug exception
// handler, to allow access to the debug registers // handler, to allow access to the debug registers
} }
if ( (((val_64>>16) & 3)==2) || if ((((val_64>>16) & 3)==2) ||
(((val_64>>20) & 3)==2) || (((val_64>>20) & 3)==2) ||
(((val_64>>24) & 3)==2) || (((val_64>>24) & 3)==2) ||
(((val_64>>28) & 3)==2)) (((val_64>>28) & 3)==2))
{ {
// IO breakpoints (10b) are not yet supported. // IO breakpoints (10b) are not yet supported.
BX_PANIC(("MOV_DqRq: write of %08x:%08x contains IO breakpoint", BX_PANIC(("MOV_DqRq: write of %08x:%08x contains IO breakpoint",
(Bit32u)(val_64 >> 32), (Bit32u)(val_64 & 0xFFFFFFFF))); (Bit32u)(val_64 >> 32), (Bit32u)(val_64 & 0xFFFFFFFF)));
} }
if ( (((val_64>>18) & 3)==2) || if ((((val_64>>18) & 3)==2) ||
(((val_64>>22) & 3)==2) || (((val_64>>22) & 3)==2) ||
(((val_64>>26) & 3)==2) || (((val_64>>26) & 3)==2) ||
(((val_64>>30) & 3)==2)) (((val_64>>30) & 3)==2))
{ {
// LEN0..3 contains undefined length specifier (10b) // LEN0..3 contains undefined length specifier (10b)
BX_PANIC(("MOV_DqRq: write of %08x:%08x contains undefined LENx", BX_PANIC(("MOV_DqRq: write of %08x:%08x contains undefined LENx",
(Bit32u)(val_64 >> 32), (Bit32u)(val_64 & 0xFFFFFFFF))); (Bit32u)(val_64 >> 32), (Bit32u)(val_64 & 0xFFFFFFFF)));
} }
if ( ((((val_64>>16) & 3)==0) && (((val_64>>18) & 3)!=0)) || if (((((val_64>>16) & 3)==0) && (((val_64>>18) & 3)!=0)) ||
((((val_64>>20) & 3)==0) && (((val_64>>22) & 3)!=0)) || ((((val_64>>20) & 3)==0) && (((val_64>>22) & 3)!=0)) ||
((((val_64>>24) & 3)==0) && (((val_64>>26) & 3)!=0)) || ((((val_64>>24) & 3)==0) && (((val_64>>26) & 3)!=0)) ||
((((val_64>>28) & 3)==0) && (((val_64>>30) & 3)!=0))) ((((val_64>>28) & 3)==0) && (((val_64>>30) & 3)!=0)))
{ {
// Instruction breakpoint with LENx not 00b (1-byte length) // Instruction breakpoint with LENx not 00b (1-byte length)
BX_PANIC(("MOV_DqRq: write of %08x:%08x , R/W=00b LEN!=00b", BX_PANIC(("MOV_DqRq: write of %08x:%08x , R/W=00b LEN!=00b",

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: segment_ctrl_pro.cc,v 1.81 2008-02-02 21:46:53 sshwarts Exp $ // $Id: segment_ctrl_pro.cc,v 1.82 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -114,11 +114,11 @@ BX_CPU_C::load_seg_reg(bx_segment_reg_t *seg, Bit16u new_value)
return; return;
} }
else if ( (seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS]) || else if ((seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS]) ||
(seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES]) (seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES])
#if BX_CPU_LEVEL >= 3 #if BX_CPU_LEVEL >= 3
|| (seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS]) || || (seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS]) ||
(seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS]) (seg==&BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS])
#endif #endif
) )
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: beos.cc,v 1.31 2008-02-05 22:57:41 sshwarts Exp $ // $Id: beos.cc,v 1.32 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -62,9 +62,7 @@ IMPLEMENT_GUI_PLUGIN_CODE(beos)
#define LOG_THIS theGui-> #define LOG_THIS theGui->
#define PAD_NEAREST(n, quantum) (( ((n) + ((quantum) - 1)) / (n) ) * (n)) #define PAD_NEAREST(n, quantum) ((((n) + ((quantum) - 1)) / (n)) * (n))
class BochsApplication : public BApplication { class BochsApplication : public BApplication {
public: public:
@ -213,7 +211,7 @@ bx_beos_gui_c::specific_init(int argc, char **argv,
put("BGUI"); put("BGUI");
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) { if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) {
BX_INFO(( "BeOS: private_colormap option not handled yet.")); BX_INFO(("BeOS: private_colormap option not handled yet."));
} }
x_tilesize = tilewidth; x_tilesize = tilewidth;
@ -241,8 +239,8 @@ BX_INFO(("font_height = %u", (unsigned) font_height));
// XSetBackground(bx_x_display, gc, col_vals[curr_background]); // XSetBackground(bx_x_display, gc, col_vals[curr_background]);
curr_foreground = 1; curr_foreground = 1;
// XSetForeground(bx_x_display, gc, col_vals[curr_foreground]); // XSetForeground(bx_x_display, gc, col_vals[curr_foreground]);
//XGrabPointer( bx_x_display, win, True, 0, GrabModeAsync, GrabModeAsync, //XGrabPointer(bx_x_display, win, True, 0, GrabModeAsync, GrabModeAsync,
// win, None, CurrentTime ); // win, None, CurrentTime);
//XFlush(bx_x_display); //XFlush(bx_x_display);
myApplication = new BochsApplication(); myApplication = new BochsApplication();
@ -277,7 +275,7 @@ void bx_beos_gui_c::handle_events(void)
{ {
Bit32u key; Bit32u key;
while ( head != tail ) { while (head != tail) {
key = deq_key_event(); key = deq_key_event();
DEV_kbd_gen_scancode(key); DEV_kbd_gen_scancode(key);
} }
@ -299,7 +297,7 @@ void bx_beos_gui_c::handle_events(void)
if (current != previous || mouse_button_state != newstate) { if (current != previous || mouse_button_state != newstate) {
int dx = (int)(current.x - previous.x) *2; int dx = (int)(current.x - previous.x) *2;
int dy = -(int)((current.y - previous.y) *2); int dy = -(int)((current.y - previous.y) *2);
DEV_mouse_motion( dx, dy, newstate); DEV_mouse_motion(dx, dy, newstate);
mouse_button_state = newstate; mouse_button_state = newstate;
previous = current; previous = current;
} }
@ -334,10 +332,10 @@ void bx_beos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
nchars = text_cols * text_rows; nchars = text_cols * text_rows;
// first draw over character at original block cursor location // first draw over character at original block cursor location
if ( (prev_block_cursor_y*text_cols + prev_block_cursor_x) < nchars ) { if ((prev_block_cursor_y*text_cols + prev_block_cursor_x) < nchars) {
achar = new_text[(prev_block_cursor_y*text_cols + prev_block_cursor_x)*2]; achar = new_text[(prev_block_cursor_y*text_cols + prev_block_cursor_x)*2];
point.Set(prev_block_cursor_x*8, prev_block_cursor_y*16 + bx_headerbar_y); point.Set(prev_block_cursor_x*8, prev_block_cursor_y*16 + bx_headerbar_y);
aView->DrawBitmap(vgafont[achar], point ); aView->DrawBitmap(vgafont[achar], point);
} }
for (i=0; i<nchars*2; i+=2) { for (i=0; i<nchars*2; i+=2) {
@ -350,7 +348,7 @@ void bx_beos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
y = (i/2) / text_cols; y = (i/2) / text_cols;
point.Set(x*8, y*16 + bx_headerbar_y); point.Set(x*8, y*16 + bx_headerbar_y);
aView->DrawBitmap(vgafont[achar], point ); aView->DrawBitmap(vgafont[achar], point);
} }
} }
@ -362,7 +360,7 @@ void bx_beos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
achar = new_text[(cursor_y*text_cols + cursor_x)*2]; achar = new_text[(cursor_y*text_cols + cursor_x)*2];
point.Set(cursor_x*8, cursor_y*16 + bx_headerbar_y); point.Set(cursor_x*8, cursor_y*16 + bx_headerbar_y);
aView->set_inv_text_colors(); aView->set_inv_text_colors();
aView->DrawBitmap(vgafont[achar], point ); aView->DrawBitmap(vgafont[achar], point);
aView->set_text_colors(); aView->set_text_colors();
} }
@ -841,7 +839,7 @@ void BochsView::KeyDown(const char *bytes, int32 numBytes)
#if 0 #if 0
case B_FUNCTION_KEY: break; case B_FUNCTION_KEY: break;
msg->FindInt32("key", &key); msg->FindInt32("key", &key);
switch ( key ) { switch (key) {
case B_F1_KEY: break; case B_F1_KEY: break;
case B_F2_KEY: break; case B_F2_KEY: break;
case B_F3_KEY: break; case B_F3_KEY: break;
@ -888,7 +886,7 @@ void BochsView::KeyDown(const char *bytes, int32 numBytes)
break; break;
default: default:
if ( (byte >= 0x01) && (byte <= 0x1a) ) { if ((byte >= 0x01) && (byte <= 0x1a)) {
// If the above keys dont catch this case, synthesize a // If the above keys dont catch this case, synthesize a
// Ctrl-A .. Ctrl-Z event // Ctrl-A .. Ctrl-Z event
byte -= 1; byte -= 1;
@ -1035,7 +1033,7 @@ unsigned bx_beos_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment,
{ {
unsigned hb_index; unsigned hb_index;
if ( (bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES ) if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES)
BX_PANIC(("beos: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES")); BX_PANIC(("beos: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES"));
bx_headerbar_entries++; bx_headerbar_entries++;
@ -1092,7 +1090,7 @@ void bx_beos_gui_c::show_headerbar(void)
else else
xorigin = dimension_x - bx_headerbar_entry[i].xorigin; xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
origin.Set(xorigin, 0); origin.Set(xorigin, 0);
aView->DrawBitmap( bx_headerbar_entry[i].bitmap, origin ); aView->DrawBitmap(bx_headerbar_entry[i].bitmap, origin);
} }
aView->set_text_colors(); aView->set_text_colors();
aWindow->Unlock(); aWindow->Unlock();
@ -1109,7 +1107,7 @@ void headerbar_click(int x, int y)
xorigin = bx_headerbar_entry[i].xorigin; xorigin = bx_headerbar_entry[i].xorigin;
else else
xorigin = dimension_x - bx_headerbar_entry[i].xorigin; xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
if ( (x>=xorigin) && (x<(xorigin+int(bx_headerbar_entry[i].xdim))) ) { if ((x>=xorigin) && (x<(xorigin+int(bx_headerbar_entry[i].xdim)))) {
bx_headerbar_entry[i].f(); bx_headerbar_entry[i].f();
return; return;
} }
@ -1123,7 +1121,7 @@ void create_vga_font(void)
unsigned char *data; unsigned char *data;
BRect brect(0,0, 7,15); BRect brect(0,0, 7,15);
BX_INFO(( "BeOS: creating VGA font from bitmaps" )); BX_INFO(("BeOS: creating VGA font from bitmaps"));
// VGA font is 8wide x 16high // VGA font is 8wide x 16high
for (unsigned c=0; c<256; c++) { for (unsigned c=0; c<256; c++) {

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// $Id: carbon.cc,v 1.37 2008-02-07 18:28:50 sshwarts Exp $ // $Id: carbon.cc,v 1.38 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,7 +23,8 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////
// carbon.cc -- bochs GUI file for MacOS X with Carbon API // carbon.cc -- bochs GUI file for MacOS X with Carbon API
// written by David Batterham <drbatter@progsoc.uts.edu.au> // written by David Batterham <drbatter@progsoc.uts.edu.au>
@ -458,7 +459,7 @@ pascal OSStatus CEvtHandleApplicationMenus (EventHandlerCallRef nextHandler,
aboutDialog, aboutDialog,
NULL, /* can be NULL */ NULL, /* can be NULL */
&index); &index);
CFRelease( cf_version ); CFRelease(cf_version);
} }
break; break;
@ -556,7 +557,7 @@ void InitToolbox(void)
1, &appleEvent, 0, NULL); 1, &appleEvent, 0, NULL);
#endif #endif
err = AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerUPP(QuitAppleEventHandler), 0, false); NewAEEventHandlerUPP(QuitAppleEventHandler), 0, false);
if (err != noErr) if (err != noErr)
ExitToShell(); ExitToShell();
@ -575,7 +576,7 @@ void CreateTile(void)
CGrafPtr savePort; CGrafPtr savePort;
OSErr err; OSErr err;
unsigned long p_f; unsigned long p_f;
long theRowBytes = ((((long) ( vga_bpp==24?32:(((vga_bpp+1)>>1)<<1) ) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2); long theRowBytes = ((((long) (vga_bpp==24?32:(((vga_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2);
// if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) // if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
// { // {
@ -707,7 +708,7 @@ void CreateWindows(void)
GetAvailableWindowPositioningBounds(GetMainDevice(), &positioningBounds); GetAvailableWindowPositioningBounds(GetMainDevice(), &positioningBounds);
SetRect(&winRect, 0, 0, screenBounds.right, screenBounds.bottom + GetMBarHeight()); SetRect(&winRect, 0, 0, screenBounds.right, screenBounds.bottom + GetMBarHeight());
CreateNewWindow(kPlainWindowClass, (kWindowStandardHandlerAttribute ), &winRect, &backdrop); CreateNewWindow(kPlainWindowClass, (kWindowStandardHandlerAttribute), &winRect, &backdrop);
if (backdrop == NULL) if (backdrop == NULL)
{BX_PANIC(("mac: can't create backdrop window"));} {BX_PANIC(("mac: can't create backdrop window"));}
InstallWindowEventHandler(backdrop, NewEventHandlerUPP(CEvtHandleWindowBackdropUpdate), 1, &eventUpdate, NULL, NULL); InstallWindowEventHandler(backdrop, NewEventHandlerUPP(CEvtHandleWindowBackdropUpdate), 1, &eventUpdate, NULL, NULL);
@ -782,7 +783,7 @@ void CreateWindows(void)
SetWindowGroup(fullwin, fullwinGroup); SetWindowGroup(fullwin, fullwinGroup);
SetWindowGroup(backdrop, fullwinGroup); SetWindowGroup(backdrop, fullwinGroup);
RepositionWindow( win, NULL, kWindowCenterOnMainScreen ); RepositionWindow(win, NULL, kWindowCenterOnMainScreen);
hidden = fullwin; hidden = fullwin;
@ -880,20 +881,20 @@ OSStatus HandleKey(EventRef theEvent, Bit32u keyState)
typeUInt32, NULL, typeUInt32, NULL,
sizeof(UInt32), NULL, sizeof(UInt32), NULL,
&modifiers); &modifiers);
if( status == noErr ) if(status == noErr)
{ {
status = GetEventParameter (theEvent, status = GetEventParameter (theEvent,
kEventParamKeyCode, kEventParamKeyCode,
typeUInt32, NULL, typeUInt32, NULL,
sizeof(UInt32), NULL, sizeof(UInt32), NULL,
&key); &key);
if( status == noErr ) if(status == noErr)
{ {
// key = event->message & charCodeMask; // key = event->message & charCodeMask;
// Let our menus process command keys // Let our menus process command keys
if( modifiers & cmdKey ) if(modifiers & cmdKey)
{ {
status = eventNotHandledErr; status = eventNotHandledErr;
} }
@ -1052,7 +1053,7 @@ void bx_carbon_gui_c::handle_events(void)
if(mouseMoved) if(mouseMoved)
{ {
CGMouseDelta CGdX, CGdY; CGMouseDelta CGdX, CGdY;
CGGetLastMouseDelta( &CGdX, &CGdY ); CGGetLastMouseDelta(&CGdX, &CGdY);
dx = CGdX; dx = CGdX;
dy = - CGdY; // Windows has an opposing grid dy = - CGdY; // Windows has an opposing grid
} }
@ -1279,17 +1280,17 @@ int bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
Size theScrapSize; Size theScrapSize;
OSStatus err; OSStatus err;
GetCurrentScrap( &theScrap ); GetCurrentScrap(&theScrap);
// Make sure there is text to paste // Make sure there is text to paste
err= GetScrapFlavorFlags( theScrap, kScrapFlavorTypeText, &theScrapFlags); err= GetScrapFlavorFlags(theScrap, kScrapFlavorTypeText, &theScrapFlags);
if(err == noErr) if(err == noErr)
{ {
GetScrapFlavorSize( theScrap, kScrapFlavorTypeText, &theScrapSize); GetScrapFlavorSize(theScrap, kScrapFlavorTypeText, &theScrapSize);
*nbytes = theScrapSize; *nbytes = theScrapSize;
*bytes = new Bit8u[1 + *nbytes]; *bytes = new Bit8u[1 + *nbytes];
BX_INFO (("found %d bytes on the clipboard", *nbytes)); BX_INFO (("found %d bytes on the clipboard", *nbytes));
err= GetScrapFlavorData( theScrap, kScrapFlavorTypeText, &theScrapSize, *bytes); err= GetScrapFlavorData(theScrap, kScrapFlavorTypeText, &theScrapSize, *bytes);
BX_INFO (("first byte is 0x%02x", *bytes[0])); BX_INFO (("first byte is 0x%02x", *bytes[0]));
} }
else else
@ -1304,14 +1305,14 @@ int bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
ScrapRef theScrap; ScrapRef theScrap;
// Clear out the existing clipboard // Clear out the existing clipboard
ClearCurrentScrap (); ClearCurrentScrap();
GetCurrentScrap(&theScrap);
PutScrapFlavor (theScrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len, text_snapshot);
GetCurrentScrap( &theScrap );
PutScrapFlavor ( theScrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len, text_snapshot);
return 1; return 1;
} }
// ::PALETTE_CHANGE() // ::PALETTE_CHANGE()
// //
// Allocate a color in the native GUI, for this color, and put // Allocate a color in the native GUI, for this color, and put
@ -1430,7 +1431,7 @@ void bx_carbon_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0
BX_ERROR(("mac: UnlockPortBits returned %hd", theError)); BX_ERROR(("mac: UnlockPortBits returned %hd", theError));
RGBForeColor(&black); RGBForeColor(&black);
RGBBackColor(&white); RGBBackColor(&white);
CopyBits( GetPortBitMapForCopyBits(gOffWorld), WINBITMAP(win), CopyBits(GetPortBitMapForCopyBits(gOffWorld), WINBITMAP(win),
&srcTileRect, &destRect, srcCopy, NULL); &srcTileRect, &destRect, srcCopy, NULL);
if ((theError = QDError()) != noErr) if ((theError = QDError()) != noErr)
BX_ERROR(("mac: CopyBits returned %hd", theError)); BX_ERROR(("mac: CopyBits returned %hd", theError));
@ -1472,7 +1473,7 @@ void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight,
if (fheight > 0) { if (fheight > 0) {
text_cols = x / fwidth; text_cols = x / fwidth;
text_rows = y / fheight; text_rows = y / fheight;
if( fwidth != font_width || fheight != font_height ) { if(fwidth != font_width || fheight != font_height) {
font_width = fwidth; font_width = fwidth;
font_height = fheight; font_height = fheight;
CreateVGAFont(vga_charmap); CreateVGAFont(vga_charmap);
@ -1590,12 +1591,11 @@ unsigned bx_carbon_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment,
info.contentType = kControlContentCIconHandle; info.contentType = kControlContentCIconHandle;
info.u.cIconHandle = bx_cicn[bmap_id]; info.u.cIconHandle = bx_cicn[bmap_id];
CreateIconControl( toolwin, &destRect, &info, false, &(bx_tool_pixmap[hb_index].control) ); CreateIconControl(toolwin, &destRect, &info, false, &(bx_tool_pixmap[hb_index].control));
SetControlCommandID(bx_tool_pixmap[hb_index].control, hb_index); SetControlCommandID(bx_tool_pixmap[hb_index].control, hb_index);
return(hb_index); return(hb_index);
} }
// ::SHOW_HEADERBAR() // ::SHOW_HEADERBAR()
// //
// Show (redraw) the current headerbar, which is composed of // Show (redraw) the current headerbar, which is composed of
@ -1712,11 +1712,11 @@ void UpdateTools()
ScrapRef theScrap; ScrapRef theScrap;
ScrapFlavorFlags theScrapFlags; ScrapFlavorFlags theScrapFlags;
GetCurrentScrap( &theScrap ); GetCurrentScrap(&theScrap);
// If keyboard mapping is on AND there is text on the clipboard enable pasting // If keyboard mapping is on AND there is text on the clipboard enable pasting
if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get() && if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get() &&
(GetScrapFlavorFlags( theScrap, kScrapFlavorTypeText, &theScrapFlags) == noErr)) (GetScrapFlavorFlags(theScrap, kScrapFlavorTypeText, &theScrapFlags) == noErr))
{ {
EnableMenuItem(GetMenuRef(mEdit), iPaste); EnableMenuItem(GetMenuRef(mEdit), iPaste);
EnableControl(bx_tool_pixmap[PASTE_TOOL_BUTTON].control); EnableControl(bx_tool_pixmap[PASTE_TOOL_BUTTON].control);
@ -2047,7 +2047,7 @@ BitMap *CreateBitMap(unsigned width, unsigned height)
BitMap *bm; BitMap *bm;
long row_bytes; long row_bytes;
row_bytes = (( width + 31) >> 5) << 2; row_bytes = ((width + 31) >> 5) << 2;
bm = (BitMap *)calloc(1, sizeof(BitMap)); bm = (BitMap *)calloc(1, sizeof(BitMap));
if (bm == NULL) if (bm == NULL)
BX_PANIC(("mac: can't allocate memory for pixmap")); BX_PANIC(("mac: can't allocate memory for pixmap"));
@ -2108,12 +2108,12 @@ void bx_carbon_gui_c::mouse_enabled_changed_specific (bx_bool val)
void bx_carbon_gui_c::beep_on(float frequency) void bx_carbon_gui_c::beep_on(float frequency)
{ {
AlertSoundPlay(); AlertSoundPlay();
BX_INFO(( "Carbon Beep ON (frequency=%.2f)",frequency)); BX_INFO(("Carbon Beep ON (frequency=%.2f)",frequency));
} }
void bx_carbon_gui_c::beep_off() void bx_carbon_gui_c::beep_off()
{ {
BX_INFO(( "Carbon Beep OFF")); BX_INFO(("Carbon Beep OFF"));
} }
// we need to handle "ask" events so that PANICs are properly reported // we need to handle "ask" events so that PANICs are properly reported
@ -2129,7 +2129,7 @@ static BxEvent * CarbonSiminterfaceCallback (void *theClass, BxEvent *event)
DialogItemIndex index; DialogItemIndex index;
AlertStdCFStringAlertParamRec alertParam = {0}; AlertStdCFStringAlertParamRec alertParam = {0};
if( event->u.logmsg.prefix != NULL ) if(event->u.logmsg.prefix != NULL)
{ {
title = CFStringCreateWithCString(NULL, event->u.logmsg.prefix, kCFStringEncodingASCII); title = CFStringCreateWithCString(NULL, event->u.logmsg.prefix, kCFStringEncodingASCII);
exposition = CFStringCreateWithCString(NULL, event->u.logmsg.msg, kCFStringEncodingASCII); exposition = CFStringCreateWithCString(NULL, event->u.logmsg.msg, kCFStringEncodingASCII);
@ -2159,25 +2159,25 @@ static BxEvent * CarbonSiminterfaceCallback (void *theClass, BxEvent *event)
NULL, /* can be NULL */ NULL, /* can be NULL */
&index); &index);
CFRelease( title ); CFRelease(title);
if( exposition != NULL ) if(exposition != NULL)
{ {
CFRelease( exposition ); CFRelease(exposition);
} }
// continue // continue
if( index == kAlertStdAlertOKButton ) if(index == kAlertStdAlertOKButton)
{ {
event->retcode = 0; event->retcode = 0;
} }
// quit // quit
else if( index == kAlertStdAlertCancelButton ) else if(index == kAlertStdAlertCancelButton)
{ {
event->retcode = 2; event->retcode = 2;
} }
#if 0 #if 0
if( event->u.logmsg.prefix != NULL ) if(event->u.logmsg.prefix != NULL)
{ {
BX_INFO(("Callback log: Prefix: %s", event->u.logmsg.prefix)); BX_INFO(("Callback log: Prefix: %s", event->u.logmsg.prefix));
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.103 2008-02-05 22:57:41 sshwarts Exp $ // $Id: gui.cc,v 1.104 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -395,7 +395,7 @@ void bx_gui_c::copy_handler(void)
Bit32u len; Bit32u len;
char *text_snapshot; char *text_snapshot;
if (make_text_snapshot (&text_snapshot, &len) < 0) { if (make_text_snapshot (&text_snapshot, &len) < 0) {
BX_INFO(( "copy button failed, mode not implemented")); BX_INFO(("copy button failed, mode not implemented"));
return; return;
} }
if (!BX_GUI_THIS set_clipboard_text(text_snapshot, len)) { if (!BX_GUI_THIS set_clipboard_text(text_snapshot, len)) {
@ -460,7 +460,7 @@ void bx_gui_c::snapshot_handler(void)
char *text_snapshot; char *text_snapshot;
Bit32u len; Bit32u len;
if (make_text_snapshot (&text_snapshot, &len) < 0) { if (make_text_snapshot (&text_snapshot, &len) < 0) {
BX_ERROR(( "snapshot button failed, mode not implemented")); BX_ERROR(("snapshot button failed, mode not implemented"));
return; return;
} }
//FIXME //FIXME

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: keymap.cc,v 1.22 2008-02-05 22:57:41 sshwarts Exp $ // $Id: keymap.cc,v 1.23 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -121,7 +121,7 @@ static void init_parse_line(char *line_to_parse)
// chop off newline // chop off newline
lineptr = (unsigned char *)line_to_parse; lineptr = (unsigned char *)line_to_parse;
char *nl; char *nl;
if( (nl = strchr(line_to_parse,'\n')) != NULL) { if ((nl = strchr(line_to_parse,'\n')) != NULL) {
*nl = 0; *nl = 0;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: rfb.cc,v 1.55 2008-02-05 22:57:41 sshwarts Exp $ // $Id: rfb.cc,v 1.56 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2000 Psyon.Org! // Copyright (C) 2000 Psyon.Org!
@ -360,18 +360,18 @@ void ServerThreadInit(void *indata)
#ifdef WIN32 #ifdef WIN32
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
if(!InitWinsock()) { if(!InitWinsock()) {
BX_PANIC(( "could not initialize winsock.")); BX_PANIC(("could not initialize winsock."));
goto end_of_thread; goto end_of_thread;
} }
#endif #endif
sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sServer == -1) { if(sServer == -1) {
BX_PANIC(( "could not create socket." )); BX_PANIC(("could not create socket."));
goto end_of_thread; goto end_of_thread;
} }
if (setsockopt(sServer, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(int)) == -1) { if (setsockopt(sServer, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(int)) == -1) {
BX_PANIC(( "could not set socket option." )); BX_PANIC(("could not set socket option."));
goto end_of_thread; goto end_of_thread;
} }
@ -381,11 +381,11 @@ void ServerThreadInit(void *indata)
sai.sin_port = htons(rfbPort); sai.sin_port = htons(rfbPort);
BX_INFO (("Trying port %d", rfbPort)); BX_INFO (("Trying port %d", rfbPort));
if(bind(sServer, (struct sockaddr *)&sai, sizeof(sai)) == -1) { if(bind(sServer, (struct sockaddr *)&sai, sizeof(sai)) == -1) {
BX_INFO(( "Could not bind socket.")); BX_INFO(("Could not bind socket."));
continue; continue;
} }
if(listen(sServer, SOMAXCONN) == -1) { if(listen(sServer, SOMAXCONN) == -1) {
BX_INFO(( "Could not listen on socket.")); BX_INFO(("Could not listen on socket."));
continue; continue;
} }
// success // success
@ -722,7 +722,7 @@ void bx_rfb_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, unsigned long c
} }
// first invalidate character at previous and new cursor location // first invalidate character at previous and new cursor location
if ( (rfbCursorY < text_rows) && (rfbCursorX < text_cols) ) { if ((rfbCursorY < text_rows) && (rfbCursorX < text_cols)) {
curs = rfbCursorY * tm_info.line_offset + rfbCursorX * 2; curs = rfbCursorY * tm_info.line_offset + rfbCursorX * 2;
old_text[curs] = ~new_text[curs]; old_text[curs] = ~new_text[curs];
} }
@ -1730,7 +1730,7 @@ void rfbMouseMove(int x, int y, int bmask)
xorigin = rfbHeaderbarBitmaps[i].xorigin; xorigin = rfbHeaderbarBitmaps[i].xorigin;
else else
xorigin = rfbWindowX - rfbHeaderbarBitmaps[i].xorigin; xorigin = rfbWindowX - rfbHeaderbarBitmaps[i].xorigin;
if ( (x>=xorigin) && (x<(xorigin+int(rfbBitmaps[rfbHeaderbarBitmaps[i].index].xdim))) ) { if ((x>=xorigin) && (x<(xorigin+int(rfbBitmaps[rfbHeaderbarBitmaps[i].index].xdim)))) {
rfbHeaderbarBitmaps[i].f(); rfbHeaderbarBitmaps[i].f();
return; return;
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: sdl.cc,v 1.72 2008-02-05 22:57:41 sshwarts Exp $ // $Id: sdl.cc,v 1.73 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,6 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
#define _MULTI_THREAD #define _MULTI_THREAD
@ -214,6 +215,7 @@ void switch_to_fullscreen(void)
0xff000000 0xff000000
#endif #endif
); );
SDL_BlitSurface(sdl_screen,&src,tmp,&dst); SDL_BlitSurface(sdl_screen,&src,tmp,&dst);
SDL_UpdateRect(tmp,0,0,res_x,res_y); SDL_UpdateRect(tmp,0,0,res_x,res_y);
SDL_FreeSurface(sdl_screen); SDL_FreeSurface(sdl_screen);
@ -314,8 +316,7 @@ void bx_sdl_gui_c::specific_init(
dimension_update(640,480); dimension_update(640,480);
SDL_EnableKeyRepeat(250,50); SDL_EnableKeyRepeat(250,50);
SDL_WM_SetCaption(BOCHS_WINDOW_NAME, SDL_WM_SetCaption(BOCHS_WINDOW_NAME, "Bochs");
"Bochs" );
SDL_WarpMouse(half_res_x, half_res_y); SDL_WarpMouse(half_res_x, half_res_y);
// load keymap for sdl // load keymap for sdl
@ -352,7 +353,7 @@ void sdl_set_status_text(int element, const char *text, bx_bool active)
int x, xleft, xsize; int x, xleft, xsize;
statusitem_active[element] = active; statusitem_active[element] = active;
if( !sdl_screen ) return; if(!sdl_screen) return;
disp = sdl_screen->pitch/4; disp = sdl_screen->pitch/4;
xleft = statusitem_pos[element] + 2; xleft = statusitem_pos[element] + 2;
xsize = statusitem_pos[element+1] - xleft - 1; xsize = statusitem_pos[element+1] - xleft - 1;
@ -370,9 +371,9 @@ void sdl_set_status_text(int element, const char *text, bx_bool active)
do do
{ {
*buf++ = bgcolor; *buf++ = bgcolor;
} while( --colsleft ); } while(--colsleft);
buf = buf_row + disp; buf = buf_row + disp;
} while( --rowsleft ); } while(--rowsleft);
if ((element > 0) && (strlen(text) > 4)) { if ((element > 0) && (strlen(text) > 4)) {
textlen = 4; textlen = 4;
} else { } else {
@ -391,14 +392,14 @@ void sdl_set_status_text(int element, const char *text, bx_bool active)
colsleft = 8; colsleft = 8;
do do
{ {
if( (font_row & 0x80) != 0x00 ) if((font_row & 0x80) != 0x00)
*buf++ = fgcolor; *buf++ = fgcolor;
else else
buf++; buf++;
font_row <<= 1; font_row <<= 1;
} while( --colsleft ); } while(--colsleft);
buf += (disp - 8); buf += (disp - 8);
} while( --rowsleft ); } while(--rowsleft);
buf = buf_row + 8; buf = buf_row + 8;
x++; x++;
} while (--textlen); } while (--textlen);
@ -468,7 +469,7 @@ void bx_sdl_gui_c::text_update(
buf_row = (Uint32 *)sdl_fullscreen->pixels; buf_row = (Uint32 *)sdl_fullscreen->pixels;
} }
// first invalidate character at previous and new cursor location // first invalidate character at previous and new cursor location
if ( (prev_cursor_y < text_rows) && (prev_cursor_x < text_cols) ) { if ((prev_cursor_y < text_rows) && (prev_cursor_x < text_cols)) {
curs = prev_cursor_y * tm_info.line_offset + prev_cursor_x * 2; curs = prev_cursor_y * tm_info.line_offset + prev_cursor_x * 2;
old_text[curs] = ~new_text[curs]; old_text[curs] = ~new_text[curs];
} }
@ -543,7 +544,7 @@ void bx_sdl_gui_c::text_update(
} }
// check if char needs to be updated // check if char needs to be updated
if(forceUpdate || (old_text[0] != new_text[0]) if(forceUpdate || (old_text[0] != new_text[0])
|| (old_text[1] != new_text[1]) ) || (old_text[1] != new_text[1]))
{ {
// Get Foreground/Background pixel colors // Get Foreground/Background pixel colors
@ -586,23 +587,23 @@ void bx_sdl_gui_c::text_update(
font_row <<= h_panning; font_row <<= h_panning;
} }
fontpixels = cfwidth; fontpixels = cfwidth;
if( (invert) && (fontline >= tm_info.cs_start) && (fontline <= tm_info.cs_end) ) if ((invert) && (fontline >= tm_info.cs_start) && (fontline <= tm_info.cs_end))
mask = 0x100; mask = 0x100;
else else
mask = 0x00; mask = 0x00;
do do
{ {
if( (font_row & 0x100) == mask ) if ((font_row & 0x100) == mask)
*buf = bgcolor; *buf = bgcolor;
else else
*buf = fgcolor; *buf = fgcolor;
buf++; buf++;
font_row <<= 1; font_row <<= 1;
} while( --fontpixels ); } while(--fontpixels);
buf -= cfwidth; buf -= cfwidth;
buf += disp; buf += disp;
fontline++; fontline++;
} while( --fontrows ); } while(--fontrows);
// restore output buffer ptr to start of this char // restore output buffer ptr to start of this char
buf = buf_char; buf = buf_char;
@ -617,7 +618,7 @@ void bx_sdl_gui_c::text_update(
x++; x++;
// process one entire horizontal row // process one entire horizontal row
} while( --hchars ); } while(--hchars);
// go to next character row location // go to next character row location
buf_row += disp * cfheight; buf_row += disp * cfheight;
@ -637,35 +638,30 @@ void bx_sdl_gui_c::text_update(
cs_y++; cs_y++;
y++; y++;
} }
} while( --rows ); } while(--rows);
h_panning = tm_info.h_panning; h_panning = tm_info.h_panning;
prev_cursor_x = cursor_x; prev_cursor_x = cursor_x;
prev_cursor_y = cursor_y; prev_cursor_y = cursor_y;
} }
int int bx_sdl_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
bx_sdl_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
{ {
return 0; return 0;
} }
int int bx_sdl_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
bx_sdl_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
{ {
return 0; return 0;
} }
void bx_sdl_gui_c::graphics_tile_update(Bit8u *snapshot,
void bx_sdl_gui_c::graphics_tile_update( unsigned x, unsigned y)
Bit8u *snapshot,
unsigned x,
unsigned y)
{ {
Uint32 *buf, disp; Uint32 *buf, disp;
Uint32 *buf_row; Uint32 *buf_row;
int i,j; int i,j;
if( sdl_screen ) if(sdl_screen)
{ {
disp = sdl_screen->pitch/4; disp = sdl_screen->pitch/4;
buf = (Uint32 *)sdl_screen->pixels + (headerbar_height+y)*disp + x; buf = (Uint32 *)sdl_screen->pixels + (headerbar_height+y)*disp + x;
@ -677,10 +673,10 @@ void bx_sdl_gui_c::graphics_tile_update(
} }
i = tileheight; i = tileheight;
if( i + y > res_y ) i = res_y - y; if(i + y > res_y) i = res_y - y;
// FIXME // FIXME
if( i<=0 ) return; if(i<=0) return;
switch (vga_bpp) switch (vga_bpp)
{ {
@ -692,9 +688,9 @@ void bx_sdl_gui_c::graphics_tile_update(
do do
{ {
*buf++ = palette[*snapshot++]; *buf++ = palette[*snapshot++];
} while( --j ); } while(--j);
buf = buf_row + disp; buf = buf_row + disp;
} while( --i); } while(--i);
break; break;
default: default:
BX_PANIC(("%u bpp modes handled by new graphics API", vga_bpp)); BX_PANIC(("%u bpp modes handled by new graphics API", vga_bpp));
@ -943,23 +939,22 @@ static Bit32u sdl_sym_to_bx_key (SDLKey sym)
} }
} }
void bx_sdl_gui_c::handle_events(void) void bx_sdl_gui_c::handle_events(void)
{ {
Bit32u key_event; Bit32u key_event;
Bit8u mouse_state; Bit8u mouse_state;
int wheel_status; int wheel_status;
while( SDL_PollEvent(&sdl_event) ) while(SDL_PollEvent(&sdl_event))
{ {
wheel_status = 0; wheel_status = 0;
switch( sdl_event.type ) switch(sdl_event.type)
{ {
case SDL_VIDEOEXPOSE: case SDL_VIDEOEXPOSE:
if( sdl_fullscreen_toggle == 0 ) if(sdl_fullscreen_toggle == 0)
SDL_UpdateRect( sdl_screen, 0,0, res_x, res_y+headerbar_height+statusbar_height ); SDL_UpdateRect(sdl_screen, 0,0, res_x, res_y+headerbar_height+statusbar_height);
else else
SDL_UpdateRect( sdl_screen, 0,headerbar_height, res_x, res_y ); SDL_UpdateRect(sdl_screen, 0,headerbar_height, res_x, res_y);
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
@ -994,11 +989,11 @@ void bx_sdl_gui_c::handle_events(void)
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if( (sdl_event.button.button == SDL_BUTTON_MIDDLE) if((sdl_event.button.button == SDL_BUTTON_MIDDLE)
&& ((SDL_GetModState() & KMOD_CTRL) > 0) && ((SDL_GetModState() & KMOD_CTRL) > 0)
&& (sdl_fullscreen_toggle == 0) ) && (sdl_fullscreen_toggle == 0))
{ {
if( sdl_grab == 0 ) if(sdl_grab == 0)
{ {
SDL_ShowCursor(0); SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON); SDL_WM_GrabInput(SDL_GRAB_ON);
@ -1035,7 +1030,7 @@ void bx_sdl_gui_c::handle_events(void)
((mouse_state>>1)&0x02) | ((mouse_state>>1)&0x02) |
((mouse_state<<1)&0x04) ; ((mouse_state<<1)&0x04) ;
// filter out middle button if not fullscreen // filter out middle button if not fullscreen
if( sdl_fullscreen_toggle == 0 ) if(sdl_fullscreen_toggle == 0)
new_mousebuttons &= 0x07; new_mousebuttons &= 0x07;
// send motion information // send motion information
DEV_mouse_motion_ext( DEV_mouse_motion_ext(
@ -1052,11 +1047,11 @@ void bx_sdl_gui_c::handle_events(void)
case SDL_KEYDOWN: case SDL_KEYDOWN:
// Windows/Fullscreen toggle-check // Windows/Fullscreen toggle-check
if( sdl_event.key.keysym.sym == SDLK_SCROLLOCK ) if(sdl_event.key.keysym.sym == SDLK_SCROLLOCK)
{ {
// SDL_WM_ToggleFullScreen( sdl_screen ); // SDL_WM_ToggleFullScreen(sdl_screen);
sdl_fullscreen_toggle = ~sdl_fullscreen_toggle; sdl_fullscreen_toggle = ~sdl_fullscreen_toggle;
if( sdl_fullscreen_toggle == 0 ) if(sdl_fullscreen_toggle == 0)
switch_to_windowed(); switch_to_windowed();
else else
switch_to_fullscreen(); switch_to_fullscreen();
@ -1066,7 +1061,7 @@ void bx_sdl_gui_c::handle_events(void)
} }
// convert sym->bochs code // convert sym->bochs code
if( sdl_event.key.keysym.sym > SDLK_LAST ) break; if (sdl_event.key.keysym.sym > SDLK_LAST) break;
if (!SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) { if (!SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) {
key_event = sdl_sym_to_bx_key (sdl_event.key.keysym.sym); key_event = sdl_sym_to_bx_key (sdl_event.key.keysym.sym);
BX_DEBUG (("keypress scancode=%d, sym=%d, bx_key = %d", sdl_event.key.keysym.scancode, sdl_event.key.keysym.sym, key_event)); BX_DEBUG (("keypress scancode=%d, sym=%d, bx_key = %d", sdl_event.key.keysym.scancode, sdl_event.key.keysym.sym, key_event));
@ -1081,18 +1076,18 @@ void bx_sdl_gui_c::handle_events(void)
} }
key_event = entry->baseKey; key_event = entry->baseKey;
} }
if( key_event == BX_KEY_UNHANDLED ) break; if (key_event == BX_KEY_UNHANDLED) break;
DEV_kbd_gen_scancode( key_event ); DEV_kbd_gen_scancode( key_event);
if ((key_event == BX_KEY_NUM_LOCK) || (key_event == BX_KEY_CAPS_LOCK)) { if ((key_event == BX_KEY_NUM_LOCK) || (key_event == BX_KEY_CAPS_LOCK)) {
DEV_kbd_gen_scancode( key_event | BX_KEY_RELEASED ); DEV_kbd_gen_scancode(key_event | BX_KEY_RELEASED);
} }
break; break;
case SDL_KEYUP: case SDL_KEYUP:
// filter out release of Windows/Fullscreen toggle and unsupported keys // filter out release of Windows/Fullscreen toggle and unsupported keys
if( (sdl_event.key.keysym.sym != SDLK_SCROLLOCK) if ((sdl_event.key.keysym.sym != SDLK_SCROLLOCK)
&& (sdl_event.key.keysym.sym < SDLK_LAST )) && (sdl_event.key.keysym.sym < SDLK_LAST))
{ {
// convert sym->bochs code // convert sym->bochs code
if (!SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) { if (!SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) {
@ -1108,11 +1103,11 @@ void bx_sdl_gui_c::handle_events(void)
} }
key_event = entry->baseKey; key_event = entry->baseKey;
} }
if( key_event == BX_KEY_UNHANDLED ) break; if (key_event == BX_KEY_UNHANDLED) break;
if ((key_event == BX_KEY_NUM_LOCK) || (key_event == BX_KEY_CAPS_LOCK)) { if ((key_event == BX_KEY_NUM_LOCK) || (key_event == BX_KEY_CAPS_LOCK)) {
DEV_kbd_gen_scancode( key_event ); DEV_kbd_gen_scancode(key_event);
} }
DEV_kbd_gen_scancode( key_event | BX_KEY_RELEASED ); DEV_kbd_gen_scancode(key_event | BX_KEY_RELEASED);
} }
break; break;
@ -1129,17 +1124,14 @@ void bx_sdl_gui_c::handle_events(void)
#endif #endif
} }
void bx_sdl_gui_c::flush(void) void bx_sdl_gui_c::flush(void)
{ {
if( sdl_screen ) if(sdl_screen)
SDL_UpdateRect( sdl_screen,0,0,res_x,res_y+headerbar_height ); SDL_UpdateRect(sdl_screen,0,0,res_x,res_y+headerbar_height);
else else
SDL_UpdateRect( sdl_fullscreen,0,0,res_x,res_y); SDL_UpdateRect(sdl_fullscreen,0,0,res_x,res_y);
} }
void bx_sdl_gui_c::clear_screen(void) void bx_sdl_gui_c::clear_screen(void)
{ {
int i = res_y, j; int i = res_y, j;
@ -1147,15 +1139,15 @@ void bx_sdl_gui_c::clear_screen(void)
Uint32 *buf, *buf_row; Uint32 *buf, *buf_row;
Uint32 disp; Uint32 disp;
if( sdl_screen ) if(sdl_screen)
{ {
color = SDL_MapRGB( sdl_screen->format, 0,0,0 ); color = SDL_MapRGB(sdl_screen->format, 0,0,0);
disp = sdl_screen->pitch/4; disp = sdl_screen->pitch/4;
buf = (Uint32 *)sdl_screen->pixels + headerbar_height*disp; buf = (Uint32 *)sdl_screen->pixels + headerbar_height*disp;
} }
else if( sdl_fullscreen ) else if(sdl_fullscreen)
{ {
color = SDL_MapRGB( sdl_fullscreen->format, 0,0,0 ); color = SDL_MapRGB(sdl_fullscreen->format, 0,0, 0);
disp = sdl_fullscreen->pitch/4; disp = sdl_fullscreen->pitch/4;
buf = (Uint32 *)sdl_fullscreen->pixels; buf = (Uint32 *)sdl_fullscreen->pixels;
} }
@ -1165,18 +1157,16 @@ void bx_sdl_gui_c::clear_screen(void)
{ {
buf_row = buf; buf_row = buf;
j = res_x; j = res_x;
while( j-- ) *buf++ = color; while(j--) *buf++ = color;
buf = buf_row + disp; buf = buf_row + disp;
} while( --i ); } while(--i);
if( sdl_screen ) if(sdl_screen)
SDL_UpdateRect(sdl_screen,0,0,res_x,res_y+headerbar_height); SDL_UpdateRect(sdl_screen,0,0,res_x,res_y+headerbar_height);
else else
SDL_UpdateRect(sdl_fullscreen,0,0,res_x,res_y); SDL_UpdateRect(sdl_fullscreen,0,0,res_x,res_y);
} }
bx_bool bx_sdl_gui_c::palette_change( bx_bool bx_sdl_gui_c::palette_change(
unsigned index, unsigned index,
unsigned red, unsigned red,
@ -1187,17 +1177,16 @@ bx_bool bx_sdl_gui_c::palette_change(
unsigned char palgreen = green & 0xFF; unsigned char palgreen = green & 0xFF;
unsigned char palblue = blue & 0xFF; unsigned char palblue = blue & 0xFF;
if( index > 255 ) return 0; if(index > 255) return 0;
if( sdl_screen ) if(sdl_screen)
palette[index] = SDL_MapRGB( sdl_screen->format, palred, palgreen, palblue ); palette[index] = SDL_MapRGB(sdl_screen->format, palred, palgreen, palblue);
else if( sdl_fullscreen ) else if(sdl_fullscreen)
palette[index] = SDL_MapRGB( sdl_fullscreen->format, palred, palgreen, palblue ); palette[index] = SDL_MapRGB(sdl_fullscreen->format, palred, palgreen, palblue);
return 1; return 1;
} }
void bx_sdl_gui_c::dimension_update( void bx_sdl_gui_c::dimension_update(
unsigned x, unsigned x,
unsigned y, unsigned y,
@ -1212,7 +1201,7 @@ void bx_sdl_gui_c::dimension_update(
{ {
BX_PANIC(("%d bpp graphics mode not supported", bpp)); BX_PANIC(("%d bpp graphics mode not supported", bpp));
} }
if( fheight > 0 ) if(fheight > 0)
{ {
fontheight = fheight; fontheight = fheight;
fontwidth = fwidth; fontwidth = fwidth;
@ -1220,23 +1209,23 @@ void bx_sdl_gui_c::dimension_update(
text_rows = y / fontheight; text_rows = y / fontheight;
} }
if( (x == res_x) && (y == res_y )) return; if((x == res_x) && (y == res_y)) return;
if( sdl_screen ) if(sdl_screen)
{ {
SDL_FreeSurface( sdl_screen ); SDL_FreeSurface(sdl_screen);
sdl_screen = NULL; sdl_screen = NULL;
} }
if( sdl_fullscreen ) if(sdl_fullscreen)
{ {
SDL_FreeSurface( sdl_fullscreen ); SDL_FreeSurface(sdl_fullscreen);
sdl_fullscreen = NULL; sdl_fullscreen = NULL;
} }
if( sdl_fullscreen_toggle == 0 ) if(sdl_fullscreen_toggle == 0)
{ {
sdl_screen = SDL_SetVideoMode( x, y+headerbar_height+statusbar_height, 32, SDL_SWSURFACE ); sdl_screen = SDL_SetVideoMode(x, y+headerbar_height+statusbar_height, 32, SDL_SWSURFACE);
if( !sdl_screen ) if(!sdl_screen)
{ {
LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL);
BX_PANIC (("Unable to set requested videomode: %ix%i: %s",x,y,SDL_GetError())); BX_PANIC (("Unable to set requested videomode: %ix%i: %s",x,y,SDL_GetError()));
@ -1245,17 +1234,17 @@ void bx_sdl_gui_c::dimension_update(
sdl_screen->format, sdl_screen->format,
BX_HEADERBAR_FG_RED, BX_HEADERBAR_FG_RED,
BX_HEADERBAR_FG_GREEN, BX_HEADERBAR_FG_GREEN,
BX_HEADERBAR_FG_BLUE ); BX_HEADERBAR_FG_BLUE);
headerbar_bg = SDL_MapRGB( headerbar_bg = SDL_MapRGB(
sdl_screen->format, sdl_screen->format,
BX_HEADERBAR_BG_RED, BX_HEADERBAR_BG_RED,
BX_HEADERBAR_BG_GREEN, BX_HEADERBAR_BG_GREEN,
BX_HEADERBAR_BG_BLUE ); BX_HEADERBAR_BG_BLUE);
} }
else else
{ {
sdl_fullscreen = SDL_SetVideoMode( x, y, 32, SDL_HWSURFACE|SDL_FULLSCREEN ); sdl_fullscreen = SDL_SetVideoMode(x, y, 32, SDL_HWSURFACE|SDL_FULLSCREEN);
if( !sdl_fullscreen ) if(!sdl_fullscreen)
{ {
LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL);
BX_PANIC (("Unable to set requested videomode: %ix%i: %s",x,y,SDL_GetError())); BX_PANIC (("Unable to set requested videomode: %ix%i: %s",x,y,SDL_GetError()));
@ -1268,11 +1257,8 @@ void bx_sdl_gui_c::dimension_update(
bx_gui->show_headerbar(); bx_gui->show_headerbar();
} }
unsigned bx_sdl_gui_c::create_bitmap(const unsigned char *bmap,
unsigned bx_sdl_gui_c::create_bitmap( unsigned xdim, unsigned ydim)
const unsigned char *bmap,
unsigned xdim,
unsigned ydim)
{ {
bitmaps *tmp = new bitmaps; bitmaps *tmp = new bitmaps;
Uint32 *buf, *buf_row; Uint32 *buf, *buf_row;
@ -1301,7 +1287,7 @@ unsigned bx_sdl_gui_c::create_bitmap(
0x00000000 0x00000000
#endif #endif
); );
if( !tmp->surface ) if(!tmp->surface)
{ {
delete tmp; delete tmp;
bx_gui->exit(); bx_gui->exit();
@ -1328,25 +1314,24 @@ unsigned bx_sdl_gui_c::create_bitmap(
pixels = *bmap++; pixels = *bmap++;
for(unsigned i=0;i<8;i++) for(unsigned i=0;i<8;i++)
{ {
if( (pixels & 0x01) == 0 ) if((pixels & 0x01) == 0)
*buf++ = headerbar_bg; *buf++ = headerbar_bg;
else else
*buf++ = headerbar_fg; *buf++ = headerbar_fg;
pixels = pixels >> 1; pixels = pixels >> 1;
} }
} while( --xdim ); } while(--xdim);
buf = buf_row + disp; buf = buf_row + disp;
} while( --ydim ); } while(--ydim);
SDL_UpdateRect( SDL_UpdateRect(
tmp->surface, tmp->surface,
0, 0, 0, 0,
tmp->src.w, tmp->src.w,
tmp->src.h ); tmp->src.h);
sdl_bitmaps[n_sdl_bitmaps] = tmp; sdl_bitmaps[n_sdl_bitmaps] = tmp;
return n_sdl_bitmaps++; return n_sdl_bitmaps++;
} }
unsigned bx_sdl_gui_c::headerbar_bitmap( unsigned bx_sdl_gui_c::headerbar_bitmap(
unsigned bmap_id, unsigned bmap_id,
unsigned alignment, unsigned alignment,
@ -1354,9 +1339,9 @@ unsigned bx_sdl_gui_c::headerbar_bitmap(
{ {
unsigned hb_index; unsigned hb_index;
if( bmap_id >= (unsigned)n_sdl_bitmaps ) return 0; if(bmap_id >= (unsigned)n_sdl_bitmaps) return 0;
if ( (bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES ) if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES)
BX_PANIC(("too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES")); BX_PANIC(("too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES"));
bx_headerbar_entries++; bx_headerbar_entries++;
@ -1388,7 +1373,7 @@ void bx_sdl_gui_c::replace_bitmap(
sdl_bitmaps[old_id]->dst.x = -1; sdl_bitmaps[old_id]->dst.x = -1;
hb_entry[hbar_id].bmp_id = bmap_id; hb_entry[hbar_id].bmp_id = bmap_id;
sdl_bitmaps[bmap_id]->dst.x = hb_dst.x; sdl_bitmaps[bmap_id]->dst.x = hb_dst.x;
if( sdl_bitmaps[bmap_id]->dst.x != -1 ) if(sdl_bitmaps[bmap_id]->dst.x != -1)
{ {
if (hb_entry[hbar_id].alignment == BX_GRAVITY_RIGHT) { if (hb_entry[hbar_id].alignment == BX_GRAVITY_RIGHT) {
hb_dst.x = res_x - hb_dst.x; hb_dst.x = res_x - hb_dst.x;
@ -1403,11 +1388,10 @@ void bx_sdl_gui_c::replace_bitmap(
hb_dst.x, hb_dst.x,
sdl_bitmaps[bmap_id]->dst.y, sdl_bitmaps[bmap_id]->dst.y,
sdl_bitmaps[bmap_id]->src.w, sdl_bitmaps[bmap_id]->src.w,
sdl_bitmaps[bmap_id]->src.h ); sdl_bitmaps[bmap_id]->src.h);
} }
} }
void bx_sdl_gui_c::show_headerbar(void) void bx_sdl_gui_c::show_headerbar(void)
{ {
Uint32 *buf; Uint32 *buf;
@ -1419,7 +1403,7 @@ void bx_sdl_gui_c::show_headerbar(void)
unsigned current_bmp, pos_x; unsigned current_bmp, pos_x;
SDL_Rect hb_dst; SDL_Rect hb_dst;
if( !sdl_screen ) return; if(!sdl_screen) return;
disp = sdl_screen->pitch/4; disp = sdl_screen->pitch/4;
buf = (Uint32 *)sdl_screen->pixels; buf = (Uint32 *)sdl_screen->pixels;
@ -1431,16 +1415,16 @@ void bx_sdl_gui_c::show_headerbar(void)
do do
{ {
*buf++ = headerbar_bg; *buf++ = headerbar_bg;
} while( --colsleft ); } while(--colsleft);
buf = buf_row + disp; buf = buf_row + disp;
} while( --rowsleft ); } while(--rowsleft);
SDL_UpdateRect( sdl_screen, 0,0,res_x,headerbar_height); SDL_UpdateRect( sdl_screen, 0,0,res_x,headerbar_height);
// go thru the bitmaps and display the active ones // go thru the bitmaps and display the active ones
while( bitmapscount-- ) while(bitmapscount--)
{ {
current_bmp = hb_entry[bitmapscount].bmp_id; current_bmp = hb_entry[bitmapscount].bmp_id;
if( sdl_bitmaps[current_bmp]->dst.x != -1 ) if(sdl_bitmaps[current_bmp]->dst.x != -1)
{ {
hb_dst = sdl_bitmaps[current_bmp]->dst; hb_dst = sdl_bitmaps[current_bmp]->dst;
if (hb_entry[bitmapscount].alignment == BX_GRAVITY_RIGHT) { if (hb_entry[bitmapscount].alignment == BX_GRAVITY_RIGHT) {
@ -1456,7 +1440,7 @@ void bx_sdl_gui_c::show_headerbar(void)
hb_dst.x, hb_dst.x,
sdl_bitmaps[current_bmp]->dst.y, sdl_bitmaps[current_bmp]->dst.y,
sdl_bitmaps[current_bmp]->src.w, sdl_bitmaps[current_bmp]->src.w,
sdl_bitmaps[current_bmp]->src.h ); sdl_bitmaps[current_bmp]->src.h);
} }
} }
// draw statusbar background // draw statusbar background
@ -1480,9 +1464,9 @@ void bx_sdl_gui_c::show_headerbar(void)
*buf++ = headerbar_bg; *buf++ = headerbar_bg;
} }
pos_x++; pos_x++;
} while( --colsleft ); } while(--colsleft);
buf = buf_row + disp; buf = buf_row + disp;
} while( --rowsleft ); } while(--rowsleft);
SDL_UpdateRect( sdl_screen, 0,res_y+headerbar_height,res_x,statusbar_height); SDL_UpdateRect( sdl_screen, 0,res_y+headerbar_height,res_x,statusbar_height);
for (unsigned i=0; i<statusitem_count; i++) { for (unsigned i=0; i<statusitem_count; i++) {
sdl_set_status_text(i+1, statusitem_text[i], statusitem_active[i+1]); sdl_set_status_text(i+1, statusitem_text[i], statusitem_active[i+1]);
@ -1492,7 +1476,7 @@ void bx_sdl_gui_c::show_headerbar(void)
void bx_sdl_gui_c::mouse_enabled_changed_specific (bx_bool val) void bx_sdl_gui_c::mouse_enabled_changed_specific (bx_bool val)
{ {
if( val == 1 ) if(val == 1)
{ {
SDL_ShowCursor(0); SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON); SDL_WM_GrabInput(SDL_GRAB_ON);
@ -1516,22 +1500,22 @@ void headerbar_click(int x)
xorigin = sdl_bitmaps[hb_entry[i].bmp_id]->dst.x; xorigin = sdl_bitmaps[hb_entry[i].bmp_id]->dst.x;
else else
xorigin = res_x - sdl_bitmaps[hb_entry[i].bmp_id]->dst.x; xorigin = res_x - sdl_bitmaps[hb_entry[i].bmp_id]->dst.x;
if ( (x>=xorigin) && (x<(xorigin+xdim)) ) { if ( (x>=xorigin) && (x<(xorigin+xdim))) {
hb_entry[i].f(); hb_entry[i].f();
return; return;
}
} }
}
} }
void bx_sdl_gui_c::exit(void) void bx_sdl_gui_c::exit(void)
{ {
if( sdl_screen ) if(sdl_screen)
SDL_FreeSurface(sdl_screen); SDL_FreeSurface(sdl_screen);
if( sdl_fullscreen ) if(sdl_fullscreen)
SDL_FreeSurface(sdl_fullscreen); SDL_FreeSurface(sdl_fullscreen);
while( n_sdl_bitmaps ) while(n_sdl_bitmaps)
{ {
SDL_FreeSurface( sdl_bitmaps[n_sdl_bitmaps-1]->surface ); SDL_FreeSurface(sdl_bitmaps[n_sdl_bitmaps-1]->surface);
n_sdl_bitmaps--; n_sdl_bitmaps--;
} }
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: svga.cc,v 1.15 2008-02-07 18:28:50 sshwarts Exp $ // $Id: svga.cc,v 1.16 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
@ -105,7 +105,7 @@ void bx_svga_gui_c::specific_init(
tilewidth = x_tilesize; tilewidth = x_tilesize;
tileheight = y_tilesize; tileheight = y_tilesize;
if(vga_init() != 0 ) if(vga_init() != 0)
{ {
LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL); LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL);
BX_PANIC (("Unable to initialize SVGAlib")); BX_PANIC (("Unable to initialize SVGAlib"));
@ -454,7 +454,7 @@ bx_bool bx_svga_gui_c::palette_change(
unsigned green, unsigned green,
unsigned blue) unsigned blue)
{ {
if( index > 255 ) return 0; if(index > 255) return 0;
// without VGA_CLUT8 extension we have only 6 bits for each r,g,b value // without VGA_CLUT8 extension we have only 6 bits for each r,g,b value
if (!clut8 && (red > 63 || green > 63 || blue > 63)) { if (!clut8 && (red > 63 || green > 63 || blue > 63)) {
@ -481,7 +481,7 @@ void bx_svga_gui_c::dimension_update(
if (bpp > 8) { if (bpp > 8) {
BX_PANIC(("%d bpp graphics mode not supported yet", bpp)); BX_PANIC(("%d bpp graphics mode not supported yet", bpp));
} }
if( fheight > 0 ) if(fheight > 0)
{ {
text_cols = x / fwidth; text_cols = x / fwidth;
text_rows = y / fheight; text_rows = y / fheight;
@ -492,7 +492,7 @@ void bx_svga_gui_c::dimension_update(
fontwidth = 8; fontwidth = 8;
} }
if( (x == res_x) && (y == res_y )) return; if ((x == res_x) && (y == res_y)) return;
if (x == 640 && y == 480) { if (x == 640 && y == 480) {
newmode = G640x480x256; newmode = G640x480x256;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: win32.cc,v 1.117 2008-02-05 22:57:41 sshwarts Exp $ // $Id: win32.cc,v 1.118 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,6 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Much of this file was written by: // Much of this file was written by:
// David Ross // David Ross
@ -343,20 +344,20 @@ Bit32u win32_to_bx_key[2][0x100] =
0, 0,
0, 0,
/* 0x70 - 0x7f */ /* 0x70 - 0x7f */
0, /* Todo: "Katakana" key ( ibm 133 ) for Japanese 106 keyboard */ 0, /* Todo: "Katakana" key (ibm 133) for Japanese 106 keyboard */
0, 0,
0, 0,
0, /* Todo: "Ro" key ( ibm 56 ) for Japanese 106 keyboard */ 0, /* Todo: "Ro" key (ibm 56) for Japanese 106 keyboard */
0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, /* Todo: "convert" key ( ibm 132 ) for Japanese 106 keyboard */ 0, /* Todo: "convert" key (ibm 132) for Japanese 106 keyboard */
0, 0,
0, /* Todo: "non-convert" key ( ibm 131 ) for Japanese 106 keyboard */ 0, /* Todo: "non-convert" key (ibm 131) for Japanese 106 keyboard */
0, 0,
0, /* Todo: "Yen" key ( ibm 14 ) for Japanese 106 keyboard */ 0, /* Todo: "Yen" key (ibm 14) for Japanese 106 keyboard */
0, 0,
0, 0,
}, },
@ -491,65 +492,65 @@ Bit32u win32_to_bx_key[2][0x100] =
void bx_signal_handler(int); void bx_signal_handler(int);
#endif #endif
static void processMouseXY( int x, int y, int z, int windows_state, int implied_state_change) static void processMouseXY(int x, int y, int z, int windows_state, int implied_state_change)
{ {
int bx_state; int bx_state;
int old_bx_state; int old_bx_state;
EnterCriticalSection( &stInfo.mouseCS); EnterCriticalSection(&stInfo.mouseCS);
bx_state=( ( windows_state & MK_LBUTTON) ? 1 : 0 ) + ( ( windows_state & MK_RBUTTON) ? 2 : 0) + bx_state=((windows_state & MK_LBUTTON) ? 1 : 0) + ((windows_state & MK_RBUTTON) ? 2 : 0) +
( ( windows_state & MK_MBUTTON) ? 4 : 0); ((windows_state & MK_MBUTTON) ? 4 : 0);
old_bx_state=bx_state ^ implied_state_change; old_bx_state=bx_state ^ implied_state_change;
if ( old_bx_state!=mouse_button_state) if (old_bx_state!=mouse_button_state)
{ {
/* Make up for missing message */ /* Make up for missing message */
BX_INFO(( "&&&missing mouse state change")); BX_INFO(("&&&missing mouse state change"));
EnterCriticalSection( &stInfo.keyCS); EnterCriticalSection(&stInfo.keyCS);
enq_mouse_event(); enq_mouse_event();
mouse_button_state=old_bx_state; mouse_button_state=old_bx_state;
enq_key_event( mouse_button_state, MOUSE_PRESSED); enq_key_event(mouse_button_state, MOUSE_PRESSED);
LeaveCriticalSection( &stInfo.keyCS); LeaveCriticalSection(&stInfo.keyCS);
} }
ms_ydelta=ms_savedy-y; ms_ydelta=ms_savedy-y;
ms_xdelta=x-ms_savedx; ms_xdelta=x-ms_savedx;
ms_zdelta=z; ms_zdelta=z;
ms_lastx=x; ms_lastx=x;
ms_lasty=y; ms_lasty=y;
if ( bx_state!=mouse_button_state) if (bx_state!=mouse_button_state)
{ {
EnterCriticalSection( &stInfo.keyCS); EnterCriticalSection(&stInfo.keyCS);
enq_mouse_event(); enq_mouse_event();
mouse_button_state=bx_state; mouse_button_state=bx_state;
enq_key_event( mouse_button_state, MOUSE_PRESSED); enq_key_event(mouse_button_state, MOUSE_PRESSED);
LeaveCriticalSection( &stInfo.keyCS); LeaveCriticalSection(&stInfo.keyCS);
} }
LeaveCriticalSection( &stInfo.mouseCS); LeaveCriticalSection(&stInfo.mouseCS);
} }
static void resetDelta() static void resetDelta()
{ {
EnterCriticalSection( &stInfo.mouseCS); EnterCriticalSection(&stInfo.mouseCS);
ms_savedx=ms_lastx; ms_savedx=ms_lastx;
ms_savedy=ms_lasty; ms_savedy=ms_lasty;
ms_ydelta=ms_xdelta=ms_zdelta=0; ms_ydelta=ms_xdelta=ms_zdelta=0;
LeaveCriticalSection( &stInfo.mouseCS); LeaveCriticalSection(&stInfo.mouseCS);
} }
static void cursorWarped() static void cursorWarped()
{ {
EnterCriticalSection( &stInfo.mouseCS); EnterCriticalSection(&stInfo.mouseCS);
EnterCriticalSection( &stInfo.keyCS); EnterCriticalSection(&stInfo.keyCS);
enq_mouse_event(); enq_mouse_event();
LeaveCriticalSection( &stInfo.keyCS); LeaveCriticalSection(&stInfo.keyCS);
ms_lastx=stretched_x/2; ms_lastx=stretched_x/2;
ms_lasty=stretched_y/2; ms_lasty=stretched_y/2;
ms_savedx=ms_lastx; ms_savedx=ms_lastx;
ms_savedy=ms_lasty; ms_savedy=ms_lasty;
LeaveCriticalSection( &stInfo.mouseCS); LeaveCriticalSection(&stInfo.mouseCS);
} }
// GUI thread must be dead/done in order to call terminateEmul // GUI thread must be dead/done in order to call terminateEmul
void terminateEmul(int reason) { void terminateEmul(int reason)
{
// We know that Critical Sections were inited when x_tilesize has been set // We know that Critical Sections were inited when x_tilesize has been set
// See bx_win32_gui_c::specific_init // See bx_win32_gui_c::specific_init
if (x_tilesize != 0) { if (x_tilesize != 0) {
@ -562,7 +563,7 @@ void terminateEmul(int reason) {
if (MemoryDC) DeleteDC (MemoryDC); if (MemoryDC) DeleteDC (MemoryDC);
if (MemoryBitmap) DeleteObject (MemoryBitmap); if (MemoryBitmap) DeleteObject (MemoryBitmap);
if ( bitmap_info) delete[] (char*)bitmap_info; if (bitmap_info) delete[] (char*)bitmap_info;
for (unsigned b=0; b<bx_bitmap_entries; b++) for (unsigned b=0; b<bx_bitmap_entries; b++)
if (bx_bitmaps[b].bmap) DeleteObject(bx_bitmaps[b].bmap); if (bx_bitmaps[b].bmap) DeleteObject(bx_bitmaps[b].bmap);
@ -798,7 +799,8 @@ void resize_main_window()
} }
// This thread controls the GUI window. // This thread controls the GUI window.
VOID UIThread(PVOID pvoid) { VOID UIThread(PVOID pvoid)
{
MSG msg; MSG msg;
HDC hdc; HDC hdc;
WNDCLASS wndclass; WNDCLASS wndclass;
@ -873,7 +875,7 @@ VOID UIThread(PVOID pvoid) {
} }
SetStatusText(0, szMouseEnable, TRUE); SetStatusText(0, szMouseEnable, TRUE);
stInfo.simWnd = CreateWindowEx( sim_exstyle, stInfo.simWnd = CreateWindowEx(sim_exstyle,
"SIMWINDOW", "SIMWINDOW",
"", "",
sim_style, sim_style,
@ -1010,7 +1012,7 @@ LRESULT CALLBACK mainWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
int rect_data[] = { 1, 0, IsWindowVisible(hwndTB), int rect_data[] = { 1, 0, IsWindowVisible(hwndTB),
100, IsWindowVisible(hwndSB), 0x7712, 0, 0 }; 100, IsWindowVisible(hwndSB), 0x7712, 0, 0 };
RECT R; RECT R;
GetEffectiveClientRect( hwnd, &R, rect_data ); GetEffectiveClientRect(hwnd, &R, rect_data);
x = R.right - R.left; x = R.right - R.left;
y = R.bottom - R.top; y = R.bottom - R.top;
MoveWindow(stInfo.simWnd, R.left, R.top, x, y, TRUE); MoveWindow(stInfo.simWnd, R.left, R.top, x, y, TRUE);
@ -1100,7 +1102,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
SetMouseCapture(); SetMouseCapture();
} }
// If mouse escaped, bring it back // If mouse escaped, bring it back
if ( mouseCaptureMode) if (mouseCaptureMode)
{ {
pt.x = 0; pt.x = 0;
pt.y = 0; pt.y = 0;
@ -1140,7 +1142,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (!mouseModeChange) { if (!mouseModeChange) {
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 0); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 0);
} }
return 0; return 0;
@ -1152,7 +1154,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
pt.x = LOWORD(lParam); pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam); pt.y = HIWORD(lParam);
ScreenToClient(stInfo.simWnd, &pt); ScreenToClient(stInfo.simWnd, &pt);
processMouseXY( pt.x, pt.y, (Bit16s) HIWORD(wParam) / 120, LOWORD(wParam), 0); processMouseXY(pt.x, pt.y, (Bit16s) HIWORD(wParam) / 120, LOWORD(wParam), 0);
} }
return 0; return 0;
@ -1167,11 +1169,11 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
} else if (mouseModeChange && (iMsg == WM_LBUTTONUP)) { } else if (mouseModeChange && (iMsg == WM_LBUTTONUP)) {
mouseModeChange = FALSE; mouseModeChange = FALSE;
} else { } else {
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 1); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 1);
} }
return 0; return 0;
} }
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 1); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 1);
return 0; return 0;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
@ -1184,7 +1186,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
} else if (mouseModeChange && (iMsg == WM_MBUTTONUP)) { } else if (mouseModeChange && (iMsg == WM_MBUTTONUP)) {
mouseModeChange = FALSE; mouseModeChange = FALSE;
} else { } else {
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 4); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 4);
} }
return 0; return 0;
@ -1199,11 +1201,11 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
} else if (mouseModeChange && (iMsg == WM_RBUTTONUP)) { } else if (mouseModeChange && (iMsg == WM_RBUTTONUP)) {
mouseModeChange = FALSE; mouseModeChange = FALSE;
} else { } else {
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 2); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 2);
} }
return 0; return 0;
} }
processMouseXY( LOWORD(lParam), HIWORD(lParam), 0, wParam, 2); processMouseXY(LOWORD(lParam), HIWORD(lParam), 0, wParam, 2);
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
@ -1349,7 +1351,7 @@ void enq_key_event(Bit32u key, Bit32u press_release)
} }
} }
if (((tail+1) % SCANCODE_BUFSIZE) == head) { if (((tail+1) % SCANCODE_BUFSIZE) == head) {
BX_ERROR(( "enq_scancode: buffer full")); BX_ERROR(("enq_scancode: buffer full"));
return; return;
} }
keyevents[tail].key_event = key | press_release; keyevents[tail].key_event = key | press_release;
@ -1358,11 +1360,11 @@ void enq_key_event(Bit32u key, Bit32u press_release)
void enq_mouse_event(void) void enq_mouse_event(void)
{ {
EnterCriticalSection( &stInfo.mouseCS); EnterCriticalSection(&stInfo.mouseCS);
if ( ms_xdelta || ms_ydelta || ms_zdelta) if (ms_xdelta || ms_ydelta || ms_zdelta)
{ {
if (((tail+1) % SCANCODE_BUFSIZE) == head) { if (((tail+1) % SCANCODE_BUFSIZE) == head) {
BX_ERROR(( "enq_scancode: buffer full" )); BX_ERROR(("enq_scancode: buffer full"));
return; return;
} }
QueueEvent& current=keyevents[tail]; QueueEvent& current=keyevents[tail];
@ -1374,13 +1376,14 @@ void enq_mouse_event(void)
resetDelta(); resetDelta();
tail = (tail + 1) % SCANCODE_BUFSIZE; tail = (tail + 1) % SCANCODE_BUFSIZE;
} }
LeaveCriticalSection( &stInfo.mouseCS); LeaveCriticalSection(&stInfo.mouseCS);
} }
QueueEvent* deq_key_event(void) { QueueEvent* deq_key_event(void)
{
QueueEvent* key; QueueEvent* key;
if ( head == tail ) { if (head == tail) {
BX_ERROR(("deq_scancode: buffer empty")); BX_ERROR(("deq_scancode: buffer empty"));
return((QueueEvent*)0); return((QueueEvent*)0);
} }
@ -1397,7 +1400,8 @@ QueueEvent* deq_key_event(void) {
// the gui code can poll for keyboard, mouse, and other // the gui code can poll for keyboard, mouse, and other
// relevant events. // relevant events.
void bx_win32_gui_c::handle_events(void) { void bx_win32_gui_c::handle_events(void)
{
Bit32u key; Bit32u key;
Bit32u key_event; Bit32u key_event;
@ -1410,17 +1414,17 @@ void bx_win32_gui_c::handle_events(void) {
EnterCriticalSection(&stInfo.keyCS); EnterCriticalSection(&stInfo.keyCS);
while (head != tail) { while (head != tail) {
QueueEvent* queue_event=deq_key_event(); QueueEvent* queue_event=deq_key_event();
if ( ! queue_event) if (! queue_event)
break; break;
key = queue_event->key_event; key = queue_event->key_event;
if ( key==MOUSE_MOTION) if (key==MOUSE_MOTION)
{ {
DEV_mouse_motion_ext( queue_event->mouse_x, DEV_mouse_motion_ext(queue_event->mouse_x,
queue_event->mouse_y, queue_event->mouse_z, queue_event->mouse_button_state); queue_event->mouse_y, queue_event->mouse_z, queue_event->mouse_button_state);
} }
// Check for mouse buttons first // Check for mouse buttons first
else if ( key & MOUSE_PRESSED) { else if (key & MOUSE_PRESSED) {
DEV_mouse_motion_ext( 0, 0, 0, LOWORD(key)); DEV_mouse_motion_ext(0, 0, 0, LOWORD(key));
} }
else if (key & HEADERBAR_CLICKED) { else if (key & HEADERBAR_CLICKED) {
headerbar_click(LOWORD(key)); headerbar_click(LOWORD(key));
@ -1446,25 +1450,26 @@ void bx_win32_gui_c::handle_events(void) {
// Called periodically, requesting that the gui code flush all pending // Called periodically, requesting that the gui code flush all pending
// screen update requests. // screen update requests.
void bx_win32_gui_c::flush(void) { void bx_win32_gui_c::flush(void)
EnterCriticalSection( &stInfo.drawCS); {
EnterCriticalSection(&stInfo.drawCS);
if (updated_area_valid) { if (updated_area_valid) {
// slight bugfix // slight bugfix
updated_area.right++; updated_area.right++;
updated_area.bottom++; updated_area.bottom++;
InvalidateRect( stInfo.simWnd, &updated_area, FALSE); InvalidateRect(stInfo.simWnd, &updated_area, FALSE);
updated_area_valid = FALSE; updated_area_valid = FALSE;
} }
LeaveCriticalSection( &stInfo.drawCS); LeaveCriticalSection(&stInfo.drawCS);
} }
// ::CLEAR_SCREEN() // ::CLEAR_SCREEN()
// //
// Called to request that the VGA region is cleared. Don't // Called to request that the VGA region is cleared. Don't
// clear the area that defines the headerbar. // clear the area that defines the headerbar.
void bx_win32_gui_c::clear_screen(void) { void bx_win32_gui_c::clear_screen(void)
{
HGDIOBJ oldObj; HGDIOBJ oldObj;
if (!stInfo.UIinited) return; if (!stInfo.UIinited) return;
@ -1744,8 +1749,7 @@ void bx_win32_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
LeaveCriticalSection(&stInfo.drawCS); LeaveCriticalSection(&stInfo.drawCS);
} }
int int bx_win32_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
bx_win32_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
{ {
if (OpenClipboard(stInfo.simWnd)) { if (OpenClipboard(stInfo.simWnd)) {
HGLOBAL hg = GetClipboardData(CF_TEXT); HGLOBAL hg = GetClipboardData(CF_TEXT);
@ -1766,8 +1770,7 @@ bx_win32_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
} }
} }
int int bx_win32_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
bx_win32_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
{ {
if (OpenClipboard(stInfo.simWnd)) { if (OpenClipboard(stInfo.simWnd)) {
HANDLE hMem = GlobalAlloc(GMEM_ZEROINIT, len); HANDLE hMem = GlobalAlloc(GMEM_ZEROINIT, len);
@ -1822,7 +1825,8 @@ bx_bool bx_win32_gui_c::palette_change(unsigned index, unsigned red,
// note: origin of tile and of window based on (0,0) being in the upper // note: origin of tile and of window based on (0,0) being in the upper
// left of the window. // left of the window.
void bx_win32_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0) { void bx_win32_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
{
HDC hdc; HDC hdc;
HGDIOBJ oldObj; HGDIOBJ oldObj;
@ -1831,7 +1835,7 @@ void bx_win32_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
oldObj = SelectObject(MemoryDC, MemoryBitmap); oldObj = SelectObject(MemoryDC, MemoryBitmap);
StretchDIBits( MemoryDC, x0, y0, x_tilesize, y_tilesize, 0, 0, StretchDIBits(MemoryDC, x0, y0, x_tilesize, y_tilesize, 0, 0,
x_tilesize, y_tilesize, tile, bitmap_info, DIB_RGB_COLORS, SRCCOPY); x_tilesize, y_tilesize, tile, bitmap_info, DIB_RGB_COLORS, SRCCOPY);
SelectObject(MemoryDC, oldObj); SelectObject(MemoryDC, oldObj);
@ -1888,7 +1892,7 @@ void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight,
#endif #endif
} }
if ( x==dimension_x && y==dimension_y && bpp==current_bpp) if (x==dimension_x && y==dimension_y && bpp==current_bpp)
return; return;
dimension_x = x; dimension_x = x;
dimension_y = y; dimension_y = y;
@ -1952,7 +1956,8 @@ void bx_win32_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight,
// ydim: y dimension of bitmap // ydim: y dimension of bitmap
unsigned bx_win32_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned bx_win32_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim,
unsigned ydim) { unsigned ydim)
{
unsigned char *data; unsigned char *data;
TBADDBITMAP tbab; TBADDBITMAP tbab;
@ -1997,11 +2002,12 @@ unsigned bx_win32_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim,
// the boundaries of this bitmap. // the boundaries of this bitmap.
unsigned bx_win32_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, unsigned bx_win32_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment,
void (*f)(void)) { void (*f)(void))
{
unsigned hb_index; unsigned hb_index;
TBBUTTON tbb[1]; TBBUTTON tbb[1];
if ( (bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES ) if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES)
terminateEmul(EXIT_HEADER_BITMAP_ERROR); terminateEmul(EXIT_HEADER_BITMAP_ERROR);
bx_headerbar_entries++; bx_headerbar_entries++;
@ -2085,7 +2091,8 @@ void bx_win32_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
// //
// Called before bochs terminates, to allow for a graceful // Called before bochs terminates, to allow for a graceful
// exit from the native GUI mechanism. // exit from the native GUI mechanism.
void bx_win32_gui_c::exit(void) { void bx_win32_gui_c::exit(void)
{
printf("# In bx_win32_gui_c::exit(void)!\n"); printf("# In bx_win32_gui_c::exit(void)!\n");
// kill thread first... // kill thread first...
@ -2098,7 +2105,8 @@ void bx_win32_gui_c::exit(void) {
} }
void create_vga_font(void) { void create_vga_font(void)
{
unsigned char data[64]; unsigned char data[64];
// VGA font is 8 or 9 wide and up to 32 high // VGA font is 8 or 9 wide and up to 32 high
@ -2113,7 +2121,8 @@ void create_vga_font(void) {
} }
unsigned char reverse_bitorder(unsigned char b) { unsigned char reverse_bitorder(unsigned char b)
{
unsigned char ret=0; unsigned char ret=0;
for (unsigned i=0; i<8; i++) { for (unsigned i=0; i<8; i++) {
@ -2134,7 +2143,8 @@ COLORREF GetColorRef(unsigned char attr)
void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart, int width, void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart, int width,
int height, int fcol, int frow, DWORD dwRop, unsigned char cColor) { int height, int fcol, int frow, DWORD dwRop, unsigned char cColor)
{
BITMAP bm; BITMAP bm;
HDC hdcMem; HDC hdcMem;
POINT ptSize, ptOrg; POINT ptSize, ptOrg;
@ -2172,7 +2182,8 @@ void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart, int width,
} }
void updateUpdated(int x1, int y1, int x2, int y2) { void updateUpdated(int x1, int y1, int x2, int y2)
{
x1*=stretch_factor; x1*=stretch_factor;
x2*=stretch_factor; x2*=stretch_factor;
if (!updated_area_valid) { if (!updated_area_valid) {
@ -2252,7 +2263,8 @@ void bx_win32_gui_c::show_ips(Bit32u ips_count)
#if BX_USE_WINDOWS_FONTS #if BX_USE_WINDOWS_FONTS
void DrawChar (HDC hdc, unsigned char c, int xStart, int yStart, void DrawChar (HDC hdc, unsigned char c, int xStart, int yStart,
unsigned char cColor, int cs_start, int cs_end) { unsigned char cColor, int cs_start, int cs_end)
{
HDC hdcMem; HDC hdcMem;
POINT ptSize, ptOrg; POINT ptSize, ptOrg;
HGDIOBJ oldObj; HGDIOBJ oldObj;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// $Id: wx.cc,v 1.93 2008-02-05 22:57:41 sshwarts Exp $ // $Id: wx.cc,v 1.94 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// //
// wxWidgets VGA display for Bochs. wx.cc implements a custom // wxWidgets VGA display for Bochs. wx.cc implements a custom
@ -27,10 +27,6 @@
// //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
// includes
//////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing. // is used to know when we are exporting symbols and when we are importing.
@ -239,7 +235,7 @@ void MyPanel::OnMouse(wxMouseEvent& event)
} }
) )
if (event.MiddleDown () && event.ControlDown ()) { if (event.MiddleDown() && event.ControlDown()) {
ToggleMouse (false); ToggleMouse (false);
return; return;
} }
@ -249,9 +245,9 @@ void MyPanel::OnMouse(wxMouseEvent& event)
// process buttons and motion together // process buttons and motion together
Bit32u buttons; Bit32u buttons;
buttons = event.LeftIsDown () ? 1 : 0; buttons = event.LeftIsDown() ? 1 : 0;
buttons |= event.RightIsDown () ? 2 : 0; buttons |= event.RightIsDown() ? 2 : 0;
buttons |= event.MiddleIsDown () ? 4 : 0; buttons |= event.MiddleIsDown() ? 4 : 0;
if (x==mouseSavedX && y==mouseSavedY && !event.IsButton ()) { if (x==mouseSavedX && y==mouseSavedY && !event.IsButton ()) {
// nothing happened. This could have been generated by the WarpPointer. // nothing happened. This could have been generated by the WarpPointer.
return; return;
@ -282,8 +278,7 @@ void MyPanel::OnMouse(wxMouseEvent& event)
// will move the cursor to (mouseSavedX, mouseSavedY). // will move the cursor to (mouseSavedX, mouseSavedY).
} }
void void MyPanel::MyRefresh ()
MyPanel::MyRefresh ()
{ {
IFDBG_VGA (wxLogDebug (wxT ("set needRefresh=true"))); IFDBG_VGA (wxLogDebug (wxT ("set needRefresh=true")));
needRefresh = true; needRefresh = true;
@ -310,10 +305,8 @@ void MyPanel::OnKeyUp(wxKeyEvent& event)
} }
} }
/// copied right out of gui/x.cc /// copied right out of gui/x.cc
static char static char wxAsciiKey[0x5f] = {
wxAsciiKey[0x5f] = {
// !"#$%&' // !"#$%&'
BX_KEY_SPACE, BX_KEY_SPACE,
BX_KEY_1, BX_KEY_1,
@ -437,8 +430,7 @@ wxAsciiKey[0x5f] = {
}; };
// copied from gui/win32.cc // copied from gui/win32.cc
Bit32u Bit32u wxMSW_to_bx_key[0x59] = {
wxMSW_to_bx_key[0x59] = {
/* 0x00 - 0x0f */ /* 0x00 - 0x0f */
0, 0,
BX_KEY_ESC, BX_KEY_ESC,
@ -544,8 +536,7 @@ wxMSW_to_bx_key[0x59] = {
#endif #endif
// MS Windows specific key mapping, which uses wxKeyEvent::m_rawCode & 2. // MS Windows specific key mapping, which uses wxKeyEvent::m_rawCode & 2.
bx_bool bx_bool MyPanel::fillBxKeyEvent_MSW (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
MyPanel::fillBxKeyEvent_MSW (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
{ {
#if defined(wxHAS_RAW_KEY_CODES) && defined(__WXMSW__) #if defined(wxHAS_RAW_KEY_CODES) && defined(__WXMSW__)
IFDBG_KEY(wxLogDebug (wxT ("fillBxKeyEvent_MSW. key code %d, raw codes %d %d", wxev.m_keyCode, wxev.m_rawCode, wxev.m_rawFlags))); IFDBG_KEY(wxLogDebug (wxT ("fillBxKeyEvent_MSW. key code %d, raw codes %d %d", wxev.m_keyCode, wxev.m_rawCode, wxev.m_rawFlags)));
@ -572,8 +563,7 @@ MyPanel::fillBxKeyEvent_MSW (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release
#endif #endif
// GTK specific key mapping, which uses wxKeyEvent::m_rawCode. // GTK specific key mapping, which uses wxKeyEvent::m_rawCode.
bx_bool bx_bool MyPanel::fillBxKeyEvent_GTK (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
MyPanel::fillBxKeyEvent_GTK (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
{ {
#if defined (wxHAS_RAW_KEY_CODES) && defined(__WXGTK__) #if defined (wxHAS_RAW_KEY_CODES) && defined(__WXGTK__)
IFDBG_KEY(wxLogDebug (wxT ("fillBxKeyEvent_GTK. key code %ld, raw codes %d %d", wxev.m_keyCode, wxev.m_rawCode, wxev.m_rawFlags))); IFDBG_KEY(wxLogDebug (wxT ("fillBxKeyEvent_GTK. key code %ld, raw codes %d %d", wxev.m_keyCode, wxev.m_rawCode, wxev.m_rawFlags)));
@ -729,14 +719,14 @@ MyPanel::fillBxKeyEvent_GTK (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release
#endif #endif
default: default:
wxLogError(wxT ("fillBxKeyEvent_GTK(): keysym %x unhandled!"), (unsigned) keysym ); wxLogError(wxT("fillBxKeyEvent_GTK(): keysym %x unhandled!"), (unsigned) keysym);
return BX_KEY_UNHANDLED; return BX_KEY_UNHANDLED;
} }
} else { } else {
/* use mapping */ /* use mapping */
BXKeyEntry *entry = bx_keymap.findHostKey (keysym); BXKeyEntry *entry = bx_keymap.findHostKey (keysym);
if (!entry) { if (!entry) {
BX_ERROR(( "fillBxKeyEvent_GTK(): keysym %x unhandled!", (unsigned) keysym )); BX_ERROR(("fillBxKeyEvent_GTK(): keysym %x unhandled!", (unsigned) keysym));
return BX_KEY_UNHANDLED; return BX_KEY_UNHANDLED;
} }
key_event = entry->baseKey; key_event = entry->baseKey;
@ -749,8 +739,7 @@ MyPanel::fillBxKeyEvent_GTK (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release
#endif #endif
} }
bx_bool bx_bool MyPanel::fillBxKeyEvent (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
MyPanel::fillBxKeyEvent (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
{ {
// Use raw codes if they are available. Raw codes are a nonstandard addition // Use raw codes if they are available. Raw codes are a nonstandard addition
// to the wxWidgets library. At present, the only way to use the "RAW_CODES" // to the wxWidgets library. At present, the only way to use the "RAW_CODES"
@ -873,13 +862,11 @@ MyPanel::fillBxKeyEvent (wxKeyEvent& wxev, BxKeyEvent& bxev, bx_bool release)
return true; return true;
} }
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// fill in methods of bx_gui // fill in methods of bx_gui
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
void void bx_wx_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
bx_wx_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
unsigned headerbar_y) unsigned headerbar_y)
{ {
int b,i,j; int b,i,j;
@ -1051,10 +1038,9 @@ void bx_wx_gui_c::handle_events(void)
num_events = 0; num_events = 0;
} }
void void bx_wx_gui_c::statusbar_setitem(int element, bx_bool active)
bx_wx_gui_c::statusbar_setitem(int element, bx_bool active)
{ {
#if defined( __WXMSW__) #if defined(__WXMSW__)
char status_text[10]; char status_text[10];
#endif #endif
@ -1062,7 +1048,7 @@ bx_wx_gui_c::statusbar_setitem(int element, bx_bool active)
if (element < 0) { if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) { for (unsigned i = 0; i < statusitem_count; i++) {
if (active) { if (active) {
#if defined( __WXMSW__) #if defined(__WXMSW__)
status_text[0] = 9; status_text[0] = 9;
strcpy(status_text+1, statusitem_text[i]); strcpy(status_text+1, statusitem_text[i]);
theFrame->SetStatusText(status_text, i+1); theFrame->SetStatusText(status_text, i+1);
@ -1075,7 +1061,7 @@ bx_wx_gui_c::statusbar_setitem(int element, bx_bool active)
} }
} else if ((unsigned)element < statusitem_count) { } else if ((unsigned)element < statusitem_count) {
if (active) { if (active) {
#if defined( __WXMSW__) #if defined(__WXMSW__)
status_text[0] = 9; status_text[0] = 9;
strcpy(status_text+1, statusitem_text[element]); strcpy(status_text+1, statusitem_text[element]);
theFrame->SetStatusText(status_text, element+1); theFrame->SetStatusText(status_text, element+1);
@ -1095,19 +1081,16 @@ bx_wx_gui_c::statusbar_setitem(int element, bx_bool active)
// Called periodically, requesting that the gui code flush all pending // Called periodically, requesting that the gui code flush all pending
// screen update requests. // screen update requests.
void void bx_wx_gui_c::flush(void)
bx_wx_gui_c::flush(void)
{ {
} }
// ::CLEAR_SCREEN() // ::CLEAR_SCREEN()
// //
// Called to request that the VGA region is cleared. Don't // Called to request that the VGA region is cleared. Don't
// clear the area that defines the headerbar. // clear the area that defines the headerbar.
void void bx_wx_gui_c::clear_screen(void)
bx_wx_gui_c::clear_screen(void)
{ {
IFDBG_VGA(wxLogDebug (wxT ("MyPanel::clear_screen trying to get lock. wxScreen=%p", wxScreen))); IFDBG_VGA(wxLogDebug (wxT ("MyPanel::clear_screen trying to get lock. wxScreen=%p", wxScreen)));
wxCriticalSectionLocker lock(wxScreen_lock); wxCriticalSectionLocker lock(wxScreen_lock);
@ -1116,8 +1099,7 @@ bx_wx_gui_c::clear_screen(void)
thePanel->MyRefresh (); thePanel->MyRefresh ();
} }
static void static void UpdateScreen(unsigned char *newBits, int x, int y, int width, int height)
UpdateScreen(unsigned char *newBits, int x, int y, int width, int height)
{ {
IFDBG_VGA(wxLogDebug (wxT ("MyPanel::UpdateScreen trying to get lock. wxScreen=%p", wxScreen))); IFDBG_VGA(wxLogDebug (wxT ("MyPanel::UpdateScreen trying to get lock. wxScreen=%p", wxScreen)));
wxCriticalSectionLocker lock(wxScreen_lock); wxCriticalSectionLocker lock(wxScreen_lock);
@ -1147,8 +1129,7 @@ UpdateScreen(unsigned char *newBits, int x, int y, int width, int height)
} }
} }
static void static void DrawBochsBitmap(int x, int y, int width, int height, char *bmap, char color, int fontx, int fonty, bx_bool gfxchar)
DrawBochsBitmap(int x, int y, int width, int height, char *bmap, char color, int fontx, int fonty, bx_bool gfxchar)
{ {
static unsigned char newBits[9 * 32]; static unsigned char newBits[9 * 32];
unsigned char mask; unsigned char mask;
@ -1368,10 +1349,9 @@ void bx_wx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
wxCursorX = cursor_x; wxCursorX = cursor_x;
wxCursorY = cursor_y; wxCursorY = cursor_y;
thePanel->MyRefresh (); thePanel->MyRefresh();
} }
// ::PALETTE_CHANGE() // ::PALETTE_CHANGE()
// //
// Allocate a color in the native GUI, for this color, and put // Allocate a color in the native GUI, for this color, and put
@ -1379,8 +1359,7 @@ void bx_wx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
// returns: 0=no screen update needed (color map change has direct effect) // returns: 0=no screen update needed (color map change has direct effect)
// 1=screen update needed (redraw using current colormap) // 1=screen update needed (redraw using current colormap)
bx_bool bx_bool bx_wx_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue)
bx_wx_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue)
{ {
IFDBG_VGA(wxLogDebug (wxT ("palette_change"))); IFDBG_VGA(wxLogDebug (wxT ("palette_change")));
wxBochsPalette[index].red = red; wxBochsPalette[index].red = red;
@ -1409,11 +1388,10 @@ void bx_wx_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
{ {
IFDBG_VGA (wxLogDebug (wxT ("graphics_tile_update"))); IFDBG_VGA (wxLogDebug (wxT ("graphics_tile_update")));
UpdateScreen(tile, x0, y0, wxTileX, wxTileY); UpdateScreen(tile, x0, y0, wxTileX, wxTileY);
thePanel->MyRefresh (); thePanel->MyRefresh();
} }
bx_svga_tileinfo_t * bx_svga_tileinfo_t *bx_wx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
bx_wx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
{ {
if (!info) { if (!info) {
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t)); info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
@ -1434,10 +1412,9 @@ bx_wx_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
info->is_little_endian = 1; info->is_little_endian = 1;
return info; return info;
}; }
Bit8u * Bit8u *bx_wx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
bx_wx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
unsigned *w, unsigned *h) unsigned *w, unsigned *h)
{ {
if (x0+wxTileX > (unsigned)wxScreenX) { if (x0+wxTileX > (unsigned)wxScreenX) {
@ -1457,8 +1434,7 @@ bx_wx_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
return (Bit8u *)wxScreen + y0 * wxScreenX * 3 + x0 * 3; return (Bit8u *)wxScreen + y0 * wxScreenX * 3 + x0 * 3;
} }
void void bx_wx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
bx_wx_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
unsigned w, unsigned h) unsigned w, unsigned h)
{ {
thePanel->MyRefresh(); thePanel->MyRefresh();
@ -1532,8 +1508,7 @@ void bx_wx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, uns
// xdim: x dimension of bitmap // xdim: x dimension of bitmap
// ydim: y dimension of bitmap // ydim: y dimension of bitmap
unsigned unsigned bx_wx_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
bx_wx_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
{ {
UNUSED(bmap); UNUSED(bmap);
UNUSED(xdim); UNUSED(xdim);
@ -1556,8 +1531,7 @@ bx_wx_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned yd
// f: a 'C' function pointer to callback when the mouse is clicked in // f: a 'C' function pointer to callback when the mouse is clicked in
// the boundaries of this bitmap. // the boundaries of this bitmap.
unsigned unsigned bx_wx_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
bx_wx_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
{ {
UNUSED(bmap_id); UNUSED(bmap_id);
UNUSED(alignment); UNUSED(alignment);
@ -1565,18 +1539,15 @@ bx_wx_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(vo
return(0); return(0);
} }
// ::SHOW_HEADERBAR() // ::SHOW_HEADERBAR()
// //
// Show (redraw) the current headerbar, which is composed of // Show (redraw) the current headerbar, which is composed of
// currently installed bitmaps. // currently installed bitmaps.
void void bx_wx_gui_c::show_headerbar(void)
bx_wx_gui_c::show_headerbar(void)
{ {
} }
// ::REPLACE_BITMAP() // ::REPLACE_BITMAP()
// //
// Replace the bitmap installed in the headerbar ID slot 'hbar_id', // Replace the bitmap installed in the headerbar ID slot 'hbar_id',
@ -1613,9 +1584,7 @@ void bx_wx_gui_c::mouse_enabled_changed_specific(bx_bool val)
mouse_captured = val; mouse_captured = val;
} }
int bx_wx_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
int
bx_wx_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
{ {
int ret = 0; int ret = 0;
wxMutexGuiEnter(); wxMutexGuiEnter();
@ -1641,8 +1610,7 @@ bx_wx_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
return ret; return ret;
} }
int int bx_wx_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
bx_wx_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
{ {
wxMutexGuiEnter(); wxMutexGuiEnter();
int ret = 0; int ret = 0;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// $Id: wxdialog.cc,v 1.104 2008-02-05 22:57:41 sshwarts Exp $ // $Id: wxdialog.cc,v 1.105 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
@ -148,7 +148,7 @@ void LogMsgAskDialog::OnEvent(wxCommandEvent& event)
void LogMsgAskDialog::ShowHelp() void LogMsgAskDialog::ShowHelp()
{ {
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this ); wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this);
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -383,10 +383,9 @@ void FloppyConfigDialog::OnEvent(wxCommandEvent& event)
void FloppyConfigDialog::ShowHelp() void FloppyConfigDialog::ShowHelp()
{ {
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this ); wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this);
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// AdvancedLogOptionsDialog implementation // AdvancedLogOptionsDialog implementation
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -629,10 +628,9 @@ void AdvancedLogOptionsDialog::OnEvent(wxCommandEvent& event)
void AdvancedLogOptionsDialog::ShowHelp() void AdvancedLogOptionsDialog::ShowHelp()
{ {
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this ); wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this);
} }
#if BX_DEBUGGER #if BX_DEBUGGER
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// DebugLogDialog implementation // DebugLogDialog implementation
@ -1153,18 +1151,18 @@ bool ParamDialog::CopyGuiToParam()
n = GetTextCtrlInt(pstr->u.text, &valid, true, complaint); n = GetTextCtrlInt(pstr->u.text, &valid, true, complaint);
} }
if ((n < nump->get_min()) || (n > nump->get_max())) { if ((n < nump->get_min()) || (n > nump->get_max())) {
wxMessageBox(wxT("Numerical parameter out of range"), wxT("Error"), wxOK | wxICON_ERROR, this ); wxMessageBox(wxT("Numerical parameter out of range"), wxT("Error"), wxOK | wxICON_ERROR, this);
return false; return false;
} }
if (n != nump->get()) nump->set(n); if (n != nump->get()) nump->set(n);
break; break;
} }
case BXT_PARAM_ENUM: { case BXT_PARAM_ENUM: {
bx_param_enum_c *enump = (bx_param_enum_c*) pstr->param; bx_param_enum_c *enump = (bx_param_enum_c*) pstr->param;
int value = pstr->u.choice->GetSelection () + enump->get_min (); int value = pstr->u.choice->GetSelection () + enump->get_min();
if (value != enump->get ()) enump->set (value); if (value != enump->get ()) enump->set (value);
break; break;
} }
case BXT_PARAM_STRING: { case BXT_PARAM_STRING: {
bx_param_string_c *stringp = (bx_param_string_c*) pstr->param; bx_param_string_c *stringp = (bx_param_string_c*) pstr->param;
char buf[1024]; char buf[1024];
@ -1185,7 +1183,7 @@ bool ParamDialog::CopyGuiToParam()
buf[i] = n; buf[i] = n;
p+=2; p+=2;
} else { } else {
wxMessageBox(wxT("Illegal raw byte format"), wxT("Error"), wxOK | wxICON_ERROR, this ); wxMessageBox(wxT("Illegal raw byte format"), wxT("Error"), wxOK | wxICON_ERROR, this);
return false; return false;
} }
} }
@ -1195,7 +1193,7 @@ bool ParamDialog::CopyGuiToParam()
buf[sizeof(buf)-1] = 0; buf[sizeof(buf)-1] = 0;
if (!stringp->equals (buf)) stringp->set (buf); if (!stringp->equals (buf)) stringp->set (buf);
break; break;
} }
case BXT_LIST: case BXT_LIST:
break; break;
default: default:
@ -1497,9 +1495,9 @@ void ParamDialog::OnEvent(wxCommandEvent& event)
} }
} }
void ParamDialog::ShowHelp () void ParamDialog::ShowHelp()
{ {
wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this ); wxMessageBox(MSG_NO_HELP, MSG_NO_HELP_CAPTION, wxOK | wxICON_ERROR, this);
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@ -1616,8 +1614,7 @@ CpuRegistersDialog::CpuRegistersDialog(
AddButton(ID_Close, BTNLABEL_CLOSE); AddButton(ID_Close, BTNLABEL_CLOSE);
} }
void void CpuRegistersDialog::AddFlag(bx_param_c *param)
CpuRegistersDialog::AddFlag(bx_param_c *param)
{ {
if (param == NULL) { if (param == NULL) {
wxLogDebug(wxT("AddFlag on undefined param")); wxLogDebug(wxT("AddFlag on undefined param"));
@ -1627,8 +1624,7 @@ CpuRegistersDialog::AddFlag(bx_param_c *param)
flagptr[nflags++] = param; flagptr[nflags++] = param;
} }
void void CpuRegistersDialog::Init()
CpuRegistersDialog::Init()
{ {
int i; int i;
for (i=0; i<CPU_REGS_MAX_FLAGS; i++) { for (i=0; i<CPU_REGS_MAX_FLAGS; i++) {
@ -1655,8 +1651,7 @@ CpuRegistersDialog::Init()
stateChanged(false); stateChanged(false);
} }
void void CpuRegistersDialog::stateChanged (bool simRunning)
CpuRegistersDialog::stateChanged (bool simRunning)
{ {
#if BX_DEBUGGER #if BX_DEBUGGER
contButton->Enable (!simRunning); contButton->Enable (!simRunning);
@ -1665,8 +1660,7 @@ CpuRegistersDialog::stateChanged (bool simRunning)
#endif #endif
} }
void void CpuRegistersDialog::CopyParamToGui ()
CpuRegistersDialog::CopyParamToGui ()
{ {
ParamDialog::CopyParamToGui (); ParamDialog::CopyParamToGui ();
#if BX_DEBUGGER #if BX_DEBUGGER
@ -1701,8 +1695,7 @@ CpuRegistersDialog::CopyParamToGui ()
// times, with each click it should call bx_dbg_stepN_command(1) in the // times, with each click it should call bx_dbg_stepN_command(1) in the
// simulator thread. When it returns, it goes back to // simulator thread. When it returns, it goes back to
// //
void void CpuRegistersDialog::OnEvent(wxCommandEvent& event)
CpuRegistersDialog::OnEvent(wxCommandEvent& event)
{ {
int id = event.GetId (); int id = event.GetId ();
switch (id) { switch (id) {
@ -1766,7 +1759,8 @@ LogOptionsDialog::LogOptionsDialog(
} }
} }
void LogOptionsDialog::SetAction(int evtype, int a) { void LogOptionsDialog::SetAction(int evtype, int a)
{
// find the choice whose client data matches "a". // find the choice whose client data matches "a".
int *ptr; int *ptr;
//wxLogDebug ("SetAction type=%d a=%d", evtype, a); //wxLogDebug ("SetAction type=%d a=%d", evtype, a);
@ -1784,7 +1778,8 @@ void LogOptionsDialog::SetAction(int evtype, int a) {
wxLogDebug(wxT("SetAction type=%d a=%d not found"), evtype, a); wxLogDebug(wxT("SetAction type=%d a=%d not found"), evtype, a);
} }
int LogOptionsDialog::GetAction(int evtype) { int LogOptionsDialog::GetAction(int evtype)
{
int sel = action[evtype]->GetSelection(); int sel = action[evtype]->GetSelection();
int *ptrToChoice = (int*)action[evtype]->GetClientData(sel); int *ptrToChoice = (int*)action[evtype]->GetClientData(sel);
wxASSERT(ptrToChoice != NULL); wxASSERT(ptrToChoice != NULL);
@ -1810,8 +1805,7 @@ void ChangeStaticText (wxSizer *sizer, wxStaticText *win, wxString newtext)
// CreateImage produces a disk image. It's in the utility function // CreateImage produces a disk image. It's in the utility function
// area because it's used by both floppy and hard disk image creation. // area because it's used by both floppy and hard disk image creation.
bool bool CreateImage (int harddisk, int sectors, const char *filename)
CreateImage (int harddisk, int sectors, const char *filename)
{ {
if (sectors<1) { if (sectors<1) {
wxMessageBox(wxT("The disk size is invalid."), wxT("Invalid Size"), wxOK | wxICON_ERROR); wxMessageBox(wxT("The disk size is invalid."), wxT("Invalid Size"), wxOK | wxICON_ERROR);
@ -1844,7 +1838,8 @@ CreateImage (int harddisk, int sectors, const char *filename)
return true; return true;
} }
void SetTextCtrl(wxTextCtrl *ctrl, const char *format, int val) { void SetTextCtrl(wxTextCtrl *ctrl, const char *format, int val)
{
wxString tmp; wxString tmp;
tmp.Printf(wxString(format, wxConvUTF8), val); tmp.Printf(wxString(format, wxConvUTF8), val);
ctrl->SetValue(tmp); ctrl->SetValue(tmp);
@ -1865,13 +1860,14 @@ int GetTextCtrlInt (wxTextCtrl *ctrl,
} }
if (valid) *valid = false; if (valid) *valid = false;
if (complain) { if (complain) {
wxMessageBox(complaint, wxT("Invalid"), wxOK | wxICON_ERROR ); wxMessageBox(complaint, wxT("Invalid"), wxOK | wxICON_ERROR);
ctrl->SetFocus(); ctrl->SetFocus();
} }
return -1; return -1;
} }
bool BrowseTextCtrl(wxTextCtrl *text, wxString prompt, long style) { bool BrowseTextCtrl(wxTextCtrl *text, wxString prompt, long style)
{
// try to configure the dialog to show hidden files // try to configure the dialog to show hidden files
wxConfigBase::Get() ->Write(wxT("/wxWidgets/wxFileDialog/ShowHidden"), true); wxConfigBase::Get() ->Write(wxT("/wxWidgets/wxFileDialog/ShowHidden"), true);
wxFileDialog *fdialog = new wxFileDialog (text->GetParent(), prompt, wxT(""), text->GetValue(), wxT("*.*"), style); wxFileDialog *fdialog = new wxFileDialog (text->GetParent(), prompt, wxT(""), text->GetValue(), wxT("*.*"), style);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// $Id: wxmain.cc,v 1.155 2008-02-05 22:57:41 sshwarts Exp $ // $Id: wxmain.cc,v 1.156 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// //
// wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs. // wxmain.cc implements the wxWidgets frame, toolbar, menus, and dialogs.
@ -33,10 +33,6 @@
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// includes
//////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing. // is used to know when we are exporting symbols and when we are importing.
@ -268,8 +264,7 @@ int MyApp::OnExit()
} }
// these are only called when the simthread is not running. // these are only called when the simthread is not running.
BxEvent * BxEvent *MyApp::DefaultCallback(void *thisptr, BxEvent *event)
MyApp::DefaultCallback(void *thisptr, BxEvent *event)
{ {
wxLogDebug(wxT("DefaultCallback: event type %d"), event->type); wxLogDebug(wxT("DefaultCallback: event type %d"), event->type);
event->retcode = -1; // default return code event->retcode = -1; // default return code
@ -284,7 +279,7 @@ MyApp::DefaultCallback(void *thisptr, BxEvent *event)
// gui closing down, do something simple and nongraphical. // gui closing down, do something simple and nongraphical.
fprintf(stderr, "%s\n", (const char *)text.mb_str(wxConvUTF8)); fprintf(stderr, "%s\n", (const char *)text.mb_str(wxConvUTF8));
} else { } else {
wxMessageBox(text, wxT("Error"), wxOK | wxICON_ERROR ); wxMessageBox(text, wxT("Error"), wxOK | wxICON_ERROR);
// maybe I can make OnLogMsg display something that looks appropriate. // maybe I can make OnLogMsg display something that looks appropriate.
// theFrame->OnLogMsg(event); // theFrame->OnLogMsg(event);
} }
@ -680,7 +675,7 @@ void MyFrame::OnEditBoot(wxCommandEvent& WXUNUSED(event))
} }
if (bootDevices == 0) { if (bootDevices == 0) {
wxMessageBox(wxT("All the possible boot devices are disabled right now!\nYou must enable the first floppy drive, a hard drive, or a CD-ROM."), wxMessageBox(wxT("All the possible boot devices are disabled right now!\nYou must enable the first floppy drive, a hard drive, or a CD-ROM."),
wxT("None enabled"), wxOK | wxICON_ERROR, this ); wxT("None enabled"), wxOK | wxICON_ERROR, this);
return; return;
} }
ParamDialog dlg(this, -1); ParamDialog dlg(this, -1);
@ -833,7 +828,7 @@ void MyFrame::OnShowKeyboard(wxCommandEvent& WXUNUSED(event))
if (list_size == 0) { if (list_size == 0) {
// if params not initialized yet, then give up // if params not initialized yet, then give up
wxMessageBox(wxT("Cannot show the debugger window until the simulation has begun."), wxMessageBox(wxT("Cannot show the debugger window until the simulation has begun."),
wxT("Sim not running"), wxOK | wxICON_ERROR, this ); wxT("Sim not running"), wxOK | wxICON_ERROR, this);
return; return;
} }
if (showKbd == NULL) { if (showKbd == NULL) {
@ -855,8 +850,7 @@ void MyFrame::OnDebugLog(wxCommandEvent& WXUNUSED(event))
showDebugLog->Show(TRUE); showDebugLog->Show(TRUE);
} }
void void MyFrame::DebugBreak()
MyFrame::DebugBreak()
{ {
if (debugCommand) { if (debugCommand) {
delete [] debugCommand; delete [] debugCommand;
@ -867,16 +861,14 @@ MyFrame::DebugBreak()
SIM->debug_break(); SIM->debug_break();
} }
void void MyFrame::DebugCommand(wxString cmd)
MyFrame::DebugCommand(wxString cmd)
{ {
char buf[1024]; char buf[1024];
safeWxStrcpy(buf, cmd, sizeof(buf)); safeWxStrcpy(buf, cmd, sizeof(buf));
DebugCommand(buf); DebugCommand(buf);
} }
void void MyFrame::DebugCommand(const char *cmd)
MyFrame::DebugCommand(const char *cmd)
{ {
wxLogDebug(wxT("debugger command: %s"), cmd); wxLogDebug(wxT("debugger command: %s"), cmd);
wxASSERT(showDebugLog != NULL); wxASSERT(showDebugLog != NULL);
@ -913,7 +905,7 @@ void MyFrame::OnQuit(wxCommandEvent& event)
bx_user_quit = 1; bx_user_quit = 1;
if (!sim_thread) { if (!sim_thread) {
// no simulation thread is running. Just close the window. // no simulation thread is running. Just close the window.
Close( TRUE ); Close(TRUE);
} else { } else {
SIM->set_notify_callback(&MyApp::DefaultCallback, this); SIM->set_notify_callback(&MyApp::DefaultCallback, this);
// ask the simulator to stop. When it stops it will close this frame. // ask the simulator to stop. When it stops it will close this frame.
@ -927,7 +919,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
wxString str(wxT("Bochs x86 Emulator version ")); wxString str(wxT("Bochs x86 Emulator version "));
str += wxString(VER_STRING, wxConvUTF8); str += wxString(VER_STRING, wxConvUTF8);
str += wxT(" (wxWidgets port)"); str += wxT(" (wxWidgets port)");
wxMessageBox(str, wxT("About Bochs"), wxOK | wxICON_INFORMATION, this ); wxMessageBox(str, wxT("About Bochs"), wxOK | wxICON_INFORMATION, this);
} }
// update the menu items, status bar, etc. // update the menu items, status bar, etc.
@ -1090,14 +1082,13 @@ void MyFrame::OnKillSim(wxCommandEvent& WXUNUSED(event))
} }
} }
void void MyFrame::OnSimThreadExit()
MyFrame::OnSimThreadExit() { {
wxCriticalSectionLocker lock(sim_thread_lock); wxCriticalSectionLocker lock(sim_thread_lock);
sim_thread = NULL; sim_thread = NULL;
} }
int int MyFrame::HandleAskParamString(bx_param_string_c *param)
MyFrame::HandleAskParamString(bx_param_string_c *param)
{ {
wxLogDebug(wxT("HandleAskParamString start")); wxLogDebug(wxT("HandleAskParamString start"));
bx_param_num_c *opt = param->get_options(); bx_param_num_c *opt = param->get_options();
@ -1159,8 +1150,7 @@ MyFrame::HandleAskParamString(bx_param_string_c *param)
// Returns 1 if the user chose a value and the param was modified. // Returns 1 if the user chose a value and the param was modified.
// Returns 0 if the user cancelled. // Returns 0 if the user cancelled.
// Returns -1 if the gui doesn't know how to ask for that param. // Returns -1 if the gui doesn't know how to ask for that param.
int int MyFrame::HandleAskParam(BxEvent *event)
MyFrame::HandleAskParam(BxEvent *event)
{ {
wxASSERT(event->type == BX_SYNC_EVT_ASK_PARAM); wxASSERT(event->type == BX_SYNC_EVT_ASK_PARAM);
@ -1183,7 +1173,7 @@ MyFrame::HandleAskParam(BxEvent *event)
wxString msg; wxString msg;
msg.Printf(wxT("ask param for parameter type %d is not implemented in wxWidgets"), msg.Printf(wxT("ask param for parameter type %d is not implemented in wxWidgets"),
param->get_type()); param->get_type());
wxMessageBox(msg, wxT("not implemented"), wxOK | wxICON_ERROR, this ); wxMessageBox(msg, wxT("not implemented"), wxOK | wxICON_ERROR, this);
return -1; return -1;
} }
} }
@ -1193,8 +1183,7 @@ MyFrame::HandleAskParam(BxEvent *event)
// This is called from the wxWidgets GUI thread, when a Sim2CI event // This is called from the wxWidgets GUI thread, when a Sim2CI event
// is found. (It got there via wxPostEvent in SiminterfaceCallback2, which is // is found. (It got there via wxPostEvent in SiminterfaceCallback2, which is
// executed in the simulator Thread.) // executed in the simulator Thread.)
void void MyFrame::OnSim2CIEvent(wxCommandEvent& event)
MyFrame::OnSim2CIEvent(wxCommandEvent& event)
{ {
IFDBG_EVENT(wxLogDebug(wxT("received a bochs event in the GUI thread"))); IFDBG_EVENT(wxLogDebug(wxT("received a bochs event in the GUI thread")));
BxEvent *be = (BxEvent *) event.GetEventObject(); BxEvent *be = (BxEvent *) event.GetEventObject();
@ -1260,7 +1249,8 @@ MyFrame::OnSim2CIEvent(wxCommandEvent& event)
delete be; delete be;
} }
void MyFrame::OnLogMsg(BxEvent *be) { void MyFrame::OnLogMsg(BxEvent *be)
{
wxLogDebug(wxT("log msg: level=%d, prefix='%s', msg='%s'"), wxLogDebug(wxT("log msg: level=%d, prefix='%s', msg='%s'"),
be->u.logmsg.level, be->u.logmsg.level,
be->u.logmsg.prefix, be->u.logmsg.prefix,
@ -1294,8 +1284,7 @@ void MyFrame::OnLogMsg(BxEvent *be) {
sim_thread->SendSyncResponse(be); // only for case #2 sim_thread->SendSyncResponse(be); // only for case #2
} }
bool bool MyFrame::editFloppyValidate(FloppyConfigDialog *dialog)
MyFrame::editFloppyValidate(FloppyConfigDialog *dialog)
{ {
// haven't done anything with this 'feature' // haven't done anything with this 'feature'
return true; return true;
@ -1364,7 +1353,7 @@ void MyFrame::editFirstCdrom()
bx_param_c *firstcd = SIM->get_first_cdrom(); bx_param_c *firstcd = SIM->get_first_cdrom();
if (!firstcd) { if (!firstcd) {
wxMessageBox(wxT("No CDROM drive is enabled. Use Edit:ATA to set one up."), wxMessageBox(wxT("No CDROM drive is enabled. Use Edit:ATA to set one up."),
wxT("No CDROM"), wxOK | wxICON_ERROR, this ); wxT("No CDROM"), wxOK | wxICON_ERROR, this);
return; return;
} }
ParamDialog dlg(this, -1); ParamDialog dlg(this, -1);
@ -1426,14 +1415,16 @@ void MyFrame::OnToolbarClick(wxCommandEvent& event)
} }
// warning: This can be called from the simulator thread!!! // warning: This can be called from the simulator thread!!!
bool MyFrame::WantRefresh() { bool MyFrame::WantRefresh()
{
bool anyShowing = false; bool anyShowing = false;
if (showCpu!=NULL && showCpu->IsShowing()) anyShowing = true; if (showCpu!=NULL && showCpu->IsShowing()) anyShowing = true;
if (showKbd!=NULL && showKbd->IsShowing()) anyShowing = true; if (showKbd!=NULL && showKbd->IsShowing()) anyShowing = true;
return anyShowing; return anyShowing;
} }
void MyFrame::RefreshDialogs() { void MyFrame::RefreshDialogs()
{
if (showCpu!=NULL && showCpu->IsShowing()) showCpu->CopyParamToGui(); if (showCpu!=NULL && showCpu->IsShowing()) showCpu->CopyParamToGui();
if (showKbd!=NULL && showKbd->IsShowing()) showKbd->CopyParamToGui(); if (showKbd!=NULL && showKbd->IsShowing()) showKbd->CopyParamToGui();
} }
@ -1442,8 +1433,7 @@ void MyFrame::RefreshDialogs() {
// Simulation Thread // Simulation Thread
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
void * void *SimThread::Entry(void)
SimThread::Entry(void)
{ {
// run all the rest of the Bochs simulator code. This function will // run all the rest of the Bochs simulator code. This function will
// run forever, unless a "kill_bochs_request" is issued. The shutdown // run forever, unless a "kill_bochs_request" is issued. The shutdown
@ -1486,8 +1476,7 @@ SimThread::Entry(void)
return NULL; return NULL;
} }
void void SimThread::OnExit()
SimThread::OnExit()
{ {
// notify the MyFrame that the bochs thread has died. I can't adjust // notify the MyFrame that the bochs thread has died. I can't adjust
// the sim_thread directly because it's private. // the sim_thread directly because it's private.
@ -1504,8 +1493,7 @@ SimThread::OnExit()
// function when it needs to contact the gui. It will always be // function when it needs to contact the gui. It will always be
// called with a pointer to the SimThread as the first argument, and // called with a pointer to the SimThread as the first argument, and
// it will be called from the simulator thread, not the GUI thread. // it will be called from the simulator thread, not the GUI thread.
BxEvent * BxEvent *SimThread::SiminterfaceCallback(void *thisptr, BxEvent *event)
SimThread::SiminterfaceCallback(void *thisptr, BxEvent *event)
{ {
SimThread *me = (SimThread *)thisptr; SimThread *me = (SimThread *)thisptr;
// call the normal non-static method now that we know the this pointer. // call the normal non-static method now that we know the this pointer.
@ -1517,8 +1505,7 @@ SimThread::SiminterfaceCallback(void *thisptr, BxEvent *event)
// thread safe. Most events are handled by packaging up the event // thread safe. Most events are handled by packaging up the event
// in a wxEvent of some kind, and posting it to the GUI thread for // in a wxEvent of some kind, and posting it to the GUI thread for
// processing. // processing.
BxEvent * BxEvent *SimThread::SiminterfaceCallback2(BxEvent *event)
SimThread::SiminterfaceCallback2(BxEvent *event)
{ {
// wxLogDebug(wxT("SiminterfaceCallback with event type=%d"), (int)event->type); // wxLogDebug(wxT("SiminterfaceCallback with event type=%d"), (int)event->type);
event->retcode = 0; // default return code event->retcode = 0; // default return code
@ -1581,8 +1568,7 @@ SimThread::SiminterfaceCallback2(BxEvent *event)
} }
} }
void void SimThread::ClearSyncResponse()
SimThread::ClearSyncResponse()
{ {
wxCriticalSectionLocker lock(sim2gui_mailbox_lock); wxCriticalSectionLocker lock(sim2gui_mailbox_lock);
if (sim2gui_mailbox != NULL) { if (sim2gui_mailbox != NULL) {
@ -1591,8 +1577,7 @@ SimThread::ClearSyncResponse()
sim2gui_mailbox = NULL; sim2gui_mailbox = NULL;
} }
void void SimThread::SendSyncResponse(BxEvent *event)
SimThread::SendSyncResponse(BxEvent *event)
{ {
wxCriticalSectionLocker lock(sim2gui_mailbox_lock); wxCriticalSectionLocker lock(sim2gui_mailbox_lock);
if (sim2gui_mailbox != NULL) { if (sim2gui_mailbox != NULL) {
@ -1601,8 +1586,7 @@ SimThread::SendSyncResponse(BxEvent *event)
sim2gui_mailbox = event; sim2gui_mailbox = event;
} }
BxEvent * BxEvent *SimThread::GetSyncResponse()
SimThread::GetSyncResponse()
{ {
wxCriticalSectionLocker lock(sim2gui_mailbox_lock); wxCriticalSectionLocker lock(sim2gui_mailbox_lock);
BxEvent *event = sim2gui_mailbox; BxEvent *event = sim2gui_mailbox;
@ -1613,8 +1597,7 @@ SimThread::GetSyncResponse()
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// utility // utility
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
void void safeWxStrcpy(char *dest, wxString src, int destlen)
safeWxStrcpy(char *dest, wxString src, int destlen)
{ {
wxString tmp(src); wxString tmp(src);
strncpy(dest, tmp.mb_str(wxConvUTF8), destlen); strncpy(dest, tmp.mb_str(wxConvUTF8), destlen);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: x.cc,v 1.111 2008-02-05 22:57:41 sshwarts Exp $ // $Id: x.cc,v 1.112 2008-02-15 22:05:40 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -291,11 +291,10 @@ Bit32u ascii_to_key_event[0x5f] = {
BX_KEY_BACKSLASH, BX_KEY_BACKSLASH,
BX_KEY_RIGHT_BRACKET, BX_KEY_RIGHT_BRACKET,
BX_KEY_GRAVE BX_KEY_GRAVE
}; };
extern Bit8u graphics_snapshot[32 * 1024]; extern Bit8u graphics_snapshot[32 * 1024];
static void create_internal_vga_font(void); static void create_internal_vga_font(void);
static void xkeypress(KeySym keysym, int press_release); static void xkeypress(KeySym keysym, int press_release);
// extern "C" void select_visual(void); // extern "C" void select_visual(void);
@ -349,11 +348,9 @@ test_alloc_colors (Colormap cmap, Bit32u n_tries) {
return (n_allocated == n_tries); return (n_allocated == n_tries);
} }
bx_x_gui_c::bx_x_gui_c () { bx_x_gui_c::bx_x_gui_c () {}
}
void void bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
unsigned headerbar_y) unsigned headerbar_y)
{ {
unsigned i; unsigned i;
@ -385,7 +382,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
progname = argv[0]; progname = argv[0];
/* connect to X server */ /* connect to X server */
if ( (bx_x_display=XOpenDisplay(display_name)) == NULL ) if ((bx_x_display=XOpenDisplay(display_name)) == NULL)
{ {
BX_PANIC(("%s: cannot connect to X server %s", BX_PANIC(("%s: cannot connect to X server %s",
progname, XDisplayName(display_name))); progname, XDisplayName(display_name)));
@ -399,7 +396,6 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
*/ */
x = y = 0; x = y = 0;
// Temporary values so we can create the window // Temporary values so we can create the window
font_width = 8; font_width = 8;
font_height = 16; font_height = 16;
@ -448,7 +444,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
if (XAllocColorCells(bx_x_display, default_cmap, False, if (XAllocColorCells(bx_x_display, default_cmap, False,
plane_masks_return, 0, col_vals, MAX_VGA_COLORS) == 0) { plane_masks_return, 0, col_vals, MAX_VGA_COLORS) == 0) {
BX_PANIC(("XAllocColorCells returns error. Maybe your screen does not support a private colormap?")); BX_PANIC(("XAllocColorCells returns error. Maybe your screen does not support a private colormap?"));
} }
win_attr.colormap = default_cmap; win_attr.colormap = default_cmap;
XChangeWindowAttributes(bx_x_display, win, CWColormap, &win_attr); XChangeWindowAttributes(bx_x_display, win, CWColormap, &win_attr);
@ -461,26 +457,25 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
color.red = 0xffff; color.red = 0xffff;
color.green = 0xffff; color.green = 0xffff;
color.blue = 0xffff; color.blue = 0xffff;
} }
else { else {
color.red = 0; color.red = 0;
color.green = 0; color.green = 0;
color.blue = 0; color.blue = 0;
}
XStoreColor(bx_x_display, default_cmap, &color);
} }
XStoreColor(bx_x_display, default_cmap, &color);
} }
}
// convenience variables which hold the black & white color indeces // convenience variables which hold the black & white color indeces
black_pixel = col_vals[0]; black_pixel = col_vals[0];
white_pixel = col_vals[15]; white_pixel = col_vals[15];
BX_INFO(("font %u wide x %u high, display depth = %d", BX_INFO(("font %u wide x %u high, display depth = %d",
(unsigned) font_width, (unsigned) font_height, default_depth)); (unsigned) font_width, (unsigned) font_height, default_depth));
//select_visual(); //select_visual();
/* Get available icon sizes from Window manager */ /* Get available icon sizes from Window manager */
#if BX_HAVE_XPM_H #if BX_HAVE_XPM_H
@ -551,8 +546,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
/* Select event types wanted */ /* Select event types wanted */
XSelectInput(bx_x_display, win, ExposureMask | KeyPressMask | KeyReleaseMask | XSelectInput(bx_x_display, win, ExposureMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | PointerMotionMask |
EnterWindowMask | LeaveWindowMask ); EnterWindowMask | LeaveWindowMask);
/* Create default Graphics Context */ /* Create default Graphics Context */
gc = XCreateGC(bx_x_display, win, valuemask, &values); gc = XCreateGC(bx_x_display, win, valuemask, &values);
@ -577,14 +571,13 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
while (1) { while (1) {
XNextEvent(bx_x_display, &report); XNextEvent(bx_x_display, &report);
if (report.type == MapNotify) break; if (report.type == MapNotify) break;
} }
BX_DEBUG(("MapNotify found.")); BX_DEBUG(("MapNotify found."));
// Create the VGA font // Create the VGA font
create_internal_vga_font(); create_internal_vga_font();
{
{
char *imagedata; char *imagedata;
ximage = XCreateImage(bx_x_display, default_visual, ximage = XCreateImage(bx_x_display, default_visual,
@ -594,7 +587,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
NULL, // malloc() space after NULL, // malloc() space after
x_tilesize, y_tilesize, // x & y size of image x_tilesize, y_tilesize, // x & y size of image
32, // # bits of padding 32, // # bits of padding
0 ); // bytes_per_line, let X11 calculate 0); // bytes_per_line, let X11 calculate
if (!ximage) if (!ximage)
BX_PANIC(("vga: couldn't XCreateImage()")); BX_PANIC(("vga: couldn't XCreateImage()"));
@ -602,14 +595,14 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
imWide = ximage->bytes_per_line; imWide = ximage->bytes_per_line;
imBPP = ximage->bits_per_pixel; imBPP = ximage->bits_per_pixel;
imagedata = (char *) malloc( (size_t) (ximage->bytes_per_line * y_tilesize) ); imagedata = (char *) malloc((size_t) (ximage->bytes_per_line * y_tilesize));
if (!imagedata) BX_PANIC(("imagedata: malloc returned error")); if (!imagedata) BX_PANIC(("imagedata: malloc returned error"));
ximage->data = imagedata; ximage->data = imagedata;
if (imBPP < imDepth) { if (imBPP < imDepth) {
BX_PANIC(("vga_x: bits_per_pixel < depth ?")); BX_PANIC(("vga_x: bits_per_pixel < depth ?"));
} }
for (i=0; i<12; i++) bx_statusitem_active[i] = 0; for (i=0; i<12; i++) bx_statusitem_active[i] = 0;
switch (imBPP) { switch (imBPP) {
@ -629,15 +622,14 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
strcpy(bx_status_info_text, "CTRL + 3rd button enables mouse"); strcpy(bx_status_info_text, "CTRL + 3rd button enables mouse");
x_init_done = true; x_init_done = true;
} }
curr_background = 0; curr_background = 0;
XSetBackground(bx_x_display, gc, col_vals[curr_background]); XSetBackground(bx_x_display, gc, col_vals[curr_background]);
curr_foreground = 1; curr_foreground = 1;
XSetForeground(bx_x_display, gc, col_vals[curr_foreground]); XSetForeground(bx_x_display, gc, col_vals[curr_foreground]);
//XGrabPointer( bx_x_display, win, True, 0, GrabModeAsync, GrabModeAsync, //XGrabPointer(bx_x_display, win, True, 0, GrabModeAsync, GrabModeAsync,
// win, None, CurrentTime ); // win, None, CurrentTime);
XFlush(bx_x_display); XFlush(bx_x_display);
@ -655,8 +647,7 @@ bx_x_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned ti
dialog_caps |= BX_GUI_DLG_USER; dialog_caps |= BX_GUI_DLG_USER;
} }
void void set_status_text(int element, const char *text, bx_bool active)
set_status_text(int element, const char *text, bx_bool active)
{ {
int xleft, xsize, sb_ypos; int xleft, xsize, sb_ypos;
@ -687,8 +678,7 @@ set_status_text(int element, const char *text, bx_bool active)
} }
} }
void void bx_x_gui_c::statusbar_setitem(int element, bx_bool active)
bx_x_gui_c::statusbar_setitem(int element, bx_bool active)
{ {
if (element < 0) { if (element < 0) {
for (unsigned i = 0; i < statusitem_count; i++) { for (unsigned i = 0; i < statusitem_count; i++) {
@ -703,8 +693,7 @@ bx_x_gui_c::statusbar_setitem(int element, bx_bool active)
// can change because of a gui event such as clicking on the mouse-enable // can change because of a gui event such as clicking on the mouse-enable
// bitmap or pressing the middle button, or from the configuration interface. // bitmap or pressing the middle button, or from the configuration interface.
// In all those cases, setting the parameter value will get you here. // In all those cases, setting the parameter value will get you here.
void void bx_x_gui_c::mouse_enabled_changed_specific (bx_bool val)
bx_x_gui_c::mouse_enabled_changed_specific (bx_bool val)
{ {
BX_DEBUG (("mouse_enabled=%d, x11 specific code", val?1:0)); BX_DEBUG (("mouse_enabled=%d, x11 specific code", val?1:0));
if (val) { if (val) {
@ -726,8 +715,7 @@ bx_x_gui_c::mouse_enabled_changed_specific (bx_bool val)
#endif #endif
} }
void void create_internal_vga_font(void)
create_internal_vga_font(void)
{ {
// Default values // Default values
font_width=8; font_width=8;
@ -741,8 +729,7 @@ create_internal_vga_font(void)
} }
} }
void void bx_x_gui_c::handle_events(void)
bx_x_gui_c::handle_events(void)
{ {
XEvent report; XEvent report;
XKeyEvent *key_event; XKeyEvent *key_event;
@ -754,14 +741,12 @@ bx_x_gui_c::handle_events(void)
bx_bool mouse_update; bx_bool mouse_update;
int y, height; int y, height;
XPointerMovedEvent *pointer_event; XPointerMovedEvent *pointer_event;
XEnterWindowEvent *enter_event; XEnterWindowEvent *enter_event;
XLeaveWindowEvent *leave_event; XLeaveWindowEvent *leave_event;
XButtonEvent *button_event; XButtonEvent *button_event;
XExposeEvent *expose_event; XExposeEvent *expose_event;
//current_x = -1; //current_x = -1;
//current_y = -1; //current_y = -1;
mouse_update = 0; mouse_update = 0;
@ -777,8 +762,8 @@ bx_x_gui_c::handle_events(void)
y = expose_event->y - BX_HEADER_BAR_Y; y = expose_event->y - BX_HEADER_BAR_Y;
height = expose_event->height; height = expose_event->height;
if (y < 0) { if (y < 0) {
height += y; height += y;
y = 0; y = 0;
} }
DEV_vga_redraw_area( DEV_vga_redraw_area(
@ -805,23 +790,23 @@ bx_x_gui_c::handle_events(void)
case ButtonPress: case ButtonPress:
button_event = (XButtonEvent *) &report; button_event = (XButtonEvent *) &report;
BX_DEBUG(("xxx: buttonpress")); BX_DEBUG(("xxx: buttonpress"));
if (button_event->y < BX_HEADER_BAR_Y) { if (button_event->y < BX_HEADER_BAR_Y) {
BX_DEBUG(("xxx: in headerbar")); BX_DEBUG(("xxx: in headerbar"));
if (mouse_update) { if (mouse_update) {
BX_DEBUG(("xxx: mouse_update=1")); BX_DEBUG(("xxx: mouse_update=1"));
send_keyboard_mouse_status(); send_keyboard_mouse_status();
mouse_update = 0; mouse_update = 0;
} }
prev_x = current_x = -1; prev_x = current_x = -1;
prev_y = current_y = -1; prev_y = current_y = -1;
headerbar_click(button_event->x, button_event->y); headerbar_click(button_event->x, button_event->y);
break; break;
} }
current_x = button_event->x; current_x = button_event->x;
current_y = button_event->y; current_y = button_event->y;
mouse_update = 1; mouse_update = 1;
BX_DEBUG(("xxx: x,y=(%d,%d)", current_x, current_y)); BX_DEBUG(("xxx: x,y=(%d,%d)", current_x, current_y));
switch (button_event->button) { switch (button_event->button) {
case Button1: case Button1:
mouse_button_state |= 0x01; mouse_button_state |= 0x01;
@ -829,7 +814,7 @@ bx_x_gui_c::handle_events(void)
mouse_update = 0; mouse_update = 0;
break; break;
case Button2: case Button2:
if (CTRL_pressed) { if (CTRL_pressed) {
toggle_mouse_enable(); toggle_mouse_enable();
} else { } else {
mouse_button_state |= 0x04; mouse_button_state |= 0x04;
@ -842,7 +827,7 @@ bx_x_gui_c::handle_events(void)
send_keyboard_mouse_status(); send_keyboard_mouse_status();
mouse_update = 0; mouse_update = 0;
break; break;
} }
break; break;
case ButtonRelease: case ButtonRelease:
@ -851,12 +836,12 @@ bx_x_gui_c::handle_events(void)
if (mouse_update) { if (mouse_update) {
send_keyboard_mouse_status(); send_keyboard_mouse_status();
mouse_update = 0; mouse_update = 0;
} }
prev_x = current_x = -1; prev_x = current_x = -1;
prev_y = current_y = -1; prev_y = current_y = -1;
// ignore, in headerbar area // ignore, in headerbar area
break; break;
} }
current_x = button_event->x; current_x = button_event->x;
current_y = button_event->y; current_y = button_event->y;
mouse_update = 1; mouse_update = 1;
@ -886,7 +871,7 @@ bx_x_gui_c::handle_events(void)
send_keyboard_mouse_status(); send_keyboard_mouse_status();
mouse_update = 0; mouse_update = 0;
break; break;
} }
break; break;
case KeyPress: case KeyPress:
@ -954,12 +939,10 @@ bx_x_gui_c::handle_events(void)
#endif #endif
} }
void send_keyboard_mouse_status(void)
void
send_keyboard_mouse_status(void)
{ {
BX_DEBUG(("XXX: prev=(%d,%d) curr=(%d,%d)", BX_DEBUG(("XXX: prev=(%d,%d) curr=(%d,%d)",
prev_x, prev_y, current_x, current_y)); prev_x, prev_y, current_x, current_y));
if (((prev_x!=-1) && (current_x!=-1) && (prev_y!=-1) && (current_y!=-1)) || if (((prev_x!=-1) && (current_x!=-1) && (prev_y!=-1) && (current_y!=-1)) ||
(current_z != 0)) { (current_z != 0)) {
@ -975,38 +958,34 @@ send_keyboard_mouse_status(void)
//if (warped) { //if (warped) {
// prev_x = current_x = -1; // prev_x = current_x = -1;
// prev_y = current_y = -1; // prev_y = current_y = -1;
// } //}
//else { //else {
prev_x = current_x; prev_x = current_x;
prev_y = current_y; prev_y = current_y;
// } //}
} }
else { else {
if ( (current_x!=-1) && (current_y!=-1)) { if ((current_x!=-1) && (current_y!=-1)) {
prev_x = current_x; prev_x = current_x;
prev_y = current_y; prev_y = current_y;
} }
else { else {
prev_x = current_x = -1; prev_x = current_x = -1;
prev_y = current_y = -1; prev_y = current_y = -1;
}
} }
}
} }
void void bx_x_gui_c::flush(void)
bx_x_gui_c::flush(void)
{ {
if (bx_x_display) if (bx_x_display)
XFlush(bx_x_display); XFlush(bx_x_display);
} }
void xkeypress(KeySym keysym, int press_release)
void
xkeypress(KeySym keysym, int press_release)
{ {
Bit32u key_event; Bit32u key_event;
if ((keysym == XK_Control_L) || (keysym == XK_Control_R)) { if ((keysym == XK_Control_L) || (keysym == XK_Control_R)) {
CTRL_pressed = !press_release; CTRL_pressed = !press_release;
} }
@ -1019,7 +998,7 @@ xkeypress(KeySym keysym, int press_release)
// are in consequtive order. // are in consequtive order.
if ((keysym >= XK_space) && (keysym <= XK_asciitilde)) { if ((keysym >= XK_space) && (keysym <= XK_asciitilde)) {
key_event = ascii_to_key_event[keysym - XK_space]; key_event = ascii_to_key_event[keysym - XK_space];
} }
else switch (keysym) { else switch (keysym) {
case XK_KP_1: case XK_KP_1:
#ifdef XK_KP_End #ifdef XK_KP_End
@ -1153,20 +1132,20 @@ xkeypress(KeySym keysym, int press_release)
case XK_Page_Down: key_event = BX_KEY_PAGE_DOWN; break; case XK_Page_Down: key_event = BX_KEY_PAGE_DOWN; break;
default: default:
BX_ERROR(( "xkeypress(): keysym %x unhandled!", (unsigned) keysym )); BX_ERROR(("xkeypress(): keysym %x unhandled!", (unsigned) keysym));
return; return;
break; break;
}
} }
}
else { else {
/* use mapping */ /* use mapping */
BXKeyEntry *entry = bx_keymap.findHostKey (keysym); BXKeyEntry *entry = bx_keymap.findHostKey (keysym);
if (!entry) { if (!entry) {
BX_ERROR(( "xkeypress(): keysym %x unhandled!", (unsigned) keysym )); BX_ERROR(("xkeypress(): keysym %x unhandled!", (unsigned) keysym));
return; return;
} }
key_event = entry->baseKey; key_event = entry->baseKey;
} }
if (press_release) if (press_release)
key_event |= BX_KEY_RELEASED; key_event |= BX_KEY_RELEASED;
@ -1174,13 +1153,11 @@ xkeypress(KeySym keysym, int press_release)
DEV_kbd_gen_scancode(key_event); DEV_kbd_gen_scancode(key_event);
} }
void bx_x_gui_c::clear_screen(void) void bx_x_gui_c::clear_screen(void)
{ {
XClearArea(bx_x_display, win, 0, bx_headerbar_y, dimension_x, dimension_y, 0); XClearArea(bx_x_display, win, 0, bx_headerbar_y, dimension_x, dimension_y, 0);
} }
void bx_x_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, void bx_x_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y, unsigned long cursor_x, unsigned long cursor_y,
bx_vga_tminfo_t tm_info) bx_vga_tminfo_t tm_info)
@ -1250,7 +1227,7 @@ void bx_x_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
} }
// first invalidate character at previous and new cursor location // first invalidate character at previous and new cursor location
if ( (prev_cursor_y < text_rows) && (prev_cursor_x < text_cols) ) { if ((prev_cursor_y < text_rows) && (prev_cursor_x < text_cols)) {
curs = prev_cursor_y * tm_info.line_offset + prev_cursor_x * 2; curs = prev_cursor_y * tm_info.line_offset + prev_cursor_x * 2;
old_text[curs] = ~new_text[curs]; old_text[curs] = ~new_text[curs];
} }
@ -1328,8 +1305,8 @@ void bx_x_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
font_col = 0; font_col = 0;
cfwidth = font_width; cfwidth = font_width;
} }
if ( forceUpdate || (old_text[0] != new_text[0]) if (forceUpdate || (old_text[0] != new_text[0])
|| (old_text[1] != new_text[1]) ) { || (old_text[1] != new_text[1])) {
cChar = new_text[0]; cChar = new_text[0];
new_foreground = new_text[1] & 0x0f; new_foreground = new_text[1] & 0x0f;
@ -1423,7 +1400,6 @@ int bx_x_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
return 1; return 1;
} }
void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0) void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
{ {
unsigned x, y, y_size; unsigned x, y, y_size;
@ -1451,11 +1427,11 @@ void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
if (ximage->byte_order == LSBFirst) { if (ximage->byte_order == LSBFirst) {
ximage->data[offset + 0] = b0; ximage->data[offset + 0] = b0;
ximage->data[offset + 1] = b1; ximage->data[offset + 1] = b1;
} }
else { // MSBFirst else { // MSBFirst
ximage->data[offset + 0] = b1; ximage->data[offset + 0] = b1;
ximage->data[offset + 1] = b0; ximage->data[offset + 1] = b0;
} }
break; break;
case 24: // 24 bits per pixel case 24: // 24 bits per pixel
offset = imWide*y + 3*x; offset = imWide*y + 3*x;
@ -1466,12 +1442,12 @@ void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
ximage->data[offset + 0] = b0; ximage->data[offset + 0] = b0;
ximage->data[offset + 1] = b1; ximage->data[offset + 1] = b1;
ximage->data[offset + 2] = b2; ximage->data[offset + 2] = b2;
} }
else { // MSBFirst else { // MSBFirst
ximage->data[offset + 0] = b2; ximage->data[offset + 0] = b2;
ximage->data[offset + 1] = b1; ximage->data[offset + 1] = b1;
ximage->data[offset + 2] = b0; ximage->data[offset + 2] = b0;
} }
break; break;
case 32: // 32 bits per pixel case 32: // 32 bits per pixel
offset = imWide*y + 4*x; offset = imWide*y + 4*x;
@ -1484,33 +1460,32 @@ void bx_x_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
ximage->data[offset + 1] = b1; ximage->data[offset + 1] = b1;
ximage->data[offset + 2] = b2; ximage->data[offset + 2] = b2;
ximage->data[offset + 3] = b3; ximage->data[offset + 3] = b3;
} }
else { // MSBFirst else { // MSBFirst
ximage->data[offset + 0] = b3; ximage->data[offset + 0] = b3;
ximage->data[offset + 1] = b2; ximage->data[offset + 1] = b2;
ximage->data[offset + 2] = b1; ximage->data[offset + 2] = b1;
ximage->data[offset + 3] = b0; ximage->data[offset + 3] = b0;
} }
break; break;
default: default:
BX_PANIC(("X_graphics_tile_update: bits_per_pixel %u not implemented", BX_PANIC(("X_graphics_tile_update: bits_per_pixel %u not implemented",
(unsigned) imBPP)); (unsigned) imBPP));
return; return;
}
} }
} }
}
break; break;
default: default:
BX_PANIC(("X_graphics_tile_update: bits_per_pixel %u handled by new graphics API", BX_PANIC(("X_graphics_tile_update: bits_per_pixel %u handled by new graphics API",
(unsigned) vga_bpp)); (unsigned) vga_bpp));
return; return;
} }
XPutImage(bx_x_display, win, gc, ximage, 0, 0, x0, y0+bx_headerbar_y, XPutImage(bx_x_display, win, gc, ximage, 0, 0, x0, y0+bx_headerbar_y,
x_tilesize, y_size); x_tilesize, y_size);
} }
bx_svga_tileinfo_t * bx_svga_tileinfo_t *bx_x_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
bx_x_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
{ {
if (!info) { if (!info) {
info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t)); info = (bx_svga_tileinfo_t *)malloc(sizeof(bx_svga_tileinfo_t));
@ -1586,8 +1561,7 @@ bx_x_gui_c::graphics_tile_info(bx_svga_tileinfo_t *info)
return info; return info;
} }
Bit8u * Bit8u *bx_x_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
bx_x_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
unsigned *w, unsigned *h) unsigned *w, unsigned *h)
{ {
if (x0+x_tilesize > dimension_x) { if (x0+x_tilesize > dimension_x) {
@ -1607,16 +1581,14 @@ bx_x_gui_c::graphics_tile_get(unsigned x0, unsigned y0,
return (Bit8u *)ximage->data + ximage->xoffset*ximage->bits_per_pixel/8; return (Bit8u *)ximage->data + ximage->xoffset*ximage->bits_per_pixel/8;
} }
void void bx_x_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
bx_x_gui_c::graphics_tile_update_in_place(unsigned x0, unsigned y0,
unsigned w, unsigned h) unsigned w, unsigned h)
{ {
XPutImage(bx_x_display, win, gc, ximage, 0, 0, XPutImage(bx_x_display, win, gc, ximage, 0, 0,
x0, y0+bx_headerbar_y, w, h); x0, y0+bx_headerbar_y, w, h);
} }
bx_bool bx_bool bx_x_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue)
bx_x_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue)
{ {
// returns: 0=no screen update needed (color map change has direct effect) // returns: 0=no screen update needed (color map change has direct effect)
// 1=screen updated needed (redraw using current colormap) // 1=screen updated needed (redraw using current colormap)
@ -1631,18 +1603,16 @@ bx_x_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigne
color.pixel = index; color.pixel = index;
XStoreColor(bx_x_display, default_cmap, &color); XStoreColor(bx_x_display, default_cmap, &color);
return(0); // no screen update needed return(0); // no screen update needed
} }
else { else {
XAllocColor(bx_x_display, DefaultColormap(bx_x_display, bx_x_screen_num), XAllocColor(bx_x_display, DefaultColormap(bx_x_display, bx_x_screen_num),
&color); &color);
col_vals[index] = color.pixel; col_vals[index] = color.pixel;
return(1); // screen update needed return(1); // screen update needed
} }
} }
void bx_x_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp)
void
bx_x_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp)
{ {
if ((bpp == 8) || (bpp == 15) || (bpp == 16) || (bpp == 24) || (bpp == 32)) { if ((bpp == 8) || (bpp == 15) || (bpp == 16) || (bpp == 24) || (bpp == 32)) {
vga_bpp = bpp; vga_bpp = bpp;
@ -1655,25 +1625,23 @@ bx_x_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned
text_cols = x / font_width; text_cols = x / font_width;
text_rows = y / font_height; text_rows = y / font_height;
} }
if ( (x != dimension_x) || (y != dimension_y) ) { if ((x != dimension_x) || (y != dimension_y)) {
XSizeHints hints; XSizeHints hints;
long supplied_return; long supplied_return;
if ( XGetWMNormalHints(bx_x_display, win, &hints, &supplied_return) && if (XGetWMNormalHints(bx_x_display, win, &hints, &supplied_return) &&
supplied_return & PMaxSize ) { supplied_return & PMaxSize) {
hints.max_width = hints.min_width = x; hints.max_width = hints.min_width = x;
hints.max_height = hints.min_height = y+bx_headerbar_y+bx_statusbar_y; hints.max_height = hints.min_height = y+bx_headerbar_y+bx_statusbar_y;
XSetWMNormalHints(bx_x_display, win, &hints); XSetWMNormalHints(bx_x_display, win, &hints);
} }
XResizeWindow(bx_x_display, win, x, y+bx_headerbar_y+bx_statusbar_y); XResizeWindow(bx_x_display, win, x, y+bx_headerbar_y+bx_statusbar_y);
dimension_x = x; dimension_x = x;
dimension_y = y; dimension_y = y;
} }
} }
void bx_x_gui_c::show_headerbar(void)
void
bx_x_gui_c::show_headerbar(void)
{ {
unsigned xorigin; unsigned xorigin;
int xleft, xright, sb_ypos; int xleft, xright, sb_ypos;
@ -1689,16 +1657,16 @@ bx_x_gui_c::show_headerbar(void)
if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT) { if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT) {
xorigin = bx_headerbar_entry[i].xorigin; xorigin = bx_headerbar_entry[i].xorigin;
xleft += bx_headerbar_entry[i].xdim; xleft += bx_headerbar_entry[i].xdim;
} }
else { else {
xorigin = dimension_x - bx_headerbar_entry[i].xorigin; xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
xright = xorigin; xright = xorigin;
} }
if (xright < xleft) break; if (xright < xleft) break;
XCopyPlane(bx_x_display, bx_headerbar_entry[i].bitmap, win, gc_headerbar, XCopyPlane(bx_x_display, bx_headerbar_entry[i].bitmap, win, gc_headerbar,
0,0, bx_headerbar_entry[i].xdim, bx_headerbar_entry[i].ydim, 0,0, bx_headerbar_entry[i].xdim, bx_headerbar_entry[i].ydim,
xorigin, 0, 1); xorigin, 0, 1);
} }
for (unsigned i=0; i<12; i++) { for (unsigned i=0; i<12; i++) {
xleft = bx_statusitem_pos[i]; xleft = bx_statusitem_pos[i];
if (i > 0) { if (i > 0) {
@ -1713,13 +1681,11 @@ bx_x_gui_c::show_headerbar(void)
} }
} }
unsigned bx_x_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
unsigned
bx_x_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
{ {
if (bx_bitmap_entries >= BX_MAX_PIXMAPS) { if (bx_bitmap_entries >= BX_MAX_PIXMAPS) {
BX_PANIC(("x: too many pixmaps, increase BX_MAX_PIXMAPS")); BX_PANIC(("x: too many pixmaps, increase BX_MAX_PIXMAPS"));
} }
bx_bitmaps[bx_bitmap_entries].bmap = bx_bitmaps[bx_bitmap_entries].bmap =
XCreateBitmapFromData(bx_x_display, win, (const char *) bmap, xdim, ydim); XCreateBitmapFromData(bx_x_display, win, (const char *) bmap, xdim, ydim);
@ -1727,18 +1693,16 @@ bx_x_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydi
bx_bitmaps[bx_bitmap_entries].ydim = ydim; bx_bitmaps[bx_bitmap_entries].ydim = ydim;
if (!bx_bitmaps[bx_bitmap_entries].bmap) { if (!bx_bitmaps[bx_bitmap_entries].bmap) {
BX_PANIC(("x: could not create bitmap")); BX_PANIC(("x: could not create bitmap"));
} }
bx_bitmap_entries++; bx_bitmap_entries++;
return(bx_bitmap_entries-1); // return index as handle return(bx_bitmap_entries-1); // return index as handle
} }
unsigned bx_x_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
unsigned
bx_x_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
{ {
unsigned hb_index; unsigned hb_index;
if ( (bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES ) if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES)
BX_PANIC(("x: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES")); BX_PANIC(("x: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES"));
bx_headerbar_entries++; bx_headerbar_entries++;
@ -1753,17 +1717,16 @@ bx_x_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(voi
bx_headerbar_entry[hb_index].xorigin = bx_bitmap_left_xorigin; bx_headerbar_entry[hb_index].xorigin = bx_bitmap_left_xorigin;
bx_headerbar_entry[hb_index].yorigin = 0; bx_headerbar_entry[hb_index].yorigin = 0;
bx_bitmap_left_xorigin += bx_bitmaps[bmap_id].xdim; bx_bitmap_left_xorigin += bx_bitmaps[bmap_id].xdim;
} }
else { // BX_GRAVITY_RIGHT else { // BX_GRAVITY_RIGHT
bx_bitmap_right_xorigin += bx_bitmaps[bmap_id].xdim; bx_bitmap_right_xorigin += bx_bitmaps[bmap_id].xdim;
bx_headerbar_entry[hb_index].xorigin = bx_bitmap_right_xorigin; bx_headerbar_entry[hb_index].xorigin = bx_bitmap_right_xorigin;
bx_headerbar_entry[hb_index].yorigin = 0; bx_headerbar_entry[hb_index].yorigin = 0;
} }
return(hb_index); return(hb_index);
} }
void void bx_x_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
bx_x_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
{ {
unsigned xorigin; unsigned xorigin;
@ -1778,9 +1741,7 @@ bx_x_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
xorigin, 0, 1); xorigin, 0, 1);
} }
void headerbar_click(int x, int y)
void
headerbar_click(int x, int y)
{ {
int xorigin; int xorigin;
@ -1791,87 +1752,87 @@ headerbar_click(int x, int y)
xorigin = bx_headerbar_entry[i].xorigin; xorigin = bx_headerbar_entry[i].xorigin;
else else
xorigin = dimension_x - bx_headerbar_entry[i].xorigin; xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
if ( (x>=xorigin) && (x<(xorigin+int(bx_headerbar_entry[i].xdim))) ) { if ((x>=xorigin) && (x<(xorigin+int(bx_headerbar_entry[i].xdim)))) {
bx_headerbar_entry[i].f(); bx_headerbar_entry[i].f();
return; return;
}
} }
}
} }
void void bx_x_gui_c::exit(void)
bx_x_gui_c::exit(void)
{ {
if (!x_init_done) return; if (!x_init_done) return;
// Delete the font bitmaps // Delete the font bitmaps
for (int i=0; i<256; i++) { for (int i=0; i<256; i++) {
//if (vgafont[i] != NULL) //if (vgafont[i] != NULL)
XFreePixmap(bx_x_display,vgafont[i]); XFreePixmap(bx_x_display,vgafont[i]);
} }
if (bx_x_display) if (bx_x_display)
XCloseDisplay (bx_x_display); XCloseDisplay (bx_x_display);
BX_INFO(("Exit."));
BX_INFO(("Exit"));
} }
static void warp_cursor (int dx, int dy) static void warp_cursor (int dx, int dy)
{ {
if (SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get() && if (SIM->get_param_bool(BXPN_MOUSE_ENABLED)->get() &&
(warp_dx || warp_dy || dx || dy) (warp_dx || warp_dy || dx || dy)
) { ) {
warp_dx = dx; warp_dx = dx;
warp_dy = dy; warp_dy = dy;
XWarpPointer(bx_x_display, None, None, 0, 0, 0, 0, dx, dy); XWarpPointer(bx_x_display, None, None, 0, 0, 0, 0, dx, dy);
} }
} }
static void disable_cursor () static void disable_cursor()
{ {
static Cursor cursor; static Cursor cursor;
static unsigned cursor_created = 0; static unsigned cursor_created = 0;
static int shape_width = 16, static int shape_width = 16,
shape_height = 16, shape_height = 16,
mask_width = 16, mask_width = 16,
mask_height = 16; mask_height = 16;
static Bit32u shape_bits[(16*16)/32] = { static Bit32u shape_bits[(16*16)/32] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
static Bit32u mask_bits[(16*16)/32] = { static Bit32u mask_bits[(16*16)/32] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
}; };
if (!cursor_created) { if (!cursor_created) {
Pixmap shape, mask; Pixmap shape, mask;
XColor white, black; XColor white, black;
shape = XCreatePixmapFromBitmapData(bx_x_display, shape = XCreatePixmapFromBitmapData(bx_x_display,
RootWindow(bx_x_display,bx_x_screen_num), RootWindow(bx_x_display,bx_x_screen_num),
(char*)shape_bits, (char*)shape_bits,
shape_width, shape_width,
shape_height, shape_height,
1, 0, 1); 1, 0, 1);
mask = XCreatePixmapFromBitmapData(bx_x_display, mask = XCreatePixmapFromBitmapData(bx_x_display,
RootWindow(bx_x_display,bx_x_screen_num), RootWindow(bx_x_display,bx_x_screen_num),
(char*)mask_bits, (char*)mask_bits,
mask_width, mask_width,
mask_height, mask_height,
1, 0, 1); 1, 0, 1);
XParseColor(bx_x_display, default_cmap, "black", &black); XParseColor(bx_x_display, default_cmap, "black", &black);
XParseColor(bx_x_display, default_cmap, "white", &white); XParseColor(bx_x_display, default_cmap, "white", &white);
cursor = XCreatePixmapCursor(bx_x_display, shape, mask, cursor = XCreatePixmapCursor(bx_x_display, shape, mask,
&white, &black, 1, 1); &white, &black, 1, 1);
cursor_created = 1; cursor_created = 1;
} }
XDefineCursor(bx_x_display, win, cursor); XDefineCursor(bx_x_display, win, cursor);
} }
static void enable_cursor () static void enable_cursor()
{ {
XUndefineCursor(bx_x_display, win); XUndefineCursor(bx_x_display, win);
} }
/* convertStringToXKeysym is a keymap callback /* convertStringToXKeysym is a keymap callback
@ -1882,14 +1843,14 @@ static void enable_cursor ()
*/ */
static Bit32u convertStringToXKeysym (const char *string) static Bit32u convertStringToXKeysym (const char *string)
{ {
if (strncmp ("XK_", string, 3) != 0) if (strncmp ("XK_", string, 3) != 0)
return BX_KEYMAP_UNKNOWN; return BX_KEYMAP_UNKNOWN;
KeySym keysym=XStringToKeysym(string+3); KeySym keysym=XStringToKeysym(string+3);
// failure, return unknown // failure, return unknown
if(keysym==NoSymbol) return BX_KEYMAP_UNKNOWN; if(keysym==NoSymbol) return BX_KEYMAP_UNKNOWN;
return((Bit32u)keysym); return((Bit32u)keysym);
} }
#if BX_USE_IDLE_HACK #if BX_USE_IDLE_HACK
@ -1911,38 +1872,38 @@ static Bit32u convertStringToXKeysym (const char *string)
* (adopted from mozilla/gfx/src/xprint/xprintutil_printtofile.c#XNextEventTimeout()) * (adopted from mozilla/gfx/src/xprint/xprintutil_printtofile.c#XNextEventTimeout())
*/ */
static static
Bool XPeekEventTimeout( Display *display, XEvent *event_return, struct timeval *timeout ) Bool XPeekEventTimeout(Display *display, XEvent *event_return, struct timeval *timeout)
{ {
int res; int res;
fd_set readfds; fd_set readfds;
int display_fd = XConnectionNumber(display); int display_fd = XConnectionNumber(display);
/* small shortcut... */ /* small shortcut... */
if( timeout == NULL ) if(timeout == NULL)
{ {
XPeekEvent(display, event_return); XPeekEvent(display, event_return);
return(True); return(True);
} }
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(display_fd, &readfds); FD_SET(display_fd, &readfds);
/* Note/bug: In the case of internal X events (like used to trigger callbacks /* Note/bug: In the case of internal X events (like used to trigger callbacks
* registered by XpGetDocumentData()&co.) select() will return with "new info" * registered by XpGetDocumentData()&co.) select() will return with "new info"
* - but XNextEvent() below processes these _internal_ events silently - and * - but XNextEvent() below processes these _internal_ events silently - and
* will block if there are no other non-internal events. * will block if there are no other non-internal events.
* The workaround here is to check with XEventsQueued() if there are non-internal * The workaround here is to check with XEventsQueued() if there are non-internal
* events queued - if not select() will be called again - unfortunately we use * events queued - if not select() will be called again - unfortunately we use
* the old timeout here instead of the "remaining" time... (this only would hurt * the old timeout here instead of the "remaining" time... (this only would hurt
* if the timeout would be really long - but for current use with values below * if the timeout would be really long - but for current use with values below
* 1/2 secs it does not hurt... =:-) * 1/2 secs it does not hurt... =:-)
*/ */
while( XEventsQueued(display, QueuedAfterFlush) == 0 ) while(XEventsQueued(display, QueuedAfterFlush) == 0)
{
res = select(display_fd+1, &readfds, NULL, NULL, timeout);
switch(res)
{ {
res = select(display_fd+1, &readfds, NULL, NULL, timeout);
switch(res)
{
case -1: /* select() error - should not happen */ case -1: /* select() error - should not happen */
if (errno == EINTR) if (errno == EINTR)
break; // caused e.g. by alarm(3) break; // caused e.g. by alarm(3)
@ -1951,14 +1912,15 @@ Bool XPeekEventTimeout( Display *display, XEvent *event_return, struct timeval *
case 0: /* timeout */ case 0: /* timeout */
return(False); return(False);
}
} }
}
XPeekEvent(display, event_return); XPeekEvent(display, event_return);
return(True); return(True);
} }
void bx_x_gui_c::sim_is_idle () { void bx_x_gui_c::sim_is_idle()
{
XEvent dummy; XEvent dummy;
struct timeval timeout; struct timeval timeout;
timeout.tv_sec = 0; timeout.tv_sec = 0;
@ -1969,12 +1931,12 @@ void bx_x_gui_c::sim_is_idle () {
void bx_x_gui_c::beep_on(float frequency) void bx_x_gui_c::beep_on(float frequency)
{ {
BX_INFO(( "X11 Beep ON (frequency=%.2f)",frequency)); BX_INFO(("X11 Beep ON (frequency=%.2f)",frequency));
} }
void bx_x_gui_c::beep_off() void bx_x_gui_c::beep_off()
{ {
BX_INFO(( "X11 Beep OFF")); BX_INFO(("X11 Beep OFF"));
} }
void bx_x_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp) void bx_x_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
@ -2301,8 +2263,7 @@ int x11_string_dialog(bx_param_string_c *param)
return control; return control;
} }
BxEvent * BxEvent *x11_notify_callback (void *unused, BxEvent *event)
x11_notify_callback (void *unused, BxEvent *event)
{ {
int opts; int opts;
bx_param_c *param; bx_param_c *param;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: biosdev.cc,v 1.12 2008-01-26 22:24:00 sshwarts Exp $ // $Id: biosdev.cc,v 1.13 2008-02-15 22:05:41 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -154,7 +154,7 @@ void bx_biosdev_c::write(Bit32u address, Bit32u value, unsigned io_len)
BX_BIOS_THIS s.bios_message[BX_BIOS_THIS s.bios_message_i] = BX_BIOS_THIS s.bios_message[BX_BIOS_THIS s.bios_message_i] =
(Bit8u) value; (Bit8u) value;
BX_BIOS_THIS s.bios_message_i ++; BX_BIOS_THIS s.bios_message_i ++;
if ( BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE ) { if (BX_BIOS_THIS s.bios_message_i >= BX_BIOS_MESSAGE_SIZE) {
BX_BIOS_THIS s.bios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; BX_BIOS_THIS s.bios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0;
BX_BIOS_THIS s.bios_message_i = 0; BX_BIOS_THIS s.bios_message_i = 0;
if (address==0x403) if (address==0x403)
@ -201,7 +201,7 @@ void bx_biosdev_c::write(Bit32u address, Bit32u value, unsigned io_len)
BX_BIOS_THIS s.vgabios_message[BX_BIOS_THIS s.vgabios_message_i] = BX_BIOS_THIS s.vgabios_message[BX_BIOS_THIS s.vgabios_message_i] =
(Bit8u) value; (Bit8u) value;
BX_BIOS_THIS s.vgabios_message_i ++; BX_BIOS_THIS s.vgabios_message_i ++;
if ( BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE ) { if (BX_BIOS_THIS s.vgabios_message_i >= BX_BIOS_MESSAGE_SIZE) {
BX_BIOS_THIS s.vgabios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0; BX_BIOS_THIS s.vgabios_message[ BX_BIOS_MESSAGE_SIZE - 1] = 0;
BX_BIOS_THIS s.vgabios_message_i = 0; BX_BIOS_THIS s.vgabios_message_i = 0;
if (address==0x503) if (address==0x503)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: busmouse.cc,v 1.8 2008-01-26 22:24:00 sshwarts Exp $ // $Id: busmouse.cc,v 1.9 2008-02-15 22:05:41 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2004 MandrakeSoft S.A. // Copyright (C) 2004 MandrakeSoft S.A.
@ -70,7 +70,7 @@ bx_busm_c::~bx_busm_c()
void bx_busm_c::init(void) void bx_busm_c::init(void)
{ {
BX_DEBUG(("Init $Id: busmouse.cc,v 1.8 2008-01-26 22:24:00 sshwarts Exp $")); BX_DEBUG(("Init $Id: busmouse.cc,v 1.9 2008-02-15 22:05:41 sshwarts Exp $"));
DEV_register_irq(BUS_MOUSE_IRQ, "Bus Mouse"); DEV_register_irq(BUS_MOUSE_IRQ, "Bus Mouse");
@ -275,9 +275,9 @@ void bx_busm_c::write(Bit32u address, Bit32u value, unsigned io_len)
void bx_busm_c::bus_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state) void bx_busm_c::bus_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state)
{ {
// scale down the motion // scale down the motion
if ( (delta_x < -1) || (delta_x > 1) ) if ((delta_x < -1) || (delta_x > 1))
delta_x /= 2; delta_x /= 2;
if ( (delta_y < -1) || (delta_y > 1) ) if ((delta_y < -1) || (delta_y > 1))
delta_y /= 2; delta_y /= 2;
if(delta_x>127) delta_x=127; if(delta_x>127) delta_x=127;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cdrom.cc,v 1.90 2008-01-26 22:24:00 sshwarts Exp $ // $Id: cdrom.cc,v 1.91 2008-02-15 22:05:41 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,7 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// These are the low-level CDROM functions which are called // These are the low-level CDROM functions which are called
// from 'harddrv.cc'. They effect the OS specific functionality // from 'harddrv.cc'. They effect the OS specific functionality
@ -111,7 +111,7 @@ extern "C" {
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#if defined (__GNUC__) && ( __GNUC__ >= 4 ) #if defined (__GNUC__) && (__GNUC__ >= 4)
#include <sys/disk.h> #include <sys/disk.h>
#else #else
#include <dev/disk.h> #include <dev/disk.h>
@ -136,37 +136,37 @@ extern "C" {
// however there seems to be some dissagreement in // however there seems to be some dissagreement in
// the definition of CDTOC.length // the definition of CDTOC.length
struct _CDMSF { struct _CDMSF {
u_char minute; u_char minute;
u_char second; u_char second;
u_char frame; u_char frame;
}; };
#define MSF_TO_LBA(msf) \ #define MSF_TO_LBA(msf) \
(((((msf).minute * 60UL) + (msf).second) * 75UL) + (msf).frame - 150) (((((msf).minute * 60UL) + (msf).second) * 75UL) + (msf).frame - 150)
struct _CDTOC_Desc { struct _CDTOC_Desc {
u_char session; u_char session;
u_char ctrl_adr; /* typed to be machine and compiler independent */ u_char ctrl_adr; /* typed to be machine and compiler independent */
u_char tno; u_char tno;
u_char point; u_char point;
struct _CDMSF address; struct _CDMSF address;
u_char zero; u_char zero;
struct _CDMSF p; struct _CDMSF p;
}; };
struct _CDTOC { struct _CDTOC {
u_short length; /* in native cpu endian */ u_short length; /* in native cpu endian */
u_char first_session; u_char first_session;
u_char last_session; u_char last_session;
struct _CDTOC_Desc trackdesc[1]; struct _CDTOC_Desc trackdesc[1];
}; };
static kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator, mach_port_t *masterPort ); static kern_return_t FindEjectableCDMedia(io_iterator_t *mediaIterator, mach_port_t *masterPort);
static kern_return_t GetDeviceFilePath( io_iterator_t mediaIterator, char *deviceFilePath, CFIndex maxPathSize ); static kern_return_t GetDeviceFilePath(io_iterator_t mediaIterator, char *deviceFilePath, CFIndex maxPathSize);
//int OpenDrive( const char *deviceFilePath ); //int OpenDrive(const char *deviceFilePath);
static struct _CDTOC * ReadTOC( const char * devpath ); static struct _CDTOC *ReadTOC(const char *devpath);
static char CDDevicePath[ MAXPATHLEN ]; static char CDDevicePath[MAXPATHLEN];
#define BX_CD_FRAMESIZE 2048 #define BX_CD_FRAMESIZE 2048
#define CD_FRAMESIZE 2048 #define CD_FRAMESIZE 2048
@ -250,185 +250,176 @@ typedef struct _CDROM_TOC_SESSION_DATA {
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__ #ifdef __APPLE__
static kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator, static kern_return_t FindEjectableCDMedia(io_iterator_t *mediaIterator,
mach_port_t *masterPort ) mach_port_t *masterPort)
{ {
kern_return_t kernResult; kern_return_t kernResult;
CFMutableDictionaryRef classesToMatch; CFMutableDictionaryRef classesToMatch;
kernResult = IOMasterPort( bootstrap_port, masterPort ); kernResult = IOMasterPort(bootstrap_port, masterPort);
if ( kernResult != KERN_SUCCESS ) if (kernResult != KERN_SUCCESS)
{ {
fprintf ( stderr, "IOMasterPort returned %d\n", kernResult ); fprintf (stderr, "IOMasterPort returned %d\n", kernResult);
return kernResult; return kernResult;
} }
// CD media are instances of class kIOCDMediaClass. // CD media are instances of class kIOCDMediaClass.
classesToMatch = IOServiceMatching( kIOCDMediaClass ); classesToMatch = IOServiceMatching(kIOCDMediaClass);
if ( classesToMatch == NULL ) if (classesToMatch == NULL)
fprintf ( stderr, "IOServiceMatching returned a NULL dictionary.\n" ); fprintf (stderr, "IOServiceMatching returned a NULL dictionary.\n");
else else
{ {
// Each IOMedia object has a property with key kIOMediaEjectableKey // Each IOMedia object has a property with key kIOMediaEjectableKey
// which is true if the media is indeed ejectable. So add property // which is true if the media is indeed ejectable. So add property
// to CFDictionary for matching. // to CFDictionary for matching.
CFDictionarySetValue( classesToMatch, CFDictionarySetValue(classesToMatch,
CFSTR( kIOMediaEjectableKey ), kCFBooleanTrue ); CFSTR(kIOMediaEjectableKey), kCFBooleanTrue);
} }
kernResult = IOServiceGetMatchingServices( *masterPort, kernResult = IOServiceGetMatchingServices(*masterPort,
classesToMatch, mediaIterator ); classesToMatch, mediaIterator);
if ( (kernResult != KERN_SUCCESS) || (*mediaIterator == NULL) ) if ((kernResult != KERN_SUCCESS) || (*mediaIterator == NULL))
fprintf( stderr, "No ejectable CD media found.\n kernResult = %d\n", kernResult ); fprintf(stderr, "No ejectable CD media found.\n kernResult = %d\n", kernResult);
return kernResult; return kernResult;
} }
static kern_return_t GetDeviceFilePath(io_iterator_t mediaIterator,
static kern_return_t GetDeviceFilePath( io_iterator_t mediaIterator, char *deviceFilePath, CFIndex maxPathSize)
char *deviceFilePath, CFIndex maxPathSize )
{ {
io_object_t nextMedia; io_object_t nextMedia;
kern_return_t kernResult = KERN_FAILURE; kern_return_t kernResult = KERN_FAILURE;
nextMedia = IOIteratorNext( mediaIterator ); nextMedia = IOIteratorNext(mediaIterator);
if ( nextMedia == NULL ) if (nextMedia == NULL)
{ {
*deviceFilePath = '\0'; *deviceFilePath = '\0';
} }
else else
{ {
CFTypeRef deviceFilePathAsCFString; CFTypeRef deviceFilePathAsCFString;
deviceFilePathAsCFString = IORegistryEntryCreateCFProperty( deviceFilePathAsCFString = IORegistryEntryCreateCFProperty(nextMedia, CFSTR(kIOBSDNameKey),
nextMedia, CFSTR( kIOBSDNameKey ), kCFAllocatorDefault, 0);
kCFAllocatorDefault, 0 );
*deviceFilePath = '\0'; *deviceFilePath = '\0';
if ( deviceFilePathAsCFString ) if (deviceFilePathAsCFString)
{ {
size_t devPathLength = strlen( _PATH_DEV ); size_t devPathLength = strlen(_PATH_DEV);
strcpy( deviceFilePath, _PATH_DEV ); strcpy(deviceFilePath, _PATH_DEV);
if ( CFStringGetCString( (const __CFString *) deviceFilePathAsCFString, if (CFStringGetCString((const __CFString *) deviceFilePathAsCFString,
deviceFilePath + devPathLength, deviceFilePath + devPathLength,
maxPathSize - devPathLength, maxPathSize - devPathLength,
kCFStringEncodingASCII ) ) kCFStringEncodingASCII))
{ {
// fprintf( stderr, "BSD path: %s\n", deviceFilePath ); // fprintf(stderr, "BSD path: %s\n", deviceFilePath);
kernResult = KERN_SUCCESS; kernResult = KERN_SUCCESS;
} }
CFRelease( deviceFilePathAsCFString ); CFRelease(deviceFilePathAsCFString);
} }
} }
IOObjectRelease( nextMedia );
IOObjectRelease(nextMedia);
return kernResult; return kernResult;
} }
static int OpenDrive(const char *deviceFilePath)
static int OpenDrive( const char *deviceFilePath )
{ {
int fileDescriptor = open(deviceFilePath, O_RDONLY);
int fileDescriptor; if (fileDescriptor == -1)
fprintf(stderr, "Error %d opening device %s.\n", errno, deviceFilePath);
fileDescriptor = open( deviceFilePath, O_RDONLY );
if ( fileDescriptor == -1 )
fprintf( stderr, "Error %d opening device %s.\n", errno, deviceFilePath );
return fileDescriptor; return fileDescriptor;
} }
static struct _CDTOC * ReadTOC( const char * devpath ) { static struct _CDTOC * ReadTOC(const char *devpath)
{
struct _CDTOC * toc_p = NULL; struct _CDTOC * toc_p = NULL;
io_iterator_t iterator = 0; io_iterator_t iterator = 0;
io_registry_entry_t service = 0; io_registry_entry_t service = 0;
CFDictionaryRef properties = 0; CFDictionaryRef properties = 0;
CFDataRef data = 0; CFDataRef data = 0;
mach_port_t port = 0; mach_port_t port = 0;
char * devname; char *devname;
if (( devname = strrchr( devpath, '/' )) != NULL ) { if ((devname = strrchr(devpath, '/')) != NULL) {
++devname; ++devname;
} }
else { else {
devname = (char *) devpath; devname = (char *) devpath;
} }
if ( IOMasterPort(bootstrap_port, &port ) != KERN_SUCCESS ) { if (IOMasterPort(bootstrap_port, &port) != KERN_SUCCESS) {
fprintf( stderr, "IOMasterPort failed\n" ); fprintf(stderr, "IOMasterPort failed\n");
goto Exit; goto Exit;
} }
if ( IOServiceGetMatchingServices( port, IOBSDNameMatching( port, 0, devname ), if (IOServiceGetMatchingServices(port, IOBSDNameMatching(port, 0, devname),
&iterator ) != KERN_SUCCESS ) { &iterator) != KERN_SUCCESS) {
fprintf( stderr, "IOServiceGetMatchingServices failed\n" ); fprintf(stderr, "IOServiceGetMatchingServices failed\n");
goto Exit; goto Exit;
} }
service = IOIteratorNext( iterator ); service = IOIteratorNext(iterator);
IOObjectRelease( iterator ); IOObjectRelease(iterator);
iterator = 0; iterator = 0;
while ( service && !IOObjectConformsTo( service, "IOCDMedia" )) { while (service && !IOObjectConformsTo(service, "IOCDMedia")) {
if ( IORegistryEntryGetParentIterator( service, kIOServicePlane, if (IORegistryEntryGetParentIterator(service, kIOServicePlane,
&iterator ) != KERN_SUCCESS ) { &iterator) != KERN_SUCCESS)
fprintf( stderr, "IORegistryEntryGetParentIterator failed\n" ); {
fprintf(stderr, "IORegistryEntryGetParentIterator failed\n");
goto Exit; goto Exit;
} }
IOObjectRelease( service ); IOObjectRelease(service);
service = IOIteratorNext( iterator ); service = IOIteratorNext(iterator);
IOObjectRelease( iterator ); IOObjectRelease(iterator);
} }
if ( service == NULL ) { if (service == NULL) {
fprintf( stderr, "CD media not found\n" ); fprintf(stderr, "CD media not found\n");
goto Exit; goto Exit;
} }
if ( IORegistryEntryCreateCFProperties( service, (__CFDictionary **) &properties, if (IORegistryEntryCreateCFProperties(service, (__CFDictionary **) &properties,
kCFAllocatorDefault, kCFAllocatorDefault,
kNilOptions ) != KERN_SUCCESS ) { kNilOptions) != KERN_SUCCESS)
fprintf( stderr, "IORegistryEntryGetParentIterator failed\n" ); {
fprintf(stderr, "IORegistryEntryGetParentIterator failed\n");
goto Exit; goto Exit;
} }
data = (CFDataRef) CFDictionaryGetValue( properties, CFSTR(kIOCDMediaTOCKey) ); data = (CFDataRef) CFDictionaryGetValue(properties, CFSTR(kIOCDMediaTOCKey));
if ( data == NULL ) { if (data == NULL) {
fprintf( stderr, "CFDictionaryGetValue failed\n" ); fprintf(stderr, "CFDictionaryGetValue failed\n");
goto Exit; goto Exit;
} }
else { else {
CFRange range; CFRange range;
CFIndex buflen; CFIndex buflen;
buflen = CFDataGetLength( data ) + 1; buflen = CFDataGetLength(data) + 1;
range = CFRangeMake( 0, buflen ); range = CFRangeMake(0, buflen);
toc_p = (struct _CDTOC *) malloc( buflen ); toc_p = (struct _CDTOC *) malloc(buflen);
if ( toc_p == NULL ) { if (toc_p == NULL) {
fprintf( stderr, "Out of memory\n" ); fprintf(stderr, "Out of memory\n");
goto Exit; goto Exit;
} }
else { else {
CFDataGetBytes( data, range, (unsigned char *) toc_p ); CFDataGetBytes(data, range, (unsigned char *) toc_p);
} }
/* /*
fprintf( stderr, "Table of contents\n length %d first %d last %d\n", fprintf(stderr, "Table of contents\n length %d first %d last %d\n",
toc_p->length, toc_p->first_session, toc_p->last_session ); toc_p->length, toc_p->first_session, toc_p->last_session);
*/ */
CFRelease( properties ); CFRelease(properties);
} }
Exit:
Exit: if (service) {
IOObjectRelease(service);
if ( service ) {
IOObjectRelease( service );
} }
return toc_p; return toc_p;
} }
#endif #endif
@ -436,76 +427,76 @@ static struct _CDTOC * ReadTOC( const char * devpath ) {
bool ReadCDSector(unsigned int hid, unsigned int tid, unsigned int lun, unsigned long frame, unsigned char *buf, int bufsize) bool ReadCDSector(unsigned int hid, unsigned int tid, unsigned int lun, unsigned long frame, unsigned char *buf, int bufsize)
{ {
HANDLE hEventSRB; HANDLE hEventSRB;
SRB_ExecSCSICmd srb; SRB_ExecSCSICmd srb;
DWORD dwStatus; DWORD dwStatus;
hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL); hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL);
memset(&srb,0,sizeof(SRB_ExecSCSICmd)); memset(&srb,0,sizeof(SRB_ExecSCSICmd));
srb.SRB_Cmd = SC_EXEC_SCSI_CMD; srb.SRB_Cmd = SC_EXEC_SCSI_CMD;
srb.SRB_HaId = hid; srb.SRB_HaId = hid;
srb.SRB_Target = tid; srb.SRB_Target = tid;
srb.SRB_Lun = lun; srb.SRB_Lun = lun;
srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
srb.SRB_SenseLen = SENSE_LEN; srb.SRB_SenseLen = SENSE_LEN;
srb.SRB_PostProc = hEventSRB; srb.SRB_PostProc = hEventSRB;
srb.SRB_BufPointer = buf; srb.SRB_BufPointer = buf;
srb.SRB_BufLen = bufsize; srb.SRB_BufLen = bufsize;
srb.SRB_CDBLen = 10; srb.SRB_CDBLen = 10;
srb.CDBByte[0] = SCSI_READ10; srb.CDBByte[0] = SCSI_READ10;
srb.CDBByte[2] = (unsigned char) (frame>>24); srb.CDBByte[2] = (unsigned char) (frame>>24);
srb.CDBByte[3] = (unsigned char) (frame>>16); srb.CDBByte[3] = (unsigned char) (frame>>16);
srb.CDBByte[4] = (unsigned char) (frame>>8); srb.CDBByte[4] = (unsigned char) (frame>>8);
srb.CDBByte[5] = (unsigned char) (frame); srb.CDBByte[5] = (unsigned char) (frame);
srb.CDBByte[7] = 0; srb.CDBByte[7] = 0;
srb.CDBByte[8] = 1; /* read 1 frames */ srb.CDBByte[8] = 1; /* read 1 frames */
ResetEvent(hEventSRB); ResetEvent(hEventSRB);
dwStatus = SendASPI32Command((SRB *)&srb); dwStatus = SendASPI32Command((SRB *)&srb);
if(dwStatus == SS_PENDING) { if(dwStatus == SS_PENDING) {
WaitForSingleObject(hEventSRB, 100000); WaitForSingleObject(hEventSRB, 100000);
} }
CloseHandle(hEventSRB); CloseHandle(hEventSRB);
return (srb.SRB_TargStat == STATUS_GOOD); return (srb.SRB_TargStat == STATUS_GOOD);
} }
int GetCDCapacity(unsigned int hid, unsigned int tid, unsigned int lun) int GetCDCapacity(unsigned int hid, unsigned int tid, unsigned int lun)
{ {
HANDLE hEventSRB; HANDLE hEventSRB;
SRB_ExecSCSICmd srb; SRB_ExecSCSICmd srb;
DWORD dwStatus; DWORD dwStatus;
unsigned char buf[8]; unsigned char buf[8];
hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL); hEventSRB = CreateEvent(NULL, TRUE, FALSE, NULL);
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
memset(&srb,0,sizeof(SRB_ExecSCSICmd)); memset(&srb,0,sizeof(SRB_ExecSCSICmd));
srb.SRB_Cmd = SC_EXEC_SCSI_CMD; srb.SRB_Cmd = SC_EXEC_SCSI_CMD;
srb.SRB_HaId = hid; srb.SRB_HaId = hid;
srb.SRB_Target = tid; srb.SRB_Target = tid;
srb.SRB_Lun = lun; srb.SRB_Lun = lun;
srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; srb.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY;
srb.SRB_SenseLen = SENSE_LEN; srb.SRB_SenseLen = SENSE_LEN;
srb.SRB_PostProc = hEventSRB; srb.SRB_PostProc = hEventSRB;
srb.SRB_BufPointer = (unsigned char *)buf; srb.SRB_BufPointer = (unsigned char *)buf;
srb.SRB_BufLen = 8; srb.SRB_BufLen = 8;
srb.SRB_CDBLen = 10; srb.SRB_CDBLen = 10;
srb.CDBByte[0] = SCSI_READCDCAP; srb.CDBByte[0] = SCSI_READCDCAP;
srb.CDBByte[2] = 0; srb.CDBByte[2] = 0;
srb.CDBByte[3] = 0; srb.CDBByte[3] = 0;
srb.CDBByte[4] = 0; srb.CDBByte[4] = 0;
srb.CDBByte[5] = 0; srb.CDBByte[5] = 0;
srb.CDBByte[8] = 0; srb.CDBByte[8] = 0;
ResetEvent(hEventSRB); ResetEvent(hEventSRB);
dwStatus = SendASPI32Command((SRB *)&srb); dwStatus = SendASPI32Command((SRB *)&srb);
if(dwStatus == SS_PENDING) { if(dwStatus == SS_PENDING) {
WaitForSingleObject(hEventSRB, 100000); WaitForSingleObject(hEventSRB, 100000);
} }
CloseHandle(hEventSRB); CloseHandle(hEventSRB);
return ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]) * ((buf[4] << 24) + (buf[5] << 16) + (buf[6] << 8) + buf[7]); return ((buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]) * ((buf[4] << 24) + (buf[5] << 16) + (buf[6] << 8) + buf[7]);
} }
#endif #endif
@ -532,7 +523,7 @@ cdrom_interface::cdrom_interface(char *dev)
void void
cdrom_interface::init(void) { cdrom_interface::init(void) {
BX_DEBUG(("Init $Id: cdrom.cc,v 1.90 2008-01-26 22:24:00 sshwarts Exp $")); BX_DEBUG(("Init $Id: cdrom.cc,v 1.91 2008-02-15 22:05:41 sshwarts Exp $"));
BX_INFO(("file = '%s'",path)); BX_INFO(("file = '%s'",path));
} }
@ -561,7 +552,7 @@ cdrom_interface::insert_cdrom(char *dev)
BX_INFO (("load cdrom with path=%s", path)); BX_INFO (("load cdrom with path=%s", path));
#ifdef WIN32 #ifdef WIN32
char drive[256]; char drive[256];
if ( (path[1] == ':') && (strlen(path) == 2) ) if ((path[1] == ':') && (strlen(path) == 2))
{ {
if(osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) { if(osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// Use direct device access under windows NT/2k/XP // Use direct device access under windows NT/2k/XP
@ -592,9 +583,9 @@ cdrom_interface::insert_cdrom(char *dev)
if (!hASPI) { if (!hASPI) {
hASPI = LoadLibrary("WNASPI32.DLL"); hASPI = LoadLibrary("WNASPI32.DLL");
if (hASPI) { if (hASPI) {
SendASPI32Command = (DWORD(*)(LPSRB))GetProcAddress( hASPI, "SendASPI32Command" ); SendASPI32Command = (DWORD(*)(LPSRB))GetProcAddress(hASPI, "SendASPI32Command");
GetASPI32DLLVersion = (DWORD(*)(void))GetProcAddress( hASPI, "GetASPI32DLLVersion" ); GetASPI32DLLVersion = (DWORD(*)(void))GetProcAddress(hASPI, "GetASPI32DLLVersion");
GetASPI32SupportInfo = (DWORD(*)(void))GetProcAddress( hASPI, "GetASPI32SupportInfo" ); GetASPI32SupportInfo = (DWORD(*)(void))GetProcAddress(hASPI, "GetASPI32SupportInfo");
d = GetASPI32DLLVersion(); d = GetASPI32DLLVersion();
BX_INFO(("WNASPI32.DLL version %d.%02d initialized", d & 0xff, (d >> 8) & 0xff)); BX_INFO(("WNASPI32.DLL version %d.%02d initialized", d & 0xff, (d >> 8) & 0xff));
} else { } else {
@ -657,28 +648,27 @@ cdrom_interface::insert_cdrom(char *dev)
io_iterator_t mediaIterator; io_iterator_t mediaIterator;
kern_return_t kernResult; kern_return_t kernResult;
BX_INFO(( "Insert CDROM" )); BX_INFO(("Insert CDROM"));
kernResult = FindEjectableCDMedia( &mediaIterator, &masterPort ); kernResult = FindEjectableCDMedia(&mediaIterator, &masterPort);
if ( kernResult != KERN_SUCCESS ) { if (kernResult != KERN_SUCCESS) {
BX_INFO (("Unable to find CDROM")); BX_INFO(("Unable to find CDROM"));
return 0; return 0;
} }
kernResult = GetDeviceFilePath( mediaIterator, CDDevicePath, sizeof( CDDevicePath ) ); kernResult = GetDeviceFilePath(mediaIterator, CDDevicePath, sizeof(CDDevicePath));
if ( kernResult != KERN_SUCCESS ) { if (kernResult != KERN_SUCCESS) {
BX_INFO (("Unable to get CDROM device file path" )); BX_INFO(("Unable to get CDROM device file path"));
return 0; return 0;
} }
// Here a cdrom was found so see if we can read from it. // Here a cdrom was found so see if we can read from it.
// At this point a failure will result in panic. // At this point a failure will result in panic.
if ( strlen( CDDevicePath ) ) { if (strlen(CDDevicePath)) {
fd = open(CDDevicePath, O_RDONLY); fd = open(CDDevicePath, O_RDONLY);
} }
} }
else else {
{
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
} }
#else #else
@ -686,7 +676,7 @@ cdrom_interface::insert_cdrom(char *dev)
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
#endif #endif
if (fd < 0) { if (fd < 0) {
BX_ERROR(( "open cd failed for %s: %s", path, strerror(errno))); BX_ERROR(("open cd failed for %s: %s", path, strerror(errno)));
return 0; return 0;
} }
#ifndef WIN32 #ifndef WIN32
@ -718,11 +708,11 @@ cdrom_interface::start_cdrom()
if (fd >= 0) { if (fd >= 0) {
#if defined(__NetBSD__) || defined(__NetBSD_kernel__) #if defined(__NetBSD__) || defined(__NetBSD_kernel__)
if (ioctl (fd, CDIOCSTART) < 0) if (ioctl (fd, CDIOCSTART) < 0)
BX_DEBUG(( "start_cdrom: start returns error: %s", strerror (errno) )); BX_DEBUG(("start_cdrom: start returns error: %s", strerror (errno)));
return 1; return 1;
#else #else
BX_INFO(("start_cdrom: your OS is not supported yet.")); BX_INFO(("start_cdrom: your OS is not supported yet"));
return 0; // OS not supported yet, return 0 always. return 0; // OS not supported yet, return 0 always
#endif #endif
} }
return 0; return 0;
@ -738,7 +728,7 @@ cdrom_interface::eject_cdrom()
#if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) #if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
(void) ioctl (fd, CDIOCALLOW); (void) ioctl (fd, CDIOCALLOW);
if (ioctl (fd, CDIOCEJECT) < 0) if (ioctl (fd, CDIOCEJECT) < 0)
BX_DEBUG(( "eject_cdrom: eject returns error." )); BX_DEBUG(("eject_cdrom: eject returns error"));
#endif #endif
#ifdef WIN32 #ifdef WIN32
@ -1091,7 +1081,7 @@ cdrom_interface::read_toc(Bit8u* buf, int* length, bx_bool msf, int start_track,
#if 1 #if 1
{ {
struct _CDTOC * toc = ReadTOC( CDDevicePath ); struct _CDTOC *toc = ReadTOC(CDDevicePath);
if ((start_track > toc->last_session) && (start_track != 0xaa)) if ((start_track > toc->last_session) && (start_track != 0xaa))
return 0; return 0;
@ -1153,18 +1143,16 @@ cdrom_interface::read_toc(Bit8u* buf, int* length, bx_bool msf, int start_track,
return 1; return 1;
} }
#else #else
BX_INFO(( "Read TOC - Not Implemented" )); BX_INFO(("Read TOC - Not Implemented"));
return 0; return 0;
#endif #endif
#else #else
BX_INFO(("read_toc: your OS is not supported yet.")); BX_INFO(("read_toc: your OS is not supported yet"));
return 0; // OS not supported yet, return 0 always. return 0; // OS not supported yet, return 0 always.
#endif #endif
} }
Bit32u cdrom_interface::capacity()
Bit32u
cdrom_interface::capacity()
{ {
// Return CD-ROM capacity. I believe you want to return // Return CD-ROM capacity. I believe you want to return
// the number of blocks of capacity the actual media has. // the number of blocks of capacity the actual media has.
@ -1195,7 +1183,7 @@ cdrom_interface::capacity()
BX_PANIC(("cdrom: capacity: file not open.")); BX_PANIC(("cdrom: capacity: file not open."));
} }
if( fstat(fd, &buf) != 0 ) if(fstat(fd, &buf) != 0)
BX_PANIC(("cdrom: capacity: stat() failed.")); BX_PANIC(("cdrom: capacity: stat() failed."));
return(buf.st_size); return(buf.st_size);
@ -1211,7 +1199,7 @@ cdrom_interface::capacity()
if (ioctl(fd, DIOCGDINFO, &lp) < 0) if (ioctl(fd, DIOCGDINFO, &lp) < 0)
BX_PANIC(("cdrom: ioctl(DIOCGDINFO) failed")); BX_PANIC(("cdrom: ioctl(DIOCGDINFO) failed"));
BX_DEBUG(( "capacity: %u", lp.d_secperunit )); BX_DEBUG(("capacity: %u", lp.d_secperunit));
return(lp.d_secperunit); return(lp.d_secperunit);
} }
#elif defined(__linux__) #elif defined(__linux__)
@ -1300,7 +1288,7 @@ cdrom_interface::capacity()
if (rte.data[i].control & 4) { /* data track */ if (rte.data[i].control & 4) { /* data track */
num_sectors = ntohl(rte.data[i + 1].addr.lba) num_sectors = ntohl(rte.data[i + 1].addr.lba)
- ntohl(rte.data[i].addr.lba); - ntohl(rte.data[i].addr.lba);
BX_INFO(( "cdrom: Data track %d, length %d", BX_INFO(("cdrom: Data track %d, length %d",
rte.data[i].track, num_sectors)); rte.data[i].track, num_sectors));
break; break;
} }
@ -1330,7 +1318,7 @@ cdrom_interface::capacity()
ULARGE_INTEGER FreeBytesForCaller; ULARGE_INTEGER FreeBytesForCaller;
ULARGE_INTEGER TotalNumOfBytes; ULARGE_INTEGER TotalNumOfBytes;
ULARGE_INTEGER TotalFreeBytes; ULARGE_INTEGER TotalFreeBytes;
GetDiskFreeSpaceEx( path, &FreeBytesForCaller, &TotalNumOfBytes, &TotalFreeBytes); GetDiskFreeSpaceEx(path, &FreeBytesForCaller, &TotalNumOfBytes, &TotalFreeBytes);
return (Bit32u)(TotalNumOfBytes.QuadPart / 2048); return (Bit32u)(TotalNumOfBytes.QuadPart / 2048);
} }
} }
@ -1345,17 +1333,17 @@ cdrom_interface::capacity()
// Return CD-ROM capacity. I believe you want to return // Return CD-ROM capacity. I believe you want to return
// the number of bytes of capacity the actual media has. // the number of bytes of capacity the actual media has.
BX_INFO(( "Capacity" )); BX_INFO(("Capacity"));
struct _CDTOC * toc = ReadTOC( CDDevicePath ); struct _CDTOC *toc = ReadTOC(CDDevicePath);
if ( toc == NULL ) { if (toc == NULL) {
BX_PANIC(( "capacity: Failed to read toc" )); BX_PANIC(("capacity: Failed to read toc"));
} }
size_t toc_entries = ( toc->length - 2 ) / sizeof( struct _CDTOC_Desc ); size_t toc_entries = (toc->length - 2) / sizeof(struct _CDTOC_Desc);
BX_DEBUG(( "reading %d toc entries\n", toc_entries )); BX_DEBUG(("reading %d toc entries\n", toc_entries));
int start_sector = -1; int start_sector = -1;
int data_track = -1; int data_track = -1;
@ -1364,32 +1352,32 @@ cdrom_interface::capacity()
// get the address of the immediately previous (or following depending // get the address of the immediately previous (or following depending
// on how you look at it). The difference in the sector numbers // on how you look at it). The difference in the sector numbers
// is returned as the sized of the data track. // is returned as the sized of the data track.
for ( int i=toc_entries - 1; i>=0; i-- ) { for (int i=toc_entries - 1; i>=0; i--) {
BX_DEBUG(( "session %d ctl_adr %d tno %d point %d lba %d z %d p lba %d\n", BX_DEBUG(("session %d ctl_adr %d tno %d point %d lba %d z %d p lba %d\n",
(int)toc->trackdesc[i].session, (int)toc->trackdesc[i].session,
(int)toc->trackdesc[i].ctrl_adr, (int)toc->trackdesc[i].ctrl_adr,
(int)toc->trackdesc[i].tno, (int)toc->trackdesc[i].tno,
(int)toc->trackdesc[i].point, (int)toc->trackdesc[i].point,
MSF_TO_LBA( toc->trackdesc[i].address ), MSF_TO_LBA(toc->trackdesc[i].address),
(int)toc->trackdesc[i].zero, (int)toc->trackdesc[i].zero,
MSF_TO_LBA(toc->trackdesc[i].p ))); MSF_TO_LBA(toc->trackdesc[i].p)));
if ( start_sector != -1 ) { if (start_sector != -1) {
start_sector = MSF_TO_LBA(toc->trackdesc[i].p) - start_sector; start_sector = MSF_TO_LBA(toc->trackdesc[i].p) - start_sector;
break; break;
} }
if ((toc->trackdesc[i].ctrl_adr >> 4) != 1) continue; if ((toc->trackdesc[i].ctrl_adr >> 4) != 1) continue;
if ( toc->trackdesc[i].ctrl_adr & 0x04 ) { if (toc->trackdesc[i].ctrl_adr & 0x04) {
data_track = toc->trackdesc[i].point; data_track = toc->trackdesc[i].point;
start_sector = MSF_TO_LBA(toc->trackdesc[i].p); start_sector = MSF_TO_LBA(toc->trackdesc[i].p);
} }
} }
free( toc ); free(toc);
if ( start_sector == -1 ) { if (start_sector == -1) {
start_sector = 0; start_sector = 0;
} }
@ -1398,7 +1386,7 @@ cdrom_interface::capacity()
return start_sector; return start_sector;
} }
#else #else
BX_ERROR(( "capacity: your OS is not supported yet." )); BX_ERROR(("capacity: your OS is not supported yet"));
return(0); return(0);
#endif #endif
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: cmos.cc,v 1.63 2008-01-26 22:24:00 sshwarts Exp $ // $Id: cmos.cc,v 1.64 2008-02-15 22:05:41 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -140,7 +140,7 @@ bx_cmos_c::~bx_cmos_c(void)
void bx_cmos_c::init(void) void bx_cmos_c::init(void)
{ {
BX_DEBUG(("Init $Id: cmos.cc,v 1.63 2008-01-26 22:24:00 sshwarts Exp $")); BX_DEBUG(("Init $Id: cmos.cc,v 1.64 2008-02-15 22:05:41 sshwarts Exp $"));
// CMOS RAM & RTC // CMOS RAM & RTC
DEV_register_ioread_handler(this, read_handler, 0x0070, "CMOS RAM", 1); DEV_register_ioread_handler(this, read_handler, 0x0070, "CMOS RAM", 1);
@ -519,11 +519,11 @@ void bx_cmos_c::write(Bit32u address, Bit32u value, unsigned io_len)
unsigned prev_CRB; unsigned prev_CRB;
prev_CRB = BX_CMOS_THIS s.reg[REG_STAT_B]; prev_CRB = BX_CMOS_THIS s.reg[REG_STAT_B];
BX_CMOS_THIS s.reg[REG_STAT_B] = value; BX_CMOS_THIS s.reg[REG_STAT_B] = value;
if ( (prev_CRB & 0x02) != (value & 0x02) ) { if ((prev_CRB & 0x02) != (value & 0x02)) {
BX_CMOS_THIS s.rtc_mode_12hour = ((value & 0x02) == 0); BX_CMOS_THIS s.rtc_mode_12hour = ((value & 0x02) == 0);
update_clock(); update_clock();
} }
if ( (prev_CRB & 0x04) != (value & 0x04) ) { if ((prev_CRB & 0x04) != (value & 0x04)) {
BX_CMOS_THIS s.rtc_mode_binary = ((value & 0x04) != 0); BX_CMOS_THIS s.rtc_mode_binary = ((value & 0x04) != 0);
update_clock(); update_clock();
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: devices.cc,v 1.119 2008-01-26 22:24:00 sshwarts Exp $ // $Id: devices.cc,v 1.120 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -122,7 +122,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
unsigned i; unsigned i;
const char def_name[] = "Default"; const char def_name[] = "Default";
BX_DEBUG(("Init $Id: devices.cc,v 1.119 2008-01-26 22:24:00 sshwarts Exp $")); BX_DEBUG(("Init $Id: devices.cc,v 1.120 2008-02-15 22:05:42 sshwarts Exp $"));
mem = newmem; mem = newmem;
/* set no-default handlers, will be overwritten by the real default handler */ /* set no-default handlers, will be overwritten by the real default handler */
@ -302,16 +302,16 @@ void bx_devices_c::init(BX_MEM_C *newmem)
DEV_cmos_set_reg(0x15, (Bit8u) BASE_MEMORY_IN_K); DEV_cmos_set_reg(0x15, (Bit8u) BASE_MEMORY_IN_K);
DEV_cmos_set_reg(0x16, (Bit8u) (BASE_MEMORY_IN_K >> 8)); DEV_cmos_set_reg(0x16, (Bit8u) (BASE_MEMORY_IN_K >> 8));
DEV_cmos_set_reg(0x17, (Bit8u) (extended_memory_in_k & 0xff) ); DEV_cmos_set_reg(0x17, (Bit8u) (extended_memory_in_k & 0xff));
DEV_cmos_set_reg(0x18, (Bit8u) ((extended_memory_in_k >> 8) & 0xff) ); DEV_cmos_set_reg(0x18, (Bit8u) ((extended_memory_in_k >> 8) & 0xff));
DEV_cmos_set_reg(0x30, (Bit8u) (extended_memory_in_k & 0xff) ); DEV_cmos_set_reg(0x30, (Bit8u) (extended_memory_in_k & 0xff));
DEV_cmos_set_reg(0x31, (Bit8u) ((extended_memory_in_k >> 8) & 0xff) ); DEV_cmos_set_reg(0x31, (Bit8u) ((extended_memory_in_k >> 8) & 0xff));
Bit32u extended_memory_in_64k = mem->get_memory_in_k() > 16384 ? (mem->get_memory_in_k() - 16384) / 64 : 0; Bit32u extended_memory_in_64k = mem->get_memory_in_k() > 16384 ? (mem->get_memory_in_k() - 16384) / 64 : 0;
if (extended_memory_in_64k > 0xffff) extended_memory_in_64k = 0xffff; if (extended_memory_in_64k > 0xffff) extended_memory_in_64k = 0xffff;
DEV_cmos_set_reg(0x34, (Bit8u) (extended_memory_in_64k & 0xff) ); DEV_cmos_set_reg(0x34, (Bit8u) (extended_memory_in_64k & 0xff));
DEV_cmos_set_reg(0x35, (Bit8u) ((extended_memory_in_64k >> 8) & 0xff) ); DEV_cmos_set_reg(0x35, (Bit8u) ((extended_memory_in_64k >> 8) & 0xff));
if (timer_handle != BX_NULL_TIMER_HANDLE) { if (timer_handle != BX_NULL_TIMER_HANDLE) {
timer_handle = bx_pc_system.register_timer(this, timer_handler, timer_handle = bx_pc_system.register_timer(this, timer_handler,
@ -467,7 +467,7 @@ void bx_devices_c::port92_write(Bit32u address, Bit32u value, unsigned io_len)
BX_DEBUG(("port92h write of %02x partially supported!!!", (unsigned) value)); BX_DEBUG(("port92h write of %02x partially supported!!!", (unsigned) value));
BX_DEBUG(("A20: set_enable_a20() called")); BX_DEBUG(("A20: set_enable_a20() called"));
BX_SET_ENABLE_A20( (value & 0x02) >> 1 ); BX_SET_ENABLE_A20((value & 0x02) >> 1);
BX_DEBUG(("A20: now %u", (unsigned) BX_GET_ENABLE_A20())); BX_DEBUG(("A20: now %u", (unsigned) BX_GET_ENABLE_A20()));
if (value & 0x01) { /* high speed reset */ if (value & 0x01) { /* high speed reset */
BX_INFO(("iowrite to port0x92 : reset resquested")); BX_INFO(("iowrite to port0x92 : reset resquested"));

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: dma.cc,v 1.45 2008-01-26 22:24:01 sshwarts Exp $ // $Id: dma.cc,v 1.46 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,8 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
@ -123,7 +122,7 @@ unsigned bx_dma_c::get_TC(void)
void bx_dma_c::init(void) void bx_dma_c::init(void)
{ {
unsigned c, i, j; unsigned c, i, j;
BX_DEBUG(("Init $Id: dma.cc,v 1.45 2008-01-26 22:24:01 sshwarts Exp $")); BX_DEBUG(("Init $Id: dma.cc,v 1.46 2008-02-15 22:05:42 sshwarts Exp $"));
/* 8237 DMA controller */ /* 8237 DMA controller */
@ -379,7 +378,7 @@ bx_dma_c::write(Bit32u address, Bit32u value, unsigned io_len)
Bit8u channel; Bit8u channel;
if (io_len > 1) { if (io_len > 1) {
if ( (io_len == 2) && (address == 0x0b) ) { if ((io_len == 2) && (address == 0x0b)) {
#if BX_USE_DMA_SMF #if BX_USE_DMA_SMF
BX_DMA_THIS write_handler(NULL, address, value & 0xff, 1); BX_DMA_THIS write_handler(NULL, address, value & 0xff, 1);
BX_DMA_THIS write_handler(NULL, address+1, value >> 8, 1); BX_DMA_THIS write_handler(NULL, address+1, value >> 8, 1);
@ -617,11 +616,13 @@ void bx_dma_c::set_DRQ(unsigned channel, bx_bool val)
BX_DMA_THIS s[ma_sl].status_reg |= (1 << (channel+4)); BX_DMA_THIS s[ma_sl].status_reg |= (1 << (channel+4));
if ( (BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_SINGLE) && if ((BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_SINGLE) &&
(BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_DEMAND) && (BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_DEMAND) &&
(BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_CASCADE) ) (BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type != DMA_MODE_CASCADE))
{
BX_PANIC(("set_DRQ: mode_type(%02x) not handled", BX_PANIC(("set_DRQ: mode_type(%02x) not handled",
(unsigned) BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type)); (unsigned) BX_DMA_THIS s[ma_sl].chan[channel].mode.mode_type));
}
dma_base = (BX_DMA_THIS s[ma_sl].chan[channel].page_reg << 16) | dma_base = (BX_DMA_THIS s[ma_sl].chan[channel].page_reg << 16) |
(BX_DMA_THIS s[ma_sl].chan[channel].base_address << ma_sl); (BX_DMA_THIS s[ma_sl].chan[channel].base_address << ma_sl);
@ -630,7 +631,7 @@ void bx_dma_c::set_DRQ(unsigned channel, bx_bool val)
} else { } else {
dma_roof = dma_base - (BX_DMA_THIS s[ma_sl].chan[channel].base_count << ma_sl); dma_roof = dma_base - (BX_DMA_THIS s[ma_sl].chan[channel].base_count << ma_sl);
} }
if ( (dma_base & (0x7fff0000 << ma_sl)) != (dma_roof & (0x7fff0000 << ma_sl)) ) { if ((dma_base & (0x7fff0000 << ma_sl)) != (dma_roof & (0x7fff0000 << ma_sl))) {
BX_INFO(("dma_base = %08x", (unsigned) dma_base)); BX_INFO(("dma_base = %08x", (unsigned) dma_base));
BX_INFO(("dma_base_count = %08x", (unsigned) BX_DMA_THIS s[ma_sl].chan[channel].base_count)); BX_INFO(("dma_base_count = %08x", (unsigned) BX_DMA_THIS s[ma_sl].chan[channel].base_count));
BX_INFO(("dma_roof = %08x", (unsigned) dma_roof)); BX_INFO(("dma_roof = %08x", (unsigned) dma_roof));
@ -659,8 +660,8 @@ void bx_dma_c::control_HRQ(bx_bool ma_sl)
} }
// find highest priority channel // find highest priority channel
for (channel=0; channel<4; channel++) { for (channel=0; channel<4; channel++) {
if ( (BX_DMA_THIS s[ma_sl].status_reg & (1 << (channel+4))) && if ((BX_DMA_THIS s[ma_sl].status_reg & (1 << (channel+4))) &&
(BX_DMA_THIS s[ma_sl].mask[channel]==0) ) { (BX_DMA_THIS s[ma_sl].mask[channel]==0)) {
if (ma_sl) { if (ma_sl) {
// assert Hold ReQuest line to CPU // assert Hold ReQuest line to CPU
bx_pc_system.set_HRQ(1); bx_pc_system.set_HRQ(1);
@ -683,8 +684,8 @@ void bx_dma_c::raise_HLDA(void)
BX_DMA_THIS HLDA = 1; BX_DMA_THIS HLDA = 1;
// find highest priority channel // find highest priority channel
for (channel=0; channel<4; channel++) { for (channel=0; channel<4; channel++) {
if ( (BX_DMA_THIS s[1].status_reg & (1 << (channel+4))) && if ((BX_DMA_THIS s[1].status_reg & (1 << (channel+4))) &&
(BX_DMA_THIS s[1].mask[channel]==0) ) { (BX_DMA_THIS s[1].mask[channel]==0)) {
ma_sl = 1; ma_sl = 1;
break; break;
} }
@ -692,8 +693,8 @@ void bx_dma_c::raise_HLDA(void)
if (channel == 0) { // master cascade channel if (channel == 0) { // master cascade channel
BX_DMA_THIS s[1].DACK[0] = 1; BX_DMA_THIS s[1].DACK[0] = 1;
for (channel=0; channel<4; channel++) { for (channel=0; channel<4; channel++) {
if ( (BX_DMA_THIS s[0].status_reg & (1 << (channel+4))) && if ((BX_DMA_THIS s[0].status_reg & (1 << (channel+4))) &&
(BX_DMA_THIS s[0].mask[channel]==0) ) { (BX_DMA_THIS s[0].mask[channel]==0)) {
ma_sl = 0; ma_sl = 0;
break; break;
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: dma.h,v 1.21 2007-09-28 19:51:59 sshwarts Exp $ // $Id: dma.h,v 1.22 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -64,8 +64,8 @@ private:
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len); static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
#if !BX_USE_DMA_SMF #if !BX_USE_DMA_SMF
Bit32u read( Bit32u address, unsigned io_len) BX_CPP_AttrRegparmN(2); Bit32u read (Bit32u address, unsigned io_len) BX_CPP_AttrRegparmN(2);
void write(Bit32u address, Bit32u value, unsigned io_len) BX_CPP_AttrRegparmN(3); void write(Bit32u address, Bit32u value, unsigned io_len) BX_CPP_AttrRegparmN(3);
#endif #endif
BX_DMA_SMF void control_HRQ(bx_bool ma_sl); BX_DMA_SMF void control_HRQ(bx_bool ma_sl);
BX_DMA_SMF void reset_controller(unsigned num); BX_DMA_SMF void reset_controller(unsigned num);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: eth.cc,v 1.25 2008-01-26 22:24:01 sshwarts Exp $ // $Id: eth.cc,v 1.26 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -168,19 +168,19 @@ extern "C" {
#define LOG_THIS bx_devices.pluginNE2kDevice-> #define LOG_THIS bx_devices.pluginNE2kDevice->
// This is a utility script used for tuntap or ethertap // This is a utility script used for tuntap or ethertap
int execute_script( char* scriptname, char* arg1 ) int execute_script(char* scriptname, char* arg1)
{ {
int pid,status; int pid,status;
if (!(pid=fork())) { if (!(pid=fork())) {
char filename[BX_PATHNAME_LEN]; char filename[BX_PATHNAME_LEN];
if ( scriptname[0]=='/' ) { if (scriptname[0]=='/') {
strcpy (filename, scriptname); strcpy(filename, scriptname);
} }
else { else {
getcwd (filename, BX_PATHNAME_LEN); getcwd(filename, BX_PATHNAME_LEN);
strcat (filename, "/"); strcat(filename, "/");
strcat (filename, scriptname); strcat(filename, scriptname);
} }
// execute the script // execute the script

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: eth_packetmaker.cc,v 1.15 2008-01-26 22:24:01 sshwarts Exp $ // $Id: eth_packetmaker.cc,v 1.16 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
@ -14,25 +14,27 @@
#include "eth_packetmaker.h" #include "eth_packetmaker.h"
bx_bool sendable(const eth_packet& outpacket) { bx_bool sendable(const eth_packet& outpacket) {
//FINISH ME! //FINISH ME!
return 0; return 0;
} }
Bit32u eth_IPmaker::datalen(const eth_packet& outpacket) { Bit32u eth_IPmaker::datalen(const eth_packet& outpacket)
{
Bit32u out; Bit32u out;
out=((outpacket.buf[16]<<8)+outpacket.buf[17])-(4*(0xF & outpacket.buf[14])); out=((outpacket.buf[16]<<8)+outpacket.buf[17])-(4*(0xF & outpacket.buf[14]));
return out; return out;
} }
const Bit8u * eth_IPmaker::datagram(const eth_packet& outpacket) { const Bit8u *eth_IPmaker::datagram(const eth_packet& outpacket)
const Bit8u * out; {
const Bit8u *out;
out=outpacket.buf+14+(4*(0xF & outpacket.buf[14])); out=outpacket.buf+14+(4*(0xF & outpacket.buf[14]));
return out; return out;
} }
Bit32u eth_IPmaker::build_packet_header(Bit32u source, Bit32u dest, Bit8u protocol, Bit32u datalen) { Bit32u eth_IPmaker::build_packet_header(Bit32u source, Bit32u dest, Bit8u protocol, Bit32u datalen)
{
Bit32u temp; Bit32u temp;
Bit32u i; Bit32u i;
memcpy(pending.buf,internal_mac,6); memcpy(pending.buf,internal_mac,6);
@ -73,49 +75,51 @@ Bit32u eth_IPmaker::build_packet_header(Bit32u source, Bit32u dest, Bit8u protoc
return(34); return(34);
} }
Bit8u eth_IPmaker::protocol(const eth_packet& outpacket) { Bit8u eth_IPmaker::protocol(const eth_packet& outpacket)
{
return (*(outpacket.buf+23) & 0xff); return (*(outpacket.buf+23) & 0xff);
} }
Bit32u eth_IPmaker::source(const eth_packet& outpacket) { Bit32u eth_IPmaker::source(const eth_packet& outpacket)
Bit32u out; {
out=0xFF & *(outpacket.buf+26); Bit32u out=0xFF & *(outpacket.buf+26);
out=(out<<8) | (0xFF & *(outpacket.buf+27)); out=(out<<8) | (0xFF & *(outpacket.buf+27));
out=(out<<8) | (0xFF & *(outpacket.buf+28)); out=(out<<8) | (0xFF & *(outpacket.buf+28));
out=(out<<8) | (0xFF & *(outpacket.buf+29)); out=(out<<8) | (0xFF & *(outpacket.buf+29));
return out; return out;
} }
Bit32u eth_IPmaker::destination(const eth_packet& outpacket) { Bit32u eth_IPmaker::destination(const eth_packet& outpacket)
Bit32u out; {
out=0xFF & *(outpacket.buf+30); Bit32u out=0xFF & *(outpacket.buf+30);
out=(out<<8) | (0xFF & *(outpacket.buf+31)); out=(out<<8) | (0xFF & *(outpacket.buf+31));
out=(out<<8) | (0xFF & *(outpacket.buf+32)); out=(out<<8) | (0xFF & *(outpacket.buf+32));
out=(out<<8) | (0xFF & *(outpacket.buf+33)); out=(out<<8) | (0xFF & *(outpacket.buf+33));
return out; return out;
} }
void eth_IPmaker::init(void) { void eth_IPmaker::init(void)
{
is_pending=0; is_pending=0;
} }
void void eth_ETHmaker::init(void)
eth_ETHmaker::init(void) { {
arper.init(); arper.init();
} }
bx_bool bx_bool eth_ETHmaker::getpacket(eth_packet& inpacket)
eth_ETHmaker::getpacket(eth_packet& inpacket) { {
return arper.getpacket(inpacket); return arper.getpacket(inpacket);
} }
bx_bool bx_bool eth_ETHmaker::ishandler(const eth_packet& outpacket)
eth_ETHmaker::ishandler(const eth_packet& outpacket) { {
if((outpacket.len>=60) && if((outpacket.len>=60) &&
( (!memcmp(outpacket.buf, external_mac, 6)) ( (!memcmp(outpacket.buf, external_mac, 6))
|| (!memcmp(outpacket.buf, broadcast_macaddr, 6)) ) && || (!memcmp(outpacket.buf, broadcast_macaddr, 6))) &&
( (!memcmp(outpacket.buf+12, ethtype_arp, 2)) || ( (!memcmp(outpacket.buf+12, ethtype_arp, 2)) ||
(!memcmp(outpacket.buf+12, ethtype_ip, 2)) ) && (!memcmp(outpacket.buf+12, ethtype_ip, 2))) &&
(outpacket.len<PACKET_BUF_SIZE) (outpacket.len<PACKET_BUF_SIZE)
) { ) {
return 1; return 1;
@ -123,21 +127,19 @@ eth_ETHmaker::ishandler(const eth_packet& outpacket) {
return 0; return 0;
} }
bx_bool bx_bool eth_ETHmaker::sendpacket(const eth_packet& outpacket)
eth_ETHmaker::sendpacket(const eth_packet& outpacket) { {
return arper.sendpacket(outpacket); return arper.sendpacket(outpacket);
} }
void eth_ARPmaker::init(void)
{
void
eth_ARPmaker::init(void) {
is_pending=0; is_pending=0;
pending.len=0; pending.len=0;
} }
bx_bool bx_bool eth_ARPmaker::getpacket(eth_packet& inpacket)
eth_ARPmaker::getpacket(eth_packet& inpacket) { {
if(is_pending) { if(is_pending) {
memcpy(inpacket.buf,pending.buf,pending.len); memcpy(inpacket.buf,pending.buf,pending.len);
inpacket.len=pending.len; inpacket.len=pending.len;
@ -147,8 +149,8 @@ eth_ARPmaker::getpacket(eth_packet& inpacket) {
return 0; return 0;
} }
bx_bool bx_bool eth_ARPmaker::ishandler(const eth_packet& outpacket)
eth_ARPmaker::ishandler(const eth_packet& outpacket) { {
if((outpacket.len>=60) && if((outpacket.len>=60) &&
(!memcmp(outpacket.buf+12, ethtype_arp, 2)) && (!memcmp(outpacket.buf+12, ethtype_arp, 2)) &&
(outpacket.len<PACKET_BUF_SIZE) && (outpacket.len<PACKET_BUF_SIZE) &&
@ -161,8 +163,8 @@ eth_ARPmaker::ishandler(const eth_packet& outpacket) {
return 0; return 0;
} }
bx_bool bx_bool eth_ARPmaker::sendpacket(const eth_packet& outpacket)
eth_ARPmaker::sendpacket(const eth_packet& outpacket) { {
if(is_pending || !ishandler(outpacket)) { if(is_pending || !ishandler(outpacket)) {
return 0; return 0;
} else { } else {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: eth_tap.cc,v 1.29 2008-01-26 22:24:01 sshwarts Exp $ // $Id: eth_tap.cc,v 1.30 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -175,28 +175,28 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif,
#if defined(__linux__) #if defined(__linux__)
// check if the TAP devices is running, and turn on ARP. This is based // check if the TAP devices is running, and turn on ARP. This is based
// on code from the Mac-On-Linux project. http://http://www.maconlinux.org/ // on code from the Mac-On-Linux project. http://http://www.maconlinux.org/
int sock = socket( AF_INET, SOCK_DGRAM, 0 ); int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) { if (sock < 0) {
BX_PANIC (("socket creation: %s", strerror(errno))); BX_PANIC (("socket creation: %s", strerror(errno)));
return; return;
} }
struct ifreq ifr; struct ifreq ifr;
memset( &ifr, 0, sizeof(ifr) ); memset(&ifr, 0, sizeof(ifr));
strncpy( ifr.ifr_name, netif, sizeof(ifr.ifr_name) ); strncpy(ifr.ifr_name, netif, sizeof(ifr.ifr_name));
if( ioctl( sock, SIOCGIFFLAGS, &ifr ) < 0 ){ if(ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
BX_PANIC (("SIOCGIFFLAGS on %s: %s", netif, strerror (errno))); BX_PANIC (("SIOCGIFFLAGS on %s: %s", netif, strerror(errno)));
close(sock); close(sock);
return; return;
} }
if( !(ifr.ifr_flags & IFF_RUNNING ) ){ if (!(ifr.ifr_flags & IFF_RUNNING)) {
BX_PANIC (("%s device is not running", netif)); BX_PANIC (("%s device is not running", netif));
close(sock); close(sock);
return; return;
} }
if( (ifr.ifr_flags & IFF_NOARP ) ){ if ((ifr.ifr_flags & IFF_NOARP)){
BX_INFO (("turn on ARP for %s device", netif)); BX_INFO(("turn on ARP for %s device", netif));
ifr.ifr_flags &= ~IFF_NOARP; ifr.ifr_flags &= ~IFF_NOARP;
if( ioctl( sock, SIOCSIFFLAGS, &ifr ) < 0 ) { if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
BX_PANIC (("SIOCSIFFLAGS: %s", strerror(errno))); BX_PANIC (("SIOCSIFFLAGS: %s", strerror(errno)));
close(sock); close(sock);
return; return;
@ -207,30 +207,29 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif,
fd = open (filename, O_RDWR); fd = open (filename, O_RDWR);
if (fd < 0) { if (fd < 0) {
BX_PANIC (("open failed on %s: %s", netif, strerror (errno))); BX_PANIC(("open failed on %s: %s", netif, strerror(errno)));
return; return;
} }
/* set O_ASYNC flag so that we can poll with read() */ /* set O_ASYNC flag so that we can poll with read() */
if ((flags = fcntl( fd, F_GETFL)) < 0) { if ((flags = fcntl(fd, F_GETFL)) < 0) {
BX_PANIC (("getflags on tap device: %s", strerror (errno))); BX_PANIC(("getflags on tap device: %s", strerror(errno)));
} }
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
if (fcntl( fd, F_SETFL, flags ) < 0) { if (fcntl(fd, F_SETFL, flags) < 0) {
BX_PANIC (("set tap device flags: %s", strerror (errno))); BX_PANIC(("set tap device flags: %s", strerror(errno)));
} }
BX_INFO (("eth_tap: opened %s device", netif)); BX_INFO(("eth_tap: opened %s device", netif));
/* Execute the configuration script */ /* Execute the configuration script */
char intname[IFNAMSIZ]; char intname[IFNAMSIZ];
strcpy(intname,netif); strcpy(intname,netif);
if((script != NULL) if((script != NULL) && (strcmp(script, "") != 0) && (strcmp(script, "none") != 0))
&&(strcmp(script, "") != 0) {
&&(strcmp(script, "none") != 0)) {
if (execute_script(script, intname) < 0) if (execute_script(script, intname) < 0)
BX_ERROR (("execute script '%s' on %s failed", script, intname)); BX_ERROR(("execute script '%s' on %s failed", script, intname));
} }
// Start the rx poll // Start the rx poll
this->rx_timer_index = this->rx_timer_index =
@ -269,8 +268,7 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif,
#endif #endif
} }
void void bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len)
bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len)
{ {
Bit8u txbuf[BX_PACKET_BUFSIZE]; Bit8u txbuf[BX_PACKET_BUFSIZE];
txbuf[0] = 0; txbuf[0] = 0;
@ -310,13 +308,13 @@ bx_tap_pktmover_c::sendpkt(void *buf, unsigned io_len)
#endif #endif
} }
void bx_tap_pktmover_c::rx_timer_handler (void *this_ptr) void bx_tap_pktmover_c::rx_timer_handler(void *this_ptr)
{ {
bx_tap_pktmover_c *class_ptr = (bx_tap_pktmover_c *) this_ptr; bx_tap_pktmover_c *class_ptr = (bx_tap_pktmover_c *) this_ptr;
class_ptr->rx_timer(); class_ptr->rx_timer();
} }
void bx_tap_pktmover_c::rx_timer () void bx_tap_pktmover_c::rx_timer()
{ {
int nbytes; int nbytes;
Bit8u buf[BX_PACKET_BUFSIZE]; Bit8u buf[BX_PACKET_BUFSIZE];

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: eth_tuntap.cc,v 1.27 2008-01-26 22:24:01 sshwarts Exp $ // $Id: eth_tuntap.cc,v 1.28 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,6 +23,8 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
/////////////////////////////////////////////////////////////////////////
// eth_tuntap.cc - TUN/TAP interface by Renzo Davoli <renzo@cs.unibo.it> // eth_tuntap.cc - TUN/TAP interface by Renzo Davoli <renzo@cs.unibo.it>
@ -133,28 +135,28 @@ bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif,
// check if the TUN/TAP devices is running, and turn on ARP. This is based // check if the TUN/TAP devices is running, and turn on ARP. This is based
// on code from the Mac-On-Linux project. http://http://www.maconlinux.org/ // on code from the Mac-On-Linux project. http://http://www.maconlinux.org/
int sock = socket( AF_INET, SOCK_DGRAM, 0 ); int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) { if (sock < 0) {
BX_PANIC (("socket creation: %s", strerror(errno))); BX_PANIC (("socket creation: %s", strerror(errno)));
return; return;
} }
struct ifreq ifr; struct ifreq ifr;
memset( &ifr, 0, sizeof(ifr) ); memset(&ifr, 0, sizeof(ifr));
strncpy( ifr.ifr_name, netif, sizeof(ifr.ifr_name) ); strncpy(ifr.ifr_name, netif, sizeof(ifr.ifr_name));
if( ioctl( sock, SIOCGIFFLAGS, &ifr ) < 0 ){ if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
BX_PANIC (("SIOCGIFFLAGS on %s: %s", netif, strerror (errno))); BX_PANIC (("SIOCGIFFLAGS on %s: %s", netif, strerror (errno)));
close(sock); close(sock);
return; return;
} }
if( !(ifr.ifr_flags & IFF_RUNNING ) ){ if (!(ifr.ifr_flags & IFF_RUNNING)) {
BX_PANIC (("%s device is not running", netif)); BX_PANIC (("%s device is not running", netif));
close(sock); close(sock);
return; return;
} }
if( (ifr.ifr_flags & IFF_NOARP ) ){ if ((ifr.ifr_flags & IFF_NOARP)) {
BX_INFO (("turn on ARP for %s device", netif)); BX_INFO (("turn on ARP for %s device", netif));
ifr.ifr_flags &= ~IFF_NOARP; ifr.ifr_flags &= ~IFF_NOARP;
if( ioctl( sock, SIOCSIFFLAGS, &ifr ) < 0 ) { if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
BX_PANIC (("SIOCSIFFLAGS: %s", strerror(errno))); BX_PANIC (("SIOCSIFFLAGS: %s", strerror(errno)));
close(sock); close(sock);
return; return;
@ -168,28 +170,27 @@ bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif,
strcpy(intname,netif); strcpy(intname,netif);
fd=tun_alloc(intname); fd=tun_alloc(intname);
if (fd < 0) { if (fd < 0) {
BX_PANIC (("open failed on %s: %s", netif, strerror (errno))); BX_PANIC(("open failed on %s: %s", netif, strerror (errno)));
return; return;
} }
/* set O_ASYNC flag so that we can poll with read() */ /* set O_ASYNC flag so that we can poll with read() */
if ((flags = fcntl( fd, F_GETFL)) < 0) { if ((flags = fcntl(fd, F_GETFL)) < 0) {
BX_PANIC (("getflags on tun device: %s", strerror (errno))); BX_PANIC (("getflags on tun device: %s", strerror (errno)));
} }
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
if (fcntl( fd, F_SETFL, flags ) < 0) { if (fcntl(fd, F_SETFL, flags) < 0) {
BX_PANIC (("set tun device flags: %s", strerror (errno))); BX_PANIC(("set tun device flags: %s", strerror (errno)));
} }
BX_INFO (("eth_tuntap: opened %s device", netif)); BX_INFO(("eth_tuntap: opened %s device", netif));
/* Execute the configuration script */ /* Execute the configuration script */
if((script != NULL) if((script != NULL) && (strcmp(script, "") != 0) && (strcmp(script, "none") != 0))
&&(strcmp(script, "") != 0) {
&&(strcmp(script, "none") != 0)) {
if (execute_script(script, intname) < 0) if (execute_script(script, intname) < 0)
BX_ERROR (("execute script '%s' on %s failed", script, intname)); BX_ERROR (("execute script '%s' on %s failed", script, intname));
} }
// Start the rx poll // Start the rx poll
this->rx_timer_index = this->rx_timer_index =
@ -228,8 +229,7 @@ bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif,
#endif #endif
} }
void void bx_tuntap_pktmover_c::sendpkt(void *buf, unsigned io_len)
bx_tuntap_pktmover_c::sendpkt(void *buf, unsigned io_len)
{ {
#ifdef __APPLE__ //FIXME #ifdef __APPLE__ //FIXME
unsigned int size = write (fd, (char*)buf+14, io_len-14); unsigned int size = write (fd, (char*)buf+14, io_len-14);
@ -359,7 +359,6 @@ void bx_tuntap_pktmover_c::rx_timer ()
(*rxh)(rxarg, rxbuf, nbytes); (*rxh)(rxarg, rxbuf, nbytes);
} }
int tun_alloc(char *dev) int tun_alloc(char *dev)
{ {
struct ifreq ifr; struct ifreq ifr;
@ -369,10 +368,10 @@ int tun_alloc(char *dev)
// split name into device:ifname if applicable, to allow for opening // split name into device:ifname if applicable, to allow for opening
// persistent tuntap devices // persistent tuntap devices
for (ifname = dev; *ifname; ifname++) { for (ifname = dev; *ifname; ifname++) {
if (*ifname == ':') { if (*ifname == ':') {
*(ifname++) = '\0'; *(ifname++) = '\0';
break; break;
} }
} }
if ((fd = open(dev, O_RDWR)) < 0) if ((fd = open(dev, O_RDWR)) < 0)
return -1; return -1;
@ -393,7 +392,7 @@ int tun_alloc(char *dev)
strncpy(dev, ifr.ifr_name, IFNAMSIZ); strncpy(dev, ifr.ifr_name, IFNAMSIZ);
dev[IFNAMSIZ-1]=0; dev[IFNAMSIZ-1]=0;
ioctl( fd, TUNSETNOCSUM, 1 ); ioctl(fd, TUNSETNOCSUM, 1);
#endif #endif
return fd; return fd;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: eth_vde.cc,v 1.14 2008-01-26 22:24:01 sshwarts Exp $ // $Id: eth_vde.cc,v 1.15 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2003 Renzo Davoli // Copyright (C) 2003 Renzo Davoli
@ -17,6 +17,8 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
/////////////////////////////////////////////////////////////////////////
// eth_vde.cc - Virtual Distributed Ethernet interface by Renzo Davoli <renzo@cs.unibo.it> // eth_vde.cc - Virtual Distributed Ethernet interface by Renzo Davoli <renzo@cs.unibo.it>
// //
@ -127,23 +129,22 @@ bx_vde_pktmover_c::bx_vde_pktmover_c(const char *netif,
} }
/* set O_ASYNC flag so that we can poll with read() */ /* set O_ASYNC flag so that we can poll with read() */
if ((flags = fcntl( fd, F_GETFL)) < 0) { if ((flags = fcntl(fd, F_GETFL)) < 0) {
BX_PANIC (("getflags on vde device: %s", strerror (errno))); BX_PANIC (("getflags on vde device: %s", strerror (errno)));
} }
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
if (fcntl( fd, F_SETFL, flags ) < 0) { if (fcntl(fd, F_SETFL, flags) < 0) {
BX_PANIC (("set vde device flags: %s", strerror (errno))); BX_PANIC (("set vde device flags: %s", strerror (errno)));
} }
BX_INFO (("eth_vde: opened %s device", netif)); BX_INFO(("eth_vde: opened %s device", netif));
/* Execute the configuration script */ /* Execute the configuration script */
if((script != NULL) if((script != NULL) && (strcmp(script, "") != 0) && (strcmp(script, "none") != 0))
&&(strcmp(script, "") != 0) {
&&(strcmp(script, "none") != 0)) {
if (execute_script(script, intname) < 0) if (execute_script(script, intname) < 0)
BX_ERROR (("execute script '%s' on %s failed", script, intname)); BX_ERROR (("execute script '%s' on %s failed", script, intname));
} }
// Start the rx poll // Start the rx poll
this->rx_timer_index = this->rx_timer_index =
@ -181,8 +182,7 @@ bx_vde_pktmover_c::bx_vde_pktmover_c(const char *netif,
#endif #endif
} }
void void bx_vde_pktmover_c::sendpkt(void *buf, unsigned io_len)
bx_vde_pktmover_c::sendpkt(void *buf, unsigned io_len)
{ {
unsigned int size; unsigned int size;
//size = write (fd, buf, io_len); //size = write (fd, buf, io_len);
@ -273,68 +273,69 @@ void bx_vde_pktmover_c::rx_timer ()
#define REQ_NEW_CONTROL 0 #define REQ_NEW_CONTROL 0
struct request_v3 { struct request_v3 {
Bit32u magic; Bit32u magic;
Bit32u version; Bit32u version;
//enum request_type type; //enum request_type type;
int type; int type;
struct sockaddr_un sock; struct sockaddr_un sock;
}; };
static int send_fd(char *name, int fddata, struct sockaddr_un *datasock, int group) static int send_fd(char *name, int fddata, struct sockaddr_un *datasock, int group)
{ {
int pid = getpid(); int pid = getpid();
struct request_v3 req; struct request_v3 req;
int fdctl; int fdctl;
struct sockaddr_un sock; struct sockaddr_un sock;
if((fdctl = socket(AF_UNIX, SOCK_STREAM, 0)) < 0){
perror("socket"); if((fdctl = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
return(-1); perror("socket");
} return(-1);
sock.sun_family = AF_UNIX; }
snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); sock.sun_family = AF_UNIX;
if(connect(fdctl, (struct sockaddr *) &sock, sizeof(sock))){ snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
perror("connect"); if(connect(fdctl, (struct sockaddr *) &sock, sizeof(sock))) {
return(-1); perror("connect");
} return(-1);
req.magic=SWITCH_MAGIC; }
req.version=3;
req.type=((int)REQ_NEW_CONTROL)+((group > 0)?((geteuid()<<8) + group) << 8:0); req.magic=SWITCH_MAGIC;
req.sock.sun_family=AF_UNIX; req.version=3;
memset(req.sock.sun_path, 0, sizeof(req.sock.sun_path)); req.type=((int)REQ_NEW_CONTROL)+((group > 0)?((geteuid()<<8) + group) << 8:0);
sprintf(&req.sock.sun_path[1], "%5d", pid); req.sock.sun_family=AF_UNIX;
if(bind(fddata, (struct sockaddr *) &req.sock, sizeof(req.sock)) < 0){ memset(req.sock.sun_path, 0, sizeof(req.sock.sun_path));
perror("bind"); sprintf(&req.sock.sun_path[1], "%5d", pid);
return(-1);
} if(bind(fddata, (struct sockaddr *) &req.sock, sizeof(req.sock)) < 0) {
if (send(fdctl,&req,sizeof(req),0) < 0) { perror("bind");
perror("send"); return(-1);
return(-1); }
} if (send(fdctl,&req,sizeof(req),0) < 0) {
if (recv(fdctl,datasock,sizeof(struct sockaddr_un),0)<0) { perror("send");
perror("recv"); return(-1);
return(-1); }
} if (recv(fdctl,datasock,sizeof(struct sockaddr_un),0) < 0) {
return fdctl; perror("recv");
return(-1);
}
return fdctl;
} }
int vde_alloc(char *dev, int *fdp, struct sockaddr_un *pdataout) int vde_alloc(char *dev, int *fdp, struct sockaddr_un *pdataout)
{ {
//struct ifreq ifr; //struct ifreq ifr;
//int err; //int err;
int fd, fddata; int fd, fddata;
if((fddata = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0){ if ((fddata = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
return -1; return -1;
}
if ((fd = send_fd(dev, fddata, pdataout, 0)) < 0)
return -1;
if( (fd = send_fd(dev, fddata, pdataout, 0)) < 0 ) //memset(&ifr, 0, sizeof(ifr));
return -1; *fdp=fddata;
//memset(&ifr, 0, sizeof(ifr)); return fd;
*fdp=fddata;
return fd;
} }
#endif /* if BX_NETWORKING && defined HAVE_VDE */ #endif /* if BX_NETWORKING && defined HAVE_VDE */

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: floppy.cc,v 1.109 2008-01-26 22:24:01 sshwarts Exp $ // $Id: floppy.cc,v 1.110 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -24,6 +24,8 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
/////////////////////////////////////////////////////////////////////////
// //
// Floppy Disk Controller Docs: // Floppy Disk Controller Docs:
// Intel 82077A Data sheet // Intel 82077A Data sheet
@ -139,7 +141,7 @@ void bx_floppy_ctrl_c::init(void)
{ {
Bit8u i; Bit8u i;
BX_DEBUG(("Init $Id: floppy.cc,v 1.109 2008-01-26 22:24:01 sshwarts Exp $")); BX_DEBUG(("Init $Id: floppy.cc,v 1.110 2008-02-15 22:05:42 sshwarts Exp $"));
DEV_dma_register_8bit_channel(2, dma_read, dma_write, "Floppy Drive"); DEV_dma_register_8bit_channel(2, dma_read, dma_write, "Floppy Drive");
DEV_register_irq(6, "Floppy Drive"); DEV_register_irq(6, "Floppy Drive");
for (unsigned addr=0x03F2; addr<=0x03F7; addr++) { for (unsigned addr=0x03F2; addr<=0x03F7; addr++) {
@ -324,7 +326,7 @@ void bx_floppy_ctrl_c::init(void)
if (BX_FD_THIS s.floppy_timer_index == BX_NULL_TIMER_HANDLE) { if (BX_FD_THIS s.floppy_timer_index == BX_NULL_TIMER_HANDLE) {
BX_FD_THIS s.floppy_timer_index = BX_FD_THIS s.floppy_timer_index =
bx_pc_system.register_timer( this, timer_handler, 250, 0, 0, "floppy"); bx_pc_system.register_timer(this, timer_handler, 250, 0, 0, "floppy");
} }
/* phase out s.non_dma in favor of using FD_MS_NDMA, more like hardware */ /* phase out s.non_dma in favor of using FD_MS_NDMA, more like hardware */
BX_FD_THIS s.main_status_reg &= ~FD_MS_NDMA; // enable DMA from start BX_FD_THIS s.main_status_reg &= ~FD_MS_NDMA; // enable DMA from start
@ -450,7 +452,7 @@ Bit32u bx_floppy_ctrl_c::read_handler(void *this_ptr, Bit32u address, unsigned i
#if !BX_USE_FD_SMF #if !BX_USE_FD_SMF
bx_floppy_ctrl_c *class_ptr = (bx_floppy_ctrl_c *) this_ptr; bx_floppy_ctrl_c *class_ptr = (bx_floppy_ctrl_c *) this_ptr;
return( class_ptr->read(address, io_len) ); return class_ptr->read(address, io_len);
} }
/* reads from the floppy io ports */ /* reads from the floppy io ports */
@ -496,7 +498,7 @@ Bit32u bx_floppy_ctrl_c::read(Bit32u address, unsigned io_len)
case 0x3F3: // Tape Drive Register case 0x3F3: // Tape Drive Register
drive = BX_FD_THIS s.DOR & 0x03; drive = BX_FD_THIS s.DOR & 0x03;
if (BX_FD_THIS s.media_present[drive]) { if (BX_FD_THIS s.media_present[drive]) {
switch ( BX_FD_THIS s.media[drive].type) { switch (BX_FD_THIS s.media[drive].type) {
case BX_FLOPPY_160K: case BX_FLOPPY_160K:
case BX_FLOPPY_180K: case BX_FLOPPY_180K:
case BX_FLOPPY_320K: case BX_FLOPPY_320K:
@ -861,11 +863,11 @@ void bx_floppy_ctrl_c::floppy_command(void)
return; return;
case 0x13: // Configure case 0x13: // Configure
BX_DEBUG(("configure (eis = 0x%02x)", BX_FD_THIS s.command[2] & 0x40 )); BX_DEBUG(("configure (eis = 0x%02x)", BX_FD_THIS s.command[2] & 0x40));
BX_DEBUG(("configure (efifo = 0x%02x)", BX_FD_THIS s.command[2] & 0x20 )); BX_DEBUG(("configure (efifo = 0x%02x)", BX_FD_THIS s.command[2] & 0x20));
BX_DEBUG(("configure (no poll = 0x%02x)", BX_FD_THIS s.command[2] & 0x10 )); BX_DEBUG(("configure (no poll = 0x%02x)", BX_FD_THIS s.command[2] & 0x10));
BX_DEBUG(("configure (fifothr = 0x%02x)", BX_FD_THIS s.command[2] & 0x0f )); BX_DEBUG(("configure (fifothr = 0x%02x)", BX_FD_THIS s.command[2] & 0x0f));
BX_DEBUG(("configure (pretrk = 0x%02x)", BX_FD_THIS s.command[3] )); BX_DEBUG(("configure (pretrk = 0x%02x)", BX_FD_THIS s.command[3]));
BX_FD_THIS s.config = BX_FD_THIS s.command[2]; BX_FD_THIS s.config = BX_FD_THIS s.command[2];
BX_FD_THIS s.pretrk = BX_FD_THIS s.command[3]; BX_FD_THIS s.pretrk = BX_FD_THIS s.command[3];
enter_idle_phase(); enter_idle_phase();
@ -962,7 +964,7 @@ void bx_floppy_ctrl_c::floppy_command(void)
case 0x45: // write normal data, MT=0 case 0x45: // write normal data, MT=0
case 0xc5: // write normal data, MT=1 case 0xc5: // write normal data, MT=1
BX_FD_THIS s.multi_track = (BX_FD_THIS s.command[0] >> 7); BX_FD_THIS s.multi_track = (BX_FD_THIS s.command[0] >> 7);
if ( (BX_FD_THIS s.DOR & 0x08) == 0 ) if ((BX_FD_THIS s.DOR & 0x08) == 0)
BX_PANIC(("read/write command with DMA and int disabled")); BX_PANIC(("read/write command with DMA and int disabled"));
drive = BX_FD_THIS s.command[1] & 0x03; drive = BX_FD_THIS s.command[1] & 0x03;
BX_FD_THIS s.DOR &= 0xfc; BX_FD_THIS s.DOR &= 0xfc;
@ -1000,7 +1002,7 @@ void bx_floppy_ctrl_c::floppy_command(void)
return; return;
} }
if ( BX_FD_THIS s.media_present[drive] == 0 ) { if (BX_FD_THIS s.media_present[drive] == 0) {
BX_INFO(("attempt to read/write sector %u with media not present", (unsigned) sector)); BX_INFO(("attempt to read/write sector %u with media not present", (unsigned) sector));
return; // Hang controller return; // Hang controller
} }
@ -1009,7 +1011,7 @@ void bx_floppy_ctrl_c::floppy_command(void)
BX_PANIC(("read/write command: sector size %d not supported", 128<<sector_size)); BX_PANIC(("read/write command: sector size %d not supported", 128<<sector_size));
} }
if ( cylinder >= BX_FD_THIS s.media[drive].tracks ) { if (cylinder >= BX_FD_THIS s.media[drive].tracks) {
BX_PANIC(("io: norm r/w parms out of range: sec#%02xh cyl#%02xh eot#%02xh head#%02xh", BX_PANIC(("io: norm r/w parms out of range: sec#%02xh cyl#%02xh eot#%02xh head#%02xh",
(unsigned) sector, (unsigned) cylinder, (unsigned) eot, (unsigned) sector, (unsigned) cylinder, (unsigned) eot,
(unsigned) head)); (unsigned) head));
@ -1511,7 +1513,7 @@ unsigned bx_floppy_ctrl_c::set_media_status(unsigned drive, unsigned status)
if (status == 0) { if (status == 0) {
// eject floppy // eject floppy
if (BX_FD_THIS s.media[drive].fd >= 0) { if (BX_FD_THIS s.media[drive].fd >= 0) {
close( BX_FD_THIS s.media[drive].fd ); close(BX_FD_THIS s.media[drive].fd);
BX_FD_THIS s.media[drive].fd = -1; BX_FD_THIS s.media[drive].fd = -1;
} }
BX_FD_THIS s.media_present[drive] = 0; BX_FD_THIS s.media_present[drive] = 0;
@ -1621,7 +1623,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path,
if (strcmp(SIM->get_param_string(BXPN_FLOPPYA_PATH)->getptr(), SuperDrive)) if (strcmp(SIM->get_param_string(BXPN_FLOPPYA_PATH)->getptr(), SuperDrive))
#endif #endif
#ifdef WIN32 #ifdef WIN32
if ( (isalpha(path[0])) && (path[1] == ':') && (strlen(path) == 2) ) { if ((isalpha(path[0])) && (path[1] == ':') && (strlen(path) == 2)) {
raw_floppy = 1; raw_floppy = 1;
wsprintf(sTemp, "\\\\.\\%s", path); wsprintf(sTemp, "\\\\.\\%s", path);
hFile = CreateFile(sTemp, GENERIC_READ, FILE_SHARE_WRITE, NULL, hFile = CreateFile(sTemp, GENERIC_READ, FILE_SHARE_WRITE, NULL,
@ -1680,7 +1682,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path,
// Don't open the handle if using Win95 style direct access // Don't open the handle if using Win95 style direct access
if (!media->raw_floppy_win95) { if (!media->raw_floppy_win95) {
if (media->fd < 0) { if (media->fd < 0) {
BX_INFO(( "tried to open '%s' read/write: %s",path,strerror(errno) )); BX_INFO(("tried to open '%s' read/write: %s",path,strerror(errno)));
// try opening the file read-only // try opening the file read-only
media->write_protected = 1; media->write_protected = 1;
#ifdef macintosh #ifdef macintosh
@ -1698,7 +1700,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path,
#endif #endif
if (media->fd < 0) { if (media->fd < 0) {
// failed to open read-only too // failed to open read-only too
BX_INFO(( "tried to open '%s' read only: %s",path,strerror(errno) )); BX_INFO(("tried to open '%s' read only: %s",path,strerror(errno)));
media->type = type; media->type = type;
return(0); return(0);
} }
@ -1727,7 +1729,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path,
return(0); return(0);
} }
if ( S_ISREG(stat_buf.st_mode) ) { if (S_ISREG(stat_buf.st_mode)) {
// regular file // regular file
switch (type) { switch (type) {
// use CMOS reserved types // use CMOS reserved types
@ -1786,7 +1788,7 @@ bx_bool bx_floppy_ctrl_c::evaluate_media(Bit8u devtype, Bit8u type, char *path,
return (media->sectors > 0); // success return (media->sectors > 0); // success
} }
else if ( S_ISCHR(stat_buf.st_mode) else if (S_ISCHR(stat_buf.st_mode)
#if BX_WITH_MACOS == 0 #if BX_WITH_MACOS == 0
#ifdef S_ISBLK #ifdef S_ISBLK
|| S_ISBLK(stat_buf.st_mode) || S_ISBLK(stat_buf.st_mode)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: guest2host.cc,v 1.15 2006-03-07 18:16:40 sshwarts Exp $ // $Id: guest2host.cc,v 1.16 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,8 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
#include "iodev.h" #include "iodev.h"
#define LOG_THIS bx_g2h. #define LOG_THIS bx_g2h.
@ -50,7 +49,7 @@ bx_g2h_c::~bx_g2h_c()
void bx_g2h_c::init(void) void bx_g2h_c::init(void)
{ {
BX_DEBUG(("Init $Id: guest2host.cc,v 1.15 2006-03-07 18:16:40 sshwarts Exp $")); BX_DEBUG(("Init $Id: guest2host.cc,v 1.16 2008-02-15 22:05:42 sshwarts Exp $"));
// Reserve a dword port for this interface // Reserve a dword port for this interface
for (Bit32u addr=BX_G2H_PORT; addr<=(BX_G2H_PORT+3); addr++) { for (Bit32u addr=BX_G2H_PORT; addr<=(BX_G2H_PORT+3); addr++) {
bx_devices.register_io_read_handler(&bx_g2h, bx_devices.register_io_read_handler(&bx_g2h,
@ -83,8 +82,8 @@ unsigned bx_g2h_c::acquire_channel(bx_g2h_callback_t f)
unsigned bx_g2h_c::deacquire_channel(unsigned channel) unsigned bx_g2h_c::deacquire_channel(unsigned channel)
{ {
if ( (channel >= BX_MAX_G2H_CHANNELS) || if ((channel >= BX_MAX_G2H_CHANNELS) ||
(bx_g2h.s.callback[channel].used==0) ) (bx_g2h.s.callback[channel].used==0))
{ {
BX_PANIC(("g2h: attempt to deacquire channel %u: not acquired", channel)); BX_PANIC(("g2h: attempt to deacquire channel %u: not acquired", channel));
} }
@ -119,7 +118,7 @@ void bx_g2h_c::outp_handler(void *this_ptr, Bit32u addr, Bit32u val32, unsigned
if (io_len != 4) if (io_len != 4)
BX_PANIC(("g2h: IO write not dword.")); BX_PANIC(("g2h: IO write not dword."));
if ( (bx_g2h.s.packet_count==0) && (val32!=BX_G2H_MAGIC) ) { if ((bx_g2h.s.packet_count==0) && (val32!=BX_G2H_MAGIC)) {
BX_INFO(("g2h: IO W: Not magic header.")); BX_INFO(("g2h: IO W: Not magic header."));
return; return;
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: harddrv.cc,v 1.207 2008-02-07 20:43:13 sshwarts Exp $ // $Id: harddrv.cc,v 1.208 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,13 +23,12 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Useful docs: // Useful docs:
// AT Attachment with Packet Interface // AT Attachment with Packet Interface
// working draft by T13 at www.t13.org // working draft by T13 at www.t13.org
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing. // is used to know when we are exporting symbols and when we are importing.
@ -174,7 +173,7 @@ void bx_hard_drive_c::init(void)
char ata_name[20]; char ata_name[20];
bx_list_c *base; bx_list_c *base;
BX_DEBUG(("Init $Id: harddrv.cc,v 1.207 2008-02-07 20:43:13 sshwarts Exp $")); BX_DEBUG(("Init $Id: harddrv.cc,v 1.208 2008-02-15 22:05:42 sshwarts Exp $"));
for (channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) { for (channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
sprintf(ata_name, "ata.%d.resources", channel); sprintf(ata_name, "ata.%d.resources", channel);
@ -185,9 +184,10 @@ void bx_hard_drive_c::init(void)
BX_HD_THIS channels[channel].irq = SIM->get_param_num("irq", base)->get(); BX_HD_THIS channels[channel].irq = SIM->get_param_num("irq", base)->get();
// Coherency check // Coherency check
if ( (BX_HD_THIS channels[channel].ioaddr1 == 0) || if ((BX_HD_THIS channels[channel].ioaddr1 == 0) ||
(BX_HD_THIS channels[channel].ioaddr2 == 0) || (BX_HD_THIS channels[channel].ioaddr2 == 0) ||
(BX_HD_THIS channels[channel].irq == 0) ) { (BX_HD_THIS channels[channel].irq == 0))
{
BX_PANIC(("incoherency for ata channel %d: io1=0x%x, io2=%x, irq=%d", BX_PANIC(("incoherency for ata channel %d: io1=0x%x, io2=%x, irq=%d",
channel, channel,
BX_HD_THIS channels[channel].ioaddr1, BX_HD_THIS channels[channel].ioaddr1,
@ -288,7 +288,7 @@ void bx_hard_drive_c::init(void)
} }
if (SIM->get_param_enum("type", base)->get() == BX_ATA_DEVICE_DISK) { if (SIM->get_param_enum("type", base)->get() == BX_ATA_DEVICE_DISK) {
BX_DEBUG(( "Hard-Disk on target %d/%d",channel,device)); BX_DEBUG(("Hard-Disk on target %d/%d",channel,device));
BX_HD_THIS channels[channel].drives[device].device_type = IDE_DISK; BX_HD_THIS channels[channel].drives[device].device_type = IDE_DISK;
sprintf(sbtext, "HD:%d-%s", channel, device?"S":"M"); sprintf(sbtext, "HD:%d-%s", channel, device?"S":"M");
BX_HD_THIS channels[channel].drives[device].statusbar_id = BX_HD_THIS channels[channel].drives[device].statusbar_id =
@ -450,7 +450,7 @@ void bx_hard_drive_c::init(void)
BX_PANIC(("ata%d-%d image doesn't support geometry detection", channel, device)); BX_PANIC(("ata%d-%d image doesn't support geometry detection", channel, device));
} }
} else if (SIM->get_param_enum("type", base)->get() == BX_ATA_DEVICE_CDROM) { } else if (SIM->get_param_enum("type", base)->get() == BX_ATA_DEVICE_CDROM) {
BX_DEBUG(( "CDROM on target %d/%d",channel,device)); BX_DEBUG(("CDROM on target %d/%d",channel,device));
BX_HD_THIS channels[channel].drives[device].device_type = IDE_CDROM; BX_HD_THIS channels[channel].drives[device].device_type = IDE_CDROM;
BX_HD_THIS channels[channel].drives[device].cdrom.locked = 0; BX_HD_THIS channels[channel].drives[device].cdrom.locked = 0;
BX_HD_THIS channels[channel].drives[device].sense.sense_key = SENSE_NONE; BX_HD_THIS channels[channel].drives[device].sense.sense_key = SENSE_NONE;
@ -491,13 +491,13 @@ void bx_hard_drive_c::init(void)
if (SIM->get_param_enum("status", base)->get() == BX_INSERTED) { if (SIM->get_param_enum("status", base)->get() == BX_INSERTED) {
if (BX_HD_THIS channels[channel].drives[device].cdrom.cd->insert_cdrom()) { if (BX_HD_THIS channels[channel].drives[device].cdrom.cd->insert_cdrom()) {
BX_INFO(( "Media present in CD-ROM drive")); BX_INFO(("Media present in CD-ROM drive"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 1; BX_HD_THIS channels[channel].drives[device].cdrom.ready = 1;
Bit32u capacity = BX_HD_THIS channels[channel].drives[device].cdrom.cd->capacity(); Bit32u capacity = BX_HD_THIS channels[channel].drives[device].cdrom.cd->capacity();
BX_HD_THIS channels[channel].drives[device].cdrom.capacity = capacity; BX_HD_THIS channels[channel].drives[device].cdrom.capacity = capacity;
BX_INFO(("Capacity is %d sectors (%.2f MB)", capacity, (float)capacity / 512.0)); BX_INFO(("Capacity is %d sectors (%.2f MB)", capacity, (float)capacity / 512.0));
} else { } else {
BX_INFO(( "Could not locate CD-ROM, continuing with media not present")); BX_INFO(("Could not locate CD-ROM, continuing with media not present"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0; BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
SIM->get_param_enum("status", base)->set(BX_EJECTED); SIM->get_param_enum("status", base)->set(BX_EJECTED);
} }
@ -505,7 +505,7 @@ void bx_hard_drive_c::init(void)
else else
#endif #endif
{ {
BX_INFO(( "Media not present in CD-ROM drive" )); BX_INFO(("Media not present in CD-ROM drive"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0; BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
} }
} }
@ -640,8 +640,7 @@ void bx_hard_drive_c::init(void)
BX_INFO(("Using boot sequence %s, %s, %s", BX_INFO(("Using boot sequence %s, %s, %s",
SIM->get_param_enum(BXPN_BOOTDRIVE1)->get_selected(), SIM->get_param_enum(BXPN_BOOTDRIVE1)->get_selected(),
SIM->get_param_enum(BXPN_BOOTDRIVE2)->get_selected(), SIM->get_param_enum(BXPN_BOOTDRIVE2)->get_selected(),
SIM->get_param_enum(BXPN_BOOTDRIVE3)->get_selected() SIM->get_param_enum(BXPN_BOOTDRIVE3)->get_selected()));
));
DEV_cmos_set_reg(0x3d, SIM->get_param_enum(BXPN_BOOTDRIVE1)->get() | DEV_cmos_set_reg(0x3d, SIM->get_param_enum(BXPN_BOOTDRIVE1)->get() |
(SIM->get_param_enum(BXPN_BOOTDRIVE2)->get() << 4)); (SIM->get_param_enum(BXPN_BOOTDRIVE2)->get() << 4));
@ -735,7 +734,7 @@ void bx_hard_drive_c::iolight_timer()
for (unsigned device=0; device<2; device++) { for (unsigned device=0; device<2; device++) {
if (BX_HD_THIS channels[channel].drives[device].iolight_counter > 0) { if (BX_HD_THIS channels[channel].drives[device].iolight_counter > 0) {
if (--BX_HD_THIS channels[channel].drives[device].iolight_counter) if (--BX_HD_THIS channels[channel].drives[device].iolight_counter)
bx_pc_system.activate_timer( BX_HD_THIS iolight_timer_index, 100000, 0 ); bx_pc_system.activate_timer(BX_HD_THIS iolight_timer_index, 100000, 0);
else else
bx_gui->statusbar_setitem(BX_HD_THIS channels[channel].drives[device].statusbar_id, 0); bx_gui->statusbar_setitem(BX_HD_THIS channels[channel].drives[device].statusbar_id, 0);
} }
@ -941,7 +940,7 @@ Bit32u bx_hard_drive_c::read(Bit32u address, unsigned io_len)
if (!BX_SELECTED_DRIVE(channel).iolight_counter) if (!BX_SELECTED_DRIVE(channel).iolight_counter)
bx_gui->statusbar_setitem(BX_SELECTED_DRIVE(channel).statusbar_id, 1); bx_gui->statusbar_setitem(BX_SELECTED_DRIVE(channel).statusbar_id, 1);
BX_SELECTED_DRIVE(channel).iolight_counter = 5; BX_SELECTED_DRIVE(channel).iolight_counter = 5;
bx_pc_system.activate_timer( BX_HD_THIS iolight_timer_index, 100000, 0 ); bx_pc_system.activate_timer(BX_HD_THIS iolight_timer_index, 100000, 0);
if (!BX_SELECTED_DRIVE(channel).cdrom.cd->read_block(BX_SELECTED_CONTROLLER(channel).buffer, if (!BX_SELECTED_DRIVE(channel).cdrom.cd->read_block(BX_SELECTED_CONTROLLER(channel).buffer,
BX_SELECTED_DRIVE(channel).cdrom.next_lba, BX_SELECTED_DRIVE(channel).cdrom.next_lba,
BX_SELECTED_CONTROLLER(channel).buffer_size)) BX_SELECTED_CONTROLLER(channel).buffer_size))
@ -1289,7 +1288,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
quantumsMax = quantumsMax =
(BX_SELECTED_CONTROLLER(channel).buffer_size - BX_SELECTED_CONTROLLER(channel).buffer_index) / io_len; (BX_SELECTED_CONTROLLER(channel).buffer_size - BX_SELECTED_CONTROLLER(channel).buffer_index) / io_len;
if ( quantumsMax == 0) if (quantumsMax == 0)
BX_PANIC(("IO write(0x%04x): not enough space for write", address)); BX_PANIC(("IO write(0x%04x): not enough space for write", address));
DEV_bulk_io_quantum_transferred() = DEV_bulk_io_quantum_transferred() =
DEV_bulk_io_quantum_requested(); DEV_bulk_io_quantum_requested();
@ -2039,7 +2038,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
// b4: DRV // b4: DRV
// b3..0 HD3..HD0 // b3..0 HD3..HD0
{ {
if ( (value & 0xa0) != 0xa0 ) // 1x1xxxxx if ((value & 0xa0) != 0xa0) // 1x1xxxxx
BX_DEBUG(("IO write 0x%04x (%02x): not 1x1xxxxxb", address, (unsigned) value)); BX_DEBUG(("IO write 0x%04x (%02x): not 1x1xxxxxb", address, (unsigned) value));
Bit32u drvsel = BX_HD_THIS channels[channel].drive_select = (value >> 4) & 0x01; Bit32u drvsel = BX_HD_THIS channels[channel].drive_select = (value >> 4) & 0x01;
WRITE_HEAD_NO(channel,value & 0xf); WRITE_HEAD_NO(channel,value & 0xf);
@ -2064,7 +2063,7 @@ void bx_hard_drive_c::write(Bit32u address, Bit32u value, unsigned io_len)
BX_ERROR(("ata%d: command 0x%02x sent, controller BSY bit set", channel, value)); BX_ERROR(("ata%d: command 0x%02x sent, controller BSY bit set", channel, value));
break; break;
} }
if ( (value & 0xf0) == 0x10 ) if ((value & 0xf0) == 0x10)
value = 0x10; value = 0x10;
BX_SELECTED_CONTROLLER(channel).status.err = 0; BX_SELECTED_CONTROLLER(channel).status.err = 0;
switch (value) { switch (value) {
@ -3310,7 +3309,7 @@ unsigned bx_hard_drive_c::get_cd_media_status(Bit32u handle)
Bit8u channel = handle / 2; Bit8u channel = handle / 2;
Bit8u device = handle % 2; Bit8u device = handle % 2;
return( BX_HD_THIS channels[channel].drives[device].cdrom.ready ); return BX_HD_THIS channels[channel].drives[device].cdrom.ready;
} }
unsigned bx_hard_drive_c::set_cd_media_status(Bit32u handle, unsigned status) unsigned bx_hard_drive_c::set_cd_media_status(Bit32u handle, unsigned status)
@ -3318,7 +3317,7 @@ unsigned bx_hard_drive_c::set_cd_media_status(Bit32u handle, unsigned status)
char ata_name[20]; char ata_name[20];
BX_DEBUG (("set_cd_media_status handle=%d status=%d", handle, status)); BX_DEBUG (("set_cd_media_status handle=%d status=%d", handle, status));
if ( handle >= BX_MAX_ATA_CHANNEL*2 ) return 0; if (handle >= BX_MAX_ATA_CHANNEL*2) return 0;
Bit8u channel = handle / 2; Bit8u channel = handle / 2;
Bit8u device = handle % 2; Bit8u device = handle % 2;
@ -3346,7 +3345,7 @@ unsigned bx_hard_drive_c::set_cd_media_status(Bit32u handle, unsigned status)
// insert cdrom // insert cdrom
#ifdef LOWLEVEL_CDROM #ifdef LOWLEVEL_CDROM
if (BX_HD_THIS channels[channel].drives[device].cdrom.cd->insert_cdrom(SIM->get_param_string("path", base)->getptr())) { if (BX_HD_THIS channels[channel].drives[device].cdrom.cd->insert_cdrom(SIM->get_param_string("path", base)->getptr())) {
BX_INFO(( "Media present in CD-ROM drive")); BX_INFO(("Media present in CD-ROM drive"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 1; BX_HD_THIS channels[channel].drives[device].cdrom.ready = 1;
Bit32u capacity = BX_HD_THIS channels[channel].drives[device].cdrom.cd->capacity(); Bit32u capacity = BX_HD_THIS channels[channel].drives[device].cdrom.cd->capacity();
BX_HD_THIS channels[channel].drives[device].cdrom.capacity = capacity; BX_HD_THIS channels[channel].drives[device].cdrom.capacity = capacity;
@ -3360,7 +3359,7 @@ unsigned bx_hard_drive_c::set_cd_media_status(Bit32u handle, unsigned status)
else else
#endif #endif
{ {
BX_INFO(( "Could not locate CD-ROM, continuing with media not present")); BX_INFO(("Could not locate CD-ROM, continuing with media not present"));
BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0; BX_HD_THIS channels[channel].drives[device].cdrom.ready = 0;
SIM->get_param_enum("status", base)->set(BX_EJECTED); SIM->get_param_enum("status", base)->set(BX_EJECTED);
} }
@ -3398,7 +3397,7 @@ bx_bool bx_hard_drive_c::bmdma_read_sector(Bit8u channel, Bit8u *buffer, Bit32u
if (!BX_SELECTED_DRIVE(channel).iolight_counter) if (!BX_SELECTED_DRIVE(channel).iolight_counter)
bx_gui->statusbar_setitem(BX_SELECTED_DRIVE(channel).statusbar_id, 1); bx_gui->statusbar_setitem(BX_SELECTED_DRIVE(channel).statusbar_id, 1);
BX_SELECTED_DRIVE(channel).iolight_counter = 5; BX_SELECTED_DRIVE(channel).iolight_counter = 5;
bx_pc_system.activate_timer( BX_HD_THIS iolight_timer_index, 100000, 0 ); bx_pc_system.activate_timer(BX_HD_THIS iolight_timer_index, 100000, 0);
if (!BX_SELECTED_DRIVE(channel).cdrom.cd->read_block(buffer, BX_SELECTED_DRIVE(channel).cdrom.next_lba, if (!BX_SELECTED_DRIVE(channel).cdrom.cd->read_block(buffer, BX_SELECTED_DRIVE(channel).cdrom.next_lba,
BX_SELECTED_CONTROLLER(channel).buffer_size)) BX_SELECTED_CONTROLLER(channel).buffer_size))
{ {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: hdimage.cc,v 1.15 2008-02-05 22:57:42 sshwarts Exp $ // $Id: hdimage.cc,v 1.16 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -205,7 +205,7 @@ void concat_image_t::close()
Bit64s concat_image_t::lseek(Bit64s offset, int whence) Bit64s concat_image_t::lseek(Bit64s offset, int whence)
{ {
if ((offset % 512) != 0) if ((offset % 512) != 0)
BX_PANIC( ("lseek HD with offset not multiple of 512")); BX_PANIC(("lseek HD with offset not multiple of 512"));
BX_DEBUG(("concat_image_t.lseek(%d)", whence)); BX_DEBUG(("concat_image_t.lseek(%d)", whence));
// is this offset in this disk image? // is this offset in this disk image?
if (offset < thismin) { if (offset < thismin) {
@ -252,7 +252,7 @@ ssize_t concat_image_t::read(void* buf, size_t count)
// This can be supported pretty easily, but needs additional checks for // This can be supported pretty easily, but needs additional checks for
// end of a partial image. // end of a partial image.
if (!seek_was_last_op) if (!seek_was_last_op)
BX_PANIC( ("no seek before read")); BX_PANIC(("no seek before read"));
return ::read(fd, (char*) buf, count); return ::read(fd, (char*) buf, count);
} }
@ -263,7 +263,7 @@ ssize_t concat_image_t::write(const void* buf, size_t count)
// This can be supported pretty easily, but needs additional checks for // This can be supported pretty easily, but needs additional checks for
// end of a partial image. // end of a partial image.
if (!seek_was_last_op) if (!seek_was_last_op)
BX_PANIC( ("no seek before write")); BX_PANIC(("no seek before write"));
return ::write(fd, (char*) buf, count); return ::write(fd, (char*) buf, count);
} }
@ -480,9 +480,9 @@ Bit64s sparse_image_t::lseek(Bit64s offset, int whence)
//showpagetable(pagetable, header.numpages); //showpagetable(pagetable, header.numpages);
if ((offset % 512) != 0) if ((offset % 512) != 0)
BX_PANIC( ("lseek HD with offset not multiple of 512")); BX_PANIC(("lseek HD with offset not multiple of 512"));
if (whence != SEEK_SET) if (whence != SEEK_SET)
BX_PANIC( ("lseek HD with whence not SEEK_SET")); BX_PANIC(("lseek HD with whence not SEEK_SET"));
BX_DEBUG(("sparse_image_t.lseek(%d)", whence)); BX_DEBUG(("sparse_image_t.lseek(%d)", whence));
@ -1098,11 +1098,11 @@ Bit64u redolog_t::get_size()
Bit64s redolog_t::lseek(Bit64s offset, int whence) Bit64s redolog_t::lseek(Bit64s offset, int whence)
{ {
if ((offset % 512) != 0) { if ((offset % 512) != 0) {
BX_PANIC( ("redolog : lseek HD with offset not multiple of 512")); BX_PANIC(("redolog : lseek HD with offset not multiple of 512"));
return -1; return -1;
} }
if (whence != SEEK_SET) { if (whence != SEEK_SET) {
BX_PANIC( ("redolog : lseek HD with whence not SEEK_SET")); BX_PANIC(("redolog : lseek HD with whence not SEEK_SET"));
return -1; return -1;
} }
if (offset > (Bit64s)dtoh64(header.specific.disk)) if (offset > (Bit64s)dtoh64(header.specific.disk))
@ -1124,7 +1124,7 @@ ssize_t redolog_t::read(void* buf, size_t count)
Bit64s bloc_offset, bitmap_offset; Bit64s bloc_offset, bitmap_offset;
if (count != 512) if (count != 512)
BX_PANIC( ("redolog : read HD with count not 512")); BX_PANIC(("redolog : read HD with count not 512"));
BX_DEBUG(("redolog : reading index %d, mapping to %d", extent_index, dtoh32(catalog[extent_index]))); BX_DEBUG(("redolog : reading index %d, mapping to %d", extent_index, dtoh32(catalog[extent_index])));
@ -1151,7 +1151,7 @@ ssize_t redolog_t::read(void* buf, size_t count)
return 0; return 0;
} }
if ( ((bitmap[extent_offset/8] >> (extent_offset%8)) & 0x01) == 0x00 ) if (((bitmap[extent_offset/8] >> (extent_offset%8)) & 0x01) == 0x00)
{ {
BX_DEBUG(("read not in redolog")); BX_DEBUG(("read not in redolog"));
@ -1172,7 +1172,7 @@ ssize_t redolog_t::write(const void* buf, size_t count)
bx_bool update_catalog = 0; bx_bool update_catalog = 0;
if (count != 512) if (count != 512)
BX_PANIC( ("redolog : write HD with count not 512")); BX_PANIC(("redolog : write HD with count not 512"));
BX_DEBUG(("redolog : writing index %d, mapping to %d", extent_index, dtoh32(catalog[extent_index]))); BX_DEBUG(("redolog : writing index %d, mapping to %d", extent_index, dtoh32(catalog[extent_index])));
if (dtoh32(catalog[extent_index]) == REDOLOG_PAGE_NOT_ALLOCATED) if (dtoh32(catalog[extent_index]) == REDOLOG_PAGE_NOT_ALLOCATED)
@ -1233,7 +1233,7 @@ ssize_t redolog_t::write(const void* buf, size_t count)
} }
// If bloc does not belong to extent yet // If bloc does not belong to extent yet
if ( ((bitmap[extent_offset/8] >> (extent_offset%8)) & 0x01) == 0x00 ) if (((bitmap[extent_offset/8] >> (extent_offset%8)) & 0x01) == 0x00)
{ {
bitmap[extent_offset/8] |= 1 << (extent_offset%8); bitmap[extent_offset/8] |= 1 << (extent_offset%8);
::lseek(fd, (off_t)bitmap_offset, SEEK_SET); ::lseek(fd, (off_t)bitmap_offset, SEEK_SET);
@ -1326,15 +1326,15 @@ int undoable_image_t::open(const char* pathname)
hd_size = ro_disk->hd_size; hd_size = ro_disk->hd_size;
// if redolog name was set // if redolog name was set
if ( redolog_name != NULL) { if (redolog_name != NULL) {
if ( strcmp(redolog_name, "") != 0 ) { if (strcmp(redolog_name, "") != 0) {
logname = (char*)malloc(strlen(redolog_name) + 1); logname = (char*)malloc(strlen(redolog_name) + 1);
strcpy(logname, redolog_name); strcpy(logname, redolog_name);
} }
} }
// Otherwise we make up the redolog filename from the pathname // Otherwise we make up the redolog filename from the pathname
if ( logname == NULL) { if (logname == NULL) {
logname = (char*)malloc(strlen(pathname) + UNDOABLE_REDOLOG_EXTENSION_LENGTH + 1); logname = (char*)malloc(strlen(pathname) + UNDOABLE_REDOLOG_EXTENSION_LENGTH + 1);
sprintf(logname, "%s%s", pathname, UNDOABLE_REDOLOG_EXTENSION); sprintf(logname, "%s%s", pathname, UNDOABLE_REDOLOG_EXTENSION);
} }
@ -1420,8 +1420,8 @@ int volatile_image_t::open(const char* pathname)
hd_size = ro_disk->hd_size; hd_size = ro_disk->hd_size;
// if redolog name was set // if redolog name was set
if ( redolog_name != NULL) { if (redolog_name != NULL) {
if ( strcmp(redolog_name, "") != 0 ) { if (strcmp(redolog_name, "") != 0) {
logname = redolog_name; logname = redolog_name;
} }
} }
@ -1586,15 +1586,15 @@ int z_undoable_image_t::open(const char* pathname)
return -1; return -1;
// If redolog name was set // If redolog name was set
if ( redolog_name != NULL) { if (redolog_name != NULL) {
if ( strcmp(redolog_name, "") != 0) { if (strcmp(redolog_name, "") != 0) {
logname = (char*)malloc(strlen(redolog_name) + 1); logname = (char*)malloc(strlen(redolog_name) + 1);
strcpy (logname, redolog_name); strcpy (logname, redolog_name);
} }
} }
// Otherwise we make up the redolog filename from the pathname // Otherwise we make up the redolog filename from the pathname
if ( logname == NULL) { if (logname == NULL) {
logname = (char*)malloc(strlen(pathname) + UNDOABLE_REDOLOG_EXTENSION_LENGTH + 1); logname = (char*)malloc(strlen(pathname) + UNDOABLE_REDOLOG_EXTENSION_LENGTH + 1);
sprintf (logname, "%s%s", pathname, UNDOABLE_REDOLOG_EXTENSION); sprintf (logname, "%s%s", pathname, UNDOABLE_REDOLOG_EXTENSION);
} }
@ -1677,7 +1677,7 @@ int z_volatile_image_t::open(const char* pathname)
// if redolog name was set // if redolog name was set
if (redolog_name != NULL) { if (redolog_name != NULL) {
if (strcmp(redolog_name, "") !=0 ) { if (strcmp(redolog_name, "") != 0) {
logname = redolog_name; logname = redolog_name;
} }
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: iodebug.cc,v 1.24 2008-02-15 19:03:54 sshwarts Exp $ // $Id: iodebug.cc,v 1.25 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
#include "bochs.h" #include "bochs.h"
@ -292,8 +292,8 @@ void bx_iodebug_c::add_range(Bit32u addr_start, Bit32u addr_end)
{ {
for(unsigned i=0;i<BX_IODEBUG_MAX_AREAS;i++) for(unsigned i=0;i<BX_IODEBUG_MAX_AREAS;i++)
{ {
if( !bx_iodebug_s.monitored_mem_areas_start[i] && if(!bx_iodebug_s.monitored_mem_areas_start[i] &&
!bx_iodebug_s.monitored_mem_areas_end[i] ) !bx_iodebug_s.monitored_mem_areas_end[i])
{ {
bx_iodebug_s.monitored_mem_areas_start[i] = addr_start; bx_iodebug_s.monitored_mem_areas_start[i] = addr_start;
bx_iodebug_s.monitored_mem_areas_end[i] = addr_end; bx_iodebug_s.monitored_mem_areas_end[i] = addr_end;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: iodebug.h,v 1.9 2006-03-07 21:11:16 sshwarts Exp $ // $Id: iodebug.h,v 1.10 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
#ifndef _BX_IODEBUG_H #ifndef _BX_IODEBUG_H
@ -17,8 +17,8 @@ public:
virtual ~bx_iodebug_c() {} virtual ~bx_iodebug_c() {}
virtual void init(void); virtual void init(void);
virtual void reset (unsigned type) {} virtual void reset (unsigned type) {}
static void mem_write( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data); static void mem_write(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data);
static void mem_read( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data); static void mem_read (BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data);
private: private:
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.90 2008-01-26 22:24:02 sshwarts Exp $ // $Id: iodev.h,v 1.91 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -115,7 +115,7 @@ public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#define STUBFUNC(dev,method) \ #define STUBFUNC(dev,method) \
pluginlog->panic("%s called in %s stub. you must not have loaded the %s plugin", #dev, #method, #dev ) pluginlog->panic("%s called in %s stub. you must not have loaded the %s plugin", #dev, #method, #dev)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
class BOCHSAPI bx_keyb_stub_c : public bx_devmodel_c { class BOCHSAPI bx_keyb_stub_c : public bx_devmodel_c {
@ -405,13 +405,13 @@ public:
bx_bool register_io_write_handler(void *this_ptr, bx_write_handler_t f, bx_bool register_io_write_handler(void *this_ptr, bx_write_handler_t f,
Bit32u addr, const char *name, Bit8u mask); Bit32u addr, const char *name, Bit8u mask);
bx_bool unregister_io_write_handler(void *this_ptr, bx_write_handler_t f, bx_bool unregister_io_write_handler(void *this_ptr, bx_write_handler_t f,
Bit32u addr, Bit8u mask ); Bit32u addr, Bit8u mask);
bx_bool register_io_read_handler_range(void *this_ptr, bx_read_handler_t f, bx_bool register_io_read_handler_range(void *this_ptr, bx_read_handler_t f,
Bit32u begin_addr, Bit32u end_addr, Bit32u begin_addr, Bit32u end_addr,
const char *name, Bit8u mask); const char *name, Bit8u mask);
bx_bool register_io_write_handler_range(void *this_ptr, bx_write_handler_t f, bx_bool register_io_write_handler_range(void *this_ptr, bx_write_handler_t f,
Bit32u begin_addr, Bit32u end_addr, Bit32u begin_addr, Bit32u end_addr,
const char *name, Bit8u mask ); const char *name, Bit8u mask);
bx_bool unregister_io_read_handler_range(void *this_ptr, bx_read_handler_t f, bx_bool unregister_io_read_handler_range(void *this_ptr, bx_read_handler_t f,
Bit32u begin, Bit32u end, Bit8u mask); Bit32u begin, Bit32u end, Bit8u mask);
bx_bool unregister_io_write_handler_range(void *this_ptr, bx_write_handler_t f, bx_bool unregister_io_write_handler_range(void *this_ptr, bx_write_handler_t f,
@ -598,8 +598,8 @@ private:
#endif /* NO_DEVICE_INCLUDES */ #endif /* NO_DEVICE_INCLUDES */
#if ( BX_PROVIDE_DEVICE_MODELS==1 ) #if BX_PROVIDE_DEVICE_MODELS
BOCHSAPI extern bx_devices_c bx_devices; BOCHSAPI extern bx_devices_c bx_devices;
#endif #endif
#endif /* IODEV_H */ #endif /* IODEV_H */

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: keyboard.cc,v 1.132 2008-01-26 22:24:02 sshwarts Exp $ // $Id: keyboard.cc,v 1.133 2008-02-15 22:05:42 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,7 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Now features proper implementation of keyboard opcodes 0xF4 to 0xF6 // Now features proper implementation of keyboard opcodes 0xF4 to 0xF6
// Silently ignores PS/2 keyboard extensions (0xF7 to 0xFD) // Silently ignores PS/2 keyboard extensions (0xF7 to 0xFD)
@ -126,7 +126,7 @@ void bx_keyb_c::resetinternals(bx_bool powerup)
void bx_keyb_c::init(void) void bx_keyb_c::init(void)
{ {
BX_DEBUG(("Init $Id: keyboard.cc,v 1.132 2008-01-26 22:24:02 sshwarts Exp $")); BX_DEBUG(("Init $Id: keyboard.cc,v 1.133 2008-02-15 22:05:42 sshwarts Exp $"));
Bit32u i; Bit32u i;
DEV_register_irq(1, "8042 Keyboard controller"); DEV_register_irq(1, "8042 Keyboard controller");
@ -140,7 +140,7 @@ void bx_keyb_c::init(void)
0x0060, "8042 Keyboard controller", 1); 0x0060, "8042 Keyboard controller", 1);
DEV_register_iowrite_handler(this, write_handler, DEV_register_iowrite_handler(this, write_handler,
0x0064, "8042 Keyboard controller", 1); 0x0064, "8042 Keyboard controller", 1);
BX_KEY_THIS timer_handle = bx_pc_system.register_timer( this, timer_handler, BX_KEY_THIS timer_handle = bx_pc_system.register_timer(this, timer_handler,
SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->get(), 1, 1, SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->get(), 1, 1,
"8042 Keyboard controller"); "8042 Keyboard controller");
@ -544,7 +544,7 @@ void bx_keyb_c::write(Bit32u address, Bit32u value, unsigned io_len)
else if (BX_KEY_THIS s.kbd_controller.allow_irq1 && BX_KEY_THIS s.kbd_controller.outb) else if (BX_KEY_THIS s.kbd_controller.allow_irq1 && BX_KEY_THIS s.kbd_controller.outb)
BX_KEY_THIS s.kbd_controller.irq1_requested = 1; BX_KEY_THIS s.kbd_controller.irq1_requested = 1;
BX_DEBUG(( " allow_irq12 set to %u", BX_DEBUG((" allow_irq12 set to %u",
(unsigned) BX_KEY_THIS s.kbd_controller.allow_irq12)); (unsigned) BX_KEY_THIS s.kbd_controller.allow_irq12));
if (!scan_convert) if (!scan_convert)
BX_INFO(("keyboard: scan convert turned off")); BX_INFO(("keyboard: scan convert turned off"));
@ -559,7 +559,7 @@ void bx_keyb_c::write(Bit32u address, Bit32u value, unsigned io_len)
BX_SET_ENABLE_A20((value & 0x02) != 0); BX_SET_ENABLE_A20((value & 0x02) != 0);
if (!(value & 0x01)) { if (!(value & 0x01)) {
BX_INFO(("write output port : processor reset requested!")); BX_INFO(("write output port : processor reset requested!"));
bx_pc_system.Reset( BX_RESET_SOFTWARE); bx_pc_system.Reset(BX_RESET_SOFTWARE);
} }
break; break;
case 0xd4: // Write to mouse case 0xd4: // Write to mouse
@ -1086,14 +1086,14 @@ void bx_keyb_c::kbd_ctrl_to_kbd(Bit8u value)
if (BX_KEY_THIS s.kbd_controller.expecting_scancodes_set) { if (BX_KEY_THIS s.kbd_controller.expecting_scancodes_set) {
BX_KEY_THIS s.kbd_controller.expecting_scancodes_set = 0; BX_KEY_THIS s.kbd_controller.expecting_scancodes_set = 0;
if( value != 0 ) { if(value != 0) {
if( value<4 ) { if(value < 4) {
BX_KEY_THIS s.kbd_controller.current_scancodes_set = (value-1); BX_KEY_THIS s.kbd_controller.current_scancodes_set = (value-1);
BX_INFO(("Switched to scancode set %d", BX_INFO(("Switched to scancode set %d",
(unsigned) BX_KEY_THIS s.kbd_controller.current_scancodes_set + 1)); (unsigned) BX_KEY_THIS s.kbd_controller.current_scancodes_set + 1));
kbd_enQ(0xFA); kbd_enQ(0xFA);
} else { } else {
BX_ERROR(("Received scancodes set out of range: %d", value )); BX_ERROR(("Received scancodes set out of range: %d", value));
kbd_enQ(0xFF); // send ERROR kbd_enQ(0xFF); // send ERROR
} }
} else { } else {
@ -1222,11 +1222,11 @@ unsigned bx_keyb_c::periodic(Bit32u usec_delta)
{ {
/* static int multiple=0; */ /* static int multiple=0; */
static unsigned count_before_paste=0; static unsigned count_before_paste=0;
Bit8u retval; Bit8u retval;
UNUSED( usec_delta ); UNUSED(usec_delta);
if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled ) { if (BX_KEY_THIS s.kbd_controller.kbd_clock_enabled) {
if(++count_before_paste>=BX_KEY_THIS pastedelay) { if(++count_before_paste>=BX_KEY_THIS pastedelay) {
// after the paste delay, consider adding moving more chars // after the paste delay, consider adding moving more chars
// from the paste buffer to the keyboard buffer. // from the paste buffer to the keyboard buffer.
@ -1555,7 +1555,7 @@ void bx_keyb_c::create_mouse_packet(bool force_enq)
b1 = (button_state & 0x0f) | 0x08; // bit3 always set b1 = (button_state & 0x0f) | 0x08; // bit3 always set
if ( (delta_x>=0) && (delta_x<=255) ) { if ((delta_x>=0) && (delta_x<=255)) {
b2 = (Bit8u) delta_x; b2 = (Bit8u) delta_x;
BX_KEY_THIS s.mouse.delayed_dx-=delta_x; BX_KEY_THIS s.mouse.delayed_dx-=delta_x;
} }
@ -1574,7 +1574,7 @@ void bx_keyb_c::create_mouse_packet(bool force_enq)
BX_KEY_THIS s.mouse.delayed_dx+=256; BX_KEY_THIS s.mouse.delayed_dx+=256;
} }
if ( (delta_y>=0) && (delta_y<=255) ) { if ((delta_y>=0) && (delta_y<=255)) {
b3 = (Bit8u) delta_y; b3 = (Bit8u) delta_y;
BX_KEY_THIS s.mouse.delayed_dy-=delta_y; BX_KEY_THIS s.mouse.delayed_dy-=delta_y;
} }
@ -1654,7 +1654,7 @@ void bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned but
#endif #endif
// don't generate interrupts if we are in remote mode. // don't generate interrupts if we are in remote mode.
if ( BX_KEY_THIS s.mouse.mode == MOUSE_MODE_REMOTE) if (BX_KEY_THIS s.mouse.mode == MOUSE_MODE_REMOTE)
// is there any point in doing any work if we don't act on the result // is there any point in doing any work if we don't act on the result
// so go home. // so go home.
return; return;
@ -1677,7 +1677,7 @@ void bx_keyb_c::mouse_motion(int delta_x, int delta_y, int delta_z, unsigned but
BX_DEBUG(("[mouse] Dx=%d Dy=%d Dz=%d", delta_x, delta_y, delta_z)); BX_DEBUG(("[mouse] Dx=%d Dy=%d Dz=%d", delta_x, delta_y, delta_z));
#endif /* ifdef VERBOSE_KBD_DEBUG */ #endif /* ifdef VERBOSE_KBD_DEBUG */
if( (delta_x==0) && (delta_y==0) && (delta_z==0) && (BX_KEY_THIS s.mouse.button_status == (button_state & 0x7) ) ) { if ((delta_x==0) && (delta_y==0) && (delta_z==0) && (BX_KEY_THIS s.mouse.button_status == (button_state & 0x7))) {
BX_DEBUG(("Ignoring useless mouse_motion call:")); BX_DEBUG(("Ignoring useless mouse_motion call:"));
BX_DEBUG(("This should be fixed in the gui code.")); BX_DEBUG(("This should be fixed in the gui code."));
return; return;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: keyboard.h,v 1.41 2008-01-26 22:24:02 sshwarts Exp $ // $Id: keyboard.h,v 1.42 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -24,11 +24,9 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _PCKEY_H #ifndef _PCKEY_H
#define _PCKEY_H #define _PCKEY_H
#define BX_KBD_ELEMENTS 16 #define BX_KBD_ELEMENTS 16
#define BX_MOUSE_BUFF_SIZE 48 #define BX_MOUSE_BUFF_SIZE 48
@ -69,14 +67,14 @@ private:
BX_KEY_SMF Bit8u get_kbd_enable(void); BX_KEY_SMF Bit8u get_kbd_enable(void);
BX_KEY_SMF void service_paste_buf (); BX_KEY_SMF void service_paste_buf ();
BX_KEY_SMF void create_mouse_packet(bool force_enq); BX_KEY_SMF void create_mouse_packet(bool force_enq);
BX_KEY_SMF unsigned periodic( Bit32u usec_delta ); BX_KEY_SMF unsigned periodic(Bit32u usec_delta);
static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len); static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
#if !BX_USE_KEY_SMF #if !BX_USE_KEY_SMF
void write(Bit32u address, Bit32u value, unsigned io_len); void write(Bit32u address, Bit32u value, unsigned io_len);
Bit32u read(Bit32u address, unsigned io_len); Bit32u read(Bit32u address, unsigned io_len);
#endif #endif
struct { struct {

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: ne2k.cc,v 1.96 2008-01-26 22:24:02 sshwarts Exp $ // $Id: ne2k.cc,v 1.97 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,6 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Peter Grehan (grehan@iprg.nokia.com) coded the initial version of this // Peter Grehan (grehan@iprg.nokia.com) coded the initial version of this
// NE2000/ether stuff. // NE2000/ether stuff.
@ -1129,7 +1130,7 @@ Bit32u bx_ne2k_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
#if !BX_USE_NE2K_SMF #if !BX_USE_NE2K_SMF
bx_ne2k_c *class_ptr = (bx_ne2k_c *) this_ptr; bx_ne2k_c *class_ptr = (bx_ne2k_c *) this_ptr;
return( class_ptr->read(address, io_len) ); return class_ptr->read(address, io_len);
} }
Bit32u bx_ne2k_c::read(Bit32u address, unsigned io_len) Bit32u bx_ne2k_c::read(Bit32u address, unsigned io_len)
@ -1401,7 +1402,7 @@ void bx_ne2k_c::init(void)
char devname[16]; char devname[16];
bx_list_c *base; bx_list_c *base;
BX_DEBUG(("Init $Id: ne2k.cc,v 1.96 2008-01-26 22:24:02 sshwarts Exp $")); BX_DEBUG(("Init $Id: ne2k.cc,v 1.97 2008-02-15 22:05:43 sshwarts Exp $"));
// Read in values from config interface // Read in values from config interface
base = (bx_list_c*) SIM->get_param(BXPN_NE2K); base = (bx_list_c*) SIM->get_param(BXPN_NE2K);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: pcipnic.cc,v 1.26 2008-01-26 22:24:02 sshwarts Exp $ // $Id: pcipnic.cc,v 1.27 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2003 Fen Systems Ltd. // Copyright (C) 2003 Fen Systems Ltd.
@ -18,6 +18,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
@ -211,19 +212,19 @@ Bit32u bx_pcipnic_c::read(Bit32u address, unsigned io_len)
offset = address - BX_PNIC_THIS s.base_ioaddr; offset = address - BX_PNIC_THIS s.base_ioaddr;
switch (offset) { switch (offset) {
case PNIC_REG_STAT : case PNIC_REG_STAT:
val = BX_PNIC_THIS s.rStatus; val = BX_PNIC_THIS s.rStatus;
break; break;
case PNIC_REG_LEN : case PNIC_REG_LEN:
val = BX_PNIC_THIS s.rLength; val = BX_PNIC_THIS s.rLength;
break; break;
case PNIC_REG_DATA : case PNIC_REG_DATA:
if ( BX_PNIC_THIS s.rDataCursor >= BX_PNIC_THIS s.rLength ) if (BX_PNIC_THIS s.rDataCursor >= BX_PNIC_THIS s.rLength)
BX_PANIC(("PNIC read at %u, beyond end of data register array", BX_PANIC(("PNIC read at %u, beyond end of data register array",
BX_PNIC_THIS s.rDataCursor)); BX_PNIC_THIS s.rDataCursor));
val = BX_PNIC_THIS s.rData[BX_PNIC_THIS s.rDataCursor ++]; val = BX_PNIC_THIS s.rData[BX_PNIC_THIS s.rDataCursor++];
break; break;
default : default :
@ -260,24 +261,24 @@ void bx_pcipnic_c::write(Bit32u address, Bit32u value, unsigned io_len)
offset = address - BX_PNIC_THIS s.base_ioaddr; offset = address - BX_PNIC_THIS s.base_ioaddr;
switch (offset) { switch (offset) {
case PNIC_REG_CMD : case PNIC_REG_CMD:
BX_PNIC_THIS s.rCmd = value; BX_PNIC_THIS s.rCmd = value;
BX_PNIC_THIS exec_command(); BX_PNIC_THIS exec_command();
break; break;
case PNIC_REG_LEN : case PNIC_REG_LEN:
if ( value > PNIC_DATA_SIZE ) if (value > PNIC_DATA_SIZE)
BX_PANIC(("PNIC bad length %u written to length register, max is %u", BX_PANIC(("PNIC bad length %u written to length register, max is %u",
value, PNIC_DATA_SIZE)); value, PNIC_DATA_SIZE));
BX_PNIC_THIS s.rLength = value; BX_PNIC_THIS s.rLength = value;
BX_PNIC_THIS s.rDataCursor = 0; BX_PNIC_THIS s.rDataCursor = 0;
break; break;
case PNIC_REG_DATA : case PNIC_REG_DATA:
if ( BX_PNIC_THIS s.rDataCursor >= BX_PNIC_THIS s.rLength ) if (BX_PNIC_THIS s.rDataCursor >= BX_PNIC_THIS s.rLength)
BX_PANIC(("PNIC write at %u, beyond end of data register array", BX_PANIC(("PNIC write at %u, beyond end of data register array",
BX_PNIC_THIS s.rDataCursor)); BX_PNIC_THIS s.rDataCursor));
BX_PNIC_THIS s.rData[BX_PNIC_THIS s.rDataCursor ++] = value; BX_PNIC_THIS s.rData[BX_PNIC_THIS s.rDataCursor++] = value;
break; break;
default: default:
@ -427,37 +428,37 @@ void bx_pcipnic_c::exec_command(void)
Bit16u status = PNIC_STATUS_UNKNOWN_CMD; Bit16u status = PNIC_STATUS_UNKNOWN_CMD;
Bit16u olength = 0; Bit16u olength = 0;
if ( ilength != BX_PNIC_THIS s.rDataCursor ) if (ilength != BX_PNIC_THIS s.rDataCursor)
BX_PANIC(("PNIC command issued with incomplete data (should be %u, is %u)", BX_PANIC(("PNIC command issued with incomplete data (should be %u, is %u)",
ilength, BX_PNIC_THIS s.rDataCursor )); ilength, BX_PNIC_THIS s.rDataCursor));
switch ( command ) { switch (command) {
case PNIC_CMD_NOOP : case PNIC_CMD_NOOP:
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_API_VER : case PNIC_CMD_API_VER:
Bit16u api_version; Bit16u api_version;
api_version = PNIC_API_VERSION; api_version = PNIC_API_VERSION;
olength = sizeof(api_version); olength = sizeof(api_version);
memcpy ( data, &api_version, sizeof(api_version) ); memcpy (data, &api_version, sizeof(api_version));
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_READ_MAC : case PNIC_CMD_READ_MAC:
olength = sizeof ( BX_PNIC_THIS s.macaddr ); olength = sizeof (BX_PNIC_THIS s.macaddr);
memcpy ( data, BX_PNIC_THIS s.macaddr, olength ); memcpy (data, BX_PNIC_THIS s.macaddr, olength);
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_RESET : case PNIC_CMD_RESET:
/* Flush the receive queue */ /* Flush the receive queue */
BX_PNIC_THIS s.recvQueueLength = 0; BX_PNIC_THIS s.recvQueueLength = 0;
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_XMIT : case PNIC_CMD_XMIT:
BX_PNIC_THIS ethdev->sendpkt(data, ilength); BX_PNIC_THIS ethdev->sendpkt(data, ilength);
if (BX_PNIC_THIS s.irqEnabled) { if (BX_PNIC_THIS s.irqEnabled) {
set_irq_level(1); set_irq_level(1);
@ -465,35 +466,35 @@ void bx_pcipnic_c::exec_command(void)
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_RECV : case PNIC_CMD_RECV:
if ( BX_PNIC_THIS s.recvQueueLength > 0 ) { if (BX_PNIC_THIS s.recvQueueLength > 0) {
int idx = ( BX_PNIC_THIS s.recvIndex - BX_PNIC_THIS s.recvQueueLength int idx = (BX_PNIC_THIS s.recvIndex - BX_PNIC_THIS s.recvQueueLength
+ PNIC_RECV_RINGS ) % PNIC_RECV_RINGS; + PNIC_RECV_RINGS) % PNIC_RECV_RINGS;
olength = BX_PNIC_THIS s.recvRingLength[idx]; olength = BX_PNIC_THIS s.recvRingLength[idx];
memcpy ( data, BX_PNIC_THIS s.recvRing[idx], olength ); memcpy (data, BX_PNIC_THIS s.recvRing[idx], olength);
BX_PNIC_THIS s.recvQueueLength --; BX_PNIC_THIS s.recvQueueLength--;
} }
if ( ! BX_PNIC_THIS s.recvQueueLength ) { if (! BX_PNIC_THIS s.recvQueueLength) {
set_irq_level(0); set_irq_level(0);
} }
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_RECV_QLEN : case PNIC_CMD_RECV_QLEN:
Bit16u qlen; Bit16u qlen;
qlen = BX_PNIC_THIS s.recvQueueLength; qlen = BX_PNIC_THIS s.recvQueueLength;
olength = sizeof(qlen); olength = sizeof(qlen);
memcpy ( data, &qlen, sizeof(qlen) ); memcpy (data, &qlen, sizeof(qlen));
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_MASK_IRQ : case PNIC_CMD_MASK_IRQ:
Bit8u enabled; Bit8u enabled;
enabled = *((Bit8u*)data); enabled = *((Bit8u*)data);
BX_PNIC_THIS s.irqEnabled = enabled; BX_PNIC_THIS s.irqEnabled = enabled;
if ( enabled && BX_PNIC_THIS s.recvQueueLength ) { if (enabled && BX_PNIC_THIS s.recvQueueLength) {
set_irq_level(1); set_irq_level(1);
} else { } else {
set_irq_level(0); set_irq_level(0);
@ -501,16 +502,15 @@ void bx_pcipnic_c::exec_command(void)
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
case PNIC_CMD_FORCE_IRQ : case PNIC_CMD_FORCE_IRQ:
set_irq_level(1); set_irq_level(1);
status = PNIC_STATUS_OK; status = PNIC_STATUS_OK;
break; break;
default: default:
BX_ERROR(("Unknown PNIC command %x (data length %u)", command, ilength )); BX_ERROR(("Unknown PNIC command %x (data length %u)", command, ilength));
status = PNIC_STATUS_UNKNOWN_CMD; status = PNIC_STATUS_UNKNOWN_CMD;
break; break;
} }
// Set registers // Set registers
@ -519,7 +519,6 @@ void bx_pcipnic_c::exec_command(void)
BX_PNIC_THIS s.rDataCursor = 0; BX_PNIC_THIS s.rDataCursor = 0;
} }
/* /*
* Callback from the eth system driver when a frame has arrived * Callback from the eth system driver when a frame has arrived
*/ */
@ -540,26 +539,26 @@ void bx_pcipnic_c::rx_handler(void *arg, const void *buf, unsigned len)
void bx_pcipnic_c::rx_frame(const void *buf, unsigned io_len) void bx_pcipnic_c::rx_frame(const void *buf, unsigned io_len)
{ {
// Check packet length // Check packet length
if ( io_len > PNIC_DATA_SIZE ) { if (io_len > PNIC_DATA_SIZE) {
BX_PANIC ( ( "PNIC receive: data size %u exceeded buffer size %u", BX_PANIC(("PNIC receive: data size %u exceeded buffer size %u",
io_len, PNIC_DATA_SIZE ) ); io_len, PNIC_DATA_SIZE));
// Truncate if user continues // Truncate if user continues
io_len = PNIC_DATA_SIZE; io_len = PNIC_DATA_SIZE;
} }
// Check receive ring is not full // Check receive ring is not full
if ( BX_PNIC_THIS s.recvQueueLength == PNIC_RECV_RINGS ) { if (BX_PNIC_THIS s.recvQueueLength == PNIC_RECV_RINGS) {
BX_ERROR ( ( "PNIC receive: receive ring full, discarding packet" ) ); BX_ERROR(("PNIC receive: receive ring full, discarding packet"));
return; return;
} }
// Copy data to receive ring and record length // Copy data to receive ring and record length
memcpy ( BX_PNIC_THIS s.recvRing[ BX_PNIC_THIS s.recvIndex ], buf, io_len ); memcpy (BX_PNIC_THIS s.recvRing[BX_PNIC_THIS s.recvIndex], buf, io_len);
BX_PNIC_THIS s.recvRingLength[ BX_PNIC_THIS s.recvIndex ] = io_len; BX_PNIC_THIS s.recvRingLength[BX_PNIC_THIS s.recvIndex] = io_len;
// Move to next ring entry // Move to next ring entry
BX_PNIC_THIS s.recvIndex = ( BX_PNIC_THIS s.recvIndex + 1) % PNIC_RECV_RINGS; BX_PNIC_THIS s.recvIndex = (BX_PNIC_THIS s.recvIndex + 1) % PNIC_RECV_RINGS;
BX_PNIC_THIS s.recvQueueLength ++; BX_PNIC_THIS s.recvQueueLength++;
// Generate interrupt if enabled // Generate interrupt if enabled
if ( BX_PNIC_THIS s.irqEnabled ) { if (BX_PNIC_THIS s.irqEnabled) {
set_irq_level(1); set_irq_level(1);
} }
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: pic.cc,v 1.48 2008-01-26 22:24:02 sshwarts Exp $ // $Id: pic.cc,v 1.49 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,7 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
@ -270,7 +270,7 @@ void bx_pic_c::write(Bit32u address, Bit32u value, unsigned io_len)
case 0x20: case 0x20:
if (value & 0x10) { /* initialization command 1 */ if (value & 0x10) { /* initialization command 1 */
BX_DEBUG(("master: init command 1 found")); BX_DEBUG(("master: init command 1 found"));
BX_DEBUG((" requires 4 = %u", (unsigned) (value & 0x01) )); BX_DEBUG((" requires 4 = %u", (unsigned) (value & 0x01)));
BX_DEBUG((" cascade mode: [0=cascade,1=single] %u", BX_DEBUG((" cascade mode: [0=cascade,1=single] %u",
(unsigned) ((value & 0x02) >> 1))); (unsigned) ((value & 0x02) >> 1)));
BX_PIC_THIS s.master_pic.init.in_init = 1; BX_PIC_THIS s.master_pic.init.in_init = 1;
@ -295,7 +295,7 @@ void bx_pic_c::write(Bit32u address, Bit32u value, unsigned io_len)
return; return;
} }
if ( (value & 0x18) == 0x08 ) { /* OCW3 */ if ((value & 0x18) == 0x08) { /* OCW3 */
Bit8u special_mask, poll, read_op; Bit8u special_mask, poll, read_op;
special_mask = (value & 0x60) >> 5; special_mask = (value & 0x60) >> 5;
@ -445,7 +445,7 @@ void bx_pic_c::write(Bit32u address, Bit32u value, unsigned io_len)
if (value & 0x10) { /* initialization command 1 */ if (value & 0x10) { /* initialization command 1 */
BX_DEBUG(("slave: init command 1 found")); BX_DEBUG(("slave: init command 1 found"));
BX_DEBUG((" requires 4 = %u", BX_DEBUG((" requires 4 = %u",
(unsigned) (value & 0x01) )); (unsigned) (value & 0x01)));
BX_DEBUG((" cascade mode: [0=cascade,1=single] %u", BX_DEBUG((" cascade mode: [0=cascade,1=single] %u",
(unsigned) ((value & 0x02) >> 1))); (unsigned) ((value & 0x02) >> 1)));
BX_PIC_THIS s.slave_pic.init.in_init = 1; BX_PIC_THIS s.slave_pic.init.in_init = 1;
@ -470,7 +470,7 @@ void bx_pic_c::write(Bit32u address, Bit32u value, unsigned io_len)
return; return;
} }
if ( (value & 0x18) == 0x08 ) { /* OCW3 */ if ((value & 0x18) == 0x08) { /* OCW3 */
Bit8u special_mask, poll, read_op; Bit8u special_mask, poll, read_op;
special_mask = (value & 0x60) >> 5; special_mask = (value & 0x60) >> 5;
@ -721,13 +721,13 @@ void bx_pic_c::service_master_pic(void)
isr = BX_PIC_THIS s.master_pic.isr; isr = BX_PIC_THIS s.master_pic.isr;
if (isr) { if (isr) {
max_irq = highest_priority; max_irq = highest_priority;
while ( (isr & (1 << max_irq)) == 0) { while ((isr & (1 << max_irq)) == 0) {
max_irq++; max_irq++;
if(max_irq > 7) if(max_irq > 7)
max_irq = 0; max_irq = 0;
} }
if (max_irq == highest_priority ) return; /* Highest priority interrupt in-service, if (max_irq == highest_priority) return; /* Highest priority interrupt in-service,
* no other priorities allowed */ * no other priorities allowed */
if (max_irq > 7) BX_PANIC(("error in service_master_pic()")); if (max_irq > 7) BX_PANIC(("error in service_master_pic()"));
} }
else else
@ -735,13 +735,13 @@ void bx_pic_c::service_master_pic(void)
} }
/* now, see if there are any higher priority requests */ /* now, see if there are any higher priority requests */
if ((unmasked_requests = (BX_PIC_THIS s.master_pic.irr & ~BX_PIC_THIS s.master_pic.imr)) ) { if ((unmasked_requests = (BX_PIC_THIS s.master_pic.irr & ~BX_PIC_THIS s.master_pic.imr))) {
irq = highest_priority; irq = highest_priority;
do { do {
/* for special mode, since we're looking at all IRQ's, skip if /* for special mode, since we're looking at all IRQ's, skip if
* current IRQ is already in-service * current IRQ is already in-service
*/ */
if ( ! (BX_PIC_THIS s.master_pic.special_mask && ((BX_PIC_THIS s.master_pic.isr >> irq) & 0x01)) ) { if (! (BX_PIC_THIS s.master_pic.special_mask && ((BX_PIC_THIS s.master_pic.isr >> irq) & 0x01))) {
if (unmasked_requests & (1 << irq)) { if (unmasked_requests & (1 << irq)) {
BX_DEBUG(("signalling IRQ(%u)", (unsigned) irq)); BX_DEBUG(("signalling IRQ(%u)", (unsigned) irq));
BX_PIC_THIS s.master_pic.INT = 1; BX_PIC_THIS s.master_pic.INT = 1;
@ -782,13 +782,13 @@ void bx_pic_c::service_slave_pic(void)
isr = BX_PIC_THIS s.slave_pic.isr; isr = BX_PIC_THIS s.slave_pic.isr;
if (isr) { if (isr) {
max_irq = highest_priority; max_irq = highest_priority;
while ( (isr & (1 << max_irq)) == 0) { while ((isr & (1 << max_irq)) == 0) {
max_irq++; max_irq++;
if(max_irq > 7) if(max_irq > 7)
max_irq = 0; max_irq = 0;
} }
if (max_irq == highest_priority ) return; /* Highest priority interrupt in-service, if (max_irq == highest_priority) return; /* Highest priority interrupt in-service,
* no other priorities allowed */ * no other priorities allowed */
if (max_irq > 7) BX_PANIC(("error in service_master_pic()")); if (max_irq > 7) BX_PANIC(("error in service_master_pic()"));
} }
else else
@ -796,13 +796,13 @@ void bx_pic_c::service_slave_pic(void)
} }
/* now, see if there are any higher priority requests */ /* now, see if there are any higher priority requests */
if ((unmasked_requests = (BX_PIC_THIS s.slave_pic.irr & ~BX_PIC_THIS s.slave_pic.imr)) ) { if ((unmasked_requests = (BX_PIC_THIS s.slave_pic.irr & ~BX_PIC_THIS s.slave_pic.imr))) {
irq = highest_priority; irq = highest_priority;
do { do {
/* for special mode, since we're looking at all IRQ's, skip if /* for special mode, since we're looking at all IRQ's, skip if
* current IRQ is already in-service * current IRQ is already in-service
*/ */
if ( ! (BX_PIC_THIS s.slave_pic.special_mask && ((BX_PIC_THIS s.slave_pic.isr >> irq) & 0x01)) ) { if (! (BX_PIC_THIS s.slave_pic.special_mask && ((BX_PIC_THIS s.slave_pic.isr >> irq) & 0x01))) {
if (unmasked_requests & (1 << irq)) { if (unmasked_requests & (1 << irq)) {
BX_DEBUG(("slave: signalling IRQ(%u)", (unsigned) 8 + irq)); BX_DEBUG(("slave: signalling IRQ(%u)", (unsigned) 8 + irq));

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.cc,v 1.68 2008-01-26 22:24:02 sshwarts Exp $ // $Id: pit_wrap.cc,v 1.69 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -75,8 +75,8 @@ bx_pit_c bx_pit;
//PIT tick to usec conversion functions: //PIT tick to usec conversion functions:
//Direct conversions: //Direct conversions:
#define TICKS_TO_USEC(a) ( ((a)*USEC_PER_SECOND)/TICKS_PER_SECOND ) #define TICKS_TO_USEC(a) (((a)*USEC_PER_SECOND)/TICKS_PER_SECOND)
#define USEC_TO_TICKS(a) ( ((a)*TICKS_PER_SECOND)/USEC_PER_SECOND ) #define USEC_TO_TICKS(a) (((a)*TICKS_PER_SECOND)/USEC_PER_SECOND)
bx_pit_c::bx_pit_c() bx_pit_c::bx_pit_c()
{ {
@ -186,18 +186,16 @@ void bx_pit_c::handle_timer()
periodic(time_passed32); periodic(time_passed32);
} }
BX_PIT_THIS s.last_usec=BX_PIT_THIS s.last_usec + time_passed; BX_PIT_THIS s.last_usec=BX_PIT_THIS s.last_usec + time_passed;
if(time_passed || if(time_passed || (BX_PIT_THIS s.last_next_event_time != BX_PIT_THIS s.timer.get_next_event_time()))
(BX_PIT_THIS s.last_next_event_time {
!= BX_PIT_THIS s.timer.get_next_event_time()) BX_DEBUG(("pit: RESETting timer"));
) {
BX_DEBUG(("pit: RESETting timer."));
bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]); bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]);
BX_DEBUG(("deactivated timer.")); BX_DEBUG(("deactivated timer"));
if(BX_PIT_THIS s.timer.get_next_event_time()) { if(BX_PIT_THIS s.timer.get_next_event_time()) {
bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0], bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0],
(Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())), (Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())),
0); 0);
BX_DEBUG(("activated timer.")); BX_DEBUG(("activated timer"));
} }
BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time(); BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time();
} }
@ -249,10 +247,10 @@ Bit32u bx_pit_c::read(Bit32u address, unsigned io_len)
case 0x61: case 0x61:
/* AT, port 61h */ /* AT, port 61h */
BX_PIT_THIS s.refresh_clock_div2 = (bx_bool)((my_time_usec / 15) & 1); BX_PIT_THIS s.refresh_clock_div2 = (bx_bool)((my_time_usec / 15) & 1);
return( (BX_PIT_THIS s.timer.read_OUT(2)<<5) | return (BX_PIT_THIS s.timer.read_OUT(2)<<5) |
(BX_PIT_THIS s.refresh_clock_div2<<4) | (BX_PIT_THIS s.refresh_clock_div2<<4) |
(BX_PIT_THIS s.speaker_data_on<<1) | (BX_PIT_THIS s.speaker_data_on<<1) |
(BX_PIT_THIS s.timer.read_GATE(2)?1:0) ); (BX_PIT_THIS s.timer.read_GATE(2)?1:0);
break; break;
default: default:
@ -288,7 +286,7 @@ void bx_pit_c::write(Bit32u address, Bit32u dvalue, unsigned io_len)
} }
BX_PIT_THIS s.last_usec=BX_PIT_THIS s.last_usec + time_passed; BX_PIT_THIS s.last_usec=BX_PIT_THIS s.last_usec + time_passed;
value = (Bit8u ) dvalue; value = (Bit8u) dvalue;
if (bx_dbg.pit) if (bx_dbg.pit)
BX_INFO(("pit: write to port %04x = %02x", BX_INFO(("pit: write to port %04x = %02x",
@ -296,24 +294,24 @@ void bx_pit_c::write(Bit32u address, Bit32u dvalue, unsigned io_len)
switch (address) { switch (address) {
case 0x40: /* timer 0: write count register */ case 0x40: /* timer 0: write count register */
BX_PIT_THIS s.timer.write(0,value); BX_PIT_THIS s.timer.write(0, value);
break; break;
case 0x41: /* timer 1: write count register */ case 0x41: /* timer 1: write count register */
BX_PIT_THIS s.timer.write( 1,value ); BX_PIT_THIS s.timer.write(1, value);
break; break;
case 0x42: /* timer 2: write count register */ case 0x42: /* timer 2: write count register */
BX_PIT_THIS s.timer.write( 2,value ); BX_PIT_THIS s.timer.write(2, value);
break; break;
case 0x43: /* timer 0-2 mode control */ case 0x43: /* timer 0-2 mode control */
BX_PIT_THIS s.timer.write( 3,value ); BX_PIT_THIS s.timer.write(3, value);
break; break;
case 0x61: case 0x61:
BX_PIT_THIS s.speaker_data_on = (value >> 1) & 0x01; BX_PIT_THIS s.speaker_data_on = (value >> 1) & 0x01;
if ( BX_PIT_THIS s.speaker_data_on ) { if (BX_PIT_THIS s.speaker_data_on) {
DEV_speaker_beep_on((float)(1193180.0 / this->get_timer(2))); DEV_speaker_beep_on((float)(1193180.0 / this->get_timer(2)));
} else { } else {
DEV_speaker_beep_off(); DEV_speaker_beep_off();
@ -327,18 +325,16 @@ void bx_pit_c::write(Bit32u address, Bit32u dvalue, unsigned io_len)
(unsigned) address, (unsigned) value)); (unsigned) address, (unsigned) value));
} }
if(time_passed || if(time_passed || (BX_PIT_THIS s.last_next_event_time != BX_PIT_THIS s.timer.get_next_event_time()))
(BX_PIT_THIS s.last_next_event_time {
!= BX_PIT_THIS s.timer.get_next_event_time()) BX_DEBUG(("pit: RESETting timer"));
) {
BX_DEBUG(("pit: RESETting timer."));
bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]); bx_virt_timer.deactivate_timer(BX_PIT_THIS s.timer_handle[0]);
BX_DEBUG(("deactivated timer.")); BX_DEBUG(("deactivated timer"));
if(BX_PIT_THIS s.timer.get_next_event_time()) { if(BX_PIT_THIS s.timer.get_next_event_time()) {
bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0], bx_virt_timer.activate_timer(BX_PIT_THIS s.timer_handle[0],
(Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())), (Bit32u)BX_MAX(1,TICKS_TO_USEC(BX_PIT_THIS s.timer.get_next_event_time())),
0); 0);
BX_DEBUG(("activated timer.")); BX_DEBUG(("activated timer"));
} }
BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time(); BX_PIT_THIS s.last_next_event_time = BX_PIT_THIS s.timer.get_next_event_time();
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: pit_wrap.h,v 1.27 2007-09-28 19:52:05 sshwarts Exp $ // $Id: pit_wrap.h,v 1.28 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -78,9 +78,9 @@ private:
static void timer_handler(void *this_ptr); static void timer_handler(void *this_ptr);
BX_PIT_SMF void handle_timer(); BX_PIT_SMF void handle_timer();
BX_PIT_SMF void write_count_reg( Bit8u value, unsigned timerid ); BX_PIT_SMF void write_count_reg(Bit8u value, unsigned timerid);
BX_PIT_SMF Bit8u read_counter( unsigned timerid ); BX_PIT_SMF Bit8u read_counter(unsigned timerid);
BX_PIT_SMF void latch( unsigned timerid ); BX_PIT_SMF void latch(unsigned timerid);
BX_PIT_SMF void set_GATE(unsigned pit_id, unsigned value); BX_PIT_SMF void set_GATE(unsigned pit_id, unsigned value);
BX_PIT_SMF void start(unsigned timerid); BX_PIT_SMF void start(unsigned timerid);

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: sb16.cc,v 1.56 2008-01-26 22:24:02 sshwarts Exp $ // $Id: sb16.cc,v 1.57 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,6 +23,8 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
/////////////////////////////////////////////////////////////////////////
// This file (SB16.CC) written and donated by Josef Drexler // This file (SB16.CC) written and donated by Josef Drexler
@ -135,7 +137,7 @@ void bx_sb16_c::init(void)
bx_list_c *base; bx_list_c *base;
base = (bx_list_c*) SIM->get_param(BXPN_SB16); base = (bx_list_c*) SIM->get_param(BXPN_SB16);
if ( (strlen(SIM->get_param_string("logfile", base)->getptr()) < 1) ) if ((strlen(SIM->get_param_string("logfile", base)->getptr()) < 1))
SIM->get_param_num("loglevel", base)->set(0); SIM->get_param_num("loglevel", base)->set(0);
if (SIM->get_param_num("loglevel", base)->get() > 0) if (SIM->get_param_num("loglevel", base)->get() > 0)
@ -162,8 +164,8 @@ void bx_sb16_c::init(void)
BX_SB16_THIS wavemode = 0; BX_SB16_THIS wavemode = 0;
} }
if ( (BX_SB16_THIS midimode == 2) || if ((BX_SB16_THIS midimode == 2) ||
(BX_SB16_THIS midimode == 3) ) (BX_SB16_THIS midimode == 3))
{ {
MIDIDATA = fopen(SIM->get_param_string("midifile", base)->getptr(),"wb"); MIDIDATA = fopen(SIM->get_param_string("midifile", base)->getptr(),"wb");
if (MIDIDATA == NULL) if (MIDIDATA == NULL)
@ -176,8 +178,8 @@ void bx_sb16_c::init(void)
initmidifile(); initmidifile();
} }
if ( (BX_SB16_THIS wavemode == 2) || if ((BX_SB16_THIS wavemode == 2) ||
(BX_SB16_THIS wavemode == 3) ) (BX_SB16_THIS wavemode == 3))
{ {
WAVEDATA = fopen(SIM->get_param_string("wavefile", base)->getptr(),"wb"); WAVEDATA = fopen(SIM->get_param_string("wavefile", base)->getptr(),"wb");
if (WAVEDATA == NULL) if (WAVEDATA == NULL)
@ -209,14 +211,14 @@ void bx_sb16_c::init(void)
// allocate the FIFO buffers - except for the MPUMIDICMD buffer // allocate the FIFO buffers - except for the MPUMIDICMD buffer
// these sizes are generous, 16 or 8 would probably be sufficient // these sizes are generous, 16 or 8 would probably be sufficient
MPU.datain.init( (int) 64); // the input MPU.datain.init((int) 64); // the input
MPU.dataout.init( (int) 64); // and output MPU.dataout.init((int) 64); // and output
MPU.cmd.init( (int) 64); // and command buffers MPU.cmd.init((int) 64); // and command buffers
MPU.midicmd.init( (int) 256); // and the midi command buffer (note- large SYSEX'es have to fit!) MPU.midicmd.init((int) 256); // and the midi command buffer (note- large SYSEX'es have to fit!)
DSP.datain.init( (int) 64); // the DSP input DSP.datain.init((int) 64); // the DSP input
DSP.dataout.init( (int) 64); // and output buffers DSP.dataout.init((int) 64); // and output buffers
EMUL.datain.init( (int) 64); // the emulator ports EMUL.datain.init((int) 64); // the emulator ports
EMUL.dataout.init( (int) 64); // for changing emulator settings EMUL.dataout.init((int) 64); // for changing emulator settings
// reset all parts of the hardware by // reset all parts of the hardware by
// triggering their reset functions // triggering their reset functions
@ -302,7 +304,7 @@ void bx_sb16_c::init(void)
} }
writelog(MIDILOG(4), "Timers initialized, midi %d, dma %d, opl %d", writelog(MIDILOG(4), "Timers initialized, midi %d, dma %d, opl %d",
MPU.timer_handle, DSP.timer_handle, OPL.timer_handle ); MPU.timer_handle, DSP.timer_handle, OPL.timer_handle);
MPU.current_timer = 0; MPU.current_timer = 0;
// init runtime parameters // init runtime parameters
@ -464,10 +466,10 @@ void bx_sb16_c::dsp_dmatimer(void *this_ptr)
// However, don't do this if the next byte/word will fill up the // However, don't do this if the next byte/word will fill up the
// output buffer and the output functions are not ready yet. // output buffer and the output functions are not ready yet.
if ( (BX_SB16_THIS wavemode != 1) || if ((BX_SB16_THIS wavemode != 1) ||
( (This->dsp.dma.chunkindex + 1 < BX_SOUND_OUTPUT_WAVEPACKETSIZE) && ((This->dsp.dma.chunkindex + 1 < BX_SOUND_OUTPUT_WAVEPACKETSIZE) &&
(This->dsp.dma.count > 0) ) || (This->dsp.dma.count > 0)) ||
(This->output->waveready() == BX_SOUND_OUTPUT_OK) ) { (This->output->waveready() == BX_SOUND_OUTPUT_OK)) {
if ((DSP.dma.bits == 8) || (BX_SB16_DMAH == 0)) { if ((DSP.dma.bits == 8) || (BX_SB16_DMAH == 0)) {
DEV_dma_set_drq(BX_SB16_DMAL, 1); DEV_dma_set_drq(BX_SB16_DMAL, 1);
} else { } else {
@ -809,14 +811,14 @@ void bx_sb16_c::dsp_datawrite(Bit32u value)
// set samplerate for output // set samplerate for output
case 0x42: case 0x42:
// 1,2: hi(frq) lo(frq) // 1,2: hi(frq) lo(frq)
DSP.datain.getw1( &(DSP.dma.samplerate) ); DSP.datain.getw1(&(DSP.dma.samplerate));
DSP.dma.timeconstant = 65536 - (Bit32u) 256000000 / (Bit32u) DSP.dma.samplerate ; DSP.dma.timeconstant = 65536 - (Bit32u) 256000000 / (Bit32u) DSP.dma.samplerate;
break; break;
// set block length // set block length
case 0x48: case 0x48:
// 1,2: lo(blk len) hi(blk len) // 1,2: lo(blk len) hi(blk len)
DSP.datain.getw( &(DSP.dma.blocklength) ); DSP.datain.getw(&(DSP.dma.blocklength));
break; break;
// 4-bit comp'd, normal DAC DMA, no ref byte // 4-bit comp'd, normal DAC DMA, no ref byte
@ -992,7 +994,7 @@ void bx_sb16_c::dsp_datawrite(Bit32u value)
// read speaker on/off (out ff=on, 00=off) // read speaker on/off (out ff=on, 00=off)
case 0xd8: case 0xd8:
// none, o1: speaker; ff/00 // none, o1: speaker; ff/00
DSP.dataout.put( (DSP.speaker == 1)?0xff:0x00); DSP.dataout.put((DSP.speaker == 1)?0xff:0x00);
break; break;
// stop 16 bit auto DMA // stop 16 bit auto DMA
@ -1102,23 +1104,23 @@ void bx_sb16_c::dsp_dma(Bit8u command, Bit8u mode, Bit16u length, Bit8u comp)
writelog(WAVELOG(4), "DMA initialized. Cmd %02x, mode %02x, length %d, comp %d", writelog(WAVELOG(4), "DMA initialized. Cmd %02x, mode %02x, length %d, comp %d",
command, mode, length, comp); command, mode, length, comp);
if ( (command >> 4) == 0xb ) // 0xb? = 16 bit DMA if ((command >> 4) == 0xb) // 0xb? = 16 bit DMA
{ {
DSP.dma.bits = 16; DSP.dma.bits = 16;
DSP.dma.bps = 2; DSP.dma.bps = 2;
} }
else // 0xc? = 8 bit DMA else // 0xc? = 8 bit DMA
{ {
DSP.dma.bits = 8; DSP.dma.bits = 8;
DSP.dma.bps = 1; DSP.dma.bps = 1;
} }
// Prevent division by zero in some instances // Prevent division by zero in some instances
if ( DSP.dma.samplerate == 0 ) if (DSP.dma.samplerate == 0)
DSP.dma.samplerate= 10752; DSP.dma.samplerate= 10752;
command &= 0x0f; command &= 0x0f;
DSP.dma.output = 1 - (command >> 3); // 1=output, 0=input DSP.dma.output = 1 - (command >> 3); // 1=output, 0=input
DSP.dma.mode = 1 + ( (command >> 2) & 1); // 0=none, 1=normal, 2=auto DSP.dma.mode = 1 + ((command >> 2) & 1); // 0=none, 1=normal, 2=auto
DSP.dma.fifo = (command >> 1) & 1; // ? not sure what this is DSP.dma.fifo = (command >> 1) & 1; // ? not sure what this is
DSP.dma.stereo = (mode >> 5) & 1; DSP.dma.stereo = (mode >> 5) & 1;
@ -1149,7 +1151,7 @@ void bx_sb16_c::dsp_dma(Bit8u command, Bit8u mode, Bit16u length, Bit8u comp)
(DSP.dma.highspeed == 1)?"highspeed":"normal speed", (DSP.dma.highspeed == 1)?"highspeed":"normal speed",
sampledatarate, DSP.dma.timer); sampledatarate, DSP.dma.timer);
DSP.dma.format = DSP.dma.issigned | ( (comp & 7) << 1) | ( (comp & 8) << 4); DSP.dma.format = DSP.dma.issigned | ((comp & 7) << 1) | ((comp & 8) << 4);
// write the output to the device/file // write the output to the device/file
if (DSP.dma.output == 1) if (DSP.dma.output == 1)
@ -1271,7 +1273,7 @@ void bx_sb16_c::dsp_getwavepacket()
byteA = byteB; byteA = byteB;
for (int i = 0; i < BX_SOUND_OUTPUT_WAVEPACKETSIZE; i++) for (int i = 0; i < BX_SOUND_OUTPUT_WAVEPACKETSIZE; i++)
DSP.dma.chunk[i] = ( (i & 1) == 0) ? byteA : byteB; DSP.dma.chunk[i] = ((i & 1) == 0) ? byteA : byteB;
DSP.dma.chunkcount = BX_SOUND_OUTPUT_WAVEPACKETSIZE; DSP.dma.chunkcount = BX_SOUND_OUTPUT_WAVEPACKETSIZE;
DSP.dma.chunkindex = 0; DSP.dma.chunkindex = 0;
@ -1292,7 +1294,7 @@ void bx_sb16_c::dsp_sendwavepacket()
Bit8u temparray[12] = Bit8u temparray[12] =
{ DSP.dma.samplerate & 0xff, DSP.dma.samplerate >> 8, 0, 0, { DSP.dma.samplerate & 0xff, DSP.dma.samplerate >> 8, 0, 0,
DSP.dma.bits, DSP.dma.stereo + 1, 0, 0, 0, 0, 0, 0 }; DSP.dma.bits, DSP.dma.stereo + 1, 0, 0, 0, 0, 0, 0 };
switch ( (DSP.dma.format >> 1) & 7) switch ((DSP.dma.format >> 1) & 7)
{ {
case 2: case 2:
temparray[7] = 3; temparray[7] = 3;
@ -1338,7 +1340,7 @@ void bx_sb16_c::dsp_dmadone()
{ {
writelog(WAVELOG(4), "DMA transfer done, triggering IRQ"); writelog(WAVELOG(4), "DMA transfer done, triggering IRQ");
if ( (DSP.dma.output == 1) && (DSP.dma.mode != 2) ) if ((DSP.dma.output == 1) && (DSP.dma.mode != 2))
{ {
dsp_sendwavepacket(); // flush the output dsp_sendwavepacket(); // flush the output
@ -1725,9 +1727,9 @@ Bit32u bx_sb16_c::mpu_status()
{ {
Bit32u result = 0; Bit32u result = 0;
if ( (MPU.datain.full() == 1) || if ((MPU.datain.full() == 1) ||
( (BX_SB16_THIS midimode == 1) && ((BX_SB16_THIS midimode == 1) &&
(BX_SB16_OUTPUT->midiready() == BX_SOUND_OUTPUT_ERR) ) ) (BX_SB16_OUTPUT->midiready() == BX_SOUND_OUTPUT_ERR)))
result |= 0x40; // output not ready result |= 0x40; // output not ready
if (MPU.dataout.empty() == 1) if (MPU.dataout.empty() == 1)
result |= 0x80; // no input available result |= 0x80; // no input available
@ -1747,7 +1749,7 @@ void bx_sb16_c::mpu_command(Bit32u value)
if (MPU.cmd.hascommand() == 1) // already a command pending, abort that one if (MPU.cmd.hascommand() == 1) // already a command pending, abort that one
{ {
if ((MPU.cmd.currentcommand() != value) || if ((MPU.cmd.currentcommand() != value) ||
(MPU.cmd.commanddone() == 0) ) (MPU.cmd.commanddone() == 0))
// it's a different command, or the old one isn't done yet, abort it // it's a different command, or the old one isn't done yet, abort it
{ {
MPU.cmd.clearcommand(); MPU.cmd.clearcommand();
@ -1761,7 +1763,7 @@ void bx_sb16_c::mpu_command(Bit32u value)
if (MPU.cmd.hascommand() == 0) // no command pending, set one up if (MPU.cmd.hascommand() == 0) // no command pending, set one up
{ {
bytesneeded = 0; bytesneeded = 0;
if ( (value >> 4) == 14) bytesneeded = 1; if ((value >> 4) == 14) bytesneeded = 1;
MPU.cmd.newcommand(value, bytesneeded); MPU.cmd.newcommand(value, bytesneeded);
} }
@ -1869,7 +1871,7 @@ void bx_sb16_c::mpu_datawrite(Bit32u value)
if (MPU.cmd.commanddone() == 1) if (MPU.cmd.commanddone() == 1)
BX_SB16_THIS mpu_command(MPU.cmd.currentcommand()); BX_SB16_THIS mpu_command(MPU.cmd.currentcommand());
} }
else if ( (MPU.uartmode == 0) && (MPU.singlecommand == 0) ) else if ((MPU.uartmode == 0) && (MPU.singlecommand == 0))
{ {
// Hm? No UART mode, but still data? Maybe should send it // Hm? No UART mode, but still data? Maybe should send it
// to the command port... Only SBMPU401.EXE does this... // to the command port... Only SBMPU401.EXE does this...
@ -1907,7 +1909,7 @@ void bx_sb16_c::mpu_mididata(Bit32u value)
{ {
writelog(MIDILOG(3), "Midi command %02x incomplete, has %d of %d bytes.", writelog(MIDILOG(3), "Midi command %02x incomplete, has %d of %d bytes.",
MPU.midicmd.currentcommand(), MPU.midicmd.bytes(), MPU.midicmd.currentcommand(), MPU.midicmd.bytes(),
MPU.midicmd.commandbytes() ); MPU.midicmd.commandbytes());
// write as much as we can. Should we do this? // write as much as we can. Should we do this?
processmidicommand(0); processmidicommand(0);
// clear the pending command // clear the pending command
@ -1918,7 +1920,7 @@ void bx_sb16_c::mpu_mididata(Bit32u value)
// find the number of arguments to the command // find the number of arguments to the command
static const signed eventlength[] = { 2, 2, 2, 2, 1, 1, 2, 255}; static const signed eventlength[] = { 2, 2, 2, 2, 1, 1, 2, 255};
// note - length 255 commands have unknown length // note - length 255 commands have unknown length
MPU.midicmd.newcommand(value, eventlength[ (value & 0x70) >> 4 ]); MPU.midicmd.newcommand(value, eventlength[(value & 0x70) >> 4]);
} }
else // no command, just arguments to the old command else // no command, just arguments to the old command
{ {
@ -1935,7 +1937,7 @@ void bx_sb16_c::mpu_mididata(Bit32u value)
{ {
// the command is complete, process it // the command is complete, process it
writelog(MIDILOG(5), "Midi command %02x complete, has %d bytes.", writelog(MIDILOG(5), "Midi command %02x complete, has %d bytes.",
MPU.midicmd.currentcommand(), MPU.midicmd.bytes() ); MPU.midicmd.currentcommand(), MPU.midicmd.bytes());
processmidicommand(0); processmidicommand(0);
// and remove the command from the buffer // and remove the command from the buffer
MPU.midicmd.clearcommand(); MPU.midicmd.clearcommand();
@ -2123,7 +2125,7 @@ void bx_sb16_c::emul_write(Bit32u value)
case 9: // enter specific OPL2/3 mode case 9: // enter specific OPL2/3 mode
EMUL.dataout.get(&value8); EMUL.dataout.get(&value8);
writelog(4, "Entering OPL2/3 mode %d", value8); writelog(4, "Entering OPL2/3 mode %d", value8);
opl_entermode( (bx_sb16_fm_mode) value8); opl_entermode((bx_sb16_fm_mode) value8);
break; break;
case 10: // check emulator present case 10: // check emulator present
EMUL.datain.put(0x55); EMUL.datain.put(0x55);
@ -2225,7 +2227,7 @@ void bx_sb16_c::opl_entermode(bx_sb16_fm_mode newmode)
// ch: 0 1 2 3 4 5 6 7 8 // ch: 0 1 2 3 4 5 6 7 8
// op1: 0 1 2 6 7 8 12 13 14 // op1: 0 1 2 6 7 8 12 13 14
// op2: 3 4 5 9 10 11 15 16 17 // op2: 3 4 5 9 10 11 15 16 17
OPL.chan[i].opnum[0] = i + ( (int) (i / 3) ) * 3; OPL.chan[i].opnum[0] = i + ((int) (i / 3)) * 3;
OPL.chan[i].opnum[1] = OPL.chan[i].opnum[0] + 3; OPL.chan[i].opnum[1] = OPL.chan[i].opnum[0] + 3;
} }
@ -2242,12 +2244,12 @@ void bx_sb16_c::opl_entermode(bx_sb16_fm_mode newmode)
void bx_sb16_c::opl_timerevent() void bx_sb16_c::opl_timerevent()
{ {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
if ((OPL.tmask[i/2] & (1 << (i % 2)) ) != 0) if ((OPL.tmask[i/2] & (1 << (i % 2))) != 0)
{ // only running timers { // only running timers
if ((OPL.timer[i]--) == 0) if ((OPL.timer[i]--) == 0)
{ // overflow occured, set flags accordingly { // overflow occured, set flags accordingly
OPL.timer[i] = OPL.timerinit[i]; // reset the counter OPL.timer[i] = OPL.timerinit[i]; // reset the counter
if ((OPL.tmask[i/2] >> (6 - (i % 2)) ) == 0) // set flags only if unmasked if ((OPL.tmask[i/2] >> (6 - (i % 2))) == 0) // set flags only if unmasked
{ {
writelog(WAVELOG(5), "OPL Timer Interrupt: Chip %d, Timer %d", i/2, 1 << (i % 2)); writelog(WAVELOG(5), "OPL Timer Interrupt: Chip %d, Timer %d", i/2, 1 << (i % 2));
OPL.tflag[i/2] |= 1 << (6 - (i % 2)); // set the overflow flag OPL.tflag[i/2] |= 1 << (6 - (i % 2)); // set the overflow flag
@ -2288,8 +2290,8 @@ void bx_sb16_c::opl_data(Bit32u value, int chipid)
// first find out operator and/or channel numbers // first find out operator and/or channel numbers
// case 0x20 ... 0x95: includes too many ports, but that is harmless // case 0x20 ... 0x95: includes too many ports, but that is harmless
// case 0xe0 ... 0xf5: // case 0xe0 ... 0xf5:
if ( ((index>=0x20) && (index<=0x95)) || if (((index>=0x20) && (index<=0x95)) ||
((index>=0xe0) && (index<=0xf5)) ) { ((index>=0xe0) && (index<=0xf5))) {
// operator access // operator access
// find the operator number. 0..17 on chip 1, 18..35 on chip 2 // find the operator number. 0..17 on chip 1, 18..35 on chip 2
@ -2313,7 +2315,7 @@ void bx_sb16_c::opl_data(Bit32u value, int chipid)
opernum += BX_SB16_FM_NOP / 2; opernum += BX_SB16_FM_NOP / 2;
// find out the channel number, and which of the channel's operators this is // find out the channel number, and which of the channel's operators this is
channum = opernum % 3 + ( (int) (opernum / 6) ) * 3; channum = opernum % 3 + ((int) (opernum / 6)) * 3;
subopnum = 0; subopnum = 0;
if ((opernum % 6) > 2) // second operator if ((opernum % 6) > 2) // second operator
@ -2331,7 +2333,7 @@ void bx_sb16_c::opl_data(Bit32u value, int chipid)
writelog(MIDILOG(5), "Is Channel %d, Oper %d, Subop %d", writelog(MIDILOG(5), "Is Channel %d, Oper %d, Subop %d",
channum, opernum, subopnum); channum, opernum, subopnum);
} }
else if ( (index>=0xa0) && (index<=0xc8) ) { else if ((index>=0xa0) && (index<=0xc8)) {
// channel access // channel access
channum = index & 0x0f; channum = index & 0x0f;
if (OPL.chan[channum].nop == 0) if (OPL.chan[channum].nop == 0)
@ -2346,7 +2348,7 @@ break_here:
// WSEnable and Test Register // WSEnable and Test Register
case 0x01: case 0x01:
OPL.wsenable[chipid] = (value >> 5) & 1; OPL.wsenable[chipid] = (value >> 5) & 1;
if ( (value & 0x1f) != 0) if ((value & 0x1f) != 0)
writelog(MIDILOG(3), "Warning: Test Register set to %02x", value & 0x1f); writelog(MIDILOG(3), "Warning: Test Register set to %02x", value & 0x1f);
break; break;
@ -2360,7 +2362,7 @@ break_here:
// if OPL2: timer masks // if OPL2: timer masks
// if OPL3: 4-operator modes // if OPL3: 4-operator modes
case 0x04: case 0x04:
if ( (chipid == 0) || (OPL.mode == dual) ) if ((chipid == 0) || (OPL.mode == dual))
opl_settimermask(value, chipid); opl_settimermask(value, chipid);
else else
opl_set4opmode(value & 0x3f); opl_set4opmode(value & 0x3f);
@ -2370,7 +2372,7 @@ break_here:
case 0x05: case 0x05:
if (chipid == 1) if (chipid == 1)
{ {
if ( (value & 1) != 0) if ((value & 1) != 0)
opl_entermode(opl3); opl_entermode(opl3);
else else
opl_entermode(single); opl_entermode(single);
@ -2627,7 +2629,7 @@ void bx_sb16_c::opl_set4opmode(int new4opmode)
channel1 = i + (i / 3) * 6; channel1 = i + (i / 3) * 6;
channel2 = channel1 + 3; channel2 = channel1 + 3;
if ( ( (new4opmode >> i) & 1) != 0) if (((new4opmode >> i) & 1) != 0)
{ // enable 4-op mode { // enable 4-op mode
opl_keyonoff(channel1, 0); opl_keyonoff(channel1, 0);
opl_keyonoff(channel2, 0); opl_keyonoff(channel2, 0);
@ -2670,13 +2672,13 @@ void bx_sb16_c::opl_settimermask(int value, int chipid)
if ((value & 0x03) != 0) // yes, it's different. Start or stop? if ((value & 0x03) != 0) // yes, it's different. Start or stop?
{ {
writelog(MIDILOG(5), "Starting timers"); writelog(MIDILOG(5), "Starting timers");
bx_pc_system.activate_timer( OPL.timer_handle, 0, 1); bx_pc_system.activate_timer(OPL.timer_handle, 0, 1);
OPL.timer_running = 1; OPL.timer_running = 1;
} }
else else
{ {
writelog(MIDILOG(5), "Stopping timers"); writelog(MIDILOG(5), "Stopping timers");
bx_pc_system.deactivate_timer( OPL.timer_handle ); bx_pc_system.deactivate_timer(OPL.timer_handle);
OPL.timer_running = 0; OPL.timer_running = 0;
} }
} }
@ -2788,7 +2790,7 @@ void bx_sb16_c::opl_setfreq(int channel)
// this is a reasonable approximation for keyfreq /= 1.059463 // this is a reasonable approximation for keyfreq /= 1.059463
// (that value is 2**(1/12), which is the difference between two keys) // (that value is 2**(1/12), which is the difference between two keys)
while ( (keyfreq -= ( (keyfreq * 1000) / 17817) ) > freqC) while ((keyfreq -= ((keyfreq * 1000) / 17817)) > freqC)
keynum++; keynum++;
} }
else { else {
@ -2820,7 +2822,7 @@ void bx_sb16_c::opl_keyonoff(int channel, bx_bool onoff)
if (OPL.chan[channel].midichan == 0xff) if (OPL.chan[channel].midichan == 0xff)
{ {
for (i=0; i<16; i++) for (i=0; i<16; i++)
if (((OPL.midichannels >> i) & 1 ) != 0) if (((OPL.midichannels >> i) & 1) != 0)
{ {
OPL.chan[channel].midichan = i; OPL.chan[channel].midichan = i;
OPL.midichannels &= ~(1 << i); // mark channel as used OPL.midichannels &= ~(1 << i); // mark channel as used
@ -2961,7 +2963,7 @@ void bx_sb16_c::processmidicommand(bx_bool force)
channel = MPU.midicmd.currentcommand() & 0xf; channel = MPU.midicmd.currentcommand() & 0xf;
// we need to log bank changes and program changes // we need to log bank changes and program changes
if ( (MPU.midicmd.currentcommand() >> 4) == 0xc) if ((MPU.midicmd.currentcommand() >> 4) == 0xc)
{ // a program change { // a program change
value = MPU.midicmd.peek(0); value = MPU.midicmd.peek(0);
writelog(MIDILOG(1), "* ProgramChange channel %d to %d", writelog(MIDILOG(1), "* ProgramChange channel %d to %d",
@ -2969,7 +2971,7 @@ void bx_sb16_c::processmidicommand(bx_bool force)
MPU.program[channel] = value; MPU.program[channel] = value;
needremap = 1; needremap = 1;
} }
else if ( (MPU.midicmd.currentcommand() >> 4) == 0xb) else if ((MPU.midicmd.currentcommand() >> 4) == 0xb)
{ // a control change, could be a bank change { // a control change, could be a bank change
if (MPU.midicmd.peek(0) == 0) if (MPU.midicmd.peek(0) == 0)
{ // bank select MSB { // bank select MSB
@ -2993,7 +2995,7 @@ void bx_sb16_c::processmidicommand(bx_bool force)
Bit8u temparray[256]; Bit8u temparray[256];
i = 0; i = 0;
while (MPU.midicmd.empty() == 0) while (MPU.midicmd.empty() == 0)
MPU.midicmd.get( &(temparray[i++]) ); MPU.midicmd.get(&(temparray[i++]));
writemidicommand(MPU.midicmd.currentcommand(), i, temparray); writemidicommand(MPU.midicmd.currentcommand(), i, temparray);
@ -3024,32 +3026,32 @@ void bx_sb16_c::midiremapprogram(int channel)
for(int i = 0; i < EMUL.remaps; i++) for(int i = 0; i < EMUL.remaps; i++)
{ {
if (( (EMUL.remaplist[i].oldbankmsb == bankmsb) || if (((EMUL.remaplist[i].oldbankmsb == bankmsb) ||
(EMUL.remaplist[i].oldbankmsb == 0xff) ) && (EMUL.remaplist[i].oldbankmsb == 0xff)) &&
( (EMUL.remaplist[i].oldbanklsb == banklsb) || ((EMUL.remaplist[i].oldbanklsb == banklsb) ||
(EMUL.remaplist[i].oldbanklsb == 0xff) ) && (EMUL.remaplist[i].oldbanklsb == 0xff)) &&
( (EMUL.remaplist[i].oldprogch == program) || ((EMUL.remaplist[i].oldprogch == program) ||
(EMUL.remaplist[i].oldprogch == 0xff) ) ) (EMUL.remaplist[i].oldprogch == 0xff)))
{ {
writelog(5, "Remapping instrument for channel %d", channel); writelog(5, "Remapping instrument for channel %d", channel);
if ( (EMUL.remaplist[i].newbankmsb != bankmsb) && if ((EMUL.remaplist[i].newbankmsb != bankmsb) &&
(EMUL.remaplist[i].newbankmsb != 0xff) ) (EMUL.remaplist[i].newbankmsb != 0xff))
{ // write control change bank msb { // write control change bank msb
MPU.bankmsb[channel] = EMUL.remaplist[i].newbankmsb; MPU.bankmsb[channel] = EMUL.remaplist[i].newbankmsb;
commandbytes[0] = 0; commandbytes[0] = 0;
commandbytes[1] = EMUL.remaplist[i].newbankmsb; commandbytes[1] = EMUL.remaplist[i].newbankmsb;
writemidicommand(0xb0 | channel, 2, commandbytes); writemidicommand(0xb0 | channel, 2, commandbytes);
} }
if ( (EMUL.remaplist[i].newbanklsb != banklsb) && if ((EMUL.remaplist[i].newbanklsb != banklsb) &&
(EMUL.remaplist[i].newbanklsb != 0xff) ) (EMUL.remaplist[i].newbanklsb != 0xff))
{ // write control change bank lsb { // write control change bank lsb
MPU.banklsb[channel] = EMUL.remaplist[i].newbanklsb; MPU.banklsb[channel] = EMUL.remaplist[i].newbanklsb;
commandbytes[0] = 32; commandbytes[0] = 32;
commandbytes[1] = EMUL.remaplist[i].newbanklsb; commandbytes[1] = EMUL.remaplist[i].newbanklsb;
writemidicommand(0xb0 | channel, 2, commandbytes); writemidicommand(0xb0 | channel, 2, commandbytes);
} }
if ( (EMUL.remaplist[i].newprogch != program) && if ((EMUL.remaplist[i].newprogch != program) &&
(EMUL.remaplist[i].newprogch != 0xff) ) (EMUL.remaplist[i].newprogch != 0xff))
{ // write program change { // write program change
MPU.program[channel] = EMUL.remaplist[i].newprogch; MPU.program[channel] = EMUL.remaplist[i].newprogch;
commandbytes[0] = EMUL.remaplist[i].newprogch; commandbytes[0] = EMUL.remaplist[i].newprogch;
@ -3059,7 +3061,6 @@ void bx_sb16_c::midiremapprogram(int channel)
} }
} }
// convert a number into a delta time coded value // convert a number into a delta time coded value
int bx_sb16_c::converttodeltatime(Bit32u deltatime, Bit8u value[4]) int bx_sb16_c::converttodeltatime(Bit32u deltatime, Bit8u value[4])
{ {
@ -3091,12 +3092,11 @@ int bx_sb16_c::converttodeltatime(Bit32u deltatime, Bit8u value[4])
void bx_sb16_c::writedeltatime(Bit32u deltatime) void bx_sb16_c::writedeltatime(Bit32u deltatime)
{ {
Bit8u outbytes[4]; Bit8u outbytes[4];
int count,i;
count = converttodeltatime(deltatime, outbytes); int count = converttodeltatime(deltatime, outbytes);
for (i=0; i<count; i++) for (int i=0; i<count; i++)
fputc(outbytes[i], MIDIDATA ); fputc(outbytes[i], MIDIDATA);
} }
@ -3109,7 +3109,7 @@ void bx_sb16_c::finishmidifile()
} metatrackend = { 0, 0xff, 0x2f, 0 }; } metatrackend = { 0, 0xff, 0x2f, 0 };
// Meta event track end (0xff 0x2f 0x00) plus leading delta time // Meta event track end (0xff 0x2f 0x00) plus leading delta time
fwrite(&metatrackend, 1, sizeof metatrackend, MIDIDATA ); fwrite(&metatrackend, 1, sizeof metatrackend, MIDIDATA);
Bit32u tracklen = ftell(MIDIDATA); Bit32u tracklen = ftell(MIDIDATA);
if (tracklen < 0) if (tracklen < 0)
@ -3178,7 +3178,7 @@ void bx_sb16_c::writevocblock(int block,
fwrite(lengthbytes, 1, 3, WAVEDATA); fwrite(lengthbytes, 1, 3, WAVEDATA);
#endif #endif
writelog(WAVELOG(5), "Voc block %d; Headerlen %d; Datalen %d", writelog(WAVELOG(5), "Voc block %d; Headerlen %d; Datalen %d",
block, headerlen, datalen ); block, headerlen, datalen);
if (headerlen > 0) if (headerlen > 0)
fwrite(header, 1, headerlen, WAVEDATA); fwrite(header, 1, headerlen, WAVEDATA);
if (datalen > 0) if (datalen > 0)
@ -3532,9 +3532,9 @@ bx_bool bx_sb16_buffer::puts(char *data, ...)
while (string[index] != 0) while (string[index] != 0)
{ {
if (put( (Bit8u) string[index]) == 0) if (put((Bit8u) string[index]) == 0)
return 0; // buffer full return 0; // buffer full
index++; index++;
} }
return 1; return 1;
} }
@ -3558,8 +3558,8 @@ bx_bool bx_sb16_buffer::get(Bit8u *data)
{ {
// Buffer is empty. Still, if it was initialized, return // Buffer is empty. Still, if it was initialized, return
// the last byte again. // the last byte again.
if ( length > 0 ) if (length > 0)
(*data) = buffer[ (tail - 1) % length ]; (*data) = buffer[ (tail - 1) % length ];
return 0; // buffer empty return 0; // buffer empty
} }
@ -3587,7 +3587,7 @@ bx_bool bx_sb16_buffer::getw(Bit16u *data)
get(&dummy); get(&dummy);
*data = (Bit16u) dummy; *data = (Bit16u) dummy;
get(&dummy); get(&dummy);
*data |= ( (Bit16u) dummy ) << 8; *data |= ((Bit16u) dummy) << 8;
return 1; return 1;
} }
@ -3600,14 +3600,14 @@ bx_bool bx_sb16_buffer::getw1(Bit16u *data)
if (bytes() == 1) if (bytes() == 1)
{ {
get(&dummy); get(&dummy);
*data = ( (Bit16u) dummy ) << 8; *data = ((Bit16u) dummy) << 8;
} }
else else
dummy = 0; dummy = 0;
return 0; return 0;
} }
get(&dummy); get(&dummy);
*data = ( (Bit16u) dummy ) << 8; *data = ((Bit16u) dummy) << 8;
get(&dummy); get(&dummy);
*data |= (Bit16u) dummy; *data |= (Bit16u) dummy;
return 1; return 1;

View File

@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: scsipt.h,v 1.4 2002-09-16 16:58:36 bdenney Exp $ // $Id: scsipt.h,v 1.5 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// //
// iodev/scsipt.h // iodev/scsipt.h
// $Id: scsipt.h,v 1.4 2002-09-16 16:58:36 bdenney Exp $ // $Id: scsipt.h,v 1.5 2008-02-15 22:05:43 sshwarts Exp $
// //
// This file was copied from ... ? // This file was copied from ... ?
// //
@ -128,7 +128,7 @@ typedef struct {
/* /*
* Standard IOCTL define * Standard IOCTL define
*/ */
#define CTL_CODE( DevType, Function, Method, Access ) ( \ #define CTL_CODE(DevType, Function, Method, Access) ( \
((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ ((DevType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
) )

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: serial.cc,v 1.80 2008-01-26 22:24:02 sshwarts Exp $ // $Id: serial.cc,v 1.81 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2004 MandrakeSoft S.A. // Copyright (C) 2004 MandrakeSoft S.A.
@ -23,7 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Peter Grehan (grehan@iprg.nokia.com) coded the original version of this // Peter Grehan (grehan@iprg.nokia.com) coded the original version of this
// serial emulation. He implemented a single 8250, and allow terminal // serial emulation. He implemented a single 8250, and allow terminal
@ -31,7 +31,6 @@
// The current version emulates up to 4 UART 16550A with FIFO. Terminal // The current version emulates up to 4 UART 16550A with FIFO. Terminal
// input/output now works on some more platforms. // input/output now works on some more platforms.
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing. // is used to know when we are exporting symbols and when we are importing.
@ -530,21 +529,18 @@ bx_serial_c::raise_interrupt(Bit8u port, int type)
} }
} }
// static IO port read callback handler // static IO port read callback handler
// redirects to non-static class handler to avoid virtual functions // redirects to non-static class handler to avoid virtual functions
Bit32u Bit32u bx_serial_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
bx_serial_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
{ {
#if !BX_USE_SER_SMF #if !BX_USE_SER_SMF
bx_serial_c *class_ptr = (bx_serial_c *) this_ptr; bx_serial_c *class_ptr = (bx_serial_c *) this_ptr;
return( class_ptr->read(address, io_len) ); return class_ptr->read(address, io_len);
} }
Bit32u bx_serial_c::read(Bit32u address, unsigned io_len)
Bit32u
bx_serial_c::read(Bit32u address, unsigned io_len)
{ {
#else #else
UNUSED(this_ptr); UNUSED(this_ptr);
@ -1337,7 +1333,7 @@ bx_serial_c::rx_timer(void)
int data; int data;
if ((data_ready = BX_SER_THIS s[port].raw->ready_receive())) { if ((data_ready = BX_SER_THIS s[port].raw->ready_receive())) {
data = BX_SER_THIS s[port].raw->receive(); data = BX_SER_THIS s[port].raw->receive();
if (data < 0 ) { if (data < 0) {
data_ready = 0; data_ready = 0;
switch (data) { switch (data) {
case RAW_EVENT_BREAK: case RAW_EVENT_BREAK:
@ -1460,9 +1456,9 @@ bx_serial_c::serial_mouse_enq(int delta_x, int delta_y, int delta_z, unsigned bu
return; return;
// scale down the motion // scale down the motion
if ( (delta_x < -1) || (delta_x > 1) ) if ((delta_x < -1) || (delta_x > 1))
delta_x /= 2; delta_x /= 2;
if ( (delta_y < -1) || (delta_y > 1) ) if ((delta_y < -1) || (delta_y > 1))
delta_y /= 2; delta_y /= 2;
if(delta_x>127) delta_x=127; if(delta_x>127) delta_x=127;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: slowdown_timer.cc,v 1.27 2007-09-28 19:52:06 sshwarts Exp $ // $Id: slowdown_timer.cc,v 1.28 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -24,6 +24,7 @@
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
/////////////////////////////////////////////////////////////////////////
#include "bochs.h" #include "bochs.h"
#include "slowdown_timer.h" #include "slowdown_timer.h"
@ -63,7 +64,7 @@ void bx_slowdown_timer_c::init(void)
{ {
// Return early if slowdown timer not selected // Return early if slowdown timer not selected
if ((SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_SLOWDOWN) && if ((SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_SLOWDOWN) &&
(SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_BOTH) ) (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_BOTH))
return; return;
BX_INFO(("using 'slowdown' timer synchronization method")); BX_INFO(("using 'slowdown' timer synchronization method"));

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: soundlnx.cc,v 1.12 2008-01-26 22:24:02 sshwarts Exp $ // $Id: soundlnx.cc,v 1.13 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,10 +23,10 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// This file (SOUNDLNX.CC) written and donated by Josef Drexler // This file (SOUNDLNX.CC) written and donated by Josef Drexler
#define NO_DEVICE_INCLUDES #define NO_DEVICE_INCLUDES
#include "iodev.h" #include "iodev.h"
#define BX_SOUNDLOW #define BX_SOUNDLOW
@ -69,17 +69,17 @@ int bx_sound_linux_c::midiready()
int bx_sound_linux_c::openmidioutput(char *device) int bx_sound_linux_c::openmidioutput(char *device)
{ {
if ( (device == NULL) || (strlen(device) < 1) ) if ((device == NULL) || (strlen(device) < 1))
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
midi = fopen(device,"w"); midi = fopen(device,"w");
if (midi == NULL) if (midi == NULL)
{ {
WRITELOG( MIDILOG(2), "Couldn't open midi output device %s: %s.", WRITELOG(MIDILOG(2), "Couldn't open midi output device %s: %s.",
device, strerror(errno)); device, strerror(errno));
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
} }
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
} }
@ -88,7 +88,6 @@ int bx_sound_linux_c::openmidioutput(char *device)
int bx_sound_linux_c::sendmidicommand(int delta, int command, int length, Bit8u data[]) int bx_sound_linux_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{ {
UNUSED(delta); UNUSED(delta);
// BX_PANIC(("Sendmidicommand!!");
fputc(command, midi); fputc(command, midi);
fwrite(data, 1, length, midi); fwrite(data, 1, length, midi);
@ -128,16 +127,16 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
int fmt, ret; int fmt, ret;
int signeddata = format & 1; int signeddata = format & 1;
if ( (wavedevice == NULL) || (strlen(wavedevice) < 1) ) if ((wavedevice == NULL) || (strlen(wavedevice) < 1))
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
if (wave == -1) if (wave == -1)
wave = open(wavedevice, O_WRONLY); wave = open(wavedevice, O_WRONLY);
else else
if ( (frequency == oldfreq) && if ((frequency == oldfreq) &&
(bits == oldbits) && (bits == oldbits) &&
(stereo == oldstereo) && (stereo == oldstereo) &&
(format == oldformat) ) (format == oldformat))
return BX_SOUND_OUTPUT_OK; // nothing to do return BX_SOUND_OUTPUT_OK; // nothing to do
oldfreq = frequency; oldfreq = frequency;
@ -164,53 +163,51 @@ int bx_sound_linux_c::startwaveplayback(int frequency, int bits, int stereo, int
// set frequency etc. // set frequency etc.
ret = ioctl(wave, SNDCTL_DSP_RESET); ret = ioctl(wave, SNDCTL_DSP_RESET);
if (ret != 0) if (ret != 0)
WRITELOG( WAVELOG(4), "ioctl(SNDCTL_DSP_RESET): %s", strerror(errno)); WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_RESET): %s", strerror(errno));
/* /*
ret = ioctl(wave, SNDCTL_DSP_SETFRAGMENT, &fragment); ret = ioctl(wave, SNDCTL_DSP_SETFRAGMENT, &fragment);
if (ret != 0) if (ret != 0)
WRITELOG( WAVELOG(4), "ioctl(SNDCTL_DSP_SETFRAGMENT, %d): %s", WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_SETFRAGMENT, %d): %s",
fragment, strerror(errno)); fragment, strerror(errno));
*/ */
ret = ioctl(wave, SNDCTL_DSP_SETFMT, &fmt); ret = ioctl(wave, SNDCTL_DSP_SETFMT, &fmt);
if (ret != 0) // abort if the format is unknown, to avoid playing noise if (ret != 0) // abort if the format is unknown, to avoid playing noise
{ {
WRITELOG( WAVELOG(4), "ioctl(SNDCTL_DSP_SETFMT, %d): %s", WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_SETFMT, %d): %s",
fmt, strerror(errno)); fmt, strerror(errno));
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
} }
ret = ioctl(wave, SNDCTL_DSP_STEREO, &stereo); ret = ioctl(wave, SNDCTL_DSP_STEREO, &stereo);
if (ret != 0) if (ret != 0)
WRITELOG( WAVELOG(4), "ioctl(SNDCTL_DSP_STEREO, %d): %s", WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_STEREO, %d): %s",
stereo, strerror(errno)); stereo, strerror(errno));
ret = ioctl(wave, SNDCTL_DSP_SPEED, &frequency); ret = ioctl(wave, SNDCTL_DSP_SPEED, &frequency);
if (ret != 0) if (ret != 0)
WRITELOG( WAVELOG(4), "ioctl(SNDCTL_DSP_SPEED, %d): %s", WRITELOG(WAVELOG(4), "ioctl(SNDCTL_DSP_SPEED, %d): %s",
frequency, strerror(errno)); frequency, strerror(errno));
// ioctl(wave, SNDCTL_DSP_GETBLKSIZE, &fragment); // ioctl(wave, SNDCTL_DSP_GETBLKSIZE, &fragment);
// WRITELOG( WAVELOG(4), "current output block size is %d", fragment); // WRITELOG(WAVELOG(4), "current output block size is %d", fragment);
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
} }
int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[]) int bx_sound_linux_c::sendwavepacket(int length, Bit8u data[])
{ {
int ret; int ret = write(wave, data, length);
ret = write(wave, data, length);
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
} }
int bx_sound_linux_c::stopwaveplayback() int bx_sound_linux_c::stopwaveplayback()
{ {
// ioctl(wave, SNDCTL_DSP_SYNC); // ioctl(wave, SNDCTL_DSP_SYNC);
// close(wave); // close(wave);
// wave = -1; // wave = -1;
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
} }
@ -221,10 +218,10 @@ int bx_sound_linux_c::closewaveoutput()
delete(wavedevice); delete(wavedevice);
if (wave != -1) if (wave != -1)
{ {
close(wave); close(wave);
wave = -1; wave = -1;
} }
wavedevice = NULL; wavedevice = NULL;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: soundosx.cc,v 1.8 2008-01-26 22:24:02 sshwarts Exp $ // $Id: soundosx.cc,v 1.9 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// This file (SOUNDOSX.CC) written and donated by Brian Huffman // This file (SOUNDOSX.CC) written and donated by Brian Huffman
@ -126,14 +126,14 @@ int bx_sound_osx_c::openmidioutput(char *device)
// Start playing // Start playing
AUGraphStart (MidiGraph); AUGraphStart (MidiGraph);
#endif #endif
WRITELOG( WAVELOG(4), "openmidioutput(%s)", device); WRITELOG(WAVELOG(4), "openmidioutput(%s)", device);
MidiOpen = 1; MidiOpen = 1;
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
} }
int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[]) int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u data[])
{ {
WRITELOG( WAVELOG(5), "sendmidicommand(%i,%02x,%i)", delta, command, length); WRITELOG(WAVELOG(5), "sendmidicommand(%i,%02x,%i)", delta, command, length);
if (!MidiOpen) return BX_SOUND_OUTPUT_ERR; if (!MidiOpen) return BX_SOUND_OUTPUT_ERR;
#ifdef BX_SOUND_OSX_use_converter #ifdef BX_SOUND_OSX_use_converter
@ -151,7 +151,7 @@ int bx_sound_osx_c::sendmidicommand(int delta, int command, int length, Bit8u da
int bx_sound_osx_c::closemidioutput() int bx_sound_osx_c::closemidioutput()
{ {
WRITELOG( WAVELOG(4), "closemidioutput()"); WRITELOG(WAVELOG(4), "closemidioutput()");
MidiOpen = 0; MidiOpen = 0;
#ifdef BX_SOUND_OSX_use_converter #ifdef BX_SOUND_OSX_use_converter
AUGraphStop (MidiGraph); AUGraphStop (MidiGraph);
@ -176,7 +176,7 @@ int bx_sound_osx_c::openwaveoutput(char *device)
{ {
OSStatus err; OSStatus err;
WRITELOG( WAVELOG(4), "openwaveoutput(%s)", device); WRITELOG(WAVELOG(4), "openwaveoutput(%s)", device);
// open the default output unit // open the default output unit
#ifdef BX_SOUND_OSX_use_quicktime #ifdef BX_SOUND_OSX_use_quicktime
@ -208,7 +208,7 @@ int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int f
UInt32 formatSize = sizeof(AudioStreamBasicDescription); UInt32 formatSize = sizeof(AudioStreamBasicDescription);
#endif #endif
WRITELOG( WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format); WRITELOG(WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format);
#ifdef BX_SOUND_OSX_use_quicktime #ifdef BX_SOUND_OSX_use_quicktime
WaveInfo.samplePtr = NULL; WaveInfo.samplePtr = NULL;
@ -228,10 +228,10 @@ int bx_sound_osx_c::startwaveplayback(int frequency, int bits, int stereo, int f
#endif #endif
#ifdef BX_SOUND_OSX_use_converter #ifdef BX_SOUND_OSX_use_converter
if ( (frequency == oldfreq) && if ((frequency == oldfreq) &&
(bits == oldbits) && (bits == oldbits) &&
(stereo == oldstereo) && (stereo == oldstereo) &&
(format == oldformat) ) (format == oldformat))
return BX_SOUND_OUTPUT_OK; // nothing to do return BX_SOUND_OUTPUT_OK; // nothing to do
oldfreq = frequency; oldfreq = frequency;
@ -299,7 +299,7 @@ int bx_sound_osx_c::sendwavepacket(int length, Bit8u data[])
SndCommand mySndCommand; SndCommand mySndCommand;
#endif #endif
WRITELOG( WAVELOG(4), "sendwavepacket(%d, %p), head=%u", length, data, head); WRITELOG(WAVELOG(4), "sendwavepacket(%d, %p), head=%u", length, data, head);
// sanity check // sanity check
if ((!WaveOpen) || (head - tail >= BX_SOUND_OSX_NBUF)) if ((!WaveOpen) || (head - tail >= BX_SOUND_OSX_NBUF))
@ -380,7 +380,7 @@ OSStatus MyACInputProc (AudioConverterRef inAudioConverter,
void bx_sound_osx_c::nextbuffer (int *outDataSize, void **outData) void bx_sound_osx_c::nextbuffer (int *outDataSize, void **outData)
{ {
WRITELOG( WAVELOG(4), "nextbuffer(), tail=%u", tail); WRITELOG(WAVELOG(4), "nextbuffer(), tail=%u", tail);
if (head - tail <= 0) { if (head - tail <= 0) {
*outData = NULL; *outData = NULL;
*outDataSize = 0; *outDataSize = 0;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: soundwin.cc,v 1.19 2008-01-26 22:24:02 sshwarts Exp $ // $Id: soundwin.cc,v 1.20 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,6 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// This file (SOUNDWIN.CC) written and donated by Josef Drexler // This file (SOUNDWIN.CC) written and donated by Josef Drexler
@ -57,12 +58,12 @@ bx_sound_windows_c::bx_sound_windows_c(bx_sb16_c *sb16)
// BX_SOUND_WINDOWS_NBUF wave header and buffers, all aligned // BX_SOUND_WINDOWS_NBUF wave header and buffers, all aligned
// on a 16-byte boundary // on a 16-byte boundary
#define ALIGN(size) ( (size + 15) & ~15 ) #define ALIGN(size) ((size + 15) & ~15)
#define size ALIGN(sizeof(MIDIHDR)) \ #define size ALIGN(sizeof(MIDIHDR)) \
+ ALIGN(sizeof(WAVEHDR)) \ + ALIGN(sizeof(WAVEHDR)) \
+ ALIGN(BX_SOUND_WINDOWS_MAXSYSEXLEN) * BX_SOUND_WINDOWS_NBUF \ + ALIGN(BX_SOUND_WINDOWS_MAXSYSEXLEN) * BX_SOUND_WINDOWS_NBUF \
+ ALIGN(BX_SOUND_OUTPUT_WAVEPACKETSIZE) * BX_SOUND_WINDOWS_NBUF + ALIGN(BX_SOUND_OUTPUT_WAVEPACKETSIZE) * BX_SOUND_WINDOWS_NBUF
DataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size); DataHandle = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
DataPointer = (Bit8u*) GlobalLock(DataHandle); DataPointer = (Bit8u*) GlobalLock(DataHandle);
@ -127,11 +128,11 @@ int bx_sound_windows_c::openmidioutput(char *device)
MidiOpen = 0; MidiOpen = 0;
UINT ret = midiOutOpen( &MidiOut, deviceid, 0, 0, CALLBACK_NULL); UINT ret = midiOutOpen(&MidiOut, deviceid, 0, 0, CALLBACK_NULL);
if (ret == 0) if (ret == 0)
MidiOpen = 1; MidiOpen = 1;
WRITELOG( MIDILOG(4), "midiOutOpen() = %d, MidiOpen: %d", ret, MidiOpen); WRITELOG(MIDILOG(4), "midiOutOpen() = %d, MidiOpen: %d", ret, MidiOpen);
return (MidiOpen == 1) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; return (MidiOpen == 1) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
} }
@ -143,33 +144,33 @@ int bx_sound_windows_c::sendmidicommand(int delta, int command, int length, Bit8
if (MidiOpen != 1) if (MidiOpen != 1)
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
if ( (command == 0xf0) || (command == 0xf7) || (length > 3) ) if ((command == 0xf0) || (command == 0xf7) || (length > 3))
{ {
WRITELOG( WAVELOG(5), "SYSEX started, length %d", length); WRITELOG(WAVELOG(5), "SYSEX started, length %d", length);
ismidiready = 0; // until the buffer is done ismidiready = 0; // until the buffer is done
memcpy(MidiData, data, length); memcpy(MidiData, data, length);
MidiHeader->lpData = MidiData; MidiHeader->lpData = MidiData;
MidiHeader->dwBufferLength = BX_SOUND_WINDOWS_MAXSYSEXLEN; MidiHeader->dwBufferLength = BX_SOUND_WINDOWS_MAXSYSEXLEN;
MidiHeader->dwBytesRecorded = 0; MidiHeader->dwBytesRecorded = 0;
MidiHeader->dwUser = 0; MidiHeader->dwUser = 0;
MidiHeader->dwFlags = 0; MidiHeader->dwFlags = 0;
ret = midiOutPrepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader)); ret = midiOutPrepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader));
if (ret != 0) if (ret != 0)
WRITELOG( MIDILOG(2), "midiOutPrepareHeader() = %d", ret); WRITELOG(MIDILOG(2), "midiOutPrepareHeader() = %d", ret);
ret = midiOutLongMsg(MidiOut, MidiHeader, sizeof(*MidiHeader)); ret = midiOutLongMsg(MidiOut, MidiHeader, sizeof(*MidiHeader));
if (ret != 0) if (ret != 0)
WRITELOG( MIDILOG(2), "midiOutLongMsg() = %d", ret); WRITELOG(MIDILOG(2), "midiOutLongMsg() = %d", ret);
} }
else else
{ {
DWORD msg = command; DWORD msg = command;
for (int i = 0; i<length; i++) for (int i = 0; i<length; i++)
msg |= (data[i] << (8 * (i + 1) ) ); msg |= (data[i] << (8 * (i + 1)));
ret = midiOutShortMsg(MidiOut, msg); ret = midiOutShortMsg(MidiOut, msg);
WRITELOG( MIDILOG(4), "midiOutShortMsg(%x) = %d", msg, ret); WRITELOG(MIDILOG(4), "midiOutShortMsg(%x) = %d", msg, ret);
} }
return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
} }
@ -186,7 +187,7 @@ int bx_sound_windows_c::closemidioutput()
checkmidiready(); // to clear any pending SYSEX checkmidiready(); // to clear any pending SYSEX
ret = midiOutClose(MidiOut); ret = midiOutClose(MidiOut);
WRITELOG( MIDILOG(4), "midiOutClose() = %d", ret); WRITELOG(MIDILOG(4), "midiOutClose() = %d", ret);
MidiOpen = 0; MidiOpen = 0;
return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR; return (ret == 0) ? BX_SOUND_OUTPUT_OK : BX_SOUND_OUTPUT_ERR;
@ -198,7 +199,7 @@ int bx_sound_windows_c::openwaveoutput(char *device)
// but currently only the midi mapper is supported // but currently only the midi mapper is supported
UNUSED(device); UNUSED(device);
WRITELOG( WAVELOG(4), "openwaveoutput(%s)", device); WRITELOG(WAVELOG(4), "openwaveoutput(%s)", device);
#ifdef usewaveOut #ifdef usewaveOut
WaveDevice = (UINT) WAVEMAPPER; WaveDevice = (UINT) WAVEMAPPER;
@ -225,7 +226,7 @@ int bx_sound_windows_c::playnextbuffer()
// so reset it first // so reset it first
if (needreopen != 0) if (needreopen != 0)
if (WaveOpen != 0) if (WaveOpen != 0)
ret = waveOutReset( WaveOut ); ret = waveOutReset(WaveOut);
// clean up the buffers and mark if output is ready // clean up the buffers and mark if output is ready
checkwaveready(); checkwaveready();
@ -236,131 +237,127 @@ int bx_sound_windows_c::playnextbuffer()
// if the format is different, we have to close and reopen the device // if the format is different, we have to close and reopen the device
// or, just open the device if it's not open yet // or, just open the device if it's not open yet
if ( (needreopen != 0) || (WaveOpen == 0) ) if ((needreopen != 0) || (WaveOpen == 0))
{
if (WaveOpen != 0)
{ {
if (WaveOpen != 0) ret = waveOutClose(WaveOut);
{ WaveOpen = 0;
ret = waveOutClose( WaveOut );
WaveOpen = 0;
}
// try three times to find a suitable format
for (int tries = 0; tries < 3; tries++)
{
int frequency = WaveInfo.frequency;
int stereo = WaveInfo.stereo;
int bits = WaveInfo.bits;
int format = WaveInfo.format;
int bps = (bits / 8) * (stereo + 1);
waveformat.wf.wFormatTag = WAVE_FORMAT_PCM;
waveformat.wf.nChannels = stereo + 1;
waveformat.wf.nSamplesPerSec = frequency;
waveformat.wf.nAvgBytesPerSec = frequency * bps;
waveformat.wf.nBlockAlign = bps;
waveformat.wBitsPerSample = bits;
ret = waveOutOpen( &(WaveOut), WaveDevice, (LPWAVEFORMATEX)&(waveformat.wf), 0, 0, CALLBACK_NULL);
if (ret != 0)
{
char errormsg[4*MAXERRORLENGTH+1];
waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1);
WRITELOG( WAVELOG(5), "waveOutOpen: %s", errormsg);
switch (tries)
{
case 0: // maybe try a different frequency
if (frequency < 15600)
frequency = 11025;
else if (frequency < 31200)
frequency = 22050;
else
frequency = 44100;
WRITELOG( WAVELOG(4), "Couldn't open wave device (error %d), trying frequency %d", ret, frequency);
break;
case 1: // or something else
frequency = 11025;
stereo = 0;
bits = 8;
bps = 1;
WRITELOG( WAVELOG(4), "Couldn't open wave device again (error %d), trying 11KHz, mono, 8bit", ret);
break;
case 2: // nope, doesn't work
WRITELOG( WAVELOG(2), "Couldn't open wave device (error %d)!", ret);
return BX_SOUND_OUTPUT_ERR;
}
WRITELOG( WAVELOG(5), "The format was: wFormatTag=%d, nChannels=%d, nSamplesPerSec=%d,",
waveformat.wf.wFormatTag, waveformat.wf.nChannels, waveformat.wf.nSamplesPerSec);
WRITELOG( WAVELOG(5), " nAvgBytesPerSec=%d, nBlockAlign=%d, wBitsPerSample=%d",
waveformat.wf.nAvgBytesPerSec, waveformat.wf.nBlockAlign, waveformat.wBitsPerSample);
}
else
{
WaveOpen = 1;
needreopen = 0;
break;
}
}
} }
// try three times to find a suitable format
for (int tries = 0; tries < 3; tries++)
{
int frequency = WaveInfo.frequency;
int stereo = WaveInfo.stereo;
int bits = WaveInfo.bits;
int format = WaveInfo.format;
int bps = (bits / 8) * (stereo + 1);
waveformat.wf.wFormatTag = WAVE_FORMAT_PCM;
waveformat.wf.nChannels = stereo + 1;
waveformat.wf.nSamplesPerSec = frequency;
waveformat.wf.nAvgBytesPerSec = frequency * bps;
waveformat.wf.nBlockAlign = bps;
waveformat.wBitsPerSample = bits;
ret = waveOutOpen(&(WaveOut), WaveDevice, (LPWAVEFORMATEX)&(waveformat.wf), 0, 0, CALLBACK_NULL);
if (ret != 0)
{
char errormsg[4*MAXERRORLENGTH+1];
waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1);
WRITELOG(WAVELOG(5), "waveOutOpen: %s", errormsg);
switch (tries) {
case 0: // maybe try a different frequency
if (frequency < 15600)
frequency = 11025;
else if (frequency < 31200)
frequency = 22050;
else
frequency = 44100;
WRITELOG(WAVELOG(4), "Couldn't open wave device (error %d), trying frequency %d", ret, frequency);
break;
case 1: // or something else
frequency = 11025;
stereo = 0;
bits = 8;
bps = 1;
WRITELOG(WAVELOG(4), "Couldn't open wave device again (error %d), trying 11KHz, mono, 8bit", ret);
break;
case 2: // nope, doesn't work
WRITELOG(WAVELOG(2), "Couldn't open wave device (error %d)!", ret);
return BX_SOUND_OUTPUT_ERR;
}
WRITELOG(WAVELOG(5), "The format was: wFormatTag=%d, nChannels=%d, nSamplesPerSec=%d,",
waveformat.wf.wFormatTag, waveformat.wf.nChannels, waveformat.wf.nSamplesPerSec);
WRITELOG(WAVELOG(5), " nAvgBytesPerSec=%d, nBlockAlign=%d, wBitsPerSample=%d",
waveformat.wf.nAvgBytesPerSec, waveformat.wf.nBlockAlign, waveformat.wBitsPerSample);
}
else
{
WaveOpen = 1;
needreopen = 0;
break;
}
}
}
for (bufnum=tailplay; bufnum != head; for (bufnum=tailplay; bufnum != head;
bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK, tailplay=bufnum) bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK, tailplay=bufnum)
{
WRITELOG(WAVELOG(5), "Playing buffer %d", bufnum);
// prepare the wave header
WaveHeader[bufnum]->lpData = WaveData[bufnum];
WaveHeader[bufnum]->dwBufferLength = length[bufnum];
WaveHeader[bufnum]->dwBytesRecorded = length[bufnum];
WaveHeader[bufnum]->dwUser = 0;
WaveHeader[bufnum]->dwFlags = 0;
WaveHeader[bufnum]->dwLoops = 1;
ret = waveOutPrepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
if (ret != 0)
{ {
WRITELOG( WAVELOG(5), "Playing buffer %d", bufnum); WRITELOG(WAVELOG(2), "waveOutPrepareHeader = %d", ret);
return BX_SOUND_OUTPUT_ERR;
// prepare the wave header
WaveHeader[bufnum]->lpData = WaveData[bufnum];
WaveHeader[bufnum]->dwBufferLength = length[bufnum];
WaveHeader[bufnum]->dwBytesRecorded = length[bufnum];
WaveHeader[bufnum]->dwUser = 0;
WaveHeader[bufnum]->dwFlags = 0;
WaveHeader[bufnum]->dwLoops = 1;
ret = waveOutPrepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
if (ret != 0)
{
WRITELOG( WAVELOG(2), "waveOutPrepareHeader = %d", ret);
return BX_SOUND_OUTPUT_ERR;
}
ret = waveOutWrite(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
if (ret != 0)
{
char errormsg[4*MAXERRORLENGTH+1];
waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1);
WRITELOG( WAVELOG(5), "waveOutWrite: %s", errormsg);
}
} }
return BX_SOUND_OUTPUT_OK;
ret = waveOutWrite(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
if (ret != 0)
{
char errormsg[4*MAXERRORLENGTH+1];
waveOutGetErrorTextA(ret, errormsg, 4*MAXERRORLENGTH+1);
WRITELOG(WAVELOG(5), "waveOutWrite: %s", errormsg);
}
}
return BX_SOUND_OUTPUT_OK;
} }
int bx_sound_windows_c::startwaveplayback(int frequency, int bits, int stereo, int format) int bx_sound_windows_c::startwaveplayback(int frequency, int bits, int stereo, int format)
{ {
// UINT ret; WRITELOG(WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format);
WRITELOG( WAVELOG(4), "startwaveplayback(%d, %d, %d, %x)", frequency, bits, stereo, format);
#ifdef usewaveOut #ifdef usewaveOut
// check if any of the properties have changed // check if any of the properties have changed
if ( (WaveInfo.frequency != frequency) || if ((WaveInfo.frequency != frequency) ||
(WaveInfo.bits != bits) || (WaveInfo.bits != bits) ||
(WaveInfo.stereo != stereo) || (WaveInfo.stereo != stereo) ||
(WaveInfo.format != format) ) (WaveInfo.format != format))
{ {
needreopen = 1; needreopen = 1;
// store the current settings to be used by sendwavepacket() // store the current settings to be used by sendwavepacket()
WaveInfo.frequency = frequency; WaveInfo.frequency = frequency;
WaveInfo.bits = bits; WaveInfo.bits = bits;
WaveInfo.stereo = stereo; WaveInfo.stereo = stereo;
WaveInfo.format = format; WaveInfo.format = format;
} }
#endif #endif
#ifdef usesndPlaySnd #ifdef usesndPlaySnd
@ -392,7 +389,7 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
UINT ret; UINT ret;
#endif #endif
WRITELOG( WAVELOG(4), "sendwavepacket(%d, %p)", length, data); WRITELOG(WAVELOG(4), "sendwavepacket(%d, %p)", length, data);
#ifdef usewaveOut #ifdef usewaveOut
bufnum = head; bufnum = head;
@ -404,25 +401,24 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
bufnum++; bufnum++;
bufnum &= BX_SOUND_WINDOWS_NMASK; bufnum &= BX_SOUND_WINDOWS_NMASK;
if ( ( (bufnum + 1) & BX_SOUND_WINDOWS_NMASK) == tailfull ) if (((bufnum + 1) & BX_SOUND_WINDOWS_NMASK) == tailfull)
{ // this should not actually happen! { // this should not actually happen!
WRITELOG( WAVELOG(2), "Output buffer overflow! Not played. Iswaveready was %d", iswaveready); WRITELOG(WAVELOG(2), "Output buffer overflow! Not played. Iswaveready was %d", iswaveready);
iswaveready = 0; // stop the output for a while iswaveready = 0; // stop the output for a while
return BX_SOUND_OUTPUT_ERR; return BX_SOUND_OUTPUT_ERR;
} }
head = bufnum; head = bufnum;
// check if more buffers are available, otherwise stall the emulator // check if more buffers are available, otherwise stall the emulator
if ( ( (bufnum + 2) & BX_SOUND_WINDOWS_NMASK) == tailfull ) if (((bufnum + 2) & BX_SOUND_WINDOWS_NMASK) == tailfull)
{ {
WRITELOG( WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Stall.", WRITELOG(WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Stall.",
head, tailfull, tailplay); head, tailfull, tailplay);
iswaveready = 0; iswaveready = 0;
} }
playnextbuffer(); playnextbuffer();
#endif #endif
#ifdef usesndPlaySnd #ifdef usesndPlaySnd
@ -431,13 +427,13 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
header->length = length + 36; header->length = length + 36;
header->chnk2len = length; header->chnk2len = length;
memcpy( &(header->data), data, length); memcpy(&(header->data), data, length);
ret = sndPlaySoundA( (LPCSTR) header, SND_SYNC | SND_MEMORY ); ret = sndPlaySoundA((LPCSTR) header, SND_SYNC | SND_MEMORY);
if (ret != 0) if (ret != 0)
{ {
WRITELOG( WAVELOG(3), "sndPlaySoundA: %d", ret); WRITELOG(WAVELOG(3), "sndPlaySoundA: %d", ret);
} }
#endif #endif
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
@ -445,14 +441,14 @@ int bx_sound_windows_c::sendwavepacket(int length, Bit8u data[])
int bx_sound_windows_c::stopwaveplayback() int bx_sound_windows_c::stopwaveplayback()
{ {
WRITELOG( WAVELOG(4), "stopwaveplayback()"); WRITELOG(WAVELOG(4), "stopwaveplayback()");
#ifdef usewaveOut #ifdef usewaveOut
// this is handled by checkwaveready() when closing // this is handled by checkwaveready() when closing
#endif #endif
#ifdef usesndPlaySnd #ifdef usesndPlaySnd
sndPlaySoundA( NULL, SND_ASYNC | SND_MEMORY ); sndPlaySoundA(NULL, SND_ASYNC | SND_MEMORY);
WaveOpen = 0; WaveOpen = 0;
#endif #endif
@ -462,25 +458,23 @@ int bx_sound_windows_c::stopwaveplayback()
int bx_sound_windows_c::closewaveoutput() int bx_sound_windows_c::closewaveoutput()
{ {
// int bufnum; WRITELOG(WAVELOG(4), "closewaveoutput");
WRITELOG( WAVELOG(4), "closewaveoutput");
#ifdef usewaveOut #ifdef usewaveOut
if (WaveOpen == 1) if (WaveOpen == 1)
{ {
waveOutReset(WaveOut); waveOutReset(WaveOut);
// let checkwaveready() clean up the buffers // let checkwaveready() clean up the buffers
checkwaveready(); checkwaveready();
waveOutClose(WaveOut); waveOutClose(WaveOut);
head = 0; head = 0;
tailfull = 0; tailfull = 0;
tailplay = 0; tailplay = 0;
needreopen = 0; needreopen = 0;
} }
#endif #endif
return BX_SOUND_OUTPUT_OK; return BX_SOUND_OUTPUT_OK;
@ -490,12 +484,12 @@ void bx_sound_windows_c::checkmidiready()
{ {
UINT ret; UINT ret;
if ( (MidiHeader->dwFlags & WHDR_DONE) != 0) if ((MidiHeader->dwFlags & WHDR_DONE) != 0)
{ {
WRITELOG( MIDILOG(5), "SYSEX message done, midi ready again."); WRITELOG(MIDILOG(5), "SYSEX message done, midi ready again.");
ret = midiOutUnprepareHeader( MidiOut, MidiHeader, sizeof(*MidiHeader)); ret = midiOutUnprepareHeader(MidiOut, MidiHeader, sizeof(*MidiHeader));
ismidiready = 1; ismidiready = 1;
} }
} }
void bx_sound_windows_c::checkwaveready() void bx_sound_windows_c::checkwaveready()
{ {
@ -503,25 +497,23 @@ void bx_sound_windows_c::checkwaveready()
UINT ret; UINT ret;
// clean up all finished buffers and mark them as available // clean up all finished buffers and mark them as available
for (bufnum=tailfull; for (bufnum=tailfull; (bufnum != tailplay) &&
(bufnum != tailplay) && ((WaveHeader[bufnum]->dwFlags & WHDR_DONE) != 0);
( (WaveHeader[bufnum]->dwFlags & WHDR_DONE) != 0); bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK)
bufnum++, bufnum &= BX_SOUND_WINDOWS_NMASK) {
{ WRITELOG(WAVELOG(5), "Buffer %d done.", bufnum);
WRITELOG( WAVELOG(5), "Buffer %d done.", bufnum); ret = waveOutUnprepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
}
ret = waveOutUnprepareHeader(WaveOut, WaveHeader[bufnum], sizeof(*WaveHeader[bufnum]));
}
tailfull = bufnum; tailfull = bufnum;
// enable gathering data if a buffer is available // enable gathering data if a buffer is available
if ( ( (head + 2) & BX_SOUND_WINDOWS_NMASK) != tailfull ) if (((head + 2) & BX_SOUND_WINDOWS_NMASK) != tailfull)
{ {
WRITELOG( WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Ready.", WRITELOG(WAVELOG(5), "Buffer status: Head %d, TailFull %d, TailPlay %d. Ready.",
head, tailfull, tailplay); head, tailfull, tailplay);
iswaveready = 1; iswaveready = 1;
} }
} }
#endif // defined(WIN32) #endif // defined(WIN32)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: unmapped.cc,v 1.26 2008-01-29 17:34:52 sshwarts Exp $ // $Id: unmapped.cc,v 1.27 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -23,9 +23,9 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
// is used to know when we are exporting symbols and when we are importing. // is used to know when we are exporting symbols and when we are importing.
@ -263,7 +263,7 @@ void bx_unmapped_c::write(Bit32u address, Bit32u value, unsigned io_len)
case 0xfedc: case 0xfedc:
bx_dbg.debugger = (value > 0); bx_dbg.debugger = (value > 0);
BX_DEBUG(( "DEBUGGER = %u", (unsigned) bx_dbg.debugger)); BX_DEBUG(("DEBUGGER = %u", (unsigned) bx_dbg.debugger));
break; break;
default: default:

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: vga.cc,v 1.150 2008-01-28 21:52:09 vruppert Exp $ // $Id: vga.cc,v 1.151 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,7 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/////////////////////////////////////////////////////////////////////////
// Define BX_PLUGGABLE in files that can be compiled into plugins. For // Define BX_PLUGGABLE in files that can be compiled into plugins. For
// platforms that require a special tag on exported symbols, BX_PLUGGABLE // platforms that require a special tag on exported symbols, BX_PLUGGABLE
@ -34,7 +34,6 @@
#define LOG_THIS theVga-> #define LOG_THIS theVga->
// (mch)
#define VGA_TRACE_FEATURE #define VGA_TRACE_FEATURE
// Only reference the array if the tile numbers are within the bounds // Only reference the array if the tile numbers are within the bounds
@ -266,7 +265,7 @@ void bx_vga_c::init(void)
bx_gui->init(argc, argv, BX_VGA_THIS s.x_tilesize, BX_VGA_THIS s.y_tilesize); bx_gui->init(argc, argv, BX_VGA_THIS s.x_tilesize, BX_VGA_THIS s.y_tilesize);
for (i = 1; i < (unsigned)argc; i++) for (i = 1; i < (unsigned)argc; i++)
{ {
if ( argv[i] != NULL ) if (argv[i] != NULL)
{ {
free(argv[i]); free(argv[i]);
argv[i] = NULL; argv[i] = NULL;
@ -565,7 +564,7 @@ void bx_vga_c::determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth
{ {
int ai[0x20]; int ai[0x20];
int i,h,v; int i,h,v;
for ( i = 0 ; i < 0x20 ; i++ ) for (i = 0 ; i < 0x20 ; i++)
ai[i] = BX_VGA_THIS s.CRTC.reg[i]; ai[i] = BX_VGA_THIS s.CRTC.reg[i];
h = (ai[1] + 1) * 8; h = (ai[1] + 1) * 8;
@ -576,7 +575,7 @@ void bx_vga_c::determine_screen_dimensions(unsigned *piHeight, unsigned *piWidth
*piWidth = 640; *piWidth = 640;
*piHeight = 480; *piHeight = 480;
if ( BX_VGA_THIS s.CRTC.reg[6] == 0xBF ) if (BX_VGA_THIS s.CRTC.reg[6] == 0xBF)
{ {
if (BX_VGA_THIS s.CRTC.reg[23] == 0xA3 && if (BX_VGA_THIS s.CRTC.reg[23] == 0xA3 &&
BX_VGA_THIS s.CRTC.reg[20] == 0x40 && BX_VGA_THIS s.CRTC.reg[20] == 0x40 &&
@ -654,26 +653,26 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
ret16 |= (bx_vga_c::read(address+1, 1) << 8; ret16 |= (bx_vga_c::read(address+1, 1) << 8;
#endif #endif
RETURN(ret16); RETURN(ret16);
} }
#ifdef __OS2__ #ifdef __OS2__
if ( bx_options.videomode == BX_VIDEO_DIRECT ) if (bx_options.videomode == BX_VIDEO_DIRECT)
{ {
return _inp(address); return _inp(address);
} }
#endif #endif
#if !defined(VGA_TRACE_FEATURE) #if !defined(VGA_TRACE_FEATURE)
BX_DEBUG(("io read from 0x%04x", (unsigned) address)); BX_DEBUG(("io read from 0x%04x", (unsigned) address));
#endif #endif
if ( (address >= 0x03b0) && (address <= 0x03bf) && if ((address >= 0x03b0) && (address <= 0x03bf) &&
(BX_VGA_THIS s.misc_output.color_emulation) ) { (BX_VGA_THIS s.misc_output.color_emulation)) {
RETURN(0xff); RETURN(0xff);
} }
if ( (address >= 0x03d0) && (address <= 0x03df) && if ((address >= 0x03d0) && (address <= 0x03df) &&
(BX_VGA_THIS s.misc_output.color_emulation==0) ) { (BX_VGA_THIS s.misc_output.color_emulation==0)) {
RETURN(0xff); RETURN(0xff);
} }
switch (address) { switch (address) {
@ -690,7 +689,7 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
// using 72 Hz vertical frequency // using 72 Hz vertical frequency
usec = bx_pc_system.time_usec(); usec = bx_pc_system.time_usec();
switch ( ( BX_VGA_THIS s.misc_output.vert_sync_pol << 1) | BX_VGA_THIS s.misc_output.horiz_sync_pol ) switch ((BX_VGA_THIS s.misc_output.vert_sync_pol << 1) | BX_VGA_THIS s.misc_output.horiz_sync_pol)
{ {
case 0: vertres = 200; break; case 0: vertres = 200; break;
case 1: vertres = 400; break; case 1: vertres = 400; break;
@ -810,7 +809,7 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
BX_DEBUG(("io read 0x3c5: index %u unhandled", BX_DEBUG(("io read 0x3c5: index %u unhandled",
(unsigned) BX_VGA_THIS s.sequencer.index)); (unsigned) BX_VGA_THIS s.sequencer.index));
RETURN(0); RETURN(0);
} }
break; break;
case 0x03c6: /* PEL mask ??? */ case 0x03c6: /* PEL mask ??? */
@ -895,7 +894,7 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
case 5: /* Mode */ case 5: /* Mode */
retval = retval =
((BX_VGA_THIS s.graphics_ctrl.shift_reg & 0x03) << 5) | ((BX_VGA_THIS s.graphics_ctrl.shift_reg & 0x03) << 5) |
((BX_VGA_THIS s.graphics_ctrl.odd_even & 0x01 ) << 4) | ((BX_VGA_THIS s.graphics_ctrl.odd_even & 0x01) << 4) |
((BX_VGA_THIS s.graphics_ctrl.read_mode & 0x01) << 3) | ((BX_VGA_THIS s.graphics_ctrl.read_mode & 0x01) << 3) |
((BX_VGA_THIS s.graphics_ctrl.write_mode & 0x03) << 0); ((BX_VGA_THIS s.graphics_ctrl.write_mode & 0x03) << 0);
@ -906,7 +905,7 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
break; break;
case 6: /* Miscellaneous */ case 6: /* Miscellaneous */
retval = retval =
((BX_VGA_THIS s.graphics_ctrl.memory_mapping & 0x03 ) << 2) | ((BX_VGA_THIS s.graphics_ctrl.memory_mapping & 0x03) << 2) |
((BX_VGA_THIS s.graphics_ctrl.odd_even & 0x01) << 1) | ((BX_VGA_THIS s.graphics_ctrl.odd_even & 0x01) << 1) |
((BX_VGA_THIS s.graphics_ctrl.graphics_alpha & 0x01) << 0); ((BX_VGA_THIS s.graphics_ctrl.graphics_alpha & 0x01) << 0);
RETURN(retval); RETURN(retval);
@ -947,13 +946,13 @@ Bit32u bx_vga_c::read(Bit32u address, unsigned io_len)
} }
#if defined(VGA_TRACE_FEATURE) #if defined(VGA_TRACE_FEATURE)
read_return: read_return:
if (io_len == 1) { if (io_len == 1) {
BX_DEBUG(("8-bit read from 0x%04x = 0x%02x", (unsigned) address, ret)); BX_DEBUG(("8-bit read from 0x%04x = 0x%02x", (unsigned) address, ret));
} else { } else {
BX_DEBUG(("16-bit read from 0x%04x = 0x%04x", (unsigned) address, ret)); BX_DEBUG(("16-bit read from 0x%04x = 0x%04x", (unsigned) address, ret));
} }
return ret; return ret;
#endif #endif
} }
#if defined(VGA_TRACE_FEATURE) #if defined(VGA_TRACE_FEATURE)
@ -994,16 +993,16 @@ void bx_vga_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_l
#if defined(VGA_TRACE_FEATURE) #if defined(VGA_TRACE_FEATURE)
if (!no_log) if (!no_log)
switch (io_len) { switch (io_len) {
case 1: case 1:
BX_DEBUG(("8-bit write to %04x = %02x", (unsigned)address, (unsigned)value)); BX_DEBUG(("8-bit write to %04x = %02x", (unsigned)address, (unsigned)value));
break; break;
case 2: case 2:
BX_DEBUG(("16-bit write to %04x = %04x", (unsigned)address, (unsigned)value)); BX_DEBUG(("16-bit write to %04x = %04x", (unsigned)address, (unsigned)value));
break; break;
default: default:
BX_PANIC(("Weird VGA write size")); BX_PANIC(("Weird VGA write size"));
} }
#else #else
if (io_len == 1) { if (io_len == 1) {
BX_DEBUG(("io write to 0x%04x = 0x%02x", (unsigned) address, BX_DEBUG(("io write to 0x%04x = 0x%02x", (unsigned) address,
@ -1023,18 +1022,18 @@ void bx_vga_c::write(Bit32u address, Bit32u value, unsigned io_len, bx_bool no_l
} }
#ifdef __OS2__ #ifdef __OS2__
if ( bx_options.videomode == BX_VIDEO_DIRECT ) if (bx_options.videomode == BX_VIDEO_DIRECT)
{ {
_outp(address,value); _outp(address,value);
return; return;
} }
#endif #endif
if ( (address >= 0x03b0) && (address <= 0x03bf) && if ((address >= 0x03b0) && (address <= 0x03bf) &&
(BX_VGA_THIS s.misc_output.color_emulation) ) (BX_VGA_THIS s.misc_output.color_emulation))
return; return;
if ( (address >= 0x03d0) && (address <= 0x03df) && if ((address >= 0x03d0) && (address <= 0x03df) &&
(BX_VGA_THIS s.misc_output.color_emulation==0) ) (BX_VGA_THIS s.misc_output.color_emulation==0))
return; return;
switch (address) { switch (address) {
@ -1878,8 +1877,7 @@ void bx_vga_c::update(void)
BX_VGA_THIS s.last_bpp = 8; BX_VGA_THIS s.last_bpp = 8;
} }
switch ( BX_VGA_THIS s.graphics_ctrl.shift_reg ) { switch (BX_VGA_THIS s.graphics_ctrl.shift_reg) {
case 0: case 0:
Bit8u attribute, palette_reg_val, DAC_regno; Bit8u attribute, palette_reg_val, DAC_regno;
unsigned long line_compare; unsigned long line_compare;
@ -2035,7 +2033,7 @@ void bx_vga_c::update(void)
// (format for VGA mode 13 hex) // (format for VGA mode 13 hex)
case 3: // FIXME: is this really the same ??? case 3: // FIXME: is this really the same ???
if ( BX_VGA_THIS s.sequencer.chain_four ) { if (BX_VGA_THIS s.sequencer.chain_four) {
unsigned long pixely, pixelx, plane; unsigned long pixely, pixelx, plane;
if (BX_VGA_THIS s.misc_output.select_high_bank != 1) if (BX_VGA_THIS s.misc_output.select_high_bank != 1)
@ -2054,14 +2052,14 @@ void bx_vga_c::update(void)
(pixely * BX_VGA_THIS s.line_offset) + (pixelx & ~0x03); (pixely * BX_VGA_THIS s.line_offset) + (pixelx & ~0x03);
color = BX_VGA_THIS s.memory[byte_offset]; color = BX_VGA_THIS s.memory[byte_offset];
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color; BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color;
}
} }
}
SET_TILE_UPDATED (xti, yti, 0); SET_TILE_UPDATED (xti, yti, 0);
bx_gui->graphics_tile_update(BX_VGA_THIS s.tile, xc, yc); bx_gui->graphics_tile_update(BX_VGA_THIS s.tile, xc, yc);
}
} }
} }
} }
}
else { // chain_four == 0, modeX else { // chain_four == 0, modeX
unsigned long pixely, pixelx, plane; unsigned long pixely, pixelx, plane;
@ -2080,24 +2078,24 @@ void bx_vga_c::update(void)
+ (pixelx >> 2); + (pixelx >> 2);
color = BX_VGA_THIS s.memory[start_addr + byte_offset]; color = BX_VGA_THIS s.memory[start_addr + byte_offset];
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color; BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color;
}
} }
}
SET_TILE_UPDATED (xti, yti, 0); SET_TILE_UPDATED (xti, yti, 0);
bx_gui->graphics_tile_update(BX_VGA_THIS s.tile, xc, yc); bx_gui->graphics_tile_update(BX_VGA_THIS s.tile, xc, yc);
} }
}
} }
} }
}
break; // case 2 break; // case 2
default: default:
BX_PANIC(("update: shift_reg == %u", (unsigned) BX_PANIC(("update: shift_reg == %u", (unsigned)
BX_VGA_THIS s.graphics_ctrl.shift_reg )); BX_VGA_THIS s.graphics_ctrl.shift_reg));
} }
BX_VGA_THIS s.vga_mem_updated = 0; BX_VGA_THIS s.vga_mem_updated = 0;
return; return;
} }
else { // text mode else { // text mode
unsigned long start_address; unsigned long start_address;
@ -2275,7 +2273,7 @@ Bit8u bx_vga_c::mem_read(Bit32u addr)
offset = addr & 0x1FFFF; offset = addr & 0x1FFFF;
} }
if ( BX_VGA_THIS s.sequencer.chain_four ) { if (BX_VGA_THIS s.sequencer.chain_four) {
// Mode 13h: 320 x 200 256 color mode: chained pixel representation // Mode 13h: 320 x 200 256 color mode: chained pixel representation
return BX_VGA_THIS s.memory[(offset & ~0x03) + (offset % 4)*65536]; return BX_VGA_THIS s.memory[(offset & ~0x03) + (offset % 4)*65536];
} }
@ -2382,7 +2380,7 @@ void bx_vga_c::mem_write(Bit32u addr, Bit8u value)
#endif #endif
#if defined(VGA_TRACE_FEATURE) #if defined(VGA_TRACE_FEATURE)
// BX_DEBUG(("8-bit memory write to %08x = %02x", addr, value)); //BX_DEBUG(("8-bit memory write to %08x = %02x", addr, value));
#endif #endif
#ifdef __OS2__ #ifdef __OS2__
@ -2413,7 +2411,7 @@ void bx_vga_c::mem_write(Bit32u addr, Bit8u value)
break; break;
default: // 0xA0000 .. 0xBFFFF default: // 0xA0000 .. 0xBFFFF
offset = addr - 0xA0000; offset = addr - 0xA0000;
} }
start_addr = (BX_VGA_THIS s.CRTC.reg[0x0c] << 8) | BX_VGA_THIS s.CRTC.reg[0x0d]; start_addr = (BX_VGA_THIS s.CRTC.reg[0x0c] << 8) | BX_VGA_THIS s.CRTC.reg[0x0d];
@ -2463,15 +2461,14 @@ void bx_vga_c::mem_write(Bit32u addr, Bit8u value)
} }
return; return;
/* CGA 320x200x4 / 640x200x2 end */ /* CGA 320x200x4 / 640x200x2 end */
} }
else if (BX_VGA_THIS s.graphics_ctrl.memory_mapping != 1) { else if (BX_VGA_THIS s.graphics_ctrl.memory_mapping != 1) {
BX_PANIC(("mem_write: graphics: mapping = %u", BX_PANIC(("mem_write: graphics: mapping = %u",
(unsigned) BX_VGA_THIS s.graphics_ctrl.memory_mapping)); (unsigned) BX_VGA_THIS s.graphics_ctrl.memory_mapping));
return; return;
} }
if ( BX_VGA_THIS s.sequencer.chain_four ) { if (BX_VGA_THIS s.sequencer.chain_four) {
unsigned x_tileno, y_tileno; unsigned x_tileno, y_tileno;
// 320 x 200 256 color mode: chained pixel representation // 320 x 200 256 color mode: chained pixel representation
@ -2624,7 +2621,7 @@ void bx_vga_c::mem_write(Bit32u addr, Bit8u value)
break; break;
case 1: /* write mode 1 */ case 1: /* write mode 1 */
for (i=0; i<4; i++ ) { for (i=0; i<4; i++) {
new_val[i] = BX_VGA_THIS s.graphics_ctrl.latch[i]; new_val[i] = BX_VGA_THIS s.graphics_ctrl.latch[i];
} }
break; break;
@ -2856,8 +2853,8 @@ void bx_vga_c::dump_status(void)
(unsigned) BX_VGA_THIS s.misc_output.horiz_sync_pol); (unsigned) BX_VGA_THIS s.misc_output.horiz_sync_pol);
dbg_printf("s.misc_output.vert_sync_pol = %u ", dbg_printf("s.misc_output.vert_sync_pol = %u ",
(unsigned) BX_VGA_THIS s.misc_output.vert_sync_pol); (unsigned) BX_VGA_THIS s.misc_output.vert_sync_pol);
switch ( (BX_VGA_THIS s.misc_output.vert_sync_pol << 1) | switch ((BX_VGA_THIS s.misc_output.vert_sync_pol << 1) |
BX_VGA_THIS s.misc_output.horiz_sync_pol ) { BX_VGA_THIS s.misc_output.horiz_sync_pol) {
case 1: dbg_printf("(400 lines)\n"); break; case 1: dbg_printf("(400 lines)\n"); break;
case 2: dbg_printf("(350 lines)\n"); break; case 2: dbg_printf("(350 lines)\n"); break;
case 3: dbg_printf("(480 lines)\n"); break; case 3: dbg_printf("(480 lines)\n"); break;
@ -3045,8 +3042,7 @@ Bit32u bx_vga_c::vbe_read_handler(void *this_ptr, Bit32u address, unsigned io_le
{ {
#if !BX_USE_VGA_SMF #if !BX_USE_VGA_SMF
bx_vga_c *class_ptr = (bx_vga_c *) this_ptr; bx_vga_c *class_ptr = (bx_vga_c *) this_ptr;
return class_ptr->vbe_read(address, io_len);
return( class_ptr->vbe_read(address, io_len) );
} }
Bit32u bx_vga_c::vbe_read(Bit32u address, unsigned io_len) Bit32u bx_vga_c::vbe_read(Bit32u address, unsigned io_len)
@ -3187,11 +3183,11 @@ Bit32u bx_vga_c::vbe_write(Bit32u address, Bit32u value, unsigned io_len)
{ {
case VBE_DISPI_INDEX_ID: // Display Interface ID check case VBE_DISPI_INDEX_ID: // Display Interface ID check
{ {
if ( (value == VBE_DISPI_ID0) || if ((value == VBE_DISPI_ID0) ||
(value == VBE_DISPI_ID1) || (value == VBE_DISPI_ID1) ||
(value == VBE_DISPI_ID2) || (value == VBE_DISPI_ID2) ||
(value == VBE_DISPI_ID3) || (value == VBE_DISPI_ID3) ||
(value == VBE_DISPI_ID4) ) (value == VBE_DISPI_ID4))
{ {
// allow backwards compatible with previous dispi bioses // allow backwards compatible with previous dispi bioses
BX_VGA_THIS s.vbe_cur_dispi=value; BX_VGA_THIS s.vbe_cur_dispi=value;

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// $Id: virt_timer.cc,v 1.36 2008-01-26 22:24:03 sshwarts Exp $ // $Id: virt_timer.cc,v 1.37 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -23,6 +23,7 @@
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
@ -127,8 +128,8 @@ bx_virt_timer_c bx_virt_timer;
//Conversion between emulated useconds and optionally realtime ticks. //Conversion between emulated useconds and optionally realtime ticks.
#define TICKS_TO_USEC(a) ( ((a)*usec_per_second)/ticks_per_second ) #define TICKS_TO_USEC(a) (((a)*usec_per_second)/ticks_per_second)
#define USEC_TO_TICKS(a) ( ((a)*ticks_per_second)/usec_per_second ) #define USEC_TO_TICKS(a) (((a)*ticks_per_second)/usec_per_second)
bx_virt_timer_c::bx_virt_timer_c() bx_virt_timer_c::bx_virt_timer_c()
{ {
@ -390,8 +391,8 @@ void bx_virt_timer_c::setup(void)
void bx_virt_timer_c::init(void) void bx_virt_timer_c::init(void)
{ {
if ( (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get()!=BX_CLOCK_SYNC_REALTIME) if ((SIM->get_param_enum(BXPN_CLOCK_SYNC)->get()!=BX_CLOCK_SYNC_REALTIME) &&
&& (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get()!=BX_CLOCK_SYNC_BOTH) ) (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get()!=BX_CLOCK_SYNC_BOTH))
virtual_timers_realtime = 0; virtual_timers_realtime = 0;
else else
virtual_timers_realtime = 1; virtual_timers_realtime = 1;

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// $Id: virt_timer.h,v 1.14 2007-09-28 19:52:08 sshwarts Exp $ // $Id: virt_timer.h,v 1.15 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -34,9 +34,7 @@
#define BX_MAX_VIRTUAL_TIME (0x7fffffff) #define BX_MAX_VIRTUAL_TIME (0x7fffffff)
class bx_virt_timer_c : public logfunctions class bx_virt_timer_c : public logfunctions {
{
private: private:
struct { struct {
@ -122,21 +120,21 @@ public:
//Register a timer handler to go off after a given interval. //Register a timer handler to go off after a given interval.
//Register a timer handler to go off with a periodic interval. //Register a timer handler to go off with a periodic interval.
int register_timer( void *this_ptr, bx_timer_handler_t handler, int register_timer(void *this_ptr, bx_timer_handler_t handler,
Bit32u useconds, Bit32u useconds,
bx_bool continuous, bx_bool active, const char *id); bx_bool continuous, bx_bool active, const char *id);
//unregister a previously registered timer. //unregister a previously registered timer.
bx_bool unregisterTimer(unsigned timerID); bx_bool unregisterTimer(unsigned timerID);
void start_timers(void); void start_timers(void);
//activate a deactivated but registered timer. //activate a deactivated but registered timer.
void activate_timer( unsigned timer_index, Bit32u useconds, void activate_timer(unsigned timer_index, Bit32u useconds,
bx_bool continuous ); bx_bool continuous);
//deactivate (but don't unregister) a currently registered timer. //deactivate (but don't unregister) a currently registered timer.
void deactivate_timer( unsigned timer_index ); void deactivate_timer(unsigned timer_index);
//Timer handler passed to pc_system //Timer handler passed to pc_system

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: logio.cc,v 1.66 2008-02-15 19:03:53 sshwarts Exp $ // $Id: logio.cc,v 1.67 2008-02-15 22:05:37 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2001 MandrakeSoft S.A. // Copyright (C) 2001 MandrakeSoft S.A.
@ -161,7 +161,7 @@ void iofunctions::set_log_prefix(const char* prefix)
strcpy(logprefix, prefix); strcpy(logprefix, prefix);
} }
// iofunctions::out( class, level, prefix, fmt, ap) // iofunctions::out(class, level, prefix, fmt, ap)
// DO NOT nest out() from ::info() and the like. // DO NOT nest out() from ::info() and the like.
// fmt and ap retained for direct printinf from iofunctions only! // fmt and ap retained for direct printinf from iofunctions only!

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.373 2008-02-15 19:03:53 sshwarts Exp $ // $Id: main.cc,v 1.374 2008-02-15 22:05:37 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -185,7 +185,7 @@ static void carbonFatalDialog(const char *error, const char *exposition)
cfExposition, /* can be NULL */ cfExposition, /* can be NULL */
&alertParam, /* can be NULL */ &alertParam, /* can be NULL */
&alertDialog); &alertDialog);
RunStandardAlert( alertDialog, NULL, &index); RunStandardAlert(alertDialog, NULL, &index);
// Cleanup // Cleanup
CFRelease(cfError); CFRelease(cfError);
if(cfExposition != NULL) { CFRelease(cfExposition); } if(cfExposition != NULL) { CFRelease(cfExposition); }
@ -429,7 +429,7 @@ int RedirectIOToConsole()
// redirect unbuffered STDERR to the console // redirect unbuffered STDERR to the console
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" ); fp = _fdopen(hConHandle, "w");
*stderr = *fp; *stderr = *fp;
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
return 1; return 1;
@ -654,7 +654,7 @@ int bx_init_main(int argc, char *argv[])
// our plugins into true frameworks and bundles either // our plugins into true frameworks and bundles either
mainBundle = CFBundleGetMainBundle(); mainBundle = CFBundleGetMainBundle();
BX_ASSERT(mainBundle != NULL); BX_ASSERT(mainBundle != NULL);
libDir = CFBundleCopyAuxiliaryExecutableURL( mainBundle, CFSTR("lib")); libDir = CFBundleCopyAuxiliaryExecutableURL(mainBundle, CFSTR("lib"));
BX_ASSERT(libDir != NULL); BX_ASSERT(libDir != NULL);
// translate this to a unix style full path // translate this to a unix style full path
if(!CFURLGetFileSystemRepresentation(libDir, true, (UInt8 *)libDirPath, MAXPATHLEN)) if(!CFURLGetFileSystemRepresentation(libDir, true, (UInt8 *)libDirPath, MAXPATHLEN))

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: misc_mem.cc,v 1.109 2008-02-03 20:27:06 sshwarts Exp $ // $Id: misc_mem.cc,v 1.110 2008-02-15 22:05:43 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -90,7 +90,7 @@ void BX_MEM_C::init_memory(Bit32u memsize)
{ {
unsigned idx; unsigned idx;
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.109 2008-02-03 20:27:06 sshwarts Exp $")); BX_DEBUG(("Init $Id: misc_mem.cc,v 1.110 2008-02-15 22:05:43 sshwarts Exp $"));
alloc_vector_aligned(memsize+ BIOSROMSZ + EXROMSIZE + 4096, BX_MEM_VECTOR_ALIGN); alloc_vector_aligned(memsize+ BIOSROMSZ + EXROMSIZE + 4096, BX_MEM_VECTOR_ALIGN);
BX_MEM_THIS len = memsize; BX_MEM_THIS len = memsize;
@ -187,13 +187,13 @@ void BX_MEM_C::load_ROM(const char *path, bx_phy_address romaddress, Bit8u type)
if (*path == '\0') { if (*path == '\0') {
if (type == 2) { if (type == 2) {
BX_PANIC(( "ROM: Optional ROM image undefined")); BX_PANIC(("ROM: Optional ROM image undefined"));
} }
else if (type == 1) { else if (type == 1) {
BX_PANIC(( "ROM: VGA BIOS image undefined")); BX_PANIC(("ROM: VGA BIOS image undefined"));
} }
else { else {
BX_PANIC(( "ROM: System BIOS image undefined")); BX_PANIC(("ROM: System BIOS image undefined"));
} }
return; return;
} }
@ -205,20 +205,20 @@ void BX_MEM_C::load_ROM(const char *path, bx_phy_address romaddress, Bit8u type)
); );
if (fd < 0) { if (fd < 0) {
if (type < 2) { if (type < 2) {
BX_PANIC(( "ROM: couldn't open ROM image file '%s'.", path)); BX_PANIC(("ROM: couldn't open ROM image file '%s'.", path));
} }
else { else {
BX_ERROR(( "ROM: couldn't open ROM image file '%s'.", path)); BX_ERROR(("ROM: couldn't open ROM image file '%s'.", path));
} }
return; return;
} }
ret = fstat(fd, &stat_buf); ret = fstat(fd, &stat_buf);
if (ret) { if (ret) {
if (type < 2) { if (type < 2) {
BX_PANIC(( "ROM: couldn't stat ROM image file '%s'.", path)); BX_PANIC(("ROM: couldn't stat ROM image file '%s'.", path));
} }
else { else {
BX_ERROR(( "ROM: couldn't stat ROM image file '%s'.", path)); BX_ERROR(("ROM: couldn't stat ROM image file '%s'.", path));
} }
return; return;
} }
@ -289,7 +289,7 @@ void BX_MEM_C::load_ROM(const char *path, bx_phy_address romaddress, Bit8u type)
while (size > 0) { while (size > 0) {
ret = read(fd, (bx_ptr_t) &BX_MEM_THIS rom[offset], size); ret = read(fd, (bx_ptr_t) &BX_MEM_THIS rom[offset], size);
if (ret <= 0) { if (ret <= 0) {
BX_PANIC(( "ROM: read failed on BIOS image: '%s'",path)); BX_PANIC(("ROM: read failed on BIOS image: '%s'",path));
} }
size -= ret; size -= ret;
offset += ret; offset += ret;
@ -304,9 +304,9 @@ void BX_MEM_C::load_ROM(const char *path, bx_phy_address romaddress, Bit8u type)
} }
if (checksum != 0) { if (checksum != 0) {
if (type == 1) { if (type == 1) {
BX_PANIC(( "ROM: checksum error in VGABIOS image: '%s'", path)); BX_PANIC(("ROM: checksum error in VGABIOS image: '%s'", path));
} else if (is_bochs_bios) { } else if (is_bochs_bios) {
BX_ERROR(( "ROM: checksum error in BIOS image: '%s'", path)); BX_ERROR(("ROM: checksum error in BIOS image: '%s'", path));
} }
} }
} }
@ -323,7 +323,7 @@ void BX_MEM_C::load_RAM(const char *path, bx_phy_address ramaddress, Bit8u type)
unsigned long size, offset; unsigned long size, offset;
if (*path == '\0') { if (*path == '\0') {
BX_PANIC(( "RAM: Optional RAM image undefined")); BX_PANIC(("RAM: Optional RAM image undefined"));
return; return;
} }
// read in RAM BIOS image file // read in RAM BIOS image file
@ -333,12 +333,12 @@ void BX_MEM_C::load_RAM(const char *path, bx_phy_address ramaddress, Bit8u type)
#endif #endif
); );
if (fd < 0) { if (fd < 0) {
BX_PANIC(( "RAM: couldn't open RAM image file '%s'.", path)); BX_PANIC(("RAM: couldn't open RAM image file '%s'.", path));
return; return;
} }
ret = fstat(fd, &stat_buf); ret = fstat(fd, &stat_buf);
if (ret) { if (ret) {
BX_PANIC(( "RAM: couldn't stat RAM image file '%s'.", path)); BX_PANIC(("RAM: couldn't stat RAM image file '%s'.", path));
return; return;
} }
@ -348,7 +348,7 @@ void BX_MEM_C::load_RAM(const char *path, bx_phy_address ramaddress, Bit8u type)
while (size > 0) { while (size > 0) {
ret = read(fd, (bx_ptr_t) &BX_MEM_THIS vector[offset], size); ret = read(fd, (bx_ptr_t) &BX_MEM_THIS vector[offset], size);
if (ret <= 0) { if (ret <= 0) {
BX_PANIC(( "RAM: read failed on RAM image: '%s'",path)); BX_PANIC(("RAM: read failed on RAM image: '%s'",path));
} }
size -= ret; size -= ret;
offset += ret; offset += ret;
@ -362,7 +362,7 @@ void BX_MEM_C::load_RAM(const char *path, bx_phy_address ramaddress, Bit8u type)
#endif // #if BX_PROVIDE_CPU_MEMORY #endif // #if BX_PROVIDE_CPU_MEMORY
#if ( BX_DEBUGGER || BX_DISASM || BX_GDBSTUB) #if (BX_DEBUGGER || BX_DISASM || BX_GDBSTUB)
bx_bool BX_MEM_C::dbg_fetch_mem(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, Bit8u *buf) bx_bool BX_MEM_C::dbg_fetch_mem(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, Bit8u *buf)
{ {
bx_bool ret = 1; bx_bool ret = 1;
@ -576,7 +576,7 @@ Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address a20Addr, unsigned
} }
else else
{ {
return( (Bit8u *) &BX_MEM_THIS rom[(a20Addr & EXROM_MASK) + BIOSROMSZ]); return((Bit8u *) &BX_MEM_THIS rom[(a20Addr & EXROM_MASK) + BIOSROMSZ]);
} }
} }
else if (a20Addr >= (bx_phy_address)~BIOS_MASK) else if (a20Addr >= (bx_phy_address)~BIOS_MASK)

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: pc_system.cc,v 1.68 2007-11-01 18:03:48 sshwarts Exp $ // $Id: pc_system.cc,v 1.69 2008-02-15 22:05:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2002 MandrakeSoft S.A. // Copyright (C) 2002 MandrakeSoft S.A.
@ -258,7 +258,7 @@ void bx_pc_system_c::register_state(void)
// Bochs internal timer delivery framework features // Bochs internal timer delivery framework features
// ================================================ // ================================================
int bx_pc_system_c::register_timer( void *this_ptr, void (*funct)(void *), int bx_pc_system_c::register_timer(void *this_ptr, void (*funct)(void *),
Bit32u useconds, bx_bool continuous, bx_bool active, const char *id) Bit32u useconds, bx_bool continuous, bx_bool active, const char *id)
{ {
// Convert useconds to number of ticks. // Convert useconds to number of ticks.

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: plugin.cc,v 1.24 2008-02-05 22:57:40 sshwarts Exp $ // $Id: plugin.cc,v 1.25 2008-02-15 22:05:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// This file defines the plugin and plugin-device registration functions and // This file defines the plugin and plugin-device registration functions and
@ -34,7 +34,7 @@ void (*pluginRegisterIRQ)(unsigned irq, const char* name) = 0;
void (*pluginUnregisterIRQ)(unsigned irq, const char* name) = 0; void (*pluginUnregisterIRQ)(unsigned irq, const char* name) = 0;
void (*pluginSetHRQ)(unsigned val) = 0; void (*pluginSetHRQ)(unsigned val) = 0;
void (*pluginSetHRQHackCallback)( void (*callback)(void) ) = 0; void (*pluginSetHRQHackCallback)(void (*callback)(void)) = 0;
int (*pluginRegisterIOReadHandler)(void *thisPtr, ioReadHandler_t callback, int (*pluginRegisterIOReadHandler)(void *thisPtr, ioReadHandler_t callback,
unsigned base, const char *name, Bit8u mask) = 0; unsigned base, const char *name, Bit8u mask) = 0;
@ -108,7 +108,7 @@ builtinSetHRQ(unsigned val)
} }
static void static void
builtinSetHRQHackCallback( void (*callback)(void) ) builtinSetHRQHackCallback(void (*callback)(void))
{ {
#if 0 #if 0
pluginlog->panic("builtinSetHRQHackCallback called, no plugin loaded?"); pluginlog->panic("builtinSetHRQHackCallback called, no plugin loaded?");
@ -122,7 +122,7 @@ builtinRegisterIOReadHandler(void *thisPtr, ioReadHandler_t callback,
unsigned base, const char *name, Bit8u mask) unsigned base, const char *name, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.register_io_read_handler (thisPtr, callback, base, name, mask); ret = bx_devices.register_io_read_handler (thisPtr, callback, base, name, mask);
pluginlog->ldebug("plugin %s registered I/O read address at %04x", name, base); pluginlog->ldebug("plugin %s registered I/O read address at %04x", name, base);
return ret; return ret;
@ -133,7 +133,7 @@ builtinRegisterIOWriteHandler(void *thisPtr, ioWriteHandler_t callback,
unsigned base, const char *name, Bit8u mask) unsigned base, const char *name, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.register_io_write_handler (thisPtr, callback, base, name, mask); ret = bx_devices.register_io_write_handler (thisPtr, callback, base, name, mask);
pluginlog->ldebug("plugin %s registered I/O write address at %04x", name, base); pluginlog->ldebug("plugin %s registered I/O write address at %04x", name, base);
return ret; return ret;
@ -144,7 +144,7 @@ builtinUnregisterIOReadHandler(void *thisPtr, ioReadHandler_t callback,
unsigned base, Bit8u mask) unsigned base, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.unregister_io_read_handler (thisPtr, callback, base, mask); ret = bx_devices.unregister_io_read_handler (thisPtr, callback, base, mask);
pluginlog->ldebug("plugin unregistered I/O read address at %04x", base); pluginlog->ldebug("plugin unregistered I/O read address at %04x", base);
return ret; return ret;
@ -155,7 +155,7 @@ builtinUnregisterIOWriteHandler(void *thisPtr, ioWriteHandler_t callback,
unsigned base, Bit8u mask) unsigned base, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.unregister_io_write_handler (thisPtr, callback, base, mask); ret = bx_devices.unregister_io_write_handler (thisPtr, callback, base, mask);
pluginlog->ldebug("plugin unregistered I/O write address at %04x", base); pluginlog->ldebug("plugin unregistered I/O write address at %04x", base);
return ret; return ret;
@ -166,7 +166,7 @@ builtinRegisterIOReadHandlerRange(void *thisPtr, ioReadHandler_t callback,
unsigned base, unsigned end, const char *name, Bit8u mask) unsigned base, unsigned end, const char *name, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.register_io_read_handler_range (thisPtr, callback, base, end, name, mask); ret = bx_devices.register_io_read_handler_range (thisPtr, callback, base, end, name, mask);
pluginlog->ldebug("plugin %s registered I/O read addresses %04x to %04x", name, base, end); pluginlog->ldebug("plugin %s registered I/O read addresses %04x to %04x", name, base, end);
return ret; return ret;
@ -177,7 +177,7 @@ builtinRegisterIOWriteHandlerRange(void *thisPtr, ioWriteHandler_t callback,
unsigned base, unsigned end, const char *name, Bit8u mask) unsigned base, unsigned end, const char *name, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.register_io_write_handler_range (thisPtr, callback, base, end, name, mask); ret = bx_devices.register_io_write_handler_range (thisPtr, callback, base, end, name, mask);
pluginlog->ldebug("plugin %s registered I/O write addresses %04x to %04x", name, base, end); pluginlog->ldebug("plugin %s registered I/O write addresses %04x to %04x", name, base, end);
return ret; return ret;
@ -188,7 +188,7 @@ builtinUnregisterIOReadHandlerRange(void *thisPtr, ioReadHandler_t callback,
unsigned begin, unsigned end, Bit8u mask) unsigned begin, unsigned end, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.unregister_io_read_handler_range (thisPtr, callback, begin, end, mask); ret = bx_devices.unregister_io_read_handler_range (thisPtr, callback, begin, end, mask);
pluginlog->ldebug("plugin unregistered I/O read addresses %04x to %04x", begin, end); pluginlog->ldebug("plugin unregistered I/O read addresses %04x to %04x", begin, end);
return ret; return ret;
@ -199,7 +199,7 @@ builtinUnregisterIOWriteHandlerRange(void *thisPtr, ioWriteHandler_t callback,
unsigned begin, unsigned end, Bit8u mask) unsigned begin, unsigned end, Bit8u mask)
{ {
int ret; int ret;
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
ret = bx_devices.unregister_io_write_handler_range (thisPtr, callback, begin, end, mask); ret = bx_devices.unregister_io_write_handler_range (thisPtr, callback, begin, end, mask);
pluginlog->ldebug("plugin unregistered I/O write addresses %04x to %04x", begin, end); pluginlog->ldebug("plugin unregistered I/O write addresses %04x to %04x", begin, end);
return ret; return ret;
@ -209,7 +209,7 @@ builtinUnregisterIOWriteHandlerRange(void *thisPtr, ioWriteHandler_t callback,
builtinRegisterDefaultIOReadHandler(void *thisPtr, ioReadHandler_t callback, builtinRegisterDefaultIOReadHandler(void *thisPtr, ioReadHandler_t callback,
const char *name, Bit8u mask) const char *name, Bit8u mask)
{ {
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
bx_devices.register_default_io_read_handler (thisPtr, callback, name, mask); bx_devices.register_default_io_read_handler (thisPtr, callback, name, mask);
pluginlog->ldebug("plugin %s registered default I/O read ", name); pluginlog->ldebug("plugin %s registered default I/O read ", name);
return 0; return 0;
@ -219,7 +219,7 @@ builtinRegisterDefaultIOReadHandler(void *thisPtr, ioReadHandler_t callback,
builtinRegisterDefaultIOWriteHandler(void *thisPtr, ioWriteHandler_t callback, builtinRegisterDefaultIOWriteHandler(void *thisPtr, ioWriteHandler_t callback,
const char *name, Bit8u mask) const char *name, Bit8u mask)
{ {
BX_ASSERT (mask<8); BX_ASSERT(mask<8);
bx_devices.register_default_io_write_handler (thisPtr, callback, name, mask); bx_devices.register_default_io_write_handler (thisPtr, callback, name, mask);
pluginlog->ldebug("plugin %s registered default I/O write ", name); pluginlog->ldebug("plugin %s registered default I/O write ", name);
return 0; return 0;
@ -247,195 +247,181 @@ builtinActivateTimer(unsigned id, Bit32u usec, bx_bool continuous)
/* Plugin initialization / deinitialization */ /* Plugin initialization / deinitialization */
/************************************************************************/ /************************************************************************/
void void plugin_init_all (void)
plugin_init_all (void)
{ {
plugin_t *plugin; plugin_t *plugin;
pluginlog->info("Initializing plugins"); pluginlog->info("Initializing plugins");
for (plugin = plugins; plugin; plugin = plugin->next) for (plugin = plugins; plugin; plugin = plugin->next)
{
char *arg_ptr = plugin->args;
/* process the command line */
plugin->argc = 0;
while (plugin->argc < MAX_ARGC)
{ {
char *arg_ptr = plugin->args; while (*arg_ptr && isspace (*arg_ptr))
arg_ptr++;
/* process the command line */ if (!*arg_ptr) break;
plugin->argc = 0; plugin->argv[plugin->argc++] = arg_ptr;
while (plugin->argc < MAX_ARGC)
{
while (*arg_ptr && isspace (*arg_ptr))
arg_ptr++;
if (!*arg_ptr) while (*arg_ptr && !isspace (*arg_ptr))
break; arg_ptr++;
plugin->argv[plugin->argc++] = arg_ptr;
while (*arg_ptr && !isspace (*arg_ptr)) if (!*arg_ptr) break;
arg_ptr++; *arg_ptr++ = '\0';
if (!*arg_ptr)
break;
*arg_ptr++ = '\0';
}
/* initialize the plugin */
if (plugin->plugin_init (plugin, plugin->type, plugin->argc, plugin->argv))
{
pluginlog->panic("Plugin initialization failed for %s", plugin->name);
plugin_abort();
}
plugin->initialized = 1;
} }
return; /* initialize the plugin */
if (plugin->plugin_init (plugin, plugin->type, plugin->argc, plugin->argv))
{
pluginlog->panic("Plugin initialization failed for %s", plugin->name);
plugin_abort();
}
plugin->initialized = 1;
}
} }
void void plugin_init_one(plugin_t *plugin)
plugin_init_one(plugin_t *plugin)
{ {
char *arg_ptr = plugin->args; char *arg_ptr = plugin->args;
/* process the command line */ /* process the command line */
plugin->argc = 0; plugin->argc = 0;
while (plugin->argc < MAX_ARGC) while (plugin->argc < MAX_ARGC)
{ {
while (*arg_ptr && isspace (*arg_ptr)) while (*arg_ptr && isspace (*arg_ptr))
arg_ptr++; arg_ptr++;
if (!*arg_ptr) if (!*arg_ptr) break;
break; plugin->argv[plugin->argc++] = arg_ptr;
plugin->argv[plugin->argc++] = arg_ptr;
while (*arg_ptr && !isspace (*arg_ptr)) while (*arg_ptr && !isspace (*arg_ptr))
arg_ptr++; arg_ptr++;
if (!*arg_ptr) if (!*arg_ptr) break;
break; *arg_ptr++ = '\0';
*arg_ptr++ = '\0'; }
}
/* initialize the plugin */ /* initialize the plugin */
if (plugin->plugin_init (plugin, plugin->type, plugin->argc, plugin->argv)) if (plugin->plugin_init (plugin, plugin->type, plugin->argc, plugin->argv))
{ {
pluginlog->info("Plugin initialization failed for %s", plugin->name); pluginlog->info("Plugin initialization failed for %s", plugin->name);
plugin_abort(); plugin_abort();
} }
plugin->initialized = 1; plugin->initialized = 1;
} }
plugin_t *plugin_unload(plugin_t *plugin) plugin_t *plugin_unload(plugin_t *plugin)
{ {
plugin_t *dead_plug; plugin_t *dead_plug;
if (plugin->initialized) if (plugin->initialized)
plugin->plugin_fini(); plugin->plugin_fini();
lt_dlclose(plugin->handle); lt_dlclose(plugin->handle);
delete [] plugin->name; delete [] plugin->name;
dead_plug = plugin; dead_plug = plugin;
plugin = plugin->next; plugin = plugin->next;
free(dead_plug); free(dead_plug);
return plugin; return plugin;
} }
void plugin_fini_all (void) void plugin_fini_all (void)
{ {
plugin_t *plugin; plugin_t *plugin;
for (plugin = plugins; plugin; plugin = plugin_unload(plugin)); for (plugin = plugins; plugin; plugin = plugin_unload(plugin));
return;
} }
void plugin_load(char *name, char *args, plugintype_t type) void plugin_load(char *name, char *args, plugintype_t type)
{ {
plugin_t *plugin; plugin_t *plugin;
plugin = (plugin_t *)malloc (sizeof(plugin_t)); plugin = (plugin_t *)malloc (sizeof(plugin_t));
if (!plugin) if (!plugin)
{ {
BX_PANIC(("malloc plugin_t failed")); BX_PANIC(("malloc plugin_t failed"));
} }
plugin->type = type; plugin->type = type;
plugin->name = name; plugin->name = name;
plugin->args = args; plugin->args = args;
plugin->initialized = 0; plugin->initialized = 0;
char plugin_filename[BX_PATHNAME_LEN], buf[BX_PATHNAME_LEN]; char plugin_filename[BX_PATHNAME_LEN], buf[BX_PATHNAME_LEN];
sprintf(buf, PLUGIN_FILENAME_FORMAT, name); sprintf(buf, PLUGIN_FILENAME_FORMAT, name);
sprintf(plugin_filename, "%s%s", PLUGIN_PATH, buf); sprintf(plugin_filename, "%s%s", PLUGIN_PATH, buf);
// Set context so that any devices that the plugin registers will // Set context so that any devices that the plugin registers will
// be able to see which plugin created them. The registration will // be able to see which plugin created them. The registration will
// be called from either dlopen (global constructors) or plugin_init. // be called from either dlopen (global constructors) or plugin_init.
BX_ASSERT (current_plugin_context == NULL); BX_ASSERT(current_plugin_context == NULL);
current_plugin_context = plugin; current_plugin_context = plugin;
plugin->handle = lt_dlopen (plugin_filename); plugin->handle = lt_dlopen (plugin_filename);
BX_INFO (("lt_dlhandle is %p", plugin->handle)); BX_INFO(("lt_dlhandle is %p", plugin->handle));
if (!plugin->handle) if (!plugin->handle)
{ {
current_plugin_context = NULL;
BX_PANIC (("dlopen failed for module '%s': %s", name, lt_dlerror ()));
free (plugin);
return;
}
sprintf(buf, PLUGIN_INIT_FMT_STRING, name);
plugin->plugin_init =
(int (*)(struct _plugin_t *, enum plugintype_t, int, char *[])) /* monster typecast */
lt_dlsym (plugin->handle, buf);
if (plugin->plugin_init == NULL) {
pluginlog->panic("could not find plugin_init: %s", lt_dlerror ());
plugin_abort ();
}
sprintf(buf, PLUGIN_FINI_FMT_STRING, name);
plugin->plugin_fini = (void (*)(void)) lt_dlsym (plugin->handle, buf);
if (plugin->plugin_init == NULL) {
pluginlog->panic("could not find plugin_fini: %s", lt_dlerror ());
plugin_abort ();
}
pluginlog->info("loaded plugin %s",plugin_filename);
/* Insert plugin at the _end_ of the plugin linked list. */
plugin->next = NULL;
if (!plugins)
{
/* Empty list, this become the first entry. */
plugins = plugin;
}
else
{
/* Non-empty list. Add to end. */
plugin_t *temp = plugins;
while (temp->next)
temp = temp->next;
temp->next = plugin;
}
plugin_init_one(plugin);
// check that context didn't change. This should only happen if we
// need a reentrant plugin_load.
BX_ASSERT (current_plugin_context == plugin);
current_plugin_context = NULL; current_plugin_context = NULL;
BX_PANIC(("dlopen failed for module '%s': %s", name, lt_dlerror ()));
free (plugin);
return; return;
}
sprintf(buf, PLUGIN_INIT_FMT_STRING, name);
plugin->plugin_init =
(int (*)(struct _plugin_t *, enum plugintype_t, int, char *[])) /* monster typecast */
lt_dlsym (plugin->handle, buf);
if (plugin->plugin_init == NULL) {
pluginlog->panic("could not find plugin_init: %s", lt_dlerror ());
plugin_abort ();
}
sprintf(buf, PLUGIN_FINI_FMT_STRING, name);
plugin->plugin_fini = (void (*)(void)) lt_dlsym (plugin->handle, buf);
if (plugin->plugin_init == NULL) {
pluginlog->panic("could not find plugin_fini: %s", lt_dlerror ());
plugin_abort();
}
pluginlog->info("loaded plugin %s",plugin_filename);
/* Insert plugin at the _end_ of the plugin linked list. */
plugin->next = NULL;
if (!plugins)
{
/* Empty list, this become the first entry. */
plugins = plugin;
}
else
{
/* Non-empty list. Add to end. */
plugin_t *temp = plugins;
while (temp->next)
temp = temp->next;
temp->next = plugin;
}
plugin_init_one(plugin);
// check that context didn't change. This should only happen if we
// need a reentrant plugin_load.
BX_ASSERT(current_plugin_context == plugin);
current_plugin_context = NULL;
} }
void plugin_abort(void) void plugin_abort(void)
{ {
pluginlog->panic("plugin load aborted"); pluginlog->panic("plugin load aborted");
} }
#endif /* end of #if BX_PLUGINS */ #endif /* end of #if BX_PLUGINS */
@ -490,50 +476,48 @@ plugin_startup(void)
void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *devmodel, const char *name) void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmodel_c *devmodel, const char *name)
{ {
device_t *device; device_t *device;
device = (device_t *)malloc (sizeof (device_t)); device = (device_t *)malloc (sizeof (device_t));
if (!device) if (!device)
{ {
pluginlog->panic("can't allocate device_t"); pluginlog->panic("can't allocate device_t");
} }
device->name = name; device->name = name;
BX_ASSERT (devmodel != NULL); BX_ASSERT(devmodel != NULL);
device->devmodel = devmodel; device->devmodel = devmodel;
device->plugin = plugin; // this can be NULL device->plugin = plugin; // this can be NULL
device->next = NULL; device->next = NULL;
// Don't add every kind of device to the list. // Don't add every kind of device to the list.
switch (type) { switch (type) {
case PLUGTYPE_CORE: case PLUGTYPE_CORE:
// Core devices are present whether or not we are using plugins, so // Core devices are present whether or not we are using plugins, so
// they are managed by the same code in iodev/devices.cc whether // they are managed by the same code in iodev/devices.cc whether
// plugins are on or off. // plugins are on or off.
free(device); free(device);
return; // Do not add core devices to the devices list. return; // Do not add core devices to the devices list.
case PLUGTYPE_OPTIONAL: case PLUGTYPE_OPTIONAL:
case PLUGTYPE_USER: case PLUGTYPE_USER:
default: default:
// The plugin system will manage optional and user devices only. // The plugin system will manage optional and user devices only.
break; break;
} }
if (!devices) if (!devices) {
{ /* Empty list, this become the first entry. */
/* Empty list, this become the first entry. */ devices = device;
devices = device; }
} else {
else /* Non-empty list. Add to end. */
{ device_t *temp = devices;
/* Non-empty list. Add to end. */
device_t *temp = devices;
while (temp->next) while (temp->next)
temp = temp->next; temp = temp->next;
temp->next = device; temp->next = device;
} }
} }
/************************************************************************/ /************************************************************************/
@ -542,14 +526,14 @@ void pluginRegisterDeviceDevmodel(plugin_t *plugin, plugintype_t type, bx_devmod
bx_bool pluginDevicePresent(char *name) bx_bool pluginDevicePresent(char *name)
{ {
device_t *device; device_t *device;
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
if (strcmp(device->name,name)==0) return true; if (strcmp(device->name,name)==0) return true;
} }
return false; return false;
} }
#if BX_PLUGINS #if BX_PLUGINS
@ -592,20 +576,20 @@ void bx_unload_plugin(const char *name)
void bx_init_plugins() void bx_init_plugins()
{ {
device_t *device; device_t *device;
// two loops // two loops
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
pluginlog->info("init_mem of '%s' plugin device by virtual method",device->name); pluginlog->info("init_mem of '%s' plugin device by virtual method",device->name);
device->devmodel->init_mem(BX_MEM(0)); device->devmodel->init_mem(BX_MEM(0));
} }
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
pluginlog->info("init_dev of '%s' plugin device by virtual method",device->name); pluginlog->info("init_dev of '%s' plugin device by virtual method",device->name);
device->devmodel->init(); device->devmodel->init();
} }
} }
/**************************************************************************/ /**************************************************************************/
@ -614,12 +598,12 @@ void bx_init_plugins()
void bx_reset_plugins(unsigned signal) void bx_reset_plugins(unsigned signal)
{ {
device_t *device; device_t *device;
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
pluginlog->info("reset of '%s' plugin device by virtual method",device->name); pluginlog->info("reset of '%s' plugin device by virtual method",device->name);
device->devmodel->reset(signal); device->devmodel->reset(signal);
} }
} }
/*******************************************************/ /*******************************************************/
@ -642,7 +626,7 @@ void bx_unload_plugins()
next = device->next; next = device->next;
free(device); free(device);
device = next; device = next;
}; }
devices = NULL; devices = NULL;
} }
@ -652,12 +636,12 @@ void bx_unload_plugins()
void bx_plugins_register_state() void bx_plugins_register_state()
{ {
device_t *device; device_t *device;
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
pluginlog->info("register state of '%s' plugin device by virtual method",device->name); pluginlog->info("register state of '%s' plugin device by virtual method",device->name);
device->devmodel->register_state(); device->devmodel->register_state();
} }
} }
/***************************************************************************/ /***************************************************************************/
@ -666,11 +650,11 @@ void bx_plugins_register_state()
void bx_plugins_after_restore_state() void bx_plugins_after_restore_state()
{ {
device_t *device; device_t *device;
for (device = devices; device; device = device->next) for (device = devices; device; device = device->next)
{ {
device->devmodel->after_restore_state(); device->devmodel->after_restore_state();
} }
} }
} }

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// $Id: plugin.h,v 1.61 2008-02-05 22:57:40 sshwarts Exp $ // $Id: plugin.h,v 1.62 2008-02-15 22:05:38 sshwarts Exp $
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// This file provides macros and types needed for plugins. It is based on // This file provides macros and types needed for plugins. It is based on
@ -315,24 +315,24 @@ BOCHSAPI extern void (* pluginVGASetUpdateInterval)(unsigned);
BOCHSAPI extern Bit8u (* pluginVGAGetActlPaletteIdx)(Bit8u index); BOCHSAPI extern Bit8u (* pluginVGAGetActlPaletteIdx)(Bit8u index);
/* === Timer stuff === */ /* === Timer stuff === */
BOCHSAPI extern int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *), BOCHSAPI extern int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *),
Bit32u useconds, bx_bool continuous, Bit32u useconds, bx_bool continuous,
bx_bool active, const char *name); bx_bool active, const char *name);
BOCHSAPI extern void (*pluginActivateTimer)(unsigned id, Bit32u usec, bx_bool continuous); BOCHSAPI extern void (*pluginActivateTimer)(unsigned id, Bit32u usec, bx_bool continuous);
BOCHSAPI extern void (*pluginDeactivateTimer)(unsigned id); BOCHSAPI extern void (*pluginDeactivateTimer)(unsigned id);
/* === HRQ stuff === */ /* === HRQ stuff === */
BOCHSAPI extern void (*pluginSetHRQ)(unsigned val); BOCHSAPI extern void (*pluginSetHRQ)(unsigned val);
BOCHSAPI extern void (*pluginSetHRQHackCallback)( void (*callback)(void) ); BOCHSAPI extern void (*pluginSetHRQHackCallback)(void (*callback)(void));
/* === PCI stuff === */ /* === PCI stuff === */
BOCHSAPI extern bx_bool (*pluginRegisterPCIDevice)(void *this_ptr, BOCHSAPI extern bx_bool (*pluginRegisterPCIDevice)(void *this_ptr,
Bit32u (*bx_pci_read_handler)(void *, Bit8u, unsigned), Bit32u (*bx_pci_read_handler)(void *, Bit8u, unsigned),
void(*bx_pci_write_handler)(void *, Bit8u, Bit32u, unsigned), void(*bx_pci_write_handler)(void *, Bit8u, Bit32u, unsigned),
Bit8u *devfunc, const char *name, const char *descr); Bit8u *devfunc, const char *name, const char *descr);
BOCHSAPI extern Bit8u (*pluginRd_memType)(Bit32u addr); BOCHSAPI extern Bit8u (*pluginRd_memType)(Bit32u addr);
BOCHSAPI extern Bit8u (*pluginWr_memType)(Bit32u addr); BOCHSAPI extern Bit8u (*pluginWr_memType)(Bit32u addr);
void plugin_abort(void); void plugin_abort(void);
@ -341,8 +341,8 @@ extern void bx_unload_plugin(const char *name);
extern void bx_init_plugins(void); extern void bx_init_plugins(void);
extern void bx_reset_plugins(unsigned); extern void bx_reset_plugins(unsigned);
extern void bx_unload_plugins(void); extern void bx_unload_plugins(void);
extern void bx_plugins_register_state(); extern void bx_plugins_register_state(void);
extern void bx_plugins_after_restore_state(); extern void bx_plugins_after_restore_state(void);
// every plugin must define these, within the extern"C" block, so that // every plugin must define these, within the extern"C" block, so that
// a non-mangled function symbol is available in the shared library. // a non-mangled function symbol is available in the shared library.