RFC: omap3 patch collection
cover RFC: omap3 patch collection
From: Riku Voipio <[email protected]>
Hi,
This set of patches is quite raw, intended mostly just for discussion at this point. We'd like to identify the unobjectionable patches and "ready for upstream with minor fixes" patches first, so we can send them for a pull request. After which we can start diving more deeply into restructuring the remaining patches.
git pull git://gitorious.org/qemu-maemo/qemu-maemo.git omap3
Filip Navara (2):
Get rid of AREG1 and AREG2.
Shrink tb_jmp_offset to two entries, the other two are never used.
Juha Riihimäki (33):
arm-dis debug helper
audio: fix integer overflow expression
audion: fix coreaudio compilation
Cortex-A8 R2 support and trustzone
console change headers
Lots of arm TCG changes
cocoa frontend changes
multitouch and window close handler multikeyboard support merge
sdl: multitouch and window close suppport
add reset support for musb
NAND emulation overhaul
multi-mmc support in init call
onenand overhaul
SD overhaul
tsc2005 overhaul
Add triton2 (twl4030) driver
Overhaul omap support and base omap3 support
target-arm: add support for smc
target-arm: fix neon vmon/vmvn with modified immediate
target-arm: fix neon vqshl/vqshlu instructions
target-arm: fix neon vqrshl instruction
target-arm: fix neon vrshl instruction
target-arm: fix neon vrshr instruction
target-arm: fix neon v(r)sra instructions
target-arm: fix neon vld1 single element to all lanes
target-arm: fix signed narrow 64->32 operation
target-arm: fix neon vq(r)dmulh.s16 instructions
target-arm: fix neon v(q)(r)shrn instructions
target-arm: fix neon vcvt fixed-point
target-arm: fix neon vrsqrts instruction
target-arm: fix neon vshll (shift < max)
usb: fix -usbdevice option handling with no parameters
Riku Voipio (13):
fix function signature of qemu_chr_open_pty on !linux add multi-sd support
make cursor grab optional
usb-ohci: add omap init support
License update
blizzard: fix for non-32bpp host displays prepare smc driver support for omap
savevm and reset support for soc_dma
Add beagleboard and n900 machine definitions Add OpenGL ES accelerator support
Makefile.target | 25 +- arm-dis.c | 10 +- audio/coreaudio.c | 81 +- audio/mixeng_template.h | 4 +- cocoa.m | 313 ++- configure | 41 +- console.c | 18 + console.h | 13 + dyngen-exec.h | 26 - exec-all.h | 5 +- exec.c | 5 +- hw/axis_dev88.c | 2 +- hw/beagle.c | 108 + hw/blizzard.c | 104 +- hw/blizzard_template.h | 2 +- hw/cbus.c | 2 +- hw/devices.h | 5 +- hw/flash.h | 12 +- hw/gles2.c | 764 +++++++ hw/gles2.h | 323 +++ hw/gles2_calls.c | 2409 +++++++++++++++++++++ hw/gles2_calls.h | 189 ++ hw/i2c.h | 10 + hw/lm832x.c | 2 +- hw/nand.c | 207 ++- hw/nseries.c | 1093 +++++++++- hw/omap.h | 643 ++++-- hw/omap1.c | 1279 ++---------- hw/omap2.c | 2357 +-------------------- hw/omap3.c | 4774 +++++++++++++++++++++++++++++++++++++++++ hw/omap3_boot.c | 918 ++++++++ hw/omap3_lcd.c | 288 +++ hw/omap3_lcd_panel_template.h | 284 +++ hw/omap3_mmc.c | 841 ++++++++ hw/omap_clk.c | 687 ++++++ hw/omap_dma.c | 276 +++- hw/omap_dss.c | 2033 ++++++++++++++---- hw/omap_dss.h | 84 + hw/omap_gpio.c | 812 +++++++ hw/omap_gpmc.c | 741 +++++++ hw/omap_gptimer.c | 597 +++++ hw/omap_i2c.c | 825 +++++--- hw/omap_intc.c | 668 ++++++ hw/omap_l4.c | 443 ++++ hw/omap_mmc.c | 4 +- hw/omap_sdrc.c | 334 +++ hw/omap_spi.c | 679 ++++++ hw/omap_synctimer.c | 172 ++ hw/omap_tap.c | 116 + hw/omap_uart.c | 221 ++ hw/omap_usb.c | 539 +++++ hw/onenand.c | 279 ++- hw/pl181.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/sd.c | 390 +++- hw/sd.h | 4 +- hw/smc91c111.c | 22 + hw/soc_dma.c | 74 +- hw/soc_dma.h | 4 +- hw/spitz.c | 4 +- hw/ssi-sd.c | 2 +- hw/tc6393xb.c | 3 +- hw/tmp105.c | 2 +- hw/tsc2005.c | 173 +- hw/tusb6010.c | 2 +- hw/twl4030.c | 1469 +++++++++++++ hw/twl92230.c | 2 +- hw/usb-bus.c | 2 +- hw/usb-musb.c | 29 +- hw/usb-ohci.c | 12 + hw/usb-ohci.h | 2 + hw/usb.h | 1 + input.c | 21 +- linux-user/arm/syscall_nr.h | 2 +- linux-user/main.c | 23 +- linux-user/syscall.c | 160 ++- qemu-char.c | 2 +- qemu-options.hx | 19 + sdl.c | 66 +- sysemu.h | 1 + target-arm/cpu.h | 17 +- target-arm/helper.c | 402 +++-- target-arm/helpers.h | 15 + target-arm/machine.c | 6 + target-arm/neon_helper.c | 410 ++++- target-arm/op_helper.c | 124 ++ target-arm/translate.c | 1693 ++++++++------- tcg/arm/tcg-target.h | 2 - tcg/hppa/tcg-target.h | 2 - tcg/i386/tcg-target.h | 2 - tcg/ppc/tcg-target.h | 2 - tcg/ppc64/tcg-target.h | 2 - tcg/sparc/tcg-target.h | 6 - tcg/x86_64/tcg-target.h | 2 - translate-all.c | 4 - vl.c | 18 +- 96 files changed, 26066 insertions(+), 5803 deletions(-) create mode 100644 hw/beagle.c create mode 100644 hw/gles2.c create mode 100644 hw/gles2.h create mode 100644 hw/gles2_calls.c create mode 100644 hw/gles2_calls.h create mode 100644 hw/omap3.c create mode 100644 hw/omap3_boot.c create mode 100644 hw/omap3_lcd.c create mode 100644 hw/omap3_lcd_panel_template.h create mode 100644 hw/omap3_mmc.c create mode 100644 hw/omap_dss.h create mode 100644 hw/omap_gpio.c create mode 100644 hw/omap_gpmc.c create mode 100644 hw/omap_gptimer.c create mode 100644 hw/omap_intc.c create mode 100644 hw/omap_l4.c create mode 100644 hw/omap_sdrc.c create mode 100644 hw/omap_spi.c create mode 100644 hw/omap_synctimer.c create mode 100644 hw/omap_tap.c create mode 100644 hw/omap_uart.c create mode 100644 hw/omap_usb.c create mode 100644 hw/twl4030.c
PATCH 1/48 arm-dis debug helper
From: Juha Riihimäki <[email protected]>
modified the arm disassembler to include the opcode binary representation along with the symbolic disassembly.
--- arm-dis.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
arm-dis.c +8 -2
@@ -4101,8 +4101,14 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)In such cases, we can ignore the pc when computing addresses, since the addend is not currently pc-relative. */ pc =0 ; - -printer (pc, info, given); +if (size ==2 ) { + info->fprintf_func (info->stream,"[%04lx] " , + ((unsigned long )given) &0xffffffff ); + }else { + info->fprintf_func (info->stream,"[%08lx] " , + ((unsigned long )given) &0xffffffff ); + } +printer (pc, info, given);if (is_thumb) {
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 01/48] arm-dis debug helper
Quoted 16 lines · Riku Voipio
From: Juha Riihimäki <[email protected]>
modified the arm disassembler to include the opcode binary representation along with the symbolic disassembly.
Signed-off-by Riku Voipio <[email protected]>Signed-off-by Juha Riihimäki <[email protected]>--- arm-dis.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)arm-dis.c +0
-0
arm-dis.c print_insn_arm (bfd_vma pc, struct disassemble_info *info) · line 4106
Quoted 8 lines
arm-dis.c +3
-2@@ -4101,8 +4101,14 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info)In such cases, we can ignore the pc when computing addresses, since the addend is not currently pc-relative. */ pc =0 ; - -printer (pc, info, given); +if (size ==2 ) { + info->fprintf_func (info->stream,"[%04lx] " , + ((unsigned long )given) &0xffffffff );
Is the mask here correct? As far as I understand, we only want to keep 16 bits here.
Quoted 14 lines
arm-dis.c +5
-0+ }else { + info->fprintf_func (info->stream,"[%08lx] " , + ((unsigned long )given) &0xffffffff ); + } +printer (pc, info, given);if (is_thumb) {Signature · 1 line
1.6.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH 4/48 audio: fix integer overflow expression
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- audio/mixeng_template.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
audio/mixeng_template.h +2 -2
@@ -56,7 +56,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v)#endif #else /* !RECIPROCAL */ #ifdef SIGNED -return nv / (mixeng_real) (IN_MAX -IN_MIN ); +return nv / (mixeng_real) ((mixeng_real )IN_MAX - (mixeng_real )IN_MIN );#else return (nv -HALF ) / (mixeng_real )IN_MAX ;#endif
@@ -73,7 +73,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v) }#ifdef SIGNED -return ENDIAN_CONVERT ((IN_T ) (v * (IN_MAX -IN_MIN ))); +return ENDIAN_CONVERT ((IN_T ) (v * ((mixeng_real )IN_MAX - (mixeng_real )IN_MIN )));#else return ENDIAN_CONVERT ((IN_T ) ((v *IN_MAX ) +HALF ));#endif
Signature · 1 line
1.6.5
PATCH 5/48 audio: fix coreaudio compilation
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
audio: fix coreaudio compilation on OS X 10.6 and OS X 10.5
--- audio/coreaudio.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 78 insertions(+), 3 deletions(-)
audio/coreaudio.c +78 -3
@@ -47,6 +47,9 @@ typedef struct coreaudioVoiceOut {pthread_mutex_t mutex;int isAtexit;AudioDeviceID outputDeviceID; +#if defined(MAC_OS_X_VERSION_10_5 ) && (MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_X_VERSION_10_5 ) +AudioDeviceIOProcID ioProcID; +#endif UInt32 audioDevicePropertyBufferFrameSize;AudioStreamBasicDescription outputStreamBasicDescription;int live;
@@ -56,7 +59,7 @@ typedef struct coreaudioVoiceOut {static void coreaudio_logstatus (OSStatus status) { -char *str ="BUG" ; +const char *str ="BUG" ;switch (status) {case kAudioHardwareNoError:
@@ -104,7 +107,7 @@ static void coreaudio_logstatus (OSStatus status)break ;default : -AUD_log (AUDIO_CAP ,"Reason: status code %ld\n" , status); +AUD_log (AUDIO_CAP ,"Reason: status code %d\n" , status);return ; }
@@ -148,10 +151,21 @@ static inline UInt32 isPlaying (AudioDeviceID outputDeviceID) {OSStatus status;UInt32 result =0 ; +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 +AudioObjectPropertyAddress propertyAddress = { + .mSelector = kAudioDevicePropertyDeviceIsRunning, + .mScope = kAudioObjectPropertyScopeGlobal, + .mElement = kAudioObjectPropertyElementMaster, + }; +UInt32 resultSize =sizeof (result); + status =AudioObjectGetPropertyData (outputDeviceID, &propertyAddress, +0 ,NULL , &resultSize, &result); +#else UInt32 propertySize =sizeof (outputDeviceID); status =AudioDeviceGetProperty ( outputDeviceID,0 ,0 , kAudioDevicePropertyDeviceIsRunning, &propertySize, &result); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr (status,"Could not determine whether Device is playing\n" );
@@ -307,10 +321,21 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)/* open default output device */ propertySize =sizeof (core->outputDeviceID); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 +AudioObjectPropertyAddress propertyAddress = { + .mSelector = kAudioHardwarePropertyDefaultOutputDevice, + .mScope = kAudioObjectPropertyScopeGlobal, + .mElement = kAudioObjectPropertyElementMaster, + }; + status =AudioObjectGetPropertyData (kAudioObjectSystemObject, + &propertyAddress,0 ,NULL , + &propertySize, &core->outputDeviceID); +#else status =AudioHardwareGetProperty ( kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &core->outputDeviceID); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not get default output Device\n" );
@@ -323,6 +348,11 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)/* get minimum and maximum buffer frame sizes */ propertySize =sizeof (frameRange); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 + propertyAddress.mSelector = kAudioDevicePropertyBufferFrameSizeRange; + status =AudioObjectGetPropertyData (core->outputDeviceID, &propertyAddress, +0 ,NULL , &propertySize, &frameRange); +#else status = AudioDeviceGetProperty( core->outputDeviceID, 0,
@@ -330,6 +360,7 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) kAudioDevicePropertyBufferFrameSizeRange, &propertySize, &frameRange); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not get device buffer frame range\n" );
@@ -350,6 +381,12 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)/* set Buffer Frame Size */ propertySize =sizeof (core->audioDevicePropertyBufferFrameSize); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 + propertyAddress.mSelector = kAudioDevicePropertyBufferFrameSize; + status =AudioObjectSetPropertyData (core->outputDeviceID, &propertyAddress, +0 ,NULL , propertySize, + &core->audioDevicePropertyBufferFrameSize); +#else status = AudioDeviceSetProperty( core->outputDeviceID, NULL,
@@ -358,15 +395,22 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) kAudioDevicePropertyBufferFrameSize, propertySize, &core->audioDevicePropertyBufferFrameSize); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ, -"Could not set device buffer frame size %ld\n" , +"Could not set device buffer frame size %d\n" , core->audioDevicePropertyBufferFrameSize);return -1 ; }/* get Buffer Frame Size */ propertySize =sizeof (core->audioDevicePropertyBufferFrameSize); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 + propertyAddress.mSelector = kAudioDevicePropertyBufferFrameSize; + status =AudioObjectGetPropertyData (core->outputDeviceID, &propertyAddress, +0 ,NULL , &propertySize, + &core->audioDevicePropertyBufferFrameSize); +#else status = AudioDeviceGetProperty( core->outputDeviceID, 0,
@@ -374,6 +418,7 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) kAudioDevicePropertyBufferFrameSize, &propertySize, &core->audioDevicePropertyBufferFrameSize); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not get device buffer frame size\n" );
@@ -383,6 +428,12 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)/* get StreamFormat */ propertySize =sizeof (core->outputStreamBasicDescription); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 + propertyAddress.mSelector = kAudioDevicePropertyStreamFormat; + status =AudioObjectGetPropertyData (core->outputDeviceID, &propertyAddress, +0 ,NULL , &propertySize, + &core->outputStreamBasicDescription); +#else status = AudioDeviceGetProperty( core->outputDeviceID, 0,
@@ -390,6 +441,7 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) kAudioDevicePropertyStreamFormat, &propertySize, &core->outputStreamBasicDescription); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not get Device Stream properties\n" );
@@ -400,6 +452,12 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)/* set Samplerate */ core->outputStreamBasicDescription.mSampleRate = (Float64 ) as->freq; propertySize =sizeof (core->outputStreamBasicDescription); +#if MAC_OS_X_VERSION_MIN_REQUIRED >MAC_OS_X_VERSION_10_5 + propertyAddress.mSelector = kAudioDevicePropertyStreamFormat; + status =AudioObjectSetPropertyData (core->outputDeviceID, &propertyAddress, +0 ,NULL , propertySize, + &core->outputStreamBasicDescription); +#else status = AudioDeviceSetProperty( core->outputDeviceID, 0,
@@ -408,6 +466,7 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) kAudioDevicePropertyStreamFormat, propertySize, &core->outputStreamBasicDescription); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not set samplerate %d\n" , as->freq);
@@ -416,7 +475,14 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) }/* set Callback */ +#if defined(MAC_OS_X_VERSION_10_5 ) && (MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_X_VERSION_10_5 ) + status =AudioDeviceCreateIOProcID (core->outputDeviceID, + audioDeviceIOProc, + hw, + &core->ioProcID); +#else status =AudioDeviceAddIOProc (core->outputDeviceID, audioDeviceIOProc, hw); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not set IOProc\n" ); core->outputDeviceID = kAudioDeviceUnknown;
@@ -428,7 +494,11 @@ static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as) status =AudioDeviceStart (core->outputDeviceID, audioDeviceIOProc);if (status != kAudioHardwareNoError) {coreaudio_logerr2 (status, typ,"Could not start playback\n" ); +#if defined(MAC_OS_X_VERSION_10_5 ) && (MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_X_VERSION_10_5 ) +AudioDeviceDestroyIOProcID (core->outputDeviceID, core->ioProcID); +#else AudioDeviceRemoveIOProc (core->outputDeviceID, audioDeviceIOProc); +#endif core->outputDeviceID = kAudioDeviceUnknown;return -1 ; }
@@ -453,8 +523,13 @@ static void coreaudio_fini_out (HWVoiceOut *hw) }/* remove callback */ +#if defined(MAC_OS_X_VERSION_10_5 ) && (MAC_OS_X_VERSION_MIN_REQUIRED >=MAC_OS_X_VERSION_10_5 ) + status =AudioDeviceDestroyIOProcID (core->outputDeviceID, + core->ioProcID); +#else status =AudioDeviceRemoveIOProc (core->outputDeviceID, audioDeviceIOProc); +#endif if (status != kAudioHardwareNoError) {coreaudio_logerr (status,"Could not remove IOProc\n" ); }
Signature · 1 line
1.6.5
PATCH 6/48 Get rid of AREG1 and AREG2.
In reply to Riku VoipioFrom: Filip Navara <[email protected]>
--- dyngen-exec.h | 26 -------------------------- tcg/arm/tcg-target.h | 2 -- tcg/hppa/tcg-target.h | 2 -- tcg/i386/tcg-target.h | 2 -- tcg/ppc/tcg-target.h | 2 -- tcg/ppc64/tcg-target.h | 2 -- tcg/sparc/tcg-target.h | 6 ------ tcg/x86_64/tcg-target.h | 2 -- 8 files changed, 0 insertions(+), 44 deletions(-)
dyngen-exec.h +0 -26
@@ -50,62 +50,36 @@ extern int printf(const char *, ...);#if defined(__i386__)#define AREG0 "ebp" -#define AREG1 "ebx" -#define AREG2 "esi"#elif defined(__x86_64__)#define AREG0 "r14" -#define AREG1 "r15" -#define AREG2 "r12"#elif defined(_ARCH_PPC)#define AREG0 "r27" -#define AREG1 "r24" -#define AREG2 "r25"#elif defined(__arm__)#define AREG0 "r7" -#define AREG1 "r4" -#define AREG2 "r5"#elif defined(__hppa__)#define AREG0 "r17" -#define AREG1 "r14" -#define AREG2 "r15"#elif defined(__mips__)#define AREG0 "fp" -#define AREG1 "s0" -#define AREG2 "s1"#elif defined(__sparc__)#ifdef CONFIG_SOLARIS #define AREG0 "g2" -#define AREG1 "g3" -#define AREG2 "g4"#else #ifdef __sparc_v9__#define AREG0 "g5" -#define AREG1 "g6" -#define AREG2 "g7"#else #define AREG0 "g6" -#define AREG1 "g1" -#define AREG2 "g2"#endif #endif #elif defined(__s390__)#define AREG0 "r10" -#define AREG1 "r7" -#define AREG2 "r8"#elif defined(__alpha__)/* Note $15 is the frame pointer, so anything in op-i386.c that would require a frame pointer, like alloca, would probably loose. */ #define AREG0 "$15" -#define AREG1 "$9" -#define AREG2 "$10"#elif defined(__mc68000)#define AREG0 "%a5" -#define AREG1 "%a4" -#define AREG2 "%d7"#elif defined(__ia64__)#define AREG0 "r7" -#define AREG1 "r4" -#define AREG2 "r5"#else #error unsupported CPU#endif
tcg/arm/tcg-target.h +0 -2
@@ -73,8 +73,6 @@ enum {enum {/* Note: must be synced with dyngen-exec.h */ TCG_AREG0 =TCG_REG_R7 , -TCG_AREG1 =TCG_REG_R4 , -TCG_AREG2 =TCG_REG_R5 , };static inline void flush_icache_range (unsigned long start,unsigned long stop)
tcg/hppa/tcg-target.h +0 -2
@@ -83,8 +83,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R17 -#define TCG_AREG1 TCG_REG_R14 -#define TCG_AREG2 TCG_REG_R15static inline void flush_icache_range (unsigned long start,unsigned long stop) {
tcg/i386/tcg-target.h +0 -2
@@ -62,8 +62,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_EBP -#define TCG_AREG1 TCG_REG_EBX -#define TCG_AREG2 TCG_REG_ESIstatic inline void flush_icache_range (unsigned long start,unsigned long stop) {
tcg/ppc/tcg-target.h +0 -2
@@ -91,7 +91,5 @@ enum {#define TCG_TARGET_HAS_orc_i32#define TCG_AREG0 TCG_REG_R27 -#define TCG_AREG1 TCG_REG_R24 -#define TCG_AREG2 TCG_REG_R25#define TCG_TARGET_HAS_GUEST_BASE
tcg/ppc64/tcg-target.h +0 -2
@@ -98,7 +98,5 @@ enum {/* #define TCG_TARGET_HAS_orc_i64 */ #define TCG_AREG0 TCG_REG_R27 -#define TCG_AREG1 TCG_REG_R24 -#define TCG_AREG2 TCG_REG_R25#define TCG_TARGET_HAS_GUEST_BASE
tcg/sparc/tcg-target.h +0 -6
@@ -122,16 +122,10 @@ enum {/* Note: must be synced with dyngen-exec.h and Makefile.target */ #ifdef CONFIG_SOLARIS #define TCG_AREG0 TCG_REG_G2 -#define TCG_AREG1 TCG_REG_G3 -#define TCG_AREG2 TCG_REG_G4#elif defined(__sparc_v9__)#define TCG_AREG0 TCG_REG_G5 -#define TCG_AREG1 TCG_REG_G6 -#define TCG_AREG2 TCG_REG_G7#else #define TCG_AREG0 TCG_REG_G6 -#define TCG_AREG1 TCG_REG_G1 -#define TCG_AREG2 TCG_REG_G2#endif static inline void flush_icache_range (unsigned long start,unsigned long stop)
tcg/x86_64/tcg-target.h +0 -2
@@ -89,8 +89,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R14 -#define TCG_AREG1 TCG_REG_R15 -#define TCG_AREG2 TCG_REG_R12static inline void flush_icache_range (unsigned long start,unsigned long stop) {
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 06/48] Get rid of AREG1 and AREG2.
Quoted 4 lines · Riku Voipio
From: Filip Navara <[email protected]>
Signed-off-by Riku Voipio <[email protected]>Signed-off-by Filip Navara <[email protected]>
Quoted 10 lines
--- dyngen-exec.h | 26 -------------------------- tcg/arm/tcg-target.h | 2 -- tcg/hppa/tcg-target.h | 2 -- tcg/i386/tcg-target.h | 2 -- tcg/ppc/tcg-target.h | 2 -- tcg/ppc64/tcg-target.h | 2 -- tcg/sparc/tcg-target.h | 6 ------ tcg/x86_64/tcg-target.h | 2 -- 8 files changed, 0 insertions(+), 44 deletions(-)
I have just merged the patch from Paolo Bonzini posted a few weeks ago doing exactly the same thing.
Quoted 169 lines
dyngen-exec.h +0
-26@@ -50,62 +50,36 @@ extern int printf(const char *, ...);#if defined(__i386__)#define AREG0 "ebp" -#define AREG1 "ebx" -#define AREG2 "esi"#elif defined(__x86_64__)#define AREG0 "r14" -#define AREG1 "r15" -#define AREG2 "r12"#elif defined(_ARCH_PPC)#define AREG0 "r27" -#define AREG1 "r24" -#define AREG2 "r25"#elif defined(__arm__)#define AREG0 "r7" -#define AREG1 "r4" -#define AREG2 "r5"#elif defined(__hppa__)#define AREG0 "r17" -#define AREG1 "r14" -#define AREG2 "r15"#elif defined(__mips__)#define AREG0 "fp" -#define AREG1 "s0" -#define AREG2 "s1"#elif defined(__sparc__)#ifdef CONFIG_SOLARIS #define AREG0 "g2" -#define AREG1 "g3" -#define AREG2 "g4"#else #ifdef __sparc_v9__#define AREG0 "g5" -#define AREG1 "g6" -#define AREG2 "g7"#else #define AREG0 "g6" -#define AREG1 "g1" -#define AREG2 "g2"#endif #endif #elif defined(__s390__)#define AREG0 "r10" -#define AREG1 "r7" -#define AREG2 "r8"#elif defined(__alpha__)/* Note $15 is the frame pointer, so anything in op-i386.c that would require a frame pointer, like alloca, would probably loose. */ #define AREG0 "$15" -#define AREG1 "$9" -#define AREG2 "$10"#elif defined(__mc68000)#define AREG0 "%a5" -#define AREG1 "%a4" -#define AREG2 "%d7"#elif defined(__ia64__)#define AREG0 "r7" -#define AREG1 "r4" -#define AREG2 "r5"#else #error unsupported CPU#endif tcg/arm/tcg-target.h +0
-2@@ -73,8 +73,6 @@ enum {enum {/* Note: must be synced with dyngen-exec.h */ TCG_AREG0 =TCG_REG_R7 , -TCG_AREG1 =TCG_REG_R4 , -TCG_AREG2 =TCG_REG_R5 , };static inline void flush_icache_range (unsigned long start,unsigned long stop)tcg/hppa/tcg-target.h +0
-2@@ -83,8 +83,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R17 -#define TCG_AREG1 TCG_REG_R14 -#define TCG_AREG2 TCG_REG_R15static inline void flush_icache_range (unsigned long start,unsigned long stop) {tcg/i386/tcg-target.h +0
-2@@ -62,8 +62,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_EBP -#define TCG_AREG1 TCG_REG_EBX -#define TCG_AREG2 TCG_REG_ESIstatic inline void flush_icache_range (unsigned long start,unsigned long stop) {tcg/ppc/tcg-target.h +0
-2@@ -91,7 +91,5 @@ enum {#define TCG_TARGET_HAS_orc_i32#define TCG_AREG0 TCG_REG_R27 -#define TCG_AREG1 TCG_REG_R24 -#define TCG_AREG2 TCG_REG_R25#define TCG_TARGET_HAS_GUEST_BASE tcg/ppc64/tcg-target.h +0
-2@@ -98,7 +98,5 @@ enum {/* #define TCG_TARGET_HAS_orc_i64 */ #define TCG_AREG0 TCG_REG_R27 -#define TCG_AREG1 TCG_REG_R24 -#define TCG_AREG2 TCG_REG_R25#define TCG_TARGET_HAS_GUEST_BASE tcg/sparc/tcg-target.h +0
-6@@ -122,16 +122,10 @@ enum {/* Note: must be synced with dyngen-exec.h and Makefile.target */ #ifdef CONFIG_SOLARIS #define TCG_AREG0 TCG_REG_G2 -#define TCG_AREG1 TCG_REG_G3 -#define TCG_AREG2 TCG_REG_G4#elif defined(__sparc_v9__)#define TCG_AREG0 TCG_REG_G5 -#define TCG_AREG1 TCG_REG_G6 -#define TCG_AREG2 TCG_REG_G7#else #define TCG_AREG0 TCG_REG_G6 -#define TCG_AREG1 TCG_REG_G1 -#define TCG_AREG2 TCG_REG_G2#endif static inline void flush_icache_range (unsigned long start,unsigned long stop)tcg/x86_64/tcg-target.h +0
-2@@ -89,8 +89,6 @@ enum {/* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R14 -#define TCG_AREG1 TCG_REG_R15 -#define TCG_AREG2 TCG_REG_R12static inline void flush_icache_range (unsigned long start,unsigned long stop) {Signature · 1 line
1.6.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH 7/48 Shrink tb_jmp_offset to two entries, the other two are never used.
In reply to Riku VoipioFrom: Filip Navara <[email protected]>
--- exec-all.h | 5 +---- translate-all.c | 4 ---- 2 files changed, 1 insertions(+), 8 deletions(-)
exec-all.h +1 -4
@@ -143,7 +143,7 @@ struct TranslationBlock {the code of this one. */ uint16_t tb_next_offset[2 ];/* offset of original jump target */ #ifdef USE_DIRECT_JUMP -uint16_t tb_jmp_offset[4 ];/* offset of jump instruction */ +uint16_t tb_jmp_offset[2 ];/* offset of jump instruction */ #else unsigned long tb_next[2 ];/* address of jump generated code */ #endif
@@ -234,9 +234,6 @@ static inline void tb_set_jmp_target(TranslationBlock *tb, offset = tb->tb_jmp_offset[n]; tb_set_jmp_target1((unsigned long)(tb->tc_ptr + offset), addr); - offset = tb->tb_jmp_offset[n +2 ]; -if (offset !=0xffff ) - tb_set_jmp_target1((unsigned long)(tb->tc_ptr + offset), addr); }#else
translate-all.c +0 -4
@@ -103,10 +103,6 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)#ifdef USE_DIRECT_JUMP s->tb_jmp_offset = tb->tb_jmp_offset; s->tb_next =NULL ; -/* the following two entries are optional (only used for string ops) */ -/* XXX: not used ? */ - tb->tb_jmp_offset[2 ] =0xffff ; - tb->tb_jmp_offset[3 ] =0xffff ;#else s->tb_jmp_offset =NULL ; s->tb_next = tb->tb_next;
Signature · 1 line
1.6.5
PATCH 8/48 Cortex-A8 R2 support and trustzone
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/cpu.h | 7 +- target-arm/helper.c | 330 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 220 insertions(+), 117 deletions(-)
target-arm/cpu.h +6 -1
@@ -110,6 +110,9 @@ typedef struct CPUARMState {uint32_t c1_sys;/* System control register. */ uint32_t c1_coproc;/* Coprocessor access register. */ uint32_t c1_xscaleauxcr;/* XScale auxiliary control register. */ +uint32_t c1_secfg;/* Secure configuration register. */ +uint32_t c1_sedbg;/* Secure debug enable register. */ +uint32_t c1_nseac;/* Non-secure access control register. */ uint32_t c2_base0;/* MMU translation table base 0. */ uint32_t c2_base1;/* MMU translation table base 1. */ uint32_t c2_control;/* MMU translation table base control. */
@@ -345,7 +348,8 @@ enum arm_features {ARM_FEATURE_DIV ,ARM_FEATURE_M ,/* Microcontroller profile. */ ARM_FEATURE_OMAPCP ,/* OMAP specific CP15 ops handling. */ - ARM_FEATURE_THUMB2EE +ARM_FEATURE_THUMB2EE , + ARM_FEATURE_TRUSTZONE /* TrustZone Security Extensions. */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -392,6 +396,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define ARM_CPUID_ARM1136_R2 0x4107b362#define ARM_CPUID_ARM11MPCORE 0x410fb022#define ARM_CPUID_CORTEXA8 0x410fc080 +#define ARM_CPUID_CORTEXA8_R2 0x412fc083#define ARM_CPUID_CORTEXA9 0x410fc090#define ARM_CPUID_CORTEXM3 0x410fc231#define ARM_CPUID_ANY 0xffffffff
target-arm/helper.c +214 -116
445 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 9/48 console change headers
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
multitouch, multi-keyboard and window close hook support
--- console.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
console.h +13 -0
@@ -10,6 +10,7 @@#define MOUSE_EVENT_LBUTTON 0x01#define MOUSE_EVENT_RBUTTON 0x02#define MOUSE_EVENT_MBUTTON 0x04 +extern int multitouch_enabled;/* identical to the ps/2 keyboard bits */ #define QEMU_SCROLL_LOCK_LED (1 << 0)
@@ -19,6 +20,10 @@/* in ms */ #define GUI_REFRESH_INTERVAL 30 +typedef int QEMUDisplayCloseCallback (void *opaque); +void qemu_set_display_close_handler (QEMUDisplayCloseCallback *cb,void *opaque); +int qemu_run_display_close_handler (void ); +typedef void QEMUPutKBDEvent (void *opaque,int keycode);typedef void QEMUPutLEDEvent (void *opaque,int ledstate);typedef void QEMUPutMouseEvent (void *opaque,int dx,int dy,int dz,int buttons_state);
@@ -34,6 +39,13 @@ typedef struct QEMUPutMouseEntry {/* used internally by qemu for handling mice */ QTAILQ_ENTRY (QEMUPutMouseEntry) node; } QEMUPutMouseEntry; +typedef struct QEMUPutKBDEntry { +QEMUPutKBDEvent *qemu_put_kbd_event; +void *qemu_put_kbd_event_opaque; + +/* used internally by qemu for handling keyboards */ +struct QEMUPutKBDEntry *next; +}QEMUPutKBDEntry ; typedef struct QEMUPutLEDEntry { QEMUPutLEDEvent *put_led;
@@ -42,6 +54,7 @@ typedef struct QEMUPutLEDEntry { } QEMUPutLEDEntry;void qemu_add_kbd_event_handler (QEMUPutKBDEvent *func,void *opaque); +void qemu_remove_kbd_event_handler (QEMUPutKBDEvent *entry);QEMUPutMouseEntry *qemu_add_mouse_event_handler (QEMUPutMouseEvent *func,void *opaque,int absolute,const char *name);
Signature · 1 line
1.6.5
PATCH 10/48 Lots of ARM TCG changes
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
This patch is flattened set of dozens of patches. These patches will be sent via another patch series once the commit messages have been improved.
--- target-arm/helpers.h | 11 + target-arm/machine.c | 6 + target-arm/neon_helper.c | 269 ++++++++ target-arm/op_helper.c | 124 ++++ target-arm/translate.c | 1619 ++++++++++++++++++++++++---------------------- 5 files changed, 1263 insertions(+), 766 deletions(-)
target-arm/helpers.h +11 -0
@@ -160,10 +160,14 @@ DEF_HELPER_3(neon_qadd_u8, i32, env, i32, i32) DEF_HELPER_3(neon_qadd_s8, i32, env, i32, i32) DEF_HELPER_3(neon_qadd_u16, i32, env, i32, i32) DEF_HELPER_3(neon_qadd_s16, i32, env, i32, i32) +DEF_HELPER_3(neon_qadd_u32, i32, env, i32, i32) +DEF_HELPER_3(neon_qadd_s32, i32, env, i32, i32) DEF_HELPER_3(neon_qsub_u8, i32, env, i32, i32) DEF_HELPER_3(neon_qsub_s8, i32, env, i32, i32) DEF_HELPER_3(neon_qsub_u16, i32, env, i32, i32) DEF_HELPER_3(neon_qsub_s16, i32, env, i32, i32) +DEF_HELPER_3(neon_qsub_u32, i32, env, i32, i32) +DEF_HELPER_3(neon_qsub_s32, i32, env, i32, i32) DEF_HELPER_2(neon_hadd_s8, i32, i32, i32)DEF_HELPER_2 (neon_hadd_u8, i32, i32, i32)
@@ -291,10 +295,13 @@ DEF_HELPER_3(neon_qrdmulh_s32, i32, env, i32, i32) DEF_HELPER_1(neon_narrow_u8, i32, i64) DEF_HELPER_1(neon_narrow_u16, i32, i64) +DEF_HELPER_2(neon_unarrow_sat8, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u8, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s8, i32, env, i64) +DEF_HELPER_2(neon_unarrow_sat16, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u16, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s16, i32, env, i64) +DEF_HELPER_2(neon_unarrow_sat32, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_u32, i32, env, i64) DEF_HELPER_2(neon_narrow_sat_s32, i32, env, i64)DEF_HELPER_1 (neon_narrow_high_u8, i32, i64)
@@ -447,4 +454,8 @@ DEF_HELPER_3(iwmmxt_muladdswl, i64, i64, i32, i32) DEF_HELPER_2(set_teecr, void, env, i32) +DEF_HELPER_2(neon_unzip, void, env, i32) +DEF_HELPER_2(neon_zip, void, env, i32) +DEF_HELPER_2(neon_vldst_all, void, env, i32) +#include "def-helper.h"
target-arm/machine.c +6 -0
@@ -26,6 +26,9 @@ void cpu_save(QEMUFile *f, void *opaque)qemu_put_be32 (f, env->cp15.c1_sys);qemu_put_be32 (f, env->cp15.c1_coproc);qemu_put_be32 (f, env->cp15.c1_xscaleauxcr); +qemu_put_be32 (f, env->cp15.c1_secfg); +qemu_put_be32 (f, env->cp15.c1_sedbg); +qemu_put_be32 (f, env->cp15.c1_nseac);qemu_put_be32 (f, env->cp15.c2_base0);qemu_put_be32 (f, env->cp15.c2_base1);qemu_put_be32 (f, env->cp15.c2_control);
@@ -133,6 +136,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) env->cp15.c1_sys =qemu_get_be32 (f); env->cp15.c1_coproc =qemu_get_be32 (f); env->cp15.c1_xscaleauxcr =qemu_get_be32 (f); + env->cp15.c1_secfg =qemu_get_be32 (f); + env->cp15.c1_sedbg =qemu_get_be32 (f); + env->cp15.c1_nseac =qemu_get_be32 (f); env->cp15.c2_base0 =qemu_get_be32 (f); env->cp15.c2_base1 =qemu_get_be32 (f); env->cp15.c2_control =qemu_get_be32 (f);
target-arm/neon_helper.c +269 -0
314 lines not on this page · raw message
target-arm/op_helper.c +124 -0
127 lines not on this page · raw message
target-arm/translate.c +853 -766
2,379 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 12/48 cocoa frontend changes
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
remove help menu, fix fullscreen mode mouse handling, add confirmation dialog to quit menu command, add support for undocumented alt-grab and ctrl-grab options, add qemu version printout in about panel.
- fix build on os x versions prior to 10.6
- cocoa window handling fixes
- show shutting down status in window caption
- add display close handler support
- add support for multitouch in cocoa frontend
- cocoa keymap changes
--- cocoa.m | 313 +++++++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 217 insertions(+), 96 deletions(-)
cocoa.m +217 -96
@@ -47,10 +47,25 @@ #define cgrect(nsrect) (*(CGRect *)&(nsrect)) #define COCOA_MOUSE_EVENT \ if (isTabletEnabled) { \ - kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \ + if (isFullscreen) { \ + NSSize fs = [[NSScreen mainScreen] frame].size; \ + kbd_mouse_event((int)(p.x * 0x7FFF / (fs.width - 1)), \ + (int)((fs.height - p.y) * 0x7FFF / (fs.height - 1)), \ + 0, buttons); \ + } else { \ + kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), \ + (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), \ + 0, buttons); \ + } \ } else if (isMouseGrabed) { \ kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \ } else { \ + if (isFullscreen) { \ + NSSize fs = [[NSScreen mainScreen] frame].size; \ + kbd_mouse_event((int)(p.x * 0x7FFF / (fs.width - 1)), \ + (int)((fs.height - p.y) * 0x7FFF / (fs.height - 1)), \ + 0, buttons); \ + } \ [NSApp sendEvent:event]; \ }
@@ -65,6 +80,7 @@ int qemu_main(int argc, char **argv); // main defined in qemu/vl.c NSWindow *normalWindow; id cocoaView; static DisplayChangeListener *dcl; +static int last_vm_running; int gArgc; char **gArgv;
@@ -83,7 +99,7 @@ int keymap[] = 45, // 7 0x07 0x2d X QZ_x 46, // 8 0x08 0x2e C QZ_c 47, // 9 0x09 0x2f V QZ_v - 0, // 10 0x0A Undefined + 0, // 10 0x0A Undefined (paragraph) 48, // 11 0x0B 0x30 B QZ_b 16, // 12 0x0C 0x10 Q QZ_q 17, // 13 0x0D 0x11 W QZ_w
@@ -127,8 +143,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 0xdc e0,5c R GUI QZ_RMETA + 219,// 55 0xdb e0,5b L GUI 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
@@ -136,9 +152,9 @@ int keymap[] = 54, // 60 0x3C 0x36 R SHFT QZ_RSHIFT 184,// 61 0x3D 0xb8 E0,38 R ALT QZ_RALT 157,// 62 0x3E 0x9d E0,1D R CTRL QZ_RCTRL - 0, // 63 0x3F Undefined - 0, // 64 0x40 Undefined - 0, // 65 0x41 Undefined + 0, // 63 0x3F Undefined (fn) + 0, // 64 0x40 Undefined (f17) + 83, // 65 0x53 0x53 KP . 0, // 66 0x42 Undefined 55, // 67 0x43 0x37 KP * QZ_KP_MULTIPLY 0, // 68 0x44 Undefined
@@ -152,9 +168,9 @@ int keymap[] = 152,// 76 0x4C 0x9c E0,1C KP EN QZ_KP_ENTER 0, // 77 0x4D undefined 74, // 78 0x4E 0x4a KP - QZ_KP_MINUS - 0, // 79 0x4F Undefined - 0, // 80 0x50 Undefined - 0, // 81 0x51 QZ_KP_EQUALS + 0, // 79 0x4F Undefined (f18) + 0, // 80 0x50 Undefined (f19) + 0, // 81 0x51 (kp =) QZ_KP_EQUALS 82, // 82 0x52 0x52 KP 0 QZ_KP0 79, // 83 0x53 0x4f KP 1 QZ_KP1 80, // 84 0x54 0x50 KP 2 QZ_KP2
@@ -178,15 +194,15 @@ int keymap[] = 0, // 102 0x66 Undefined 87, // 103 0x67 0x57 F11 QZ_F11 0, // 104 0x68 Undefined - 183,// 105 0x69 0xb7 QZ_PRINT + 183,// 105 0x69 0xb7 (f13) QZ_PRINT 0, // 106 0x6A Undefined - 70, // 107 0x6B 0x46 SCROLL QZ_SCROLLOCK + 70, // 107 0x6B 0x46 SCROLL(f14) QZ_SCROLLOCK 0, // 108 0x6C Undefined 68, // 109 0x6D 0x44 F10 QZ_F10 0, // 110 0x6E Undefined 88, // 111 0x6F 0x58 F12 QZ_F12 0, // 112 0x70 Undefined - 110,// 113 0x71 0x0 QZ_PAUSE + 110,// 113 0x71 0x0 (f15) QZ_PAUSE 210,// 114 0x72 0xd2 E0,52 INSERT QZ_INSERT 199,// 115 0x73 0xc7 E0,47 HOME QZ_HOME 201,// 116 0x74 0xc9 E0,49 PG UP QZ_PAGEUP
@@ -204,12 +220,9 @@ int keymap[] = /* Aditional 104 Key XP-Keyboard Scancodes from http://www.computer-engineering.org/ps2keyboard/scancodes1.html */ /* - 219 // 0xdb e0,5b L GUI - 220 // 0xdc e0,5c R GUI 221 // 0xdd e0,5d APPS // E0,2A,E0,37 PRNT SCRN // E1,1D,45,E1,9D,C5 PAUSE - 83 // 0x53 0x53 KP . // ACPI Scan Codes 222 // 0xde E0, 5E Power 223 // 0xdf E0, 5F Sleep
@@ -259,23 +272,29 @@ static int cocoa_keycode_to_qemu(int keycode) NSWindow *fullScreenWindow; float cx,cy,cw,ch,cdx,cdy; CGDataProviderRef dataProviderRef; + void *dataRawPtr; + int mouseX, mouseY; int modifiers_state[256]; BOOL isMouseGrabed; BOOL isFullscreen; BOOL isAbsoluteEnabled; BOOL isTabletEnabled; + BOOL isShuttingDownGuest; } - (void) resizeContentToWidth:(int)w height:(int)h displayState:(DisplayState *)ds; - (void) grabMouse; - (void) ungrabMouse; - (void) toggleFullScreen:(id)sender; -- (void) handleEvent:(NSEvent *)event; +- (void) qemuHandleEvent:(NSEvent *)event; - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; +- (void) setShuttingDownGuest; - (BOOL) isMouseGrabed; - (BOOL) isAbsoluteEnabled; - (float) cdx; - (float) cdy; - (QEMUScreen) gscreen; +- (void) updateCaption; +- (void) checkAndDisplayAltCursor; @end @implementation QemuCocoaView
@@ -310,6 +329,34 @@ static int cocoa_keycode_to_qemu(int keycode) return YES; } +- (void) checkAndDisplayAltCursor +{ + if (multitouch_enabled && !isMouseGrabed && !cursor_hide && + dataRawPtr && modifiers_state[56]) { + unsigned char *p = (unsigned char *)dataRawPtr; + int altX = screen.width - mouseX; + int altY = mouseY; + int x, y; + int bytesperpixel = screen.bitsPerPixel / 8; + p += (altY * screen.width) * bytesperpixel; + for (y = 0; y < 8; y++) { + if (y + altY > 0 && y + altY < screen.height) { + unsigned char *q = p + altX * bytesperpixel; + for (x = 0; x < 8; x++) { + if (x + altX > 0 && x + altX < screen.width) { + int i; + for (i = 0; i < bytesperpixel; i++) { + q[i] ^= 0xff; + } + } + q += bytesperpixel; + } + } + p += screen.width * bytesperpixel; + } + } +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");
@@ -321,6 +368,7 @@ static int cocoa_keycode_to_qemu(int keycode) // draw screen bitmap directly to Core Graphics context if (dataProviderRef) { + [self checkAndDisplayAltCursor]; CGImageRef imageRef = CGImageCreate( screen.width, //width screen.height, //height
@@ -360,10 +408,10 @@ static int cocoa_keycode_to_qemu(int keycode) [self getRectsBeingDrawn:&rectList count:&rectCount]; for (i = 0; i < rectCount; i++) { - clipRect.origin.x = rectList[i].origin.x / cdx; - clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy; - clipRect.size.width = rectList[i].size.width / cdx; - clipRect.size.height = rectList[i].size.height / cdy; + clipRect.origin.x = floorf(rectList[i].origin.x / cdx); + clipRect.origin.y = floorf((float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy); + clipRect.size.width = ceilf(rectList[i].size.width / cdx); + clipRect.size.height = ceilf(rectList[i].size.height / cdy); clipImageRef = CGImageCreateWithImageInRect( imageRef, clipRect
@@ -410,6 +458,7 @@ static int cocoa_keycode_to_qemu(int keycode) screen.bitsPerPixel = ds_get_bits_per_pixel(ds); screen.bitsPerComponent = ds_get_bytes_per_pixel(ds) * 2; + dataRawPtr = is_graphic_console() ? ds_get_data(ds) : 0; dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), w * 4 * h, NULL); // update windows
@@ -417,10 +466,9 @@ static int cocoa_keycode_to_qemu(int keycode) [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:NO animate:NO]; } else { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; } + [self updateCaption]; screen.width = w; screen.height = h; [normalWindow center];
@@ -434,7 +482,7 @@ static int cocoa_keycode_to_qemu(int keycode) if (isFullscreen) { // switch from fullscreen to desktop isFullscreen = FALSE; - [self ungrabMouse]; + if (isMouseGrabed) [self ungrabMouse]; [self setContentDimensions]; // test if host supports "exitFullScreenModeWithOptions" at compile time #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@@ -444,29 +492,33 @@ static int cocoa_keycode_to_qemu(int keycode) #endif [fullScreenWindow close]; [normalWindow setContentView: self]; - [normalWindow makeKeyAndOrderFront: self]; [NSMenu setMenuBarVisible:YES]; #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) } #endif + [normalWindow makeKeyAndOrderFront:self]; } else { // switch from desktop to fullscreen isFullscreen = TRUE; - [self grabMouse]; + if (cursor_allow_grab) [self grabMouse]; [self setContentDimensions]; + [normalWindow orderOut:self]; // test if host supports "enterFullScreenMode:withOptions" at compile time #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime - [self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, - [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], kCGDisplayModeIsStretched, nil], NSFullScreenModeSetting, - nil]]; + [self enterFullScreenMode:[NSScreen mainScreen] + withOptions:[NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kCGDisplayModeIsStretched, + nil], NSFullScreenModeSetting, + nil]]; } else { #endif [NSMenu setMenuBarVisible:NO]; fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO]; + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; [fullScreenWindow setHasShadow:NO]; [fullScreenWindow setContentView:self]; [fullScreenWindow makeKeyAndOrderFront:self];
@@ -476,7 +528,7 @@ static int cocoa_keycode_to_qemu(int keycode) } } -- (void) handleEvent:(NSEvent *)event +- (void) qemuHandleEvent:(NSEvent *)event { COCOA_DEBUG("QemuCocoaView: handleEvent\n");
@@ -505,8 +557,13 @@ static int cocoa_keycode_to_qemu(int keycode) } // release Mouse grab when pressing ctrl+alt - if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { - [self ungrabMouse]; + if (!isFullscreen) { + if ((ctrl_grab && [event keyCode] == 0x3e) + || ((([event modifierFlags] & NSControlKeyMask) && + ([event modifierFlags] & NSAlternateKeyMask)) + && (!alt_grab || ([event modifierFlags] & NSShiftKeyMask)))) { + [self ungrabMouse]; + } } break; case NSKeyDown:
@@ -581,15 +638,17 @@ static int cocoa_keycode_to_qemu(int keycode) } break; case NSMouseMoved: + mouseX = p.x; + mouseY = p.y; if (isAbsoluteEnabled) { if (p.x < 0 || p.x > screen.width || p.y < 0 || p.y > screen.height || ![[self window] isKeyWindow]) { if (isTabletEnabled) { // if we leave the window, deactivate the tablet - [NSCursor unhide]; + if (cursor_hide) [NSCursor unhide]; isTabletEnabled = FALSE; } } else { if (!isTabletEnabled) { // if we enter the window, activate the tablet - [NSCursor hide]; + if (cursor_hide) [NSCursor hide]; isTabletEnabled = TRUE; } }
@@ -602,6 +661,9 @@ static int cocoa_keycode_to_qemu(int keycode) } else { buttons |= MOUSE_EVENT_LBUTTON; } + if ([event modifierFlags] & NSAlternateKeyMask) { + buttons |= MOUSE_EVENT_MBUTTON << 1; + } COCOA_MOUSE_EVENT break; case NSRightMouseDown:
@@ -613,11 +675,16 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_MOUSE_EVENT break; case NSLeftMouseDragged: + mouseX = p.x; + mouseY = p.y; if ([event modifierFlags] & NSCommandKeyMask) { buttons |= MOUSE_EVENT_RBUTTON; } else { buttons |= MOUSE_EVENT_LBUTTON; } + if ([event modifierFlags] & NSAlternateKeyMask) { + buttons |= MOUSE_EVENT_MBUTTON << 1; + } COCOA_MOUSE_EVENT break; case NSRightMouseDragged:
@@ -633,7 +700,7 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_MOUSE_EVENT } else if (!isMouseGrabed) { if (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.height) { - [self grabMouse]; + if (cursor_allow_grab) [self grabMouse]; } else { [NSApp sendEvent:event]; }
@@ -654,6 +721,25 @@ static int cocoa_keycode_to_qemu(int keycode) [NSApp sendEvent:event]; } break; + case NSAppKitDefined: + switch ([event subtype]) { + case NSApplicationActivatedEventType: + if (dcl) { + dcl->gui_timer_interval = 0; + dcl->idle = 0; + } + break; + case NSApplicationDeactivatedEventType: + if (dcl) { + dcl->gui_timer_interval = 500; + dcl->idle = 1; + } + break; + default: + break; + } + [NSApp sendEvent:event]; + break; default: [NSApp sendEvent:event]; }
@@ -662,34 +748,48 @@ static int cocoa_keycode_to_qemu(int keycode) - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); - - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt to release Mouse)", qemu_name]]; - else - [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"]; - } - [NSCursor hide]; + if (cursor_hide) [NSCursor hide]; CGAssociateMouseAndMouseCursorPosition(FALSE); isMouseGrabed = TRUE; // while isMouseGrabed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] + [self updateCaption]; } - (void) ungrabMouse { COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - else - [normalWindow setTitle:@"QEMU"]; - } - [NSCursor unhide]; + if (cursor_hide) [NSCursor unhide]; CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabed = FALSE; + [self updateCaption]; +} + +- (void) updateCaption +{ + NSMutableString *caption = [NSMutableString stringWithCapacity:10]; + [caption appendFormat:@"QEMU"]; + if (isShuttingDownGuest) { + [caption appendString:@" [Shutting down]"]; + } + if (qemu_name) { + [caption appendFormat:@" (%s)", qemu_name]; + } + if (!vm_running) { + [caption appendString:@" [Stopped]"]; + } else if (isMouseGrabed) { + if (ctrl_grab) { + [caption appendString:@" - Press Right-Ctrl to release mouse"]; + } else if (alt_grab) { + [caption appendString:@" - Press Ctrl-Alt-Shift to release mouse"]; + } else { + [caption appendString:@" - Press Ctrl-Alt to release mouse"]; + } + } + [normalWindow setTitle:caption]; } - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled {isAbsoluteEnabled = tIsAbsoluteEnabled;} +- (void) setShuttingDownGuest { isShuttingDownGuest = YES; [self updateCaption]; } - (BOOL) isMouseGrabed {return isMouseGrabed;} - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;} - (float) cdx {return cdx;}
@@ -704,14 +804,16 @@ static int cocoa_keycode_to_qemu(int keycode) QemuCocoaAppController ------------------------------------------------------ */ +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) +@interface QemuCocoaAppController : NSObject <NSWindowDelegate> +#else @interface QemuCocoaAppController : NSObject +#endif { } - (void)startEmulationWithArgc:(int)argc argv:(char**)argv; - (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; - (void)toggleFullScreen:(id)sender; -- (void)showQEMUDoc:(id)sender; -- (void)showQEMUTec:(id)sender; @end @implementation QemuCocoaAppController
@@ -743,7 +845,8 @@ static int cocoa_keycode_to_qemu(int keycode) [normalWindow useOptimizedDrawing:YES]; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center]; - + [normalWindow setDelegate:self]; + [cocoaView updateCaption]; } return self; }
@@ -781,7 +884,6 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n"); qemu_system_shutdown_request(); - exit(0); } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
@@ -819,6 +921,7 @@ static int cocoa_keycode_to_qemu(int keycode) [self startEmulationWithArgc:3 argv:(char**)argv]; } } + - (void)toggleFullScreen:(id)sender { COCOA_DEBUG("QemuCocoaAppController: toggleFullScreen\n");
@@ -826,41 +929,57 @@ static int cocoa_keycode_to_qemu(int keycode) [cocoaView toggleFullScreen:sender]; } -- (void)showQEMUDoc:(id)sender +- (BOOL)windowShouldClose:(id)sender { - COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n"); - - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-doc.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; + if (!no_quit) { + if (qemu_run_display_close_handler()) { + return YES; + } + [cocoaView setShuttingDownGuest]; + } + return NO; } -- (void)showQEMUTec:(id)sender +- (void)confirmQuit:(id)sender { - COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n"); + NSAlert *alert = [NSAlert alertWithMessageText:@"Are you sure you want to quit QEMU?" + defaultButton:@"No" + alternateButton:@"Yes" + otherButton:@"Shutdown" + informativeTextWithFormat:@"If you quit QEMU without shutting down the emulated machine properly you risk losing data and possibly corrupting the virtual machine contents."]; + [alert setAlertStyle:NSCriticalAlertStyle]; + switch ([alert runModal]) { + case NSAlertDefaultReturn: + /* do nothing */ + break; + case NSAlertAlternateReturn: + [NSApp terminate:sender]; + break; + case NSAlertOtherReturn: + if (qemu_run_display_close_handler()) { + qemu_system_shutdown_request(); + } else { + [cocoaView setShuttingDownGuest]; + } + break; + default: + break; + } +} - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; +- (void)aboutQEMU:(id)sender +{ + [NSApp orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys: + @ QEMU_VERSION QEMU_PKGVERSION, @"ApplicationVersion", + nil]]; } @end - -// Dock Connection -typedef struct CPSProcessSerNum +int main (int argc, const char * argv[]) { - UInt32 lo; - UInt32 hi; -} CPSProcessSerNum; - -extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); - -int main (int argc, const char * argv[]) { - gArgc = argc; gArgv = (char **)argv; - CPSProcessSerNum PSN; int i; /* In case we don't need to display a window, let's not do that */
@@ -875,10 +994,11 @@ int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; - if (!CPSGetCurrentProcess(&PSN)) - if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) - if (!CPSSetFrontProcess(&PSN)) - [NSApplication sharedApplication]; + ProcessSerialNumber PSN; + if (!GetCurrentProcess(&PSN) && + !TransformProcessType(&PSN, kProcessTransformToForegroundApplication) && + !SetFrontProcess(&PSN)) + [NSApplication sharedApplication]; // Add menus NSMenu *menu;
@@ -888,14 +1008,14 @@ int main (int argc, const char * argv[]) { // Application menu menu = [[NSMenu alloc] initWithTitle:@""]; - [menu addItemWithTitle:@"About QEMU" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; // About QEMU + [menu addItemWithTitle:@"About QEMU" action:@selector(aboutQEMU:) keyEquivalent:@""]; // About QEMU [menu addItem:[NSMenuItem separatorItem]]; //Separator [menu addItemWithTitle:@"Hide QEMU" action:@selector(hide:) keyEquivalent:@"h"]; //Hide QEMU menuItem = (NSMenuItem *)[menu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; // Hide Others [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; [menu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; // Show All [menu addItem:[NSMenuItem separatorItem]]; //Separator - [menu addItemWithTitle:@"Quit QEMU" action:@selector(terminate:) keyEquivalent:@"q"]; + [menu addItemWithTitle:@"Quit QEMU" action:@selector(confirmQuit:) keyEquivalent:@"q"]; menuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" action:nil keyEquivalent:@""]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem];
@@ -916,14 +1036,6 @@ int main (int argc, const char * argv[]) { [[NSApp mainMenu] addItem:menuItem]; [NSApp setWindowsMenu:menu]; - // Help menu - menu = [[NSMenu alloc] initWithTitle:@"Help"]; - [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Documentation" action:@selector(showQEMUDoc:) keyEquivalent:@"?"] autorelease]]; // QEMU Help - [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Technology" action:@selector(showQEMUTec:) keyEquivalent:@""] autorelease]]; // QEMU Help - menuItem = [[[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""] autorelease]; - [menuItem setSubmenu:menu]; - [[NSApp mainMenu] addItem:menuItem]; - // Create an Application controller QemuCocoaAppController *appController = [[QemuCocoaAppController alloc] init]; [NSApp setDelegate:appController];
@@ -968,6 +1080,11 @@ static void cocoa_refresh(DisplayState *ds) { COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); + if (last_vm_running != vm_running) { + last_vm_running = vm_running; + [cocoaView updateCaption]; + } + if (kbd_mouse_is_absolute()) { if (![cocoaView isAbsoluteEnabled]) { if ([cocoaView isMouseGrabed]) {
@@ -984,7 +1101,7 @@ static void cocoa_refresh(DisplayState *ds) event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast inMode: NSDefaultRunLoopMode dequeue:YES]; if (event != nil) { - [cocoaView handleEvent:event]; + [cocoaView qemuHandleEvent:event]; } } while(event != nil); vga_hw_update();
@@ -1012,3 +1129,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen) // register cleanup function atexit(cocoa_cleanup); } + +#ifdef CONFIG_GLHW +#include "hw/gl/opengl_host_cocoa.m" +#endif
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 12/48] cocoa frontend changes
Hello,
Am 26.03.2010 um 17:06 schrieb Riku Voipio:
Quoted 11 lines
From: Juha Riihimäki <[email protected]>
remove help menu, fix fullscreen mode mouse handling, add confirmation dialog to quit menu command, add support for undocumented alt-grab and ctrl-grab options, add qemu version printout in about panel.
- fix build on os x versions prior to 10.6
- cocoa window handling fixes
- show shutting down status in window caption
- add display close handler support
- add support for multitouch in cocoa frontend
- cocoa keymap changes
I would appreciate if you could untangle these for review by splitting this patch up. Last time I built on 10.5/ppc there were no build issues in Cocoa, for instance.
Further comment inline.
Quoted 12 lines
Signed-off-by Riku Voipio <[email protected]>Signed-off-by Juha Riihimäki <[email protected]>---
cocoa.m | 313 +++++++++++++++++++++++++++++++++++++++++++-------------------1 files changed, 217 insertions(+), 96 deletions(-)cocoa.m +0
-0
cocoa.m line 48
Quoted 2 lines
cocoa.m +0
-0@@ -47,10 +47,25 @@ #define cgrect(nsrect) (*(CGRect *)&(nsrect)) #define COCOA_MOUSE_EVENT \
Since this macro is growing large, could you consider turning it into a static inline function please?
Regards,
Andreas
Quoted 650 lines
cocoa.m +36
-27if (isTabletEnabled) { \ - kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), 0, buttons); \ + if (isFullscreen) { \ + NSSize fs = [[NSScreen mainScreen] frame].size; \ + kbd_mouse_event((int)(p.x * 0x7FFF / (fs.width - 1)), \ + (int)((fs.height - p.y) * 0x7FFF / (fs.height - 1)), \ + 0, buttons); \ + } else { \ + kbd_mouse_event((int)(p.x * 0x7FFF / (screen.width - 1)), \ + (int)((screen.height - p.y) * 0x7FFF / (screen.height - 1)), \ + 0, buttons); \ + } \ } else if (isMouseGrabed) { \ kbd_mouse_event((int)[event deltaX], (int)[event deltaY], 0, buttons); \ } else { \ + if (isFullscreen) { \ + NSSize fs = [[NSScreen mainScreen] frame].size; \ + kbd_mouse_event((int)(p.x * 0x7FFF / (fs.width - 1)), \ + (int)((fs.height - p.y) * 0x7FFF / (fs.height - 1)), \ + 0, buttons); \ + } \ [NSApp sendEvent:event]; \ }@@ -65,6 +80,7 @@ int qemu_main(int argc, char **argv); // main defined in qemu/vl.c NSWindow *normalWindow; id cocoaView; static DisplayChangeListener *dcl; +static int last_vm_running; int gArgc; char **gArgv;@@ -83,7 +99,7 @@ int keymap[] = 45, // 7 0x07 0x2d X QZ_x 46, // 8 0x08 0x2e C QZ_c 47, // 9 0x09 0x2f V QZ_v - 0, // 10 0x0A Undefined + 0, // 10 0x0A Undefined (paragraph) 48, // 11 0x0B 0x30 B QZ_b 16, // 12 0x0C 0x10 Q QZ_q 17, // 13 0x0D 0x11 W QZ_w@@ -127,8 +143,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 0xdc e0,5c R GUI QZ_RMETA + 219,// 55 0xdb e0,5b L GUI 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@@ -136,9 +152,9 @@ int keymap[] = 54, // 60 0x3C 0x36 R SHFT QZ_RSHIFT 184,// 61 0x3D 0xb8 E0,38 R ALT QZ_RALT 157,// 62 0x3E 0x9d E0,1D R CTRL QZ_RCTRL - 0, // 63 0x3F Undefined - 0, // 64 0x40 Undefined - 0, // 65 0x41 Undefined + 0, // 63 0x3F Undefined (fn) + 0, // 64 0x40 Undefined (f17) + 83, // 65 0x53 0x53 KP . 0, // 66 0x42 Undefined 55, // 67 0x43 0x37 KP * QZ_KP_MULTIPLY 0, // 68 0x44 Undefined@@ -152,9 +168,9 @@ int keymap[] = 152,// 76 0x4C 0x9c E0,1C KP EN QZ_KP_ENTER 0, // 77 0x4D undefined 74, // 78 0x4E 0x4a KP - QZ_KP_MINUS - 0, // 79 0x4F Undefined - 0, // 80 0x50 Undefined - 0, // 81 0x51 QZ_KP_EQUALS + 0, // 79 0x4F Undefined (f18) + 0, // 80 0x50 Undefined (f19) + 0, // 81 0x51 (kp =) QZ_KP_EQUALS 82, // 82 0x52 0x52 KP 0 QZ_KP0 79, // 83 0x53 0x4f KP 1 QZ_KP1 80, // 84 0x54 0x50 KP 2 QZ_KP2@@ -178,15 +194,15 @@ int keymap[] = 0, // 102 0x66 Undefined 87, // 103 0x67 0x57 F11 QZ_F11 0, // 104 0x68 Undefined - 183,// 105 0x69 0xb7 QZ_PRINT + 183,// 105 0x69 0xb7 (f13) QZ_PRINT 0, // 106 0x6A Undefined - 70, // 107 0x6B 0x46 SCROLL QZ_SCROLLOCK + 70, // 107 0x6B 0x46 SCROLL(f14) QZ_SCROLLOCK 0, // 108 0x6C Undefined 68, // 109 0x6D 0x44 F10 QZ_F10 0, // 110 0x6E Undefined 88, // 111 0x6F 0x58 F12 QZ_F12 0, // 112 0x70 Undefined - 110,// 113 0x71 0x0 QZ_PAUSE + 110,// 113 0x71 0x0 (f15) QZ_PAUSE 210,// 114 0x72 0xd2 E0,52 INSERT QZ_INSERT 199,// 115 0x73 0xc7 E0,47 HOME QZ_HOME 201,// 116 0x74 0xc9 E0,49 PG UP QZ_PAGEUP@@ -204,12 +220,9 @@ int keymap[] = /* Aditional 104 Key XP-Keyboard Scancodes from http://www.computer-engineering.org/ps2keyboard/scancodes1.html */ /* - 219 // 0xdb e0,5b L GUI - 220 // 0xdc e0,5c R GUI 221 // 0xdd e0,5d APPS // E0,2A,E0,37 PRNT SCRN // E1,1D,45,E1,9D,C5 PAUSE - 83 // 0x53 0x53 KP . // ACPI Scan Codes 222 // 0xde E0, 5E Power 223 // 0xdf E0, 5F Sleep@@ -259,23 +272,29 @@ static int cocoa_keycode_to_qemu(int keycode) NSWindow *fullScreenWindow; float cx,cy,cw,ch,cdx,cdy; CGDataProviderRef dataProviderRef; + void *dataRawPtr; + int mouseX, mouseY; int modifiers_state[256]; BOOL isMouseGrabed; BOOL isFullscreen; BOOL isAbsoluteEnabled; BOOL isTabletEnabled; + BOOL isShuttingDownGuest; } - (void) resizeContentToWidth:(int)w height:(int)h displayState:(DisplayState *)ds; - (void) grabMouse; - (void) ungrabMouse; - (void) toggleFullScreen:(id)sender; -- (void) handleEvent:(NSEvent *)event; +- (void) qemuHandleEvent:(NSEvent *)event; - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; +- (void) setShuttingDownGuest; - (BOOL) isMouseGrabed; - (BOOL) isAbsoluteEnabled; - (float) cdx; - (float) cdy; - (QEMUScreen) gscreen; +- (void) updateCaption; +- (void) checkAndDisplayAltCursor;@end
@implementation QemuCocoaView
cocoa.m +121
-44@@ -310,6 +329,34 @@ static int cocoa_keycode_to_qemu(int keycode) return YES; } +- (void) checkAndDisplayAltCursor +{ + if (multitouch_enabled && !isMouseGrabed && !cursor_hide && + dataRawPtr && modifiers_state[56]) { + unsigned char *p = (unsigned char *)dataRawPtr; + int altX = screen.width - mouseX; + int altY = mouseY; + int x, y; + int bytesperpixel = screen.bitsPerPixel / 8; + p += (altY * screen.width) * bytesperpixel; + for (y = 0; y < 8; y++) { + if (y + altY > 0 && y + altY < screen.height) { + unsigned char *q = p + altX * bytesperpixel; + for (x = 0; x < 8; x++) { + if (x + altX > 0 && x + altX < screen.width) { + int i; + for (i = 0; i < bytesperpixel; i++) { + q[i] ^= 0xff; + } + } + q += bytesperpixel; + } + } + p += screen.width * bytesperpixel; + } + } +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");@@ -321,6 +368,7 @@ static int cocoa_keycode_to_qemu(int keycode) // draw screen bitmap directly to Core Graphics context if (dataProviderRef) { + [self checkAndDisplayAltCursor]; CGImageRef imageRef = CGImageCreate( screen.width, //width screen.height, //height@@ -360,10 +408,10 @@ static int cocoa_keycode_to_qemu(int keycode) [self getRectsBeingDrawn:&rectList count:&rectCount]; for (i = 0; i < rectCount; i++) { - clipRect.origin.x = rectList[i].origin.x / cdx; - clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy; - clipRect.size.width = rectList[i].size.width / cdx; - clipRect.size.height = rectList[i].size.height / cdy; + clipRect.origin.x = floorf(rectList[i].origin.x / cdx); + clipRect.origin.y = floorf((float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy); + clipRect.size.width = ceilf(rectList[i].size.width / cdx); + clipRect.size.height = ceilf(rectList[i].size.height / cdy); clipImageRef = CGImageCreateWithImageInRect( imageRef, clipRect@@ -410,6 +458,7 @@ static int cocoa_keycode_to_qemu(int keycode) screen.bitsPerPixel = ds_get_bits_per_pixel(ds); screen.bitsPerComponent = ds_get_bytes_per_pixel(ds) * 2; + dataRawPtr = is_graphic_console() ? ds_get_data(ds) : 0; dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), w * 4 * h, NULL); // update windows@@ -417,10 +466,9 @@ static int cocoa_keycode_to_qemu(int keycode) [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:NO animate:NO]; } else { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; } + [self updateCaption]; screen.width = w; screen.height = h; [normalWindow center];@@ -434,7 +482,7 @@ static int cocoa_keycode_to_qemu(int keycode) if (isFullscreen) { // switch from fullscreen to desktop isFullscreen = FALSE; - [self ungrabMouse]; + if (isMouseGrabed) [self ungrabMouse]; [self setContentDimensions]; // test if host supports "exitFullScreenModeWithOptions" at compile time #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)@@ -444,29 +492,33 @@ static int cocoa_keycode_to_qemu(int keycode) #endif [fullScreenWindow close]; [normalWindow setContentView: self]; - [normalWindow makeKeyAndOrderFront: self]; [NSMenu setMenuBarVisible:YES]; #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) } #endif + [normalWindow makeKeyAndOrderFront:self]; } else { // switch from desktop to fullscreen isFullscreen = TRUE; - [self grabMouse]; + if (cursor_allow_grab) [self grabMouse]; [self setContentDimensions]; + [normalWindow orderOut:self]; // test if host supports "enterFullScreenMode:withOptions" at compile time #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if ([NSView respondsToSelector:@selector(enterFullScreenMode:withOptions:)]) { // test if "enterFullScreenMode:withOptions" is supported on host at runtime - [self enterFullScreenMode:[NSScreen mainScreen] withOptions:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, - [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], kCGDisplayModeIsStretched, nil], NSFullScreenModeSetting, - nil]]; + [self enterFullScreenMode:[NSScreen mainScreen] + withOptions:[NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kCGDisplayModeIsStretched, + nil], NSFullScreenModeSetting, + nil]]; } else { #endif [NSMenu setMenuBarVisible:NO]; fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO]; + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; [fullScreenWindow setHasShadow:NO]; [fullScreenWindow setContentView:self]; [fullScreenWindow makeKeyAndOrderFront:self];@@ -476,7 +528,7 @@ static int cocoa_keycode_to_qemu(int keycode) } } -- (void) handleEvent:(NSEvent *)event +- (void) qemuHandleEvent:(NSEvent *)event { COCOA_DEBUG("QemuCocoaView: handleEvent\n");@@ -505,8 +557,13 @@ static int cocoa_keycode_to_qemu(int keycode) } // release Mouse grab when pressing ctrl+alt - if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { - [self ungrabMouse]; + if (!isFullscreen) { + if ((ctrl_grab && [event keyCode] == 0x3e) + || ((([event modifierFlags] & NSControlKeyMask) && + ([event modifierFlags] & NSAlternateKeyMask)) + && (!alt_grab || ([event modifierFlags] & NSShiftKeyMask)))) { + [self ungrabMouse]; + } } break; case NSKeyDown:@@ -581,15 +638,17 @@ static int cocoa_keycode_to_qemu(int keycode) } break; case NSMouseMoved: + mouseX = p.x; + mouseY = p.y; if (isAbsoluteEnabled) { if (p.x < 0 || p.x > screen.width || p.y < 0 || p.y > screen.height || ![[self window] isKeyWindow]) { if (isTabletEnabled) { // if we leave the window, deactivate the tablet - [NSCursor unhide]; + if (cursor_hide) [NSCursor unhide]; isTabletEnabled = FALSE; } } else { if (!isTabletEnabled) { // if we enter the window, activate the tablet - [NSCursor hide]; + if (cursor_hide) [NSCursor hide]; isTabletEnabled = TRUE; } }@@ -602,6 +661,9 @@ static int cocoa_keycode_to_qemu(int keycode) } else { buttons |= MOUSE_EVENT_LBUTTON; } + if ([event modifierFlags] & NSAlternateKeyMask) { + buttons |= MOUSE_EVENT_MBUTTON << 1; + } COCOA_MOUSE_EVENT break; case NSRightMouseDown:@@ -613,11 +675,16 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_MOUSE_EVENT break; case NSLeftMouseDragged: + mouseX = p.x; + mouseY = p.y; if ([event modifierFlags] & NSCommandKeyMask) { buttons |= MOUSE_EVENT_RBUTTON; } else { buttons |= MOUSE_EVENT_LBUTTON; } + if ([event modifierFlags] & NSAlternateKeyMask) { + buttons |= MOUSE_EVENT_MBUTTON << 1; + } COCOA_MOUSE_EVENT break; case NSRightMouseDragged:@@ -633,7 +700,7 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_MOUSE_EVENT } else if (!isMouseGrabed) { if (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.height) { - [self grabMouse]; + if (cursor_allow_grab) [self grabMouse]; } else { [NSApp sendEvent:event]; }@@ -654,6 +721,25 @@ static int cocoa_keycode_to_qemu(int keycode) [NSApp sendEvent:event]; } break; + case NSAppKitDefined: + switch ([event subtype]) { + case NSApplicationActivatedEventType: + if (dcl) { + dcl->gui_timer_interval = 0; + dcl->idle = 0; + } + break; + case NSApplicationDeactivatedEventType: + if (dcl) { + dcl->gui_timer_interval = 500; + dcl->idle = 1; + } + break; + default: + break; + } + [NSApp sendEvent:event]; + break; default: [NSApp sendEvent:event]; }@@ -662,34 +748,48 @@ static int cocoa_keycode_to_qemu(int keycode) - (void) grabMouse { COCOA_DEBUG("QemuCocoaView: grabMouse\n"); - - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt to release Mouse)", qemu_name]]; - else - [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"]; - } - [NSCursor hide]; + if (cursor_hide) [NSCursor hide]; CGAssociateMouseAndMouseCursorPosition(FALSE); isMouseGrabed = TRUE; // while isMouseGrabed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] + [self updateCaption]; } - (void) ungrabMouse { COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); - if (!isFullscreen) { - if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - else - [normalWindow setTitle:@"QEMU"]; - } - [NSCursor unhide]; + if (cursor_hide) [NSCursor unhide]; CGAssociateMouseAndMouseCursorPosition(TRUE); isMouseGrabed = FALSE; + [self updateCaption]; +} + +- (void) updateCaption +{ + NSMutableString *caption = [NSMutableString stringWithCapacity:10]; + [caption appendFormat:@"QEMU"]; + if (isShuttingDownGuest) { + [caption appendString:@" [Shutting down]"]; + } + if (qemu_name) { + [caption appendFormat:@" (%s)", qemu_name]; + } + if (!vm_running) { + [caption appendString:@" [Stopped]"]; + } else if (isMouseGrabed) { + if (ctrl_grab) { + [caption appendString:@" - Press Right-Ctrl to release mouse"]; + } else if (alt_grab) { + [caption appendString:@" - Press Ctrl-Alt-Shift to release mouse"]; + } else { + [caption appendString:@" - Press Ctrl-Alt to release mouse"]; + } + } + [normalWindow setTitle:caption]; } - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled {isAbsoluteEnabled = tIsAbsoluteEnabled;} +- (void) setShuttingDownGuest { isShuttingDownGuest = YES; [self updateCaption]; } - (BOOL) isMouseGrabed {return isMouseGrabed;} - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;} - (float) cdx {return cdx;}@@ -704,14 +804,16 @@ static int cocoa_keycode_to_qemu(int keycode) QemuCocoaAppController ------------------------------------------------------ */ +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) +@interface QemuCocoaAppController : NSObject <NSWindowDelegate> +#else@interface QemuCocoaAppController : NSObject
+#endif
{
}
- (void)startEmulationWithArgc:(int)argc argv:(char**)argv;
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void)toggleFullScreen:(id)sender;
-- (void)showQEMUDoc:(id)sender;
-- (void)showQEMUTec:(id)sender;
@end@implementation QemuCocoaAppController
cocoa.m +41
-13@@ -743,7 +845,8 @@ static int cocoa_keycode_to_qemu(int keycode) [normalWindow useOptimizedDrawing:YES]; [normalWindow makeKeyAndOrderFront:self]; [normalWindow center]; - + [normalWindow setDelegate:self]; + [cocoaView updateCaption]; } return self; }@@ -781,7 +884,6 @@ static int cocoa_keycode_to_qemu(int keycode) COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n"); qemu_system_shutdown_request(); - exit(0); } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication@@ -819,6 +921,7 @@ static int cocoa_keycode_to_qemu(int keycode) [self startEmulationWithArgc:3 argv:(char**)argv]; } } + - (void)toggleFullScreen:(id)sender { COCOA_DEBUG("QemuCocoaAppController: toggleFullScreen\n");@@ -826,41 +929,57 @@ static int cocoa_keycode_to_qemu(int keycode) [cocoaView toggleFullScreen:sender]; } -- (void)showQEMUDoc:(id)sender +- (BOOL)windowShouldClose:(id)sender { - COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n"); - - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-doc.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; + if (!no_quit) { + if (qemu_run_display_close_handler()) { + return YES; + } + [cocoaView setShuttingDownGuest]; + } + return NO; } -- (void)showQEMUTec:(id)sender +- (void)confirmQuit:(id)sender { - COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n"); + NSAlert *alert = [NSAlert alertWithMessageText:@"Are you sure you want to quit QEMU?" + defaultButton:@"No" + alternateButton:@"Yes" + otherButton:@"Shutdown" + informativeTextWithFormat:@"If you quit QEMU without shutting down the emulated machine properly you risk losing data and possibly corrupting the virtual machine contents."]; + [alert setAlertStyle:NSCriticalAlertStyle]; + switch ([alert runModal]) { + case NSAlertDefaultReturn: + /* do nothing */ + break; + case NSAlertAlternateReturn: + [NSApp terminate:sender]; + break; + case NSAlertOtherReturn: + if (qemu_run_display_close_handler()) { + qemu_system_shutdown_request(); + } else { + [cocoaView setShuttingDownGuest]; + } + break; + default: + break; + } +} - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; +- (void)aboutQEMU:(id)sender +{ + [NSApp orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys: + @ QEMU_VERSION QEMU_PKGVERSION, @"ApplicationVersion", + nil]]; }@end
cocoa.m +1
-3- -// Dock Connection -typedef struct CPSProcessSerNum +int main (int argc, const char * argv[]){
cocoa.m +17
-26- UInt32 lo; - UInt32 hi; -} CPSProcessSerNum; - -extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); - -int main (int argc, const char * argv[]) { - gArgc = argc; gArgv = (char **)argv; - CPSProcessSerNum PSN; int i; /* In case we don't need to display a window, let's not do that */@@ -875,10 +994,11 @@ int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; - if (!CPSGetCurrentProcess(&PSN)) - if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) - if (!CPSSetFrontProcess(&PSN)) - [NSApplication sharedApplication]; + ProcessSerialNumber PSN; + if (!GetCurrentProcess(&PSN) && + !TransformProcessType(&PSN, kProcessTransformToForegroundApplication) && + !SetFrontProcess(&PSN)) + [NSApplication sharedApplication]; // Add menus NSMenu *menu;@@ -888,14 +1008,14 @@ int main (int argc, const char * argv[]) { // Application menu menu = [[NSMenu alloc] initWithTitle:@""]; - [menu addItemWithTitle:@"About QEMU" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; // About QEMU + [menu addItemWithTitle:@"About QEMU" action:@selector(aboutQEMU:) keyEquivalent:@""]; // About QEMU [menu addItem:[NSMenuItem separatorItem]]; //Separator [menu addItemWithTitle:@"Hide QEMU" action:@selector(hide:) keyEquivalent:@"h"]; //Hide QEMU menuItem = (NSMenuItem *)[menu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; // Hide Others [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; [menu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; // Show All [menu addItem:[NSMenuItem separatorItem]]; //Separator - [menu addItemWithTitle:@"Quit QEMU" action:@selector(terminate:) keyEquivalent:@"q"]; + [menu addItemWithTitle:@"Quit QEMU" action:@selector(confirmQuit:) keyEquivalent:@"q"]; menuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" action:nil keyEquivalent:@""]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem];@@ -916,14 +1036,6 @@ int main (int argc, const char * argv[]) { [[NSApp mainMenu] addItem:menuItem]; [NSApp setWindowsMenu:menu]; - // Help menu - menu = [[NSMenu alloc] initWithTitle:@"Help"]; - [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Documentation" action:@selector(showQEMUDoc:) keyEquivalent:@"?"] autorelease]]; // QEMU Help - [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Technology" action:@selector(showQEMUTec:) keyEquivalent:@""] autorelease]]; // QEMU Help - menuItem = [[[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""] autorelease]; - [menuItem setSubmenu:menu]; - [[NSApp mainMenu] addItem:menuItem]; - // Create an Application controller QemuCocoaAppController *appController = [[QemuCocoaAppController alloc] init]; [NSApp setDelegate:appController];@@ -968,6 +1080,11 @@ static void cocoa_refresh(DisplayState *ds) { COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); + if (last_vm_running != vm_running) { + last_vm_running = vm_running; + [cocoaView updateCaption]; + } + if (kbd_mouse_is_absolute()) { if (![cocoaView isAbsoluteEnabled]) { if ([cocoaView isMouseGrabed]) {@@ -984,7 +1101,7 @@ static void cocoa_refresh(DisplayState *ds) event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast inMode: NSDefaultRunLoopMode dequeue:YES]; if (event != nil) { - [cocoaView handleEvent:event]; + [cocoaView qemuHandleEvent:event]; } } while(event != nil); vga_hw_update();@@ -1012,3 +1129,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen) // register cleanup function atexit(cocoa_cleanup); } + +#ifdef CONFIG_GLHW +#include "hw/gl/opengl_host_cocoa.m" +#endifSignature · 1 line
1.6.5
PATCH 13/48 multitouch and window close handler
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- console.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
console.c +18 -0
@@ -32,6 +32,24 @@#define QEMU_RGBA (r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))#define QEMU_RGB (r, g, b) QEMU_RGBA(r, g, b, 0xff) +int multitouch_enabled =0 ; +static QEMUDisplayCloseCallback *qemu_display_close_callback =NULL ; +static void *qemu_display_close_callback_opaque =NULL ; + +void qemu_set_display_close_handler (QEMUDisplayCloseCallback *cb,void *opaque) +{ + qemu_display_close_callback = cb; + qemu_display_close_callback_opaque = opaque; +} + +int qemu_run_display_close_handler (void ) +{ +if (qemu_display_close_callback !=NULL ) { +return qemu_display_close_callback (qemu_display_close_callback_opaque); + } +return 1 ; +} + typedef struct TextAttributes { uint8_t fgcol:4; uint8_t bgcol:4;
Signature · 1 line
1.6.5
PATCH 14/48 multikeyboard support merge
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
On some systems (such as n900), multiple physical devices can create keyboard events (gpio, lis302dl, twl4030, ..). Add hooks to make it possible to recieve keyboard input from multiple devices.
merge our version with upstream multikb support
--- console.h | 8 ++++---- input.c | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-)
console.h +4 -4
@@ -39,12 +39,13 @@ typedef struct QEMUPutMouseEntry {/* used internally by qemu for handling mice */ QTAILQ_ENTRY (QEMUPutMouseEntry) node; } QEMUPutMouseEntry; +typedef struct QEMUPutKBDEntry { -QEMUPutKBDEvent *qemu_put_kbd_event; -void *qemu_put_kbd_event_opaque; +QEMUPutKBDEvent *put_kbd_event; +void *opaque;/* used internally by qemu for handling keyboards */ -struct QEMUPutKBDEntry *next; +QTAILQ_ENTRY (QEMUPutKBDEntry) next; }QEMUPutKBDEntry ; typedef struct QEMUPutLEDEntry {
@@ -54,7 +55,6 @@ typedef struct QEMUPutLEDEntry { } QEMUPutLEDEntry;void qemu_add_kbd_event_handler (QEMUPutKBDEvent *func,void *opaque); -void qemu_remove_kbd_event_handler (QEMUPutKBDEvent *entry);QEMUPutMouseEntry *qemu_add_mouse_event_handler (QEMUPutMouseEvent *func,void *opaque,int absolute,const char *name);
input.c +15 -6
@@ -28,8 +28,8 @@#include "console.h" #include "qjson.h" -static QEMUPutKBDEvent *qemu_put_kbd_event; -static void *qemu_put_kbd_event_opaque; +static QTAILQ_HEAD(, QEMUPutKBDEntry) kbd_handlers = +QTAILQ_HEAD_INITIALIZER (kbd_handlers); static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers); static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =QTAILQ_HEAD_INITIALIZER (mouse_handlers);
@@ -38,8 +38,16 @@ static NotifierList mouse_mode_notifiers =void qemu_add_kbd_event_handler (QEMUPutKBDEvent *func,void *opaque) { - qemu_put_kbd_event_opaque = opaque; - qemu_put_kbd_event = func; +QEMUPutKBDEntry *s; + +if (func !=NULL ) { + s =qemu_mallocz (sizeof (QEMUPutKBDEntry)); + + s->put_kbd_event = func; + s->opaque = opaque; + +QTAILQ_INSERT_TAIL (&kbd_handlers, s, next); + } }static void check_mode_change (void )
@@ -123,8 +131,9 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)void kbd_put_keycode (int keycode) { -if (qemu_put_kbd_event) { -qemu_put_kbd_event (qemu_put_kbd_event_opaque, keycode); +QEMUPutKBDEntry *cursor; + QTAILQ_FOREACH(cursor, &kbd_handlers, next) { + cursor->put_kbd_event (cursor->opaque, keycode); } }
Signature · 1 line
1.6.5
PATCH 15/48 fix function signature of qemu_chr_open_pty on !linux
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- qemu-char.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-char.c +1 -1
@@ -1218,7 +1218,7 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) return chr; }#else /* ! __linux__ && ! __sun__ */ -static CharDriverState *qemu_chr_open_pty (void ) +static CharDriverState *qemu_chr_open_pty (QemuOpts *opts) {return NULL ; }
Signature · 1 line
1.6.5
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH 15/48] fix function signature of qemu_chr_open_pty on !linux
Quoted 4 lines · Riku Voipio
From: Riku Voipio <[email protected]>
Signed-off-by Riku Voipio <[email protected]>Signed-off-by Juha Riihimäki <[email protected]>
Thanks, applied.
Quoted 23 lines
--- qemu-char.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)qemu-char.c +1
-1@@ -1218,7 +1218,7 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) return chr; }#else /* ! __linux__ && ! __sun__ */ -static CharDriverState *qemu_chr_open_pty (void ) +static CharDriverState *qemu_chr_open_pty (QemuOpts *opts) {return NULL ; }Signature · 1 line
1.6.5
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH 16/48 sdl: multitouch and window close suppport
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
- show shutting down status in window caption
- add display close handler support
- add support for disabling input grabbing
- add ability to disable window grab:
currently if the qemu window is inactive and you click inside the qemu window the input will be grabbed. with touchscreen devices this might not be very feasible as there is no visible guest cursor so this patch adds a global variable that can be used to control the grabbing behavior. default behavior is not modified but for n8x0, n900 and n00 devices the grabbing is disabled. note that with sdl rendering you can still toggle grabbing by pressing ctrl+alt when the qemu window is active.
--- sdl.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 54 insertions(+), 12 deletions(-)
sdl.c +54 -12
@@ -57,6 +57,8 @@ static SDL_Cursor *guest_sprite = NULL;static uint8_t allocator;static SDL_PixelFormat host_format;static int scaling_active =0 ; +static int mouseX =0 , mouseY =0 ; +static int shutting_down_guest =0 ;static Notifier mouse_mode_notifier;static void sdl_update (DisplayState *ds,int x,int y,int w,int h)
@@ -78,6 +80,30 @@ static void sdl_update(DisplayState *ds, int x, int y, int w, int h) } } } +if (multitouch_enabled && !cursor_hide && !gui_grab && + modifiers_state[56 ] && real_screen && real_screen->pixels) { +unsigned char *p = (unsigned char *)real_screen->pixels; +int altX = real_screen->w - mouseX; +int altY = real_screen->h - mouseY; +int x, y; +int bytesperpixel = real_screen->format->BytesPerPixel; + p += altY * real_screen->pitch; +for (y =0 ; y <8 ; y++) { +if (y + altY >0 && y + altY < real_screen->h) { +unsigned char *q = p + altX * bytesperpixel; +for (x =0 ; x <8 ; x++) { +if (x + altX >0 && x + altX < real_screen->w) { +int i; +for (i =0 ; i < bytesperpixel; i++) { + q[i] ^=0xff ; + } + } + q += bytesperpixel; + } + } + p += real_screen->pitch; + } + }SDL_UpdateRect (real_screen, rec.x, rec.y, rec.w, rec.h); }
@@ -413,15 +439,19 @@ static void sdl_update_caption(void)char icon_title[1024 ];const char *status ="" ; -if (!vm_running) - status =" [Stopped]" ; -else if (gui_grab) { -if (alt_grab) - status =" - Press Ctrl-Alt-Shift to exit mouse grab" ; -else if (ctrl_grab) - status =" - Press Right-Ctrl to exit mouse grab" ; -else - status =" - Press Ctrl-Alt to exit mouse grab" ; +if (shutting_down_guest) { + status =" [Shutting down]" ; + }else { +if (!vm_running) + status =" [Stopped]" ; +else if (gui_grab) { +if (alt_grab) + status =" - Press Ctrl-Alt-Shift to exit mouse grab" ; +else if (ctrl_grab) + status =" - Press Right-Ctrl to exit mouse grab" ; +else + status =" - Press Ctrl-Alt to exit mouse grab" ; + } }if (qemu_name) {
@@ -513,6 +543,9 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state buttons |=MOUSE_EVENT_RBUTTON ;if (state &SDL_BUTTON (SDL_BUTTON_MIDDLE )) buttons |=MOUSE_EVENT_MBUTTON ; +if (modifiers_state[56 ] && + (buttons & (MOUSE_EVENT_LBUTTON |MOUSE_EVENT_RBUTTON ))) + buttons |=MOUSE_EVENT_MBUTTON <<1 ;if (kbd_mouse_is_absolute ()) { dx = x *0x7FFF / (width -1 );
@@ -526,6 +559,9 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state dy = y; } + mouseX = x; + mouseY = y; +kbd_mouse_event (dx, dy, dz, buttons); }
@@ -678,8 +714,14 @@ static void sdl_refresh(DisplayState *ds)sdl_process_key (&ev->key);break ;case SDL_QUIT : -if (!no_quit) -qemu_system_shutdown_request (); +if (!no_quit) { +if (qemu_run_display_close_handler ()) { +qemu_system_shutdown_request (); + }else { + shutting_down_guest =1 ; +sdl_update_caption (); + } + }break ;case SDL_MOUSEMOTION : if (gui_grab || kbd_mouse_is_absolute() ||
@@ -696,7 +738,7 @@ static void sdl_refresh(DisplayState *ds)if (ev->type ==SDL_MOUSEBUTTONDOWN && (bev->button ==SDL_BUTTON_LEFT )) {/* start grabbing all events */ -sdl_grab_start (); +if (cursor_allow_grab)sdl_grab_start (); } }else {int dz;
Signature · 1 line
1.6.5
PATCH 17/48 add multi-sd support
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
N900 and other devices can have more than one sd/mmc card, and thus the -sd command line option needs to be read multiple times.
--- vl.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
vl.c +4 -3
@@ -752,7 +752,7 @@ static int bt_parse(const char *opt)#define FD_ALIAS "index=%d,if=floppy"#define PFLASH_ALIAS "if=pflash"#define MTD_ALIAS "if=mtd" -#define SD_ALIAS "index=0,if=sd" +#define SD_ALIAS "index=%d,if=sd"QemuOpts *drive_add (const char *file,const char *fmt, ...) {
@@ -3738,6 +3738,7 @@ int main(int argc, char **argv, char **envp)CPUState *env;int show_vnc_port =0 ;int defconfig =1 ; +int sd_device_index =0 ;error_set_progname (argv[0 ]);
@@ -3920,7 +3921,7 @@ int main(int argc, char **argv, char **envp)drive_add (optarg,MTD_ALIAS );break ;case QEMU_OPTION_sd: -drive_add (optarg,SD_ALIAS ); +drive_add (optarg,SD_ALIAS , sd_device_index++);break ;case QEMU_OPTION_pflash:drive_add (optarg,PFLASH_ALIAS );
@@ -4762,7 +4763,7 @@ int main(int argc, char **argv, char **envp)if (default_sdcard) {/* we always create one sd slot, even if no card is in it */ -drive_add (NULL ,SD_ALIAS ); +drive_add (NULL ,SD_ALIAS ,0 ); }/* open the virtual block devices */
Signature · 1 line
1.6.5
PATCH 18/48 make cursor grab optional
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- sysemu.h | 1 + vl.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
sysemu.h +1 -0
@@ -128,6 +128,7 @@ extern int usb_enabled;extern int smp_cpus;extern int max_cpus;extern int cursor_hide; +extern int cursor_allow_grab;extern int graphic_rotate;extern int no_quit;extern int semihosting_enabled;
vl.c +1 -0
@@ -224,6 +224,7 @@ int fd_bootchk = 1;int no_reboot =0 ;int no_shutdown =0 ;int cursor_hide =1 ; +int cursor_allow_grab =1 ;int graphic_rotate =0 ;uint8_t irq0override =1 ;#ifndef _WIN32
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 18/48] make cursor grab optional
Quoted 26 lines · Riku Voipio
From: Riku Voipio <[email protected]>
Signed-off-by Riku Voipio <[email protected]>--- sysemu.h | 1 + vl.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)sysemu.h +1
-0@@ -128,6 +128,7 @@ extern int usb_enabled;extern int smp_cpus;extern int max_cpus;extern int cursor_hide; +extern int cursor_allow_grab;extern int graphic_rotate;extern int no_quit;extern int semihosting_enabled;vl.c +0
-0
vl.c int fd_bootchk = 1; · line 230
Quoted 7 lines
vl.c +1
-0@@ -224,6 +224,7 @@ int fd_bootchk = 1;int no_reboot =0 ;int no_shutdown =0 ;int cursor_hide =1 ; +int cursor_allow_grab =1 ;int graphic_rotate =0 ;uint8_t irq0override =1 ;#ifndef _WIN32
It looks like this patch is not complete. Adding a new variable won't add the feature automatically ;-)
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 18/48] make cursor grab optional
In reply to Riku VoipioQuoted 34 lines · Riku Voipio
From: Riku Voipio <[email protected]>
Signed-off-by Riku Voipio <[email protected]>---
sysemu.h | 1 +
vl.c | 1 +2 files changed, 2 insertions(+), 0 deletions(-)sysemu.h +1
-0@@ -128,6 +128,7 @@ extern int usb_enabled; extern int smp_cpus; extern int max_cpus; extern int cursor_hide; +extern int cursor_allow_grab; extern int graphic_rotate; extern int no_quit; extern int semihosting_enabled;vl.c +1
-1@@ -224,6 +224,7 @@ int fd_bootchk = 1; int no_reboot = 0; int no_shutdown = 0; int cursor_hide = 1; +int cursor_allow_grab =1 ; int graphic_rotate = 0; uint8_t irq0override = 1; #ifndef _WIN32 --
Quoted 5 lines
1.6.5
The n900 uses a touchscreen, right? For absolute pointer devices there's no need to do the grab so unless something else is broken, you shouldn't need to disallow it from command line.
Cheers
PATCH 19/48 usb-ohci: add omap init support
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- hw/usb-ohci.c | 12 ++++++++++++ hw/usb-ohci.h | 2 ++ 2 files changed, 14 insertions(+), 0 deletions(-)
hw/usb-ohci.c +12 -0
@@ -61,6 +61,7 @@ typedef struct OHCIPort {enum ohci_type {OHCI_TYPE_PCI ,OHCI_TYPE_PXA , +OHCI_TYPE_OMAP ,OHCI_TYPE_SM501 , };
@@ -1782,6 +1783,17 @@ void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,cpu_register_physical_memory (base,0x1000 , ohci->mem); } +void usb_ohci_init_omap (target_phys_addr_t base,uint32_t region_size, +int num_ports,qemu_irq irq,int be) +{ +OHCIState *ohci = (OHCIState *)qemu_mallocz (sizeof (OHCIState)); + +usb_ohci_init (ohci,NULL /* FIXME */ , num_ports,-1 , irq, +OHCI_TYPE_OMAP ,"OHCI USB" ,0 , be); + +cpu_register_physical_memory (base,0x1000 , ohci->mem); +} +void usb_ohci_init_sm501 (uint32_t mmio_base,uint32_t localmem_base,int num_ports,int devfn,qemu_irq irq,int be) {
hw/usb-ohci.h +2 -0
@@ -6,5 +6,7 @@void usb_ohci_init_pci (struct PCIBus *bus,int devfn,int be);void usb_ohci_init_pxa (target_phys_addr_t base,int num_ports,int devfn,qemu_irq irq,int be); +void usb_ohci_init_omap (target_phys_addr_t base,uint32_t region_size, +int num_ports,qemu_irq irq,int be);#endif
Signature · 1 line
1.6.5
PATCH 20/48 add reset support for musb
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- hw/usb-musb.c | 29 +++++++++++++++++++++++------ hw/usb.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-)
hw/usb-musb.c +23 -6
@@ -8,7 +8,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -307,7 +307,9 @@ struct MUSBState {uint16_t rx_intr;uint16_t rx_mask; +#ifdef SETUPLEN_HACK int setup_len; +#endif int session;uint8_t buf[0x8000 ];
@@ -315,15 +317,16 @@ struct MUSBState {/* Duplicating the world since 2008!... probably we should have 32 * logical, single endpoints instead. */ MUSBEndPoint ep[16 ]; -} *musb_init(qemu_irq *irqs) +}; + +void musb_reset (MUSBState *s) { -MUSBState *s =qemu_mallocz (sizeof (*s));int i; - s->irqs = irqs; - s->faddr =0x00 ; + s->devctl =0 ; s->power =MGC_M_POWER_HSENAB ; + s->tx_intr =0x0000 ; s->rx_intr =0x0000 ; s->tx_mask =0xffff ;
@@ -332,6 +335,12 @@ struct MUSBState { s->mask =0x06 ; s->idx =0 ; +#ifdef SETUPLEN_HACK + s->setup_len =0 ; +#endif + s->session =0 ; +memset (s->buf,0 ,sizeof (s->buf)); +/* TODO: _DW */ s->ep[0 ].config =MGC_M_CONFIGDATA_SOFTCONE |MGC_M_CONFIGDATA_DYNFIFO ;for (i =0 ; i <16 ; i ++) {
@@ -341,6 +350,14 @@ struct MUSBState { s->ep[i].musb = s; s->ep[i].epnum = i; } +} + +struct MUSBState *musb_init (qemu_irq *irqs) +{ +MUSBState *s =qemu_mallocz (sizeof (*s)); + + s->irqs = irqs; +musb_reset (s);usb_bus_new (&s->bus,NULL /* FIXME */ );usb_register_port (&s->bus, &s->port, s,0 , musb_attach);
@@ -1481,7 +1498,7 @@ static void musb_writew(void *opaque, target_phys_addr_t addr, uint32_t value)musb_write_fifo (s->ep + ep, (value >>8 ) &0xff );musb_write_fifo (s->ep + ep, (value >>16 ) &0xff );musb_write_fifo (s->ep + ep, (value >>24 ) &0xff ); -break ; +break ;default :TRACE ("unknown register 0x%02x" , (int ) addr);break ;
hw/usb.h +1 -0
@@ -284,6 +284,7 @@ enum musb_irq_source_e {typedef struct MUSBState MUSBState ;MUSBState *musb_init (qemu_irq *irqs); +void musb_reset (MUSBState *s);uint32_t musb_core_intr_get (MUSBState *s);void musb_core_intr_clear (MUSBState *s,uint32_t mask);void musb_set_size (MUSBState *s,int epnum,int size,int is_tx);
Signature · 1 line
1.6.5
PATCH 21/48 NAND emulation overhaul
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
- Enhanced existing NAND emulation to support other than 8-bit devices.
- Enhanced existing NAND emulation to support over 1Gb devices.
- Enhanced existing NAND emulation to support cache status bits and read cache commands.
- Fixed existing NAND emulation to correctly handle multiple IO reads after READ STATUS command.
- nand emulation fixes
- more NAND fixing & tidying
--- hw/axis_dev88.c | 2 +- hw/flash.h | 7 +- hw/nand.c | 207 +++++++++++++++++++++++++++++++++++++------------------ hw/spitz.c | 4 +- hw/tc6393xb.c | 3 +- 5 files changed, 148 insertions(+), 75 deletions(-)
hw/axis_dev88.c +1 -1
@@ -292,7 +292,7 @@ void axisdev88_init (ram_addr_t ram_size,/* Attach a NAND flash to CS1. */ - nand_state.nand =nand_init (NAND_MFR_STMICRO ,0x39 ); + nand_state.nand =nand_init (NAND_MFR_STMICRO ,0x39 ,drive_get (IF_MTD ,0 ,0 )); nand_regs =cpu_register_io_memory (nand_read, nand_write, &nand_state);cpu_register_physical_memory (0x10000000 ,0x05000000 , nand_regs);
hw/flash.h +4 -3
@@ -18,13 +18,14 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off,/* nand.c */ typedef struct NANDFlashState NANDFlashState ; -NANDFlashState *nand_init (int manf_id,int chip_id); +NANDFlashState *nand_init (int manf_id,int chip_id,DriveInfo *dinfo);void nand_done (NANDFlashState *s);void nand_setpins (NANDFlashState *s,int cle,int ale,int ce,int wp,int gnd);void nand_getpins (NANDFlashState *s,int *rb); -void nand_setio (NANDFlashState *s,uint8_t value); -uint8_t nand_getio (NANDFlashState *s); +void nand_setio (NANDFlashState *s,uint32_t value); +uint32_t nand_getio (NANDFlashState *s); +uint32_t nand_getbuswidth (NANDFlashState *s);#define NAND_MFR_TOSHIBA 0x98#define NAND_MFR_SAMSUNG 0xec
hw/nand.c +139 -68
420 lines not on this page · raw message
hw/spitz.c +2 -2
@@ -170,9 +170,9 @@ static void sl_flash_register(PXA2xxState *cpu, int size) s = (SLNANDState *)qemu_mallocz (sizeof (SLNANDState)); s->ctl =0 ;if (size ==FLASH_128M ) - s->nand =nand_init (NAND_MFR_SAMSUNG ,0x73 ); + s->nand =nand_init (NAND_MFR_SAMSUNG ,0x73 ,drive_get (IF_MTD ,0 ,0 ));else if (size ==FLASH_1024M ) - s->nand =nand_init (NAND_MFR_SAMSUNG ,0xf1 ); + s->nand =nand_init (NAND_MFR_SAMSUNG ,0xf1 ,drive_get (IF_MTD ,0 ,0 )); iomemtype =cpu_register_io_memory (sl_readfn, sl_writefn, s);
hw/tc6393xb.c +2 -1
@@ -13,6 +13,7 @@#include "flash.h" #include "console.h" #include "pixel_ops.h" +#include "sysemu.h" #define IRQ_TC6393_NAND 0#define IRQ_TC6393_MMC 1
@@ -587,7 +588,7 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq) s->sub_irqs =qemu_allocate_irqs (tc6393xb_sub_irq, s,TC6393XB_NR_IRQS ); - s->flash =nand_init (NAND_MFR_TOSHIBA ,0x76 ); + s->flash =nand_init (NAND_MFR_TOSHIBA ,0x76 ,drive_get (IF_MTD ,0 ,0 )); iomemtype =cpu_register_io_memory (tc6393xb_readfn, tc6393xb_writefn, s);
Signature · 1 line
1.6.5
PATCH 22/48 License update
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
Legal requested us to be open to future.
--- hw/blizzard.c | 2 +- hw/blizzard_template.h | 2 +- hw/cbus.c | 2 +- hw/lm832x.c | 2 +- hw/nseries.c | 7 ++++--- hw/omap2.c | 4 ++-- hw/onenand.c | 4 ++-- hw/soc_dma.c | 2 +- hw/tmp105.c | 2 +- hw/tusb6010.c | 2 +- hw/twl92230.c | 2 +- 11 files changed, 16 insertions(+), 15 deletions(-)
hw/blizzard.c +1 -1
@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/blizzard_template.h +1 -1
@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/cbus.c +1 -1
@@ -9,7 +9,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/lm832x.c +1 -1
@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/nseries.c +4 -3
@@ -1,13 +1,14 @@/* * Nokia N-series internet tablets. * -* Copyright (C) 2007 Nokia Corporation -* Written by Andrzej Zaborowski <[email protected]> +* Copyright (C) 2007-2009 Nokia Corporation +* N800/N810 support written by Andrzej Zaborowski <[email protected]> +* N900 support written by Juha Riihimäki * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/omap2.c +2 -2
@@ -1,13 +1,13 @@/* * TI OMAP processors emulation. * -* Copyright (C) 2007-2008 Nokia Corporation +* Copyright (C) 2007-2009 Nokia Corporation * Written by Andrzej Zaborowski <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/onenand.c +2 -2
@@ -1,13 +1,13 @@/* * OneNAND flash memories emulation. * -* Copyright (C) 2008 Nokia Corporation +* Copyright (C) 2008-2009 Nokia Corporation * Written by Andrzej Zaborowski <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/soc_dma.c +1 -1
@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/tmp105.c +1 -1
@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/tusb6010.c +1 -1
@@ -8,7 +8,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
hw/twl92230.c +1 -1
@@ -8,7 +8,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 22/48] License update
Quoted 7 lines · Riku Voipio
From: Riku Voipio<[email protected]>
Legal requested us to be open to future.
Signed-off-by Riku Voipio<[email protected]>Signed-off-by Juha Riihimäki<[email protected]>
Quoted 14 lines
--- hw/blizzard.c | 2 +- hw/blizzard_template.h | 2 +- hw/cbus.c | 2 +- hw/lm832x.c | 2 +- hw/nseries.c | 7 ++++--- hw/omap2.c | 4 ++-- hw/onenand.c | 4 ++-- hw/soc_dma.c | 2 +- hw/tmp105.c | 2 +- hw/tusb6010.c | 2 +- hw/twl92230.c | 2 +- 11 files changed, 16 insertions(+), 15 deletions(-)
These files have been touched by multiple authors so the license cannot be changed without permission from each author.
git log --format=pretty:"%an <%ae>"
Will give you a quick list for each file.
Regards,
Anthony Liguori
Quoted 167 lines
hw/blizzard.c +1
-1@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/blizzard_template.h +1
-1@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/cbus.c +1
-1@@ -9,7 +9,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/lm832x.c +1
-1@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/nseries.c +4
-3@@ -1,13 +1,14 @@/* * Nokia N-series internet tablets. * -* Copyright (C) 2007 Nokia Corporation -* Written by Andrzej Zaborowski<[email protected]> +* Copyright (C) 2007-2009 Nokia Corporation +* N800/N810 support written by Andrzej Zaborowski<[email protected]> +* N900 support written by Juha Riihimäki * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/omap2.c +2
-2@@ -1,13 +1,13 @@/* * TI OMAP processors emulation. * -* Copyright (C) 2007-2008 Nokia Corporation +* Copyright (C) 2007-2009 Nokia Corporation * Written by Andrzej Zaborowski<[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/onenand.c +2
-2@@ -1,13 +1,13 @@/* * OneNAND flash memories emulation. * -* Copyright (C) 2008 Nokia Corporation +* Copyright (C) 2008-2009 Nokia Corporation * Written by Andrzej Zaborowski<[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/soc_dma.c +1
-1@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/tmp105.c +1
-1@@ -7,7 +7,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/tusb6010.c +1
-1@@ -8,7 +8,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of hw/twl92230.c +1
-1@@ -8,7 +8,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 or -* (at your option) version 3 of the License. +* (at your option) any later version of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
PATCH 23/48 multi-mmc support in init call
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
change sd_init convention to allow multiple entries
--- hw/omap_mmc.c | 4 ++-- hw/pl181.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/sd.h | 4 +++- hw/ssi-sd.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-)
hw/omap_mmc.c +2 -2
@@ -590,7 +590,7 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base,cpu_register_physical_memory (base,0x800 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 );return s; }
@@ -616,7 +616,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,omap_l4_attach (ta,0 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 ); s->cdet =qemu_allocate_irqs (omap_mmc_cover_cb, s,1 )[0 ];sd_set_cb (s->card,NULL , s->cdet);
hw/pl181.c +1 -1
@@ -458,7 +458,7 @@ static int pl181_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq[0 ]);sysbus_init_irq (dev, &s->irq[1 ]); bd =qdev_init_bdrv (&dev->qdev,IF_SD ); - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 );qemu_register_reset (pl181_reset, s);pl181_reset (s);/* ??? Save/restore. */
hw/pxa2xx_mmci.c +1 -1
@@ -532,7 +532,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,cpu_register_physical_memory (base,0x00100000 , iomemtype);/* Instantiate the actual storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 );register_savevm ("pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);
hw/sd.h +3 -1
@@ -67,7 +67,8 @@ typedef struct {typedef struct SDState SDState ; -SDState *sd_init (BlockDriverState *bs,int is_spi); +SDState *sd_init (BlockDriverState *bs,int is_spi,int is_mmc); +void sd_reset (SDState *sd);int sd_do_command (SDState *sd,SDRequest *req,uint8_t *response);void sd_write_data (SDState *sd,uint8_t value);
@@ -75,5 +76,6 @@ uint8_t sd_read_data(SDState *sd);void sd_set_cb (SDState *sd,qemu_irq readonly,qemu_irq insert);int sd_data_ready (SDState *sd);void sd_enable (SDState *sd,int enable); +int sd_is_mmc (SDState *sd);#endif /* __hw_sd_h */
hw/ssi-sd.c +1 -1
@@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; bs =qdev_init_bdrv (&dev->qdev,IF_SD ); - s->sd =sd_init (bs,1 ); + s->sd =sd_init (bs,1 ,0 );register_savevm ("ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 23/48] multi-mmc support in init call
I see neither the change to sd_init implementation nor the implementation of sd_is_mmc.
Best regards,
Filip Navara
Quoted 106 lines · Riku Voipio
From: Juha Riihimäki <[email protected]>
change
sd_initconvention to allow multiple entriesSigned-off-by Riku Voipio <[email protected]>Signed-off-by Juha Riihimäki <[email protected]>--- hw/omap_mmc.c | 4 ++-- hw/pl181.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/sd.h | 4 +++- hw/ssi-sd.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-)hw/omap_mmc.c +1
-1@@ -590,7 +590,7 @@ struct omap_mmc_s *omap_mmc_init(target_phys_addr_t base,cpu_register_physical_memory (base,0x800 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 );return s;}
hw/omap_mmc.c +1
-1@@ -616,7 +616,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,omap_l4_attach (ta,0 , iomemtype);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 ); s->cdet =qemu_allocate_irqs (omap_mmc_cover_cb, s,1 )[0 ];sd_set_cb(s->card, NULL, s->cdet);hw/pl181.c +1
-1@@ -458,7 +458,7 @@ static int pl181_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq[0 ]);sysbus_init_irq (dev, &s->irq[1 ]); bd =qdev_init_bdrv (&dev->qdev,IF_SD ); - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 );qemu_register_reset (pl181_reset, s);pl181_reset (s);/* ??? Save/restore. */ hw/pxa2xx_mmci.c +1
-1@@ -532,7 +532,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,cpu_register_physical_memory (base,0x00100000 , iomemtype);/* Instantiate the actual storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd,0 ,0 ); register_savevm("pxa2xx_mmci", 0, 0,pxa2xx_mmci_save, pxa2xx_mmci_load, s);hw/sd.h +3
-1@@ -67,7 +67,8 @@ typedef struct {typedef struct SDState SDState ; -SDState *sd_init (BlockDriverState *bs,int is_spi); +SDState *sd_init (BlockDriverState *bs,int is_spi,int is_mmc); +void sd_reset (SDState *sd);int sd_do_command (SDState *sd,SDRequest *req,uint8_t *response);void sd_write_data (SDState *sd,uint8_t value);@@ -75,5 +76,6 @@ uint8_t sd_read_data(SDState *sd);void sd_set_cb (SDState *sd,qemu_irq readonly,qemu_irq insert);int sd_data_ready (SDState *sd);void sd_enable (SDState *sd,int enable); +int sd_is_mmc (SDState *sd);#endif /* __hw_sd_h */ hw/ssi-sd.c +1
-2@@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; bs =qdev_init_bdrv (&dev->qdev,IF_SD ); - s->sd =sd_init (bs,1 ); + s->sd =sd_init (bs,1 ,0 );register_savevm ("ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; } --1.6.5
PATCH 24/48 onenand overhaul
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
- major onenand emulation changes
- add reset support
- onenand: ignore zero writes to boot command area
--- hw/flash.h | 5 +- hw/onenand.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 234 insertions(+), 46 deletions(-)
hw/flash.h +4 -1
@@ -1,3 +1,5 @@ +#include "sysemu.h" +/* NOR flash devices */ typedef struct pflash_t pflash_t ;
@@ -39,7 +41,8 @@ uint32_t nand_getbuswidth(NANDFlashState *s);/* onenand.c */ void onenand_base_update (void *opaque,target_phys_addr_t new);void onenand_base_unmap (void *opaque); -void *onenand_init (uint32_t id,int regshift,qemu_irq irq); +void *onenand_init (uint16_t man_id,uint16_t dev_id,uint16_t ver_id, +int regshift,qemu_irq irq,DriveInfo *dinfo);void *onenand_raw_otp (void *opaque);/* ecc.c */
hw/onenand.c +230 -45
363 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 25/48 blizzard: fix for non-32bpp host displays
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- hw/blizzard.c | 102 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 53 insertions(+), 49 deletions(-)
hw/blizzard.c +53 -49
@@ -71,7 +71,6 @@ typedef struct {uint8_t iformat;uint8_t source;DisplayState *state; -blizzard_fn_t *line_fn_tab[2 ];void *fb;uint8_t hssi_config[3 ];
@@ -117,7 +116,6 @@ typedef struct {uint16_t *ptr;int angle;int pitch; -blizzard_fn_t line_fn; } data; } BlizzardState;
@@ -135,6 +133,17 @@ static const int blizzard_iformat_bpp[0x10] = { 0, 0, 0, 0, 0, 0, }; +#define DEPTH 8 +#include "blizzard_template.h" +#define DEPTH 15 +#include "blizzard_template.h" +#define DEPTH 16 +#include "blizzard_template.h" +#define DEPTH 24 +#include "blizzard_template.h" +#define DEPTH 32 +#include "blizzard_template.h" +static inline void blizzard_rgb2yuv (int r,int g,int b,int *y,int *u,int *v) {
@@ -149,8 +158,43 @@ static void blizzard_window(BlizzardState *s)int bypp[2 ];int bypl[3 ];int y; -blizzard_fn_t fn = s->data.line_fn; - +blizzard_fn_t fn =0 ; + +/* FIXME: this is a hack - but nseries.c will use this function +* before correct DisplayState is initialized so we need a way to +* avoid drawing something when we actually have no clue about host bpp */ +if (!s->state->listeners) +return ; + +switch (ds_get_bits_per_pixel (s->state)) { +case 8 : + fn = s->data.angle + ? blizzard_draw_fn_r_8[s->iformat] + : blizzard_draw_fn_8[s->iformat]; +break ; +case 15 : + fn = s->data.angle + ? blizzard_draw_fn_r_15[s->iformat] + : blizzard_draw_fn_15[s->iformat]; +break ; +case 16 : + fn = s->data.angle + ? blizzard_draw_fn_r_16[s->iformat] + : blizzard_draw_fn_16[s->iformat]; +break ; +case 24 : + fn = s->data.angle + ? blizzard_draw_fn_r_24[s->iformat] + : blizzard_draw_fn_24[s->iformat]; +break ; +case 32 : + fn = s->data.angle + ? blizzard_draw_fn_r_32[s->iformat] + : blizzard_draw_fn_32[s->iformat]; +break ; +default : +break ; + }if (!fn)return ;if (s->mx[0 ] > s->data.x)
@@ -181,7 +225,6 @@ static int blizzard_transfer_setup(BlizzardState *s)return 0 ; s->data.angle = s->effect &3 ; - s->data.line_fn = s->line_fn_tab[!!s->data.angle][s->iformat]; s->data.x = s->ix[0 ]; s->data.y = s->iy[0 ]; s->data.dx = s->ix[1 ] - s->ix[0 ] +1 ;
@@ -941,58 +984,19 @@ static void blizzard_screen_dump(void *opaque, const char *filename) {ppm_save (filename, s->state->surface); } -#define DEPTH 8 -#include "blizzard_template.h" -#define DEPTH 15 -#include "blizzard_template.h" -#define DEPTH 16 -#include "blizzard_template.h" -#define DEPTH 24 -#include "blizzard_template.h" -#define DEPTH 32 -#include "blizzard_template.h" -void *s1d13745_init (qemu_irq gpio_int) {BlizzardState *s = (BlizzardState *)qemu_mallocz (sizeof (*s)); s->fb =qemu_malloc (0x180000 ); - +/* Fill the framebuffer with white color here because the corresponding +* code in nseries.c is broken since the DisplayState change in QEMU. +* This is supposedly ok since nseries.c is the only user of blizzard.c */ +memset (s->fb,0xff ,0x180000 ); + s->state =graphic_console_init (blizzard_update_display, blizzard_invalidate_display, blizzard_screen_dump,NULL , s); - -switch (ds_get_bits_per_pixel (s->state)) { -case 0 : - s->line_fn_tab[0 ] = s->line_fn_tab[1 ] = -qemu_mallocz (sizeof (blizzard_fn_t) *0x10 ); -break ; -case 8 : - s->line_fn_tab[0 ] = blizzard_draw_fn_8; - s->line_fn_tab[1 ] = blizzard_draw_fn_r_8; -break ; -case 15 : - s->line_fn_tab[0 ] = blizzard_draw_fn_15; - s->line_fn_tab[1 ] = blizzard_draw_fn_r_15; -break ; -case 16 : - s->line_fn_tab[0 ] = blizzard_draw_fn_16; - s->line_fn_tab[1 ] = blizzard_draw_fn_r_16; -break ; -case 24 : - s->line_fn_tab[0 ] = blizzard_draw_fn_24; - s->line_fn_tab[1 ] = blizzard_draw_fn_r_24; -break ; -case 32 : - s->line_fn_tab[0 ] = blizzard_draw_fn_32; - s->line_fn_tab[1 ] = blizzard_draw_fn_r_32; -break ; -default : -fprintf (stderr,"%s: Bad color depth\n" , __FUNCTION__); -exit (1 ); - } -blizzard_reset (s); -return s; }
Signature · 1 line
1.6.5
PATCH 26/48 SD overhaul
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
- reset support
- add high capacity mmc support
- sd: improve mmc emulation
- make sd emulation work as mmc emulation as well
- handle SD CMD5 without error messages
- remove couple of unnecessary error messages
- Fix block count for OMAP3 MMC emulation
--- hw/sd.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 334 insertions(+), 56 deletions(-)
hw/sd.c +334 -56
@@ -4,6 +4,7 @@* * Copyright (c) 2006 Andrzej Zaborowski <[email protected]> * Copyright (c) 2007 CodeSourcery +* Copyright (c) 2009 Nokia Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
@@ -75,6 +76,7 @@ struct SDState {uint8_t scr[8 ];uint8_t cid[16 ];uint8_t csd[16 ]; +uint8_t ext_csd[512 ];uint16_t rca;uint32_t card_status;uint8_t sd_status[64 ];
@@ -89,7 +91,7 @@ struct SDState {int pwd_len;int function_group[6 ]; -int spi; +int spi, mmc;int current_cmd;int blk_written;uint64_t data_start;
@@ -101,6 +103,7 @@ struct SDState {uint8_t *buf;int enable; +int buswidth, highspeed; };static void sd_set_status (SDState *sd)
@@ -131,9 +134,9 @@ static void sd_set_status(SDState *sd) }static const sd_cmd_type_t sd_cmd_type[64 ] = { - sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_none, sd_none, sd_ac, + sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_ac, sd_none, sd_ac, sd_bcr, sd_ac, sd_ac, sd_adtc, sd_ac, sd_ac, sd_none, sd_ac, - sd_ac, sd_adtc, sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, + sd_ac, sd_adtc, sd_adtc, sd_none, sd_adtc, sd_none, sd_none, sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_ac, sd_ac, sd_adtc, sd_none, sd_ac, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, sd_none, sd_none, sd_bc, sd_none, sd_none, sd_none, sd_none, sd_none,
@@ -200,8 +203,8 @@ static void sd_set_ocr(SDState *sd)static void sd_set_scr (SDState *sd) { - sd->scr[0 ] =0x00 ;/* SCR Structure */ - sd->scr[1 ] =0x2f ;/* SD Security Support */ + sd->scr[0 ] =0x00 ;/* SCR v1.0, SD spec v1.0/1.01 */ + sd->scr[1 ] =0x25 ;/* erase=0, SD security v1.01, 1bit/4bit bus width */ sd->scr[2 ] =0x00 ; sd->scr[3 ] =0x00 ; sd->scr[4 ] =0x00 ;
@@ -212,7 +215,7 @@ static void sd_set_scr(SDState *sd)#define MID 0xaa#define OID "XY" -#define PNM "QEMU!" +#define PNM "QEMU!!"#define PRV 0x01#define MDT_YR 2006#define MDT_MON 2
@@ -227,14 +230,23 @@ static void sd_set_cid(SDState *sd) sd->cid[5 ] =PNM [2 ]; sd->cid[6 ] =PNM [3 ]; sd->cid[7 ] =PNM [4 ]; - sd->cid[8 ] =PRV ;/* Fake product revision (PRV) */ +if (sd->mmc) { + sd->cid[8 ] =PNM [5 ]; + }else { + sd->cid[8 ] =PRV ;/* Fake product revision (PRV) */ + } sd->cid[9 ] =0xde ;/* Fake serial number (PSN) */ sd->cid[10 ] =0xad ; sd->cid[11 ] =0xbe ; sd->cid[12 ] =0xef ; - sd->cid[13 ] =0x00 |/* Manufacture date (MDT) */ - ((MDT_YR -2000 ) /10 ); - sd->cid[14 ] = ((MDT_YR %10 ) <<4 ) |MDT_MON ; +if (sd->mmc) { + sd->cid[13 ] =0x55 ; + sd->cid[14 ] = ((MDT_MON ) <<4 ) | (MDT_YR -1997 ); + }else { + sd->cid[13 ] =0x00 |/* Manufacture date (MDT) */ + ((MDT_YR -2000 ) /10 ); + sd->cid[14 ] = ((MDT_YR %10 ) <<4 ) |MDT_MON ; + } sd->cid[15 ] = (sd_crc7 (sd->cid,15 ) <<1 ) |1 ; }
@@ -256,7 +268,12 @@ static void sd_set_csd(SDState *sd, uint64_t size)uint32_t wpsize = (1 << (WPGROUP_SHIFT +1 )) -1 ;if (size <=0x40000000 ) {/* Standard Capacity SD */ - sd->csd[0 ] =0x00 ;/* CSD structure */ +if (sd->mmc) { + sd->csd[0 ] =0x80 |/* CSD structure: v1.2 */ +0x0c ;/* MMC v3.x */ + }else { + sd->csd[0 ] =0x00 ;/* CSD structure: v0 */ + } sd->csd[1 ] =0x26 ;/* Data read access-time-1 */ sd->csd[2 ] =0x00 ;/* Data read access-time-2 */ sd->csd[3 ] =0x5a ;/* Max. data transfer rate */
@@ -282,25 +299,52 @@ static void sd_set_csd(SDState *sd, uint64_t size) sd->csd[14 ] =0x00 ;/* File format group */ sd->csd[15 ] = (sd_crc7 (sd->csd,15 ) <<1 ) |1 ; }else {/* SDHC */ - size /=512 *1024 ; - size -=1 ; - sd->csd[0 ] =0x40 ; +if (sd->mmc) { + sd->csd[0 ] =0x90 ;/* CSD structure v1.2, MMC v4.0/4.1 */ + }else { + sd->csd[0 ] =0x40 ;/* CSD structure v1 */ + } sd->csd[1 ] =0x0e ; sd->csd[2 ] =0x00 ; sd->csd[3 ] =0x32 ; sd->csd[4 ] =0x5b ; sd->csd[5 ] =0x59 ; - sd->csd[6 ] =0x00 ; - sd->csd[7 ] = (size >>16 ) &0xff ; - sd->csd[8 ] = (size >>8 ) &0xff ; - sd->csd[9 ] = (size &0xff ); - sd->csd[10 ] =0x7f ; +if (sd->mmc) { + sd->csd[6 ] =0x03 ; + sd->csd[7 ] =0xff ; + sd->csd[8 ] =0xff ; + sd->csd[9 ] =0xff ; + sd->csd[10 ] =0xff ; + }else { + size /=512 *1024 ; + size -=1 ; + sd->csd[6 ] =0x00 ; + sd->csd[7 ] = (size >>16 ) &0xff ; + sd->csd[8 ] = (size >>8 ) &0xff ; + sd->csd[9 ] = (size &0xff ); + sd->csd[10 ] =0x7f ; + } sd->csd[11 ] =0x80 ; sd->csd[12 ] =0x0a ; sd->csd[13 ] =0x40 ; sd->csd[14 ] =0x00 ; sd->csd[15 ] =0x00 ; - sd->ocr |=1 <<30 ;/* High Capacity SD Memort Card */ + sd->ocr |=1 <<30 ;/* High Capacity SD Memory Card */ +if (sd->mmc) { + size /=512 ; + sd->buswidth =1 ;/* 4bit mode */ + sd->highspeed =0 ; +memset (sd->ext_csd,0 ,512 ); + sd->ext_csd[183 ] = sd->buswidth; + sd->ext_csd[185 ] = sd->highspeed; + sd->ext_csd[192 ] =0x03 ;/* EXT_CSD v3 */ + sd->ext_csd[196 ] =0x03 ;/* supports 26MHz and 52MHz */ + sd->ext_csd[212 ] = (size &0xff ); + sd->ext_csd[213 ] = (size >>8 ) &0xff ; + sd->ext_csd[214 ] = (size >>16 ) &0xff ; + sd->ext_csd[215 ] = (size >>24 ) &0xff ; + sd->ext_csd[217 ] =0x00 ;/* sleep/awake timeout */ + } } }
@@ -382,13 +426,13 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) response[3 ] = (sd->vhs >>0 ) &0xff ; } -static void sd_reset (SDState *sd,BlockDriverState *bdrv) +void sd_reset (SDState *sd) {uint64_t size;uint64_t sect; -if (bdrv) { -bdrv_get_geometry (bdrv, §); +if (sd->bdrv) { +bdrv_get_geometry (sd->bdrv, §); }else { sect =0 ; }
@@ -397,7 +441,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv) size = sect +1 ; sect = (size >> (HWBLOCK_SHIFT +SECTOR_SHIFT +WPGROUP_SHIFT )) +1 ; - + sd->state = sd_idle_state; sd->rca =0x0000 ;sd_set_ocr (sd);
@@ -407,11 +451,9 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)sd_set_cardstatus (sd);sd_set_sdstatus (sd); - sd->bdrv = bdrv; -if (sd->wp_groups)qemu_free (sd->wp_groups); - sd->wp_switch = bdrv ?bdrv_is_read_only (bdrv) :0 ; + sd->wp_switch = sd->bdrv ?bdrv_is_read_only (sd->bdrv) :0 ; sd->wp_groups = (int *)qemu_mallocz (sizeof (int ) * sect);memset (sd->function_group,0 ,sizeof (int ) *6 ); sd->erase_start =0 ;
@@ -426,27 +468,121 @@ static void sd_cardchange(void *opaque)SDState *sd = opaque;qemu_set_irq (sd->inserted_cb,bdrv_is_inserted (sd->bdrv));if (bdrv_is_inserted (sd->bdrv)) { -sd_reset (sd, sd->bdrv); +sd_reset (sd);qemu_set_irq (sd->readonly_cb, sd->wp_switch); } } +static void sd_save_state (QEMUFile *f,void *opaque) +{ +struct SDState *s = (struct SDState *)opaque; +int i; +uint32_t wpgc = (s->size >> (HWBLOCK_SHIFT +SECTOR_SHIFT +WPGROUP_SHIFT )) +1 ; +char *filename; + + filename =qemu_mallocz (1024 ); +bdrv_get_backing_filename (s->bdrv, filename,1024 ); +qemu_put_buffer (f, (uint8_t *)filename,1024 ); +free (filename); + +qemu_put_sbe32 (f, s->mode); +qemu_put_sbe32 (f, s->state); +qemu_put_be32 (f, s->ocr); +qemu_put_buffer (f, s->scr,sizeof (s->scr)); +qemu_put_buffer (f, s->cid,sizeof (s->cid)); +qemu_put_buffer (f, s->csd,sizeof (s->csd)); +qemu_put_be16 (f, s->rca); +qemu_put_be32 (f, s->card_status); +qemu_put_buffer (f, s->sd_status,sizeof (s->sd_status)); +qemu_put_be32 (f, s->vhs); +for (i =0 ; i < wpgc; i++) +qemu_put_sbe32 (f, s->wp_groups[i]); +qemu_put_sbe32 (f, s->blk_len); +qemu_put_be32 (f, s->erase_start); +qemu_put_be32 (f, s->erase_end); +qemu_put_buffer (f, s->pwd,sizeof (s->pwd)); +qemu_put_sbe32 (f, s->pwd_len); +for (i =0 ; i <6 ; i++) +qemu_put_sbe32 (f, s->function_group[i]); +qemu_put_sbe32 (f, s->current_cmd); +qemu_put_sbe32 (f, s->blk_written); +qemu_put_be32 (f, s->data_start); +qemu_put_be32 (f, s->data_offset); +qemu_put_buffer (f, s->data,sizeof (s->data)); +qemu_put_buffer (f, s->buf,512 ); +qemu_put_sbe32 (f, s->enable); +} + +static int sd_load_state (QEMUFile *f,void *opaque,int version_id) +{ +struct SDState *s = (struct SDState *)opaque; +int i; +uint32_t wpgc = (s->size >> (HWBLOCK_SHIFT +SECTOR_SHIFT +WPGROUP_SHIFT )) +1 ; +char *filename1, *filename2; +int result =0 ; + +if (version_id) +return -EINVAL ; + + filename1 =qemu_mallocz (1024 ); + filename2 =qemu_mallocz (1024 ); +bdrv_get_backing_filename (s->bdrv, filename1,1024 ); +qemu_get_buffer (f, (uint8_t *)filename2,1024 ); +if (!strcmp (filename1, filename2)) { + s->mode =qemu_get_sbe32 (f); + s->state =qemu_get_sbe32 (f); + s->ocr =qemu_get_be32 (f); +qemu_get_buffer (f, s->scr,sizeof (s->scr)); +qemu_get_buffer (f, s->cid,sizeof (s->cid)); +qemu_get_buffer (f, s->csd,sizeof (s->csd)); + s->rca =qemu_get_be16 (f); + s->card_status =qemu_get_be32 (f); +qemu_get_buffer (f, s->sd_status,sizeof (s->sd_status)); + s->vhs =qemu_get_be32 (f); +for (i =0 ; i < wpgc; i++) + s->wp_groups[i] =qemu_get_sbe32 (f); + s->blk_len =qemu_get_sbe32 (f); + s->erase_start =qemu_get_be32 (f); + s->erase_end =qemu_get_be32 (f); +qemu_get_buffer (f, s->pwd,sizeof (s->pwd)); + s->pwd_len =qemu_get_sbe32 (f); +for (i =0 ; i <6 ; i++) + s->function_group[i] =qemu_get_sbe32 (f); + s->current_cmd =qemu_get_sbe32 (f); + s->blk_written =qemu_get_sbe32 (f); + s->data_start =qemu_get_be32 (f); + s->data_offset =qemu_get_be32 (f); +qemu_get_buffer (f, s->data,sizeof (s->data)); +qemu_get_buffer (f, s->buf,512 ); + s->enable =qemu_get_sbe32 (f); + }else + result = -EINVAL ; +free (filename2); +free (filename1); +return result; +} +/* We do not model the chip select pin, so allow the board to select whether card should be in SSI or MMC/SD mode. It is also up to the board to ensure that ssi transfers only occur when the chip select is asserted. */ -SDState *sd_init (BlockDriverState *bs,int is_spi) +SDState *sd_init (BlockDriverState *bs,int is_spi,int is_mmc) {SDState *sd; +static int instance_number =1 ; sd = (SDState *)qemu_mallocz (sizeof (SDState)); sd->buf =qemu_memalign (512 ,512 ); sd->spi = is_spi; + sd->mmc = is_mmc; sd->enable =1 ; -sd_reset (sd, bs); + sd->bdrv = bs; +sd_reset (sd);if (sd->bdrv) {bdrv_set_change_cb (sd->bdrv, sd_cardchange, sd); } +register_savevm ("sd" , instance_number++,0 , + sd_save_state, sd_load_state, sd);return sd; }
@@ -524,6 +660,46 @@ static void sd_function_switch(SDState *sd, uint32_t arg) sd->data[66 ] = crc &0xff ; } +static void mmc_function_switch (SDState *sd,uint32_t arg) +{ +enum { + cmd_set =0 , + set_bits, + clear_bits, + write_byte, + + unknown + } mode = (arg >>24 ); +if (mode >= unknown) { +fprintf (stderr,"%s: unknown mode 0x%02x\n" , __FUNCTION__, mode); + }else { +if (mode == cmd_set) { +fprintf (stderr,"%s: command set change not implemented!\n" , + __FUNCTION__); + }else { +uint8_t index = (arg >>16 ) &0xff ; +/* ignore writes to read-only fields */ +if (index !=192 && index !=196 && + (index <212 || index >215 )) { +uint8_t value = (arg >>8 ) &0xff ; +switch (mode) { +case set_bits: + sd->ext_csd[index] |= value; +break ; +case clear_bits: + sd->ext_csd[index] &= ~value; +break ; +case write_byte: + sd->ext_csd[index] = value; +break ; +default : +break ; + } + } + } + } +} +static inline int sd_wp_addr (SDState *sd,uint32_t addr) { return sd->wp_groups[addr >>
@@ -617,15 +793,21 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,default : sd->state = sd_idle_state; -sd_reset (sd, sd->bdrv); +sd_reset (sd);return sd->spi ? sd_r1 : sd_r0; }break ;case 1 :/* CMD1: SEND_OP_CMD */ +if (sd->mmc) { +if (sd->state == sd_idle_state) { + sd->state = sd_ready_state; +return sd_r3; + } +break ; + }if (!sd->spi) goto bad_cmd; - sd->state = sd_transfer_state;return sd_r1;
@@ -647,8 +829,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, goto bad_cmd;switch (sd->state) {case sd_identification_state: -case sd_standby_state: sd->state = sd_standby_state; +case sd_standby_state: +if (sd->mmc) { + sd->rca = req.arg >>16 ; +return sd_r1; + }sd_set_rca (sd);return sd_r6;
@@ -662,14 +848,25 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, goto bad_cmd;switch (sd->state) {case sd_standby_state: -break ; +return sd_r0;default :break ; }break ; -case 5 :/* CMD5: reserved for SDIO cards */ +case 5 :/* CMD5: reserved for SDIO cards / SLEEP_AWAKE (MMC) */ +if (sd->mmc) { +if (sd->rca != rca) { +return sd_r0; + } +if (req.arg & (1 <<15 )) { + sd->state = sd_transfer_state; + }else { + sd->state = sd_standby_state; + } +return sd_r1b; + } sd->card_status |=ILLEGAL_COMMAND ;return sd_r0;
@@ -678,11 +875,16 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, goto bad_cmd;switch (sd->mode) {case sd_data_transfer_mode: -sd_function_switch (sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start =0 ; - sd->data_offset =0 ; -return sd_r1; +if (sd->mmc) { +mmc_function_switch (sd, req.arg); +return sd_r1b; + }else { +sd_function_switch (sd, req.arg); + sd->state = sd_sendingdata_state; + sd->data_start =0 ; + sd->data_offset =0 ; +return sd_r1; + }default :break ;
@@ -727,22 +929,30 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, }break ; -case 8 :/* CMD8: SEND_IF_COND */ -/* Physical Layer Specification Version 2.00 command */ -switch (sd->state) { -case sd_idle_state: - sd->vhs =0 ; +case 8 :/* CMD8: SEND_IF_COND / SEND_EXT_CSD (MMC) */ +if (sd->mmc) { + sd->state = sd_sendingdata_state; +memcpy (sd->data, sd->ext_csd,512 ); + sd->data_start = addr; + sd->data_offset =0 ; +return sd_r1; + }else { +/* Physical Layer Specification Version 2.00 command */ +switch (sd->state) { +case sd_idle_state: + sd->vhs =0 ; -/* No response if not exactly one VHS bit is set. */ -if (!(req.arg >>8 ) || (req.arg >>ffs (req.arg & ~0xff ))) -return sd->spi ? sd_r7 : sd_r0; +/* No response if not exactly one VHS bit is set. */ +if (!(req.arg >>8 ) || (req.arg >>ffs (req.arg & ~0xff ))) +return sd->spi ? sd_r7 : sd_r0; -/* Accept. */ - sd->vhs = req.arg; -return sd_r7; +/* Accept. */ + sd->vhs = req.arg; +return sd_r7; -default : -break ; +default : +break ; + } }break ;
@@ -901,8 +1111,33 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,break ; }break ; + +/* Block write commands (Class 3) */ +case 20 :/* CMD20: WRITE_DAT_UNTIL_STOP */ +if (sd->mmc) { +if (sd->state == sd_transfer_state) { + sd->state = sd_sendingdata_state; + sd->data_start = req.arg; + sd->data_offset =0 ; + +if (sd->data_start + sd->blk_len > sd->size) { + sd->card_status |=ADDRESS_ERROR ; + } +return sd_r0; + } +break ; + } + goto bad_cmd;/* Block write commands (Class 4) */ +case 23 :/* CMD23: SET_BLOCK_COUNT */ +if (sd->mmc) { + sd->card_status |=ILLEGAL_COMMAND ; +fprintf (stderr,"%s: CMD23 not implemented\n" , __FUNCTION__); +return sd_r0; + } + goto bad_cmd; +case 24 :/* CMD24: WRITE_SINGLE_BLOCK */ if (sd->spi) goto unimplemented_cmd;
@@ -1042,6 +1277,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,/* Erase commands (Class 5) */ case 32 :/* CMD32: ERASE_WR_BLK_START */ +case 35 :/* CMD35: ERASE_GROUP_START */ +if ((req.cmd ==35 && !sd->mmc) || + (req.cmd ==32 && sd->mmc)) { + goto bad_cmd; + }switch (sd->state) {case sd_transfer_state: sd->erase_start = req.arg;
@@ -1053,6 +1293,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,break ;case 33 :/* CMD33: ERASE_WR_BLK_END */ +case 36 :/* CMD36: ERASE_GROUP_END */ +if ((req.cmd ==36 && !sd->mmc) || + (req.cmd ==33 && sd->mmc)) { + goto bad_cmd; + }switch (sd->state) {case sd_transfer_state: sd->erase_end = req.arg;
@@ -1081,6 +1326,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,break ; }break ; + +/* Class 9 */ +case 39 :/* CMD39: FAST_IO */ +case 40 :/* CMD40: GO_IRQ_STATE */ +if (sd->mmc) { + sd->card_status |=ILLEGAL_COMMAND ; +fprintf (stderr,"%s: CMD%d not implemented\n" , + __FUNCTION__, req.cmd); +return sd_r0; + } + goto bad_cmd;/* Lock card commands (Class 7) */ case 42 :/* CMD42: LOCK_UNLOCK */
@@ -1336,8 +1592,8 @@ int sd_do_command(SDState *sd, SDRequest *req,int i;DPRINTF ("Response:" );for (i =0 ; i < rsplen; i++) -printf (" %02x" , response[i]); -printf (" state %d\n" , sd->state); +fprintf (stderr," %02x" , response[i]); +fprintf (stderr," state %d\n" , sd->state); }else {DPRINTF ("No response %d\n" , sd->state); }
@@ -1434,6 +1690,11 @@ void sd_write_data(SDState *sd, uint8_t value) }break ; +case 20 :/* CMD20: WRITE_DAT_UNTIL_STOP */ +if (!sd->mmc) { + goto unknown_command; + } +/* fall through */ case 25 :/* CMD25: WRITE_MULTIPLE_BLOCK */ sd->data[sd->data_offset ++] = value;if (sd->data_offset >= sd->blk_len) {
@@ -1521,6 +1782,7 @@ void sd_write_data(SDState *sd, uint8_t value)break ;default : + unknown_command:fprintf (stderr,"sd_write_data: unknown command\n" );break ; }
@@ -1536,7 +1798,7 @@ uint8_t sd_read_data(SDState *sd)return 0x00 ;if (sd->state != sd_sendingdata_state) { -fprintf (stderr,"sd_read_data: not in Sending-Data state\n" ); +fprintf (stderr,"sd_read_data: not in Sending-Data state (state=%d)\n" , sd->state);return 0x00 ; }
@@ -1553,6 +1815,16 @@ uint8_t sd_read_data(SDState *sd) sd->state = sd_transfer_state;break ; +case 8 :/* CMD8: SEND_EXT_CSD (MMC only) */ +if (sd->mmc) { + ret = sd->data[sd->data_offset++]; +if (sd->data_offset >=512 ) { + sd->state = sd_transfer_state; + } + }else { + goto unknown_command; + } +break ;case 9 :/* CMD9: SEND_CSD */ case 10 :/* CMD10: SEND_CID */ ret = sd->data[sd->data_offset ++];
@@ -1638,6 +1910,7 @@ uint8_t sd_read_data(SDState *sd)break ;default : + unknown_command:fprintf (stderr,"sd_read_data: unknown command\n" );return 0x00 ; }
@@ -1654,3 +1927,8 @@ void sd_enable(SDState *sd, int enable) { sd->enable = enable; } + +int sd_is_mmc (SDState *sd) +{ +return sd->mmc; +}
Signature · 1 line
1.6.5
PATCH 27/48 tsc2005 overhaul
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- hw/tsc2005.c | 173 ++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 120 insertions(+), 53 deletions(-)
hw/tsc2005.c +120 -53
@@ -2,7 +2,7 @@* TI TSC2005 emulator. * * Copyright (c) 2006 Andrzej Zaborowski <[email protected]> -* Copyright (C) 2008 Nokia Corporation +* Copyright (c) 2009-2010 Nokia Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as
@@ -23,6 +23,15 @@#include "console.h" #include "devices.h" +//#define TSC2005_DEBUG + +#ifdef TSC2005_DEBUG +#define TRACE (fmt, ...) fprintf(stderr, "%s@%d: " fmt "\n", \ + __FUNCTION__, __LINE__, ##__VA_ARGS__) +#else +#define TRACE (...) +#endif +#define TSC_CUT_RESOLUTION (value, p) ((value) >> (16 - (p ? 12 : 10))) typedef struct {
@@ -54,6 +63,7 @@ typedef struct {uint16_t aux_thr[2 ];int tr[8 ]; +int z1_cons, z2_cons; } TSC2005State;enum {
@@ -98,10 +108,15 @@ static const uint16_t mode_regs[16] = { ((s->y * s->tr[0] - s->x * s->tr[1]) / s->tr[2] + s->tr[3])#define Y_TRANSFORM (s) \ ((s->y * s->tr[4] - s->x * s->tr[5]) / s->tr[6] + s->tr[7]) +/* #define Z1_TRANSFORM(s) \ - ((400 - ((s)->x >> 7) + ((s)->pressure << 10)) << 4) +(((s)->z1_cons - ((s)->x >> 7) + ((s)->pressure << 10)) << 4) #define Z2_TRANSFORM(s) \ - ((4000 + ((s)->y >> 7) - ((s)->pressure << 10)) << 4) +(((s)->z2_cons + ((s)->y >> 7) - ((s)->pressure << 10)) << 4) +*/ +/* these simpler forms work much better */ +#define Z1_TRANSFORM (s) (((s)->z1_cons) << 4) +#define Z2_TRANSFORM (s) (((s)->z2_cons) << 4)#define AUX_VAL (700 << 4)/* +/- 3 at 12-bit */ #define TEMP1_VAL (1264 << 4)/* +/- 5 at 12-bit */
@@ -114,33 +129,46 @@ static uint16_t tsc2005_read(TSC2005State *s, int reg)switch (reg) {case 0x0 :/* X */ s->dav &= ~mode_regs[TSC_MODE_X ]; +TRACE ("X = %d" ,TSC_CUT_RESOLUTION (X_TRANSFORM (s), s->precision) + + (s->noise &3 ));return TSC_CUT_RESOLUTION (X_TRANSFORM (s), s->precision) + (s->noise &3 );case 0x1 :/* Y */ s->dav &= ~mode_regs[TSC_MODE_Y ]; s->noise ++; +TRACE ("Y = %d" ,TSC_CUT_RESOLUTION (Y_TRANSFORM (s), s->precision) ^ + (s->noise &3 ));return TSC_CUT_RESOLUTION (Y_TRANSFORM (s), s->precision) ^ (s->noise &3 );case 0x2 :/* Z1 */ s->dav &=0xdfff ; +TRACE ("Z1 = %d" ,TSC_CUT_RESOLUTION (Z1_TRANSFORM (s), s->precision) - + (s->noise &3 ));return TSC_CUT_RESOLUTION (Z1_TRANSFORM (s), s->precision) - (s->noise &3 );case 0x3 :/* Z2 */ s->dav &=0xefff ; +TRACE ("Z2 = %d" ,TSC_CUT_RESOLUTION (Z2_TRANSFORM (s), s->precision) | + (s->noise &3 ));return TSC_CUT_RESOLUTION (Z2_TRANSFORM (s), s->precision) | (s->noise &3 );case 0x4 :/* AUX */ s->dav &= ~mode_regs[TSC_MODE_AUX ]; +TRACE ("AUX = %d" ,TSC_CUT_RESOLUTION (AUX_VAL , s->precision));return TSC_CUT_RESOLUTION (AUX_VAL , s->precision);case 0x5 :/* TEMP1 */ s->dav &= ~mode_regs[TSC_MODE_TEMP1 ]; +TRACE ("TEMP1 = %d" ,TSC_CUT_RESOLUTION (TEMP1_VAL , s->precision) - + (s->noise &5 ));return TSC_CUT_RESOLUTION (TEMP1_VAL , s->precision) - (s->noise &5 );case 0x6 :/* TEMP2 */ s->dav &=0xdfff ; s->dav &= ~mode_regs[TSC_MODE_TEMP2 ]; +TRACE ("TEMP2 = %d" ,TSC_CUT_RESOLUTION (TEMP2_VAL , s->precision) ^ + (s->noise &3 ));return TSC_CUT_RESOLUTION (TEMP2_VAL , s->precision) ^ (s->noise &3 );
@@ -149,31 +177,43 @@ static uint16_t tsc2005_read(TSC2005State *s, int reg) s->dav &= ~(mode_regs[TSC_MODE_X_TEST ] | mode_regs[TSC_MODE_Y_TEST ] | mode_regs[TSC_MODE_TS_TEST ]); s->reset =1 ; +TRACE ("STATUS = 0x%04x" , ret);return ret;case 0x8 :/* AUX high treshold */ +TRACE ("AUX high threshold = 0x%04x" , s->aux_thr[1 ]);return s->aux_thr[1 ];case 0x9 :/* AUX low treshold */ +TRACE ("AUX low threshold = 0x%04x" , s->aux_thr[0 ]);return s->aux_thr[0 ];case 0xa :/* TEMP high treshold */ +TRACE ("TEMP high threshold = 0x%04x" , s->temp_thr[1 ]);return s->temp_thr[1 ];case 0xb :/* TEMP low treshold */ +TRACE ("TEMP low threshold = 0x%04x" , s->temp_thr[0 ]);return s->temp_thr[0 ];case 0xc :/* CFR0 */ +TRACE ("CFR0 = 0x%04x" , (s->pressure <<15 ) | ((!s->busy) <<14 ) | + (s->nextprecision <<13 ) | s->timing[0 ]);return (s->pressure <<15 ) | ((!s->busy) <<14 ) | (s->nextprecision <<13 ) | s->timing[0 ];case 0xd :/* CFR1 */ +TRACE ("CFR1 = 0x%04x" , s->timing[1 ]);return s->timing[1 ];case 0xe :/* CFR2 */ +TRACE ("CFR2 = 0x%04x" , (s->pin_func <<14 ) | s->filter);return (s->pin_func <<14 ) | s->filter;case 0xf :/* Function select status */ +TRACE ("function select status = 0x%04x" , + s->function >=0 ?1 << s->function :0 );return s->function >=0 ?1 << s->function :0 ; }/* Never gets here */ +TRACE ("unknown register = 0xffff" );return 0xffff ; }
@@ -181,46 +221,52 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data) {switch (reg) {case 0x8 :/* AUX high treshold */ +TRACE ("AUX high threshold = 0x%04x" , data); s->aux_thr[1 ] = data;break ;case 0x9 :/* AUX low treshold */ +TRACE ("AUX low threshold = 0x%04x" , data); s->aux_thr[0 ] = data;break ;case 0xa :/* TEMP high treshold */ +TRACE ("TEMP high threshold = 0x%04x" , data); s->temp_thr[1 ] = data;break ;case 0xb :/* TEMP low treshold */ +TRACE ("TEMP low threshold = 0x%04x" , data); s->temp_thr[0 ] = data;break ;case 0xc :/* CFR0 */ +TRACE ("CFR0 = 0x%04x" , data); s->host_mode = data >>15 ;if (s->enabled != !(data &0x4000 )) { s->enabled = !(data &0x4000 ); -fprintf (stderr,"%s: touchscreen sense %sabled\n" , - __FUNCTION__, s->enabled ?"en" :"dis" ); -if (s->busy && !s->enabled) +TRACE ("touchscreen sense %sabled" , s->enabled ?"en" :"dis" ); +if (s->busy && !s->enabled) {qemu_del_timer (s->timer); + } s->busy &= s->enabled; } s->nextprecision = (data >>13 ) &1 ; s->timing[0 ] = data &0x1fff ; -if ((s->timing[0 ] >>11 ) ==3 ) -fprintf (stderr,"%s: illegal conversion clock setting\n" , - __FUNCTION__); +if ((s->timing[0 ] >>11 ) ==3 ) { +TRACE ("illegal conversion clock setting" ); + }break ;case 0xd :/* CFR1 */ +TRACE ("CFR1 = 0x%04x" , data); s->timing[1 ] = data &0xf07 ;break ;case 0xe :/* CFR2 */ +TRACE ("CFR2 = 0x%04x" , data); s->pin_func = (data >>14 ) &3 ; s->filter = data &0x3fff ;break ;default : -fprintf (stderr,"%s: write into read-only register %x\n" , - __FUNCTION__, reg); +TRACE ("write into read-only register 0x%x, value 0x%04x" , reg, data); } }
@@ -228,29 +274,16 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data)static void tsc2005_pin_update (TSC2005State *s) {int64_t expires; -int pin_state; - -switch (s->pin_func) { -case 0 : - pin_state = !s->pressure && !!s->dav; -break ; -case 1 : -case 3 : -default : - pin_state = !s->dav; -break ; -case 2 : - pin_state = !s->pressure; - } - -if (pin_state != s->irq) { - s->irq = pin_state; -qemu_set_irq (s->pint, s->irq); - } - +TRACE ("nextf=%d, press=%d, ena=%d, busy=%d, dav=0x%04x, irq=%d" , + s->nextfunction, s->pressure, s->enabled, s->busy, s->dav, s->irq);switch (s->nextfunction) {case TSC_MODE_XYZ_SCAN :case TSC_MODE_XY_SCAN : +if (!s->pin_func && !s->dav) { +TRACE ("all values read, lowering irq" ); + s->irq =0 ; +qemu_set_irq (s->pint, s->irq); + }if (!s->host_mode && s->dav) s->enabled =0 ;if (!s->pressure)
@@ -283,15 +316,14 @@ static void tsc2005_pin_update(TSC2005State *s)return ; } -if (!s->enabled || s->busy) -return ; - - s->busy =1 ; - s->precision = s->nextprecision; - s->function = s->nextfunction; - s->pdst = !s->pnd0;/* Synchronised on internal clock */ - expires =qemu_get_clock (vm_clock) + (get_ticks_per_sec () >>7 ); -qemu_mod_timer (s->timer, expires); +if (s->enabled && !s->busy) { + s->busy =1 ; + s->precision = s->nextprecision; + s->function = s->nextfunction; + s->pdst = !s->pnd0;/* Synchronised on internal clock */ + expires =qemu_get_clock (vm_clock) + (get_ticks_per_sec () >>7 ); +qemu_mod_timer (s->timer, expires); + } }static void tsc2005_reset (TSC2005State *s)
@@ -322,20 +354,20 @@ static uint8_t tsc2005_txrx_word(void *opaque, uint8_t value) {TSC2005State *s = opaque;uint32_t ret =0 ; - +TRACE ("value = 0x%08x, state=%d" , value, s->state +1 );switch (s->state ++) {case 0 :if (value &0x80 ) {/* Command */ -if (value & (1 <<1 )) +if (value & (1 <<1 )) {tsc2005_reset (s); -else { + }else { s->nextfunction = (value >>3 ) &0xf ; s->nextprecision = (value >>2 ) &1 ;if (s->enabled != !(value &1 )) { s->enabled = !(value &1 ); -fprintf (stderr,"%s: touchscreen sense %sabled\n" , - __FUNCTION__, s->enabled ?"en" :"dis" ); +TRACE ("touchscreen sense %sabled" , + s->enabled ?"en" :"dis" );if (s->busy && !s->enabled)qemu_del_timer (s->timer); s->busy &= s->enabled;
@@ -386,7 +418,7 @@ static uint8_t tsc2005_txrx_word(void *opaque, uint8_t value)uint32_t tsc2005_txrx (void *opaque,uint32_t value,int len) {uint32_t ret =0 ; - +TRACE ("value=0x%08x, len=%d" , value, len); len &= ~7 ;while (len >0 ) { len -=8 ;
@@ -398,17 +430,44 @@ uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len)static void tsc2005_timer_tick (void *opaque) { +int pin_state;TSC2005State *s = opaque;/* Timer ticked -- a set of conversions has been finished. */ -if (!s->busy) +if (!s->busy) { +TRACE ("not busy -> exit" );return ; + } - s->busy =0 ; - s->dav |= mode_regs[s->function]; - s->function =-1 ; -tsc2005_pin_update (s); +switch (s->pin_func) { +case 0 : + pin_state = s->pressure || !s->dav; +break ; +case 1 : +case 3 : +default : + pin_state = !s->dav; +break ; +case 2 : + pin_state = s->pressure; + } + s->busy =0 ; +if (!s->dav) { +TRACE ("report new conversions ready" ); + s->dav |= mode_regs[s->function]; + } +TRACE ("pin_func=%d, pin_state=%d, pressure=%d, irq=%d, dav=0x%04x" , + s->pin_func, pin_state, s->pressure, s->irq, s->dav); + s->function =-1 ; +tsc2005_pin_update (s); + +if (pin_state != s->irq) { +TRACE ("changing IRQ state to %d" , pin_state); + s->irq = pin_state; +qemu_set_irq (s->pint, s->irq); + } +TRACE ("done" ); } static void tsc2005_touchscreen_event(void *opaque,
@@ -428,8 +487,9 @@ static void tsc2005_touchscreen_event(void *opaque,* signaling TS events immediately, but for now we simulate * the first conversion delay for sake of correctness. */ -if (p != s->pressure) +if (p != s->pressure) {tsc2005_pin_update (s); + } }static void tsc2005_save (QEMUFile *f,void *opaque)
@@ -541,6 +601,9 @@ void *tsc2005_init(qemu_irq pintdav) s->tr[5 ] =0 ; s->tr[6 ] =1 ; s->tr[7 ] =0 ; + + s->z1_cons =400 ; + s->z2_cons =4000 ;tsc2005_reset (s);
@@ -558,7 +621,8 @@ void *tsc2005_init(qemu_irq pintdav)* from the touchscreen. Assuming 12-bit precision was used during * tslib calibration. */ -void tsc2005_set_transform (void *opaque,MouseTransformInfo *info) +void tsc2005_set_transform (void *opaque,MouseTransformInfo *info, +int z1_cons,int z2_cons) {TSC2005State *s = (TSC2005State *) opaque;
@@ -590,4 +654,7 @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info) s->tr[4 ] >>=11 ; s->tr[5 ] >>=11 ; s->tr[7 ] <<=4 ; + + s->z1_cons = z1_cons; + s->z2_cons = z2_cons; }
Signature · 1 line
1.6.5
PATCH 28/48 prepare smc driver support for omap
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- hw/devices.h | 5 ++++- hw/smc91c111.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-)
hw/devices.h +4 -1
@@ -5,6 +5,8 @@/* smc91c111.c */ void smc91c111_init (NICInfo *,uint32_t ,qemu_irq ); +void *smc91c111_init_lite (NICInfo *,qemu_irq ); +int smc91c111_iomemtype (void *opaque);/* lan9118.c */ void lan9118_init (NICInfo *,uint32_t ,qemu_irq );
@@ -21,7 +23,8 @@ void tsc210x_key_event(uWireSlave *chip, int key, int down);/* tsc2005.c */ void *tsc2005_init (qemu_irq pintdav);uint32_t tsc2005_txrx (void *opaque,uint32_t value,int len); -void tsc2005_set_transform (void *opaque,MouseTransformInfo *info); +void tsc2005_set_transform (void *opaque,MouseTransformInfo *info, +int z1_cons,int z2_cons);/* stellaris_input.c */ void stellaris_gamepad_init (int n,qemu_irq *irq,const int *keycode);
hw/smc91c111.c +22 -0
@@ -717,6 +717,7 @@ static int smc91c111_init1(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq);qemu_macaddr_default_if_unset (&s->conf.macaddr); +qemu_register_reset ((void *)smc91c111_reset, s);smc91c111_reset (s); s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,
@@ -757,4 +758,25 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)sysbus_connect_irq (s,0 , irq); } +void *smc91c111_init_lite (NICInfo *nd,qemu_irq irq) +{ +DeviceState *dev; +SysBusDevice *s; + +qemu_check_nic_model (nd,"smc91c111" ); + dev =qdev_create (NULL ,"smc91c111" ); +qdev_set_nic_properties (dev, nd); +qdev_init_nofail (dev); + s =sysbus_from_qdev (dev); +//sysbus_mmio_map(s, 0, base); +sysbus_connect_irq (s,0 , irq); +return s; +} + +int smc91c111_iomemtype (void *opaque) +{ +SysBusDevice *s = (SysBusDevice *)opaque; +return (FROM_SYSBUS (smc91c111_state, s))->mmio_index; +} +device_init (smc91c111_register_devices)
Signature · 1 line
1.6.5
PATCH 29/48 Add triton2 (twl4030) driver
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
The swiss knife companion chip for omap3
--- hw/i2c.h | 10 + hw/twl4030.c | 1469 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1479 insertions(+), 0 deletions(-) create mode 100644 hw/twl4030.c
hw/i2c.h +10 -0
@@ -79,4 +79,14 @@ void tmp105_set(i2c_slave *i2c, int temp);/* lm832x.c */ void lm832x_key_event (i2c_slave *i2c,int key,int state); +/* twl4030.c */ +typedef struct { +int code; +int column; +int row; +}TWL4030KeyMap ; +void *twl4030_init (i2c_bus *gp_bus,qemu_irq irq1,qemu_irq irq2, +const TWL4030KeyMap *keymap); +void twl4030_set_powerbutton_state (void *opaque,int pressed); +#endif
hw/twl4030.c new file +1469 -0
1,469 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 30/48 savevm and reset support for soc_dma
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
--- hw/soc_dma.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- hw/soc_dma.h | 4 ++- 2 files changed, 74 insertions(+), 2 deletions(-)
hw/soc_dma.c +71 -1
@@ -20,6 +20,7 @@#include "qemu-common.h" #include "qemu-timer.h" #include "soc_dma.h" +#include "hw.h" static void transfer_mem2mem (struct soc_dma_ch_s *ch) {
@@ -228,12 +229,79 @@ void soc_dma_reset(struct soc_dma_s *soc) {struct dma_s *s = (struct dma_s *) soc; - s->soc.drqbmp =0 ; +memset (s->soc.drqst,0 ,sizeof (s->soc.drqst)); s->ch_enable_mask =0 ; s->enabled_count =0 ;soc_dma_ch_freq_update (s); } +static void soc_dma_save_state (QEMUFile *f,void *opaque) +{ +struct dma_s *s = (struct dma_s *)opaque; +int i; + +qemu_put_buffer (f, s->soc.drqst,sizeof (s->soc.drqst)); +qemu_put_sbe64 (f, s->soc.freq); +qemu_put_be64 (f, s->ch_enable_mask); +qemu_put_sbe64 (f, s->channel_freq); +qemu_put_sbe32 (f, s->enabled_count); +for (i =0 ; i < s->chnum; i++) { +qemu_put_timer (f, s->ch[i].timer); +qemu_put_sbe32 (f, s->ch[i].enable); +qemu_put_sbe32 (f, s->ch[i].update); +qemu_put_sbe32 (f, s->ch[i].bytes); +qemu_put_sbe32 (f, s->ch[i].type[0 ]); +qemu_put_sbe32 (f, s->ch[i].type[1 ]); +#if TARGET_PHYS_ADDR_BITS ==32 +qemu_put_be32 (f, s->ch[i].vaddr[0 ]); +qemu_put_be32 (f, s->ch[i].vaddr[1 ]); +#elif TARGET_PHYS_ADDR_BITS ==64 +qemu_put_be64 (f, s->ch[i].vaddr[0 ]); +qemu_put_be64 (f, s->ch[i].vaddr[1 ]); +#else +#error TARGET_PHYS_ADDR_BITS undefined +#endif +qemu_put_sbe32 (f, s->ch[i].running); + } +} + +static int soc_dma_load_state (QEMUFile *f,void *opaque,int version_id) +{ +struct dma_s *s = (struct dma_s *)opaque; +int i; + +if (version_id) +return -EINVAL ; + +qemu_get_buffer (f, s->soc.drqst,sizeof (s->soc.drqst)); + s->soc.freq =qemu_get_sbe64 (f); + s->ch_enable_mask =qemu_get_be64 (f); + s->channel_freq =qemu_get_sbe64 (f); + s->enabled_count =qemu_get_sbe32 (f); +for (i =0 ; i < s->chnum; i++) { +qemu_get_timer (f, s->ch[i].timer); + s->ch[i].enable =qemu_get_sbe32 (f); + s->ch[i].update =qemu_get_sbe32 (f); + s->ch[i].bytes =qemu_get_sbe32 (f); + s->ch[i].type[0 ] =qemu_get_sbe32 (f); + s->ch[i].type[1 ] =qemu_get_sbe32 (f); +#if TARGET_PHYS_ADDR_BITS ==32 + s->ch[i].vaddr[0 ] =qemu_get_be32 (f); + s->ch[i].vaddr[1 ] =qemu_get_be32 (f); +#elif TARGET_PHYS_ADDR_BITS ==64 + s->ch[i].vaddr[0 ] =qemu_get_be64 (f); + s->ch[i].vaddr[1 ] =qemu_get_be64 (f); +#else +#error TARGET_PHYS_ADDR_BITS undefined +#endif + s->ch[i].running =qemu_get_sbe32 (f); + +soc_dma_ch_update (&s->ch[i]); + } + +return 0 ; +} +/* TODO: take a functional-clock argument */ struct soc_dma_s *soc_dma_init (int n) {
@@ -251,6 +319,8 @@ struct soc_dma_s *soc_dma_init(int n)soc_dma_reset (&s->soc); fifo_size =0 ; +register_savevm ("soc_dma" ,-1 ,0 , + soc_dma_save_state, soc_dma_load_state, s);return &s->soc; }
hw/soc_dma.h +3 -1
@@ -18,6 +18,8 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ +#define DMA_MAX_DRQ 96 +struct soc_dma_s ;struct soc_dma_ch_s ;typedef void (*soc_dma_io_t )(void *opaque,uint8_t *buf,int len);
@@ -65,7 +67,7 @@ struct soc_dma_ch_s {struct soc_dma_s {/* Following fields are set by the SoC DMA module and can be used * by anybody. */ -uint64_t drqbmp;/* Is zeroed by soc_dma_reset() */ +uint8_t drqst[DMA_MAX_DRQ ];/* Is zeroed by soc_dma_reset() */ qemu_irq *drq;void *opaque;int64_t freq;
Signature · 1 line
1.6.5
PATCH 32/48 Add beagleboard and n900 machine definitions
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
Wire in all the code from previous patches. Beagleboard code based on Yajin's initial work.
--- Makefile.target | 7 +- hw/beagle.c | 108 +++++++++++++++++++++ hw/nseries.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 397 insertions(+), 6 deletions(-) create mode 100644 hw/beagle.c
Makefile.target +5 -2
@@ -269,8 +269,11 @@ obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o obj-arm-y += pflash_cfi01.o gumstix.o obj-arm-y += zaurus.o ide/core.o ide/microdrive.o spitz.o tosa.o tc6393xb.o -obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o -obj-arm-y += omap2.o omap_dss.o soc_dma.o +obj-arm-y += omap_gpio.o omap_uart.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o +obj-arm-y += omap_i2c.o omap_spi.o omap_intc.o omap_dss.o soc_dma.o omap_gptimer.o +obj-arm-y += omap_synctimer.o omap_sdrc.o omap_gpmc.o omap_tap.o omap_l4.o +obj-arm-y += omap_usb.o omap3_mmc.o omap3_lcd.o omap3_boot.o omap1.o omap2.o omap3.o +obj-arm-y += beagle.o twl4030.o obj-arm-y += omap_sx1.o palm.o tsc210x.o obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o obj-arm-y += mst_fpga.o mainstone.o
hw/beagle.c new file +108 -0
108 lines not on this page · raw message
hw/nseries.c +284 -4
306 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 33/48 Add OpenGL ES accelerator support
In reply to Riku VoipioFrom: Riku Voipio <[email protected]>
To make it possible to use UI's based OpenGL ES efficiently in qemu emulator, we need to offload the rendering to the host. This patch provides the QEMU side of the code for omap3 emulation. A kernel module, gles wrapper library inside qemu target filesystem, and a gles library outside qemu are still needed. These will be provided outside qemu project at:
http://maemo.gitorious.org/qemu-maemo/gles-libs
--- Makefile.target | 18 + configure | 41 +- hw/gles2.c | 764 ++++++++++++++++ hw/gles2.h | 323 +++++++ hw/gles2_calls.c | 2409 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/gles2_calls.h | 189 ++++ hw/nseries.c | 10 + qemu-options.hx | 19 + target-arm/helper.c | 10 +- vl.c | 10 + 10 files changed, 3790 insertions(+), 3 deletions(-) create mode 100644 hw/gles2.c create mode 100644 hw/gles2.h create mode 100644 hw/gles2_calls.c create mode 100644 hw/gles2_calls.h
Makefile.target +18 -0
@@ -309,6 +309,24 @@ obj-y += $(addprefix ../libdis/, $(libdis-y)) obj-y += $(libobj-y) obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y)) +ifeq ($(TARGET_BASE_ARCH), arm) +ifdef CONFIG_GLES2 +CFLAGS+=-I$(DGLES2)/include +LIBS+=-L$(DGLES2)/lib +ifdef CONFIG_GLES2_STATIC +LIBS+=-Wl,-Bstatic -lEGL -lGLESv2 -lOSMesa -Wl,-Bdynamic +else +LIBS+=-lEGL -lGLESv2 +endif +ifndef CONFIG_WIN32 +LIBS+=-LX11 -ldl +endif +gles2_calls.o: gles2_calls.c gles2.h gles2_calls.h +gles2.o: gles2.c gles2.h gles2_calls.h +obj-arm-y += gles2.o gles2_calls.o +endif # CONFIG_GLES2 +endif # TARGET_BASE_ARCH==arm + endif # CONFIG_SOFTMMU obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
configure +39 -2
83 lines not on this page · raw message
hw/gles2.c new file +764 -0
764 lines not on this page · raw message
hw/gles2.h new file +323 -0
323 lines not on this page · raw message
hw/gles2_calls.c new file +2409 -0
1,806 lines not on this page · raw message
hw/gles2_calls.h new file +189 -0
189 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.5
Part of the diff is not shown here. View the raw message.
PATCH 34/48 target-arm: add support for smc
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- hw/omap3_boot.c | 32 +++++++++++++++-------- target-arm/cpu.h | 10 +++++-- target-arm/helper.c | 67 +++++++++++++++++++++++++++++++++++++++++++----- target-arm/translate.c | 31 ++++++++++++++++++--- 4 files changed, 114 insertions(+), 26 deletions(-)
hw/omap3_boot.c +21 -11
@@ -98,12 +98,17 @@ static const uint8_t omap3_boot_rom[] = { /* 0x40014000-0x4001bfff */0xff ,0xff ,0xff ,0xff ,/* 0x40014048: booting parameter structure 4-7 */ 0xff ,0xff ,0xff ,0xff ,/* 0x4001404c: booting parameter structure 8-11 */ 0x0e ,0xf0 ,0xb0 ,0xe1 ,/* 0x40014050: "movs pc, lr" */ -0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +0xff ,0xff ,0xff ,0xff ,/* 0x40014054 */ +0xff ,0xff ,0xff ,0xff ,/* 0x40014058 */ +0xff ,0xff ,0xff ,0xff ,/* 0x4001405c */ +0xfe ,0xff ,0xff ,0xea ,/* 0x40014060: monitor vector 0 (unused) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x40014064: monitor vector 1 (unused) */ +0x15 ,0x00 ,0x00 ,0xea ,/* 0x40014068: monitor vector 2 (smc) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x4001406c: monitor vector 3 (pabt) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x40014070: monitor vector 4 (dabt) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x40014074: monitor vector 5 (unused) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x40014078: monitor vector 6 (irq) */ +0xfe ,0xff ,0xff ,0xea ,/* 0x4001407c: monitor vector 7 (fiq) */ /* 0x40014080: Dead loops */ 0xfe ,0xff ,0xff ,0xea ,/* b 0x40014080 @ undefined exception */ 0xfe, 0xff, 0xff, 0xea, /* b 0x40014084 @ swi exception */
@@ -123,9 +128,12 @@ static const uint8_t omap3_boot_rom[] = { /* 0x40014000-0x4001bfff */0xfe ,0xff ,0xff ,0xea ,/* b 0x400140bc @ reserved */ /* 0x400140c0: should perform a software reset & jump to r0 */ 0x00 ,0xf0 ,0xa0 ,0xe1 ,/* mov pc, r0 */ -0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , -0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , +/* 0x400140c4: monitor mode smc vector handler */ +0x02 ,0x00 ,0x5c ,0xe3 ,/* cmp r12, #2 */ +0x50 ,0x0f ,0x29 ,0xee ,/* mcreq p15, 1, r0, c9, c0, 2 @ l2c aux ctrl */ +0x03 ,0x00 ,0x5c ,0xe3 ,/* cmp r12, #3 */ +0x30 ,0x0f ,0x01 ,0xee ,/* mcreq p15, 0, r0, c1, c0, 1 @ aux ctrl*/ +0x0e ,0xf0 ,0xb0 ,0xe1 ,/* movs pc, r14 */ 0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -153,8 +161,10 @@ static const uint8_t omap3_boot_rom[] = { /* 0x40014000-0x4001bfff */0x08 ,0x0c ,0x40 ,0xe2 ,/* sub r0, r0, #2048 @ 2kB UND stack */ 0xd3 ,0xf0 ,0x21 ,0xe3 ,/* msr cpsr_c, #0xd3 @ enter SVC mode */ 0x00 ,0xd0 ,0xa0 ,0xe1 ,/* mov sp, r0 @ 23kB left for SVC stack */ -0x44 ,0x00 ,0x04 ,0xe3 ,/* movw r0, #0x4044 */ -0x01 ,0x00 ,0x44 ,0xe3 ,/* movt r0, #0x4001 @ r0 -> booting parameter struct */ +0x60 ,0x00 ,0x04 ,0xe3 ,/* movw r0, #0x4060 @ r0 -> monitor vba */ +0x01 ,0x00 ,0x44 ,0xe3 ,/* movt r0, #0x4001 */ +0x30 ,0x0f ,0x0c ,0xfe ,/* mcr2 p15, 0, r0, c12, c0, 1 */ +0x1c ,0x00 ,0x40 ,0xe2 ,/* sub r0, r0, #1c @ r0 -> booting parameter struct */ 0x01, 0xf0, 0xa0, 0xe1, /* mov pc, r1 */ };
target-arm/cpu.h +7 -3
@@ -41,6 +41,7 @@#define EXCP_EXCEPTION_EXIT 8/* Return from v7M exception. */ #define EXCP_KERNEL_TRAP 9/* Jumped to kernel code page. */ #define EXCP_STREX 10 +#define EXCP_SMC 11/* secure monitor call */ #define ARMV7M_EXCP_RESET 1#define ARMV7M_EXCP_NMI 2
@@ -80,9 +81,9 @@ typedef struct CPUARMState {uint32_t spsr;/* Banked registers. */ -uint32_t banked_spsr[6 ]; -uint32_t banked_r13[6 ]; -uint32_t banked_r14[6 ]; +uint32_t banked_spsr[7 ]; +uint32_t banked_r13[7 ]; +uint32_t banked_r14[7 ];/* These hold r8-r12. */ uint32_t usr_regs[5 ];
@@ -129,6 +130,8 @@ typedef struct CPUARMState {uint32_t c6_data;uint32_t c9_insn;/* Cache lockdown registers. */ uint32_t c9_data; +uint32_t c12_vbar;/* secure/nonsecure vector base address register. */ +uint32_t c12_mvbar;/* monitor vector base address register. */ uint32_t c13_fcse;/* FCSE PID. */ uint32_t c13_context;/* Context ID. */ uint32_t c13_tls1;/* User RW Thread register. */
@@ -308,6 +311,7 @@ enum arm_cpu_mode {ARM_CPU_MODE_FIQ =0x11 ,ARM_CPU_MODE_IRQ =0x12 ,ARM_CPU_MODE_SVC =0x13 , +ARM_CPU_MODE_SMC =0x16 ,ARM_CPU_MODE_ABT =0x17 ,ARM_CPU_MODE_UND =0x1b ,ARM_CPU_MODE_SYS =0x1f
target-arm/helper.c +60 -7
97 lines not on this page · raw message
target-arm/translate.c +26 -5
@@ -73,6 +73,7 @@ typedef struct DisasContext {conditional executions state has been updated. */ #define DISAS_WFI 4#define DISAS_SWI 5 +#define DISAS_SMC 6static TCGv_ptr cpu_env;/* We reuse the same 64-bit temporaries for efficiency. */
@@ -837,6 +838,12 @@ static inline void store_reg_bx(CPUState *env, DisasContext *s, } } +static inline void gen_smc (CPUState *env,DisasContext *s) +{ +tcg_gen_movi_i32 (cpu_R[15 ], s->pc); + s->is_jmp =DISAS_SMC ; +} +static inline TCGv gen_ld8s (TCGv addr,int index) {TCGv tmp =new_tmp ();
@@ -6245,8 +6252,12 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) } }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ +cpu_abort (env,"unsupported coprocessor double register transfer\n" ); }else if ((insn &0x0f000010 ) ==0x0e000010 ) {/* Additional coprocessor register transfer. */ +if (!disas_coproc_insn (env, s, insn)) { +return ; + } }else if ((insn &0x0ff10020 ) ==0x01000000 ) {uint32_t mask;uint32_t val;
@@ -6401,10 +6412,10 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) s->is_jmp =DISAS_JUMP ; }else if (op1 ==3 ) {/* smi/smc */ -if (!(env->cp15.c0_c2[4 ] &0xf000 ) ||IS_USER (s)) +if (!(env->cp15.c0_c2[4 ] &0xf000 ) ||IS_USER (s)) { goto illegal_op; -/* TODO: real implementation; execute as NOP for now */ -/*fprintf(stderr, "smc [0x%08x] pc=0x%08x\n", insn, s->pc);*/ + } +gen_smc (env, s); }else { goto illegal_op; }
@@ -7991,8 +8002,11 @@ static int disas_thumb2_insn(CPUState *env, DisasContext *s, uint16_t insn_hw1) goto illegal_op;if (insn & (1 <<26 )) { -/* Secure monitor call (v6Z) */ - goto illegal_op;/* not implemented. */ +/* Secure monitor call / smc (v6Z) */ +if (!(env->cp15.c0_c2[4 ] &0xf000 ) ||IS_USER (s)) { + goto illegal_op; + } +gen_smc (env, s); }else { op = (insn >>20 ) &7 ;switch (op) {
@@ -9245,6 +9259,8 @@ static inline void gen_intermediate_code_internal(CPUState *env,gen_set_condexec (dc);if (dc->is_jmp ==DISAS_SWI ) {gen_exception (EXCP_SWI ); + }else if (dc->is_jmp ==DISAS_SMC ) { +gen_exception (EXCP_SMC ); }else {gen_exception (EXCP_DEBUG ); }
@@ -9257,6 +9273,8 @@ static inline void gen_intermediate_code_internal(CPUState *env,gen_set_condexec (dc);if (dc->is_jmp ==DISAS_SWI && !dc->condjmp) {gen_exception (EXCP_SWI ); + }else if (dc->is_jmp ==DISAS_SMC && !dc->condjmp) { +gen_exception (EXCP_SMC ); }else {/* FIXME: Single stepping a WFI insn will not halt the CPU. */
@@ -9291,6 +9309,9 @@ static inline void gen_intermediate_code_internal(CPUState *env,case DISAS_SWI :gen_exception (EXCP_SWI );break ; +case DISAS_SMC : +gen_exception (EXCP_SMC ); +break ; }if (dc->condjmp) {gen_set_label (dc->condlabel);
Signature · 1 line
1.6.5
PATCH 35/48 target-arm: fix neon vmon/vmvn with modified immediate
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-arm/translate.c +1 -1
@@ -4905,7 +4905,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) imm = (imm <<8 ) | (imm <<24 );break ;case 12 : - imm = (imm <8 ) |0xff ; + imm = (imm <<8 ) |0xff ;break ;case 13 : imm = (imm <<16 ) |0xffff ;
Signature · 1 line
1.6.5
PATCH 36/48 target-arm: fix neon vqshl/vqshlu instructions
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/helpers.h | 4 +++ target-arm/neon_helper.c | 58 +++++++++++++++++++++++++++++++++++++++++---- target-arm/translate.c | 28 +++++++++++----------- 3 files changed, 70 insertions(+), 20 deletions(-)
target-arm/helpers.h +4 -0
@@ -253,6 +253,10 @@ DEF_HELPER_3(neon_qshl_u32, i32, env, i32, i32) DEF_HELPER_3(neon_qshl_s32, i32, env, i32, i32) DEF_HELPER_3(neon_qshl_u64, i64, env, i64, i64) DEF_HELPER_3(neon_qshl_s64, i64, env, i64, i64) +DEF_HELPER_3(neon_qshlu_s8, i32, env, i32, i32) +DEF_HELPER_3(neon_qshlu_s16, i32, env, i32, i32) +DEF_HELPER_3(neon_qshlu_s32, i32, env, i32, i32) +DEF_HELPER_3(neon_qshlu_s64, i64, env, i64, i64) DEF_HELPER_3(neon_qrshl_u8, i32, env, i32, i32) DEF_HELPER_3(neon_qrshl_s8, i32, env, i32, i32)DEF_HELPER_3 (neon_qrshl_u16, i32, env, i32, i32)
target-arm/neon_helper.c +52 -6
89 lines not on this page · raw message
target-arm/translate.c +14 -14
@@ -4139,9 +4139,9 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)case 9 :/* VQSHL */ if (u) {gen_helper_neon_qshl_u64 (cpu_V0, cpu_env, - cpu_V0, cpu_V0); + cpu_V1, cpu_V0); }else { -gen_helper_neon_qshl_s64 (cpu_V1, cpu_env, +gen_helper_neon_qshl_s64 (cpu_V0, cpu_env, cpu_V1, cpu_V0); }break ;
@@ -4612,10 +4612,10 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)gen_helper_neon_shl_u64 (cpu_V0, cpu_V0, cpu_V1);break ;case 6 :/* VQSHLU */ -gen_helper_neon_qshl_s64 (cpu_V0, cpu_env, cpu_V0, - cpu_V1); +gen_helper_neon_qshlu_s64 (cpu_V0, cpu_env, cpu_V0, + cpu_V1);break ; -case 7 :/* VQSHL/VQSHLU */ +case 7 :/* VQSHL */ if (u) {gen_helper_neon_qshl_u64 (cpu_V0, cpu_env, cpu_V0, cpu_V1);
@@ -4673,26 +4673,26 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) }break ;case 6 :/* VQSHLU */ -GEN_NEON_INTEGER_OP_ENV (qshl); -break ; -case 7 :/* VQSHLU */ switch (size) {case 0 : -gen_helper_neon_qshl_u8 (tmp, cpu_env, tmp, - tmp2); +gen_helper_neon_qshlu_s8 (tmp, cpu_env, tmp, + tmp2);break ;case 1 : -gen_helper_neon_qshl_u16 (tmp, cpu_env, tmp, - tmp2); +gen_helper_neon_qshlu_s16 (tmp, cpu_env, tmp, + tmp2);break ;case 2 : -gen_helper_neon_qshl_u32 (tmp, cpu_env, tmp, - tmp2); +gen_helper_neon_qshlu_s32 (tmp, cpu_env, tmp, + tmp2);break ;default :abort ();/* size == 3 is handled earlier */ }break ; +case 7 :/* VQSHL */ +GEN_NEON_INTEGER_OP_ENV (qshl); +break ; }tcg_temp_free_i32 (tmp2);
Signature · 1 line
1.6.5
PATCH 37/48 target-arm: fix neon vqrshl instruction
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-)
target-arm/neon_helper.c +18 -3
@@ -727,9 +727,24 @@ uint64_t HELPER(neon_qshlu_s64)(CPUState *env, uint64_t valop, uint64_t shiftop) }}while (0 ) NEON_VOP_ENV(qrshl_u8, neon_u8, 4) NEON_VOP_ENV(qrshl_u16, neon_u16, 2) -NEON_VOP_ENV(qrshl_u32, neon_u32, 1)#undef NEON_FN +uint32_t HELPER (neon_qrshl_u32 )(CPUState *env,uint32_t val,uint32_t shiftop) +{ +int8_t shift = (int8_t )shiftop; +if (shift <0 ) { + val = ((uint64_t )val + (1 << (-1 - shift))) >> -shift; + }else { +uint32_t tmp = val; + val <<= shift; +if ((val >> shift) != tmp) { +SET_QC (); + val = ~0 ; + } + } +return val; +} +uint64_t HELPER (neon_qrshl_u64 )(CPUState *env,uint64_t val,uint64_t shiftop) {int8_t shift = (int8_t )shiftop;
@@ -755,7 +770,7 @@ uint64_t HELPER(neon_qrshl_u64)(CPUState *env, uint64_t val, uint64_t shiftop) dest = src1 << tmp; \if ((dest >> tmp) != src1) { \SET_QC (); \ - dest = src1 >>31 ; \ + dest = (uint32_t )(1 << (sizeof (src1) *8 -1 )) - (src1 >0 ?1 :0 ); \ } \ }}while (0 )NEON_VOP_ENV (qrshl_s8, neon_s8,4 )
@@ -771,7 +786,7 @@ uint64_t HELPER(neon_qrshl_s64)(CPUState *env, uint64_t valop, uint64_t shiftop)if (shift <0 ) { val = (val + (1 << (-1 - shift))) >> -shift; }else { -int64_t tmp = val;; +int64_t tmp = val; val <<= shift;if ((val >> shift) != tmp) {SET_QC ();
Signature · 1 line
1.6.5
PATCH 38/48 target-arm: fix neon vrshl instruction
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-)
target-arm/neon_helper.c +16 -3
@@ -547,20 +547,33 @@ uint64_t HELPER(neon_rshl_s64)(uint64_t valop, uint64_t shiftop) }}while (0 ) NEON_VOP(rshl_u8, neon_u8, 4) NEON_VOP(rshl_u16, neon_u16, 2) -NEON_VOP(rshl_u32, neon_u32, 1)#undef NEON_FN +uint32_t HELPER (neon_rshl_u32 )(uint32_t val,uint32_t shiftop) +{ +int8_t shift = (int8_t )shiftop; +if (shift >=32 || shift <-32 ) { + val =0 ; + }else if (shift ==-32 ) { + val >>= shift -1 ; + }else if (shift <0 ) { + val = ((uint64_t )val + (1 << (-1 - shift))) >> -shift; + }else { + val <<= shift; + } +return val; +} +uint64_t HELPER (neon_rshl_u64 )(uint64_t val,uint64_t shiftop) {int8_t shift = (uint8_t )shiftop; -if (shift >=64 || shift <64 ) { +if (shift >=64 || shift <-64 ) { val =0 ; }else if (shift ==-64 ) {/* Rounding a 1-bit result just preserves that bit. */ val >>=63 ; }if (shift <0 ) { val = (val + ((uint64_t )1 << (-1 - shift))) >> -shift; - val >>= -shift; }else { val <<= shift; }
Signature · 1 line
1.6.5
Re: [Qemu-devel] [PATCH 38/48] target-arm: fix neon vrshl instruction
target-arm/neon_helper.c uint64_t HELPER(neon_rshl_s64)(uint64_t valop, uint64_t shiftop) · line 558
Quoted 7 lines · Riku Voipio
target-arm/neon_helper.c +7
-0+uint32_t HELPER (neon_rshl_u32 )(uint32_t val,uint32_t shiftop) +{ +int8_t shift = (int8_t )shiftop; +if (shift >=32 || shift <-32 ) { + val =0 ; + }else if (shift ==-32 ) { + val >>= shift -1 ;
^^^^^^^^^^^^^^^^^
This looks wrong. Compare the equivalent case for 64-bit:
Quoted 4 lines
uint64_tHELPER(neon_rshl_u64)(uint64_t val,uint64_tshiftop)} else if (shift == -64) { /* Rounding a 1-bit result just preserves that bit. */ val >>= 63;
Bonus points for factoring out the duplicated 32/64-bit code.
-Nathan
PATCH 39/48 target-arm: fix neon vrshr instruction
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
target-arm/neon_helper.c +7 -1
@@ -573,7 +573,13 @@ uint64_t HELPER(neon_rshl_u64)(uint64_t val, uint64_t shiftop)/* Rounding a 1-bit result just preserves that bit. */ val >>=63 ; }if (shift <0 ) { - val = (val + ((uint64_t )1 << (-1 - shift))) >> -shift; +uint64_t r = ((uint64_t )1 << (-1 - shift)); +uint64_t lo = val + r; +if (lo < val || lo < r) { + val = (lo >> -shift) | ((1ull <<63 ) >> (-shift -1 )); + }else { + val = lo >> -shift; + } }else { val <<= shift; }
Signature · 1 line
1.6.5
PATCH 40/48 target-arm: fix neon v(r)sra instructions
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/translate.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
target-arm/translate.c +2 -2
@@ -4627,7 +4627,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) }if (op ==1 || op ==3 ) {/* Accumulate. */ -neon_load_reg64 (cpu_V0, rd + pass); +neon_load_reg64 (cpu_V1, rd + pass);tcg_gen_add_i64 (cpu_V0, cpu_V0, cpu_V1); }else if (op ==4 || (op ==5 && u)) {/* Insert */
@@ -4699,7 +4699,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)if (op ==1 || op ==3 ) {/* Accumulate. */ tmp2 =neon_load_reg (rd, pass); -gen_neon_add (size, tmp2, tmp); +gen_neon_add (size, tmp, tmp2);dead_tmp (tmp2); }else if (op ==4 || (op ==5 && u)) {/* Insert */
Signature · 1 line
1.6.5
PATCH 41/48 target-arm: fix neon vld1 single element to all lanes
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/translate.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
target-arm/translate.c +11 -2
@@ -3798,7 +3798,11 @@ static int disas_neon_ls_insn(CPUState * env, DisasContext *s, uint32_t insn) } size = (insn >>6 ) &3 ; nregs = ((insn >>8 ) &3 ) +1 ; - stride = (insn & (1 <<5 )) ?2 :1 ; +if (nregs ==1 ) { + stride =0 ; + }else { + stride = (insn & (1 <<5 )) ?2 :1 ; + }load_reg_var (s, addr, rn);for (reg =0 ; reg < nregs; reg++) {switch (size) {
@@ -3819,7 +3823,12 @@ static int disas_neon_ls_insn(CPUState * env, DisasContext *s, uint32_t insn)default :/* Avoid compiler warnings. */ abort (); } -tcg_gen_addi_i32 (addr, addr,1 << size); +if (stride && reg < nregs -1 ) { +tcg_gen_addi_i32 (addr, addr,1 << size); + }else if (!stride) { +tcg_gen_st_i32 (tmp, cpu_env,neon_reg_offset (rd +1 ,0 )); +tcg_gen_st_i32 (tmp, cpu_env,neon_reg_offset (rd +1 ,1 )); + } tmp2 =new_tmp ();tcg_gen_mov_i32 (tmp2, tmp);neon_store_reg (rd,0 , tmp2);
Signature · 1 line
1.6.5
PATCH 42/48 target-arm: fix signed narrow 64->32 operation
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
target-arm/neon_helper.c +6 -2
@@ -1183,9 +1183,13 @@ uint32_t HELPER(neon_narrow_sat_u32)(CPUState *env, uint64_t x)uint32_t HELPER (neon_narrow_sat_s32 )(CPUState *env,uint64_t x) { -if ((int64_t )x != (int32_t )x) { +if ((int64_t )x <-2147483648ll ) {SET_QC (); -return (x >>63 ) ^0x7fffffff ; +return 0x80000000 ; + } +if ((int64_t )x >2147483647ll ) { +SET_QC (); +return 0x7fffffff ; }return x; }
Signature · 1 line
1.6.5
PATCH 43/48 target-arm: fix neon vq(r)dmulh.s16 instructions
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
target-arm/neon_helper.c +2 -1
@@ -946,8 +946,9 @@ uint32_t HELPER(neon_cnt_u8)(uint32_t x)if ((tmp ^ (tmp <<1 )) &SIGNBIT ) { \SET_QC (); \ tmp = (tmp >>31 ) ^ ~SIGNBIT ; \ + }else { \ + tmp <<=1 ; \ } \ - tmp <<=1 ; \if (round) { \int32_t old = tmp; \ tmp +=1 <<15 ; \
Signature · 1 line
1.6.5
PATCH 44/48 target-arm: fix neon v(q)(r)shrn instructions
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 23 +++++++++++++++++++++-- target-arm/translate.c | 19 ++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-)
target-arm/neon_helper.c +21 -2
@@ -509,9 +509,28 @@ uint64_t HELPER(neon_shl_s64)(uint64_t valop, uint64_t shiftop) }}while (0 ) NEON_VOP(rshl_s8, neon_s8, 4) NEON_VOP(rshl_s16, neon_s16, 2) -NEON_VOP(rshl_s32, neon_s32, 1)#undef NEON_FN +uint32_t HELPER (neon_rshl_s32 )(uint32_t valop,uint32_t shiftop) +{ +int8_t shift =(int8_t )shiftop; +int32_t val = valop; +if (shift >=32 ) { + val =0 ; + }else if (shift <-32 ) { + val >>=31 ; + }else if (shift ==-32 ) { + val >>=31 ; + val++; + val >>=1 ; + }else if (shift <0 ) { + val = ((int64_t )val + (1 << (-1 - shift))) >> -shift; + }else { + val <<= shift; + } +return val; +} +uint64_t HELPER (neon_rshl_s64 )(uint64_t valop,uint64_t shiftop) {int8_t shift = (int8_t )shiftop;
@@ -520,7 +539,7 @@ uint64_t HELPER(neon_rshl_s64)(uint64_t valop, uint64_t shiftop) val =0 ; }else if (shift <-64 ) { val >>=63 ; - }else if (shift ==-63 ) { + }else if (shift ==-64 ) { val >>=63 ; val++; val >>=1 ;
target-arm/translate.c +14 -5
@@ -4781,6 +4781,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)abort (); } +TCGV_UNUSED (tmp5);for (pass =0 ; pass <2 ; pass++) {if (size ==3 ) {neon_load_reg64 (cpu_V0, rm + pass);
@@ -4812,18 +4813,26 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)dead_tmp (tmp);dead_tmp (tmp3); } - tmp =new_tmp (); + tmp4 =new_tmp ();if (op ==8 ) {if (u) {/* VQSHRUN / VQRSHRUN */ -gen_neon_unarrow_sats (size -1 , tmp, cpu_V0); +gen_neon_unarrow_sats (size -1 , tmp4, cpu_V0); }else {/* VSHRN / VRSHRN */ -gen_neon_narrow (size -1 , tmp, cpu_V0); +gen_neon_narrow (size -1 , tmp4, cpu_V0); } }else {/* VQSHRN / VQRSHRN */ -gen_neon_narrow_satu (size -1 , tmp, cpu_V0); +if (u) { +gen_neon_narrow_satu (size -1 , tmp4, cpu_V0); + }else { +gen_neon_narrow_sats (size -1 , tmp4, cpu_V0); + } + } +if (!pass) { + tmp5 = tmp4; } -neon_store_reg (rd, pass, tmp); }/* for pass */ +neon_store_reg (rd,0 , tmp5); +neon_store_reg (rd,1 , tmp4);if (size ==3 ) {tcg_temp_free_i64 (tmp64); }else {
Signature · 1 line
1.6.5
PATCH 45/48 target-arm: fix neon vcvt fixed-point
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/translate.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
target-arm/translate.c +5 -4
@@ -4874,20 +4874,21 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)if (!(insn & (1 <<21 )) || (q && ((rd | rm) &1 ))) {return 1 ; } + shift =64 - ((insn >>16 ) &0x3f );for (pass =0 ; pass < (q ?4 :2 ); pass++) {tcg_gen_ld_f32 (cpu_F0s, cpu_env,neon_reg_offset (rm, pass));if (op &1 ) {if (u) { -gen_vfp_ulto (0 , shift); +gen_vfp_toul (0 , shift); }else { -gen_vfp_slto (0 , shift); +gen_vfp_tosl (0 , shift); } }else {if (u) { -gen_vfp_toul (0 , shift); +gen_vfp_ulto (0 , shift); }else { -gen_vfp_tosl (0 , shift); +gen_vfp_slto (0 , shift); } } tcg_gen_st_f32(cpu_F0s, cpu_env,
Signature · 1 line
1.6.5
PATCH 46/48 target-arm: fix neon vrsqrts instruction
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/helper.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
target-arm/helper.c +2 -1
@@ -2687,8 +2687,9 @@ float32 HELPER(recps_f32)(float32 a, float32 b, CPUState *env)float32 HELPER (rsqrts_f32 )(float32 a,float32 b,CPUState *env) {float_status *s = &env->vfp.fp_status; +float32 two =int32_to_float32 (2 , s);float32 three =int32_to_float32 (3 , s); -return float32_sub (three,float32_mul (a, b, s), s); +return float32_div (float32_sub (three,float32_mul (a, b, s), s), two, s); }/* NEON helpers. */
Signature · 1 line
1.6.5
PATCH 47/48 target-arm: fix neon vshll (shift < max)
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- target-arm/neon_helper.c | 1 - target-arm/translate.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
target-arm/neon_helper.c +0 -1
@@ -1484,7 +1484,6 @@ uint64_t HELPER(neon_negl_u16)(uint64_t x)return result; } -#include <stdio.h> uint64_t HELPER (neon_negl_u32 )(uint64_t x) {uint32_t low = -x;
target-arm/translate.c +2 -2
@@ -4855,7 +4855,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn)/* The shift is less than the width of the source type, so we can just shift the whole register. */ tcg_gen_shli_i64 (cpu_V0, cpu_V0, shift); -if (size <2 || !u) { +if (size <2 ) {uint64_t imm64;if (size ==0 ) { imm = (0xffu >> (8 - shift));
@@ -4864,7 +4864,7 @@ static int disas_neon_data_insn(CPUState * env, DisasContext *s, uint32_t insn) imm =0xffff >> (16 - shift); } imm64 = imm | (((uint64_t )imm) <<32 ); -tcg_gen_andi_i64 (cpu_V0, cpu_V0, imm64); +tcg_gen_andi_i64 (cpu_V0, cpu_V0, ~imm64); } }neon_store_reg64 (cpu_V0, rd + pass);
Signature · 1 line
1.6.5
PATCH 48/48 usb: fix -usbdevice option handling with no parameters
In reply to Riku VoipioFrom: Juha Riihimäki <[email protected]>
--- hw/usb-bus.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/usb-bus.c +1 -1
@@ -299,7 +299,7 @@ USBDevice *usbdevice_create(const char *cmdline) }if (!usb->usbdevice_init) { -if (params) { +if (params && *params) {error_report ("usbdevice %s accepts no params" , driver);return NULL ; }
Signature · 1 line
1.6.5
Quoted 5 lines
This set of patches is quite raw, intended mostly just for discussion at this point. We'd like to identify the unobjectionable patches and "ready for upstream with minor fixes" patches first, so we can send them for a pull request. After which we can start diving more deeply into restructuring the remaining patches.
Your first step should be to split out unrelated changes. You're unlikely to get any interest in a 48-patch series that contains a load of random crap.
Paul