Author: mcayland
Date: Sat Jul 27 12:14:29 2013
New Revision: 1177
URL: http://tracker.coreboot.org/trac/openbios/changeset/1177
Log:
video_common.c: now fill_rect() is no longer called directly, merge it into the video_fill_rect()
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/include/libopenbios/video.h
trunk/openbios-devel/libopenbios/video_common.c
Modified: trunk/openbios-devel/include/libopenbios/video.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/video.h Sat Jul 27 12:14:26 2013 (r1176)
+++ trunk/openbios-devel/include/libopenbios/video.h Sat Jul 27 12:14:29 2013 (r1177)
@@ -5,7 +5,6 @@
int video_get_res(int *w, int *h);
void draw_pixel(int x, int y, int colind);
void video_scroll(int height);
-void fill_rect(int col_ind, int x, int y, int w, int h);
void video_mask_blit(void);
void video_invert_rect(void);
void video_fill_rect(void);
Modified: trunk/openbios-devel/libopenbios/video_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/video_common.c Sat Jul 27 12:14:26 2013 (r1176)
+++ trunk/openbios-devel/libopenbios/video_common.c Sat Jul 27 12:14:29 2013 (r1177)
@@ -225,9 +225,16 @@
}
}
+/* ( color_ind x y width height -- ) (?) */
void
-fill_rect( int col_ind, int x, int y, int w, int h )
+video_fill_rect(void)
{
+ int h = POP();
+ int w = POP();
+ int y = POP();
+ int x = POP();
+ int col_ind = POP();
+
char *pp;
unsigned long col = get_color(col_ind);
@@ -255,19 +262,6 @@
}
}
-/* ( color_ind x y width height -- ) (?) */
-void
-video_fill_rect(void)
-{
- int h = POP();
- int w = POP();
- int y = POP();
- int x = POP();
- int color_ind = POP();
-
- fill_rect( color_ind, x, y, w, h );
-}
-
void
init_video( unsigned long fb, int width, int height, int depth, int rb )
{
The three responses I've seen so far were all negative, but also puzzling
to me. I'll try to address the key points in the response that is copied
below, as well as those in the other two responses.
(1) Why floppies? -- (a) Because they are limited in storage, and
non-electronic. The smaller the memory, the harder it is to hide something
malicious in it, and the easier to check it. (b) Because they are inexpensive.
Any entity wishing to verify voting results needs one memory device for
every voting machine.
(2) Aren't floppies unreliable? -- No. Since I started keeping track of
my public voting demos in 2002, I have used 992 diskettes without a single
failure between starting voting and archiving results. (That's not 992
different new diskettes; each is used over and over again unless a check done at
startup reveals possible unreliability.)
(3) Aren't floppy drives obsolete? -- No. USB-connected floppy drives are
readily available for about $15, and computers can boot from them.
(4) BIOS averages 8 MB? -- WOW! I still don't know how big OpenBIOS is,
but I was hoping for something a bit closer to the 8 KB of the original IBM
PC. The capabilities of a 386 computer are sufficient for my voting
system. Is OpenBIOS really so huge? Does a BIOS have to be?
(5) Hypervisor? Virtual machine? Address remapping? Infectious native
BIOS? -- If a modern computer has no hard drive connected, what happens when
it boots from a floppy? There is a boot sector on the diskette (which is
verified by hash code); doesn't that control what happens next? Why can't
the floppy contents take control of the computer?
Obviously, I'm no BIOS expert. I'd appreciate recommendations of good
texts or tutorials to bring me up to speed.
Chuck Gaston
In a message dated 7/19/2013 9:04:29 A.M. Eastern Daylight Time,
Nick.Couchman(a)seakr.com writes:
>>> On 2013/07/19 at 06:01, <SAVIOCvs(a)aol.com> wrote:
> I developed a voting system (see _www.SAVIOC.com_
(http://www.SAVIOC.com) )
> that uses ordinary old PCs, yet is more transparent and trustworthy
than
> anything else in use today. All software, including the operating
system
> (FreeDOS) boots from a floppy that can be verified by hash code. The
PC
> never uses the hard drive, and doesn't even need one. Trustworthiness
> comes
> from people with different interests being able to prevent each other
from
> doing anything fraudulent. I think the only significant potential
> vulnerability is that someone with physical access to the machines
could
> install a
> malicious BIOS. Learning about the OpenBIOS project gave me hope of
> overcoming that vulnerability.
>
> (1) Is my hope justified? Can a PC be booted from a floppy that
> completely replaces the native BIOS in RAM, and then loads FreeDOS?
(Can
> the
> possibility of a malicious BIOS be made a non-issue?)
>
> If all answers are YES, then the remaining very basic questions become
> important.
Perhaps this is a digression, but why a floppy? If you're using old
hardware, that's fine, but at some point you probably want to use modern
hardware, and I don't know of a modern hardware system that comes with a floppy
drive, anymore. Furthermore, my many years of experience with floppy disks
tells me that they are unreliable - very prone to failures of a variety of
types (dirty heads, physical damage to the medium, etc.). Many of these
types of failures mean mis-reads, which means bad checksums and failures in
the security model you're trying to implement. If you're looking for
something compatible with very old hardware - hardware that does not support
booting from USB flash drives - I'd recommend finding some older IDE flash chips
(disk on chip) that you can use, instead. These are probably pretty
cheap, now, and should give you the capacity and reliability that you won't get
with floppy disks.
>
> (2) Roughly how much space on the floppy would be required?
You can build the OpenBIOS tree and see how large the binary is. I don't
remember off the top of my head, so I can't tell you. Many modern BIOS
implementations are several MB - I believe 8MB is the average BIOS size (not
openBIOS, just BIOS in general), with some as large as 12MB. This presents
another problem when using floppies...you'd need multiple ones.
> (3) What downloads would I need? OpenBIOS AND OpenFirmware AND
OpenBOOT?
> Anything else?
Probably just OpenBIOS.
> (4) How are they downloaded?
> http://www.openfirmware.info/index.php/Downloads displays a page
> beginning, "This page has been deleted." All other links that imply
the
> possibility
> of downloading reach a page headlined, "The page cannot be displayed".
>
SVN check-out of the current source tree and build. Decently modern
versions are also included with Qemu, IIRC.
-Nick
--------
This e-mail may contain confidential and privileged material for the sole
use of the intended recipient. If this email is not intended for you, or
you are not responsible for the delivery of this message to the intended
recipient, please note that this message may contain SEAKR Engineering (SEAKR)
Privileged/Proprietary Information. In such a case, you are strictly
prohibited from downloading, photocopying, distributing or otherwise using
this message, its contents or attachments in any way. If you have received
this message in error, please notify us immediately by replying to this
e-mail and delete the message from your mailbox. Information contained in this
message that does not relate to the business of SEAKR is neither endorsed
by nor attributable to SEAKR.
--
OpenBIOS http://openbios.org/
Mailinglist: http://lists.openbios.org/mailman/listinfo
Free your System - May the Forth be with you
Over half a year ago there was talk about making the command key work on QEMU. I have finally made a patch that allows users of QEMU on Mac OS X be able to do this. Just apply the patch to QEMU to make the command key work.
You set the command key by using this option: -command-key 55. This will make the command key work in QEMU. To quit QEMU, type ALT - Q.
Let me know if you like it.
---
ui/cocoa.m | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 110 insertions(+), 13 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index be49179..4884ccf 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -70,6 +70,7 @@ static DisplayChangeListener *dcl;
int gArgc;
char **gArgv;
+bool substitutingForCommandKey = false;
// keymap conversion
int keymap[] =
@@ -129,8 +130,8 @@ int keymap[] =
14, // 51 0x33 0x0e BKSP QZ_BACKSPACE
0, // 52 0x34 Undefined
1, // 53 0x35 0x01 ESC QZ_ESCAPE
- 0, // 54 0x36 QZ_RMETA
- 0, // 55 0x37 QZ_LMETA
+ 220, // 54 0x36 QZ_RMETA
+ 219, // 55 0x37 QZ_LMETA
42, // 56 0x38 0x2a L SHFT QZ_LSHIFT
58, // 57 0x39 0x3a CAPS QZ_CAPSLOCK
56, // 58 0x3A 0x38 L ALT QZ_LALT
@@ -249,6 +250,72 @@ static int cocoa_keycode_to_qemu(int keycode)
}
+// Used to map the guest OS's command key to a key on the host keyboard.
+// Uses the -command-key option.
+static void handleCommandKeyOption(int * argc, char * argv[])
+{
+ bool foundOption = false;
+ int newCommandKeyButtonValue, i;
+
+ #define BUFFER_SIZE 10
+ #define LEFT_COMMAND_KEY 0x37
+ #define RIGHT_COMMAND_KEY 0x36
+ #define GUEST_COMMAND_KEY 219
+
+ char keyValueString[BUFFER_SIZE];
+
+ for(i = 0; i < *argc; i++) {
+ if(strcmp(argv[i], "-command-key") == 0) {
+ foundOption = true;
+ break;
+ }
+ }
+
+ // if the -command-key option is found
+ if(foundOption == true)
+ {
+ snprintf(keyValueString, BUFFER_SIZE, "%s", argv[i+1]);
+ if(strlen(keyValueString) == 0) {
+ printf("Usage: -command-key <host keyboard key value>\n");
+ printf("This page will help: http://boredzo.org/blog/wp-content/uploads/2007/05/imtx-virtual-keycodes.pn…");
+ exit(-1000);
+ }
+
+ // if using hexadecimal notation (e.g. 0x37)
+ if(keyValueString[0] == '0' && toupper(keyValueString[1]) == 'X') {
+ sscanf(keyValueString, "%x", &newCommandKeyButtonValue);
+ }
+
+ // for decimal notation
+ else {
+ newCommandKeyButtonValue = atoi(keyValueString);
+ }
+
+ //in case the key specified is a negative value
+ if(newCommandKeyButtonValue < 0) {
+ printf("\aCan't use a negative value for the command key!\n");
+ exit(-1001);
+ }
+
+ // if the guest OS command key is set to the host keyboard's left or right command key
+ if(newCommandKeyButtonValue == LEFT_COMMAND_KEY || newCommandKeyButtonValue == RIGHT_COMMAND_KEY) {
+ substitutingForCommandKey = true;
+ printf("\nNote: since you are using the host command key, the ALT key can be used to send QEMU commands.\n");
+ printf("Example: use ALT-q to quit QEMU.\n\n");
+ }
+
+ // do the mapping
+ keymap[newCommandKeyButtonValue] = GUEST_COMMAND_KEY;
+
+ // Remove -command-key from the argument list.
+ // QEMU will complain if we don't.
+ for(int x = i; x < *argc - 2; x=x+2) {
+ argv[x] = argv[x+2];
+ argv[x+1] = argv[x+3];
+ }
+ *argc = *argc - 2;
+ }
+}
/*
------------------------------------------------------
@@ -491,20 +558,27 @@ QemuCocoaView *cocoaView;
int keycode;
NSPoint p = [event locationInWindow];
+ // The key used to send QEMU commands (e.g. Quit, Full Screen).
+ // Change this if you don't like using the ALT key.
+ // Possible values: NSShiftKeyMask, NSControlKeyMask, NSFunctionKeyMask, NSAlternateKeyMask
+ const int substituteKeyMask = NSAlternateKeyMask;
+
switch ([event type]) {
case NSFlagsChanged:
- keycode = cocoa_keycode_to_qemu([event keyCode]);
+ keycode = cocoa_keycode_to_qemu([event keyCode]);
if (keycode) {
if (keycode == 58 || keycode == 69) { // emulate caps lock and num lock keydown and keyup
kbd_put_keycode(keycode);
kbd_put_keycode(keycode | 0x80);
} else if (qemu_console_is_graphic(NULL)) {
- if (keycode & 0x80)
- kbd_put_keycode(0xe0);
- if (modifiers_state[keycode] == 0) { // keydown
+ if (keycode & 0x80) // if keycode >= 0x80, for those keycodes that need a 0xe0 sent first
+ {
+ kbd_put_keycode(0xe0);
+ }
+ if (modifiers_state[keycode] == 0) { // keydown
kbd_put_keycode(keycode & 0x7f);
modifiers_state[keycode] = 1;
- } else { // keyup
+ } else { // keyup
kbd_put_keycode(keycode | 0x80);
modifiers_state[keycode] = 0;
}
@@ -516,17 +590,37 @@ QemuCocoaView *cocoaView;
[self ungrabMouse];
}
break;
- case NSKeyDown:
+ case NSKeyDown:
+ // if substituting for the host command key and the substitute key is being held down - have QEMU handle it
+ if((substitutingForCommandKey == true) && ([event modifierFlags] & substituteKeyMask)) {
+ // recreate the event with the command key as the modifier
+ int modifiers = [event modifierFlags];
+ modifiers = modifiers | NSCommandKeyMask; // set the command key
+ modifiers = modifiers ^ substituteKeyMask; // unset the substitute key
+
+ event = [NSEvent keyEventWithType: [event type] location: [event locationInWindow] modifierFlags: modifiers
+ timestamp: [event timestamp] windowNumber: [event windowNumber] context: [event context] characters: [event characters]
+ charactersIgnoringModifiers: [event charactersIgnoringModifiers] isARepeat: [event isARepeat] keyCode: [event keyCode] ];
+ [NSApp sendEvent:event];
+ return;
+ }
- // forward command Key Combos
- if ([event modifierFlags] & NSCommandKeyMask) {
+ // if the command key is held down and we want QEMU to handle the event - not the guest OS
+ else if([event modifierFlags] & NSCommandKeyMask && substitutingForCommandKey == false) {
[NSApp sendEvent:event];
return;
}
+ // if the command key is held down and we want the guest OS to handle it
+ if(([event modifierFlags] & NSCommandKeyMask) && (substitutingForCommandKey == true)) {
+ kbd_put_keycode(219); // command key
+ kbd_put_keycode(cocoa_keycode_to_qemu([event keyCode])); // any other keys
+ return;
+ }
+
// default
keycode = cocoa_keycode_to_qemu([event keyCode]);
-
+
// handle control + alt Key Combos (ctrl+alt is reserved for QEMU)
if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
switch (keycode) {
@@ -584,7 +678,7 @@ QemuCocoaView *cocoaView;
if (qemu_console_is_graphic(NULL)) {
if (keycode & 0x80)
kbd_put_keycode(0xe0);
- kbd_put_keycode(keycode | 0x80); //add 128 to signal release of key
+ kbd_put_keycode(keycode | 0x80); //add 128 (0x80) to signal release of key
}
break;
case NSMouseMoved:
@@ -810,8 +904,9 @@ QemuCocoaView *cocoaView;
- (void)startEmulationWithArgc:(int)argc argv:(char**)argv
{
COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
-
+
int status;
+ handleCommandKeyOption(&argc, argv);
status = qemu_main(argc, argv, *_NSGetEnviron());
exit(status);
}
@@ -1047,3 +1142,5 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
// register cleanup function
atexit(cocoa_cleanup);
}
+
+
--
1.7.5.4