Compare commits

...
271 Commits
Author SHA1 Message Date
(no author) ea75c7d8c1 This commit was manufactured by cvs2svn to create tag
'release_0_7_0'.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/tags/release_0_7_0@1420 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:49:24 +00:00
bellard 43095f3198 tarbin fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1419 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:49:23 +00:00
bellard 5899f386ba ARM thumb fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1418 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:25:20 +00:00
bellard 6a0f9e82c5 Virtual PC read-only disk image support (Alex Beregszaszi)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1417 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:17:58 +00:00
bellard c2d551ff5a ARM thumb disassembly (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1416 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:15:00 +00:00
bellard 192c7bd927 ARM Thumb syscalls (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1415 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 20:11:21 +00:00
bellard b48a8bb6b1 win32 fix (Filip Navara)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1414 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 19:55:58 +00:00
bellard e5484d3391 BSD fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1413 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-27 19:55:01 +00:00
bellard 7674e7bf08 BSD cdrom device access fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1412 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:59:26 +00:00
bellard c747cd1fa2 raw CDROM access for windows (Filip Navara)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1411 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:47:02 +00:00
bellard 11650e3638 clean target update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1410 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:39:25 +00:00
bellard a8753c3466 Bochs disk image support (Alex Beregszaszi)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1409 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:34:00 +00:00
bellard c99280bc29 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1408 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:25:15 +00:00
bellard 905f20b151 fixed gdb error reporting (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1407 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:09:55 +00:00
bellard ff1afc72f2 VMDK4 write support - fixed packing of VMDK4Header (Filip Navara)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1406 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:08:00 +00:00
bellard 6d82d04a49 proll update: IDE HDD/CD support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1405 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 21:02:48 +00:00
bellard ad81218e40 depth=24 write mask fix (Volker Ruppert)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1404 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:49:17 +00:00
bellard e4afee9716 cosmetics
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1403 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:46:24 +00:00
bellard d0b3e73525 SYS_SEEK fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1402 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:44:10 +00:00
bellard e90096763d report user mode gdb exit codes (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1401 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:42:36 +00:00
bellard 43fb823b5f removed switches in op.c (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1400 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:38:17 +00:00
bellard e50e6a2019 better arm conditionnal execution implementation (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1399 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:36:11 +00:00
bellard 430116a1d8 debug fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1398 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:35:05 +00:00
bellard 1026f1336b win32 conf fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1397 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:34:45 +00:00
bellard e362b55a32 fixed clean target
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1396 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 20:34:26 +00:00
bellard fc9f715de8 i386-user compile fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1395 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-26 19:33:35 +00:00
bellard b359d4e7e4 fixed zero ss selector case in x86_64 emulation
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1394 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 18:04:33 +00:00
bellard c45b3c0e1b efer is present even in legacy mode
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1393 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 18:03:37 +00:00
bellard e04f40b5aa compatibility fix with kqemu-x86_64
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1392 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 18:02:38 +00:00
bellard dff293e751 qemu code is not ready to handle these registers
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1391 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 18:01:56 +00:00
bellard b3180cdc01 MMU fix (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1390 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 10:08:19 +00:00
bellard 4162503368 removed RS_CONTINUE 'state'
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1389 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-24 10:07:11 +00:00
bellard 6bae7ed8b9 informative message about low memory on /dev/shm
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1388 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 20:44:25 +00:00
bellard 74c161bd17 Fix dumping of arm registers (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1387 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:46:03 +00:00
bellard 08e489025b removed obsolete S3 VGA code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1386 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:43:45 +00:00
bellard c326e0afec cygwin host support (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1385 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:30:28 +00:00
bellard 8aaca4c0b4 ARM singlestep support (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1384 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:27:52 +00:00
bellard a4f81979e8 ARM "Angel" semihosting syscalls (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1383 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:25:41 +00:00
bellard 89344d5ad7 arm vfp fcmp and fcmpe instructions fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1382 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:21:13 +00:00
bellard da9b266bb8 PREP machines have two IO mappings.
This patch adds support for non-contiguous IO map, which is used by
OS/2.
It also adds the missing legacy IO ports for the PREP PCI bridge and
changes CPU PVR from 74x/75x to 604 to make OS/2 happy.
(Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1381 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:18:54 +00:00
bellard dccfafc4e1 This patch fixes two bugs in cuda emulation:
- the CUDA timer is always triggered twice, with current code
- SET_TIME command is supposed to send back a 7 bytes packet
(Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1380 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:16:54 +00:00
bellard 111bfab3b5 This patch adds little-endian mode support to PPC emulation.
This is needed by OS/2 and Windows NT and some programs like VirtualPC.
This patch has been tested using OS/2 bootloader (thanks to Tero
Kaarlela).
(Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1379 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:16:07 +00:00
bellard c7d344af8f - remove the ugly "stop" pseudo-opcode.
- fix fsqrt instruction (there's no fsqrt.).
- floating point load and store are not integer instructions.
- wrong opcode for dcba instructions.
(Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1378 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:05:46 +00:00
bellard e1a2849c90 ARM syscall fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1377 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 18:01:57 +00:00
bellard e06e5259c3 lretq, lcall and ljmp tests in 64 bit mode
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1376 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:54:59 +00:00
bellard aba9d61e34 lcall and ljmp fixes in 64 bit mode - sysret fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1375 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:53:12 +00:00
bellard a6f379881e return model id in cpuid for x86_64
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1374 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:50:32 +00:00
bellard f419b32104 sysret fix - better cpuid support - lcall support for x86_64 - efer access in i386 emulation
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1373 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:48:47 +00:00
bellard 8d9bfc2b48 enable EFER usage in i386 emulation - more cpuid bits
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1372 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:46:55 +00:00
bellard c28e951fc7 x86_64 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1371 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:45:43 +00:00
bellard 07f4ddbf7e kqemu build fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1370 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-23 17:44:28 +00:00
bellard 5516d670f6 make lsl, lar verr and verw exception safe
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1369 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 19:50:21 +00:00
bellard cc6f538bf6 verr and verw eflags opt fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1368 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 19:49:02 +00:00
bellard 1fddef4b1b gdb support for user mode (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1367 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 19:16:13 +00:00
bellard 6e4255f6a6 windows support for kqemu (Filip Navara)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1366 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 18:33:47 +00:00
bellard 74ffc7729e removed unused stuff
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1365 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 18:32:14 +00:00
bellard e3a4e4b643 destination write mask support, fixed banked memory access, read-only access for bus type in SR 0x17 (Volker Ruppert)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1364 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-17 17:56:18 +00:00
bellard 40545f84cf packet fix for for netware 3.11 (initial patch by Mark Jonckheere) - security bug fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1363 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-10 14:51:41 +00:00
bellard d39c0b990a fixed MMU bug on code page boundary
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1362 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-10 14:40:58 +00:00
bellard 2b03a7a5bc renamed set_bit to cow_set_bit (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1361 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-10 14:39:05 +00:00
bellard b8076a748d ia64 host support (David Mosberger)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1360 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 22:20:31 +00:00
bellard 7a674b1363 accept more disk image extensions (David Still)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1359 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 20:36:50 +00:00
bellard 5a246934eb open the dialog box if an image was not selected from command-line (Pierre d'Herbemont)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1358 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 20:35:06 +00:00
bellard b7e2c11dbd helper_lret_protected fix for kqemu (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1357 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 20:33:08 +00:00
bellard 9d60cac01f ARM double ordering fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1356 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 19:55:52 +00:00
bellard 8e96005d86 VFP register ordering (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1355 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 19:42:46 +00:00
bellard 85d8be6bf2 Open Hack'Ware version 0.4.1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1354 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 23:06:54 +00:00
bellard c194feda5f IDE irq fix (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1353 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 23:03:38 +00:00
bellard 7e6c3f34bf new bochs BIOS - 16 bit APM support (initial patch by Struan Bartlett)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1352 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 23:01:24 +00:00
bellard 39d2243955 PCI irq in sync with new Bochs BIOS
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1351 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 23:00:25 +00:00
bellard 66321a11a4 sparc update (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1350 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:47:48 +00:00
bellard c44644bb96 update (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1349 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:45:26 +00:00
bellard ed91024191 defaut case (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1348 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:44:48 +00:00
bellard b81b3b10aa swap serial ports (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1347 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:43:37 +00:00
bellard 8be1f5c889 keyboard support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1346 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:42:35 +00:00
bellard d827220bbf use standard TCX display size for sparc
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1345 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:32:23 +00:00
bellard 2f275b8f9f SCSI support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1344 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-06 20:31:50 +00:00
bellard c3278b7bf0 sparc exception fix (we go up to the shell prompt)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1343 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-20 12:43:29 +00:00
bellard 86bd2ca58a NaN tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1342 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-20 10:40:15 +00:00
bellard 8422b11337 NaN support in FPU comparisons
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1341 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-20 10:39:24 +00:00
bellard b7a100da9c removed extern inline (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1340 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-20 10:34:22 +00:00
bellard b109f9f867 more native FPU comparison functions - native FPU remainder
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1339 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-20 10:33:58 +00:00
bellard 1d6bda3561 added abs, chs and compare functions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1338 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 18:52:29 +00:00
bellard 53cd663792 soft float support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1337 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 18:50:23 +00:00
bellard 7a0e1f41ce soft float support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1336 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 17:01:47 +00:00
bellard 4ecc31906d fpu fixes (Jocelyn Mayer) - soft float support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1335 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 17:01:22 +00:00
bellard 4c2e770f37 fpu init fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1334 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 16:56:51 +00:00
bellard 2049521883 use the generic soft float code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1333 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 16:55:58 +00:00
bellard 158142c2c2 soft float support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1332 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 16:54:06 +00:00
bellard 4f716dc681 avoid redefinition problems
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1331 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 16:53:06 +00:00
bellard 539827ecf5 fpu init fix (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1330 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 16:51:00 +00:00
bellard 6eea2b1b81 add missing FORCE_RET (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1329 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 09:55:49 +00:00
bellard ae200d1062 GOTO_LABEL_PARAM for ARM
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1328 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 09:53:38 +00:00
bellard ba68055eab ARM host configure tweaks (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1327 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 09:49:52 +00:00
bellard 6f7e9aec5e sparc fixes (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1326 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 09:43:36 +00:00
bellard b756921ad1 sparc update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1325 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-13 09:43:05 +00:00
bellard 313132138a x86_64 fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1324 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-03 01:14:55 +00:00
bellard d057099aa8 cmov fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1323 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-03 01:13:19 +00:00
bellard da4dbf742d cocoa tiny fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1322 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-02 22:22:43 +00:00
bellard 776f2227f6 x86_64 test program
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1321 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-02 22:19:12 +00:00
bellard d785e6be4d x86_64 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1320 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 22:33:42 +00:00
bellard 5e83e8e3e7 SUSE fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1319 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 22:32:06 +00:00
bellard 24b55b9650 disabled obsolete static SDL warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1318 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 22:30:41 +00:00
bellard 232ba5ab2e update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1317 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 22:30:05 +00:00
bellard b6f479d355 -append support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1316 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:51:04 +00:00
bellard 1289f43ab1 Windows keys support with keymaps
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1315 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:43:42 +00:00
bellard 76472292e4 escape support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1314 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:40:00 +00:00
bellard 5b0753e0d8 initial Cocoa support (Pierre d'Herbemont)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1313 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:37:28 +00:00
bellard 157777ef3e Samba 3 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1312 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:28:45 +00:00
bellard f94daedd27 more explicit message
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1311 c046a42c-6fe2-441c-8c8c-71466251a162
2005-03-01 21:28:22 +00:00
bellard 6df700c206 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1310 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-22 19:43:42 +00:00
bellard b7bcbe9524 ARM VFP support (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1309 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-22 19:27:29 +00:00
bellard 55754d9ef2 MMU fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1308 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-22 19:14:33 +00:00
bellard afc7df1148 PSR.PS fix (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1307 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-22 19:08:57 +00:00
bellard 713c45faf8 initrd support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1306 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-22 19:08:41 +00:00
bellard 0b9dc5e4c3 loop insn fix for non x86 hosts
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1305 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-21 20:23:59 +00:00
bellard 194884dd6f win32 + Mac OS X compile fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1304 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-21 20:10:36 +00:00
bellard 91aa5d4975 Mac OS X fix (Jonas Maebe)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1303 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-21 19:53:34 +00:00
bellard 6f2f2b2489 removed all references to KQEMU to comply with the Savannah rules
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1302 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-20 19:09:44 +00:00
bellard 1d6e34fd37 sparc Linux works better with NWINDOWS = 8
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1301 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-19 17:26:37 +00:00
bellard 2623cbaf1a fixed handling of sparc register window exceptions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1300 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-19 17:25:31 +00:00
bellard a20b552469 suppressed sparc64 targets as they are far from being usable
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1299 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-19 17:24:28 +00:00
bellard f512c6fb6e update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1298 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 23:06:39 +00:00
bellard 3cc6237083 ppc fixes (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1297 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 23:06:19 +00:00
bellard c4decf377c ppc fixes (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1296 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 22:59:52 +00:00
bellard 3988e8977b ADB reset support (Joceylin Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1295 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 22:58:51 +00:00
bellard 7483750d7d sparc fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1294 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 22:55:43 +00:00
bellard 61ff6f58e9 sparc sigsegv support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1293 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-15 22:54:53 +00:00
bellard 0bee699e1d fixed jmpl, rett and call
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1292 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-13 20:11:30 +00:00
bellard 878d3096d2 sparc fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1291 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-13 19:02:42 +00:00
bellard 1a0c3292b5 sparc fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1290 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-13 19:02:07 +00:00
bellard 824d560f09 fixed kqemu config
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1289 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-12 18:58:00 +00:00
bellard 580a5e27c6 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1288 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-12 15:16:03 +00:00
bellard 0443eaf6ae update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1287 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-12 15:02:03 +00:00
bellard 9117a4ab91 disable USE_KQEMU if no source
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1286 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-12 14:50:42 +00:00
bellard 441c72ba15 kqemu is an external project
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1285 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-12 14:45:23 +00:00
bellard bf079a1e70 enabled MMX, PAE and SEP
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1284 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 22:06:29 +00:00
bellard 9df217a317 kqemu support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1283 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 22:05:51 +00:00
bellard 92a31b1fff 64 bit support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1282 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 22:00:52 +00:00
bellard 0a962c0276 dirty flag changes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1281 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 22:00:27 +00:00
bellard d993e0260b -no-kqemu option
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1280 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 22:00:06 +00:00
bellard 49b470eb96 shared pages memory allocation
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1279 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 21:59:25 +00:00
bellard c9ec1fe474 kqemu support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1278 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 21:55:30 +00:00
bellard e3086fbf8f kqemu support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1277 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 21:48:51 +00:00
bellard 7c3fc84d86 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1276 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-10 21:46:47 +00:00
bellard d7ce296f57 power down support + date fix (Thayne Harbaugh)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1275 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-09 00:07:08 +00:00
bellard f8407028b4 spelling fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1274 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-09 00:01:34 +00:00
bellard 18fba28c95 ppc fixes - gcc 3.4 compile fix (initial patch by Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1273 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-08 21:24:36 +00:00
bellard 68016c627b SIGSEGV signals for ARM and SPARC
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1272 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 23:12:27 +00:00
bellard 9d89330183 clean up - comments
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1271 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 23:10:53 +00:00
bellard b8a9e8f133 initial user mmu support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1270 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 23:10:07 +00:00
bellard 4955a2cd16 test and set fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1269 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 14:09:05 +00:00
bellard a8d3431ae9 endianness fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1268 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 12:43:57 +00:00
bellard 7ff4d2180b CF generator for constant operands
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1267 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 12:42:35 +00:00
bellard e88de09993 ARM FPA get_user/put_user fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1266 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 12:35:39 +00:00
bellard 832ed0fa34 ARM FPU endianness fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1265 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-07 12:35:16 +00:00
bellard 78573df6b2 SBCS fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1264 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-02 20:43:01 +00:00
bellard 9f0777ed88 ARM SMC workaround
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1263 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-02 20:42:01 +00:00
bellard 6bae70713c sparc fix (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1262 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-02 20:40:17 +00:00
bellard 90f11f95fe pusha, popa and enter fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1261 c046a42c-6fe2-441c-8c8c-71466251a162
2005-02-01 20:25:03 +00:00
bellard fa15e030bf 64 bit disas fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1260 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-31 23:32:31 +00:00
bellard 1ef3868708 x86_64 call Ev fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1259 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-31 23:31:02 +00:00
bellard 99c475abf1 armv5te support (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1258 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-31 20:45:13 +00:00
bellard dfe86665b8 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1257 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 23:04:39 +00:00
bellard a315a14547 initial sparc64 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1256 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:59:18 +00:00
bellard 4fa5d7722d fixed sparc cpu load/save
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1255 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:57:54 +00:00
bellard 64b3ab2439 sparc64 support (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1254 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:43:42 +00:00
bellard c1135f6152 removed debug code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1253 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:41:54 +00:00
bellard 3a5c313852 64 bit fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1252 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:39:56 +00:00
bellard af7bf89b1f initial sparc64 support - sparc fixes (Blue Swirl)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1251 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-30 22:39:04 +00:00
bellard 49be803015 endianness fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1250 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-28 22:40:22 +00:00
bellard 8df1cd076c physical memory access functions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1249 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-28 22:37:22 +00:00
bellard bb05683b12 flush TLBs at cpu reset
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1248 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-28 00:01:00 +00:00
bellard 662f3c86ec ram dirty flag handling fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1247 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-28 00:00:27 +00:00
bellard 5416376efe ram dirty flag update fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1246 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-27 23:58:13 +00:00
bellard f34c9d6f10 mouse reset fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1245 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-27 22:32:51 +00:00
bellard e3db7226b4 JIT statistics
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1244 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-26 22:00:47 +00:00
bellard d79284e07a i386 linux 2.6 timer fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1243 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-26 21:56:26 +00:00
bellard 9191d4d19f Mac OS X fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1242 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-26 21:30:57 +00:00
bellard 0b74ed78ef mode 4 and 5 write fix (Magnus Damn)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1241 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-26 19:50:16 +00:00
bellard f51589dad5 Support resolving addresses in PAE mode in cpu_get_phys_page_debug
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1240 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-25 22:35:05 +00:00
bellard 82e41634cd avoid empty op
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1239 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:55:36 +00:00
bellard bd3fae3df6 removed warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1238 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:48:05 +00:00
bellard 9230e66e5c CR8 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1237 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:46:56 +00:00
bellard 0523c6b7c5 FORCE_RET() fixes - fpu fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1236 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:46:31 +00:00
bellard 39c61f49f4 CR8 support - FORCE_RET() fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1235 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:46:09 +00:00
bellard 4d6b6c0aec more fpu functions - x86_64 fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1234 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:45:23 +00:00
bellard 79f91c27ba more fpu functions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1233 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:44:55 +00:00
bellard dc9543dc22 removed warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1232 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:42:59 +00:00
bellard bef79c34a2 support for dyngen labels on more hosts
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1231 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:42:06 +00:00
bellard 83b34f8b57 more consistent type for size (still a bug in wrapping)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1230 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-23 20:26:30 +00:00
bellard 18a6d284ad enabled wheel mouse support (initial patch by Volker Ruppert)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1229 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-17 22:32:23 +00:00
bellard ada89ce61b enabled wheel mouse support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1228 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-17 22:31:41 +00:00
bellard b328f873ab gdb M packet parsing fix (Thomas Petazzoni)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1227 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-17 22:03:16 +00:00
bellard ca954f6d90 x86_64 fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1226 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-16 23:35:43 +00:00
bellard 97ed14aead fix shufps/shufpd tests - added maskmov tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1225 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-16 01:09:01 +00:00
bellard d52cf7a64a sse fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1224 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-16 01:07:28 +00:00
bellard bb2d531499 -nographic fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1223 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-15 21:50:11 +00:00
bellard c82913f742 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1222 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-15 12:03:28 +00:00
bellard 6508fe59e0 PC parallel port support (Mark Jonckheere)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1221 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-15 12:02:56 +00:00
bellard e5843bc816 enable MMX for x86_64 too
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1220 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-12 22:46:19 +00:00
bellard d3c617219b fxsr fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1219 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-12 22:41:17 +00:00
bellard 735a8fd38e fixed performance regression
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1218 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-12 22:36:43 +00:00
bellard 1bde465e06 sse fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1217 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-12 22:34:47 +00:00
bellard a4682cc20a fxsr test
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1216 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-12 22:33:30 +00:00
bellard 839fa98885 moved ASM_NAME
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1215 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:23:48 +00:00
bellard 7c2e623559 removed debug code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1214 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:20:21 +00:00
bellard 977d5710e6 DATA_MASK fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1213 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:20:04 +00:00
bellard 34444131ad windows header fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1212 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:19:34 +00:00
bellard 8adbc566c9 typo
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1211 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:19:18 +00:00
bellard 5327cf489f better target_list logic
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1210 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-10 23:18:50 +00:00
bellard e995898b06 removed trace
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1209 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-09 00:42:09 +00:00
bellard 9df8aa4abb win32 fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1208 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-09 00:39:12 +00:00
bellard ae063a68dc generalized use of GOTO_TB() macro
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1207 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-09 00:07:04 +00:00
bellard 8636b5d873 compilation fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1206 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-09 00:03:14 +00:00
bellard 664e0f195a MMX/SSE support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1205 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-08 18:58:29 +00:00
bellard 085339a12b MMX/SSE test
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1204 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-08 18:54:41 +00:00
bellard abd2c7dc9c update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1203 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-06 20:50:00 +00:00
bellard a8ede8ba8b div64 fix - raise_interrupt() fix - SSE fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1202 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-06 20:46:58 +00:00
bellard 826461bb40 big endian SSE fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1201 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-06 20:44:11 +00:00
bellard 02536f8b1f x86_64 save/restore
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1200 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-06 20:43:38 +00:00
bellard 06c2f5066e syscall insn fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1199 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-04 01:06:58 +00:00
bellard bdfaf503dc update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1198 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:51:01 +00:00
bellard 14ce26e755 x86_64 target support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1197 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:50:08 +00:00
bellard c46878786a labels support in dyngen
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1196 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:44:44 +00:00
bellard 0fa85d43d4 64 bit target support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1195 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:43:32 +00:00
bellard b4ff598727 removed warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1194 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:43:09 +00:00
bellard 526ff7de82 removed warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1193 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:41:14 +00:00
bellard 995179f1cc gcc 2.x fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1192 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:39:08 +00:00
bellard 0b0babc623 x86_64 target support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1191 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:38:40 +00:00
bellard 20f3228237 initial x86_64 support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1190 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:36:21 +00:00
bellard c27004ec78 64 bit target support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1189 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:35:10 +00:00
bellard 612458f544 removed warning
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1188 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:34:06 +00:00
bellard 80a9d03503 64 bit target fixes - removed warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1187 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:31:27 +00:00
bellard 75598f6131 APIC support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1186 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:30:09 +00:00
bellard 4f7631cfb5 initial APIC support (only for x86_64 target now)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1185 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:28:51 +00:00
bellard 62a46c6168 suppressed warnings in 64 bit case
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1184 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:28:27 +00:00
bellard 574bbf7b0d initial APIC support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1183 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:27:31 +00:00
bellard acae4681ae fixed imul im test - added TEST_VM86 define for x86_64 tests
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1182 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 23:25:56 +00:00
bellard 42ad6ae973 'syscall' syscall
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1181 c046a42c-6fe2-441c-8c8c-71466251a162
2005-01-03 22:48:11 +00:00
bellard 808c4954bf big endian ARM support (Lennert Buytenhek)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1180 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-19 23:33:47 +00:00
bellard e80cfcfc88 SPARC merge
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1179 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-19 23:18:01 +00:00
bellard 9772c73bbc fixed ins in case of page fault
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1178 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-19 23:03:29 +00:00
bellard de06c511ff win32 qcow fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1177 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-19 20:57:26 +00:00
bellard bc7712a4ac update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1176 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-13 19:38:08 +00:00
bellard 4ca0074c8c no need to use -k for Windows
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1175 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-12 22:20:04 +00:00
bellard fed4a9adc0 keymap install fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1174 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-12 22:18:34 +00:00
bellard 3d11d0eb33 keymaps support (initial patch by Johannes Schindelin)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1173 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-12 16:56:30 +00:00
bellard 7b91a17212 slirp fix for -smb command (Initial patch by Juergen Keil)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1172 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-12 11:45:10 +00:00
bellard 585d0ed98b .dmg disk image format support (Johannes Schindelin)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1171 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-12 11:24:44 +00:00
bellard a483b654b5 updated guest kernel patch for qemu-fast (Martin Koniczek)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1170 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-08 23:48:11 +00:00
bellard 6a78ece5c5 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1169 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-08 23:47:30 +00:00
bellard 1e8d4eec48 more complete ARM shift fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1168 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-08 23:40:14 +00:00
bellard 88920f344d ARM shift fix (Paul Brook)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1167 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-08 22:28:39 +00:00
bellard f7cce89882 -pidfile option
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1166 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-08 22:21:25 +00:00
bellard fe2cece60e audio fixes (malc)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1165 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-06 23:14:48 +00:00
bellard 978a66ff73 utimes() support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1164 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-06 22:58:05 +00:00
bellard f7806f9467 uname() fix (James Pellow)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1163 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-06 22:40:57 +00:00
bellard 45aea85cef FRSP fix (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1162 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-02 23:33:11 +00:00
bellard c451ee717a added WIN_IDLEIMMEDIATE and WIN_DIAGNOSE commands
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1161 c046a42c-6fe2-441c-8c8c-71466251a162
2004-12-02 20:20:21 +00:00
bellard a07167d3d4 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1160 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-30 23:41:30 +00:00
bellard 02cfb0b4f3 update to current vga bios version - Cirrus VGA: support for 1280x1024x[8,15,16] modes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1159 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-30 23:41:04 +00:00
bellard 3bc2175dcc socket send fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1158 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-24 20:39:26 +00:00
bellard bed5cd8048 update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1157 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-24 19:31:52 +00:00
bellard c169c906a3 added undocumented FPU ops support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1156 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-24 19:28:52 +00:00
bellard 17444c9c84 fixed invalid received length
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1155 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-21 20:02:08 +00:00
bellard bf1b938fce disable automatic BIOS translation if the logical disk geometry implies it
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1154 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-17 22:35:32 +00:00
bellard 46d4767d93 better BIOS ATA translation support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1153 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-16 01:45:27 +00:00
bellard e35c55fe38 windows install fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1152 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-16 01:44:03 +00:00
bellard acd935ef62 doc update - added qemu-img manual page
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1151 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-15 22:57:26 +00:00
bellard c9c0eae84e bitblt fix (aka Solaris display fix)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1150 c046a42c-6fe2-441c-8c8c-71466251a162
2004-11-15 21:43:57 +00:00
214 changed files with 36944 additions and 10765 deletions

No files matched your search

+6
View File
@@ -1,4 +1,5 @@
arm-user
armeb-user
config-host.*
dyngen
i386
@@ -10,6 +11,11 @@ qemu-doc.html
qemu-tech.html
qemu.1
qemu.pod
qemu-img.1
qemu-img.pod
sparc-user
qemu-img
sparc-softmmu
x86_64-softmmu
sparc64-user
sparc64-softmmu
+26
View File
@@ -1,3 +1,29 @@
version 0.7.0:
- better BIOS translation and HDD geometry auto-detection
- user mode networking bug fix
- undocumented FPU ops support
- Cirrus VGA: support for 1280x1024x[8,15,16] modes
- 'pidfile' option
- .dmg disk image format support (Johannes Schindelin)
- keymaps support (initial patch by Johannes Schindelin)
- big endian ARM support (Lennert Buytenhek)
- added generic 64 bit target support
- x86_64 target support
- initial APIC support
- MMX/SSE/SSE2/PNI support
- PC parallel port support (Mark Jonckheere)
- initial SPARC64 support (Blue Swirl)
- SPARC target boots Linux (Blue Swirl)
- armv5te user mode support (Paul Brook)
- ARM VFP support (Paul Brook)
- ARM "Angel" semihosting syscalls (Paul Brook)
- user mode gdb stub support (Paul Brook)
- Samba 3 support
- initial Cocoa support (Pierre d'Herbemont)
- generic FPU emulation code
- Virtual PC read-only disk image support (Alex Beregszaszi)
version 0.6.1:
- Mac OS X port (Pierre d'Herbemont)
+12
View File
@@ -0,0 +1,12 @@
The following points clarify the QEMU licenses:
1) The QEMU virtual CPU core library (libqemu.a) and the QEMU PC
system emulator are released under the GNU Lesser General Public
License.
2) The Linux user mode QEMU emulator is released under the GNU General
Public License.
3) QEMU is a trademark of Fabrice Bellard.
Fabrice Bellard.
+34 -14
View File
@@ -4,24 +4,28 @@ CFLAGS=-Wall -O2 -g -fno-strict-aliasing
ifdef CONFIG_DARWIN
CFLAGS+= -mdynamic-no-pic
endif
ifdef CONFIG_WIN32
CFLAGS+=-fpack-struct
endif
LDFLAGS=-g
LIBS=
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
TOOLS=qemu-img
TOOLS=qemu-img$(EXESUF)
ifdef CONFIG_STATIC
LDFLAGS+=-static
endif
DOCS=qemu-doc.html qemu-tech.html qemu.1
DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1
all: dyngen$(EXESUF) $(TOOLS) $(DOCS)
for d in $(TARGET_DIRS); do \
$(MAKE) -C $$d $@ || exit 1 ; \
done
ifdef CONFIG_KQEMU
ifdef CONFIG_WIN32
$(MAKE) -C kqemu -f Makefile.winnt
else
$(MAKE) -C kqemu
endif
endif
qemu-img: qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c
qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c
$(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS)
dyngen$(EXESUF): dyngen.c
@@ -30,11 +34,14 @@ dyngen$(EXESUF): dyngen.c
clean:
# avoid old build problems by removing potentially incorrect old files
rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS qemu.pod *~ */*~
rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS *.pod *~ */*~
$(MAKE) -C tests clean
for d in $(TARGET_DIRS); do \
$(MAKE) -C $$d $@ || exit 1 ; \
done
ifdef CONFIG_KQEMU
$(MAKE) -C kqemu clean
endif
distclean: clean
rm -f config-host.mak config-host.h
@@ -42,26 +49,33 @@ distclean: clean
rm -rf $$d || exit 1 ; \
done
KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
ar de en-us fi fr-be hr it lv nl pl ru th \
common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
install: all
mkdir -p "$(bindir)"
ifndef CONFIG_WIN32
install -m 755 -s $(TOOLS) "$(bindir)"
endif
mkdir -p "$(datadir)"
install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \
pc-bios/vgabios-cirrus.bin \
pc-bios/ppc_rom.bin \
pc-bios/proll.bin \
pc-bios/proll.elf \
pc-bios/linux_boot.bin "$(datadir)"
mkdir -p "$(docdir)"
install -m 644 qemu-doc.html qemu-tech.html "$(docdir)"
ifndef CONFIG_WIN32
mkdir -p "$(mandir)/man1"
install qemu.1 qemu-mkcow.1 "$(mandir)/man1"
install qemu.1 qemu-img.1 "$(mandir)/man1"
mkdir -p "$(datadir)/keymaps"
install -m 644 $(addprefix keymaps/,$(KEYMAPS)) "$(datadir)/keymaps"
endif
for d in $(TARGET_DIRS); do \
$(MAKE) -C $$d $@ || exit 1 ; \
done
ifdef CONFIG_KQEMU
cd kqemu ; ./install.sh
endif
# various test targets
test speed test2: all
@@ -78,6 +92,10 @@ qemu.1: qemu-doc.texi
./texi2pod.pl $< qemu.pod
pod2man --section=1 --center=" " --release=" " qemu.pod > $@
qemu-img.1: qemu-img.texi
./texi2pod.pl $< qemu-img.pod
pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
FILE=qemu-$(shell cat VERSION)
# tar release (use 'make -k tar' on a checkouted tree)
@@ -90,8 +108,10 @@ tar:
# generate a binary distribution
tarbin:
( cd / ; tar zcvf ~/qemu-$(VERSION)-i386.tar.gz \
$(bindir)/qemu $(bindir)/qemu-fast \
$(bindir)/qemu \
$(bindir)/qemu-system-ppc \
$(bindir)/qemu-system-sparc \
$(bindir)/qemu-system-x86_64 \
$(bindir)/qemu-i386 \
$(bindir)/qemu-arm \
$(bindir)/qemu-sparc \
@@ -101,11 +121,11 @@ tarbin:
$(datadir)/vgabios.bin \
$(datadir)/vgabios-cirrus.bin \
$(datadir)/ppc_rom.bin \
$(datadir)/proll.bin \
$(datadir)/proll.elf \
$(datadir)/linux_boot.bin \
$(docdir)/qemu-doc.html \
$(docdir)/qemu-tech.html \
$(mandir)/man1/qemu.1 $(mandir)/man1/qemu-mkcow.1 )
$(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1 )
ifneq ($(wildcard .depend),)
include .depend
+95 -29
View File
@@ -1,6 +1,13 @@
include config.mak
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
TARGET_BASE_ARCH:=$(TARGET_ARCH)
ifeq ($(TARGET_ARCH), x86_64)
TARGET_BASE_ARCH:=i386
endif
ifeq ($(TARGET_ARCH), sparc64)
TARGET_BASE_ARCH:=sparc
endif
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
ifdef CONFIG_USER_ONLY
@@ -8,12 +15,21 @@ VPATH+=:$(SRC_PATH)/linux-user
DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
endif
CFLAGS=-Wall -O2 -g -fno-strict-aliasing
#CFLAGS+=-Werror
LDFLAGS=-g
LIBS=
HELPER_CFLAGS=$(CFLAGS)
DYNGEN=../dyngen$(EXESUF)
# user emulator name
QEMU_USER=qemu-$(TARGET_ARCH)
ifeq ($(TARGET_ARCH),arm)
ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
QEMU_USER=qemu-armeb
else
QEMU_USER=qemu-arm
endif
else
QEMU_USER=qemu-$(TARGET_ARCH)
endif
# system emulator name
ifdef CONFIG_SOFTMMU
ifeq ($(TARGET_ARCH), i386)
@@ -44,6 +60,12 @@ endif # ARCH != i386
endif # TARGET_ARCH = i386
ifeq ($(TARGET_ARCH), x86_64)
ifdef CONFIG_SOFTMMU
PROGS+=$(QEMU_SYSTEM)
endif
endif # TARGET_ARCH = x86_64
ifeq ($(TARGET_ARCH), ppc)
ifeq ($(ARCH), ppc)
@@ -56,11 +78,11 @@ PROGS+=$(QEMU_SYSTEM)
endif
endif # ARCH = i386
ifeq ($(ARCH), amd64)
ifeq ($(ARCH), x86_64)
ifdef CONFIG_SOFTMMU
PROGS+=$(QEMU_SYSTEM)
endif
endif # ARCH = amd64
endif # ARCH = x86_64
endif # TARGET_ARCH = ppc
@@ -76,13 +98,20 @@ PROGS+=$(QEMU_SYSTEM)
endif
endif # ARCH = i386
ifeq ($(ARCH), amd64)
ifeq ($(ARCH), x86_64)
ifdef CONFIG_SOFTMMU
PROGS+=$(QEMU_SYSTEM)
endif
endif # ARCH = amd64
endif # ARCH = x86_64
endif # TARGET_ARCH = sparc
ifeq ($(TARGET_ARCH), sparc64)
ifdef CONFIG_SOFTMMU
PROGS+=$(QEMU_SYSTEM)
endif
endif # TARGET_ARCH = sparc64
endif # !CONFIG_USER_ONLY
ifdef CONFIG_STATIC
@@ -114,9 +143,9 @@ LDFLAGS+=-Wl,-shared
endif
endif
ifeq ($(ARCH),amd64)
ifeq ($(ARCH),x86_64)
OP_CFLAGS=$(CFLAGS) -falign-functions=0
LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
endif
ifeq ($(ARCH),ppc)
@@ -155,11 +184,13 @@ LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
endif
ifeq ($(ARCH),ia64)
CFLAGS += -mno-sdata
OP_CFLAGS=$(CFLAGS)
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
endif
ifeq ($(ARCH),arm)
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
endif
@@ -175,6 +206,7 @@ endif
ifeq ($(CONFIG_DARWIN),yes)
OP_CFLAGS+= -mdynamic-no-pic
LIBS+=-lmx
endif
#########################################################
@@ -199,16 +231,22 @@ ifeq ($(TARGET_ARCH), i386)
OBJS+= vm86.o
endif
ifeq ($(TARGET_ARCH), arm)
OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
endif
SRCS:= $(OBJS:.o=.c)
OBJS+= libqemu.a
# cpu emulator library
LIBOBJS=exec.o translate-all.o cpu-exec.o\
translate.o op.o
LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
translate.o op.o
ifdef CONFIG_SOFTFLOAT
LIBOBJS+=fpu/softfloat.o
else
LIBOBJS+=fpu/softfloat-native.o
endif
DEFINES+=-I$(SRC_PATH)/fpu
ifeq ($(TARGET_ARCH), i386)
LIBOBJS+=helper.o helper2.o
@@ -217,20 +255,28 @@ LIBOBJS+=translate-copy.o
endif
endif
ifeq ($(TARGET_ARCH), x86_64)
LIBOBJS+=helper.o helper2.o
endif
ifeq ($(TARGET_ARCH), ppc)
LIBOBJS+= op_helper.o helper.o
endif
ifeq ($(TARGET_ARCH), sparc)
ifeq ($(TARGET_BASE_ARCH), sparc)
LIBOBJS+= op_helper.o helper.o
endif
ifeq ($(TARGET_BASE_ARCH), arm)
LIBOBJS+= op_helper.o
endif
# NOTE: the disassembler code is only needed for debugging
LIBOBJS+=disas.o
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
USE_I386_DIS=y
endif
ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
USE_I386_DIS=y
endif
ifdef USE_I386_DIS
@@ -242,7 +288,7 @@ endif
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
LIBOBJS+=ppc-dis.o
endif
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
LIBOBJS+=sparc-dis.o
endif
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
@@ -252,6 +298,9 @@ endif
ifeq ($(ARCH),ia64)
OBJS += ia64-syscall.o
endif
ifdef CONFIG_GDBSTUB
OBJS+=gdbstub.o
endif
all: $(PROGS)
@@ -264,8 +313,8 @@ ifeq ($(ARCH),alpha)
endif
# must use static linking to avoid leaving stuff in virtual address space
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o
SOUND_HW = sb16.o
AUDIODRV = audio.o noaudio.o wavaudio.o
@@ -288,19 +337,19 @@ audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
LIBS += $(CONFIG_FMOD_LIB)
endif
ifeq ($(TARGET_ARCH), i386)
ifeq ($(TARGET_BASE_ARCH), i386)
# Hardware support
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
VL_OBJS+= cirrus_vga.o mixeng.o
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
endif
ifeq ($(TARGET_ARCH), ppc)
VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
endif
ifeq ($(TARGET_ARCH), sparc)
VL_OBJS+= sun4m.o tcx.o lance.o iommu.o sched.o m48t08.o magic-load.o timer.o
ifeq ($(TARGET_BASE_ARCH), sparc)
VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o fdc.o esp.o
endif
ifdef CONFIG_GDBSTUB
VL_OBJS+=gdbstub.o
@@ -308,6 +357,10 @@ endif
ifdef CONFIG_SDL
VL_OBJS+=sdl.o
endif
ifdef CONFIG_COCOA
VL_OBJS+=cocoa.o
COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
endif
ifdef CONFIG_SLIRP
DEFINES+=-I$(SRC_PATH)/slirp
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
@@ -329,11 +382,22 @@ ifndef CONFIG_WIN32
VL_LIBS=-lutil
endif
endif
ifdef TARGET_GPROF
vl.o: CFLAGS+=-p
VL_LDFLAGS+=-p
endif
ifeq ($(ARCH),ia64)
VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
endif
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
sdl.o: sdl.c
cocoa.o: cocoa.m
$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
sdl.o: sdl.c keymaps.c sdl_keysym.h
$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
sdlaudio.o: sdlaudio.c
@@ -350,7 +414,9 @@ libqemu.a: $(LIBOBJS)
translate.o: translate.c gen-op.h opc.h cpu.h
translate-all.o: translate-all.c op.h opc.h cpu.h
translate-all.o: translate-all.c opc.h cpu.h
translate-op.o: translate-all.c op.h opc.h cpu.h
op.h: op.o $(DYNGEN)
$(DYNGEN) -o $@ $<
@@ -367,15 +433,15 @@ op.o: op.c
helper.o: helper.c
$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
ifeq ($(TARGET_ARCH), i386)
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
ifeq ($(TARGET_BASE_ARCH), i386)
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
endif
ifeq ($(TARGET_ARCH), arm)
op.o: op.c op_template.h
endif
ifeq ($(TARGET_ARCH), sparc)
ifeq ($(TARGET_BASE_ARCH), sparc)
op.o: op.c op_template.h op_mem.h
endif
@@ -393,7 +459,7 @@ mixeng.o: mixeng.c mixeng.h mixeng_template.h
$(CC) $(DEFINES) -c -o $@ $<
clean:
rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
install: all
ifneq ($(PROGS),)
-58
View File
@@ -1,61 +1,3 @@
The QEMU x86 emulator
---------------------
INSTALLATION
------------
Type
./configure
make
to build qemu, qemu-CPU and libqemu.a (CPU is the name of the various
supported target CPUs).
Type
make install
to install QEMU in /usr/local
Tested tool versions
--------------------
In order to compile QEMU succesfully, it is very important that you
have the right tools. The most important one is gcc. I cannot guaranty
that QEMU works if you do not use a tested gcc version. Look at
'configure' and 'Makefile' if you want to make a different gcc
version work.
host gcc binutils glibc linux distribution
----------------------------------------------------------------------
x86 2.95.2 2.13.2 2.1.3 2.4.18
3.2 2.13.2 2.1.3 2.4.18
2.96 2.11.93.0.2 2.2.5 2.4.18 Red Hat 7.3
3.2.2 2.13.90.0.18 2.3.2 2.4.20 Red Hat 9
PowerPC 3.3 [4] 2.13.90.0.18 2.3.1 2.4.20briq
3.2
Alpha 3.3 [1] 2.14.90.0.4 2.2.5 2.2.20 [2] Debian 3.0
Sparc32 2.95.4 2.12.90.0.1 2.2.5 2.4.18 Debian 3.0
ARM 2.95.4 2.12.90.0.1 2.2.5 2.4.9 [3] Debian 3.0
[1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
for gcc version >= 3.3.
[2] Linux >= 2.4.20 is necessary for precise exception support
(untested).
[3] 2.4.9-ac10-rmk2-np1-cerf2
[4] gcc 2.95.x generates invalid code when using too many register
variables. You must use gcc 3.x on PowerPC.
Documentation
-------------
Read the documentation in qemu-doc.html.
Fabrice Bellard.
+1 -10
View File
@@ -1,20 +1,15 @@
short term:
----------
- debug option in 'configure' script + disable -fomit-frame-pointer
- Solaris display error with Cirrus VGA
(http://lists.gnu.org/archive/html/qemu-devel/2004-10/msg00390.html).
- Precise VGA timings for old games/demos (malc patch)
- merge PIC spurious interrupt patch
- merge VNC keyboard patch
- merge Solaris patch
- merge ARM patches + self modifying code patch (Paul Brook)
- warning for OS/2: must not use 128 MB memory
- warning for OS/2: must not use 128 MB memory (merge bochs cmos patch ?)
- config file (at least for windows/Mac OS X)
- commit message if execution of code in IO memory
- update doc: PCI infos.
- VNC patch + Synaptic patch.
- basic VGA optimizations
- test sysenter/sysexit and fxsr for L4 pistachio 686
- physical memory cache (reduce qemu-fast address space size to about 32 MB)
- better code fetch (different exception handling + CS.limit support)
- do not resize vga if invalid size.
@@ -38,7 +33,6 @@ short term:
ppc specific:
------------
- TLB invalidate not needed if msr_pr changes
- endianness bugs in do_load_fpscr and do_store_fpscr
- SPR_ENCODE() not useful
- enable shift optimizations ?
@@ -46,10 +40,8 @@ lower priority:
--------------
- more friendly BIOS (logo)
- int15 ah=86: use better timing
- HDD geometry in CMOS (not used except for very old DOS programs)
- suppress shift_mem ops
- fix some 16 bit sp push/pop overflow (pusha/popa, lcall lret)
- sysenter/sysexit emulation
- optimize FPU operations (evaluate x87 stack pointer statically)
- add IPC syscalls
- use -msoft-float on ARM
@@ -63,4 +55,3 @@ lower priority:
cases of self modifying code.
- use gcc as a backend to generate better code (easy to do by using
op-i386.c operations as local inline functions).
- add SSE2/MMX operations
+1 -1
View File
@@ -1 +1 @@
0.6.1
0.7.0
+1 -1
View File
@@ -151,7 +151,7 @@ struct external_lineno {
#define E_FILNMLEN 14 /* # characters in a file name */
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
struct external_syment
struct __attribute__((packed)) external_syment
{
union {
char e_name[E_SYMNMLEN];
+5
View File
@@ -1556,6 +1556,11 @@ print_insn_arm (pc, info)
}
is_thumb = force_thumb;
if (pc & 1)
{
is_thumb = 1;
pc &= ~(bfd_vma) 1;
}
#if 0
if (!is_thumb && info->symbols != NULL)
+3 -2
View File
@@ -367,14 +367,15 @@ static int dist (void *hw)
{
if (hw) {
return (((uint8_t *) hw - (uint8_t *) hw_voices)
/ audio_state.voice_size) + 1;
/ audio_state.drv->voice_size) + 1;
}
else {
return 0;
}
}
#define ADVANCE(hw) hw ? advance (hw, audio_state.voice_size) : hw_voices
#define ADVANCE(hw) \
((hw) ? advance (hw, audio_state.drv->voice_size) : hw_voices)
HWVoice *pcm_hw_find_any (HWVoice *hw)
{
-1
View File
@@ -86,7 +86,6 @@ typedef struct AudioState {
int fixed_channels;
int fixed_fmt;
int nb_hw_voices;
int voice_size;
int64_t ticks_threshold;
int freq_threshold;
void *opaque;
-2
View File
@@ -41,7 +41,6 @@ static void no_hw_run (HWVoice *hw)
{
NoVoice *no = (NoVoice *) hw;
int rpos, live, decr, samples;
uint8_t *dst;
st_sample_t *src;
int64_t now = qemu_get_clock (vm_clock);
int64_t ticks = now - no->old_ticks;
@@ -82,7 +81,6 @@ static int no_hw_write (SWVoice *sw, void *buf, int len)
static int no_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
{
NoVoice *no = (NoVoice *) hw;
hw->freq = freq;
hw->nchannels = nchannels;
hw->fmt = fmt;
+2 -2
View File
@@ -217,7 +217,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
static void sdl_hw_fini (HWVoice *hw)
{
ldebug ("sdl_hw_fini %d fixed=%d\n",
glob_sdl.initialized, audio_conf.fixed_format);
glob_sdl.initialized, audio_state.fixed_format);
sdl_close (&glob_sdl);
}
@@ -229,7 +229,7 @@ static int sdl_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
int shift;
ldebug ("sdl_hw_init %d freq=%d fixed=%d\n",
s->initialized, freq, audio_conf.fixed_format);
s->initialized, freq, audio_state.fixed_format);
if (nchannels != 2) {
dolog ("Bogus channel count %d\n", nchannels);
+224
View File
@@ -0,0 +1,224 @@
/*
* Block driver for the various disk image formats used by Bochs
* Currently only for "growing" type in read-only mode
*
* Copyright (c) 2005 Alex Beregszaszi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
#include "block_int.h"
/**************************************************************/
#define HEADER_MAGIC "Bochs Virtual HD Image"
#define HEADER_VERSION 0x00010000
#define HEADER_SIZE 512
#define REDOLOG_TYPE "Redolog"
#define GROWING_TYPE "Growing"
// not allocated: 0xffffffff
// always little-endian
struct bochs_header {
char magic[32]; // "Bochs Virtual HD Image"
char type[16]; // "Redolog"
char subtype[16]; // "Undoable" / "Volatile" / "Growing"
uint32_t version;
uint32_t header; // size of header
union {
struct {
uint32_t catalog; // num of entries
uint32_t bitmap; // bitmap size
uint32_t extent; // extent size
uint64_t disk; // disk size
char padding[HEADER_SIZE - 64 - 8 - 20];
} redolog;
char padding[HEADER_SIZE - 64 - 8];
} extra;
};
typedef struct BDRVBochsState {
int fd;
uint32_t *catalog_bitmap;
int catalog_size;
int data_offset;
int bitmap_blocks;
int extent_blocks;
int extent_size;
} BDRVBochsState;
static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
{
const struct bochs_header *bochs = (const void *)buf;
if (buf_size < HEADER_SIZE)
return 0;
if (!strcmp(bochs->magic, HEADER_MAGIC) &&
!strcmp(bochs->type, REDOLOG_TYPE) &&
!strcmp(bochs->subtype, GROWING_TYPE) &&
(le32_to_cpu(bochs->version) == HEADER_VERSION))
return 100;
return 0;
}
static int bochs_open(BlockDriverState *bs, const char *filename)
{
BDRVBochsState *s = bs->opaque;
int fd, i;
struct bochs_header bochs;
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (fd < 0)
return -1;
}
bs->read_only = 1; // no write support yet
s->fd = fd;
if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) {
goto fail;
}
if (strcmp(bochs.magic, HEADER_MAGIC) ||
strcmp(bochs.type, REDOLOG_TYPE) ||
strcmp(bochs.subtype, GROWING_TYPE) ||
(le32_to_cpu(bochs.version) != HEADER_VERSION)) {
goto fail;
}
bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
if (!s->catalog_bitmap)
goto fail;
if (read(s->fd, s->catalog_bitmap, s->catalog_size * 4) !=
s->catalog_size * 4)
goto fail;
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
return 0;
fail:
close(fd);
return -1;
}
static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
{
BDRVBochsState *s = bs->opaque;
int64_t offset = sector_num * 512;
int64_t extent_index, extent_offset, bitmap_offset, block_offset;
char bitmap_entry;
// seek to sector
extent_index = offset / s->extent_size;
extent_offset = (offset % s->extent_size) / 512;
if (s->catalog_bitmap[extent_index] == 0xffffffff)
{
// fprintf(stderr, "page not allocated [%x - %x:%x]\n",
// sector_num, extent_index, extent_offset);
return -1; // not allocated
}
bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] *
(s->extent_blocks + s->bitmap_blocks));
block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
// fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n",
// sector_num, extent_index, extent_offset,
// le32_to_cpu(s->catalog_bitmap[extent_index]),
// bitmap_offset, block_offset);
// read in bitmap for current extent
lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
read(s->fd, &bitmap_entry, 1);
if (!((bitmap_entry >> (extent_offset % 8)) & 1))
{
// fprintf(stderr, "sector (%x) in bitmap not allocated\n",
// sector_num);
return -1; // not allocated
}
lseek(s->fd, block_offset, SEEK_SET);
return 0;
}
static int bochs_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVBochsState *s = bs->opaque;
int ret;
while (nb_sectors > 0) {
if (!seek_to_sector(bs, sector_num))
{
ret = read(s->fd, buf, 512);
if (ret != 512)
return -1;
}
else
memset(buf, 0, 512);
nb_sectors--;
sector_num++;
buf += 512;
}
return 0;
}
static void bochs_close(BlockDriverState *bs)
{
BDRVBochsState *s = bs->opaque;
qemu_free(s->catalog_bitmap);
close(s->fd);
}
BlockDriver bdrv_bochs = {
"bochs",
sizeof(BDRVBochsState),
bochs_probe,
bochs_open,
bochs_read,
NULL,
bochs_close,
};
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* QEMU System Emulator block driver
* QEMU Block driver for CLOOP images
*
* Copyright (c) 2004 Johannes E. Schindelin
*
@@ -149,6 +149,8 @@ static void cloop_close(BlockDriverState *bs)
{
BDRVCloopState *s = bs->opaque;
close(s->fd);
if(s->n_blocks>0)
free(s->offsets);
free(s->compressed_block);
free(s->uncompressed_block);
inflateEnd(&s->zstream);
+2 -2
View File
@@ -124,7 +124,7 @@ static int cow_open(BlockDriverState *bs, const char *filename)
return -1;
}
static inline void set_bit(uint8_t *bitmap, int64_t bitnum)
static inline void cow_set_bit(uint8_t *bitmap, int64_t bitnum)
{
bitmap[bitnum / 8] |= (1 << (bitnum%8));
}
@@ -198,7 +198,7 @@ static int cow_write(BlockDriverState *bs, int64_t sector_num,
if (ret != nb_sectors * 512)
return -1;
for (i = 0; i < nb_sectors; i++)
set_bit(s->cow_bitmap, sector_num + i);
cow_set_bit(s->cow_bitmap, sector_num + i);
return 0;
}
+295
View File
@@ -0,0 +1,295 @@
/*
* QEMU Block driver for DMG images
*
* Copyright (c) 2004 Johannes E. Schindelin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
#include "block_int.h"
#include "bswap.h"
#include <zlib.h>
typedef struct BDRVDMGState {
int fd;
/* each chunk contains a certain number of sectors,
* offsets[i] is the offset in the .dmg file,
* lengths[i] is the length of the compressed chunk,
* sectors[i] is the sector beginning at offsets[i],
* sectorcounts[i] is the number of sectors in that chunk,
* the sectors array is ordered
* 0<=i<n_chunks */
uint32_t n_chunks;
uint32_t* types;
uint64_t* offsets;
uint64_t* lengths;
uint64_t* sectors;
uint64_t* sectorcounts;
uint32_t current_chunk;
char* compressed_chunk;
char* uncompressed_chunk;
z_stream zstream;
} BDRVDMGState;
static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
{
int len=strlen(filename);
if(len>4 && !strcmp(filename+len-4,".dmg"))
return 2;
return 0;
}
static off_t read_off(int fd)
{
uint64_t buffer;
if(read(fd,&buffer,8)<8)
return 0;
return be64_to_cpu(buffer);
}
static off_t read_uint32(int fd)
{
uint32_t buffer;
if(read(fd,&buffer,4)<4)
return 0;
return be32_to_cpu(buffer);
}
static int dmg_open(BlockDriverState *bs, const char *filename)
{
BDRVDMGState *s = bs->opaque;
off_t info_begin,info_end,last_in_offset,last_out_offset;
uint32_t count;
uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (s->fd < 0)
return -1;
bs->read_only = 1;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = 0;
/* read offset of info blocks */
if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
dmg_close:
close(s->fd);
return -1;
}
info_begin=read_off(s->fd);
if(info_begin==0)
goto dmg_close;
if(lseek(s->fd,info_begin,SEEK_SET)<0)
goto dmg_close;
if(read_uint32(s->fd)!=0x100)
goto dmg_close;
if((count = read_uint32(s->fd))==0)
goto dmg_close;
info_end = info_begin+count;
if(lseek(s->fd,0xf8,SEEK_CUR)<0)
goto dmg_close;
/* read offsets */
last_in_offset = last_out_offset = 0;
while(lseek(s->fd,0,SEEK_CUR)<info_end) {
uint32_t type;
count = read_uint32(s->fd);
if(count==0)
goto dmg_close;
type = read_uint32(s->fd);
if(type!=0x6d697368 || count<244)
lseek(s->fd,count-4,SEEK_CUR);
else {
int new_size, chunk_count;
if(lseek(s->fd,200,SEEK_CUR)<0)
goto dmg_close;
chunk_count = (count-204)/40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
s->types = realloc(s->types, new_size/2);
s->offsets = realloc(s->offsets, new_size);
s->lengths = realloc(s->lengths, new_size);
s->sectors = realloc(s->sectors, new_size);
s->sectorcounts = realloc(s->sectorcounts, new_size);
for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
s->types[i] = read_uint32(s->fd);
if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) {
if(s->types[i]==0xffffffff) {
last_in_offset = s->offsets[i-1]+s->lengths[i-1];
last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1];
}
chunk_count--;
i--;
if(lseek(s->fd,36,SEEK_CUR)<0)
goto dmg_close;
continue;
}
read_uint32(s->fd);
s->sectors[i] = last_out_offset+read_off(s->fd);
s->sectorcounts[i] = read_off(s->fd);
s->offsets[i] = last_in_offset+read_off(s->fd);
s->lengths[i] = read_off(s->fd);
if(s->lengths[i]>max_compressed_size)
max_compressed_size = s->lengths[i];
if(s->sectorcounts[i]>max_sectors_per_chunk)
max_sectors_per_chunk = s->sectorcounts[i];
}
s->n_chunks+=chunk_count;
}
}
/* initialize zlib engine */
if(!(s->compressed_chunk=(char*)malloc(max_compressed_size+1)))
goto dmg_close;
if(!(s->uncompressed_chunk=(char*)malloc(512*max_sectors_per_chunk)))
goto dmg_close;
if(inflateInit(&s->zstream) != Z_OK)
goto dmg_close;
s->current_chunk = s->n_chunks;
return 0;
}
static inline int is_sector_in_chunk(BDRVDMGState* s,
uint32_t chunk_num,int sector_num)
{
if(chunk_num>=s->n_chunks || s->sectors[chunk_num]>sector_num ||
s->sectors[chunk_num]+s->sectorcounts[chunk_num]<=sector_num)
return 0;
else
return -1;
}
static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
{
/* binary search */
uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
while(chunk1!=chunk2) {
chunk3 = (chunk1+chunk2)/2;
if(s->sectors[chunk3]>sector_num)
chunk2 = chunk3;
else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
return chunk3;
else
chunk1 = chunk3;
}
return s->n_chunks; /* error */
}
static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
{
if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {
int ret;
uint32_t chunk = search_chunk(s,sector_num);
if(chunk>=s->n_chunks)
return -1;
s->current_chunk = s->n_chunks;
switch(s->types[chunk]) {
case 0x80000005: { /* zlib compressed */
int i;
ret = lseek(s->fd, s->offsets[chunk], SEEK_SET);
if(ret<0)
return -1;
/* we need to buffer, because only the chunk as whole can be
* inflated. */
i=0;
do {
ret = read(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i);
if(ret<0 && errno==EINTR)
ret=0;
i+=ret;
} while(ret>=0 && ret+i<s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
s->zstream.next_in = s->compressed_chunk;
s->zstream.avail_in = s->lengths[chunk];
s->zstream.next_out = s->uncompressed_chunk;
s->zstream.avail_out = 512*s->sectorcounts[chunk];
ret = inflateReset(&s->zstream);
if(ret != Z_OK)
return -1;
ret = inflate(&s->zstream, Z_FINISH);
if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])
return -1;
break; }
case 1: /* copy */
ret = read(s->fd, s->uncompressed_chunk, s->lengths[chunk]);
if (ret != s->lengths[chunk])
return -1;
break;
case 2: /* zero */
memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);
break;
}
s->current_chunk = chunk;
}
return 0;
}
static int dmg_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVDMGState *s = bs->opaque;
int i;
for(i=0;i<nb_sectors;i++) {
uint32_t sector_offset_in_chunk;
if(dmg_read_chunk(s, sector_num+i) != 0)
return -1;
sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
}
return 0;
}
static void dmg_close(BlockDriverState *bs)
{
BDRVDMGState *s = bs->opaque;
close(s->fd);
if(s->n_chunks>0) {
free(s->types);
free(s->offsets);
free(s->lengths);
free(s->sectors);
free(s->sectorcounts);
}
free(s->compressed_chunk);
free(s->uncompressed_chunk);
inflateEnd(&s->zstream);
}
BlockDriver bdrv_dmg = {
"dmg",
sizeof(BDRVDMGState),
dmg_probe,
dmg_open,
dmg_read,
NULL,
dmg_close,
};
+74 -17
View File
@@ -2,6 +2,7 @@
* Block driver for the VMDK format
*
* Copyright (c) 2004 Fabrice Bellard
* Copyright (c) 2005 Filip Navara
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,9 +25,6 @@
#include "vl.h"
#include "block_int.h"
/* XXX: this code is untested */
/* XXX: add write support */
#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
@@ -56,14 +54,16 @@ typedef struct {
int64_t grain_offset;
char filler[1];
char check_bytes[4];
} VMDK4Header;
} __attribute__((packed)) VMDK4Header;
#define L2_CACHE_SIZE 16
typedef struct BDRVVmdkState {
int fd;
int64_t l1_table_offset;
int64_t l1_backup_table_offset;
uint32_t *l1_table;
uint32_t *l1_backup_table;
unsigned int l1_size;
uint32_t l1_entry_sectors;
@@ -96,9 +96,13 @@ static int vmdk_open(BlockDriverState *bs, const char *filename)
uint32_t magic;
int l1_size;
fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (fd < 0)
return -1;
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (fd < 0)
return -1;
bs->read_only = 1;
}
if (read(fd, &magic, sizeof(magic)) != sizeof(magic))
goto fail;
magic = be32_to_cpu(magic);
@@ -111,7 +115,8 @@ static int vmdk_open(BlockDriverState *bs, const char *filename)
s->l2_size = 1 << 9;
s->l1_size = 1 << 6;
bs->total_sectors = le32_to_cpu(header.disk_sectors);
s->l1_table_offset = le32_to_cpu(header.l1dir_offset) * 512;
s->l1_table_offset = le32_to_cpu(header.l1dir_offset) << 9;
s->l1_backup_table_offset = 0;
s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
} else if (magic == VMDK4_MAGIC) {
VMDK4Header header;
@@ -126,7 +131,8 @@ static int vmdk_open(BlockDriverState *bs, const char *filename)
goto fail;
s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1)
/ s->l1_entry_sectors;
s->l1_table_offset = le64_to_cpu(header.rgd_offset) * 512;
s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;
s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9;
} else {
goto fail;
}
@@ -143,14 +149,26 @@ static int vmdk_open(BlockDriverState *bs, const char *filename)
le32_to_cpus(&s->l1_table[i]);
}
if (s->l1_backup_table_offset) {
s->l1_backup_table = qemu_malloc(l1_size);
if (!s->l1_backup_table)
goto fail;
if (lseek(fd, s->l1_backup_table_offset, SEEK_SET) == -1)
goto fail;
if (read(fd, s->l1_backup_table, l1_size) != l1_size)
goto fail;
for(i = 0; i < s->l1_size; i++) {
le32_to_cpus(&s->l1_backup_table[i]);
}
}
s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
if (!s->l2_cache)
goto fail;
s->fd = fd;
/* XXX: currently only read only */
bs->read_only = 1;
return 0;
fail:
qemu_free(s->l1_backup_table);
qemu_free(s->l1_table);
qemu_free(s->l2_cache);
close(fd);
@@ -158,12 +176,12 @@ static int vmdk_open(BlockDriverState *bs, const char *filename)
}
static uint64_t get_cluster_offset(BlockDriverState *bs,
uint64_t offset)
uint64_t offset, int allocate)
{
BDRVVmdkState *s = bs->opaque;
unsigned int l1_index, l2_offset, l2_index;
int min_index, i, j;
uint32_t min_count, *l2_table;
uint32_t min_count, *l2_table, tmp;
uint64_t cluster_offset;
l1_index = (offset >> 9) / s->l1_entry_sectors;
@@ -172,7 +190,6 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
l2_offset = s->l1_table[l1_index];
if (!l2_offset)
return 0;
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == s->l2_cache_offsets[i]) {
/* increment the hit count */
@@ -204,6 +221,26 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
found:
l2_index = ((offset >> 9) / s->cluster_sectors) % s->l2_size;
cluster_offset = le32_to_cpu(l2_table[l2_index]);
if (!cluster_offset) {
if (!allocate)
return 0;
cluster_offset = lseek(s->fd, 0, SEEK_END);
ftruncate(s->fd, cluster_offset + (s->cluster_sectors << 9));
cluster_offset >>= 9;
/* update L2 table */
tmp = cpu_to_le32(cluster_offset);
l2_table[l2_index] = tmp;
lseek(s->fd, ((int64_t)l2_offset * 512) + (l2_index * sizeof(tmp)), SEEK_SET);
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
/* update backup L2 table */
if (s->l1_backup_table_offset != 0) {
l2_offset = s->l1_backup_table[l1_index];
lseek(s->fd, ((int64_t)l2_offset * 512) + (l2_index * sizeof(tmp)), SEEK_SET);
if (write(s->fd, &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
}
}
cluster_offset <<= 9;
return cluster_offset;
}
@@ -215,7 +252,7 @@ static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
int index_in_cluster, n;
uint64_t cluster_offset;
cluster_offset = get_cluster_offset(bs, sector_num << 9);
cluster_offset = get_cluster_offset(bs, sector_num << 9, 0);
index_in_cluster = sector_num % s->cluster_sectors;
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors)
@@ -232,7 +269,7 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
uint64_t cluster_offset;
while (nb_sectors > 0) {
cluster_offset = get_cluster_offset(bs, sector_num << 9);
cluster_offset = get_cluster_offset(bs, sector_num << 9, 0);
index_in_cluster = sector_num % s->cluster_sectors;
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors)
@@ -255,7 +292,27 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
return -1;
BDRVVmdkState *s = bs->opaque;
int ret, index_in_cluster, n;
uint64_t cluster_offset;
while (nb_sectors > 0) {
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors)
n = nb_sectors;
cluster_offset = get_cluster_offset(bs, sector_num << 9, 1);
if (!cluster_offset)
return -1;
lseek(s->fd, cluster_offset + index_in_cluster * 512, SEEK_SET);
ret = write(s->fd, buf, n * 512);
if (ret != n * 512)
return -1;
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
return 0;
}
static void vmdk_close(BlockDriverState *bs)
+243
View File
@@ -0,0 +1,243 @@
/*
* Block driver for Conectix/Microsoft Virtual PC images
*
* Copyright (c) 2005 Alex Beregszaszi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
#include "block_int.h"
/**************************************************************/
#define HEADER_SIZE 512
//#define CACHE
// always big-endian
struct vpc_subheader {
char magic[8]; // "conectix" / "cxsparse"
union {
struct {
uint32_t unk1[2];
uint32_t unk2; // always zero?
uint32_t subheader_offset;
uint32_t unk3; // some size?
char creator[4]; // "vpc "
uint16_t major;
uint16_t minor;
char guest[4]; // "Wi2k"
uint32_t unk4[7];
uint8_t vnet_id[16]; // virtual network id, purpose unknown
// next 16 longs are used, but dunno the purpose
// next 6 longs unknown, following 7 long maybe a serial
char padding[HEADER_SIZE - 84];
} main;
struct {
uint32_t unk1[2]; // all bits set
uint32_t unk2; // always zero?
uint32_t pagetable_offset;
uint32_t unk3;
uint32_t pagetable_entries; // 32bit/entry
uint32_t pageentry_size; // 512*8*512
uint32_t nb_sectors;
char padding[HEADER_SIZE - 40];
} sparse;
char padding[HEADER_SIZE - 8];
} type;
};
typedef struct BDRVVPCState {
int fd;
int pagetable_entries;
uint32_t *pagetable;
uint32_t pageentry_size;
#ifdef CACHE
uint8_t *pageentry_u8;
uint32_t *pageentry_u32;
uint16_t *pageentry_u16;
uint64_t last_bitmap;
#endif
} BDRVVPCState;
static int vpc_probe(const uint8_t *buf, int buf_size, const char *filename)
{
if (!strncmp(buf, "conectix", 8))
return 100;
return 0;
}
static int vpc_open(BlockDriverState *bs, const char *filename)
{
BDRVVPCState *s = bs->opaque;
int fd, i;
struct vpc_subheader header;
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (fd < 0)
return -1;
}
bs->read_only = 1; // no write support yet
s->fd = fd;
if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
goto fail;
if (strncmp(header.magic, "conectix", 8))
goto fail;
lseek(s->fd, be32_to_cpu(header.type.main.subheader_offset), SEEK_SET);
if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
goto fail;
if (strncmp(header.magic, "cxsparse", 8))
goto fail;
bs->total_sectors = ((uint64_t)be32_to_cpu(header.type.sparse.pagetable_entries) *
be32_to_cpu(header.type.sparse.pageentry_size)) / 512;
lseek(s->fd, be32_to_cpu(header.type.sparse.pagetable_offset), SEEK_SET);
s->pagetable_entries = be32_to_cpu(header.type.sparse.pagetable_entries);
s->pagetable = qemu_malloc(s->pagetable_entries * 4);
if (!s->pagetable)
goto fail;
if (read(s->fd, s->pagetable, s->pagetable_entries * 4) !=
s->pagetable_entries * 4)
goto fail;
for (i = 0; i < s->pagetable_entries; i++)
be32_to_cpus(&s->pagetable[i]);
s->pageentry_size = be32_to_cpu(header.type.sparse.pageentry_size);
#ifdef CACHE
s->pageentry_u8 = qemu_malloc(512);
if (!s->pageentry_u8)
goto fail;
s->pageentry_u32 = s->pageentry_u8;
s->pageentry_u16 = s->pageentry_u8;
s->last_pagetable = -1;
#endif
return 0;
fail:
close(fd);
return -1;
}
static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
{
BDRVVPCState *s = bs->opaque;
uint64_t offset = sector_num * 512;
uint64_t bitmap_offset, block_offset;
uint32_t pagetable_index, pageentry_index;
pagetable_index = offset / s->pageentry_size;
pageentry_index = (offset % s->pageentry_size) / 512;
if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff)
return -1; // not allocated
bitmap_offset = 512 * s->pagetable[pagetable_index];
block_offset = bitmap_offset + 512 + (512 * pageentry_index);
// printf("sector: %llx, index: %x, offset: %x, bioff: %llx, bloff: %llx\n",
// sector_num, pagetable_index, pageentry_index,
// bitmap_offset, block_offset);
// disabled by reason
#if 0
#ifdef CACHE
if (bitmap_offset != s->last_bitmap)
{
lseek(s->fd, bitmap_offset, SEEK_SET);
s->last_bitmap = bitmap_offset;
// Scary! Bitmap is stored as big endian 32bit entries,
// while we used to look it up byte by byte
read(s->fd, s->pageentry_u8, 512);
for (i = 0; i < 128; i++)
be32_to_cpus(&s->pageentry_u32[i]);
}
if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1)
return -1;
#else
lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET);
read(s->fd, &bitmap_entry, 1);
if ((bitmap_entry >> (pageentry_index % 8)) & 1)
return -1; // not allocated
#endif
#endif
lseek(s->fd, block_offset, SEEK_SET);
return 0;
}
static int vpc_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVVPCState *s = bs->opaque;
int ret;
while (nb_sectors > 0) {
if (!seek_to_sector(bs, sector_num))
{
ret = read(s->fd, buf, 512);
if (ret != 512)
return -1;
}
else
memset(buf, 0, 512);
nb_sectors--;
sector_num++;
buf += 512;
}
return 0;
}
static void vpc_close(BlockDriverState *bs)
{
BDRVVPCState *s = bs->opaque;
qemu_free(s->pagetable);
#ifdef CACHE
qemu_free(s->pageentry_u8);
#endif
close(s->fd);
}
BlockDriver bdrv_vpc = {
"vpc",
sizeof(BDRVVPCState),
vpc_probe,
vpc_open,
vpc_read,
NULL,
vpc_close,
};
+59 -3
View File
@@ -24,6 +24,14 @@
#include "vl.h"
#include "block_int.h"
#ifdef _BSD
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/disk.h>
#endif
static BlockDriverState *bdrv_first;
static BlockDriver *first_drv;
@@ -88,18 +96,33 @@ static void get_tmp_filename(char *filename, int size)
}
#endif
/* XXX: force raw format if block or character device ? It would
simplify the BSD case */
static BlockDriver *find_image_format(const char *filename)
{
int fd, ret, score, score_max;
BlockDriver *drv1, *drv;
uint8_t buf[1024];
uint8_t *buf;
size_t bufsize = 1024;
fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
if (fd < 0)
return NULL;
ret = read(fd, buf, sizeof(buf));
#ifdef DIOCGSECTORSIZE
{
unsigned int sectorsize = 512;
if (!ioctl(fd, DIOCGSECTORSIZE, &sectorsize) &&
sectorsize > bufsize)
bufsize = sectorsize;
}
#endif
buf = malloc(bufsize);
if (!buf)
return NULL;
ret = read(fd, buf, bufsize);
if (ret < 0) {
close(fd);
free(buf);
return NULL;
}
close(fd);
@@ -113,6 +136,7 @@ static BlockDriver *find_image_format(const char *filename)
drv = drv1;
}
}
free(buf);
return drv;
}
@@ -348,6 +372,11 @@ void bdrv_set_type_hint(BlockDriverState *bs, int type)
type == BDRV_TYPE_FLOPPY));
}
void bdrv_set_translation_hint(BlockDriverState *bs, int translation)
{
bs->translation = translation;
}
void bdrv_get_geometry_hint(BlockDriverState *bs,
int *pcyls, int *pheads, int *psecs)
{
@@ -361,6 +390,11 @@ int bdrv_get_type_hint(BlockDriverState *bs)
return bs->type;
}
int bdrv_get_translation_hint(BlockDriverState *bs)
{
return bs->translation;
}
int bdrv_is_removable(BlockDriverState *bs)
{
return bs->removable;
@@ -514,6 +548,9 @@ static int raw_open(BlockDriverState *bs, const char *filename)
BDRVRawState *s = bs->opaque;
int fd;
int64_t size;
#ifdef _BSD
struct stat sb;
#endif
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
@@ -522,7 +559,23 @@ static int raw_open(BlockDriverState *bs, const char *filename)
return -1;
bs->read_only = 1;
}
size = lseek(fd, 0, SEEK_END);
#ifdef _BSD
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
#ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
#endif
size = lseek(fd, 0LL, SEEK_END);
} else
#endif
{
size = lseek(fd, 0, SEEK_END);
}
#ifdef _WIN32
/* On Windows hosts it can happen that we're unable to get file size
for CD-ROM raw device (it's inherent limitation of the CDFS driver). */
if (size == -1)
size = LONG_LONG_MAX;
#endif
bs->total_sectors = size / 512;
s->fd = fd;
return 0;
@@ -597,4 +650,7 @@ void bdrv_init(void)
bdrv_register(&bdrv_qcow);
bdrv_register(&bdrv_vmdk);
bdrv_register(&bdrv_cloop);
bdrv_register(&bdrv_dmg);
bdrv_register(&bdrv_bochs);
bdrv_register(&bdrv_vpc);
}
+1 -1
View File
@@ -68,7 +68,7 @@ struct BlockDriverState {
/* NOTE: the following infos are only hints for real hardware
drivers. They are not used by the block driver */
int cyls, heads, secs;
int cyls, heads, secs, translation;
int type;
char device_name[32];
BlockDriverState *next;
+614
View File
@@ -0,0 +1,614 @@
/*
* QEMU Cocoa display driver
*
* Copyright (c) 2005 Pierre d'Herbemont
* many code/inspiration from SDL 1.2 code (LGPL)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
Todo : x miniaturize window
x center the window
- save window position
- handle keyboard event
- handle mouse event
- non 32 bpp support
- full screen
- mouse focus
x simple graphical prompt to demo
- better graphical prompt
*/
#import <Cocoa/Cocoa.h>
#include "vl.h"
NSWindow *window = NULL;
NSQuickDrawView *qd_view = NULL;
int gArgc;
char **gArgv;
DisplayState current_ds;
/* main defined in qemu/vl.c */
int qemu_main(int argc, char **argv);
/* To deal with miniaturization */
@interface QemuWindow : NSWindow
{ }
@end
/*
------------------------------------------------------
Qemu Video Driver
------------------------------------------------------
*/
/*
------------------------------------------------------
cocoa_update
------------------------------------------------------
*/
static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
{
//printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
/* Use QDFlushPortBuffer() to flush content to display */
RgnHandle dirty = NewRgn ();
RgnHandle temp = NewRgn ();
SetEmptyRgn (dirty);
/* Build the region of dirty rectangles */
MacSetRectRgn (temp, x, y,
x + w, y + h);
MacUnionRgn (dirty, temp, dirty);
/* Flush the dirty region */
QDFlushPortBuffer ( [ qd_view qdPort ], dirty );
DisposeRgn (dirty);
DisposeRgn (temp);
}
/*
------------------------------------------------------
cocoa_resize
------------------------------------------------------
*/
static void cocoa_resize(DisplayState *ds, int w, int h)
{
const int device_bpp = 32;
static void *screen_pixels;
static int screen_pitch;
NSRect contentRect;
//printf("resizing to %d %d\n", w, h);
contentRect = NSMakeRect (0, 0, w, h);
if(window)
{
[window close];
[window release];
}
window = [ [ QemuWindow alloc ] initWithContentRect:contentRect
styleMask:NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask
backing:NSBackingStoreBuffered defer:NO];
if(!window)
{
fprintf(stderr, "(cocoa) can't create window\n");
exit(1);
}
if(qd_view)
[qd_view release];
qd_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
if(!qd_view)
{
fprintf(stderr, "(cocoa) can't create qd_view\n");
exit(1);
}
[ window setAcceptsMouseMovedEvents:YES ];
[ window setTitle:@"Qemu" ];
[ window setReleasedWhenClosed:NO ];
/* Set screen to black */
[ window setBackgroundColor: [NSColor blackColor] ];
/* set window position */
[ window center ];
[ qd_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
[ [ window contentView ] addSubview:qd_view ];
[ qd_view release ];
[ window makeKeyAndOrderFront:nil ];
/* Careful here, the window seems to have to be onscreen to do that */
LockPortBits ( [ qd_view qdPort ] );
screen_pixels = GetPixBaseAddr ( GetPortPixMap ( [ qd_view qdPort ] ) );
screen_pitch = GetPixRowBytes ( GetPortPixMap ( [ qd_view qdPort ] ) );
UnlockPortBits ( [ qd_view qdPort ] );
{
int vOffset = [ window frame ].size.height -
[ qd_view frame ].size.height - [ qd_view frame ].origin.y;
int hOffset = [ qd_view frame ].origin.x;
screen_pixels += (vOffset * screen_pitch) + hOffset * (device_bpp/8);
}
ds->data = screen_pixels;
ds->linesize = screen_pitch;
ds->depth = device_bpp;
ds->width = w;
ds->height = h;
current_ds = *ds;
}
/*
------------------------------------------------------
keymap conversion
------------------------------------------------------
*/
static int keymap[] =
{
30, //'a' 0x0
31, //'s'
32, //'d'
33, //'f'
35, //'h'
34, //'g'
44, //'z'
45, //'x'
46, //'c'
47, //'v'
0, // 0 0x0a
48, //'b'
16, //'q'
17, //'w'
18, //'e'
19, //'r'
21, //'y' 0x10
20, //'t'
2, //'1'
3, //'2'
4, //'3'
5, //'4'
7, //'6'
6, //'5'
0, //'='
10, //'9'
8, //'7' 0x1A
0, //'-'
9, //'8'
11, //'0'
27, //']'
24, //'o'
22, //'u' 0x20
26, //'['
23, //'i'
25, //'p'
28, //'\n'
38, //'l'
36, //'j'
40, //'"'
37, //'k'
39, //';'
15, //'\t' 0x30
0, //' '
0, //'`'
14, //'<backspace>'
0, //'' 0x34
0, //'<esc>'
0, //'<esc>'
/* Not completed to finish see http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/video/quartz/SDL_QuartzKeys.h?rev=1.6&content-type=text/x-cvsweb-markup */
};
static int cocoa_keycode_to_qemu(int keycode)
{
if(sizeof(keymap) <= keycode)
{
printf("(cocoa) warning unknow keycode 0x%x\n", keycode);
return 0;
}
return keymap[keycode];
}
/*
------------------------------------------------------
cocoa_refresh
------------------------------------------------------
*/
static void cocoa_refresh(DisplayState *ds)
{
//printf("cocoa_refresh \n");
NSDate *distantPast;
NSEvent *event;
NSAutoreleasePool *pool;
int grab = 1;
pool = [ [ NSAutoreleasePool alloc ] init ];
distantPast = [ NSDate distantPast ];
if (is_active_console(vga_console))
vga_update_display();
do {
event = [ NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distantPast
inMode: NSDefaultRunLoopMode dequeue:YES ];
if (event != nil) {
switch ([event type]) {
case NSKeyDown:
if(grab)
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode & 0x7f);
}
break;
case NSKeyUp:
if(grab)
{
int keycode = cocoa_keycode_to_qemu([event keyCode]);
if (keycode & 0x80)
kbd_put_keycode(0xe0);
kbd_put_keycode(keycode | 0x80);
}
break;
case NSScrollWheel:
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSOtherMouseDown:
case NSRightMouseDown:
case NSOtherMouseUp:
case NSRightMouseUp:
case NSMouseMoved:
case NSOtherMouseDragged:
case NSRightMouseDragged:
case NSLeftMouseDragged:
default: [NSApp sendEvent:event];
}
}
} while(event != nil);
}
/*
------------------------------------------------------
cocoa_cleanup
------------------------------------------------------
*/
static void cocoa_cleanup(void)
{
}
/*
------------------------------------------------------
cocoa_display_init
------------------------------------------------------
*/
void cocoa_display_init(DisplayState *ds, int full_screen)
{
ds->dpy_update = cocoa_update;
ds->dpy_resize = cocoa_resize;
ds->dpy_refresh = cocoa_refresh;
cocoa_resize(ds, 640, 400);
atexit(cocoa_cleanup);
}
/*
------------------------------------------------------
Interface with Cocoa
------------------------------------------------------
*/
/*
------------------------------------------------------
QemuWindow
Some trick from SDL to use miniwindow
------------------------------------------------------
*/
static void QZ_SetPortAlphaOpaque ()
{
/* Assume 32 bit if( bpp == 32 )*/
if ( 1 ) {
uint32_t *pixels = (uint32_t*) current_ds.data;
uint32_t rowPixels = current_ds.linesize / 4;
uint32_t i, j;
for (i = 0; i < current_ds.height; i++)
for (j = 0; j < current_ds.width; j++) {
pixels[ (i * rowPixels) + j ] |= 0xFF000000;
}
}
}
@implementation QemuWindow
- (void)miniaturize:(id)sender
{
/* make the alpha channel opaque so anim won't have holes in it */
QZ_SetPortAlphaOpaque ();
[ super miniaturize:sender ];
}
- (void)display
{
/*
This method fires just before the window deminaturizes from the Dock.
We'll save the current visible surface, let the window manager redraw any
UI elements, and restore the SDL surface. This way, no expose event
is required, and the deminiaturize works perfectly.
*/
/* make sure pixels are fully opaque */
QZ_SetPortAlphaOpaque ();
/* save current visible SDL surface */
[ self cacheImageInRect:[ qd_view frame ] ];
/* let the window manager redraw controls, border, etc */
[ super display ];
/* restore visible SDL surface */
[ self restoreCachedImage ];
}
@end
/*
------------------------------------------------------
QemuCocoaGUIController
NSApp's delegate - indeed main object
------------------------------------------------------
*/
@interface QemuCocoaGUIController : NSObject
{
}
- (void)applicationDidFinishLaunching: (NSNotification *) note;
- (void)applicationWillTerminate:(NSNotification *)aNotification;
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void)startEmulationWithArgc:(int)argc argv:(char**)argv;
@end
@implementation QemuCocoaGUIController
/* Called when the internal event loop has just started running */
- (void)applicationDidFinishLaunching: (NSNotification *) note
{
/* Display an open dialog box if no argument were passed or
if qemu was launched from the finder ( the Finder passes "-psn" ) */
if( gArgc <= 1 || strncmp (gArgv[1], "-psn", 4) == 0)
{
NSOpenPanel *op = [[NSOpenPanel alloc] init];
cocoa_resize(&current_ds, 640, 400);
[op setPrompt:@"Boot image"];
[op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"];
[op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil]
modalForWindow:window modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
}
else
{
/* or Launch Qemu, with the global args */
[self startEmulationWithArgc:gArgc argv:gArgv];
}
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
printf("Application will terminate\n");
qemu_system_shutdown_request();
/* In order to avoid a crash */
exit(0);
}
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if(returnCode == NSCancelButton)
{
exit(0);
}
if(returnCode == NSOKButton)
{
char *bin = "qemu";
char *img = (char*)[ [ sheet filename ] cString];
char **argv = (char**)malloc( sizeof(char*)*3 );
asprintf(&argv[0], "%s", bin);
asprintf(&argv[1], "-hda");
asprintf(&argv[2], "%s", img);
printf("Using argc %d argv %s -hda %s\n", 3, bin, img);
[self startEmulationWithArgc:3 argv:(char**)argv];
}
}
- (void)startEmulationWithArgc:(int)argc argv:(char**)argv
{
int status;
/* Launch Qemu */
printf("starting qemu...\n");
status = qemu_main (argc, argv);
exit(status);
}
@end
/*
------------------------------------------------------
Application Creation
------------------------------------------------------
*/
/* Dock Connection */
typedef struct CPSProcessSerNum
{
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);
/* Menu Creation */
static void setApplicationMenu(void)
{
/* warning: this code is very odd */
NSMenu *appleMenu;
NSMenuItem *menuItem;
NSString *title;
NSString *appName;
appName = @"Qemu";
appleMenu = [[NSMenu alloc] initWithTitle:@""];
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
[[NSApp mainMenu] addItem:menuItem];
/* Tell the application object that this is now the application menu */
[NSApp setAppleMenu:appleMenu];
/* Finally give up our references to the objects */
[appleMenu release];
[menuItem release];
}
/* Create a window menu */
static void setupWindowMenu(void)
{
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
[windowMenu addItem:menuItem];
[menuItem release];
/* Put menu into the menubar */
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[windowMenuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:windowMenuItem];
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
/* Finally give up our references to the objects */
[windowMenu release];
[windowMenuItem release];
}
static void CustomApplicationMain (argc, argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
QemuCocoaGUIController *gui_controller;
CPSProcessSerNum PSN;
[NSApplication sharedApplication];
if (!CPSGetCurrentProcess(&PSN))
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
if (!CPSSetFrontProcess(&PSN))
[NSApplication sharedApplication];
/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
setApplicationMenu();
setupWindowMenu();
/* Create SDLMain and make it the app delegate */
gui_controller = [[QemuCocoaGUIController alloc] init];
[NSApp setDelegate:gui_controller];
/* Start the main event loop */
[NSApp run];
[gui_controller release];
[pool release];
}
/* Real main of qemu-cocoa */
int main(int argc, char **argv)
{
gArgc = argc;
gArgv = argv;
CustomApplicationMain (argc, argv);
return 0;
}
Vendored
+154 -18
View File
@@ -27,12 +27,15 @@ ar="ar"
make="make"
strip="strip"
cpu=`uname -m`
target_list="i386-user i386 i386-softmmu arm-user sparc-user ppc-user ppc-softmmu sparc-softmmu"
target_list=""
case "$cpu" in
i386|i486|i586|i686|i86pc|BePC)
cpu="i386"
;;
armv4l)
armv*b)
cpu="armv4b"
;;
armv*l)
cpu="armv4l"
;;
alpha)
@@ -60,7 +63,7 @@ case "$cpu" in
cpu="m68k"
;;
x86_64|amd64)
cpu="amd64"
cpu="x86_64"
;;
*)
cpu="unknown"
@@ -77,16 +80,27 @@ oss="no"
fmod="no"
fmod_lib=""
fmod_inc=""
linux="no"
kqemu="no"
kernel_path=""
cocoa="no"
# OS specific
targetos=`uname -s`
case $targetos in
CYGWIN*)
mingw32="yes"
CFLAGS="-O2 -mno-cygwin"
;;
MINGW32*)
mingw32="yes"
;;
FreeBSD)
bsd="yes"
oss="yes"
if [ "$cpu" = "i386" ] ; then
kqemu="yes"
fi
;;
NetBSD)
bsd="yes"
@@ -102,6 +116,10 @@ darwin="yes"
;;
*)
oss="yes"
linux="yes"
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
kqemu="yes"
fi
;;
esac
@@ -109,7 +127,6 @@ if [ "$bsd" = "yes" ] ; then
if [ ! "$darwin" = "yes" ] ; then
make="gmake"
fi
target_list="i386-softmmu ppc-softmmu sparc-softmmu"
fi
# find source path
@@ -141,8 +158,6 @@ for opt do
;;
--extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
;;
--extra-libs=*) extralibs=${opt#--extra-libs=}
;;
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
;;
--target-list=*) target_list=${opt#--target-list=}
@@ -165,6 +180,12 @@ for opt do
;;
--enable-adlib) adlib="yes"
;;
--disable-kqemu) kqemu="no"
;;
--kernel-path=*) kernel_path=${opt#--kernel-path=}
;;
--enable-cocoa) cocoa="yes" ; sdl="no"
;;
esac
done
@@ -178,10 +199,22 @@ ar="${cross_prefix}${ar}"
strip="${cross_prefix}${strip}"
if test "$mingw32" = "yes" ; then
target_list="i386-softmmu ppc-softmmu sparc-softmmu"
linux="no"
EXESUF=".exe"
gdbstub="no"
oss="no"
if [ "$cpu" = "i386" ] ; then
kqemu="yes"
fi
fi
if test -z "$target_list" ; then
# these targets are portable
target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu"
# the following are Linux specific
if [ "$linux" = "yes" ] ; then
target_list="i386-user arm-user armeb-user sparc-user ppc-user $target_list"
fi
fi
if test -z "$cross_prefix" ; then
@@ -205,7 +238,7 @@ fi
else
# if cross compiling, cannot launch a program, so make a static guess
if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then
if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
bigendian="yes"
fi
@@ -287,6 +320,10 @@ echo " --interp-prefix=PREFIX where to find shared libraries, etc."
echo " use %M for cpu name [$interp_prefix]"
echo " --target-list=LIST set target list [$target_list]"
echo ""
echo "kqemu kernel acceleration support:"
echo " --disable-kqemu disable kqemu build"
echo " --kernel-path=PATH set the kernel path (configure probes it)"
echo ""
echo "Advanced options (experts only):"
echo " --source-path=PATH path of source code [$source_path]"
echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
@@ -320,6 +357,48 @@ docdir="$prefix/share/doc/qemu"
bindir="$prefix/bin"
fi
# kqemu support
if test $kqemu = "yes" ; then
# test if the source code is installed
if test '!' -f "kqemu/Makefile" ; then
kqemu="no"
fi
fi
# Linux specific kqemu configuration
if test $kqemu = "yes" -a $linux = "yes" ; then
# find the kernel path
if test -z "$kernel_path" ; then
kernel_version=`uname -r`
kernel_path="/lib/modules/$kernel_version/build"
if test '!' -d "$kernel_path/include" ; then
kernel_path="/usr/src/linux"
if test '!' -d "$kernel_path/include" ; then
echo "Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module"
kqemu="no"
fi
fi
fi
if test $kqemu = "yes" ; then
# test that the kernel config is present
if test '!' -f "$kernel_path/Makefile" ; then
echo "No Makefile file present in $kernel_path - kqemu cannot be built"
kqemu="no"
fi
# find build system (2.6 or legacy)
kbuild26="yes"
if grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then
kbuild26="no"
fi
fi # kqemu
fi # kqemu and linux
echo "Install prefix $prefix"
echo "BIOS directory $datadir"
echo "binary directory $bindir"
@@ -335,8 +414,13 @@ echo "host big endian $bigendian"
echo "target list $target_list"
echo "gprof enabled $gprof"
echo "static build $static"
if test "$darwin" = "yes" ; then
echo "Cocoa support $cocoa"
fi
echo "SDL support $sdl"
echo "SDL static link $sdl_static"
if test "$sdl" != "no" ; then
echo "SDL static link $sdl_static"
fi
echo "mingw32 support $mingw32"
echo "Adlib support $adlib"
echo -n "FMOD support $fmod"
@@ -344,13 +428,25 @@ if test $fmod = "yes"; then
echo -n " (lib='$fmod_lib' include='$fmod_inc')"
fi
echo ""
echo "kqemu support $kqemu"
if test $kqemu = "yes" -a $linux = "yes" ; then
echo ""
echo "KQEMU Linux module configuration:"
echo "kernel sources $kernel_path"
echo -n "kbuild type "
if test $kbuild26 = "yes"; then
echo "2.6"
else
echo "2.4"
fi
fi
if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
fi
if test "$sdl_static" = "no"; then
echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
echo "-> Your SDL version is too old - please upgrade to have SDL support"
fi
#if test "$sdl_static" = "no"; then
# echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
#fi
config_mak="config-host.mak"
config_h="config-host.h"
@@ -380,9 +476,12 @@ echo "EXESUF=$EXESUF" >> $config_mak
if test "$cpu" = "i386" ; then
echo "ARCH=i386" >> $config_mak
echo "#define HOST_I386 1" >> $config_h
elif test "$cpu" = "amd64" ; then
echo "ARCH=amd64" >> $config_mak
echo "#define HOST_AMD64 1" >> $config_h
elif test "$cpu" = "x86_64" ; then
echo "ARCH=x86_64" >> $config_mak
echo "#define HOST_X86_64 1" >> $config_h
elif test "$cpu" = "armv4b" ; then
echo "ARCH=arm" >> $config_mak
echo "#define HOST_ARM 1" >> $config_h
elif test "$cpu" = "armv4l" ; then
echo "ARCH=arm" >> $config_mak
echo "#define HOST_ARM 1" >> $config_h
@@ -465,6 +564,15 @@ echo -n "#define QEMU_VERSION \"" >> $config_h
head $source_path/VERSION >> $config_h
echo "\"" >> $config_h
if test $kqemu = "yes" ; then
echo "CONFIG_KQEMU=yes" >> $config_mak
if test $linux = "yes" ; then
echo "KERNEL_PATH=$kernel_path" >> $config_mak
if test $kbuild26 = "yes" ; then
echo "CONFIG_KBUILD26=yes" >> $config_mak
fi
fi
fi
echo "SRC_PATH=$source_path" >> $config_mak
echo "TARGET_DIRS=$target_list" >> $config_mak
@@ -482,7 +590,9 @@ config_mak=$target_dir/config.mak
config_h=$target_dir/config.h
target_cpu=`echo $target | cut -d '-' -f 1`
target_bigendian="no"
[ "$target_cpu" = "armeb" ] && target_bigendian=yes
[ "$target_cpu" = "sparc" ] && target_bigendian=yes
[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
[ "$target_cpu" = "ppc" ] && target_bigendian=yes
target_softmmu="no"
if expr $target : '.*-softmmu' > /dev/null ; then
@@ -496,7 +606,8 @@ fi
#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
mkdir -p $target_dir
if test "$target" = "arm-user" ; then
mkdir -p $target_dir/fpu
if test "$target" = "arm-user" -o "$target" = "armeb-user" ; then
mkdir -p $target_dir/nwfpe
fi
if test "$target_user_only" = "no" ; then
@@ -519,7 +630,10 @@ if test "$target_cpu" = "i386" ; then
echo "TARGET_ARCH=i386" >> $config_mak
echo "#define TARGET_ARCH \"i386\"" >> $config_h
echo "#define TARGET_I386 1" >> $config_h
elif test "$target_cpu" = "arm" ; then
if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then
echo "#define USE_KQEMU 1" >> $config_h
fi
elif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
echo "TARGET_ARCH=arm" >> $config_mak
echo "#define TARGET_ARCH \"arm\"" >> $config_h
echo "#define TARGET_ARM 1" >> $config_h
@@ -527,10 +641,23 @@ elif test "$target_cpu" = "sparc" ; then
echo "TARGET_ARCH=sparc" >> $config_mak
echo "#define TARGET_ARCH \"sparc\"" >> $config_h
echo "#define TARGET_SPARC 1" >> $config_h
elif test "$target_cpu" = "sparc64" ; then
echo "TARGET_ARCH=sparc64" >> $config_mak
echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
echo "#define TARGET_SPARC 1" >> $config_h
echo "#define TARGET_SPARC64 1" >> $config_h
elif test "$target_cpu" = "ppc" ; then
echo "TARGET_ARCH=ppc" >> $config_mak
echo "#define TARGET_ARCH \"ppc\"" >> $config_h
echo "#define TARGET_PPC 1" >> $config_h
elif test "$target_cpu" = "x86_64" ; then
echo "TARGET_ARCH=x86_64" >> $config_mak
echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
echo "#define TARGET_I386 1" >> $config_h
echo "#define TARGET_X86_64 1" >> $config_h
if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64" ; then
echo "#define USE_KQEMU 1" >> $config_h
fi
else
echo "Unsupported target CPU"
exit 1
@@ -548,6 +675,10 @@ if test "$target_user_only" = "yes" ; then
echo "#define CONFIG_USER_ONLY 1" >> $config_h
fi
if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
fi
# sdl defines
if test "$target_user_only" = "no"; then
@@ -572,6 +703,11 @@ if test "$target_user_only" = "no"; then
fi
fi
if test "$cocoa" = "yes" ; then
echo "#define CONFIG_COCOA 1" >> $config_h
echo "CONFIG_COCOA=yes" >> $config_mak
fi
done # for target in $targets
# build tree in object directory if source path is different from current one
+109 -72
View File
@@ -109,23 +109,27 @@ static inline void tswap64s(uint64_t *s)
#if TARGET_LONG_SIZE == 4
#define tswapl(s) tswap32(s)
#define tswapls(s) tswap32s((uint32_t *)(s))
#define bswaptls(s) bswap32s(s)
#else
#define tswapl(s) tswap64(s)
#define tswapls(s) tswap64s((uint64_t *)(s))
#define bswaptls(s) bswap64s(s)
#endif
/* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */
/* NOTE: arm FPA is horrible as double 32 bit words are stored in big
endian ! */
typedef union {
double d;
#if !defined(WORDS_BIGENDIAN) && !defined(__arm__)
float64 d;
#if defined(WORDS_BIGENDIAN) \
|| (defined(__arm__) && !defined(__VFP_FP__) && !defined(CONFIG_SOFTFLOAT))
struct {
uint32_t lower;
uint32_t upper;
uint32_t lower;
} l;
#else
struct {
uint32_t upper;
uint32_t lower;
uint32_t upper;
} l;
#endif
uint64_t ll;
@@ -166,17 +170,17 @@ typedef union {
* user : user mode access using soft MMU
* kernel : kernel mode access using soft MMU
*/
static inline int ldub_raw(void *ptr)
static inline int ldub_p(void *ptr)
{
return *(uint8_t *)ptr;
}
static inline int ldsb_raw(void *ptr)
static inline int ldsb_p(void *ptr)
{
return *(int8_t *)ptr;
}
static inline void stb_raw(void *ptr, int v)
static inline void stb_p(void *ptr, int v)
{
*(uint8_t *)ptr = v;
}
@@ -187,7 +191,7 @@ static inline void stb_raw(void *ptr, int v)
#if !defined(TARGET_WORDS_BIGENDIAN) && (defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
/* conservative code for little endian unaligned accesses */
static inline int lduw_raw(void *ptr)
static inline int lduw_p(void *ptr)
{
#ifdef __powerpc__
int val;
@@ -199,7 +203,7 @@ static inline int lduw_raw(void *ptr)
#endif
}
static inline int ldsw_raw(void *ptr)
static inline int ldsw_p(void *ptr)
{
#ifdef __powerpc__
int val;
@@ -211,7 +215,7 @@ static inline int ldsw_raw(void *ptr)
#endif
}
static inline int ldl_raw(void *ptr)
static inline int ldl_p(void *ptr)
{
#ifdef __powerpc__
int val;
@@ -223,16 +227,16 @@ static inline int ldl_raw(void *ptr)
#endif
}
static inline uint64_t ldq_raw(void *ptr)
static inline uint64_t ldq_p(void *ptr)
{
uint8_t *p = ptr;
uint32_t v1, v2;
v1 = ldl_raw(p);
v2 = ldl_raw(p + 4);
v1 = ldl_p(p);
v2 = ldl_p(p + 4);
return v1 | ((uint64_t)v2 << 32);
}
static inline void stw_raw(void *ptr, int v)
static inline void stw_p(void *ptr, int v)
{
#ifdef __powerpc__
__asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr));
@@ -243,7 +247,7 @@ static inline void stw_raw(void *ptr, int v)
#endif
}
static inline void stl_raw(void *ptr, int v)
static inline void stl_p(void *ptr, int v)
{
#ifdef __powerpc__
__asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr));
@@ -256,54 +260,54 @@ static inline void stl_raw(void *ptr, int v)
#endif
}
static inline void stq_raw(void *ptr, uint64_t v)
static inline void stq_p(void *ptr, uint64_t v)
{
uint8_t *p = ptr;
stl_raw(p, (uint32_t)v);
stl_raw(p + 4, v >> 32);
stl_p(p, (uint32_t)v);
stl_p(p + 4, v >> 32);
}
/* float access */
static inline float ldfl_raw(void *ptr)
static inline float32 ldfl_p(void *ptr)
{
union {
float f;
float32 f;
uint32_t i;
} u;
u.i = ldl_raw(ptr);
u.i = ldl_p(ptr);
return u.f;
}
static inline void stfl_raw(void *ptr, float v)
static inline void stfl_p(void *ptr, float32 v)
{
union {
float f;
float32 f;
uint32_t i;
} u;
u.f = v;
stl_raw(ptr, u.i);
stl_p(ptr, u.i);
}
static inline double ldfq_raw(void *ptr)
static inline float64 ldfq_p(void *ptr)
{
CPU_DoubleU u;
u.l.lower = ldl_raw(ptr);
u.l.upper = ldl_raw(ptr + 4);
u.l.lower = ldl_p(ptr);
u.l.upper = ldl_p(ptr + 4);
return u.d;
}
static inline void stfq_raw(void *ptr, double v)
static inline void stfq_p(void *ptr, float64 v)
{
CPU_DoubleU u;
u.d = v;
stl_raw(ptr, u.l.lower);
stl_raw(ptr + 4, u.l.upper);
stl_p(ptr, u.l.lower);
stl_p(ptr + 4, u.l.upper);
}
#elif defined(TARGET_WORDS_BIGENDIAN) && (!defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
static inline int lduw_raw(void *ptr)
static inline int lduw_p(void *ptr)
{
#if defined(__i386__)
int val;
@@ -318,7 +322,7 @@ static inline int lduw_raw(void *ptr)
#endif
}
static inline int ldsw_raw(void *ptr)
static inline int ldsw_p(void *ptr)
{
#if defined(__i386__)
int val;
@@ -333,7 +337,7 @@ static inline int ldsw_raw(void *ptr)
#endif
}
static inline int ldl_raw(void *ptr)
static inline int ldl_p(void *ptr)
{
#if defined(__i386__) || defined(__x86_64__)
int val;
@@ -348,15 +352,15 @@ static inline int ldl_raw(void *ptr)
#endif
}
static inline uint64_t ldq_raw(void *ptr)
static inline uint64_t ldq_p(void *ptr)
{
uint32_t a,b;
a = ldl_raw(ptr);
b = ldl_raw(ptr+4);
a = ldl_p(ptr);
b = ldl_p(ptr+4);
return (((uint64_t)a<<32)|b);
}
static inline void stw_raw(void *ptr, int v)
static inline void stw_p(void *ptr, int v)
{
#if defined(__i386__)
asm volatile ("xchgb %b0, %h0\n"
@@ -370,7 +374,7 @@ static inline void stw_raw(void *ptr, int v)
#endif
}
static inline void stl_raw(void *ptr, int v)
static inline void stl_p(void *ptr, int v)
{
#if defined(__i386__) || defined(__x86_64__)
asm volatile ("bswap %0\n"
@@ -386,112 +390,130 @@ static inline void stl_raw(void *ptr, int v)
#endif
}
static inline void stq_raw(void *ptr, uint64_t v)
static inline void stq_p(void *ptr, uint64_t v)
{
stl_raw(ptr, v >> 32);
stl_raw(ptr + 4, v);
stl_p(ptr, v >> 32);
stl_p(ptr + 4, v);
}
/* float access */
static inline float ldfl_raw(void *ptr)
static inline float32 ldfl_p(void *ptr)
{
union {
float f;
float32 f;
uint32_t i;
} u;
u.i = ldl_raw(ptr);
u.i = ldl_p(ptr);
return u.f;
}
static inline void stfl_raw(void *ptr, float v)
static inline void stfl_p(void *ptr, float32 v)
{
union {
float f;
float32 f;
uint32_t i;
} u;
u.f = v;
stl_raw(ptr, u.i);
stl_p(ptr, u.i);
}
static inline double ldfq_raw(void *ptr)
static inline float64 ldfq_p(void *ptr)
{
CPU_DoubleU u;
u.l.upper = ldl_raw(ptr);
u.l.lower = ldl_raw(ptr + 4);
u.l.upper = ldl_p(ptr);
u.l.lower = ldl_p(ptr + 4);
return u.d;
}
static inline void stfq_raw(void *ptr, double v)
static inline void stfq_p(void *ptr, float64 v)
{
CPU_DoubleU u;
u.d = v;
stl_raw(ptr, u.l.upper);
stl_raw(ptr + 4, u.l.lower);
stl_p(ptr, u.l.upper);
stl_p(ptr + 4, u.l.lower);
}
#else
static inline int lduw_raw(void *ptr)
static inline int lduw_p(void *ptr)
{
return *(uint16_t *)ptr;
}
static inline int ldsw_raw(void *ptr)
static inline int ldsw_p(void *ptr)
{
return *(int16_t *)ptr;
}
static inline int ldl_raw(void *ptr)
static inline int ldl_p(void *ptr)
{
return *(uint32_t *)ptr;
}
static inline uint64_t ldq_raw(void *ptr)
static inline uint64_t ldq_p(void *ptr)
{
return *(uint64_t *)ptr;
}
static inline void stw_raw(void *ptr, int v)
static inline void stw_p(void *ptr, int v)
{
*(uint16_t *)ptr = v;
}
static inline void stl_raw(void *ptr, int v)
static inline void stl_p(void *ptr, int v)
{
*(uint32_t *)ptr = v;
}
static inline void stq_raw(void *ptr, uint64_t v)
static inline void stq_p(void *ptr, uint64_t v)
{
*(uint64_t *)ptr = v;
}
/* float access */
static inline float ldfl_raw(void *ptr)
static inline float32 ldfl_p(void *ptr)
{
return *(float *)ptr;
return *(float32 *)ptr;
}
static inline double ldfq_raw(void *ptr)
static inline float64 ldfq_p(void *ptr)
{
return *(double *)ptr;
return *(float64 *)ptr;
}
static inline void stfl_raw(void *ptr, float v)
static inline void stfl_p(void *ptr, float32 v)
{
*(float *)ptr = v;
*(float32 *)ptr = v;
}
static inline void stfq_raw(void *ptr, double v)
static inline void stfq_p(void *ptr, float64 v)
{
*(double *)ptr = v;
*(float64 *)ptr = v;
}
#endif
/* MMU memory access macros */
/* NOTE: we use double casts if pointers and target_ulong have
different sizes */
#define ldub_raw(p) ldub_p((uint8_t *)(long)(p))
#define ldsb_raw(p) ldsb_p((uint8_t *)(long)(p))
#define lduw_raw(p) lduw_p((uint8_t *)(long)(p))
#define ldsw_raw(p) ldsw_p((uint8_t *)(long)(p))
#define ldl_raw(p) ldl_p((uint8_t *)(long)(p))
#define ldq_raw(p) ldq_p((uint8_t *)(long)(p))
#define ldfl_raw(p) ldfl_p((uint8_t *)(long)(p))
#define ldfq_raw(p) ldfq_p((uint8_t *)(long)(p))
#define stb_raw(p, v) stb_p((uint8_t *)(long)(p), v)
#define stw_raw(p, v) stw_p((uint8_t *)(long)(p), v)
#define stl_raw(p, v) stl_p((uint8_t *)(long)(p), v)
#define stq_raw(p, v) stq_p((uint8_t *)(long)(p), v)
#define stfl_raw(p, v) stfl_p((uint8_t *)(long)(p), v)
#define stfq_raw(p, v) stfq_p((uint8_t *)(long)(p), v)
#if defined(CONFIG_USER_ONLY)
/* if user mode, no other memory access functions */
@@ -707,21 +729,36 @@ static inline void cpu_physical_memory_write(target_phys_addr_t addr,
{
cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
}
uint32_t ldl_phys(target_phys_addr_t addr);
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val);
void stl_phys(target_phys_addr_t addr, uint32_t val);
int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
uint8_t *buf, int len, int is_write);
#define VGA_DIRTY_FLAG 0x01
/* read dirty bit (return 0 or 1) */
static inline int cpu_physical_memory_is_dirty(target_ulong addr)
{
return phys_ram_dirty[addr >> TARGET_PAGE_BITS];
return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
}
static inline int cpu_physical_memory_get_dirty(target_ulong addr,
int dirty_flags)
{
return phys_ram_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
}
static inline void cpu_physical_memory_set_dirty(target_ulong addr)
{
phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 1;
phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
}
void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end);
void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end,
int dirty_flags);
void dump_exec_info(FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
#endif /* CPU_ALL_H */
+2
View File
@@ -49,9 +49,11 @@
#if TARGET_LONG_SIZE == 4
typedef int32_t target_long;
typedef uint32_t target_ulong;
#define TARGET_FMT_lx "%08x"
#elif TARGET_LONG_SIZE == 8
typedef int64_t target_long;
typedef uint64_t target_ulong;
#define TARGET_FMT_lx "%016llx"
#else
#error TARGET_LONG_SIZE undefined
#endif
+195 -46
View File
@@ -1,7 +1,7 @@
/*
* i386 emulator main execution loop
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2003-2005 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -106,15 +106,16 @@ int cpu_exec(CPUState *env1)
int code_gen_size, ret, interrupt_request;
void (*gen_func)(void);
TranslationBlock *tb, **ptb;
uint8_t *tc_ptr, *cs_base, *pc;
target_ulong cs_base, pc;
uint8_t *tc_ptr;
unsigned int flags;
/* first we save global registers */
saved_env = env;
env = env1;
saved_T0 = T0;
saved_T1 = T1;
saved_T2 = T2;
saved_env = env;
env = env1;
#ifdef __sparc__
/* we also save i7 because longjmp may not restore it */
asm volatile ("mov %%i7, %0" : "=r" (saved_i7));
@@ -159,7 +160,8 @@ int cpu_exec(CPUState *env1)
env->CF = (psr >> 29) & 1;
env->NZF = (psr & 0xc0000000) ^ 0x40000000;
env->VF = (psr << 3) & 0x80000000;
env->cpsr = psr & ~0xf0000000;
env->QF = (psr >> 27) & 1;
env->cpsr = psr & ~CACHED_CPSR_BITS;
}
#elif defined(TARGET_SPARC)
#elif defined(TARGET_PPC)
@@ -202,14 +204,37 @@ int cpu_exec(CPUState *env1)
#elif defined(TARGET_PPC)
do_interrupt(env);
#elif defined(TARGET_SPARC)
do_interrupt(env->exception_index,
0,
env->error_code,
env->exception_next_pc, 0);
do_interrupt(env->exception_index);
#endif
}
env->exception_index = -1;
}
#ifdef USE_KQEMU
if (kqemu_is_ok(env) && env->interrupt_request == 0) {
int ret;
env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
ret = kqemu_cpu_exec(env);
/* put eflags in CPU temporary format */
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
DF = 1 - (2 * ((env->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
if (ret == 1) {
/* exception */
longjmp(env->jmp_env, 1);
} else if (ret == 2) {
/* softmmu execution needed */
} else {
if (env->interrupt_request != 0) {
/* hardware interrupt will be executed just after */
} else {
/* otherwise, we restart */
longjmp(env->jmp_env, 1);
}
}
}
#endif
T0 = 0; /* force lookup of first TB */
for(;;) {
#ifdef __sparc__
@@ -260,9 +285,18 @@ int cpu_exec(CPUState *env1)
}
}
#elif defined(TARGET_SPARC)
if (interrupt_request & CPU_INTERRUPT_HARD) {
do_interrupt(0, 0, 0, 0, 0);
env->interrupt_request &= ~CPU_INTERRUPT_HARD;
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(env->psret != 0)) {
int pil = env->interrupt_index & 15;
int type = env->interrupt_index & 0xf0;
if (((type == TT_EXTINT) &&
(pil == 15 || pil > env->psrpil)) ||
type != TT_EXTINT) {
env->interrupt_request &= ~CPU_INTERRUPT_HARD;
do_interrupt(env->interrupt_index);
env->interrupt_index = 0;
}
} else if (interrupt_request & CPU_INTERRUPT_TIMER) {
//do_interrupt(0, 0, 0, 0, 0);
env->interrupt_request &= ~CPU_INTERRUPT_TIMER;
@@ -285,24 +319,40 @@ int cpu_exec(CPUState *env1)
}
}
#ifdef DEBUG_EXEC
if (loglevel & CPU_LOG_EXEC) {
if ((loglevel & CPU_LOG_EXEC)) {
#if defined(TARGET_I386)
/* restore flags in standard format */
#ifdef reg_EAX
env->regs[R_EAX] = EAX;
#endif
#ifdef reg_EBX
env->regs[R_EBX] = EBX;
#endif
#ifdef reg_ECX
env->regs[R_ECX] = ECX;
#endif
#ifdef reg_EDX
env->regs[R_EDX] = EDX;
#endif
#ifdef reg_ESI
env->regs[R_ESI] = ESI;
#endif
#ifdef reg_EDI
env->regs[R_EDI] = EDI;
#endif
#ifdef reg_EBP
env->regs[R_EBP] = EBP;
#endif
#ifdef reg_ESP
env->regs[R_ESP] = ESP;
#endif
env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_ARM)
env->cpsr = compute_cpsr();
cpu_dump_state(env, logfile, fprintf, 0);
env->cpsr &= ~0xf0000000;
env->cpsr &= ~CACHED_CPSR_BITS;
#elif defined(TARGET_SPARC)
cpu_dump_state (env, logfile, fprintf, 0);
#elif defined(TARGET_PPC)
@@ -321,21 +371,23 @@ int cpu_exec(CPUState *env1)
cs_base = env->segs[R_CS].base;
pc = cs_base + env->eip;
#elif defined(TARGET_ARM)
flags = 0;
flags = env->thumb | (env->vfp.vec_len << 1)
| (env->vfp.vec_stride << 4);
cs_base = 0;
pc = (uint8_t *)env->regs[15];
pc = env->regs[15];
#elif defined(TARGET_SPARC)
flags = 0;
cs_base = (uint8_t *)env->npc;
pc = (uint8_t *) env->pc;
cs_base = env->npc;
pc = env->pc;
#elif defined(TARGET_PPC)
flags = 0;
flags = (msr_pr << MSR_PR) | (msr_fp << MSR_FP) |
(msr_se << MSR_SE) | (msr_le << MSR_LE);
cs_base = 0;
pc = (uint8_t *)env->nip;
pc = env->nip;
#else
#error unsupported CPU
#endif
tb = tb_find(&ptb, (unsigned long)pc, (unsigned long)cs_base,
tb = tb_find(&ptb, pc, cs_base,
flags);
if (!tb) {
TranslationBlock **ptb1;
@@ -350,7 +402,7 @@ int cpu_exec(CPUState *env1)
regs_to_env(); /* XXX: do it just before cpu_gen_code() */
/* find translated block using physical mappings */
phys_pc = get_phys_addr_code(env, (unsigned long)pc);
phys_pc = get_phys_addr_code(env, pc);
phys_page1 = phys_pc & TARGET_PAGE_MASK;
phys_page2 = -1;
h = tb_phys_hash_func(phys_pc);
@@ -359,13 +411,13 @@ int cpu_exec(CPUState *env1)
tb = *ptb1;
if (!tb)
goto not_found;
if (tb->pc == (unsigned long)pc &&
if (tb->pc == pc &&
tb->page_addr[0] == phys_page1 &&
tb->cs_base == (unsigned long)cs_base &&
tb->cs_base == cs_base &&
tb->flags == flags) {
/* check next page if needed */
if (tb->page_addr[1] != -1) {
virt_page2 = ((unsigned long)pc & TARGET_PAGE_MASK) +
virt_page2 = (pc & TARGET_PAGE_MASK) +
TARGET_PAGE_SIZE;
phys_page2 = get_phys_addr_code(env, virt_page2);
if (tb->page_addr[1] == phys_page2)
@@ -378,27 +430,27 @@ int cpu_exec(CPUState *env1)
}
not_found:
/* if no translated code available, then translate it now */
tb = tb_alloc((unsigned long)pc);
tb = tb_alloc(pc);
if (!tb) {
/* flush must be done */
tb_flush(env);
/* cannot fail at this point */
tb = tb_alloc((unsigned long)pc);
tb = tb_alloc(pc);
/* don't forget to invalidate previous TB info */
ptb = &tb_hash[tb_hash_func((unsigned long)pc)];
ptb = &tb_hash[tb_hash_func(pc)];
T0 = 0;
}
tc_ptr = code_gen_ptr;
tb->tc_ptr = tc_ptr;
tb->cs_base = (unsigned long)cs_base;
tb->cs_base = cs_base;
tb->flags = flags;
cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
/* check next page if needed */
virt_page2 = ((unsigned long)pc + tb->size - 1) & TARGET_PAGE_MASK;
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if (((unsigned long)pc & TARGET_PAGE_MASK) != virt_page2) {
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_phys_addr_code(env, virt_page2);
}
tb_link_phys(tb, phys_pc, phys_page2);
@@ -408,7 +460,7 @@ int cpu_exec(CPUState *env1)
/* as some TB could have been invalidated because
of memory exceptions while generating the code, we
must recompute the hash index here */
ptb = &tb_hash[tb_hash_func((unsigned long)pc)];
ptb = &tb_hash[tb_hash_func(pc)];
while (*ptb != NULL)
ptb = &(*ptb)->hash_next;
T0 = 0;
@@ -420,24 +472,25 @@ int cpu_exec(CPUState *env1)
spin_unlock(&tb_lock);
}
#ifdef DEBUG_EXEC
if (loglevel & CPU_LOG_EXEC) {
fprintf(logfile, "Trace 0x%08lx [0x%08lx] %s\n",
(long)tb->tc_ptr, (long)tb->pc,
lookup_symbol((void *)tb->pc));
if ((loglevel & CPU_LOG_EXEC)) {
fprintf(logfile, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
(long)tb->tc_ptr, tb->pc,
lookup_symbol(tb->pc));
}
#endif
#ifdef __sparc__
T0 = tmp_T0;
#endif
/* see if we can patch the calling TB. */
if (T0 != 0
{
if (T0 != 0
#if defined(TARGET_I386) && defined(USE_CODE_COPY)
&& (tb->cflags & CF_CODE_COPY) ==
(((TranslationBlock *)(T0 & ~3))->cflags & CF_CODE_COPY)
#endif
) {
spin_lock(&tb_lock);
tb_add_jump((TranslationBlock *)(T0 & ~3), T0 & 3, tb);
tb_add_jump((TranslationBlock *)(long)(T0 & ~3), T0 & 3, tb);
#if defined(USE_CODE_COPY)
/* propagates the FP use info */
((TranslationBlock *)(T0 & ~3))->cflags |=
@@ -445,6 +498,7 @@ int cpu_exec(CPUState *env1)
#endif
spin_unlock(&tb_lock);
}
}
tc_ptr = tb->tc_ptr;
env->current_tb = tb;
/* execute the generated code */
@@ -536,6 +590,15 @@ int cpu_exec(CPUState *env1)
);
}
}
#elif defined(__ia64)
struct fptr {
void *ip;
void *gp;
} fp;
fp.ip = tc_ptr;
fp.gp = code_gen_buffer + 2 * (1 << 20);
(*(void (*)(void)) &fp)();
#else
gen_func();
#endif
@@ -592,6 +655,7 @@ int cpu_exec(CPUState *env1)
#endif
#elif defined(TARGET_ARM)
env->cpsr = compute_cpsr();
/* XXX: Save/restore host fpu exception state?. */
#elif defined(TARGET_SPARC)
#elif defined(TARGET_PPC)
#else
@@ -631,7 +695,7 @@ void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector)
if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) {
selector &= 0xffff;
cpu_x86_load_seg_cache(env, seg_reg, selector,
(uint8_t *)(selector << 4), 0xffff, 0);
(selector << 4), 0xffff, 0);
} else {
load_seg(seg_reg, selector);
}
@@ -645,7 +709,7 @@ void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)
saved_env = env;
env = s;
helper_fsave(ptr, data32);
helper_fsave((target_ulong)ptr, data32);
env = saved_env;
}
@@ -657,7 +721,7 @@ void cpu_x86_frstor(CPUX86State *s, uint8_t *ptr, int data32)
saved_env = env;
env = s;
helper_frstor(ptr, data32);
helper_frstor((target_ulong)ptr, data32);
env = saved_env;
}
@@ -727,19 +791,72 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
int is_write, sigset_t *old_set,
void *puc)
{
/* XXX: do more */
return 0;
TranslationBlock *tb;
int ret;
if (cpu_single_env)
env = cpu_single_env; /* XXX: find a correct solution for multithread */
#if defined(DEBUG_SIGNAL)
printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set);
#endif
/* XXX: locking issue */
if (is_write && page_unprotect(address, pc, puc)) {
return 1;
}
/* see if it is an MMU fault */
ret = cpu_arm_handle_mmu_fault(env, address, is_write, 1, 0);
if (ret < 0)
return 0; /* not an MMU fault */
if (ret == 0)
return 1; /* the MMU fault was handled without causing real CPU fault */
/* now we have a real cpu fault */
tb = tb_find_pc(pc);
if (tb) {
/* the PC is inside the translated code. It means that we have
a virtual CPU fault */
cpu_restore_state(tb, env, pc, puc);
}
/* we restore the process signal mask as the sigreturn should
do it (XXX: use sigsetjmp) */
sigprocmask(SIG_SETMASK, old_set, NULL);
cpu_loop_exit();
}
#elif defined(TARGET_SPARC)
static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
int is_write, sigset_t *old_set,
void *puc)
{
TranslationBlock *tb;
int ret;
if (cpu_single_env)
env = cpu_single_env; /* XXX: find a correct solution for multithread */
#if defined(DEBUG_SIGNAL)
printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set);
#endif
/* XXX: locking issue */
if (is_write && page_unprotect(address, pc, puc)) {
return 1;
}
return 0;
/* see if it is an MMU fault */
ret = cpu_sparc_handle_mmu_fault(env, address, is_write, 1, 0);
if (ret < 0)
return 0; /* not an MMU fault */
if (ret == 0)
return 1; /* the MMU fault was handled without causing real CPU fault */
/* now we have a real cpu fault */
tb = tb_find_pc(pc);
if (tb) {
/* the PC is inside the translated code. It means that we have
a virtual CPU fault */
cpu_restore_state(tb, env, pc, puc);
}
/* we restore the process signal mask as the sigreturn should
do it (XXX: use sigsetjmp) */
sigprocmask(SIG_SETMASK, old_set, NULL);
cpu_loop_exit();
}
#elif defined (TARGET_PPC)
static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
@@ -749,10 +866,8 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
TranslationBlock *tb;
int ret;
#if 1
if (cpu_single_env)
env = cpu_single_env; /* XXX: find a correct solution for multithread */
#endif
#if defined(DEBUG_SIGNAL)
printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set);
@@ -1029,6 +1144,40 @@ int cpu_signal_handler(int host_signum, struct siginfo *info,
&uc->uc_sigmask, puc);
}
#elif defined(__ia64)
#ifndef __ISR_VALID
/* This ought to be in <bits/siginfo.h>... */
# define __ISR_VALID 1
# define si_flags _sifields._sigfault._si_pad0
#endif
int cpu_signal_handler(int host_signum, struct siginfo *info, void *puc)
{
struct ucontext *uc = puc;
unsigned long ip;
int is_write = 0;
ip = uc->uc_mcontext.sc_ip;
switch (host_signum) {
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGBUS:
case SIGTRAP:
if (info->si_code && (info->si_flags & __ISR_VALID))
/* ISR.W (write-access) is bit 33: */
is_write = (info->si_isr >> 33) & 1;
break;
default:
break;
}
return handle_cpu_signal(ip, (unsigned long)info->si_addr,
is_write,
&uc->uc_sigmask, puc);
}
#else
#error host CPU specific signal handler needed
+3
View File
@@ -9,6 +9,7 @@
#ifndef DIS_ASM_H
#define DIS_ASM_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
@@ -20,6 +21,8 @@ typedef int64_t bfd_signed_vma;
typedef uint8_t bfd_byte;
#define sprintf_vma(s,x) sprintf (s, "%0" PRIx64, x)
#define BFD64
enum bfd_flavour {
bfd_target_unknown_flavour,
bfd_target_aout_flavour,
+125 -76
View File
@@ -9,9 +9,7 @@
#include "disas.h"
/* Filled in by elfload.c. Simplistic, but will do for now. */
unsigned int disas_num_syms;
void *disas_symtab;
const char *disas_strtab;
struct syminfo *syminfos = NULL;
/* Get LENGTH bytes from info's buffer, at target address memaddr.
Transfer them to myaddr. */
@@ -30,23 +28,20 @@ buffer_read_memory (memaddr, myaddr, length, info)
return 0;
}
#if !defined(CONFIG_USER_ONLY)
/* Get LENGTH bytes from info's buffer, at target address memaddr.
Transfer them to myaddr. */
static int
target_read_memory (memaddr, myaddr, length, info)
bfd_vma memaddr;
bfd_byte *myaddr;
int length;
struct disassemble_info *info;
target_read_memory (bfd_vma memaddr,
bfd_byte *myaddr,
int length,
struct disassemble_info *info)
{
int i;
for(i = 0; i < length; i++) {
myaddr[i] = ldub_code((void *)((long)memaddr + i));
myaddr[i] = ldub_code(memaddr + i);
}
return 0;
}
#endif
/* Print an error message. We can assume that this is in response to
an error return from buffer_read_memory. */
@@ -113,77 +108,124 @@ bfd_vma bfd_getb32 (const bfd_byte *addr)
return (bfd_vma) v;
}
/* Disassemble this for me please... (debugging). 'flags' is only used
for i386: non zero means 16 bit code */
void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
#ifdef TARGET_ARM
static int
print_insn_thumb1(bfd_vma pc, disassemble_info *info)
{
uint8_t *pc;
return print_insn_arm(pc | 1, info);
}
#endif
/* Disassemble this for me please... (debugging). 'flags' has teh following
values:
i386 - nonzero means 16 bit code
arm - nonzero means thumb code
other targets - unused
*/
void target_disas(FILE *out, target_ulong code, target_ulong size, int flags)
{
target_ulong pc;
int count;
struct disassemble_info disasm_info;
int (*print_insn)(bfd_vma pc, disassemble_info *info);
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
#if !defined(CONFIG_USER_ONLY)
if (!is_host) {
disasm_info.read_memory_func = target_read_memory;
}
disasm_info.read_memory_func = target_read_memory;
disasm_info.buffer_vma = code;
disasm_info.buffer_length = size;
#ifdef TARGET_WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
#else
disasm_info.endian = BFD_ENDIAN_LITTLE;
#endif
#if defined(TARGET_I386)
if (flags == 2)
disasm_info.mach = bfd_mach_x86_64;
else if (flags == 1)
disasm_info.mach = bfd_mach_i386_i8086;
else
disasm_info.mach = bfd_mach_i386_i386;
print_insn = print_insn_i386;
#elif defined(TARGET_ARM)
if (flags)
print_insn = print_insn_thumb1;
else
print_insn = print_insn_arm;
#elif defined(TARGET_SPARC)
print_insn = print_insn_sparc;
#elif defined(TARGET_PPC)
if (cpu_single_env->msr[MSR_LE])
disasm_info.endian = BFD_ENDIAN_LITTLE;
print_insn = print_insn_ppc;
#else
fprintf(out, "0x" TARGET_FMT_lx
": Asm output not supported on this arch\n", code);
return;
#endif
for (pc = code; pc < code + size; pc += count) {
fprintf(out, "0x" TARGET_FMT_lx ": ", pc);
count = print_insn(pc, &disasm_info);
#if 0
{
int i;
uint8_t b;
fprintf(out, " {");
for(i = 0; i < count; i++) {
target_read_memory(pc + i, &b, 1, &disasm_info);
fprintf(out, " %02x", b);
}
fprintf(out, " }");
}
#endif
fprintf(out, "\n");
if (count < 0)
break;
}
}
/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size)
{
unsigned long pc;
int count;
struct disassemble_info disasm_info;
int (*print_insn)(bfd_vma pc, disassemble_info *info);
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
disasm_info.buffer = code;
disasm_info.buffer_vma = (unsigned long)code;
disasm_info.buffer_length = size;
if (is_host) {
#ifdef WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
disasm_info.endian = BFD_ENDIAN_BIG;
#else
disasm_info.endian = BFD_ENDIAN_LITTLE;
disasm_info.endian = BFD_ENDIAN_LITTLE;
#endif
#if defined(__i386__)
disasm_info.mach = bfd_mach_i386_i386;
print_insn = print_insn_i386;
disasm_info.mach = bfd_mach_i386_i386;
print_insn = print_insn_i386;
#elif defined(__x86_64__)
disasm_info.mach = bfd_mach_x86_64;
print_insn = print_insn_i386;
disasm_info.mach = bfd_mach_x86_64;
print_insn = print_insn_i386;
#elif defined(__powerpc__)
print_insn = print_insn_ppc;
print_insn = print_insn_ppc;
#elif defined(__alpha__)
print_insn = print_insn_alpha;
print_insn = print_insn_alpha;
#elif defined(__sparc__)
print_insn = print_insn_sparc;
print_insn = print_insn_sparc;
#elif defined(__arm__)
print_insn = print_insn_arm;
print_insn = print_insn_arm;
#else
fprintf(out, "Asm output not supported on this arch\n");
return;
fprintf(out, "0x%lx: Asm output not supported on this arch\n",
(long) code);
return;
#endif
} else {
#ifdef TARGET_WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
#else
disasm_info.endian = BFD_ENDIAN_LITTLE;
#endif
#if defined(TARGET_I386)
if (!flags)
disasm_info.mach = bfd_mach_i386_i386;
else
disasm_info.mach = bfd_mach_i386_i8086;
print_insn = print_insn_i386;
#elif defined(TARGET_ARM)
print_insn = print_insn_arm;
#elif defined(TARGET_SPARC)
print_insn = print_insn_sparc;
#elif defined(TARGET_PPC)
print_insn = print_insn_ppc;
#else
fprintf(out, "Asm output not supported on this arch\n");
return;
#endif
}
for (pc = code; pc < (uint8_t *)code + size; pc += count) {
fprintf(out, "0x%08lx: ", (long)pc);
for (pc = (unsigned long)code; pc < (unsigned long)code + size; pc += count) {
fprintf(out, "0x%08lx: ", pc);
#ifdef __arm__
/* since data are included in the code, it is better to
display code data too */
@@ -191,7 +233,7 @@ void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc));
}
#endif
count = print_insn((unsigned long)pc, &disasm_info);
count = print_insn(pc, &disasm_info);
fprintf(out, "\n");
if (count < 0)
break;
@@ -199,23 +241,27 @@ void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
}
/* Look up symbol for debugging purpose. Returns "" if unknown. */
const char *lookup_symbol(void *orig_addr)
const char *lookup_symbol(target_ulong orig_addr)
{
unsigned int i;
/* Hack, because we know this is x86. */
Elf32_Sym *sym = disas_symtab;
Elf32_Sym *sym;
struct syminfo *s;
for (s = syminfos; s; s = s->next) {
sym = s->disas_symtab;
for (i = 0; i < s->disas_num_syms; i++) {
if (sym[i].st_shndx == SHN_UNDEF
|| sym[i].st_shndx >= SHN_LORESERVE)
continue;
for (i = 0; i < disas_num_syms; i++) {
if (sym[i].st_shndx == SHN_UNDEF
|| sym[i].st_shndx >= SHN_LORESERVE)
continue;
if (ELF_ST_TYPE(sym[i].st_info) != STT_FUNC)
continue;
if (ELF_ST_TYPE(sym[i].st_info) != STT_FUNC)
continue;
if ((long)orig_addr >= sym[i].st_value
&& (long)orig_addr < sym[i].st_value + sym[i].st_size)
return disas_strtab + sym[i].st_name;
if (orig_addr >= sym[i].st_value
&& orig_addr < sym[i].st_value + sym[i].st_size)
return s->disas_strtab + sym[i].st_name;
}
}
return "";
}
@@ -270,10 +316,12 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags)
disasm_info.endian = BFD_ENDIAN_LITTLE;
#endif
#if defined(TARGET_I386)
if (!flags)
disasm_info.mach = bfd_mach_i386_i386;
else
if (flags == 2)
disasm_info.mach = bfd_mach_x86_64;
else if (flags == 1)
disasm_info.mach = bfd_mach_i386_i8086;
else
disasm_info.mach = bfd_mach_i386_i386;
print_insn = print_insn_i386;
#elif defined(TARGET_ARM)
print_insn = print_insn_arm;
@@ -282,12 +330,13 @@ void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags)
#elif defined(TARGET_PPC)
print_insn = print_insn_ppc;
#else
term_printf("Asm output not supported on this arch\n");
term_printf("0x" TARGET_FMT_lx
": Asm output not supported on this arch\n", pc);
return;
#endif
for(i = 0; i < nb_insn; i++) {
term_printf("0x%08lx: ", (unsigned long)pc);
term_printf("0x" TARGET_FMT_lx ": ", pc);
count = print_insn(pc, &disasm_info);
term_printf("\n");
if (count < 0)
+10 -5
View File
@@ -2,14 +2,19 @@
#define _QEMU_DISAS_H
/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size, int is_host, int flags);
void disas(FILE *out, void *code, unsigned long size);
void target_disas(FILE *out, target_ulong code, target_ulong size, int flags);
void monitor_disas(target_ulong pc, int nb_insn, int is_physical, int flags);
/* Look up symbol for debugging purpose. Returns "" if unknown. */
const char *lookup_symbol(void *orig_addr);
const char *lookup_symbol(target_ulong orig_addr);
/* Filled in by elfload.c. Simplistic, but will do for now. */
extern unsigned int disas_num_syms;
extern void *disas_symtab; /* FIXME: includes are a mess --RR */
extern const char *disas_strtab;
extern struct syminfo {
unsigned int disas_num_syms;
void *disas_symtab;
const char *disas_strtab;
struct syminfo *next;
} *syminfos;
#endif /* _QEMU_DISAS_H */
+20 -19
View File
@@ -29,7 +29,7 @@ typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
/* XXX may be done for all 64 bits targets ? */
#if defined (__x86_64__)
#if defined (__x86_64__) || defined(__ia64)
typedef unsigned long uint64_t;
#else
typedef unsigned long long uint64_t;
@@ -38,7 +38,7 @@ typedef unsigned long long uint64_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
#if defined (__x86_64__)
#if defined (__x86_64__) || defined(__ia64)
typedef signed long int64_t;
#else
typedef signed long long int64_t;
@@ -62,17 +62,6 @@ extern int fprintf(FILE *, const char *, ...);
extern int printf(const char *, ...);
#undef NULL
#define NULL 0
#if defined(_BSD) && !defined(__APPLE__)
#include <ieeefp.h>
#define FE_TONEAREST FP_RN
#define FE_DOWNWARD FP_RM
#define FE_UPWARD FP_RP
#define FE_TOWARDZERO FP_RZ
#define fesetround(x) fpsetround(x)
#else
#include <fenv.h>
#endif
#ifdef __i386__
#define AREG0 "ebp"
@@ -85,8 +74,8 @@ extern int printf(const char *, ...);
#define AREG1 "rbx"
#define AREG2 "r12"
#define AREG3 "r13"
#define AREG4 "r14"
#define AREG5 "r15"
//#define AREG4 "r14"
//#define AREG5 "r15"
#endif
#ifdef __powerpc__
#define AREG0 "r27"
@@ -159,10 +148,10 @@ extern int printf(const char *, ...);
#define AREG4 "%d5"
#endif
#ifdef __ia64__
#define AREG0 "r27"
#define AREG1 "r24"
#define AREG2 "r25"
#define AREG3 "r26"
#define AREG0 "r7"
#define AREG1 "r4"
#define AREG2 "r5"
#define AREG3 "r6"
#endif
/* force GCC to generate only one epilog at the end of the function */
@@ -209,14 +198,23 @@ extern int __op_param1, __op_param2, __op_param3;
extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
#if defined(_WIN32) || defined(__APPLE__)
#define ASM_NAME(x) "_" #x
#else
#define ASM_NAME(x) #x
#endif
#ifdef __i386__
#define EXIT_TB() asm volatile ("ret")
#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
#endif
#ifdef __x86_64__
#define EXIT_TB() asm volatile ("ret")
#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
#endif
#ifdef __powerpc__
#define EXIT_TB() asm volatile ("blr")
#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
#endif
#ifdef __s390__
#define EXIT_TB() asm volatile ("br %r14")
@@ -226,6 +224,8 @@ extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
#endif
#ifdef __ia64__
#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
#define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \
ASM_NAME(__op_gen_label) #n)
#endif
#ifdef __sparc__
#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \
@@ -233,6 +233,7 @@ extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
#endif
#ifdef __arm__
#define EXIT_TB() asm volatile ("b exec_loop")
#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
#endif
#ifdef __mc68000
#define EXIT_TB() asm volatile ("rts")
+9
View File
@@ -0,0 +1,9 @@
static inline int gen_new_label(void)
{
return nb_gen_labels++;
}
static inline void gen_set_label(int n)
{
gen_labels[n] = gen_opc_ptr - gen_opc_buf;
}
+248 -98
View File
@@ -54,7 +54,7 @@
#define elf_check_arch(x) ( ((x) == EM_386) || ((x) == EM_486) )
#undef ELF_USES_RELOCA
#elif defined(HOST_AMD64)
#elif defined(HOST_X86_64)
#define ELF_CLASS ELFCLASS64
#define ELF_ARCH EM_X86_64
@@ -635,6 +635,8 @@ static char *get_rel_sym_name(EXE_RELOC *rel)
name = get_sym_name(symtab + *(uint32_t *)(rel->r_reloc->r_symndx));
if (!strcmp(name, ".data"))
name = name_for_dotdata(rel);
if (name[0] == '.')
return NULL;
return name;
}
@@ -996,11 +998,11 @@ static const char * get_reloc_name(EXE_RELOC * rel, int * sslide)
switch(rel->r_type)
{
case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset & 0xffff);
case PPC_RELOC_LO16: fetch_next_pair_value(rel+1, &other_half); sectoffset |= (other_half << 16);
break;
case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
case PPC_RELOC_HI16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) | (uint16_t)(other_half & 0xffff);
break;
case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (other_half & 0xffff);
case PPC_RELOC_HA16: fetch_next_pair_value(rel+1, &other_half); sectoffset = (sectoffset << 16) + (int16_t)(other_half & 0xffff);
break;
case PPC_RELOC_BR24:
sectoffset = ( *(uint32_t *)(text + rel->r_address) & 0x03fffffc );
@@ -1146,13 +1148,11 @@ int load_object(const char *filename)
/* Now transform the symtab, to an extended version, with the sym size, and the C name */
for(i = 0, sym = symtab, syment = symtab_std; i < nb_syms; i++, sym++, syment++) {
const char *name;
struct nlist *sym_follow, *sym_next = 0;
unsigned int j;
name = find_str_by_index(sym->n_un.n_strx);
memset(sym, 0, sizeof(*sym));
if ( sym->n_type & N_STAB ) /* Debug symbols are skipped */
if ( syment->n_type & N_STAB ) /* Debug symbols are skipped */
continue;
memcpy(sym, syment, sizeof(*syment));
@@ -1185,6 +1185,68 @@ int load_object(const char *filename)
#endif /* CONFIG_FORMAT_MACH */
void get_reloc_expr(char *name, int name_size, const char *sym_name)
{
const char *p;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, name_size, "param%s", p);
} else if (strstart(sym_name, "__op_gen_label", &p)) {
snprintf(name, name_size, "gen_labels[param%s]", p);
} else {
#ifdef HOST_SPARC
if (sym_name[0] == '.')
snprintf(name, sizeof(name),
"(long)(&__dot_%s)",
sym_name + 1);
else
#endif
snprintf(name, name_size, "(long)(&%s)", sym_name);
}
}
#ifdef HOST_IA64
#define PLT_ENTRY_SIZE 16 /* 1 bundle containing "brl" */
struct plt_entry {
struct plt_entry *next;
const char *name;
unsigned long addend;
} *plt_list;
static int
get_plt_index (const char *name, unsigned long addend)
{
struct plt_entry *plt, *prev= NULL;
int index = 0;
/* see if we already have an entry for this target: */
for (plt = plt_list; plt; ++index, prev = plt, plt = plt->next)
if (strcmp(plt->name, name) == 0 && plt->addend == addend)
return index;
/* nope; create a new PLT entry: */
plt = malloc(sizeof(*plt));
if (!plt) {
perror("malloc");
exit(1);
}
memset(plt, 0, sizeof(*plt));
plt->name = strdup(name);
plt->addend = addend;
/* append to plt-list: */
if (prev)
prev->next = plt;
else
plt_list = plt;
return index;
}
#endif
#ifdef HOST_ARM
int arm_emit_ldr_info(const char *name, unsigned long start_offset,
@@ -1244,11 +1306,7 @@ int arm_emit_ldr_info(const char *name, unsigned long start_offset,
if (rel->r_offset == (pc_offset + start_offset)) {
sym_name = get_rel_sym_name(rel);
/* the compiler leave some unnecessary references to the code */
if (strstart(sym_name, "__op_param", &p)) {
snprintf(relname, sizeof(relname), "param%s", p);
} else {
snprintf(relname, sizeof(relname), "(long)(&%s)", sym_name);
}
get_reloc_expr(relname, sizeof(relname), sym_name);
type = ELF32_R_TYPE(rel->r_info);
if (type != R_ARM_ABS32)
error("%s: unsupported data relocation", name);
@@ -1307,7 +1365,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
p_start = text + offset;
p_end = p_start + size;
start_offset = offset;
#if defined(HOST_I386) || defined(HOST_AMD64)
#if defined(HOST_I386) || defined(HOST_X86_64)
#ifdef CONFIG_FORMAT_COFF
{
uint8_t *p;
@@ -1378,7 +1436,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
/* 08 00 84 00 */
if (get32((uint32_t *)p) != 0x00840008)
error("br.ret.sptk.many b0;; expected at the end of %s", name);
copy_size = p - p_start;
copy_size = p_end - p_start;
}
#elif defined(HOST_SPARC)
{
@@ -1482,7 +1540,8 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
sym_name = get_rel_sym_name(rel);
if(!sym_name)
continue;
if (strstart(sym_name, "__op_param", &p)) {
if (strstart(sym_name, "__op_param", &p) ||
strstart(sym_name, "__op_gen_label", &p)) {
n = strtoul(p, NULL, 10);
if (n > MAX_ARGS)
error("too many arguments in %s", name);
@@ -1514,7 +1573,11 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
}
fprintf(outfile, ";\n");
}
#if defined(HOST_IA64)
fprintf(outfile, " extern char %s;\n", name);
#else
fprintf(outfile, " extern void %s();\n", name);
#endif
for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
host_ulong offset = get_rel_offset(rel);
@@ -1525,7 +1588,8 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
continue;
if (*sym_name &&
!strstart(sym_name, "__op_param", NULL) &&
!strstart(sym_name, "__op_jmp", NULL)) {
!strstart(sym_name, "__op_jmp", NULL) &&
!strstart(sym_name, "__op_gen_label", NULL)) {
#if defined(HOST_SPARC)
if (sym_name[0] == '.') {
fprintf(outfile,
@@ -1534,9 +1598,18 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
continue;
}
#endif
#ifdef __APPLE__
#if defined(__APPLE__)
/* set __attribute((unused)) on darwin because we wan't to avoid warning when we don't use the symbol */
fprintf(outfile, "extern char %s __attribute__((unused));\n", sym_name);
#elif defined(HOST_IA64)
if (ELF64_R_TYPE(rel->r_info) != R_IA64_PCREL21B)
/*
* PCREL21 br.call targets generally
* are out of range and need to go
* through an "import stub".
*/
fprintf(outfile, " extern char %s;\n",
sym_name);
#else
fprintf(outfile, "extern char %s;\n", sym_name);
#endif
@@ -1604,8 +1677,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
}
}
#endif
if (val >= start_offset && val < start_offset + copy_size) {
if (val >= start_offset && val <= start_offset + copy_size) {
n = strtol(p, NULL, 10);
fprintf(outfile, " label_offsets[%d] = %ld + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset);
}
@@ -1628,6 +1700,8 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (rel->r_offset >= start_offset &&
rel->r_offset < start_offset + copy_size) {
sym_name = get_rel_sym_name(rel);
if (!sym_name)
continue;
if (strstart(sym_name, "__op_jmp", &p)) {
int n;
n = strtol(p, NULL, 10);
@@ -1640,11 +1714,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
continue;
}
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
addend = get32((uint32_t *)(text + rel->r_offset));
#ifdef CONFIG_FORMAT_ELF
type = ELF32_R_TYPE(rel->r_info);
@@ -1693,7 +1763,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
}
}
}
#elif defined(HOST_AMD64)
#elif defined(HOST_X86_64)
{
char name[256];
int type;
@@ -1702,11 +1772,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (rel->r_offset >= start_offset &&
rel->r_offset < start_offset + copy_size) {
sym_name = strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
@@ -1723,7 +1789,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
rel->r_offset - start_offset, name, rel->r_offset - start_offset, addend);
break;
default:
error("unsupported AMD64 relocation (%d)", type);
error("unsupported X86_64 relocation (%d)", type);
}
}
}
@@ -1750,11 +1816,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
continue;
}
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
@@ -1839,19 +1901,20 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
continue; /* dunno how to handle without final_sym_name */
}
if (strstart(sym_name, "__op_param", &p)) {
snprintf(final_sym_name, sizeof(final_sym_name), "param%s", p);
} else {
snprintf(final_sym_name, sizeof(final_sym_name), "(long)(&%s)", sym_name);
}
get_reloc_expr(final_sym_name, sizeof(final_sym_name),
sym_name);
switch(type) {
case PPC_RELOC_BR24:
fprintf(outfile, "{\n");
fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((imm + ((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n",
if (!strstart(sym_name,"__op_gen_label",&p)) {
fprintf(outfile, "{\n");
fprintf(outfile, " uint32_t imm = *(uint32_t *)(gen_code_ptr + %d) & 0x3fffffc;\n", slide);
fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((imm + ((long)%s - (long)gen_code_ptr) + %d) & 0x03fffffc);\n",
slide, slide, name, sslide );
fprintf(outfile, "}\n");
fprintf(outfile, "}\n");
} else {
fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | (((long)%s - (long)gen_code_ptr - %d) & 0x03fffffc);\n",
slide, slide, final_sym_name, slide);
}
break;
case PPC_RELOC_HI16:
fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
@@ -1882,11 +1945,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (rel->r_offset >= start_offset &&
rel->r_offset < start_offset + copy_size) {
sym_name = strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
@@ -1964,29 +2023,78 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
}
#elif defined(HOST_IA64)
{
unsigned long sym_idx;
long code_offset;
char name[256];
int type;
int addend;
long addend;
for(i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
if (rel->r_offset >= start_offset && rel->r_offset < start_offset + copy_size) {
sym_name = strtab + symtab[ELF64_R_SYM(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
type = ELF64_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
case R_IA64_LTOFF22:
error("must implemnt R_IA64_LTOFF22 relocation");
case R_IA64_PCREL21B:
error("must implemnt R_IA64_PCREL21B relocation");
default:
error("unsupported ia64 relocation (%d)", type);
}
}
sym_idx = ELF64_R_SYM(rel->r_info);
if (rel->r_offset < start_offset
|| rel->r_offset >= start_offset + copy_size)
continue;
sym_name = (strtab + symtab[sym_idx].st_name);
if (strstart(sym_name, "__op_jmp", &p)) {
int n;
n = strtol(p, NULL, 10);
/* __op_jmp relocations are done at
runtime to do translated block
chaining: the offset of the instruction
needs to be stored */
fprintf(outfile, " jmp_offsets[%d] ="
"%ld + (gen_code_ptr - gen_code_buf);\n",
n, rel->r_offset - start_offset);
continue;
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF64_R_TYPE(rel->r_info);
addend = rel->r_addend;
code_offset = rel->r_offset - start_offset;
switch(type) {
case R_IA64_IMM64:
fprintf(outfile,
" ia64_imm64(gen_code_ptr + %ld, "
"%s + %ld);\n",
code_offset, name, addend);
break;
case R_IA64_LTOFF22X:
case R_IA64_LTOFF22:
fprintf(outfile, " IA64_LTOFF(gen_code_ptr + %ld,"
" %s + %ld, %d);\n",
code_offset, name, addend,
(type == R_IA64_LTOFF22X));
break;
case R_IA64_LDXMOV:
fprintf(outfile,
" ia64_ldxmov(gen_code_ptr + %ld,"
" %s + %ld);\n", code_offset, name, addend);
break;
case R_IA64_PCREL21B:
if (strstart(sym_name, "__op_gen_label", NULL)) {
fprintf(outfile,
" ia64_imm21b(gen_code_ptr + %ld,"
" (long) (%s + %ld -\n\t\t"
"((long) gen_code_ptr + %ld)) >> 4);\n",
code_offset, name, addend,
code_offset & ~0xfUL);
} else {
fprintf(outfile,
" IA64_PLT(gen_code_ptr + %ld, "
"%d);\t/* %s + %ld */\n",
code_offset,
get_plt_index(sym_name, addend),
sym_name, addend);
}
break;
default:
error("unsupported ia64 relocation (0x%x)",
type);
}
}
fprintf(outfile, " ia64_nop_b(gen_code_ptr + %d);\n",
copy_size - 16 + 2);
}
#elif defined(HOST_SPARC)
{
@@ -1997,17 +2105,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (rel->r_offset >= start_offset &&
rel->r_offset < start_offset + copy_size) {
sym_name = strtab + symtab[ELF32_R_SYM(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
if (sym_name[0] == '.')
snprintf(name, sizeof(name),
"(long)(&__dot_%s)",
sym_name + 1);
else
snprintf(name, sizeof(name),
"(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
@@ -2062,11 +2160,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
if (rel->r_offset >= start_offset &&
rel->r_offset < start_offset + copy_size) {
sym_name = strtab + symtab[ELF64_R_SYM(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF64_R_TYPE(rel->r_info);
addend = rel->r_addend;
switch(type) {
@@ -2128,11 +2222,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
/* the compiler leave some unnecessary references to the code */
if (sym_name[0] == '\0')
continue;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = get32((uint32_t *)(text + rel->r_offset));
switch(type) {
@@ -2161,11 +2251,7 @@ void gen_code(const char *name, host_ulong offset, host_ulong size,
rel->r_offset < start_offset + copy_size) {
sym = &(symtab[ELFW(R_SYM)(rel->r_info)]);
sym_name = strtab + symtab[ELFW(R_SYM)(rel->r_info)].st_name;
if (strstart(sym_name, "__op_param", &p)) {
snprintf(name, sizeof(name), "param%s", p);
} else {
snprintf(name, sizeof(name), "(long)(&%s)", sym_name);
}
get_reloc_expr(name, sizeof(name), sym_name);
type = ELF32_R_TYPE(rel->r_info);
addend = get32((uint32_t *)(text + rel->r_offset)) + rel->r_addend;
switch(type) {
@@ -2232,7 +2318,7 @@ int gen_file(FILE *outfile, int out_type)
}
} else if (out_type == OUT_GEN_OP) {
/* generate gen_xxx functions */
fprintf(outfile, "#include \"dyngen-op.h\"\n");
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) {
const char *name;
name = get_sym_name(sym);
@@ -2250,7 +2336,7 @@ int gen_file(FILE *outfile, int out_type)
fprintf(outfile,
"int dyngen_code(uint8_t *gen_code_buf,\n"
" uint16_t *label_offsets, uint16_t *jmp_offsets,\n"
" const uint16_t *opc_buf, const uint32_t *opparam_buf)\n"
" const uint16_t *opc_buf, const uint32_t *opparam_buf, const long *gen_labels)\n"
"{\n"
" uint8_t *gen_code_ptr;\n"
" const uint16_t *opc_ptr;\n"
@@ -2262,6 +2348,63 @@ fprintf(outfile,
" LDREntry *arm_ldr_ptr = arm_ldr_table;\n"
" uint32_t *arm_data_ptr = arm_data_table;\n");
#endif
#ifdef HOST_IA64
{
long addend, not_first = 0;
unsigned long sym_idx;
int index, max_index;
const char *sym_name;
EXE_RELOC *rel;
max_index = -1;
for (i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
sym_idx = ELF64_R_SYM(rel->r_info);
sym_name = (strtab + symtab[sym_idx].st_name);
if (strstart(sym_name, "__op_gen_label", NULL))
continue;
if (ELF64_R_TYPE(rel->r_info) != R_IA64_PCREL21B)
continue;
addend = rel->r_addend;
index = get_plt_index(sym_name, addend);
if (index <= max_index)
continue;
max_index = index;
fprintf(outfile, " extern void %s(void);\n", sym_name);
}
fprintf(outfile,
" struct ia64_fixup *plt_fixes = NULL, "
"*ltoff_fixes = NULL;\n"
" static long plt_target[] = {\n\t");
max_index = -1;
for (i = 0, rel = relocs;i < nb_relocs; i++, rel++) {
sym_idx = ELF64_R_SYM(rel->r_info);
sym_name = (strtab + symtab[sym_idx].st_name);
if (strstart(sym_name, "__op_gen_label", NULL))
continue;
if (ELF64_R_TYPE(rel->r_info) != R_IA64_PCREL21B)
continue;
addend = rel->r_addend;
index = get_plt_index(sym_name, addend);
if (index <= max_index)
continue;
max_index = index;
if (not_first)
fprintf(outfile, ",\n\t");
not_first = 1;
if (addend)
fprintf(outfile, "(long) &%s + %ld", sym_name, addend);
else
fprintf(outfile, "(long) &%s", sym_name);
}
fprintf(outfile, "\n };\n"
" unsigned int plt_offset[%u] = { 0 };\n", max_index + 1);
}
#endif
fprintf(outfile,
"\n"
@@ -2324,6 +2467,13 @@ fprintf(outfile,
" }\n"
" the_end:\n"
);
#ifdef HOST_IA64
fprintf(outfile,
" ia64_apply_fixes(&gen_code_ptr, ltoff_fixes, "
"(uint64_t) code_gen_buffer + 2*(1<<20), plt_fixes,\n\t\t\t"
"sizeof(plt_target)/sizeof(plt_target[0]),\n\t\t\t"
"plt_target, plt_offset);\n");
#endif
/* generate some code patching */
#ifdef HOST_ARM
+220 -2
View File
@@ -19,6 +19,7 @@
*/
int __op_param1, __op_param2, __op_param3;
int __op_gen_label1, __op_gen_label2, __op_gen_label3;
int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
#ifdef __i386__
@@ -42,6 +43,11 @@ static inline void flush_icache_range(unsigned long start, unsigned long stop)
#ifdef __ia64__
static inline void flush_icache_range(unsigned long start, unsigned long stop)
{
while (start < stop) {
asm volatile ("fc %0" :: "r"(start));
start += 32;
}
asm volatile (";;sync.i;;srlz.i;;");
}
#endif
@@ -204,5 +210,217 @@ static uint8_t *arm_flush_ldr(uint8_t *gen_code_ptr,
#endif /* __arm__ */
#ifdef __ia64
/* Patch instruction with "val" where "mask" has 1 bits. */
static inline void ia64_patch (uint64_t insn_addr, uint64_t mask, uint64_t val)
{
uint64_t m0, m1, v0, v1, b0, b1, *b = (uint64_t *) (insn_addr & -16);
# define insn_mask ((1UL << 41) - 1)
unsigned long shift;
b0 = b[0]; b1 = b[1];
shift = 5 + 41 * (insn_addr % 16); /* 5 template, 3 x 41-bit insns */
if (shift >= 64) {
m1 = mask << (shift - 64);
v1 = val << (shift - 64);
} else {
m0 = mask << shift; m1 = mask >> (64 - shift);
v0 = val << shift; v1 = val >> (64 - shift);
b[0] = (b0 & ~m0) | (v0 & m0);
}
b[1] = (b1 & ~m1) | (v1 & m1);
}
static inline void ia64_patch_imm60 (uint64_t insn_addr, uint64_t val)
{
ia64_patch(insn_addr,
0x011ffffe000UL,
( ((val & 0x0800000000000000UL) >> 23) /* bit 59 -> 36 */
| ((val & 0x00000000000fffffUL) << 13) /* bit 0 -> 13 */));
ia64_patch(insn_addr - 1, 0x1fffffffffcUL, val >> 18);
}
static inline void ia64_imm64 (void *insn, uint64_t val)
{
/* Ignore the slot number of the relocation; GCC and Intel
toolchains differed for some time on whether IMM64 relocs are
against slot 1 (Intel) or slot 2 (GCC). */
uint64_t insn_addr = (uint64_t) insn & ~3UL;
ia64_patch(insn_addr + 2,
0x01fffefe000UL,
( ((val & 0x8000000000000000UL) >> 27) /* bit 63 -> 36 */
| ((val & 0x0000000000200000UL) << 0) /* bit 21 -> 21 */
| ((val & 0x00000000001f0000UL) << 6) /* bit 16 -> 22 */
| ((val & 0x000000000000ff80UL) << 20) /* bit 7 -> 27 */
| ((val & 0x000000000000007fUL) << 13) /* bit 0 -> 13 */)
);
ia64_patch(insn_addr + 1, 0x1ffffffffffUL, val >> 22);
}
static inline void ia64_imm60b (void *insn, uint64_t val)
{
/* Ignore the slot number of the relocation; GCC and Intel
toolchains differed for some time on whether IMM64 relocs are
against slot 1 (Intel) or slot 2 (GCC). */
uint64_t insn_addr = (uint64_t) insn & ~3UL;
if (val + ((uint64_t) 1 << 59) >= (1UL << 60))
fprintf(stderr, "%s: value %ld out of IMM60 range\n",
__FUNCTION__, (int64_t) val);
ia64_patch_imm60(insn_addr + 2, val);
}
static inline void ia64_imm22 (void *insn, uint64_t val)
{
if (val + (1 << 21) >= (1 << 22))
fprintf(stderr, "%s: value %li out of IMM22 range\n",
__FUNCTION__, (int64_t)val);
ia64_patch((uint64_t) insn, 0x01fffcfe000UL,
( ((val & 0x200000UL) << 15) /* bit 21 -> 36 */
| ((val & 0x1f0000UL) << 6) /* bit 16 -> 22 */
| ((val & 0x00ff80UL) << 20) /* bit 7 -> 27 */
| ((val & 0x00007fUL) << 13) /* bit 0 -> 13 */));
}
/* Like ia64_imm22(), but also clear bits 20-21. For addl, this has
the effect of turning "addl rX=imm22,rY" into "addl
rX=imm22,r0". */
static inline void ia64_imm22_r0 (void *insn, uint64_t val)
{
if (val + (1 << 21) >= (1 << 22))
fprintf(stderr, "%s: value %li out of IMM22 range\n",
__FUNCTION__, (int64_t)val);
ia64_patch((uint64_t) insn, 0x01fffcfe000UL | (0x3UL << 20),
( ((val & 0x200000UL) << 15) /* bit 21 -> 36 */
| ((val & 0x1f0000UL) << 6) /* bit 16 -> 22 */
| ((val & 0x00ff80UL) << 20) /* bit 7 -> 27 */
| ((val & 0x00007fUL) << 13) /* bit 0 -> 13 */));
}
static inline void ia64_imm21b (void *insn, uint64_t val)
{
if (val + (1 << 20) >= (1 << 21))
fprintf(stderr, "%s: value %li out of IMM21b range\n",
__FUNCTION__, (int64_t)val);
ia64_patch((uint64_t) insn, 0x11ffffe000UL,
( ((val & 0x100000UL) << 16) /* bit 20 -> 36 */
| ((val & 0x0fffffUL) << 13) /* bit 0 -> 13 */));
}
static inline void ia64_nop_b (void *insn)
{
ia64_patch((uint64_t) insn, (1UL << 41) - 1, 2UL << 37);
}
static inline void ia64_ldxmov(void *insn, uint64_t val)
{
if (val + (1 << 21) < (1 << 22))
ia64_patch((uint64_t) insn, 0x1fff80fe000UL, 8UL << 37);
}
static inline int ia64_patch_ltoff(void *insn, uint64_t val,
int relaxable)
{
if (relaxable && (val + (1 << 21) < (1 << 22))) {
ia64_imm22_r0(insn, val);
return 0;
}
return 1;
}
struct ia64_fixup {
struct ia64_fixup *next;
void *addr; /* address that needs to be patched */
long value;
};
#define IA64_PLT(insn, plt_index) \
do { \
struct ia64_fixup *fixup = alloca(sizeof(*fixup)); \
fixup->next = plt_fixes; \
plt_fixes = fixup; \
fixup->addr = (insn); \
fixup->value = (plt_index); \
plt_offset[(plt_index)] = 1; \
} while (0)
#define IA64_LTOFF(insn, val, relaxable) \
do { \
if (ia64_patch_ltoff(insn, val, relaxable)) { \
struct ia64_fixup *fixup = alloca(sizeof(*fixup)); \
fixup->next = ltoff_fixes; \
ltoff_fixes = fixup; \
fixup->addr = (insn); \
fixup->value = (val); \
} \
} while (0)
static inline void ia64_apply_fixes (uint8_t **gen_code_pp,
struct ia64_fixup *ltoff_fixes,
uint64_t gp,
struct ia64_fixup *plt_fixes,
int num_plts,
unsigned long *plt_target,
unsigned int *plt_offset)
{
static const uint8_t plt_bundle[] = {
0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* nop 0; movl r1=GP */
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x60,
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* nop 0; brl IP */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0
};
uint8_t *gen_code_ptr = *gen_code_pp, *plt_start, *got_start, *vp;
struct ia64_fixup *fixup;
unsigned int offset = 0;
struct fdesc {
long ip;
long gp;
} *fdesc;
int i;
if (plt_fixes) {
plt_start = gen_code_ptr;
for (i = 0; i < num_plts; ++i) {
if (plt_offset[i]) {
plt_offset[i] = offset;
offset += sizeof(plt_bundle);
fdesc = (struct fdesc *) plt_target[i];
memcpy(gen_code_ptr, plt_bundle, sizeof(plt_bundle));
ia64_imm64 (gen_code_ptr + 0x02, fdesc->gp);
ia64_imm60b(gen_code_ptr + 0x12,
(fdesc->ip - (long) (gen_code_ptr + 0x10)) >> 4);
gen_code_ptr += sizeof(plt_bundle);
}
}
for (fixup = plt_fixes; fixup; fixup = fixup->next)
ia64_imm21b(fixup->addr,
((long) plt_start + plt_offset[fixup->value]
- ((long) fixup->addr & ~0xf)) >> 4);
}
got_start = gen_code_ptr;
/* First, create the GOT: */
for (fixup = ltoff_fixes; fixup; fixup = fixup->next) {
/* first check if we already have this value in the GOT: */
for (vp = got_start; vp < gen_code_ptr; ++vp)
if (*(uint64_t *) vp == fixup->value)
break;
if (vp == gen_code_ptr) {
/* Nope, we need to put the value in the GOT: */
*(uint64_t *) vp = fixup->value;
gen_code_ptr += 8;
}
ia64_imm22(fixup->addr, (long) vp - gp);
}
*gen_code_pp = gen_code_ptr;
}
#endif
+75 -55
View File
@@ -55,10 +55,13 @@ struct TranslationBlock;
extern uint16_t gen_opc_buf[OPC_BUF_SIZE];
extern uint32_t gen_opparam_buf[OPPARAM_BUF_SIZE];
extern uint32_t gen_opc_pc[OPC_BUF_SIZE];
extern uint32_t gen_opc_npc[OPC_BUF_SIZE];
extern long gen_labels[OPC_BUF_SIZE];
extern int nb_gen_labels;
extern target_ulong gen_opc_pc[OPC_BUF_SIZE];
extern target_ulong gen_opc_npc[OPC_BUF_SIZE];
extern uint8_t gen_opc_cc_op[OPC_BUF_SIZE];
extern uint8_t gen_opc_instr_start[OPC_BUF_SIZE];
extern target_ulong gen_opc_jump_pc[2];
typedef void (GenOpFunc)(void);
typedef void (GenOpFunc1)(long);
@@ -123,6 +126,8 @@ int tlb_set_page(CPUState *env, target_ulong vaddr,
#if defined(__alpha__)
#define CODE_GEN_BUFFER_SIZE (2 * 1024 * 1024)
#elif defined(__ia64)
#define CODE_GEN_BUFFER_SIZE (4 * 1024 * 1024) /* range of addl */
#elif defined(__powerpc__)
#define CODE_GEN_BUFFER_SIZE (6 * 1024 * 1024)
#else
@@ -186,7 +191,7 @@ typedef struct TranslationBlock {
struct TranslationBlock *jmp_first;
} TranslationBlock;
static inline unsigned int tb_hash_func(unsigned long pc)
static inline unsigned int tb_hash_func(target_ulong pc)
{
return pc & (CODE_GEN_HASH_SIZE - 1);
}
@@ -196,7 +201,7 @@ static inline unsigned int tb_phys_hash_func(unsigned long pc)
return pc & (CODE_GEN_PHYS_HASH_SIZE - 1);
}
TranslationBlock *tb_alloc(unsigned long pc);
TranslationBlock *tb_alloc(target_ulong pc);
void tb_flush(CPUState *env);
void tb_link(TranslationBlock *tb);
void tb_link_phys(TranslationBlock *tb,
@@ -310,17 +315,15 @@ TranslationBlock *tb_find_pc(unsigned long pc_ptr);
#elif defined(__APPLE__)
#define ASM_DATA_SECTION ".data\n"
#define ASM_PREVIOUS_SECTION ".text\n"
#define ASM_NAME(x) "_" #x
#else
#define ASM_DATA_SECTION ".section \".data\"\n"
#define ASM_PREVIOUS_SECTION ".previous\n"
#define ASM_NAME(x) stringify(x)
#endif
#if defined(__powerpc__)
/* we patch the jump instruction directly */
#define JUMP_TB(opname, tbparam, n, eip)\
#define GOTO_TB(opname, tbparam, n)\
do {\
asm volatile (ASM_DATA_SECTION\
ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
@@ -328,20 +331,12 @@ do {\
ASM_PREVIOUS_SECTION \
"b " ASM_NAME(__op_jmp) #n "\n"\
"1:\n");\
T0 = (long)(tbparam) + (n);\
EIP = eip;\
EXIT_TB();\
} while (0)
#define JUMP_TB2(opname, tbparam, n)\
do {\
asm volatile ("b " ASM_NAME(__op_jmp) #n "\n");\
} while (0)
#elif defined(__i386__) && defined(USE_DIRECT_JUMP)
/* we patch the jump instruction directly */
#define JUMP_TB(opname, tbparam, n, eip)\
#define GOTO_TB(opname, tbparam, n)\
do {\
asm volatile (".section .data\n"\
ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
@@ -349,40 +344,32 @@ do {\
ASM_PREVIOUS_SECTION \
"jmp " ASM_NAME(__op_jmp) #n "\n"\
"1:\n");\
T0 = (long)(tbparam) + (n);\
EIP = eip;\
EXIT_TB();\
} while (0)
#define JUMP_TB2(opname, tbparam, n)\
do {\
asm volatile ("jmp " ASM_NAME(__op_jmp) #n "\n");\
} while (0)
#else
/* jump to next block operations (more portable code, does not need
cache flushing, but slower because of indirect jump) */
#define JUMP_TB(opname, tbparam, n, eip)\
#define GOTO_TB(opname, tbparam, n)\
do {\
static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
static void __attribute__((unused)) *dummy ## n = &&dummy_label ## n;\
static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n]);\
label ## n:\
T0 = (long)(tbparam) + (n);\
EIP = eip;\
dummy_label ## n:\
EXIT_TB();\
} while (0)
/* second jump to same destination 'n' */
#define JUMP_TB2(opname, tbparam, n)\
do {\
goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n - 2]);\
label ## n: ;\
dummy_label ## n: ;\
} while (0)
#endif
/* XXX: will be suppressed */
#define JUMP_TB(opname, tbparam, n, eip)\
do {\
GOTO_TB(opname, tbparam, n);\
T0 = (long)(tbparam) + (n);\
EIP = (int32_t)eip;\
EXIT_TB();\
} while (0)
extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];
@@ -408,28 +395,26 @@ static inline int testandset (int *p)
#ifdef __i386__
static inline int testandset (int *p)
{
char ret;
long int readval;
long int readval = 0;
__asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
: "=q" (ret), "=m" (*p), "=a" (readval)
: "r" (1), "m" (*p), "a" (0)
: "memory");
return ret;
__asm__ __volatile__ ("lock; cmpxchgl %2, %0"
: "+m" (*p), "+a" (readval)
: "r" (1)
: "cc");
return readval;
}
#endif
#ifdef __x86_64__
static inline int testandset (int *p)
{
char ret;
int readval;
long int readval = 0;
__asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
: "=q" (ret), "=m" (*p), "=a" (readval)
: "r" (1), "m" (*p), "a" (0)
: "memory");
return ret;
__asm__ __volatile__ ("lock; cmpxchgl %2, %0"
: "+m" (*p), "+a" (readval)
: "r" (1)
: "cc");
return readval;
}
#endif
@@ -500,7 +485,16 @@ static inline int testandset (int *p)
: "=r" (ret)
: "m" (p)
: "cc","memory");
return ret == 0;
return ret;
}
#endif
#ifdef __ia64
#include <ia64intrin.h>
static inline int testandset (int *p)
{
return __sync_lock_test_and_set (p, 1);
}
#endif
@@ -544,7 +538,7 @@ extern int tb_invalidated_flag;
#if !defined(CONFIG_USER_ONLY)
void tlb_fill(unsigned long addr, int is_write, int is_user,
void tlb_fill(target_ulong addr, int is_write, int is_user,
void *retaddr);
#define ACCESS_TYPE 3
@@ -560,6 +554,9 @@ void tlb_fill(unsigned long addr, int is_write, int is_user,
#define DATA_SIZE 4
#include "softmmu_header.h"
#define DATA_SIZE 8
#include "softmmu_header.h"
#undef ACCESS_TYPE
#undef MEMSUFFIX
#undef env
@@ -578,7 +575,7 @@ static inline target_ulong get_phys_addr_code(CPUState *env, target_ulong addr)
/* XXX: i386 target specific */
static inline target_ulong get_phys_addr_code(CPUState *env, target_ulong addr)
{
int is_user, index;
int is_user, index, pd;
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
#if defined(TARGET_I386)
@@ -592,8 +589,31 @@ static inline target_ulong get_phys_addr_code(CPUState *env, target_ulong addr)
#endif
if (__builtin_expect(env->tlb_read[is_user][index].address !=
(addr & TARGET_PAGE_MASK), 0)) {
ldub_code((void *)addr);
ldub_code(addr);
}
pd = env->tlb_read[is_user][index].address & ~TARGET_PAGE_MASK;
if (pd > IO_MEM_ROM) {
cpu_abort(env, "Trying to execute code outside RAM or ROM at 0x%08lx\n", addr);
}
return addr + env->tlb_read[is_user][index].addend - (unsigned long)phys_ram_base;
}
#endif
#ifdef USE_KQEMU
int kqemu_init(CPUState *env);
int kqemu_cpu_exec(CPUState *env);
void kqemu_flush_page(CPUState *env, target_ulong addr);
void kqemu_flush(CPUState *env, int global);
static inline int kqemu_is_ok(CPUState *env)
{
return(env->kqemu_enabled &&
(env->hflags & HF_CPL_MASK) == 3 &&
(env->eflags & IOPL_MASK) != IOPL_MASK &&
(env->cr[0] & CR0_PE_MASK) &&
(env->eflags & IF_MASK) &&
!(env->eflags & VM_MASK));
}
#endif
+221 -37
View File
@@ -58,7 +58,7 @@ int nb_tbs;
/* any access to the tbs or the page table must use this lock */
spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE];
uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));
uint8_t *code_gen_ptr;
int phys_ram_size;
@@ -80,7 +80,7 @@ typedef struct PageDesc {
typedef struct PhysPageDesc {
/* offset in host memory of the page + io_index in the low 12 bits */
unsigned long phys_offset;
uint32_t phys_offset;
} PhysPageDesc;
typedef struct VirtPageDesc {
@@ -110,7 +110,7 @@ unsigned long qemu_host_page_mask;
/* XXX: for system emulation, it could just be an array */
static PageDesc *l1_map[L1_SIZE];
static PhysPageDesc *l1_phys_map[L1_SIZE];
PhysPageDesc **l1_phys_map;
#if !defined(CONFIG_USER_ONLY)
static VirtPageDesc *l1_virt_map[L1_SIZE];
@@ -128,6 +128,11 @@ char *logfilename = "/tmp/qemu.log";
FILE *logfile;
int loglevel;
/* statistics */
static int tlb_flush_count;
static int tb_flush_count;
static int tb_phys_invalidate_count;
static void page_init(void)
{
/* NOTE: we can always suppose that qemu_host_page_size >=
@@ -171,6 +176,8 @@ static void page_init(void)
#if !defined(CONFIG_USER_ONLY)
virt_valid_tag = 1;
#endif
l1_phys_map = qemu_vmalloc(L1_SIZE * sizeof(PhysPageDesc *));
memset(l1_phys_map, 0, L1_SIZE * sizeof(PhysPageDesc *));
}
static inline PageDesc *page_find_alloc(unsigned int index)
@@ -206,7 +213,7 @@ static inline PhysPageDesc *phys_page_find_alloc(unsigned int index)
p = *lp;
if (!p) {
/* allocate if not found */
p = qemu_malloc(sizeof(PhysPageDesc) * L2_SIZE);
p = qemu_vmalloc(sizeof(PhysPageDesc) * L2_SIZE);
memset(p, 0, sizeof(PhysPageDesc) * L2_SIZE);
*lp = p;
}
@@ -231,6 +238,10 @@ static inline VirtPageDesc *virt_page_find_alloc(unsigned int index)
{
VirtPageDesc **lp, *p;
/* XXX: should not truncate for 64 bit addresses */
#if TARGET_LONG_BITS > 32
index &= (L1_SIZE - 1);
#endif
lp = &l1_virt_map[index >> L2_BITS];
p = *lp;
if (!p) {
@@ -332,6 +343,7 @@ void tb_flush(CPUState *env)
code_gen_ptr = code_gen_buffer;
/* XXX: flush processor icache at this point if cache flush is
expensive */
tb_flush_count++;
}
#ifdef DEBUG_TB_CHECK
@@ -526,6 +538,7 @@ static inline void tb_phys_invalidate(TranslationBlock *tb, unsigned int page_ad
}
tb_invalidate(tb);
tb_phys_invalidate_count++;
}
static inline void set_bits(uint8_t *tab, int start, int len)
@@ -597,13 +610,13 @@ static void tb_gen_code(CPUState *env,
target_ulong phys_pc, phys_page2, virt_page2;
int code_gen_size;
phys_pc = get_phys_addr_code(env, (unsigned long)pc);
tb = tb_alloc((unsigned long)pc);
phys_pc = get_phys_addr_code(env, pc);
tb = tb_alloc(pc);
if (!tb) {
/* flush must be done */
tb_flush(env);
/* cannot fail at this point */
tb = tb_alloc((unsigned long)pc);
tb = tb_alloc(pc);
}
tc_ptr = code_gen_ptr;
tb->tc_ptr = tc_ptr;
@@ -614,9 +627,9 @@ static void tb_gen_code(CPUState *env,
code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
/* check next page if needed */
virt_page2 = ((unsigned long)pc + tb->size - 1) & TARGET_PAGE_MASK;
virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
phys_page2 = -1;
if (((unsigned long)pc & TARGET_PAGE_MASK) != virt_page2) {
if ((pc & TARGET_PAGE_MASK) != virt_page2) {
phys_page2 = get_phys_addr_code(env, virt_page2);
}
tb_link_phys(tb, phys_pc, phys_page2);
@@ -884,7 +897,7 @@ static inline void tb_alloc_page(TranslationBlock *tb,
/* Allocate a new translation block. Flush the translation buffer if
too many translation blocks or too much generated code. */
TranslationBlock *tb_alloc(unsigned long pc)
TranslationBlock *tb_alloc(target_ulong pc)
{
TranslationBlock *tb;
@@ -1063,6 +1076,7 @@ static void tb_reset_jump_recursive(TranslationBlock *tb)
tb_reset_jump_recursive2(tb, 1);
}
#if defined(TARGET_HAS_ICE)
static void breakpoint_invalidate(CPUState *env, target_ulong pc)
{
target_ulong phys_addr;
@@ -1070,12 +1084,13 @@ static void breakpoint_invalidate(CPUState *env, target_ulong pc)
phys_addr = cpu_get_phys_page_debug(env, pc);
tb_invalidate_phys_page_range(phys_addr, phys_addr + 1, 0);
}
#endif
/* add a breakpoint. EXCP_DEBUG is returned by the CPU loop if a
breakpoint is reached */
int cpu_breakpoint_insert(CPUState *env, target_ulong pc)
{
#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_SPARC)
#if defined(TARGET_HAS_ICE)
int i;
for(i = 0; i < env->nb_breakpoints; i++) {
@@ -1097,7 +1112,7 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc)
/* remove a breakpoint */
int cpu_breakpoint_remove(CPUState *env, target_ulong pc)
{
#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_SPARC)
#if defined(TARGET_HAS_ICE)
int i;
for(i = 0; i < env->nb_breakpoints; i++) {
if (env->breakpoints[i] == pc)
@@ -1105,9 +1120,9 @@ int cpu_breakpoint_remove(CPUState *env, target_ulong pc)
}
return -1;
found:
memmove(&env->breakpoints[i], &env->breakpoints[i + 1],
(env->nb_breakpoints - (i + 1)) * sizeof(env->breakpoints[0]));
env->nb_breakpoints--;
if (i < env->nb_breakpoints)
env->breakpoints[i] = env->breakpoints[env->nb_breakpoints];
breakpoint_invalidate(env, pc);
return 0;
@@ -1120,7 +1135,7 @@ int cpu_breakpoint_remove(CPUState *env, target_ulong pc)
CPU loop after each instruction */
void cpu_single_step(CPUState *env, int enabled)
{
#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_SPARC)
#if defined(TARGET_HAS_ICE)
if (env->singlestep_enabled != enabled) {
env->singlestep_enabled = enabled;
/* must flush all the translated code to avoid inconsistancies */
@@ -1292,6 +1307,12 @@ void tlb_flush(CPUState *env, int flush_global)
#if !defined(CONFIG_SOFTMMU)
munmap((void *)MMAP_AREA_START, MMAP_AREA_END - MMAP_AREA_START);
#endif
#ifdef USE_KQEMU
if (env->kqemu_enabled) {
kqemu_flush(env, flush_global);
}
#endif
tlb_flush_count++;
}
static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)
@@ -1348,6 +1369,11 @@ void tlb_flush_page(CPUState *env, target_ulong addr)
if (addr < MMAP_AREA_END)
munmap((void *)addr, TARGET_PAGE_SIZE);
#endif
#ifdef USE_KQEMU
if (env->kqemu_enabled) {
kqemu_flush_page(env, addr);
}
#endif
}
static inline void tlb_protect_code1(CPUTLBEntry *tlb_entry, target_ulong addr)
@@ -1412,11 +1438,13 @@ static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry,
}
}
void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end)
void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end,
int dirty_flags)
{
CPUState *env;
unsigned long length, start1;
int i;
int i, mask, len;
uint8_t *p;
start &= TARGET_PAGE_MASK;
end = TARGET_PAGE_ALIGN(end);
@@ -1424,7 +1452,11 @@ void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end)
length = end - start;
if (length == 0)
return;
memset(phys_ram_dirty + (start >> TARGET_PAGE_BITS), 0, length >> TARGET_PAGE_BITS);
mask = ~dirty_flags;
p = phys_ram_dirty + (start >> TARGET_PAGE_BITS);
len = length >> TARGET_PAGE_BITS;
for(i = 0; i < len; i++)
p[i] &= mask;
env = cpu_single_env;
/* we modify the TLB cache so that the dirty bit will be set again
@@ -1483,7 +1515,7 @@ static inline void tlb_set_dirty(unsigned long addr, target_ulong vaddr)
CPUState *env = cpu_single_env;
int i;
phys_ram_dirty[(addr - (unsigned long)phys_ram_base) >> TARGET_PAGE_BITS] = 1;
phys_ram_dirty[(addr - (unsigned long)phys_ram_base) >> TARGET_PAGE_BITS] = 0xff;
addr &= TARGET_PAGE_MASK;
i = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
@@ -1655,7 +1687,7 @@ int page_unprotect(unsigned long addr, unsigned long pc, void *puc)
cpu_abort(cpu_single_env, "error mprotect addr=0x%lx prot=%d\n",
(unsigned long)addr, vp->prot);
/* set the dirty bit */
phys_ram_dirty[vp->phys_addr >> TARGET_PAGE_BITS] = 1;
phys_ram_dirty[vp->phys_addr >> TARGET_PAGE_BITS] = 0xff;
/* flush the code inside */
tb_invalidate_phys_page(vp->phys_addr, pc, puc);
return 1;
@@ -1872,8 +1904,8 @@ static void code_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
#if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(phys_addr, 1);
#endif
stb_raw((uint8_t *)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 1;
stb_p((uint8_t *)(long)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 0xff;
}
static void code_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
@@ -1884,8 +1916,8 @@ static void code_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
#if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(phys_addr, 2);
#endif
stw_raw((uint8_t *)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 1;
stw_p((uint8_t *)(long)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 0xff;
}
static void code_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
@@ -1896,8 +1928,8 @@ static void code_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
#if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(phys_addr, 4);
#endif
stl_raw((uint8_t *)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 1;
stl_p((uint8_t *)(long)addr, val);
phys_ram_dirty[phys_addr >> TARGET_PAGE_BITS] = 0xff;
}
static CPUReadMemoryFunc *code_mem_read[3] = {
@@ -1914,19 +1946,19 @@ static CPUWriteMemoryFunc *code_mem_write[3] = {
static void notdirty_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
stb_raw((uint8_t *)addr, val);
stb_p((uint8_t *)(long)addr, val);
tlb_set_dirty(addr, cpu_single_env->mem_write_vaddr);
}
static void notdirty_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
stw_raw((uint8_t *)addr, val);
stw_p((uint8_t *)(long)addr, val);
tlb_set_dirty(addr, cpu_single_env->mem_write_vaddr);
}
static void notdirty_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
stl_raw((uint8_t *)addr, val);
stl_p((uint8_t *)(long)addr, val);
tlb_set_dirty(addr, cpu_single_env->mem_write_vaddr);
}
@@ -1945,7 +1977,7 @@ static void io_mem_init(void)
io_mem_nb = 5;
/* alloc dirty bits array */
phys_ram_dirty = qemu_malloc(phys_ram_size >> TARGET_PAGE_BITS);
phys_ram_dirty = qemu_vmalloc(phys_ram_size >> TARGET_PAGE_BITS);
}
/* mem_read and mem_write are arrays of functions containing the
@@ -2018,6 +2050,21 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
addr += l;
}
}
/* never used */
uint32_t ldl_phys(target_phys_addr_t addr)
{
return 0;
}
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
}
void stl_phys(target_phys_addr_t addr, uint32_t val)
{
}
#else
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
int len, int is_write)
@@ -2046,17 +2093,17 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
if (l >= 4 && ((addr & 3) == 0)) {
/* 32 bit read access */
val = ldl_raw(buf);
val = ldl_p(buf);
io_mem_write[io_index][2](io_mem_opaque[io_index], addr, val);
l = 4;
} else if (l >= 2 && ((addr & 1) == 0)) {
/* 16 bit read access */
val = lduw_raw(buf);
val = lduw_p(buf);
io_mem_write[io_index][1](io_mem_opaque[io_index], addr, val);
l = 2;
} else {
/* 8 bit access */
val = ldub_raw(buf);
val = ldub_p(buf);
io_mem_write[io_index][0](io_mem_opaque[io_index], addr, val);
l = 1;
}
@@ -2069,7 +2116,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
/* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
/* set dirty bit */
phys_ram_dirty[page >> TARGET_PAGE_BITS] = 1;
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] = 0xff;
}
} else {
if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM &&
@@ -2079,17 +2126,17 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
if (l >= 4 && ((addr & 3) == 0)) {
/* 32 bit read access */
val = io_mem_read[io_index][2](io_mem_opaque[io_index], addr);
stl_raw(buf, val);
stl_p(buf, val);
l = 4;
} else if (l >= 2 && ((addr & 1) == 0)) {
/* 16 bit read access */
val = io_mem_read[io_index][1](io_mem_opaque[io_index], addr);
stw_raw(buf, val);
stw_p(buf, val);
l = 2;
} else {
/* 8 bit access */
val = io_mem_read[io_index][0](io_mem_opaque[io_index], addr);
stb_raw(buf, val);
stb_p(buf, val);
l = 1;
}
} else {
@@ -2104,6 +2151,96 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
addr += l;
}
}
/* warning: addr must be aligned */
uint32_t ldl_phys(target_phys_addr_t addr)
{
int io_index;
uint8_t *ptr;
uint32_t val;
unsigned long pd;
PhysPageDesc *p;
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
pd = IO_MEM_UNASSIGNED;
} else {
pd = p->phys_offset;
}
if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM &&
(pd & ~TARGET_PAGE_MASK) != IO_MEM_CODE) {
/* I/O case */
io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
val = io_mem_read[io_index][2](io_mem_opaque[io_index], addr);
} else {
/* RAM case */
ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) +
(addr & ~TARGET_PAGE_MASK);
val = ldl_p(ptr);
}
return val;
}
/* warning: addr must be aligned. The ram page is not masked as dirty
and the code inside is not invalidated. It is useful if the dirty
bits are used to track modified PTEs */
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
int io_index;
uint8_t *ptr;
unsigned long pd;
PhysPageDesc *p;
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
pd = IO_MEM_UNASSIGNED;
} else {
pd = p->phys_offset;
}
if ((pd & ~TARGET_PAGE_MASK) != 0) {
io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
io_mem_write[io_index][2](io_mem_opaque[io_index], addr, val);
} else {
ptr = phys_ram_base + (pd & TARGET_PAGE_MASK) +
(addr & ~TARGET_PAGE_MASK);
stl_p(ptr, val);
}
}
/* warning: addr must be aligned */
/* XXX: optimize code invalidation test */
void stl_phys(target_phys_addr_t addr, uint32_t val)
{
int io_index;
uint8_t *ptr;
unsigned long pd;
PhysPageDesc *p;
p = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!p) {
pd = IO_MEM_UNASSIGNED;
} else {
pd = p->phys_offset;
}
if ((pd & ~TARGET_PAGE_MASK) != 0) {
io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
io_mem_write[io_index][2](io_mem_opaque[io_index], addr, val);
} else {
unsigned long addr1;
addr1 = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
/* RAM case */
ptr = phys_ram_base + addr1;
stl_p(ptr, val);
/* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] = 0xff;
}
}
#endif
/* virtual memory access for debug */
@@ -2131,6 +2268,53 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
return 0;
}
void dump_exec_info(FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i, target_code_size, max_target_code_size;
int direct_jmp_count, direct_jmp2_count, cross_page;
TranslationBlock *tb;
target_code_size = 0;
max_target_code_size = 0;
cross_page = 0;
direct_jmp_count = 0;
direct_jmp2_count = 0;
for(i = 0; i < nb_tbs; i++) {
tb = &tbs[i];
target_code_size += tb->size;
if (tb->size > max_target_code_size)
max_target_code_size = tb->size;
if (tb->page_addr[1] != -1)
cross_page++;
if (tb->tb_next_offset[0] != 0xffff) {
direct_jmp_count++;
if (tb->tb_next_offset[1] != 0xffff) {
direct_jmp2_count++;
}
}
}
/* XXX: avoid using doubles ? */
cpu_fprintf(f, "TB count %d\n", nb_tbs);
cpu_fprintf(f, "TB avg target size %d max=%d bytes\n",
nb_tbs ? target_code_size / nb_tbs : 0,
max_target_code_size);
cpu_fprintf(f, "TB avg host size %d bytes (expansion ratio: %0.1f)\n",
nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
target_code_size ? (double) (code_gen_ptr - code_gen_buffer) / target_code_size : 0);
cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
cross_page,
nb_tbs ? (cross_page * 100) / nb_tbs : 0);
cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n",
direct_jmp_count,
nb_tbs ? (direct_jmp_count * 100) / nb_tbs : 0,
direct_jmp2_count,
nb_tbs ? (direct_jmp2_count * 100) / nb_tbs : 0);
cpu_fprintf(f, "TB flush count %d\n", tb_flush_count);
cpu_fprintf(f, "TB invalidate count %d\n", tb_phys_invalidate_count);
cpu_fprintf(f, "TLB flush count %d\n", tlb_flush_count);
}
#if !defined(CONFIG_USER_ONLY)
#define MMUSUFFIX _cmmu
+720
View File
@@ -0,0 +1,720 @@
/*============================================================================
This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
Arithmetic Package, Release 2b.
Written by John R. Hauser. This work was made possible in part by the
International Computer Science Institute, located at Suite 600, 1947 Center
Street, Berkeley, California 94704. Funding was partially provided by the
National Science Foundation under grant MIP-9311980. The original version
of this code was written as part of a project to build a fixed-point vector
processor in collaboration with the University of California at Berkeley,
overseen by Profs. Nelson Morgan and John Wawrzynek. More information
is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
arithmetic/SoftFloat.html'.
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
INSTITUTE (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
Derivative works are acceptable, even for commercial purposes, so long as
(1) the source code for the derivative work includes prominent notice that
the work is derivative, and (2) the source code includes prominent notice with
these four paragraphs for those parts of this code that are retained.
=============================================================================*/
/*----------------------------------------------------------------------------
| Shifts `a' right by the number of bits given in `count'. If any nonzero
| bits are shifted off, they are ``jammed'' into the least significant bit of
| the result by setting the least significant bit to 1. The value of `count'
| can be arbitrarily large; in particular, if `count' is greater than 32, the
| result will be either 0 or 1, depending on whether `a' is zero or nonzero.
| The result is stored in the location pointed to by `zPtr'.
*----------------------------------------------------------------------------*/
INLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr )
{
bits32 z;
if ( count == 0 ) {
z = a;
}
else if ( count < 32 ) {
z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 );
}
else {
z = ( a != 0 );
}
*zPtr = z;
}
/*----------------------------------------------------------------------------
| Shifts `a' right by the number of bits given in `count'. If any nonzero
| bits are shifted off, they are ``jammed'' into the least significant bit of
| the result by setting the least significant bit to 1. The value of `count'
| can be arbitrarily large; in particular, if `count' is greater than 64, the
| result will be either 0 or 1, depending on whether `a' is zero or nonzero.
| The result is stored in the location pointed to by `zPtr'.
*----------------------------------------------------------------------------*/
INLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr )
{
bits64 z;
if ( count == 0 ) {
z = a;
}
else if ( count < 64 ) {
z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 );
}
else {
z = ( a != 0 );
}
*zPtr = z;
}
/*----------------------------------------------------------------------------
| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by 64
| _plus_ the number of bits given in `count'. The shifted result is at most
| 64 nonzero bits; this is stored at the location pointed to by `z0Ptr'. The
| bits shifted off form a second 64-bit result as follows: The _last_ bit
| shifted off is the most-significant bit of the extra result, and the other
| 63 bits of the extra result are all zero if and only if _all_but_the_last_
| bits shifted off were all zero. This extra result is stored in the location
| pointed to by `z1Ptr'. The value of `count' can be arbitrarily large.
| (This routine makes more sense if `a0' and `a1' are considered to form
| a fixed-point value with binary point between `a0' and `a1'. This fixed-
| point value is shifted right by the number of bits given in `count', and
| the integer part of the result is returned at the location pointed to by
| `z0Ptr'. The fractional part of the result may be slightly corrupted as
| described above, and is returned at the location pointed to by `z1Ptr'.)
*----------------------------------------------------------------------------*/
INLINE void
shift64ExtraRightJamming(
bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
{
bits64 z0, z1;
int8 negCount = ( - count ) & 63;
if ( count == 0 ) {
z1 = a1;
z0 = a0;
}
else if ( count < 64 ) {
z1 = ( a0<<negCount ) | ( a1 != 0 );
z0 = a0>>count;
}
else {
if ( count == 64 ) {
z1 = a0 | ( a1 != 0 );
}
else {
z1 = ( ( a0 | a1 ) != 0 );
}
z0 = 0;
}
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
| number of bits given in `count'. Any bits shifted off are lost. The value
| of `count' can be arbitrarily large; in particular, if `count' is greater
| than 128, the result will be 0. The result is broken into two 64-bit pieces
| which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
shift128Right(
bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
{
bits64 z0, z1;
int8 negCount = ( - count ) & 63;
if ( count == 0 ) {
z1 = a1;
z0 = a0;
}
else if ( count < 64 ) {
z1 = ( a0<<negCount ) | ( a1>>count );
z0 = a0>>count;
}
else {
z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
z0 = 0;
}
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
| number of bits given in `count'. If any nonzero bits are shifted off, they
| are ``jammed'' into the least significant bit of the result by setting the
| least significant bit to 1. The value of `count' can be arbitrarily large;
| in particular, if `count' is greater than 128, the result will be either
| 0 or 1, depending on whether the concatenation of `a0' and `a1' is zero or
| nonzero. The result is broken into two 64-bit pieces which are stored at
| the locations pointed to by `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
shift128RightJamming(
bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
{
bits64 z0, z1;
int8 negCount = ( - count ) & 63;
if ( count == 0 ) {
z1 = a1;
z0 = a0;
}
else if ( count < 64 ) {
z1 = ( a0<<negCount ) | ( a1>>count ) | ( ( a1<<negCount ) != 0 );
z0 = a0>>count;
}
else {
if ( count == 64 ) {
z1 = a0 | ( a1 != 0 );
}
else if ( count < 128 ) {
z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<<negCount ) | a1 ) != 0 );
}
else {
z1 = ( ( a0 | a1 ) != 0 );
}
z0 = 0;
}
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' right
| by 64 _plus_ the number of bits given in `count'. The shifted result is
| at most 128 nonzero bits; these are broken into two 64-bit pieces which are
| stored at the locations pointed to by `z0Ptr' and `z1Ptr'. The bits shifted
| off form a third 64-bit result as follows: The _last_ bit shifted off is
| the most-significant bit of the extra result, and the other 63 bits of the
| extra result are all zero if and only if _all_but_the_last_ bits shifted off
| were all zero. This extra result is stored in the location pointed to by
| `z2Ptr'. The value of `count' can be arbitrarily large.
| (This routine makes more sense if `a0', `a1', and `a2' are considered
| to form a fixed-point value with binary point between `a1' and `a2'. This
| fixed-point value is shifted right by the number of bits given in `count',
| and the integer part of the result is returned at the locations pointed to
| by `z0Ptr' and `z1Ptr'. The fractional part of the result may be slightly
| corrupted as described above, and is returned at the location pointed to by
| `z2Ptr'.)
*----------------------------------------------------------------------------*/
INLINE void
shift128ExtraRightJamming(
bits64 a0,
bits64 a1,
bits64 a2,
int16 count,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr
)
{
bits64 z0, z1, z2;
int8 negCount = ( - count ) & 63;
if ( count == 0 ) {
z2 = a2;
z1 = a1;
z0 = a0;
}
else {
if ( count < 64 ) {
z2 = a1<<negCount;
z1 = ( a0<<negCount ) | ( a1>>count );
z0 = a0>>count;
}
else {
if ( count == 64 ) {
z2 = a1;
z1 = a0;
}
else {
a2 |= a1;
if ( count < 128 ) {
z2 = a0<<negCount;
z1 = a0>>( count & 63 );
}
else {
z2 = ( count == 128 ) ? a0 : ( a0 != 0 );
z1 = 0;
}
}
z0 = 0;
}
z2 |= ( a2 != 0 );
}
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Shifts the 128-bit value formed by concatenating `a0' and `a1' left by the
| number of bits given in `count'. Any bits shifted off are lost. The value
| of `count' must be less than 64. The result is broken into two 64-bit
| pieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
shortShift128Left(
bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
{
*z1Ptr = a1<<count;
*z0Ptr =
( count == 0 ) ? a0 : ( a0<<count ) | ( a1>>( ( - count ) & 63 ) );
}
/*----------------------------------------------------------------------------
| Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left
| by the number of bits given in `count'. Any bits shifted off are lost.
| The value of `count' must be less than 64. The result is broken into three
| 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
| `z1Ptr', and `z2Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
shortShift192Left(
bits64 a0,
bits64 a1,
bits64 a2,
int16 count,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr
)
{
bits64 z0, z1, z2;
int8 negCount;
z2 = a2<<count;
z1 = a1<<count;
z0 = a0<<count;
if ( 0 < count ) {
negCount = ( ( - count ) & 63 );
z1 |= a2>>negCount;
z0 |= a1>>negCount;
}
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Adds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit
| value formed by concatenating `b0' and `b1'. Addition is modulo 2^128, so
| any carry out is lost. The result is broken into two 64-bit pieces which
| are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
add128(
bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
{
bits64 z1;
z1 = a1 + b1;
*z1Ptr = z1;
*z0Ptr = a0 + b0 + ( z1 < a1 );
}
/*----------------------------------------------------------------------------
| Adds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the
| 192-bit value formed by concatenating `b0', `b1', and `b2'. Addition is
| modulo 2^192, so any carry out is lost. The result is broken into three
| 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
| `z1Ptr', and `z2Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
add192(
bits64 a0,
bits64 a1,
bits64 a2,
bits64 b0,
bits64 b1,
bits64 b2,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr
)
{
bits64 z0, z1, z2;
int8 carry0, carry1;
z2 = a2 + b2;
carry1 = ( z2 < a2 );
z1 = a1 + b1;
carry0 = ( z1 < a1 );
z0 = a0 + b0;
z1 += carry1;
z0 += ( z1 < carry1 );
z0 += carry0;
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Subtracts the 128-bit value formed by concatenating `b0' and `b1' from the
| 128-bit value formed by concatenating `a0' and `a1'. Subtraction is modulo
| 2^128, so any borrow out (carry out) is lost. The result is broken into two
| 64-bit pieces which are stored at the locations pointed to by `z0Ptr' and
| `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
sub128(
bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
{
*z1Ptr = a1 - b1;
*z0Ptr = a0 - b0 - ( a1 < b1 );
}
/*----------------------------------------------------------------------------
| Subtracts the 192-bit value formed by concatenating `b0', `b1', and `b2'
| from the 192-bit value formed by concatenating `a0', `a1', and `a2'.
| Subtraction is modulo 2^192, so any borrow out (carry out) is lost. The
| result is broken into three 64-bit pieces which are stored at the locations
| pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
sub192(
bits64 a0,
bits64 a1,
bits64 a2,
bits64 b0,
bits64 b1,
bits64 b2,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr
)
{
bits64 z0, z1, z2;
int8 borrow0, borrow1;
z2 = a2 - b2;
borrow1 = ( a2 < b2 );
z1 = a1 - b1;
borrow0 = ( a1 < b1 );
z0 = a0 - b0;
z0 -= ( z1 < borrow1 );
z1 -= borrow1;
z0 -= borrow0;
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Multiplies `a' by `b' to obtain a 128-bit product. The product is broken
| into two 64-bit pieces which are stored at the locations pointed to by
| `z0Ptr' and `z1Ptr'.
*----------------------------------------------------------------------------*/
INLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr )
{
bits32 aHigh, aLow, bHigh, bLow;
bits64 z0, zMiddleA, zMiddleB, z1;
aLow = a;
aHigh = a>>32;
bLow = b;
bHigh = b>>32;
z1 = ( (bits64) aLow ) * bLow;
zMiddleA = ( (bits64) aLow ) * bHigh;
zMiddleB = ( (bits64) aHigh ) * bLow;
z0 = ( (bits64) aHigh ) * bHigh;
zMiddleA += zMiddleB;
z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
zMiddleA <<= 32;
z1 += zMiddleA;
z0 += ( z1 < zMiddleA );
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Multiplies the 128-bit value formed by concatenating `a0' and `a1' by
| `b' to obtain a 192-bit product. The product is broken into three 64-bit
| pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and
| `z2Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
mul128By64To192(
bits64 a0,
bits64 a1,
bits64 b,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr
)
{
bits64 z0, z1, z2, more1;
mul64To128( a1, b, &z1, &z2 );
mul64To128( a0, b, &z0, &more1 );
add128( z0, more1, 0, z1, &z0, &z1 );
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Multiplies the 128-bit value formed by concatenating `a0' and `a1' to the
| 128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit
| product. The product is broken into four 64-bit pieces which are stored at
| the locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'.
*----------------------------------------------------------------------------*/
INLINE void
mul128To256(
bits64 a0,
bits64 a1,
bits64 b0,
bits64 b1,
bits64 *z0Ptr,
bits64 *z1Ptr,
bits64 *z2Ptr,
bits64 *z3Ptr
)
{
bits64 z0, z1, z2, z3;
bits64 more1, more2;
mul64To128( a1, b1, &z2, &z3 );
mul64To128( a1, b0, &z1, &more2 );
add128( z1, more2, 0, z2, &z1, &z2 );
mul64To128( a0, b0, &z0, &more1 );
add128( z0, more1, 0, z1, &z0, &z1 );
mul64To128( a0, b1, &more1, &more2 );
add128( more1, more2, 0, z2, &more1, &z2 );
add128( z0, z1, 0, more1, &z0, &z1 );
*z3Ptr = z3;
*z2Ptr = z2;
*z1Ptr = z1;
*z0Ptr = z0;
}
/*----------------------------------------------------------------------------
| Returns an approximation to the 64-bit integer quotient obtained by dividing
| `b' into the 128-bit value formed by concatenating `a0' and `a1'. The
| divisor `b' must be at least 2^63. If q is the exact quotient truncated
| toward zero, the approximation returned lies between q and q + 2 inclusive.
| If the exact quotient q is larger than 64 bits, the maximum positive 64-bit
| unsigned integer is returned.
*----------------------------------------------------------------------------*/
static bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b )
{
bits64 b0, b1;
bits64 rem0, rem1, term0, term1;
bits64 z;
if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF );
b0 = b>>32;
z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32;
mul64To128( b, z, &term0, &term1 );
sub128( a0, a1, term0, term1, &rem0, &rem1 );
while ( ( (sbits64) rem0 ) < 0 ) {
z -= LIT64( 0x100000000 );
b1 = b<<32;
add128( rem0, rem1, b0, b1, &rem0, &rem1 );
}
rem0 = ( rem0<<32 ) | ( rem1>>32 );
z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0;
return z;
}
/*----------------------------------------------------------------------------
| Returns an approximation to the square root of the 32-bit significand given
| by `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of
| `aExp' (the least significant bit) is 1, the integer returned approximates
| 2^31*sqrt(`a'/2^31), where `a' is considered an integer. If bit 0 of `aExp'
| is 0, the integer returned approximates 2^31*sqrt(`a'/2^30). In either
| case, the approximation returned lies strictly within +/-2 of the exact
| value.
*----------------------------------------------------------------------------*/
static bits32 estimateSqrt32( int16 aExp, bits32 a )
{
static const bits16 sqrtOddAdjustments[] = {
0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0,
0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67
};
static const bits16 sqrtEvenAdjustments[] = {
0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
};
int8 index;
bits32 z;
index = ( a>>27 ) & 15;
if ( aExp & 1 ) {
z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ];
z = ( ( a / z )<<14 ) + ( z<<15 );
a >>= 1;
}
else {
z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ];
z = a / z + z;
z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 );
if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 );
}
return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 );
}
/*----------------------------------------------------------------------------
| Returns the number of leading 0 bits before the most-significant 1 bit of
| `a'. If `a' is zero, 32 is returned.
*----------------------------------------------------------------------------*/
static int8 countLeadingZeros32( bits32 a )
{
static const int8 countLeadingZerosHigh[] = {
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int8 shiftCount;
shiftCount = 0;
if ( a < 0x10000 ) {
shiftCount += 16;
a <<= 16;
}
if ( a < 0x1000000 ) {
shiftCount += 8;
a <<= 8;
}
shiftCount += countLeadingZerosHigh[ a>>24 ];
return shiftCount;
}
/*----------------------------------------------------------------------------
| Returns the number of leading 0 bits before the most-significant 1 bit of
| `a'. If `a' is zero, 64 is returned.
*----------------------------------------------------------------------------*/
static int8 countLeadingZeros64( bits64 a )
{
int8 shiftCount;
shiftCount = 0;
if ( a < ( (bits64) 1 )<<32 ) {
shiftCount += 32;
}
else {
a >>= 32;
}
shiftCount += countLeadingZeros32( a );
return shiftCount;
}
/*----------------------------------------------------------------------------
| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1'
| is equal to the 128-bit value formed by concatenating `b0' and `b1'.
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/
INLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
{
return ( a0 == b0 ) && ( a1 == b1 );
}
/*----------------------------------------------------------------------------
| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
| than or equal to the 128-bit value formed by concatenating `b0' and `b1'.
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/
INLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
{
return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );
}
/*----------------------------------------------------------------------------
| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
| than the 128-bit value formed by concatenating `b0' and `b1'. Otherwise,
| returns 0.
*----------------------------------------------------------------------------*/
INLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
{
return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );
}
/*----------------------------------------------------------------------------
| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is
| not equal to the 128-bit value formed by concatenating `b0' and `b1'.
| Otherwise, returns 0.
*----------------------------------------------------------------------------*/
INLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
{
return ( a0 != b0 ) || ( a1 != b1 );
}
+348
View File
@@ -0,0 +1,348 @@
/* Native implementation of soft float functions. Only a single status
context is supported */
#include "softfloat.h"
#include <math.h>
void set_float_rounding_mode(int val STATUS_PARAM)
{
STATUS(float_rounding_mode) = val;
#if defined(_BSD) && !defined(__APPLE__)
fpsetround(val);
#elif defined(__arm__)
/* nothing to do */
#else
fesetround(val);
#endif
}
#ifdef FLOATX80
void set_floatx80_rounding_precision(int val STATUS_PARAM)
{
STATUS(floatx80_rounding_precision) = val;
}
#endif
#if defined(_BSD)
#define lrint(d) ((int32_t)rint(d))
#define llrint(d) ((int64_t)rint(d))
#endif
#if defined(__powerpc__)
/* correct (but slow) PowerPC rint() (glibc version is incorrect) */
double qemu_rint(double x)
{
double y = 4503599627370496.0;
if (fabs(x) >= y)
return x;
if (x < 0)
y = -y;
y = (x + y) - y;
if (y == 0.0)
y = copysign(y, x);
return y;
}
#define rint qemu_rint
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE integer-to-floating-point conversion routines.
*----------------------------------------------------------------------------*/
float32 int32_to_float32(int v STATUS_PARAM)
{
return (float32)v;
}
float64 int32_to_float64(int v STATUS_PARAM)
{
return (float64)v;
}
#ifdef FLOATX80
floatx80 int32_to_floatx80(int v STATUS_PARAM)
{
return (floatx80)v;
}
#endif
float32 int64_to_float32( int64_t v STATUS_PARAM)
{
return (float32)v;
}
float64 int64_to_float64( int64_t v STATUS_PARAM)
{
return (float64)v;
}
#ifdef FLOATX80
floatx80 int64_to_floatx80( int64_t v STATUS_PARAM)
{
return (floatx80)v;
}
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision conversion routines.
*----------------------------------------------------------------------------*/
int float32_to_int32( float32 a STATUS_PARAM)
{
return lrintf(a);
}
int float32_to_int32_round_to_zero( float32 a STATUS_PARAM)
{
return (int)a;
}
int64_t float32_to_int64( float32 a STATUS_PARAM)
{
return llrintf(a);
}
int64_t float32_to_int64_round_to_zero( float32 a STATUS_PARAM)
{
return (int64_t)a;
}
float64 float32_to_float64( float32 a STATUS_PARAM)
{
return a;
}
#ifdef FLOATX80
floatx80 float32_to_floatx80( float32 a STATUS_PARAM)
{
return a;
}
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision operations.
*----------------------------------------------------------------------------*/
float32 float32_round_to_int( float32 a STATUS_PARAM)
{
return rintf(a);
}
float32 float32_rem( float32 a, float32 b STATUS_PARAM)
{
return remainderf(a, b);
}
float32 float32_sqrt( float32 a STATUS_PARAM)
{
return sqrtf(a);
}
char float32_compare( float32 a, float32 b STATUS_PARAM )
{
if (a < b) {
return -1;
} else if (a == b) {
return 0;
} else if (a > b) {
return 1;
} else {
return 2;
}
}
char float32_compare_quiet( float32 a, float32 b STATUS_PARAM )
{
if (isless(a, b)) {
return -1;
} else if (a == b) {
return 0;
} else if (isgreater(a, b)) {
return 1;
} else {
return 2;
}
}
char float32_is_signaling_nan( float32 a1)
{
float32u u;
uint32_t a;
u.f = a1;
a = u.i;
return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
}
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision conversion routines.
*----------------------------------------------------------------------------*/
int float64_to_int32( float64 a STATUS_PARAM)
{
return lrint(a);
}
int float64_to_int32_round_to_zero( float64 a STATUS_PARAM)
{
return (int)a;
}
int64_t float64_to_int64( float64 a STATUS_PARAM)
{
return llrint(a);
}
int64_t float64_to_int64_round_to_zero( float64 a STATUS_PARAM)
{
return (int64_t)a;
}
float32 float64_to_float32( float64 a STATUS_PARAM)
{
return a;
}
#ifdef FLOATX80
floatx80 float64_to_floatx80( float64 a STATUS_PARAM)
{
return a;
}
#endif
#ifdef FLOAT128
float128 float64_to_float128( float64 a STATUS_PARAM)
{
return a;
}
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision operations.
*----------------------------------------------------------------------------*/
float64 float64_round_to_int( float64 a STATUS_PARAM )
{
#if defined(__arm__)
switch(STATUS(float_rounding_mode)) {
default:
case float_round_nearest_even:
asm("rndd %0, %1" : "=f" (a) : "f"(a));
break;
case float_round_down:
asm("rnddm %0, %1" : "=f" (a) : "f"(a));
break;
case float_round_up:
asm("rnddp %0, %1" : "=f" (a) : "f"(a));
break;
case float_round_to_zero:
asm("rnddz %0, %1" : "=f" (a) : "f"(a));
break;
}
#else
return rint(a);
#endif
}
float64 float64_rem( float64 a, float64 b STATUS_PARAM)
{
return remainder(a, b);
}
float64 float64_sqrt( float64 a STATUS_PARAM)
{
return sqrt(a);
}
char float64_compare( float64 a, float64 b STATUS_PARAM )
{
if (a < b) {
return -1;
} else if (a == b) {
return 0;
} else if (a > b) {
return 1;
} else {
return 2;
}
}
char float64_compare_quiet( float64 a, float64 b STATUS_PARAM )
{
if (isless(a, b)) {
return -1;
} else if (a == b) {
return 0;
} else if (isgreater(a, b)) {
return 1;
} else {
return 2;
}
}
char float64_is_signaling_nan( float64 a1)
{
float64u u;
uint64_t a;
u.f = a1;
a = u.i;
return
( ( ( a>>51 ) & 0xFFF ) == 0xFFE )
&& ( a & LIT64( 0x0007FFFFFFFFFFFF ) );
}
#ifdef FLOATX80
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision conversion routines.
*----------------------------------------------------------------------------*/
int floatx80_to_int32( floatx80 a STATUS_PARAM)
{
return lrintl(a);
}
int floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM)
{
return (int)a;
}
int64_t floatx80_to_int64( floatx80 a STATUS_PARAM)
{
return llrintl(a);
}
int64_t floatx80_to_int64_round_to_zero( floatx80 a STATUS_PARAM)
{
return (int64_t)a;
}
float32 floatx80_to_float32( floatx80 a STATUS_PARAM)
{
return a;
}
float64 floatx80_to_float64( floatx80 a STATUS_PARAM)
{
return a;
}
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision operations.
*----------------------------------------------------------------------------*/
floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM)
{
return rintl(a);
}
floatx80 floatx80_rem( floatx80 a, floatx80 b STATUS_PARAM)
{
return remainderl(a, b);
}
floatx80 floatx80_sqrt( floatx80 a STATUS_PARAM)
{
return sqrtl(a);
}
char floatx80_compare( floatx80 a, floatx80 b STATUS_PARAM )
{
if (a < b) {
return -1;
} else if (a == b) {
return 0;
} else if (a > b) {
return 1;
} else {
return 2;
}
}
char floatx80_compare_quiet( floatx80 a, floatx80 b STATUS_PARAM )
{
if (isless(a, b)) {
return -1;
} else if (a == b) {
return 0;
} else if (isgreater(a, b)) {
return 1;
} else {
return 2;
}
}
char floatx80_is_signaling_nan( floatx80 a1)
{
floatx80u u;
u.f = a1;
return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( u.i.low<<1 );
}
#endif
+332
View File
@@ -0,0 +1,332 @@
/* Native implementation of soft float functions */
#include <math.h>
#if defined(_BSD) && !defined(__APPLE__)
#include <ieeefp.h>
#else
#include <fenv.h>
#endif
typedef float float32;
typedef double float64;
#ifdef FLOATX80
typedef long double floatx80;
#endif
typedef union {
float32 f;
uint32_t i;
} float32u;
typedef union {
float64 f;
uint64_t i;
} float64u;
#ifdef FLOATX80
typedef union {
floatx80 f;
struct {
uint64_t low;
uint16_t high;
} i;
} floatx80u;
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point rounding mode.
*----------------------------------------------------------------------------*/
#if defined(_BSD) && !defined(__APPLE__)
enum {
float_round_nearest_even = FP_RN,
float_round_down = FE_RM,
float_round_up = FE_RP,
float_round_to_zero = FE_RZ
};
#elif defined(__arm__)
enum {
float_round_nearest_even = 0,
float_round_down = 1,
float_round_up = 2,
float_round_to_zero = 3
};
#else
enum {
float_round_nearest_even = FE_TONEAREST,
float_round_down = FE_DOWNWARD,
float_round_up = FE_UPWARD,
float_round_to_zero = FE_TOWARDZERO
};
#endif
typedef struct float_status {
signed char float_rounding_mode;
#ifdef FLOATX80
signed char floatx80_rounding_precision;
#endif
} float_status;
void set_float_rounding_mode(int val STATUS_PARAM);
#ifdef FLOATX80
void set_floatx80_rounding_precision(int val STATUS_PARAM);
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE integer-to-floating-point conversion routines.
*----------------------------------------------------------------------------*/
float32 int32_to_float32( int STATUS_PARAM);
float64 int32_to_float64( int STATUS_PARAM);
#ifdef FLOATX80
floatx80 int32_to_floatx80( int STATUS_PARAM);
#endif
#ifdef FLOAT128
float128 int32_to_float128( int STATUS_PARAM);
#endif
float32 int64_to_float32( int64_t STATUS_PARAM);
float64 int64_to_float64( int64_t STATUS_PARAM);
#ifdef FLOATX80
floatx80 int64_to_floatx80( int64_t STATUS_PARAM);
#endif
#ifdef FLOAT128
float128 int64_to_float128( int64_t STATUS_PARAM);
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision conversion routines.
*----------------------------------------------------------------------------*/
int float32_to_int32( float32 STATUS_PARAM);
int float32_to_int32_round_to_zero( float32 STATUS_PARAM);
int64_t float32_to_int64( float32 STATUS_PARAM);
int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM);
float64 float32_to_float64( float32 STATUS_PARAM);
#ifdef FLOATX80
floatx80 float32_to_floatx80( float32 STATUS_PARAM);
#endif
#ifdef FLOAT128
float128 float32_to_float128( float32 STATUS_PARAM);
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision operations.
*----------------------------------------------------------------------------*/
float32 float32_round_to_int( float32 STATUS_PARAM);
INLINE float32 float32_add( float32 a, float32 b STATUS_PARAM)
{
return a + b;
}
INLINE float32 float32_sub( float32 a, float32 b STATUS_PARAM)
{
return a - b;
}
INLINE float32 float32_mul( float32 a, float32 b STATUS_PARAM)
{
return a * b;
}
INLINE float32 float32_div( float32 a, float32 b STATUS_PARAM)
{
return a / b;
}
float32 float32_rem( float32, float32 STATUS_PARAM);
float32 float32_sqrt( float32 STATUS_PARAM);
INLINE char float32_eq( float32 a, float32 b STATUS_PARAM)
{
return a == b;
}
INLINE char float32_le( float32 a, float32 b STATUS_PARAM)
{
return a <= b;
}
INLINE char float32_lt( float32 a, float32 b STATUS_PARAM)
{
return a < b;
}
INLINE char float32_eq_signaling( float32 a, float32 b STATUS_PARAM)
{
return a <= b && a >= b;
}
INLINE char float32_le_quiet( float32 a, float32 b STATUS_PARAM)
{
return islessequal(a, b);
}
INLINE char float32_lt_quiet( float32 a, float32 b STATUS_PARAM)
{
return isless(a, b);
}
INLINE char float32_unordered( float32 a, float32 b STATUS_PARAM)
{
return isunordered(a, b);
}
char float32_compare( float32, float32 STATUS_PARAM );
char float32_compare_quiet( float32, float32 STATUS_PARAM );
char float32_is_signaling_nan( float32 );
INLINE float32 float32_abs(float32 a)
{
return fabsf(a);
}
INLINE float32 float32_chs(float32 a)
{
return -a;
}
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision conversion routines.
*----------------------------------------------------------------------------*/
int float64_to_int32( float64 STATUS_PARAM );
int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
int64_t float64_to_int64( float64 STATUS_PARAM );
int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM );
float32 float64_to_float32( float64 STATUS_PARAM );
#ifdef FLOATX80
floatx80 float64_to_floatx80( float64 STATUS_PARAM );
#endif
#ifdef FLOAT128
float128 float64_to_float128( float64 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision operations.
*----------------------------------------------------------------------------*/
float64 float64_round_to_int( float64 STATUS_PARAM );
INLINE float64 float64_add( float64 a, float64 b STATUS_PARAM)
{
return a + b;
}
INLINE float64 float64_sub( float64 a, float64 b STATUS_PARAM)
{
return a - b;
}
INLINE float64 float64_mul( float64 a, float64 b STATUS_PARAM)
{
return a * b;
}
INLINE float64 float64_div( float64 a, float64 b STATUS_PARAM)
{
return a / b;
}
float64 float64_rem( float64, float64 STATUS_PARAM );
float64 float64_sqrt( float64 STATUS_PARAM );
INLINE char float64_eq( float64 a, float64 b STATUS_PARAM)
{
return a == b;
}
INLINE char float64_le( float64 a, float64 b STATUS_PARAM)
{
return a <= b;
}
INLINE char float64_lt( float64 a, float64 b STATUS_PARAM)
{
return a < b;
}
INLINE char float64_eq_signaling( float64 a, float64 b STATUS_PARAM)
{
return a <= b && a >= b;
}
INLINE char float64_le_quiet( float64 a, float64 b STATUS_PARAM)
{
return islessequal(a, b);
}
INLINE char float64_lt_quiet( float64 a, float64 b STATUS_PARAM)
{
return isless(a, b);
}
INLINE char float64_unordered( float64 a, float64 b STATUS_PARAM)
{
return isunordered(a, b);
}
char float64_compare( float64, float64 STATUS_PARAM );
char float64_compare_quiet( float64, float64 STATUS_PARAM );
char float64_is_signaling_nan( float64 );
INLINE float64 float64_abs(float64 a)
{
return fabs(a);
}
INLINE float64 float64_chs(float64 a)
{
return -a;
}
#ifdef FLOATX80
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision conversion routines.
*----------------------------------------------------------------------------*/
int floatx80_to_int32( floatx80 STATUS_PARAM );
int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
int64_t floatx80_to_int64( floatx80 STATUS_PARAM);
int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM);
float32 floatx80_to_float32( floatx80 STATUS_PARAM );
float64 floatx80_to_float64( floatx80 STATUS_PARAM );
#ifdef FLOAT128
float128 floatx80_to_float128( floatx80 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision operations.
*----------------------------------------------------------------------------*/
floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM );
INLINE floatx80 floatx80_add( floatx80 a, floatx80 b STATUS_PARAM)
{
return a + b;
}
INLINE floatx80 floatx80_sub( floatx80 a, floatx80 b STATUS_PARAM)
{
return a - b;
}
INLINE floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM)
{
return a * b;
}
INLINE floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM)
{
return a / b;
}
floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_sqrt( floatx80 STATUS_PARAM );
INLINE char floatx80_eq( floatx80 a, floatx80 b STATUS_PARAM)
{
return a == b;
}
INLINE char floatx80_le( floatx80 a, floatx80 b STATUS_PARAM)
{
return a <= b;
}
INLINE char floatx80_lt( floatx80 a, floatx80 b STATUS_PARAM)
{
return a < b;
}
INLINE char floatx80_eq_signaling( floatx80 a, floatx80 b STATUS_PARAM)
{
return a <= b && a >= b;
}
INLINE char floatx80_le_quiet( floatx80 a, floatx80 b STATUS_PARAM)
{
return islessequal(a, b);
}
INLINE char floatx80_lt_quiet( floatx80 a, floatx80 b STATUS_PARAM)
{
return isless(a, b);
}
INLINE char floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM)
{
return isunordered(a, b);
}
char floatx80_compare( floatx80, floatx80 STATUS_PARAM );
char floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
char floatx80_is_signaling_nan( floatx80 );
INLINE floatx80 floatx80_abs(floatx80 a)
{
return fabsl(a);
}
INLINE floatx80 floatx80_chs(floatx80 a)
{
return -a;
}
#endif
+464
View File
@@ -0,0 +1,464 @@
/*============================================================================
This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
Arithmetic Package, Release 2b.
Written by John R. Hauser. This work was made possible in part by the
International Computer Science Institute, located at Suite 600, 1947 Center
Street, Berkeley, California 94704. Funding was partially provided by the
National Science Foundation under grant MIP-9311980. The original version
of this code was written as part of a project to build a fixed-point vector
processor in collaboration with the University of California at Berkeley,
overseen by Profs. Nelson Morgan and John Wawrzynek. More information
is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
arithmetic/SoftFloat.html'.
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
Derivative works are acceptable, even for commercial purposes, so long as
(1) the source code for the derivative work includes prominent notice that
the work is derivative, and (2) the source code includes prominent notice with
these four paragraphs for those parts of this code that are retained.
=============================================================================*/
/*----------------------------------------------------------------------------
| Underflow tininess-detection mode, statically initialized to default value.
| (The declaration in `softfloat.h' must match the `int8' type here.)
*----------------------------------------------------------------------------*/
int8 float_detect_tininess = float_tininess_after_rounding;
/*----------------------------------------------------------------------------
| Raises the exceptions specified by `flags'. Floating-point traps can be
| defined here if desired. It is currently not possible for such a trap
| to substitute a result value. If traps are not implemented, this routine
| should be simply `float_exception_flags |= flags;'.
*----------------------------------------------------------------------------*/
void float_raise( int8 flags STATUS_PARAM )
{
STATUS(float_exception_flags) |= flags;
}
/*----------------------------------------------------------------------------
| Internal canonical NaN format.
*----------------------------------------------------------------------------*/
typedef struct {
flag sign;
bits64 high, low;
} commonNaNT;
/*----------------------------------------------------------------------------
| The pattern for a default generated single-precision NaN.
*----------------------------------------------------------------------------*/
#define float32_default_nan 0xFFC00000
/*----------------------------------------------------------------------------
| Returns 1 if the single-precision floating-point value `a' is a NaN;
| otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float32_is_nan( float32 a )
{
return ( 0xFF000000 < (bits32) ( a<<1 ) );
}
/*----------------------------------------------------------------------------
| Returns 1 if the single-precision floating-point value `a' is a signaling
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float32_is_signaling_nan( float32 a )
{
return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the single-precision floating-point NaN
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
| exception is raised.
*----------------------------------------------------------------------------*/
static commonNaNT float32ToCommonNaN( float32 a STATUS_PARAM )
{
commonNaNT z;
if ( float32_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR );
z.sign = a>>31;
z.low = 0;
z.high = ( (bits64) a )<<41;
return z;
}
/*----------------------------------------------------------------------------
| Returns the result of converting the canonical NaN `a' to the single-
| precision floating-point format.
*----------------------------------------------------------------------------*/
static float32 commonNaNToFloat32( commonNaNT a )
{
return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | ( a.high>>41 );
}
/*----------------------------------------------------------------------------
| Takes two single-precision floating-point values `a' and `b', one of which
| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
| signaling NaN, the invalid exception is raised.
*----------------------------------------------------------------------------*/
static float32 propagateFloat32NaN( float32 a, float32 b STATUS_PARAM)
{
flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
aIsNaN = float32_is_nan( a );
aIsSignalingNaN = float32_is_signaling_nan( a );
bIsNaN = float32_is_nan( b );
bIsSignalingNaN = float32_is_signaling_nan( b );
a |= 0x00400000;
b |= 0x00400000;
if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid STATUS_VAR);
if ( aIsSignalingNaN ) {
if ( bIsSignalingNaN ) goto returnLargerSignificand;
return bIsNaN ? b : a;
}
else if ( aIsNaN ) {
if ( bIsSignalingNaN | ! bIsNaN ) return a;
returnLargerSignificand:
if ( (bits32) ( a<<1 ) < (bits32) ( b<<1 ) ) return b;
if ( (bits32) ( b<<1 ) < (bits32) ( a<<1 ) ) return a;
return ( a < b ) ? a : b;
}
else {
return b;
}
}
/*----------------------------------------------------------------------------
| The pattern for a default generated double-precision NaN.
*----------------------------------------------------------------------------*/
#define float64_default_nan LIT64( 0xFFF8000000000000 )
/*----------------------------------------------------------------------------
| Returns 1 if the double-precision floating-point value `a' is a NaN;
| otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float64_is_nan( float64 a )
{
return ( LIT64( 0xFFE0000000000000 ) < (bits64) ( a<<1 ) );
}
/*----------------------------------------------------------------------------
| Returns 1 if the double-precision floating-point value `a' is a signaling
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float64_is_signaling_nan( float64 a )
{
return
( ( ( a>>51 ) & 0xFFF ) == 0xFFE )
&& ( a & LIT64( 0x0007FFFFFFFFFFFF ) );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the double-precision floating-point NaN
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
| exception is raised.
*----------------------------------------------------------------------------*/
static commonNaNT float64ToCommonNaN( float64 a STATUS_PARAM)
{
commonNaNT z;
if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
z.sign = a>>63;
z.low = 0;
z.high = a<<12;
return z;
}
/*----------------------------------------------------------------------------
| Returns the result of converting the canonical NaN `a' to the double-
| precision floating-point format.
*----------------------------------------------------------------------------*/
static float64 commonNaNToFloat64( commonNaNT a )
{
return
( ( (bits64) a.sign )<<63 )
| LIT64( 0x7FF8000000000000 )
| ( a.high>>12 );
}
/*----------------------------------------------------------------------------
| Takes two double-precision floating-point values `a' and `b', one of which
| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
| signaling NaN, the invalid exception is raised.
*----------------------------------------------------------------------------*/
static float64 propagateFloat64NaN( float64 a, float64 b STATUS_PARAM)
{
flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
aIsNaN = float64_is_nan( a );
aIsSignalingNaN = float64_is_signaling_nan( a );
bIsNaN = float64_is_nan( b );
bIsSignalingNaN = float64_is_signaling_nan( b );
a |= LIT64( 0x0008000000000000 );
b |= LIT64( 0x0008000000000000 );
if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid STATUS_VAR);
if ( aIsSignalingNaN ) {
if ( bIsSignalingNaN ) goto returnLargerSignificand;
return bIsNaN ? b : a;
}
else if ( aIsNaN ) {
if ( bIsSignalingNaN | ! bIsNaN ) return a;
returnLargerSignificand:
if ( (bits64) ( a<<1 ) < (bits64) ( b<<1 ) ) return b;
if ( (bits64) ( b<<1 ) < (bits64) ( a<<1 ) ) return a;
return ( a < b ) ? a : b;
}
else {
return b;
}
}
#ifdef FLOATX80
/*----------------------------------------------------------------------------
| The pattern for a default generated extended double-precision NaN. The
| `high' and `low' values hold the most- and least-significant bits,
| respectively.
*----------------------------------------------------------------------------*/
#define floatx80_default_nan_high 0xFFFF
#define floatx80_default_nan_low LIT64( 0xC000000000000000 )
/*----------------------------------------------------------------------------
| Returns 1 if the extended double-precision floating-point value `a' is a
| NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
flag floatx80_is_nan( floatx80 a )
{
return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 );
}
/*----------------------------------------------------------------------------
| Returns 1 if the extended double-precision floating-point value `a' is a
| signaling NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
flag floatx80_is_signaling_nan( floatx80 a )
{
bits64 aLow;
aLow = a.low & ~ LIT64( 0x4000000000000000 );
return
( ( a.high & 0x7FFF ) == 0x7FFF )
&& (bits64) ( aLow<<1 )
&& ( a.low == aLow );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the extended double-precision floating-
| point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the
| invalid exception is raised.
*----------------------------------------------------------------------------*/
static commonNaNT floatx80ToCommonNaN( floatx80 a STATUS_PARAM)
{
commonNaNT z;
if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
z.sign = a.high>>15;
z.low = 0;
z.high = a.low<<1;
return z;
}
/*----------------------------------------------------------------------------
| Returns the result of converting the canonical NaN `a' to the extended
| double-precision floating-point format.
*----------------------------------------------------------------------------*/
static floatx80 commonNaNToFloatx80( commonNaNT a )
{
floatx80 z;
z.low = LIT64( 0xC000000000000000 ) | ( a.high>>1 );
z.high = ( ( (bits16) a.sign )<<15 ) | 0x7FFF;
return z;
}
/*----------------------------------------------------------------------------
| Takes two extended double-precision floating-point values `a' and `b', one
| of which is a NaN, and returns the appropriate NaN result. If either `a' or
| `b' is a signaling NaN, the invalid exception is raised.
*----------------------------------------------------------------------------*/
static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b STATUS_PARAM)
{
flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
aIsNaN = floatx80_is_nan( a );
aIsSignalingNaN = floatx80_is_signaling_nan( a );
bIsNaN = floatx80_is_nan( b );
bIsSignalingNaN = floatx80_is_signaling_nan( b );
a.low |= LIT64( 0xC000000000000000 );
b.low |= LIT64( 0xC000000000000000 );
if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid STATUS_VAR);
if ( aIsSignalingNaN ) {
if ( bIsSignalingNaN ) goto returnLargerSignificand;
return bIsNaN ? b : a;
}
else if ( aIsNaN ) {
if ( bIsSignalingNaN | ! bIsNaN ) return a;
returnLargerSignificand:
if ( a.low < b.low ) return b;
if ( b.low < a.low ) return a;
return ( a.high < b.high ) ? a : b;
}
else {
return b;
}
}
#endif
#ifdef FLOAT128
/*----------------------------------------------------------------------------
| The pattern for a default generated quadruple-precision NaN. The `high' and
| `low' values hold the most- and least-significant bits, respectively.
*----------------------------------------------------------------------------*/
#define float128_default_nan_high LIT64( 0xFFFF800000000000 )
#define float128_default_nan_low LIT64( 0x0000000000000000 )
/*----------------------------------------------------------------------------
| Returns 1 if the quadruple-precision floating-point value `a' is a NaN;
| otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float128_is_nan( float128 a )
{
return
( LIT64( 0xFFFE000000000000 ) <= (bits64) ( a.high<<1 ) )
&& ( a.low || ( a.high & LIT64( 0x0000FFFFFFFFFFFF ) ) );
}
/*----------------------------------------------------------------------------
| Returns 1 if the quadruple-precision floating-point value `a' is a
| signaling NaN; otherwise returns 0.
*----------------------------------------------------------------------------*/
flag float128_is_signaling_nan( float128 a )
{
return
( ( ( a.high>>47 ) & 0xFFFF ) == 0xFFFE )
&& ( a.low || ( a.high & LIT64( 0x00007FFFFFFFFFFF ) ) );
}
/*----------------------------------------------------------------------------
| Returns the result of converting the quadruple-precision floating-point NaN
| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
| exception is raised.
*----------------------------------------------------------------------------*/
static commonNaNT float128ToCommonNaN( float128 a STATUS_PARAM)
{
commonNaNT z;
if ( float128_is_signaling_nan( a ) ) float_raise( float_flag_invalid STATUS_VAR);
z.sign = a.high>>63;
shortShift128Left( a.high, a.low, 16, &z.high, &z.low );
return z;
}
/*----------------------------------------------------------------------------
| Returns the result of converting the canonical NaN `a' to the quadruple-
| precision floating-point format.
*----------------------------------------------------------------------------*/
static float128 commonNaNToFloat128( commonNaNT a )
{
float128 z;
shift128Right( a.high, a.low, 16, &z.high, &z.low );
z.high |= ( ( (bits64) a.sign )<<63 ) | LIT64( 0x7FFF800000000000 );
return z;
}
/*----------------------------------------------------------------------------
| Takes two quadruple-precision floating-point values `a' and `b', one of
| which is a NaN, and returns the appropriate NaN result. If either `a' or
| `b' is a signaling NaN, the invalid exception is raised.
*----------------------------------------------------------------------------*/
static float128 propagateFloat128NaN( float128 a, float128 b STATUS_PARAM)
{
flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
aIsNaN = float128_is_nan( a );
aIsSignalingNaN = float128_is_signaling_nan( a );
bIsNaN = float128_is_nan( b );
bIsSignalingNaN = float128_is_signaling_nan( b );
a.high |= LIT64( 0x0000800000000000 );
b.high |= LIT64( 0x0000800000000000 );
if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid STATUS_VAR);
if ( aIsSignalingNaN ) {
if ( bIsSignalingNaN ) goto returnLargerSignificand;
return bIsNaN ? b : a;
}
else if ( aIsNaN ) {
if ( bIsSignalingNaN | ! bIsNaN ) return a;
returnLargerSignificand:
if ( lt128( a.high<<1, a.low, b.high<<1, b.low ) ) return b;
if ( lt128( b.high<<1, b.low, a.high<<1, a.low ) ) return a;
return ( a.high < b.high ) ? a : b;
}
else {
return b;
}
}
#endif
+5320
View File
File diff suppressed because it is too large. Load diff
+398
View File
@@ -0,0 +1,398 @@
/*============================================================================
This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
Package, Release 2b.
Written by John R. Hauser. This work was made possible in part by the
International Computer Science Institute, located at Suite 600, 1947 Center
Street, Berkeley, California 94704. Funding was partially provided by the
National Science Foundation under grant MIP-9311980. The original version
of this code was written as part of a project to build a fixed-point vector
processor in collaboration with the University of California at Berkeley,
overseen by Profs. Nelson Morgan and John Wawrzynek. More information
is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
arithmetic/SoftFloat.html'.
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort has
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
Derivative works are acceptable, even for commercial purposes, so long as
(1) the source code for the derivative work includes prominent notice that
the work is derivative, and (2) the source code includes prominent notice with
these four paragraphs for those parts of this code that are retained.
=============================================================================*/
#ifndef SOFTFLOAT_H
#define SOFTFLOAT_H
#include <inttypes.h>
#include "config.h"
/*----------------------------------------------------------------------------
| Each of the following `typedef's defines the most convenient type that holds
| integers of at least as many bits as specified. For example, `uint8' should
| be the most convenient type that can hold unsigned integers of as many as
| 8 bits. The `flag' type must be able to hold either a 0 or 1. For most
| implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
| to the same as `int'.
*----------------------------------------------------------------------------*/
typedef char flag;
typedef uint8_t uint8;
typedef int8_t int8;
typedef int uint16;
typedef int int16;
typedef unsigned int uint32;
typedef signed int int32;
typedef uint64_t uint64;
typedef int64_t int64;
/*----------------------------------------------------------------------------
| Each of the following `typedef's defines a type that holds integers
| of _exactly_ the number of bits specified. For instance, for most
| implementation of C, `bits16' and `sbits16' should be `typedef'ed to
| `unsigned short int' and `signed short int' (or `short int'), respectively.
*----------------------------------------------------------------------------*/
typedef uint8_t bits8;
typedef int8_t sbits8;
typedef uint16_t bits16;
typedef int16_t sbits16;
typedef uint32_t bits32;
typedef int32_t sbits32;
typedef uint64_t bits64;
typedef int64_t sbits64;
#define LIT64( a ) a##LL
#define INLINE static inline
/*----------------------------------------------------------------------------
| The macro `FLOATX80' must be defined to enable the extended double-precision
| floating-point format `floatx80'. If this macro is not defined, the
| `floatx80' type will not be defined, and none of the functions that either
| input or output the `floatx80' type will be defined. The same applies to
| the `FLOAT128' macro and the quadruple-precision format `float128'.
*----------------------------------------------------------------------------*/
#ifdef CONFIG_SOFTFLOAT
/* bit exact soft float support */
#define FLOATX80
#define FLOAT128
#else
/* native float support */
#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
#define FLOATX80
#endif
#endif /* !CONFIG_SOFTFLOAT */
#define STATUS_PARAM , float_status *status
#define STATUS(field) status->field
#define STATUS_VAR , status
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point ordering relations
*----------------------------------------------------------------------------*/
enum {
float_relation_less = -1,
float_relation_equal = 0,
float_relation_greater = 1,
float_relation_unordered = 2
};
#ifdef CONFIG_SOFTFLOAT
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point types.
*----------------------------------------------------------------------------*/
typedef uint32_t float32;
typedef uint64_t float64;
#ifdef FLOATX80
typedef struct {
uint64_t low;
uint16_t high;
} floatx80;
#endif
#ifdef FLOAT128
typedef struct {
#ifdef WORDS_BIGENDIAN
uint64_t high, low;
#else
uint64_t low, high;
#endif
} float128;
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point underflow tininess-detection mode.
*----------------------------------------------------------------------------*/
enum {
float_tininess_after_rounding = 0,
float_tininess_before_rounding = 1
};
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point rounding mode.
*----------------------------------------------------------------------------*/
enum {
float_round_nearest_even = 0,
float_round_down = 1,
float_round_up = 2,
float_round_to_zero = 3
};
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point exception flags.
*----------------------------------------------------------------------------*/
enum {
float_flag_invalid = 1,
float_flag_divbyzero = 4,
float_flag_overflow = 8,
float_flag_underflow = 16,
float_flag_inexact = 32
};
typedef struct float_status {
signed char float_detect_tininess;
signed char float_rounding_mode;
signed char float_exception_flags;
#ifdef FLOATX80
signed char floatx80_rounding_precision;
#endif
} float_status;
void set_float_rounding_mode(int val STATUS_PARAM);
void set_float_exception_flags(int val STATUS_PARAM);
INLINE int get_float_exception_flags(float_status *status)
{
return STATUS(float_exception_flags);
}
#ifdef FLOATX80
void set_floatx80_rounding_precision(int val STATUS_PARAM);
#endif
/*----------------------------------------------------------------------------
| Routine to raise any or all of the software IEC/IEEE floating-point
| exception flags.
*----------------------------------------------------------------------------*/
void float_raise( signed char STATUS_PARAM);
/*----------------------------------------------------------------------------
| Software IEC/IEEE integer-to-floating-point conversion routines.
*----------------------------------------------------------------------------*/
float32 int32_to_float32( int STATUS_PARAM );
float64 int32_to_float64( int STATUS_PARAM );
float32 uint32_to_float32( unsigned int STATUS_PARAM );
float64 uint32_to_float64( unsigned int STATUS_PARAM );
#ifdef FLOATX80
floatx80 int32_to_floatx80( int STATUS_PARAM );
#endif
#ifdef FLOAT128
float128 int32_to_float128( int STATUS_PARAM );
#endif
float32 int64_to_float32( int64_t STATUS_PARAM );
float64 int64_to_float64( int64_t STATUS_PARAM );
#ifdef FLOATX80
floatx80 int64_to_floatx80( int64_t STATUS_PARAM );
#endif
#ifdef FLOAT128
float128 int64_to_float128( int64_t STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision conversion routines.
*----------------------------------------------------------------------------*/
int float32_to_int32( float32 STATUS_PARAM );
int float32_to_int32_round_to_zero( float32 STATUS_PARAM );
unsigned int float32_to_uint32( float32 STATUS_PARAM );
unsigned int float32_to_uint32_round_to_zero( float32 STATUS_PARAM );
int64_t float32_to_int64( float32 STATUS_PARAM );
int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM );
float64 float32_to_float64( float32 STATUS_PARAM );
#ifdef FLOATX80
floatx80 float32_to_floatx80( float32 STATUS_PARAM );
#endif
#ifdef FLOAT128
float128 float32_to_float128( float32 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE single-precision operations.
*----------------------------------------------------------------------------*/
float32 float32_round_to_int( float32 STATUS_PARAM );
float32 float32_add( float32, float32 STATUS_PARAM );
float32 float32_sub( float32, float32 STATUS_PARAM );
float32 float32_mul( float32, float32 STATUS_PARAM );
float32 float32_div( float32, float32 STATUS_PARAM );
float32 float32_rem( float32, float32 STATUS_PARAM );
float32 float32_sqrt( float32 STATUS_PARAM );
char float32_eq( float32, float32 STATUS_PARAM );
char float32_le( float32, float32 STATUS_PARAM );
char float32_lt( float32, float32 STATUS_PARAM );
char float32_eq_signaling( float32, float32 STATUS_PARAM );
char float32_le_quiet( float32, float32 STATUS_PARAM );
char float32_lt_quiet( float32, float32 STATUS_PARAM );
char float32_compare( float32, float32 STATUS_PARAM );
char float32_compare_quiet( float32, float32 STATUS_PARAM );
char float32_is_signaling_nan( float32 );
INLINE float32 float32_abs(float32 a)
{
return a & 0x7fffffff;
}
INLINE float32 float32_chs(float32 a)
{
return a ^ 0x80000000;
}
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision conversion routines.
*----------------------------------------------------------------------------*/
int float64_to_int32( float64 STATUS_PARAM );
int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
unsigned int float64_to_uint32( float64 STATUS_PARAM );
unsigned int float64_to_uint32_round_to_zero( float64 STATUS_PARAM );
int64_t float64_to_int64( float64 STATUS_PARAM );
int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM );
float32 float64_to_float32( float64 STATUS_PARAM );
#ifdef FLOATX80
floatx80 float64_to_floatx80( float64 STATUS_PARAM );
#endif
#ifdef FLOAT128
float128 float64_to_float128( float64 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE double-precision operations.
*----------------------------------------------------------------------------*/
float64 float64_round_to_int( float64 STATUS_PARAM );
float64 float64_add( float64, float64 STATUS_PARAM );
float64 float64_sub( float64, float64 STATUS_PARAM );
float64 float64_mul( float64, float64 STATUS_PARAM );
float64 float64_div( float64, float64 STATUS_PARAM );
float64 float64_rem( float64, float64 STATUS_PARAM );
float64 float64_sqrt( float64 STATUS_PARAM );
char float64_eq( float64, float64 STATUS_PARAM );
char float64_le( float64, float64 STATUS_PARAM );
char float64_lt( float64, float64 STATUS_PARAM );
char float64_eq_signaling( float64, float64 STATUS_PARAM );
char float64_le_quiet( float64, float64 STATUS_PARAM );
char float64_lt_quiet( float64, float64 STATUS_PARAM );
char float64_compare( float64, float64 STATUS_PARAM );
char float64_compare_quiet( float64, float64 STATUS_PARAM );
char float64_is_signaling_nan( float64 );
INLINE float64 float64_abs(float64 a)
{
return a & 0x7fffffffffffffffLL;
}
INLINE float64 float64_chs(float64 a)
{
return a ^ 0x8000000000000000LL;
}
#ifdef FLOATX80
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision conversion routines.
*----------------------------------------------------------------------------*/
int floatx80_to_int32( floatx80 STATUS_PARAM );
int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
int64_t floatx80_to_int64( floatx80 STATUS_PARAM );
int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM );
float32 floatx80_to_float32( floatx80 STATUS_PARAM );
float64 floatx80_to_float64( floatx80 STATUS_PARAM );
#ifdef FLOAT128
float128 floatx80_to_float128( floatx80 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE extended double-precision operations.
*----------------------------------------------------------------------------*/
floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM );
floatx80 floatx80_add( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_sub( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_mul( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_div( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM );
floatx80 floatx80_sqrt( floatx80 STATUS_PARAM );
char floatx80_eq( floatx80, floatx80 STATUS_PARAM );
char floatx80_le( floatx80, floatx80 STATUS_PARAM );
char floatx80_lt( floatx80, floatx80 STATUS_PARAM );
char floatx80_eq_signaling( floatx80, floatx80 STATUS_PARAM );
char floatx80_le_quiet( floatx80, floatx80 STATUS_PARAM );
char floatx80_lt_quiet( floatx80, floatx80 STATUS_PARAM );
char floatx80_is_signaling_nan( floatx80 );
INLINE floatx80 floatx80_abs(floatx80 a)
{
a.high &= 0x7fff;
return a;
}
INLINE floatx80 floatx80_chs(floatx80 a)
{
a.high ^= 0x8000;
return a;
}
#endif
#ifdef FLOAT128
/*----------------------------------------------------------------------------
| Software IEC/IEEE quadruple-precision conversion routines.
*----------------------------------------------------------------------------*/
int float128_to_int32( float128 STATUS_PARAM );
int float128_to_int32_round_to_zero( float128 STATUS_PARAM );
int64_t float128_to_int64( float128 STATUS_PARAM );
int64_t float128_to_int64_round_to_zero( float128 STATUS_PARAM );
float32 float128_to_float32( float128 STATUS_PARAM );
float64 float128_to_float64( float128 STATUS_PARAM );
#ifdef FLOATX80
floatx80 float128_to_floatx80( float128 STATUS_PARAM );
#endif
/*----------------------------------------------------------------------------
| Software IEC/IEEE quadruple-precision operations.
*----------------------------------------------------------------------------*/
float128 float128_round_to_int( float128 STATUS_PARAM );
float128 float128_add( float128, float128 STATUS_PARAM );
float128 float128_sub( float128, float128 STATUS_PARAM );
float128 float128_mul( float128, float128 STATUS_PARAM );
float128 float128_div( float128, float128 STATUS_PARAM );
float128 float128_rem( float128, float128 STATUS_PARAM );
float128 float128_sqrt( float128 STATUS_PARAM );
char float128_eq( float128, float128 STATUS_PARAM );
char float128_le( float128, float128 STATUS_PARAM );
char float128_lt( float128, float128 STATUS_PARAM );
char float128_eq_signaling( float128, float128 STATUS_PARAM );
char float128_le_quiet( float128, float128 STATUS_PARAM );
char float128_lt_quiet( float128, float128 STATUS_PARAM );
char float128_is_signaling_nan( float128 );
INLINE float128 float128_abs(float128 a)
{
a.high &= 0x7fffffffffffffffLL;
return a;
}
INLINE float128 float128_chs(float128 a)
{
a.high ^= 0x8000000000000000LL;
return a;
}
#endif
#else /* CONFIG_SOFTFLOAT */
#include "softfloat-native.h"
#endif /* !CONFIG_SOFTFLOAT */
#endif /* !SOFTFLOAT_H */
+170 -36
View File
@@ -17,7 +17,18 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef CONFIG_USER_ONLY
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "qemu.h"
#else
#include "vl.h"
#endif
#include <sys/socket.h>
#include <netinet/in.h>
@@ -32,17 +43,25 @@ enum RSState {
RS_CHKSUM1,
RS_CHKSUM2,
};
static int gdbserver_fd;
/* XXX: This is not thread safe. Do we care? */
static int gdbserver_fd = -1;
typedef struct GDBState {
enum RSState state;
enum RSState state; /* parsing state */
int fd;
char line_buf[4096];
int line_buf_index;
int line_csum;
#ifdef CONFIG_USER_ONLY
int running_state;
#endif
} GDBState;
#ifdef CONFIG_USER_ONLY
/* XXX: remove this hack. */
static GDBState gdbserver_state;
#endif
static int get_char(GDBState *s)
{
uint8_t ch;
@@ -218,13 +237,6 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
}
#elif defined (TARGET_PPC)
static uint32_t from_le32 (uint32_t *buf)
{
uint8_t *p = (uint8_t *)buf;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
{
uint32_t *registers = (uint32_t *)mem_buf, tmp;
@@ -298,11 +310,7 @@ static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
}
/* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
registers[64] = tswapl(env->y);
tmp = (0<<28) | (4<<24) | env->psr \
| (env->psrs? PSR_S : 0) \
| (env->psrs? PSR_PS : 0) \
| (env->psret? PSR_ET : 0) \
| env->cwp;
tmp = GET_PSR(env);
registers[65] = tswapl(tmp);
registers[66] = tswapl(env->wim);
registers[67] = tswapl(env->tbr);
@@ -317,7 +325,7 @@ static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
{
uint32_t *registers = (uint32_t *)mem_buf, tmp;
uint32_t *registers = (uint32_t *)mem_buf;
int i;
/* fill in g0..g7 */
@@ -334,20 +342,54 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
}
/* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
env->y = tswapl(registers[64]);
tmp = tswapl(registers[65]);
env->psr = tmp & ~PSR_ICC;
env->psrs = (tmp & PSR_S)? 1 : 0;
env->psrps = (tmp & PSR_PS)? 1 : 0;
env->psret = (tmp & PSR_ET)? 1 : 0;
env->cwp = (tmp & PSR_CWP);
PUT_PSR(env, tswapl(registers[65]));
env->wim = tswapl(registers[66]);
env->tbr = tswapl(registers[67]);
env->pc = tswapl(registers[68]);
env->npc = tswapl(registers[69]);
env->fsr = tswapl(registers[70]);
}
#else
#elif defined (TARGET_ARM)
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
{
int i;
uint8_t *ptr;
ptr = mem_buf;
/* 16 core integer registers (4 bytes each). */
for (i = 0; i < 16; i++)
{
*(uint32_t *)ptr = tswapl(env->regs[i]);
ptr += 4;
}
/* 8 FPA registers (12 bytes each), FPS (4 bytes).
Not yet implemented. */
memset (ptr, 0, 8 * 12 + 4);
ptr += 8 * 12 + 4;
/* CPSR (4 bytes). */
*(uint32_t *)ptr = tswapl (env->cpsr);
ptr += 4;
return ptr - mem_buf;
}
static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
{
int i;
uint8_t *ptr;
ptr = mem_buf;
/* Core integer registers. */
for (i = 0; i < 16; i++)
{
env->regs[i] = tswapl(*(uint32_t *)ptr);
ptr += 4;
}
/* Ignore FPA regs and scr. */
ptr += 8 * 12 + 4;
env->cpsr = tswapl(*(uint32_t *)ptr);
}
#else
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
{
return 0;
@@ -359,10 +401,8 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
#endif
/* port = 0 means default port */
static int gdb_handle_packet(GDBState *s, const char *line_buf)
static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
{
CPUState *env = cpu_single_env;
const char *p;
int ch, reg_size, type;
char buf[4096];
@@ -377,6 +417,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
ch = *p++;
switch(ch) {
case '?':
/* TODO: Make this return the correct value for user-mode. */
snprintf(buf, sizeof(buf), "S%02x", SIGTRAP);
put_packet(s, buf);
break;
@@ -392,8 +433,12 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
env->npc = addr + 4;
#endif
}
#ifdef CONFIG_USER_ONLY
s->running_state = 1;
#else
vm_start();
break;
#endif
return RS_IDLE;
case 's':
if (*p != '\0') {
addr = strtoul(p, (char **)&p, 16);
@@ -407,8 +452,12 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
#endif
}
cpu_single_step(env, 1);
#ifdef CONFIG_USER_ONLY
s->running_state = 1;
#else
vm_start();
break;
#endif
return RS_IDLE;
case 'g':
reg_size = cpu_gdb_read_registers(env, mem_buf);
memtohex(buf, mem_buf, reg_size);
@@ -436,11 +485,11 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
if (*p == ',')
p++;
len = strtoul(p, (char **)&p, 16);
if (*p == ',')
if (*p == ':')
p++;
hextomem(mem_buf, p, len);
if (cpu_memory_rw_debug(env, addr, mem_buf, len, 1) != 0)
put_packet(s, "ENN");
put_packet(s, "E14");
else
put_packet(s, "OK");
break;
@@ -458,7 +507,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
put_packet(s, "OK");
} else {
breakpoint_error:
put_packet(s, "ENN");
put_packet(s, "E22");
}
break;
case 'z':
@@ -486,6 +535,9 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
return RS_IDLE;
}
extern void tb_flush(CPUState *env);
#ifndef CONFIG_USER_ONLY
static void gdb_vm_stopped(void *opaque, int reason)
{
GDBState *s = opaque;
@@ -495,24 +547,30 @@ static void gdb_vm_stopped(void *opaque, int reason)
/* disable single step if it was enable */
cpu_single_step(cpu_single_env, 0);
if (reason == EXCP_DEBUG)
if (reason == EXCP_DEBUG) {
tb_flush(cpu_single_env);
ret = SIGTRAP;
}
else
ret = 0;
snprintf(buf, sizeof(buf), "S%02x", ret);
put_packet(s, buf);
}
#endif
static void gdb_read_byte(GDBState *s, int ch)
static void gdb_read_byte(GDBState *s, CPUState *env, int ch)
{
int i, csum;
char reply[1];
#ifndef CONFIG_USER_ONLY
if (vm_running) {
/* when the CPU is running, we cannot do anything except stop
it when receiving a char */
vm_stop(EXCP_INTERRUPT);
} else {
} else
#endif
{
switch(s->state) {
case RS_IDLE:
if (ch == '$') {
@@ -547,13 +605,74 @@ static void gdb_read_byte(GDBState *s, int ch)
} else {
reply[0] = '+';
put_buffer(s, reply, 1);
s->state = gdb_handle_packet(s, s->line_buf);
s->state = gdb_handle_packet(s, env, s->line_buf);
}
break;
}
}
}
#ifdef CONFIG_USER_ONLY
int
gdb_handlesig (CPUState *env, int sig)
{
GDBState *s;
char buf[256];
int n;
if (gdbserver_fd < 0)
return sig;
s = &gdbserver_state;
/* disable single step if it was enabled */
cpu_single_step(env, 0);
tb_flush(env);
if (sig != 0)
{
snprintf(buf, sizeof(buf), "S%02x", sig);
put_packet(s, buf);
}
sig = 0;
s->state = RS_IDLE;
s->running_state = 0;
while (s->running_state == 0) {
n = read (s->fd, buf, 256);
if (n > 0)
{
int i;
for (i = 0; i < n; i++)
gdb_read_byte (s, env, buf[i]);
}
else if (n == 0 || errno != EAGAIN)
{
/* XXX: Connection closed. Should probably wait for annother
connection before continuing. */
return sig;
}
}
return sig;
}
/* Tell the remote gdb that the process has exited. */
void gdb_exit(CPUState *env, int code)
{
GDBState *s;
char buf[4];
if (gdbserver_fd < 0)
return;
s = &gdbserver_state;
snprintf(buf, sizeof(buf), "W%02x", code);
put_packet(s, buf);
}
#else
static int gdb_can_read(void *opaque)
{
return 256;
@@ -571,10 +690,12 @@ static void gdb_read(void *opaque, const uint8_t *buf, int size)
vm_start();
} else {
for(i = 0; i < size; i++)
gdb_read_byte(s, buf[i]);
gdb_read_byte(s, cpu_single_env, buf[i]);
}
}
#endif
static void gdb_accept(void *opaque, const uint8_t *buf, int size)
{
GDBState *s;
@@ -597,15 +718,21 @@ static void gdb_accept(void *opaque, const uint8_t *buf, int size)
val = 1;
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
#ifdef CONFIG_USER_ONLY
s = &gdbserver_state;
memset (s, 0, sizeof (GDBState));
#else
s = qemu_mallocz(sizeof(GDBState));
if (!s) {
close(fd);
return;
}
#endif
s->fd = fd;
fcntl(fd, F_SETFL, O_NONBLOCK);
#ifndef CONFIG_USER_ONLY
/* stop the VM */
vm_stop(EXCP_INTERRUPT);
@@ -613,6 +740,7 @@ static void gdb_accept(void *opaque, const uint8_t *buf, int size)
qemu_add_fd_read_handler(s->fd, gdb_can_read, gdb_read, s);
/* when the VM is stopped, the following callback is called */
qemu_add_vm_stop_handler(gdb_vm_stopped, s);
#endif
}
static int gdbserver_open(int port)
@@ -643,7 +771,9 @@ static int gdbserver_open(int port)
perror("listen");
return -1;
}
#ifndef CONFIG_USER_ONLY
fcntl(fd, F_SETFL, O_NONBLOCK);
#endif
return fd;
}
@@ -653,6 +783,10 @@ int gdbserver_start(int port)
if (gdbserver_fd < 0)
return -1;
/* accept connections */
#ifdef CONFIG_USER_ONLY
gdb_accept (NULL, NULL, 0);
#else
qemu_add_fd_read_handler(gdbserver_fd, NULL, gdb_accept, NULL);
#endif
return 0;
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef GDBSTUB_H
#define GDBSTUB_H
#define DEFAULT_GDBSTUB_PORT 1234
#ifdef CONFIG_USER_ONLY
int gdb_handlesig (CPUState *, int);
void gdb_exit(CPUState *, int);
#endif
int gdbserver_start(int);
#endif
+28 -4
View File
@@ -248,13 +248,25 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
return olen;
}
static int adb_kbd_reset(ADBDevice *d)
{
KBDState *s = d->opaque;
d->handler = 1;
d->devaddr = ADB_KEYBOARD;
memset(s, 0, sizeof(KBDState));
return 0;
}
void adb_kbd_init(ADBBusState *bus)
{
ADBDevice *d;
KBDState *s;
s = qemu_mallocz(sizeof(KBDState));
d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request, NULL, s);
d->handler = 1;
d = adb_register_device(bus, ADB_KEYBOARD, adb_kbd_request,
adb_kbd_reset, s);
adb_kbd_reset(d);
qemu_add_kbd_event_handler(adb_kbd_put_keycode, d);
}
@@ -374,13 +386,25 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
return olen;
}
static int adb_mouse_reset(ADBDevice *d)
{
MouseState *s = d->opaque;
d->handler = 2;
d->devaddr = ADB_MOUSE;
memset(s, 0, sizeof(MouseState));
return 0;
}
void adb_mouse_init(ADBBusState *bus)
{
ADBDevice *d;
MouseState *s;
s = qemu_mallocz(sizeof(MouseState));
d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request, NULL, s);
d->handler = 2;
d = adb_register_device(bus, ADB_MOUSE, adb_mouse_request,
adb_mouse_reset, s);
adb_mouse_reset(d);
qemu_add_mouse_event_handler(adb_mouse_event, d);
}
+453
View File
@@ -0,0 +1,453 @@
/*
* APIC support
*
* Copyright (c) 2004-2005 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "vl.h"
//#define DEBUG_APIC
/* APIC Local Vector Table */
#define APIC_LVT_TIMER 0
#define APIC_LVT_THERMAL 1
#define APIC_LVT_PERFORM 2
#define APIC_LVT_LINT0 3
#define APIC_LVT_LINT1 4
#define APIC_LVT_ERROR 5
#define APIC_LVT_NB 6
/* APIC delivery modes */
#define APIC_DM_FIXED 0
#define APIC_DM_LOWPRI 1
#define APIC_DM_SMI 2
#define APIC_DM_NMI 4
#define APIC_DM_INIT 5
#define APIC_DM_SIPI 6
#define APIC_DM_EXTINT 7
#define APIC_TRIGGER_EDGE 0
#define APIC_TRIGGER_LEVEL 1
#define APIC_LVT_TIMER_PERIODIC (1<<17)
#define APIC_LVT_MASKED (1<<16)
#define APIC_LVT_LEVEL_TRIGGER (1<<15)
#define APIC_LVT_REMOTE_IRR (1<<14)
#define APIC_INPUT_POLARITY (1<<13)
#define APIC_SEND_PENDING (1<<12)
#define ESR_ILLEGAL_ADDRESS (1 << 7)
#define APIC_SV_ENABLE (1 << 8)
typedef struct APICState {
CPUState *cpu_env;
uint32_t apicbase;
uint8_t id;
uint8_t tpr;
uint32_t spurious_vec;
uint32_t isr[8]; /* in service register */
uint32_t tmr[8]; /* trigger mode register */
uint32_t irr[8]; /* interrupt request register */
uint32_t lvt[APIC_LVT_NB];
uint32_t esr; /* error register */
uint32_t icr[2];
uint32_t divide_conf;
int count_shift;
uint32_t initial_count;
int64_t initial_count_load_time, next_time;
QEMUTimer *timer;
} APICState;
static int apic_io_memory;
void cpu_set_apic_base(CPUState *env, uint64_t val)
{
APICState *s = env->apic_state;
#ifdef DEBUG_APIC
printf("cpu_set_apic_base: %016llx\n", val);
#endif
s->apicbase = (val & 0xfffff000) |
(s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
/* if disabled, cannot be enabled again */
if (!(val & MSR_IA32_APICBASE_ENABLE)) {
s->apicbase &= ~MSR_IA32_APICBASE_ENABLE;
env->cpuid_features &= ~CPUID_APIC;
s->spurious_vec &= ~APIC_SV_ENABLE;
}
}
uint64_t cpu_get_apic_base(CPUState *env)
{
APICState *s = env->apic_state;
#ifdef DEBUG_APIC
printf("cpu_get_apic_base: %016llx\n", (uint64_t)s->apicbase);
#endif
return s->apicbase;
}
void cpu_set_apic_tpr(CPUX86State *env, uint8_t val)
{
APICState *s = env->apic_state;
s->tpr = (val & 0x0f) << 4;
}
uint8_t cpu_get_apic_tpr(CPUX86State *env)
{
APICState *s = env->apic_state;
return s->tpr >> 4;
}
/* return -1 if no bit is set */
static int get_highest_priority_int(uint32_t *tab)
{
int i;
for(i = 0;i < 8; i++) {
if (tab[i] != 0) {
return i * 32 + ffs(tab[i]) - 1;
}
}
return -1;
}
static inline void set_bit(uint32_t *tab, int index)
{
int i, mask;
i = index >> 5;
mask = 1 << (index & 0x1f);
tab[i] |= mask;
}
static inline void reset_bit(uint32_t *tab, int index)
{
int i, mask;
i = index >> 5;
mask = 1 << (index & 0x1f);
tab[i] &= ~mask;
}
static int apic_get_ppr(APICState *s)
{
int tpr, isrv, ppr;
tpr = (s->tpr >> 4);
isrv = get_highest_priority_int(s->isr);
if (isrv < 0)
isrv = 0;
isrv >>= 4;
if (tpr >= isrv)
ppr = s->tpr;
else
ppr = isrv << 4;
return ppr;
}
/* signal the CPU if an irq is pending */
static void apic_update_irq(APICState *s)
{
int irrv, isrv;
irrv = get_highest_priority_int(s->irr);
if (irrv < 0)
return;
isrv = get_highest_priority_int(s->isr);
/* if the pending irq has less priority, we do not make a new request */
if (isrv >= 0 && irrv >= isrv)
return;
cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
}
static void apic_set_irq(APICState *s, int vector_num, int trigger_mode)
{
set_bit(s->irr, vector_num);
if (trigger_mode)
set_bit(s->tmr, vector_num);
else
reset_bit(s->tmr, vector_num);
apic_update_irq(s);
}
static void apic_eoi(APICState *s)
{
int isrv;
isrv = get_highest_priority_int(s->isr);
if (isrv < 0)
return;
reset_bit(s->isr, isrv);
apic_update_irq(s);
}
int apic_get_interrupt(CPUState *env)
{
APICState *s = env->apic_state;
int intno;
/* if the APIC is installed or enabled, we let the 8259 handle the
IRQs */
if (!s)
return -1;
if (!(s->spurious_vec & APIC_SV_ENABLE))
return -1;
/* XXX: spurious IRQ handling */
intno = get_highest_priority_int(s->irr);
if (intno < 0)
return -1;
reset_bit(s->irr, intno);
set_bit(s->isr, intno);
apic_update_irq(s);
return intno;
}
static uint32_t apic_get_current_count(APICState *s)
{
int64_t d;
uint32_t val;
d = (qemu_get_clock(vm_clock) - s->initial_count_load_time) >>
s->count_shift;
if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_TIMER_PERIODIC) {
/* periodic */
val = s->initial_count - (d % (s->initial_count + 1));
} else {
if (d >= s->initial_count)
val = 0;
else
val = s->initial_count - d;
}
return val;
}
static void apic_timer_update(APICState *s, int64_t current_time)
{
int64_t next_time, d;
if (!(s->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED)) {
d = (current_time - s->initial_count_load_time) >>
s->count_shift;
if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_TIMER_PERIODIC) {
d = ((d / (s->initial_count + 1)) + 1) * (s->initial_count + 1);
} else {
if (d >= s->initial_count)
goto no_timer;
d = s->initial_count + 1;
}
next_time = s->initial_count_load_time + (d << s->count_shift);
qemu_mod_timer(s->timer, next_time);
s->next_time = next_time;
} else {
no_timer:
qemu_del_timer(s->timer);
}
}
static void apic_timer(void *opaque)
{
APICState *s = opaque;
if (!(s->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED)) {
apic_set_irq(s, s->lvt[APIC_LVT_TIMER] & 0xff, APIC_TRIGGER_EDGE);
}
apic_timer_update(s, s->next_time);
}
static uint32_t apic_mem_readb(void *opaque, target_phys_addr_t addr)
{
return 0;
}
static uint32_t apic_mem_readw(void *opaque, target_phys_addr_t addr)
{
return 0;
}
static void apic_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
static void apic_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
static uint32_t apic_mem_readl(void *opaque, target_phys_addr_t addr)
{
CPUState *env;
APICState *s;
uint32_t val;
int index;
env = cpu_single_env;
if (!env)
return 0;
s = env->apic_state;
index = (addr >> 4) & 0xff;
switch(index) {
case 0x02: /* id */
val = s->id << 24;
break;
case 0x03: /* version */
val = 0x11 | ((APIC_LVT_NB - 1) << 16); /* version 0x11 */
break;
case 0x08:
val = s->tpr;
break;
case 0x0a:
/* ppr */
val = apic_get_ppr(s);
break;
case 0x0f:
val = s->spurious_vec;
break;
case 0x10 ... 0x17:
val = s->isr[index & 7];
break;
case 0x18 ... 0x1f:
val = s->tmr[index & 7];
break;
case 0x20 ... 0x27:
val = s->irr[index & 7];
break;
case 0x28:
val = s->esr;
break;
case 0x32 ... 0x37:
val = s->lvt[index - 0x32];
break;
case 0x30:
case 0x31:
val = s->icr[index & 1];
break;
case 0x38:
val = s->initial_count;
break;
case 0x39:
val = apic_get_current_count(s);
break;
case 0x3e:
val = s->divide_conf;
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
val = 0;
break;
}
#ifdef DEBUG_APIC
printf("APIC read: %08x = %08x\n", (uint32_t)addr, val);
#endif
return val;
}
static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
CPUState *env;
APICState *s;
int index;
env = cpu_single_env;
if (!env)
return;
s = env->apic_state;
#ifdef DEBUG_APIC
printf("APIC write: %08x = %08x\n", (uint32_t)addr, val);
#endif
index = (addr >> 4) & 0xff;
switch(index) {
case 0x02:
s->id = (val >> 24);
break;
case 0x08:
s->tpr = val;
break;
case 0x0b: /* EOI */
apic_eoi(s);
break;
case 0x0f:
s->spurious_vec = val & 0x1ff;
break;
case 0x30:
case 0x31:
s->icr[index & 1] = val;
break;
case 0x32 ... 0x37:
{
int n = index - 0x32;
s->lvt[n] = val;
if (n == APIC_LVT_TIMER)
apic_timer_update(s, qemu_get_clock(vm_clock));
}
break;
case 0x38:
s->initial_count = val;
s->initial_count_load_time = qemu_get_clock(vm_clock);
apic_timer_update(s, s->initial_count_load_time);
break;
case 0x3e:
{
int v;
s->divide_conf = val & 0xb;
v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
s->count_shift = (v + 1) & 7;
}
break;
default:
s->esr |= ESR_ILLEGAL_ADDRESS;
break;
}
}
static CPUReadMemoryFunc *apic_mem_read[3] = {
apic_mem_readb,
apic_mem_readw,
apic_mem_readl,
};
static CPUWriteMemoryFunc *apic_mem_write[3] = {
apic_mem_writeb,
apic_mem_writew,
apic_mem_writel,
};
int apic_init(CPUState *env)
{
APICState *s;
int i;
s = malloc(sizeof(APICState));
if (!s)
return -1;
memset(s, 0, sizeof(*s));
env->apic_state = s;
s->cpu_env = env;
s->apicbase = 0xfee00000 |
MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE;
for(i = 0; i < APIC_LVT_NB; i++)
s->lvt[i] = 1 << 16; /* mask LVT */
s->spurious_vec = 0xff;
if (apic_io_memory == 0) {
/* NOTE: the APIC is directly connected to the CPU - it is not
on the global memory bus. */
apic_io_memory = cpu_register_io_memory(0, apic_mem_read,
apic_mem_write, NULL);
cpu_register_physical_memory(s->apicbase & ~0xfff, 0x1000, apic_io_memory);
}
s->timer = qemu_new_timer(vm_clock, apic_timer, s);
return 0;
}
+16 -13
View File
@@ -31,7 +31,7 @@
/*
* TODO:
* - add support for WRITEMASK (GR2F)
* - destination write mask support not complete (bits 5..7)
* - optimize linear mappings
* - optimize bitblt functions
*/
@@ -737,7 +737,8 @@ static int cirrus_bitblt_cputovideo(CirrusVGAState * s)
else
s->cirrus_blt_srcpitch = ((w + 7) >> 3);
} else {
s->cirrus_blt_srcpitch = s->cirrus_blt_width;
/* always align input size to 32 bits */
s->cirrus_blt_srcpitch = (s->cirrus_blt_width + 3) & ~3;
}
s->cirrus_srccounter = s->cirrus_blt_srcpitch * s->cirrus_blt_height;
}
@@ -789,7 +790,7 @@ static void cirrus_bitblt_start(CirrusVGAState * s)
blt_rop = s->gr[0x32];
#ifdef DEBUG_BITBLT
printf("rop=0x%02x mode=0x%02x modeext=0x%02x w=%d h=%d dpitch=%d spicth=%d daddr=0x%08x saddr=0x%08x writemask=0x%02x\n",
printf("rop=0x%02x mode=0x%02x modeext=0x%02x w=%d h=%d dpitch=%d spitch=%d daddr=0x%08x saddr=0x%08x writemask=0x%02x\n",
blt_rop,
s->cirrus_blt_mode,
s->cirrus_blt_modeext,
@@ -799,7 +800,7 @@ static void cirrus_bitblt_start(CirrusVGAState * s)
s->cirrus_blt_srcpitch,
s->cirrus_blt_dstaddr,
s->cirrus_blt_srcaddr,
s->sr[0x2f]);
s->gr[0x2f]);
#endif
switch (s->cirrus_blt_mode & CIRRUS_BLTMODE_PIXELWIDTHMASK) {
@@ -1041,10 +1042,10 @@ static void cirrus_update_bank_ptr(CirrusVGAState * s, unsigned bank_index)
else
offset <<= 12;
if (s->vram_size <= offset)
if (s->real_vram_size <= offset)
limit = 0;
else
limit = s->vram_size - offset;
limit = s->real_vram_size - offset;
if (((s->gr[0x0b] & 0x01) == 0) && (bank_index != 0)) {
if (limit > 0x8000) {
@@ -1212,7 +1213,7 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
#endif
break;
case 0x17: // Configuration Readback and Extended Control
s->sr[reg_index] = reg_value;
s->sr[reg_index] = (s->sr[reg_index] & 0x38) | (reg_value & 0xc7);
cirrus_update_memory_access(s);
break;
default:
@@ -1779,11 +1780,12 @@ static void cirrus_mem_writeb_mode4and5_8bpp(CirrusVGAState * s,
dst = s->vram_ptr + offset;
for (x = 0; x < 8; x++) {
if (val & 0x80) {
*dst++ = s->cirrus_shadow_gr1;
*dst = s->cirrus_shadow_gr1;
} else if (mode == 5) {
*dst++ = s->cirrus_shadow_gr0;
*dst = s->cirrus_shadow_gr0;
}
val <<= 1;
dst++;
}
cpu_physical_memory_set_dirty(s->vram_offset + offset);
cpu_physical_memory_set_dirty(s->vram_offset + offset + 7);
@@ -1801,13 +1803,14 @@ static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,
dst = s->vram_ptr + offset;
for (x = 0; x < 8; x++) {
if (val & 0x80) {
*dst++ = s->cirrus_shadow_gr1;
*dst++ = s->gr[0x11];
*dst = s->cirrus_shadow_gr1;
*(dst + 1) = s->gr[0x11];
} else if (mode == 5) {
*dst++ = s->cirrus_shadow_gr0;
*dst++ = s->gr[0x10];
*dst = s->cirrus_shadow_gr0;
*(dst + 1) = s->gr[0x10];
}
val <<= 1;
dst += 2;
}
cpu_physical_memory_set_dirty(s->vram_offset + offset);
cpu_physical_memory_set_dirty(s->vram_offset + offset + 15);
+36 -15
View File
@@ -47,6 +47,11 @@ glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
int x, y, pattern_y, pattern_pitch, pattern_x;
unsigned int col;
const uint8_t *src1;
#if DEPTH == 24
int skipleft = s->gr[0x2f] & 0x1f;
#else
int skipleft = (s->gr[0x2f] & 0x07) * (DEPTH / 8);
#endif
#if DEPTH == 8
pattern_pitch = 8;
@@ -56,11 +61,11 @@ glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
pattern_pitch = 32;
#endif
pattern_y = s->cirrus_blt_srcaddr & 7;
pattern_x = 0;
pattern_x = skipleft;
for(y = 0; y < bltheight; y++) {
d = dst;
d = dst + skipleft;
src1 = src + pattern_y * pattern_pitch;
for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
for (x = skipleft; x < bltwidth; x += (DEPTH / 8)) {
#if DEPTH == 8
col = src1[pattern_x];
pattern_x = (pattern_x + 1) & 7;
@@ -99,7 +104,13 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
unsigned int col;
unsigned bitmask;
unsigned index;
int srcskipleft = 0;
#if DEPTH == 24
int dstskipleft = s->gr[0x2f] & 0x1f;
int srcskipleft = dstskipleft / 3;
#else
int srcskipleft = s->gr[0x2f] & 0x07;
int dstskipleft = srcskipleft * (DEPTH / 8);
#endif
if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
bits_xor = 0xff;
@@ -112,8 +123,8 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) {
bitmask = 0x80 >> srcskipleft;
bits = *src++ ^ bits_xor;
d = dst;
for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
d = dst + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bitmask & 0xff) == 0) {
bitmask = 0x80;
bits = *src++ ^ bits_xor;
@@ -142,15 +153,16 @@ glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
unsigned bits;
unsigned int col;
unsigned bitmask;
int srcskipleft = 0;
int srcskipleft = s->gr[0x2f] & 0x07;
int dstskipleft = srcskipleft * (DEPTH / 8);
colors[0] = s->cirrus_blt_bgcol;
colors[1] = s->cirrus_blt_fgcol;
for(y = 0; y < bltheight; y++) {
bitmask = 0x80 >> srcskipleft;
bits = *src++;
d = dst;
for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
d = dst + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bitmask & 0xff) == 0) {
bitmask = 0x80;
bits = *src++;
@@ -175,6 +187,13 @@ glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
int x, y, bitpos, pattern_y;
unsigned int bits, bits_xor;
unsigned int col;
#if DEPTH == 24
int dstskipleft = s->gr[0x2f] & 0x1f;
int srcskipleft = dstskipleft / 3;
#else
int srcskipleft = s->gr[0x2f] & 0x07;
int dstskipleft = srcskipleft * (DEPTH / 8);
#endif
if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
bits_xor = 0xff;
@@ -187,9 +206,9 @@ glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) {
bits = src[pattern_y] ^ bits_xor;
bitpos = 7;
d = dst;
for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
bitpos = 7 - srcskipleft;
d = dst + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
if ((bits >> bitpos) & 1) {
PUTPIXEL();
}
@@ -213,6 +232,8 @@ glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
int x, y, bitpos, pattern_y;
unsigned int bits;
unsigned int col;
int srcskipleft = s->gr[0x2f] & 0x07;
int dstskipleft = srcskipleft * (DEPTH / 8);
colors[0] = s->cirrus_blt_bgcol;
colors[1] = s->cirrus_blt_fgcol;
@@ -220,9 +241,9 @@ glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
for(y = 0; y < bltheight; y++) {
bits = src[pattern_y];
bitpos = 7;
d = dst;
for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
bitpos = 7 - srcskipleft;
d = dst + dstskipleft;
for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
col = colors[(bits >> bitpos) & 1];
PUTPIXEL();
d += (DEPTH / 8);
+17 -5
View File
@@ -87,6 +87,9 @@
#define CUDA_TIMER_FREQ (4700000 / 6)
#define CUDA_ADB_POLL_FREQ 50
/* CUDA returns time_t's offset from Jan 1, 1904, not 1970 */
#define RTC_OFFSET 2082844800
typedef struct CUDATimer {
unsigned int latch;
uint16_t counter_value; /* counter value at load time */
@@ -175,16 +178,19 @@ static int64_t get_next_irq_time(CUDATimer *s, int64_t current_time)
/* current counter value */
d = muldiv64(current_time - s->load_time,
CUDA_TIMER_FREQ, ticks_per_sec);
if (d <= s->counter_value) {
if (d < s->counter_value) {
next_time = s->counter_value + 1;
} else {
base = ((d - s->counter_value) / s->latch);
} else
{
base = ((d - s->counter_value + 1) / s->latch);
base = (base * s->latch) + s->counter_value;
next_time = base + s->latch;
}
#if 0
#ifdef DEBUG_CUDA
printf("latch=%d counter=%lld delta_next=%lld\n",
s->latch, d, next_time - d);
#endif
#endif
next_time = muldiv64(next_time, ticks_per_sec, CUDA_TIMER_FREQ) +
s->load_time;
@@ -502,8 +508,9 @@ static void cuda_receive_packet(CUDAState *s,
cuda_send_packet_to_host(s, obuf, 2);
break;
case CUDA_GET_TIME:
case CUDA_SET_TIME:
/* XXX: add time support ? */
ti = time(NULL);
ti = time(NULL) + RTC_OFFSET;
obuf[0] = CUDA_PACKET;
obuf[1] = 0;
obuf[2] = 0;
@@ -513,7 +520,6 @@ static void cuda_receive_packet(CUDAState *s,
obuf[6] = ti;
cuda_send_packet_to_host(s, obuf, 7);
break;
case CUDA_SET_TIME:
case CUDA_FILE_SERVER_FLAG:
case CUDA_SET_DEVICE_LIST:
case CUDA_SET_AUTO_RATE:
@@ -522,6 +528,12 @@ static void cuda_receive_packet(CUDAState *s,
obuf[1] = 0;
cuda_send_packet_to_host(s, obuf, 2);
break;
case CUDA_POWERDOWN:
obuf[0] = CUDA_PACKET;
obuf[1] = 0;
cuda_send_packet_to_host(s, obuf, 2);
qemu_system_shutdown_request();
break;
default:
break;
}
+398
View File
@@ -0,0 +1,398 @@
/*
* QEMU ESP emulation
*
* Copyright (c) 2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
/* debug ESP card */
//#define DEBUG_ESP
#ifdef DEBUG_ESP
#define DPRINTF(fmt, args...) \
do { printf("ESP: " fmt , ##args); } while (0)
#else
#define DPRINTF(fmt, args...)
#endif
#define ESPDMA_REGS 4
#define ESPDMA_MAXADDR (ESPDMA_REGS * 4 - 1)
#define ESP_MAXREG 0x3f
typedef struct ESPState {
BlockDriverState **bd;
uint8_t rregs[ESP_MAXREG];
uint8_t wregs[ESP_MAXREG];
int irq;
uint32_t espdmaregs[ESPDMA_REGS];
uint32_t ti_size;
int ti_dir;
uint8_t ti_buf[65536];
} ESPState;
#define STAT_DO 0x00
#define STAT_DI 0x01
#define STAT_CD 0x02
#define STAT_ST 0x03
#define STAT_MI 0x06
#define STAT_MO 0x07
#define STAT_TC 0x10
#define STAT_IN 0x80
#define INTR_FC 0x08
#define INTR_BS 0x10
#define INTR_DC 0x20
#define SEQ_0 0x0
#define SEQ_CD 0x4
static void handle_satn(ESPState *s)
{
uint8_t buf[32];
uint32_t dmaptr, dmalen;
unsigned int i;
int64_t nb_sectors;
int target;
dmaptr = iommu_translate(s->espdmaregs[1]);
dmalen = s->wregs[0] | (s->wregs[1] << 8);
DPRINTF("Select with ATN at %8.8x len %d\n", dmaptr, dmalen);
DPRINTF("DMA Direction: %c\n", s->espdmaregs[0] & 0x100? 'w': 'r');
cpu_physical_memory_read(dmaptr, buf, dmalen);
for (i = 0; i < dmalen; i++) {
DPRINTF("Command %2.2x\n", buf[i]);
}
s->ti_dir = 0;
s->ti_size = 0;
target = s->wregs[4] & 7;
if (target > 4 || !s->bd[target]) { // No such drive
s->rregs[4] = STAT_IN;
s->rregs[5] = INTR_DC;
s->rregs[6] = SEQ_0;
s->espdmaregs[0] |= 1;
pic_set_irq(s->irq, 1);
return;
}
switch (buf[1]) {
case 0x0:
DPRINTF("Test Unit Ready (len %d)\n", buf[5]);
break;
case 0x12:
DPRINTF("Inquiry (len %d)\n", buf[5]);
memset(s->ti_buf, 0, 36);
if (bdrv_get_type_hint(s->bd[target]) == BDRV_TYPE_CDROM) {
s->ti_buf[0] = 5;
memcpy(&s->ti_buf[16], "QEMU CDROM ", 16);
} else {
s->ti_buf[0] = 0;
memcpy(&s->ti_buf[16], "QEMU HARDDISK ", 16);
}
memcpy(&s->ti_buf[8], "QEMU ", 8);
s->ti_buf[2] = 1;
s->ti_buf[3] = 2;
s->ti_dir = 1;
s->ti_size = 36;
break;
case 0x1a:
DPRINTF("Mode Sense(6) (page %d, len %d)\n", buf[3], buf[5]);
break;
case 0x25:
DPRINTF("Read Capacity (len %d)\n", buf[5]);
memset(s->ti_buf, 0, 8);
bdrv_get_geometry(s->bd[target], &nb_sectors);
s->ti_buf[0] = (nb_sectors >> 24) & 0xff;
s->ti_buf[1] = (nb_sectors >> 16) & 0xff;
s->ti_buf[2] = (nb_sectors >> 8) & 0xff;
s->ti_buf[3] = nb_sectors & 0xff;
s->ti_buf[4] = 0;
s->ti_buf[5] = 0;
s->ti_buf[6] = 2;
s->ti_buf[7] = 0;
s->ti_dir = 1;
s->ti_size = 8;
break;
case 0x28:
{
int64_t offset, len;
offset = (buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6];
len = (buf[8] << 8) | buf[9];
DPRINTF("Read (10) (offset %lld len %lld)\n", offset, len);
bdrv_read(s->bd[target], offset, s->ti_buf, len);
s->ti_dir = 1;
s->ti_size = len * 512;
break;
}
case 0x2a:
{
int64_t offset, len;
offset = (buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6];
len = (buf[8] << 8) | buf[9];
DPRINTF("Write (10) (offset %lld len %lld)\n", offset, len);
bdrv_write(s->bd[target], offset, s->ti_buf, len);
s->ti_dir = 0;
s->ti_size = len * 512;
break;
}
default:
DPRINTF("Unknown command (%2.2x)\n", buf[1]);
break;
}
s->rregs[4] = STAT_IN | STAT_TC | STAT_DI;
s->rregs[5] = INTR_BS | INTR_FC;
s->rregs[6] = SEQ_CD;
s->espdmaregs[0] |= 1;
pic_set_irq(s->irq, 1);
}
static void dma_write(ESPState *s, const uint8_t *buf, uint32_t len)
{
uint32_t dmaptr, dmalen;
dmaptr = iommu_translate(s->espdmaregs[1]);
dmalen = s->wregs[0] | (s->wregs[1] << 8);
DPRINTF("DMA Direction: %c\n", s->espdmaregs[0] & 0x100? 'w': 'r');
cpu_physical_memory_write(dmaptr, buf, len);
s->rregs[4] = STAT_IN | STAT_TC | STAT_ST;
s->rregs[5] = INTR_BS | INTR_FC;
s->rregs[6] = SEQ_CD;
s->espdmaregs[0] |= 1;
pic_set_irq(s->irq, 1);
}
static const uint8_t okbuf[] = {0, 0};
static void handle_ti(ESPState *s)
{
uint32_t dmaptr, dmalen;
unsigned int i;
dmaptr = iommu_translate(s->espdmaregs[1]);
dmalen = s->wregs[0] | (s->wregs[1] << 8);
DPRINTF("Transfer Information at %8.8x len %d\n", dmaptr, dmalen);
DPRINTF("DMA Direction: %c\n", s->espdmaregs[0] & 0x100? 'w': 'r');
for (i = 0; i < s->ti_size; i++) {
dmaptr = iommu_translate(s->espdmaregs[1] + i);
if (s->ti_dir)
cpu_physical_memory_write(dmaptr, &s->ti_buf[i], 1);
else
cpu_physical_memory_read(dmaptr, &s->ti_buf[i], 1);
}
s->rregs[4] = STAT_IN | STAT_TC | STAT_ST;
s->rregs[5] = INTR_BS;
s->rregs[6] = 0;
s->espdmaregs[0] |= 1;
pic_set_irq(s->irq, 1);
}
static void esp_reset(void *opaque)
{
ESPState *s = opaque;
memset(s->rregs, 0, ESP_MAXREG);
s->rregs[0x0e] = 0x4; // Indicate fas100a
memset(s->espdmaregs, 0, ESPDMA_REGS * 4);
}
static uint32_t esp_mem_readb(void *opaque, target_phys_addr_t addr)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr & ESP_MAXREG) >> 2;
switch (saddr) {
default:
break;
}
DPRINTF("read reg[%d]: 0x%2.2x\n", saddr, s->rregs[saddr]);
return s->rregs[saddr];
}
static void esp_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr & ESP_MAXREG) >> 2;
DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr], val);
switch (saddr) {
case 3:
// Command
switch(val & 0x7f) {
case 0:
DPRINTF("NOP (%2.2x)\n", val);
break;
case 1:
DPRINTF("Flush FIFO (%2.2x)\n", val);
s->rregs[6] = 0;
s->rregs[5] = INTR_FC;
break;
case 2:
DPRINTF("Chip reset (%2.2x)\n", val);
esp_reset(s);
break;
case 3:
DPRINTF("Bus reset (%2.2x)\n", val);
break;
case 0x10:
handle_ti(s);
break;
case 0x11:
DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", val);
dma_write(s, okbuf, 2);
break;
case 0x12:
DPRINTF("Message Accepted (%2.2x)\n", val);
dma_write(s, okbuf, 2);
s->rregs[5] = INTR_DC;
s->rregs[6] = 0;
break;
case 0x1a:
DPRINTF("Set ATN (%2.2x)\n", val);
break;
case 0x42:
handle_satn(s);
break;
case 0x43:
DPRINTF("Set ATN & stop (%2.2x)\n", val);
handle_satn(s);
break;
default:
DPRINTF("Unhandled command (%2.2x)\n", val);
break;
}
break;
case 4 ... 7:
case 9 ... 0xf:
break;
default:
break;
}
s->wregs[saddr] = val;
}
static CPUReadMemoryFunc *esp_mem_read[3] = {
esp_mem_readb,
esp_mem_readb,
esp_mem_readb,
};
static CPUWriteMemoryFunc *esp_mem_write[3] = {
esp_mem_writeb,
esp_mem_writeb,
esp_mem_writeb,
};
static uint32_t espdma_mem_readl(void *opaque, target_phys_addr_t addr)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr & ESPDMA_MAXADDR) >> 2;
DPRINTF("read dmareg[%d]: 0x%2.2x\n", saddr, s->espdmaregs[saddr]);
return s->espdmaregs[saddr];
}
static void espdma_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
ESPState *s = opaque;
uint32_t saddr;
saddr = (addr & ESPDMA_MAXADDR) >> 2;
DPRINTF("write dmareg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->espdmaregs[saddr], val);
switch (saddr) {
case 0:
if (!(val & 0x10))
pic_set_irq(s->irq, 0);
break;
default:
break;
}
s->espdmaregs[saddr] = val;
}
static CPUReadMemoryFunc *espdma_mem_read[3] = {
espdma_mem_readl,
espdma_mem_readl,
espdma_mem_readl,
};
static CPUWriteMemoryFunc *espdma_mem_write[3] = {
espdma_mem_writel,
espdma_mem_writel,
espdma_mem_writel,
};
static void esp_save(QEMUFile *f, void *opaque)
{
ESPState *s = opaque;
unsigned int i;
qemu_put_buffer(f, s->rregs, ESP_MAXREG);
qemu_put_buffer(f, s->wregs, ESP_MAXREG);
qemu_put_be32s(f, &s->irq);
for (i = 0; i < ESPDMA_REGS; i++)
qemu_put_be32s(f, &s->espdmaregs[i]);
}
static int esp_load(QEMUFile *f, void *opaque, int version_id)
{
ESPState *s = opaque;
unsigned int i;
if (version_id != 1)
return -EINVAL;
qemu_get_buffer(f, s->rregs, ESP_MAXREG);
qemu_get_buffer(f, s->wregs, ESP_MAXREG);
qemu_get_be32s(f, &s->irq);
for (i = 0; i < ESPDMA_REGS; i++)
qemu_get_be32s(f, &s->espdmaregs[i]);
return 0;
}
void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr)
{
ESPState *s;
int esp_io_memory, espdma_io_memory;
s = qemu_mallocz(sizeof(ESPState));
if (!s)
return;
s->bd = bd;
s->irq = irq;
esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s);
cpu_register_physical_memory(espaddr, ESP_MAXREG*4, esp_io_memory);
espdma_io_memory = cpu_register_io_memory(0, espdma_mem_read, espdma_mem_write, s);
cpu_register_physical_memory(espdaddr, 16, espdma_io_memory);
esp_reset(s);
register_savevm("esp", espaddr, 1, esp_save, esp_load, s);
qemu_register_reset(esp_reset, s);
}
+48 -10
View File
@@ -21,6 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
* The controller is used in Sun4m systems in a slightly different
* way. There are changes in DOR register and DMA is not available.
*/
#include "vl.h"
/********************************************************/
@@ -404,6 +408,12 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg)
uint32_t retval;
switch (reg & 0x07) {
#ifdef TARGET_SPARC
case 0x00:
// Identify to Linux as S82078B
retval = fdctrl_read_statusB(fdctrl);
break;
#endif
case 0x01:
retval = fdctrl_read_statusB(fdctrl);
break;
@@ -455,6 +465,29 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value)
}
}
static uint32_t fdctrl_read_mem (void *opaque, target_phys_addr_t reg)
{
return fdctrl_read(opaque, reg);
}
static void fdctrl_write_mem (void *opaque,
target_phys_addr_t reg, uint32_t value)
{
fdctrl_write(opaque, reg, value);
}
static CPUReadMemoryFunc *fdctrl_mem_read[3] = {
fdctrl_read_mem,
fdctrl_read_mem,
fdctrl_read_mem,
};
static CPUWriteMemoryFunc *fdctrl_mem_write[3] = {
fdctrl_write_mem,
fdctrl_write_mem,
fdctrl_write_mem,
};
static void fd_change_cb (void *opaque)
{
fdrive_t *drv = opaque;
@@ -473,7 +506,7 @@ fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
BlockDriverState **fds)
{
fdctrl_t *fdctrl;
// int io_mem;
int io_mem;
int i;
FLOPPY_DPRINTF("init controller\n");
@@ -504,11 +537,8 @@ fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
fdctrl_reset(fdctrl, 0);
fdctrl->state = FD_CTRL_ACTIVE;
if (mem_mapped) {
FLOPPY_ERROR("memory mapped floppy not supported by now !\n");
#if 0
io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write);
cpu_register_physical_memory(base, 0x08, io_mem);
#endif
io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write, fdctrl);
cpu_register_physical_memory(io_base, 0x08, io_mem);
} else {
register_ioport_read(io_base + 0x01, 5, 1, &fdctrl_read, fdctrl);
register_ioport_read(io_base + 0x07, 1, 1, &fdctrl_read, fdctrl);
@@ -538,6 +568,14 @@ static void fdctrl_reset_irq (fdctrl_t *fdctrl)
static void fdctrl_raise_irq (fdctrl_t *fdctrl, uint8_t status)
{
#ifdef TARGET_SPARC
// Sparc mutation
if (!fdctrl->dma_en) {
fdctrl->state &= ~FD_CTRL_BUSY;
fdctrl->int_status = status;
return;
}
#endif
if (~(fdctrl->state & FD_CTRL_INTR)) {
pic_set_irq(fdctrl->irq_lvl, 1);
fdctrl->state |= FD_CTRL_INTR;
@@ -941,11 +979,11 @@ static int fdctrl_transfer_handler (void *opaque, int nchan,
len = dma_len - fdctrl->data_pos;
if (len + rel_pos > FD_SECTOR_LEN)
len = FD_SECTOR_LEN - rel_pos;
FLOPPY_DPRINTF("copy %d bytes (%d %d %d) %d pos %d %02x %02x "
"(%d-0x%08x 0x%08x)\n", len, size, fdctrl->data_pos,
FLOPPY_DPRINTF("copy %d bytes (%d %d %d) %d pos %d %02x "
"(%d-0x%08x 0x%08x)\n", len, dma_len, fdctrl->data_pos,
fdctrl->data_len, fdctrl->cur_drv, cur_drv->head,
cur_drv->track, cur_drv->sect, fd_sector(cur_drv),
fd_sector(cur_drv) * 512, addr);
fd_sector(cur_drv) * 512);
if (fdctrl->data_dir != FD_DIR_WRITE ||
len < FD_SECTOR_LEN || rel_pos != 0) {
/* READ & SCAN commands and realign to a sector for WRITE */
@@ -1006,7 +1044,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan,
FLOPPY_DPRINTF("seek to next sector (%d %02x %02x => %d) (%d)\n",
cur_drv->head, cur_drv->track, cur_drv->sect,
fd_sector(cur_drv),
fdctrl->data_pos - size);
fdctrl->data_pos - len);
/* XXX: cur_drv->sect >= cur_drv->last_sect should be an
error in fact */
if (cur_drv->sect >= cur_drv->last_sect ||
+9
View File
@@ -197,6 +197,15 @@ int cpu_get_pic_interrupt(CPUState *env)
{
int irq, irq2, intno;
#ifdef TARGET_X86_64
intno = apic_get_interrupt(env);
if (intno >= 0) {
/* set irq request if a PIC irq is still pending */
/* XXX: improve that */
pic_update_irq();
return intno;
}
#endif
/* read the irq from the PIC */
irq = pic_get_irq(&pics[0]);
+48 -16
View File
@@ -1570,6 +1570,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
}
break;
case WIN_STANDBYNOW1:
case WIN_IDLEIMMEDIATE:
s->status = READY_STAT;
ide_set_irq(s);
break;
@@ -1584,6 +1585,11 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
}
ide_set_irq(s);
break;
case WIN_DIAGNOSE:
ide_set_signature(s);
s->status = 0x00; /* NOTE: READY is _not_ set */
s->error = 0x01;
break;
case WIN_SRST:
if (!s->is_cdrom)
goto abort_cmd;
@@ -1826,37 +1832,45 @@ struct partition {
uint32_t nr_sects; /* nr of sectors in partition */
} __attribute__((packed));
/* try to guess the IDE geometry from the MSDOS partition table */
static void ide_guess_geometry(IDEState *s)
/* try to guess the disk logical geometry from the MSDOS partition table. Return 0 if OK, -1 if could not guess */
static int guess_disk_lchs(IDEState *s,
int *pcylinders, int *pheads, int *psectors)
{
uint8_t buf[512];
int ret, i;
int ret, i, heads, sectors, cylinders;
struct partition *p;
uint32_t nr_sects;
if (s->cylinders != 0)
return;
ret = bdrv_read(s->bs, 0, buf, 1);
if (ret < 0)
return;
return -1;
/* test msdos magic */
if (buf[510] != 0x55 || buf[511] != 0xaa)
return;
return -1;
for(i = 0; i < 4; i++) {
p = ((struct partition *)(buf + 0x1be)) + i;
nr_sects = le32_to_cpu(p->nr_sects);
if (nr_sects && p->end_head) {
/* We make the assumption that the partition terminates on
a cylinder boundary */
s->heads = p->end_head + 1;
s->sectors = p->end_sector & 63;
s->cylinders = s->nb_sectors / (s->heads * s->sectors);
heads = p->end_head + 1;
sectors = p->end_sector & 63;
if (sectors == 0)
continue;
cylinders = s->nb_sectors / (heads * sectors);
if (cylinders < 1 || cylinders > 16383)
continue;
*pheads = heads;
*psectors = sectors;
*pcylinders = cylinders;
#if 0
printf("guessed partition: CHS=%d %d %d\n",
s->cylinders, s->heads, s->sectors);
printf("guessed geometry: LCHS=%d %d %d\n",
cylinders, heads, sectors);
#endif
return 0;
}
}
return -1;
}
static void ide_init2(IDEState *ide_state, int irq,
@@ -1864,7 +1878,7 @@ static void ide_init2(IDEState *ide_state, int irq,
{
IDEState *s;
static int drive_serial = 1;
int i, cylinders, heads, secs;
int i, cylinders, heads, secs, translation;
int64_t nb_sectors;
for(i = 0; i < 2; i++) {
@@ -1883,9 +1897,27 @@ static void ide_init2(IDEState *ide_state, int irq,
s->heads = heads;
s->sectors = secs;
} else {
ide_guess_geometry(s);
if (s->cylinders == 0) {
/* if no geometry, use a LBA compatible one */
if (guess_disk_lchs(s, &cylinders, &heads, &secs) == 0) {
if (heads > 16) {
/* if heads > 16, it means that a BIOS LBA
translation was active, so the default
hardware geometry is OK */
goto default_geometry;
} else {
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
/* disable any translation to be in sync with
the logical geometry */
translation = bdrv_get_translation_hint(s->bs);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_set_translation_hint(s->bs,
BIOS_ATA_TRANSLATION_NONE);
}
}
} else {
default_geometry:
/* if no geometry, use a standard physical disk geometry */
cylinders = nb_sectors / (16 * 63);
if (cylinders > 16383)
cylinders = 16383;
+64 -75
View File
@@ -1,7 +1,7 @@
/*
* QEMU SPARC iommu emulation
*
* Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,30 +26,14 @@
/* debug iommu */
//#define DEBUG_IOMMU
/* The IOMMU registers occupy three pages in IO space. */
struct iommu_regs {
/* First page */
volatile unsigned long control; /* IOMMU control */
volatile unsigned long base; /* Physical base of iopte page table */
volatile unsigned long _unused1[3];
volatile unsigned long tlbflush; /* write only */
volatile unsigned long pageflush; /* write only */
volatile unsigned long _unused2[1017];
/* Second page */
volatile unsigned long afsr; /* Async-fault status register */
volatile unsigned long afar; /* Async-fault physical address */
volatile unsigned long _unused3[2];
volatile unsigned long sbuscfg0; /* SBUS configuration registers, per-slot */
volatile unsigned long sbuscfg1;
volatile unsigned long sbuscfg2;
volatile unsigned long sbuscfg3;
volatile unsigned long mfsr; /* Memory-fault status register */
volatile unsigned long mfar; /* Memory-fault physical address */
volatile unsigned long _unused4[1014];
/* Third page */
volatile unsigned long mid; /* IOMMU module-id */
};
#ifdef DEBUG_IOMMU
#define DPRINTF(fmt, args...) \
do { printf("IOMMU: " fmt , ##args); } while (0)
#else
#define DPRINTF(fmt, args...)
#endif
#define IOMMU_NREGS (3*4096)
#define IOMMU_CTRL_IMPL 0xf0000000 /* Implementation */
#define IOMMU_CTRL_VERS 0x0f000000 /* Version */
#define IOMMU_CTRL_RNGE 0x0000001c /* Mapping RANGE */
@@ -63,43 +47,6 @@ struct iommu_regs {
#define IOMMU_RNGE_2GB 0x0000001c /* 0x80000000 -> 0xffffffff */
#define IOMMU_CTRL_ENAB 0x00000001 /* IOMMU Enable */
#define IOMMU_AFSR_ERR 0x80000000 /* LE, TO, or BE asserted */
#define IOMMU_AFSR_LE 0x40000000 /* SBUS reports error after transaction */
#define IOMMU_AFSR_TO 0x20000000 /* Write access took more than 12.8 us. */
#define IOMMU_AFSR_BE 0x10000000 /* Write access received error acknowledge */
#define IOMMU_AFSR_SIZE 0x0e000000 /* Size of transaction causing error */
#define IOMMU_AFSR_S 0x01000000 /* Sparc was in supervisor mode */
#define IOMMU_AFSR_RESV 0x00f00000 /* Reserver, forced to 0x8 by hardware */
#define IOMMU_AFSR_ME 0x00080000 /* Multiple errors occurred */
#define IOMMU_AFSR_RD 0x00040000 /* A read operation was in progress */
#define IOMMU_AFSR_FAV 0x00020000 /* IOMMU afar has valid contents */
#define IOMMU_SBCFG_SAB30 0x00010000 /* Phys-address bit 30 when bypass enabled */
#define IOMMU_SBCFG_BA16 0x00000004 /* Slave supports 16 byte bursts */
#define IOMMU_SBCFG_BA8 0x00000002 /* Slave supports 8 byte bursts */
#define IOMMU_SBCFG_BYPASS 0x00000001 /* Bypass IOMMU, treat all addresses
produced by this device as pure
physical. */
#define IOMMU_MFSR_ERR 0x80000000 /* One or more of PERR1 or PERR0 */
#define IOMMU_MFSR_S 0x01000000 /* Sparc was in supervisor mode */
#define IOMMU_MFSR_CPU 0x00800000 /* CPU transaction caused parity error */
#define IOMMU_MFSR_ME 0x00080000 /* Multiple parity errors occurred */
#define IOMMU_MFSR_PERR 0x00006000 /* high bit indicates parity error occurred
on the even word of the access, low bit
indicated odd word caused the parity error */
#define IOMMU_MFSR_BM 0x00001000 /* Error occurred while in boot mode */
#define IOMMU_MFSR_C 0x00000800 /* Address causing error was marked cacheable */
#define IOMMU_MFSR_RTYP 0x000000f0 /* Memory request transaction type */
#define IOMMU_MID_SBAE 0x001f0000 /* SBus arbitration enable */
#define IOMMU_MID_SE 0x00100000 /* Enables SCSI/ETHERNET arbitration */
#define IOMMU_MID_SB3 0x00080000 /* Enable SBUS device 3 arbitration */
#define IOMMU_MID_SB2 0x00040000 /* Enable SBUS device 2 arbitration */
#define IOMMU_MID_SB1 0x00020000 /* Enable SBUS device 1 arbitration */
#define IOMMU_MID_SB0 0x00010000 /* Enable SBUS device 0 arbitration */
#define IOMMU_MID_MID 0x0000000f /* Module-id, hardcoded to 0x8 */
/* The format of an iopte in the page tables */
#define IOPTE_PAGE 0x07ffff00 /* Physical page number (PA[30:12]) */
#define IOPTE_CACHE 0x00000080 /* Cached (in vme IOCACHE or Viking/MXCC) */
@@ -113,12 +60,10 @@ struct iommu_regs {
typedef struct IOMMUState {
uint32_t addr;
uint32_t regs[sizeof(struct iommu_regs)];
uint32_t regs[IOMMU_NREGS];
uint32_t iostart;
} IOMMUState;
static IOMMUState *ps;
static uint32_t iommu_mem_readw(void *opaque, target_phys_addr_t addr)
{
IOMMUState *s = opaque;
@@ -127,6 +72,7 @@ static uint32_t iommu_mem_readw(void *opaque, target_phys_addr_t addr)
saddr = (addr - s->addr) >> 2;
switch (saddr) {
default:
DPRINTF("read reg[%d] = %x\n", saddr, s->regs[saddr]);
return s->regs[saddr];
break;
}
@@ -139,6 +85,7 @@ static void iommu_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
DPRINTF("write reg[%d] = %x\n", saddr, val);
switch (saddr) {
case 0:
switch (val & IOMMU_CTRL_RNGE) {
@@ -168,6 +115,7 @@ static void iommu_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val
s->iostart = 0x80000000;
break;
}
DPRINTF("iostart = %x\n", s->iostart);
/* Fall through */
default:
s->regs[saddr] = val;
@@ -187,32 +135,73 @@ static CPUWriteMemoryFunc *iommu_mem_write[3] = {
iommu_mem_writew,
};
uint32_t iommu_translate(uint32_t addr)
uint32_t iommu_translate_local(void *opaque, uint32_t addr)
{
uint32_t *iopte = (void *)(ps->regs[1] << 4), pa;
IOMMUState *s = opaque;
uint32_t iopte, pa, tmppte;
iopte += ((addr - ps->iostart) >> PAGE_SHIFT);
cpu_physical_memory_rw((uint32_t)iopte, (void *) &pa, 4, 0);
iopte = s->regs[1] << 4;
addr &= ~s->iostart;
iopte += (addr >> (PAGE_SHIFT - 2)) & ~3;
cpu_physical_memory_read(iopte, (void *) &pa, 4);
bswap32s(&pa);
pa = (pa & IOPTE_PAGE) << 4; /* Loose higher bits of 36 */
return pa + (addr & PAGE_MASK);
tmppte = pa;
pa = ((pa & IOPTE_PAGE) << 4) + (addr & PAGE_MASK);
DPRINTF("xlate dva %x => pa %x (iopte[%x] = %x)\n", addr, pa, iopte, tmppte);
return pa;
}
void iommu_init(uint32_t addr)
static void iommu_save(QEMUFile *f, void *opaque)
{
IOMMUState *s = opaque;
int i;
qemu_put_be32s(f, &s->addr);
for (i = 0; i < IOMMU_NREGS; i++)
qemu_put_be32s(f, &s->regs[i]);
qemu_put_be32s(f, &s->iostart);
}
static int iommu_load(QEMUFile *f, void *opaque, int version_id)
{
IOMMUState *s = opaque;
int i;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, &s->addr);
for (i = 0; i < IOMMU_NREGS; i++)
qemu_put_be32s(f, &s->regs[i]);
qemu_get_be32s(f, &s->iostart);
return 0;
}
static void iommu_reset(void *opaque)
{
IOMMUState *s = opaque;
memset(s->regs, 0, IOMMU_NREGS * 4);
s->iostart = 0;
}
void *iommu_init(uint32_t addr)
{
IOMMUState *s;
int iommu_io_memory;
s = qemu_mallocz(sizeof(IOMMUState));
if (!s)
return;
return NULL;
s->addr = addr;
iommu_io_memory = cpu_register_io_memory(0, iommu_mem_read, iommu_mem_write, s);
cpu_register_physical_memory(addr, sizeof(struct iommu_regs),
iommu_io_memory);
cpu_register_physical_memory(addr, IOMMU_NREGS * 4, iommu_io_memory);
ps = s;
register_savevm("iommu", addr, 1, iommu_save, iommu_load, s);
qemu_register_reset(iommu_reset, s);
return s;
}
+118 -117
View File
@@ -1,7 +1,7 @@
/*
* QEMU Lance emulation
*
* Copyright (c) 2003-2004 Fabrice Bellard
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,20 +26,24 @@
/* debug LANCE card */
//#define DEBUG_LANCE
#ifdef DEBUG_LANCE
#define DPRINTF(fmt, args...) \
do { printf("LANCE: " fmt , ##args); } while (0)
#else
#define DPRINTF(fmt, args...)
#endif
#ifndef LANCE_LOG_TX_BUFFERS
#define LANCE_LOG_TX_BUFFERS 4
#define LANCE_LOG_RX_BUFFERS 4
#endif
#define CRC_POLYNOMIAL_BE 0x04c11db7UL /* Ethernet CRC, big endian */
#define CRC_POLYNOMIAL_LE 0xedb88320UL /* Ethernet CRC, little endian */
#define LE_CSR0 0
#define LE_CSR1 1
#define LE_CSR2 2
#define LE_CSR3 3
#define LE_MAXREG (LE_CSR3 + 1)
#define LE_NREGS (LE_CSR3 + 1)
#define LE_MAXREG LE_CSR3
#define LE_RDP 0
#define LE_RAP 1
@@ -147,42 +151,30 @@ struct lance_init_block {
};
#define LEDMA_REGS 4
#if 0
/* Structure to describe the current status of DMA registers on the Sparc */
struct sparc_dma_registers {
uint32_t cond_reg; /* DMA condition register */
uint32_t st_addr; /* Start address of this transfer */
uint32_t cnt; /* How many bytes to transfer */
uint32_t dma_test; /* DMA test register */
};
#endif
typedef struct LEDMAState {
uint32_t addr;
uint32_t regs[LEDMA_REGS];
} LEDMAState;
#define LEDMA_MAXADDR (LEDMA_REGS * 4 - 1)
typedef struct LANCEState {
uint32_t paddr;
NetDriverState *nd;
uint32_t leptr;
uint16_t addr;
uint16_t regs[LE_MAXREG];
uint16_t regs[LE_NREGS];
uint8_t phys[6]; /* mac address */
int irq;
LEDMAState *ledma;
unsigned int rxptr, txptr;
uint32_t ledmaregs[LEDMA_REGS];
} LANCEState;
static unsigned int rxptr, txptr;
static void lance_send(void *opaque);
static void lance_reset(LANCEState *s)
static void lance_reset(void *opaque)
{
LANCEState *s = opaque;
memcpy(s->phys, s->nd->macaddr, 6);
rxptr = 0;
txptr = 0;
s->rxptr = 0;
s->txptr = 0;
memset(s->regs, 0, LE_NREGS * 2);
s->regs[LE_CSR0] = LE_C0_STOP;
memset(s->ledmaregs, 0, LEDMA_REGS * 4);
}
static uint32_t lance_mem_readw(void *opaque, target_phys_addr_t addr)
@@ -190,13 +182,16 @@ static uint32_t lance_mem_readw(void *opaque, target_phys_addr_t addr)
LANCEState *s = opaque;
uint32_t saddr;
saddr = addr - s->paddr;
saddr = addr & LE_MAXREG;
switch (saddr >> 1) {
case LE_RDP:
DPRINTF("read dreg[%d] = %4.4x\n", s->addr, s->regs[s->addr]);
return s->regs[s->addr];
case LE_RAP:
DPRINTF("read areg = %4.4x\n", s->addr);
return s->addr;
default:
DPRINTF("read unknown(%d)\n", saddr>>1);
break;
}
return 0;
@@ -208,9 +203,10 @@ static void lance_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val
uint32_t saddr;
uint16_t reg;
saddr = addr - s->paddr;
saddr = addr & LE_MAXREG;
switch (saddr >> 1) {
case LE_RDP:
DPRINTF("write dreg[%d] = %4.4x\n", s->addr, val);
switch(s->addr) {
case LE_CSR0:
if (val & LE_C0_STOP) {
@@ -245,12 +241,6 @@ static void lance_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val
}
s->regs[LE_CSR0] = reg;
// trigger bits
//if (val & LE_C0_TDMD)
if ((s->regs[LE_CSR0] & LE_C0_INTR) && (s->regs[LE_CSR0] & LE_C0_INEA))
pic_set_irq(s->irq, 1);
break;
case LE_CSR1:
s->leptr = (s->leptr & 0xffff0000) | (val & 0xffff);
@@ -266,10 +256,12 @@ static void lance_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val
}
break;
case LE_RAP:
if (val < LE_MAXREG)
DPRINTF("write areg = %4.4x\n", val);
if (val < LE_NREGS)
s->addr = val;
break;
default:
DPRINTF("write unknown(%d) = %4.4x\n", saddr>>1, val);
break;
}
lance_send(s);
@@ -292,10 +284,10 @@ static CPUWriteMemoryFunc *lance_mem_write[3] = {
static int lance_can_receive(void *opaque)
{
LANCEState *s = opaque;
void *dmaptr = (void *) (s->leptr + s->ledma->regs[3]);
uint32_t dmaptr = s->leptr + s->ledmaregs[3];
struct lance_init_block *ib;
int i;
uint16_t temp;
uint8_t temp8;
if ((s->regs[LE_CSR0] & LE_C0_STOP) == LE_C0_STOP)
return 0;
@@ -303,18 +295,13 @@ static int lance_can_receive(void *opaque)
ib = (void *) iommu_translate(dmaptr);
for (i = 0; i < RX_RING_SIZE; i++) {
cpu_physical_memory_read(&ib->brx_ring[i].rmd1_bits, (void *) &temp, 1);
temp &= 0xff;
if (temp == (LE_R1_OWN)) {
#ifdef DEBUG_LANCE
fprintf(stderr, "lance: can receive %d\n", RX_BUFF_SIZE);
#endif
cpu_physical_memory_read((uint32_t)&ib->brx_ring[i].rmd1_bits, (void *) &temp8, 1);
if (temp8 == (LE_R1_OWN)) {
DPRINTF("can receive %d\n", RX_BUFF_SIZE);
return RX_BUFF_SIZE;
}
}
#ifdef DEBUG_LANCE
fprintf(stderr, "lance: cannot receive\n");
#endif
DPRINTF("cannot receive\n");
return 0;
}
@@ -323,39 +310,33 @@ static int lance_can_receive(void *opaque)
static void lance_receive(void *opaque, const uint8_t *buf, int size)
{
LANCEState *s = opaque;
void *dmaptr = (void *) (s->leptr + s->ledma->regs[3]);
uint32_t dmaptr = s->leptr + s->ledmaregs[3];
struct lance_init_block *ib;
unsigned int i, old_rxptr, j;
uint16_t temp;
unsigned int i, old_rxptr;
uint16_t temp16;
uint8_t temp8;
DPRINTF("receive size %d\n", size);
if ((s->regs[LE_CSR0] & LE_C0_STOP) == LE_C0_STOP)
return;
ib = (void *) iommu_translate(dmaptr);
old_rxptr = rxptr;
for (i = rxptr; i != ((old_rxptr - 1) & RX_RING_MOD_MASK); i = (i + 1) & RX_RING_MOD_MASK) {
cpu_physical_memory_read(&ib->brx_ring[i].rmd1_bits, (void *) &temp, 1);
if (temp == (LE_R1_OWN)) {
rxptr = (rxptr + 1) & RX_RING_MOD_MASK;
temp = size;
bswap16s(&temp);
cpu_physical_memory_write(&ib->brx_ring[i].mblength, (void *) &temp, 2);
#if 0
cpu_physical_memory_write(&ib->rx_buf[i], buf, size);
#else
for (j = 0; j < size; j++) {
cpu_physical_memory_write(((void *)&ib->rx_buf[i]) + j, &buf[j], 1);
}
#endif
temp = LE_R1_POK;
cpu_physical_memory_write(&ib->brx_ring[i].rmd1_bits, (void *) &temp, 1);
old_rxptr = s->rxptr;
for (i = s->rxptr; i != ((old_rxptr - 1) & RX_RING_MOD_MASK); i = (i + 1) & RX_RING_MOD_MASK) {
cpu_physical_memory_read((uint32_t)&ib->brx_ring[i].rmd1_bits, (void *) &temp8, 1);
if (temp8 == (LE_R1_OWN)) {
s->rxptr = (s->rxptr + 1) & RX_RING_MOD_MASK;
temp16 = size + 4;
bswap16s(&temp16);
cpu_physical_memory_write((uint32_t)&ib->brx_ring[i].mblength, (void *) &temp16, 2);
cpu_physical_memory_write((uint32_t)&ib->rx_buf[i], buf, size);
temp8 = LE_R1_POK;
cpu_physical_memory_write((uint32_t)&ib->brx_ring[i].rmd1_bits, (void *) &temp8, 1);
s->regs[LE_CSR0] |= LE_C0_RINT | LE_C0_INTR;
if ((s->regs[LE_CSR0] & LE_C0_INTR) && (s->regs[LE_CSR0] & LE_C0_INEA))
if (s->regs[LE_CSR0] & LE_C0_INEA)
pic_set_irq(s->irq, 1);
#ifdef DEBUG_LANCE
fprintf(stderr, "lance: got packet, len %d\n", size);
#endif
DPRINTF("got packet, len %d\n", size);
return;
}
}
@@ -364,64 +345,56 @@ static void lance_receive(void *opaque, const uint8_t *buf, int size)
static void lance_send(void *opaque)
{
LANCEState *s = opaque;
void *dmaptr = (void *) (s->leptr + s->ledma->regs[3]);
uint32_t dmaptr = s->leptr + s->ledmaregs[3];
struct lance_init_block *ib;
unsigned int i, old_txptr, j;
uint16_t temp;
unsigned int i, old_txptr;
uint16_t temp16;
uint8_t temp8;
char pkt_buf[PKT_BUF_SZ];
DPRINTF("sending packet? (csr0 %4.4x)\n", s->regs[LE_CSR0]);
if ((s->regs[LE_CSR0] & LE_C0_STOP) == LE_C0_STOP)
return;
ib = (void *) iommu_translate(dmaptr);
old_txptr = txptr;
for (i = txptr; i != ((old_txptr - 1) & TX_RING_MOD_MASK); i = (i + 1) & TX_RING_MOD_MASK) {
cpu_physical_memory_read(&ib->btx_ring[i].tmd1_bits, (void *) &temp, 1);
if (temp == (LE_T1_POK|LE_T1_OWN)) {
cpu_physical_memory_read(&ib->btx_ring[i].length, (void *) &temp, 2);
bswap16s(&temp);
temp = (~temp) + 1;
#if 0
cpu_physical_memory_read(&ib->tx_buf[i], pkt_buf, temp);
#else
for (j = 0; j < temp; j++) {
cpu_physical_memory_read(((void *)&ib->tx_buf[i]) + j, &pkt_buf[j], 1);
}
#endif
#ifdef DEBUG_LANCE
fprintf(stderr, "lance: sending packet, len %d\n", temp);
#endif
qemu_send_packet(s->nd, pkt_buf, temp);
temp = LE_T1_POK;
cpu_physical_memory_write(&ib->btx_ring[i].tmd1_bits, (void *) &temp, 1);
txptr = (txptr + 1) & TX_RING_MOD_MASK;
DPRINTF("sending packet? (dmaptr %8.8x) (ib %p) (btx_ring %p)\n", dmaptr, ib, &ib->btx_ring);
old_txptr = s->txptr;
for (i = s->txptr; i != ((old_txptr - 1) & TX_RING_MOD_MASK); i = (i + 1) & TX_RING_MOD_MASK) {
cpu_physical_memory_read((uint32_t)&ib->btx_ring[i].tmd1_bits, (void *) &temp8, 1);
if (temp8 == (LE_T1_POK|LE_T1_OWN)) {
cpu_physical_memory_read((uint32_t)&ib->btx_ring[i].length, (void *) &temp16, 2);
bswap16s(&temp16);
temp16 = (~temp16) + 1;
cpu_physical_memory_read((uint32_t)&ib->tx_buf[i], pkt_buf, temp16);
DPRINTF("sending packet, len %d\n", temp16);
qemu_send_packet(s->nd, pkt_buf, temp16);
temp8 = LE_T1_POK;
cpu_physical_memory_write((uint32_t)&ib->btx_ring[i].tmd1_bits, (void *) &temp8, 1);
s->txptr = (s->txptr + 1) & TX_RING_MOD_MASK;
s->regs[LE_CSR0] |= LE_C0_TINT | LE_C0_INTR;
}
}
if ((s->regs[LE_CSR0] & LE_C0_INTR) && (s->regs[LE_CSR0] & LE_C0_INEA))
pic_set_irq(s->irq, 1);
}
static uint32_t ledma_mem_readl(void *opaque, target_phys_addr_t addr)
{
LEDMAState *s = opaque;
LANCEState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
if (saddr < LEDMA_REGS)
return s->regs[saddr];
else
return 0;
saddr = (addr & LEDMA_MAXADDR) >> 2;
return s->ledmaregs[saddr];
}
static void ledma_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
LEDMAState *s = opaque;
LANCEState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
if (saddr < LEDMA_REGS)
s->regs[saddr] = val;
saddr = (addr & LEDMA_MAXADDR) >> 2;
s->ledmaregs[saddr] = val;
}
static CPUReadMemoryFunc *ledma_mem_read[3] = {
@@ -436,33 +409,61 @@ static CPUWriteMemoryFunc *ledma_mem_write[3] = {
ledma_mem_writel,
};
static void lance_save(QEMUFile *f, void *opaque)
{
LANCEState *s = opaque;
int i;
qemu_put_be32s(f, &s->leptr);
qemu_put_be16s(f, &s->addr);
for (i = 0; i < LE_NREGS; i ++)
qemu_put_be16s(f, &s->regs[i]);
qemu_put_buffer(f, s->phys, 6);
qemu_put_be32s(f, &s->irq);
for (i = 0; i < LEDMA_REGS; i ++)
qemu_put_be32s(f, &s->ledmaregs[i]);
}
static int lance_load(QEMUFile *f, void *opaque, int version_id)
{
LANCEState *s = opaque;
int i;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, &s->leptr);
qemu_get_be16s(f, &s->addr);
for (i = 0; i < LE_NREGS; i ++)
qemu_get_be16s(f, &s->regs[i]);
qemu_get_buffer(f, s->phys, 6);
qemu_get_be32s(f, &s->irq);
for (i = 0; i < LEDMA_REGS; i ++)
qemu_get_be32s(f, &s->ledmaregs[i]);
return 0;
}
void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr)
{
LANCEState *s;
LEDMAState *led;
int lance_io_memory, ledma_io_memory;
s = qemu_mallocz(sizeof(LANCEState));
if (!s)
return;
s->paddr = leaddr;
s->nd = nd;
s->irq = irq;
lance_io_memory = cpu_register_io_memory(0, lance_mem_read, lance_mem_write, s);
cpu_register_physical_memory(leaddr, 8, lance_io_memory);
cpu_register_physical_memory(leaddr, 4, lance_io_memory);
led = qemu_mallocz(sizeof(LEDMAState));
if (!led)
return;
s->ledma = led;
led->addr = ledaddr;
ledma_io_memory = cpu_register_io_memory(0, ledma_mem_read, ledma_mem_write, led);
ledma_io_memory = cpu_register_io_memory(0, ledma_mem_read, ledma_mem_write, s);
cpu_register_physical_memory(ledaddr, 16, ledma_io_memory);
lance_reset(s);
qemu_add_read_packet(nd, lance_can_receive, lance_receive, s);
register_savevm("lance", leaddr, 1, lance_save, lance_load, s);
qemu_register_reset(lance_reset, s);
}
+63 -98
View File
@@ -32,19 +32,14 @@
#define NVRAM_PRINTF(fmt, args...) do { } while (0)
#endif
#define NVRAM_MAX_MEM 0xfff0
#define NVRAM_MAX_MEM 0x1ff0
#define NVRAM_MAXADDR 0x1fff
struct m48t08_t {
/* Hardware parameters */
int mem_index;
uint32_t mem_base;
uint16_t size;
/* RTC management */
time_t time_offset;
time_t stop_time;
/* NVRAM storage */
uint8_t lock;
uint16_t addr;
uint8_t *buffer;
};
@@ -83,14 +78,13 @@ static void set_time (m48t08_t *NVRAM, struct tm *tm)
}
/* Direct access to NVRAM */
void m48t08_write (m48t08_t *NVRAM, uint32_t val)
void m48t08_write (m48t08_t *NVRAM, uint32_t addr, uint8_t val)
{
struct tm tm;
int tmp;
if (NVRAM->addr > NVRAM_MAX_MEM && NVRAM->addr < 0x2000)
NVRAM_PRINTF("%s: 0x%08x => 0x%08x\n", __func__, NVRAM->addr, val);
switch (NVRAM->addr) {
addr &= NVRAM_MAXADDR;
switch (addr) {
case 0x1FF8:
/* control */
NVRAM->buffer[0x1FF8] = (val & ~0xA0) | 0x90;
@@ -167,25 +161,18 @@ void m48t08_write (m48t08_t *NVRAM, uint32_t val)
}
break;
default:
/* Check lock registers state */
if (NVRAM->addr >= 0x20 && NVRAM->addr <= 0x2F && (NVRAM->lock & 1))
break;
if (NVRAM->addr >= 0x30 && NVRAM->addr <= 0x3F && (NVRAM->lock & 2))
break;
if (NVRAM->addr < NVRAM_MAX_MEM ||
(NVRAM->addr > 0x1FFF && NVRAM->addr < NVRAM->size)) {
NVRAM->buffer[NVRAM->addr] = val & 0xFF;
}
NVRAM->buffer[addr] = val & 0xFF;
break;
}
}
uint32_t m48t08_read (m48t08_t *NVRAM)
uint8_t m48t08_read (m48t08_t *NVRAM, uint32_t addr)
{
struct tm tm;
uint32_t retval = 0xFF;
uint8_t retval = 0xFF;
switch (NVRAM->addr) {
addr &= NVRAM_MAXADDR;
switch (addr) {
case 0x1FF8:
/* control */
goto do_read;
@@ -225,65 +212,36 @@ uint32_t m48t08_read (m48t08_t *NVRAM)
retval = toBCD(tm.tm_year);
break;
default:
/* Check lock registers state */
if (NVRAM->addr >= 0x20 && NVRAM->addr <= 0x2F && (NVRAM->lock & 1))
break;
if (NVRAM->addr >= 0x30 && NVRAM->addr <= 0x3F && (NVRAM->lock & 2))
break;
if (NVRAM->addr < NVRAM_MAX_MEM ||
(NVRAM->addr > 0x1FFF && NVRAM->addr < NVRAM->size)) {
do_read:
retval = NVRAM->buffer[NVRAM->addr];
}
do_read:
retval = NVRAM->buffer[addr];
break;
}
if (NVRAM->addr > NVRAM_MAX_MEM + 1 && NVRAM->addr < 0x2000)
NVRAM_PRINTF("0x%08x <= 0x%08x\n", NVRAM->addr, retval);
return retval;
}
void m48t08_set_addr (m48t08_t *NVRAM, uint32_t addr)
{
NVRAM->addr = addr;
}
void m48t08_toggle_lock (m48t08_t *NVRAM, int lock)
{
NVRAM->lock ^= 1 << lock;
}
static void nvram_writeb (void *opaque, target_phys_addr_t addr, uint32_t value)
{
m48t08_t *NVRAM = opaque;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM)
NVRAM->buffer[addr] = value;
m48t08_write(NVRAM, addr, value);
}
static void nvram_writew (void *opaque, target_phys_addr_t addr, uint32_t value)
{
m48t08_t *NVRAM = opaque;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM) {
NVRAM->buffer[addr] = value >> 8;
NVRAM->buffer[addr + 1] = value;
}
m48t08_write(NVRAM, addr, value);
m48t08_write(NVRAM, addr + 1, value >> 8);
}
static void nvram_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
{
m48t08_t *NVRAM = opaque;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM) {
NVRAM->buffer[addr] = value >> 24;
NVRAM->buffer[addr + 1] = value >> 16;
NVRAM->buffer[addr + 2] = value >> 8;
NVRAM->buffer[addr + 3] = value;
}
m48t08_write(NVRAM, addr, value);
m48t08_write(NVRAM, addr + 1, value >> 8);
m48t08_write(NVRAM, addr + 2, value >> 16);
m48t08_write(NVRAM, addr + 3, value >> 24);
}
static uint32_t nvram_readb (void *opaque, target_phys_addr_t addr)
@@ -291,10 +249,7 @@ static uint32_t nvram_readb (void *opaque, target_phys_addr_t addr)
m48t08_t *NVRAM = opaque;
uint32_t retval = 0;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM)
retval = NVRAM->buffer[addr];
retval = m48t08_read(NVRAM, addr);
return retval;
}
@@ -303,12 +258,8 @@ static uint32_t nvram_readw (void *opaque, target_phys_addr_t addr)
m48t08_t *NVRAM = opaque;
uint32_t retval = 0;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM) {
retval = NVRAM->buffer[addr] << 8;
retval |= NVRAM->buffer[addr + 1];
}
retval = m48t08_read(NVRAM, addr) << 8;
retval |= m48t08_read(NVRAM, addr + 1);
return retval;
}
@@ -317,14 +268,10 @@ static uint32_t nvram_readl (void *opaque, target_phys_addr_t addr)
m48t08_t *NVRAM = opaque;
uint32_t retval = 0;
addr -= NVRAM->mem_base;
if (addr < NVRAM_MAX_MEM) {
retval = NVRAM->buffer[addr] << 24;
retval |= NVRAM->buffer[addr + 1] << 16;
retval |= NVRAM->buffer[addr + 2] << 8;
retval |= NVRAM->buffer[addr + 3];
}
retval = m48t08_read(NVRAM, addr) << 24;
retval |= m48t08_read(NVRAM, addr + 1) << 16;
retval |= m48t08_read(NVRAM, addr + 2) << 8;
retval |= m48t08_read(NVRAM, addr + 3);
return retval;
}
@@ -340,12 +287,42 @@ static CPUReadMemoryFunc *nvram_read[] = {
&nvram_readl,
};
static void nvram_save(QEMUFile *f, void *opaque)
{
m48t08_t *s = opaque;
qemu_put_be32s(f, (uint32_t *)&s->time_offset);
qemu_put_be32s(f, (uint32_t *)&s->stop_time);
qemu_put_buffer(f, s->buffer, 0x2000);
}
static int nvram_load(QEMUFile *f, void *opaque, int version_id)
{
m48t08_t *s = opaque;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, (uint32_t *)&s->time_offset);
qemu_get_be32s(f, (uint32_t *)&s->stop_time);
qemu_get_buffer(f, s->buffer, 0x2000);
return 0;
}
static void m48t08_reset(void *opaque)
{
m48t08_t *s = opaque;
s->time_offset = 0;
s->stop_time = 0;
}
/* Initialisation routine */
m48t08_t *m48t08_init(uint32_t mem_base, uint16_t size, uint8_t *macaddr)
m48t08_t *m48t08_init(uint32_t mem_base, uint16_t size)
{
m48t08_t *s;
int i;
unsigned char tmp = 0;
int mem_index;
s = qemu_mallocz(sizeof(m48t08_t));
if (!s)
@@ -355,25 +332,13 @@ m48t08_t *m48t08_init(uint32_t mem_base, uint16_t size, uint8_t *macaddr)
qemu_free(s);
return NULL;
}
s->size = size;
s->mem_base = mem_base;
s->addr = 0;
if (mem_base != 0) {
s->mem_index = cpu_register_io_memory(0, nvram_read, nvram_write, s);
cpu_register_physical_memory(mem_base, 0x4000, s->mem_index);
mem_index = cpu_register_io_memory(0, nvram_read, nvram_write, s);
cpu_register_physical_memory(mem_base, 0x2000, mem_index);
}
s->lock = 0;
i = 0x1fd8;
s->buffer[i++] = 0x01;
s->buffer[i++] = 0x80; /* Sun4m OBP */
memcpy(&s->buffer[i], macaddr, 6);
/* Calculate checksum */
for (i = 0x1fd8; i < 0x1fe7; i++) {
tmp ^= s->buffer[i];
}
s->buffer[0x1fe7] = tmp;
register_savevm("nvram", mem_base, 1, nvram_save, nvram_load, s);
qemu_register_reset(m48t08_reset, s);
return s;
}
+3 -5
View File
@@ -3,10 +3,8 @@
typedef struct m48t08_t m48t08_t;
void m48t08_write (m48t08_t *NVRAM, uint32_t val);
uint32_t m48t08_read (m48t08_t *NVRAM);
void m48t08_set_addr (m48t08_t *NVRAM, uint32_t addr);
void m48t08_toggle_lock (m48t08_t *NVRAM, int lock);
m48t08_t *m48t08_init(uint32_t mem_base, uint16_t size, uint8_t *macaddr);
void m48t08_write (m48t08_t *NVRAM, uint32_t addr, uint8_t val);
uint8_t m48t08_read (m48t08_t *NVRAM, uint32_t addr);
m48t08_t *m48t08_init(uint32_t mem_base, uint16_t size);
#endif /* !defined (__M48T08_H__) */
+98 -81
View File
@@ -1,5 +1,54 @@
#include "vl.h"
#include "disas.h"
#include "exec-all.h"
struct exec
{
uint32_t a_info; /* Use macros N_MAGIC, etc for access */
uint32_t a_text; /* length of text, in bytes */
uint32_t a_data; /* length of data, in bytes */
uint32_t a_bss; /* length of uninitialized data area, in bytes */
uint32_t a_syms; /* length of symbol table data in file, in bytes */
uint32_t a_entry; /* start address */
uint32_t a_trsize; /* length of relocation info for text, in bytes */
uint32_t a_drsize; /* length of relocation info for data, in bytes */
};
#ifdef BSWAP_NEEDED
static void bswap_ahdr(struct exec *e)
{
bswap32s(&e->a_info);
bswap32s(&e->a_text);
bswap32s(&e->a_data);
bswap32s(&e->a_bss);
bswap32s(&e->a_syms);
bswap32s(&e->a_entry);
bswap32s(&e->a_trsize);
bswap32s(&e->a_drsize);
}
#else
#define bswap_ahdr(x) do { } while (0)
#endif
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#define OMAGIC 0407
#define NMAGIC 0410
#define ZMAGIC 0413
#define QMAGIC 0314
#define _N_HDROFF(x) (1024 - sizeof (struct exec))
#define N_TXTOFF(x) \
(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
(N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? TARGET_PAGE_SIZE : 0)
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
#define _N_SEGMENT_ROUND(x) (((x) + TARGET_PAGE_SIZE - 1) & ~(TARGET_PAGE_SIZE - 1))
#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
#define N_DATADDR(x) \
(N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB
@@ -103,27 +152,27 @@ static void *find_shdr(struct elfhdr *ehdr, int fd, struct elf_shdr *shdr, uint3
return NULL;
}
static int find_strtab(struct elfhdr *ehdr, int fd, struct elf_shdr *shdr, struct elf_shdr *symtab)
static void *find_strtab(struct elfhdr *ehdr, int fd, struct elf_shdr *shdr, struct elf_shdr *symtab)
{
int retval;
retval = lseek(fd, ehdr->e_shoff + sizeof(struct elf_shdr) * symtab->sh_link, SEEK_SET);
if (retval < 0)
return -1;
return NULL;
retval = read(fd, shdr, sizeof(*shdr));
if (retval < 0)
return -1;
return NULL;
bswap_shdr(shdr);
if (shdr->sh_type == SHT_STRTAB)
return qemu_malloc(shdr->sh_size);;
return 0;
return NULL;
}
static int read_program(int fd, struct elf_phdr *phdr, void *dst)
static int read_program(int fd, struct elf_phdr *phdr, void *dst, uint32_t entry)
{
int retval;
retval = lseek(fd, 0x4000, SEEK_SET);
retval = lseek(fd, phdr->p_offset + entry - phdr->p_vaddr, SEEK_SET);
if (retval < 0)
return -1;
return read(fd, dst, phdr->p_filesz);
@@ -178,6 +227,7 @@ static void load_symbols(struct elfhdr *ehdr, int fd)
{
struct elf_shdr symtab, strtab;
struct elf_sym *syms;
struct syminfo *s;
int nsyms, i;
char *str;
@@ -196,20 +246,19 @@ static void load_symbols(struct elfhdr *ehdr, int fd)
goto error_freesyms;
/* Commit */
if (disas_symtab)
qemu_free(disas_symtab); /* XXX Merge with old symbols? */
if (disas_strtab)
qemu_free(disas_strtab);
disas_symtab = syms;
disas_num_syms = nsyms;
disas_strtab = str;
s = qemu_mallocz(sizeof(*s));
s->disas_symtab = syms;
s->disas_num_syms = nsyms;
s->disas_strtab = str;
s->next = syminfos;
syminfos = s;
return;
error_freesyms:
qemu_free(syms);
return;
}
int load_elf(const char * filename, uint8_t *addr)
int load_elf(const char *filename, uint8_t *addr)
{
struct elfhdr ehdr;
struct elf_phdr phdr;
@@ -227,12 +276,13 @@ int load_elf(const char * filename, uint8_t *addr)
if (ehdr.e_ident[0] != 0x7f || ehdr.e_ident[1] != 'E'
|| ehdr.e_ident[2] != 'L' || ehdr.e_ident[3] != 'F'
|| ehdr.e_machine != EM_SPARC)
|| (ehdr.e_machine != EM_SPARC
&& ehdr.e_machine != EM_SPARC32PLUS))
goto error;
if (find_phdr(&ehdr, fd, &phdr, PT_LOAD))
goto error;
retval = read_program(fd, &phdr, addr);
retval = read_program(fd, &phdr, addr, ehdr.e_entry);
if (retval < 0)
goto error;
@@ -245,17 +295,45 @@ int load_elf(const char * filename, uint8_t *addr)
return -1;
}
int load_kernel(const char *filename, uint8_t *addr)
int load_aout(const char *filename, uint8_t *addr)
{
int fd, size;
int fd, size, ret;
struct exec e;
uint32_t magic;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
return -1;
/* load 32 bit code */
size = read(fd, addr, 16 * 1024 * 1024);
size = read(fd, &e, sizeof(e));
if (size < 0)
goto fail;
bswap_ahdr(&e);
magic = N_MAGIC(e);
switch (magic) {
case ZMAGIC:
case QMAGIC:
case OMAGIC:
lseek(fd, N_TXTOFF(e), SEEK_SET);
size = read(fd, addr, e.a_text + e.a_data);
if (size < 0)
goto fail;
break;
case NMAGIC:
lseek(fd, N_TXTOFF(e), SEEK_SET);
size = read(fd, addr, e.a_text);
if (size < 0)
goto fail;
ret = read(fd, addr + N_DATADDR(e), e.a_data);
if (ret < 0)
goto fail;
size += ret;
break;
default:
goto fail;
}
close(fd);
return size;
fail:
@@ -263,64 +341,3 @@ int load_kernel(const char *filename, uint8_t *addr)
return -1;
}
typedef struct MAGICState {
uint32_t addr;
uint32_t saved_addr;
int magic_state;
char saved_kfn[1024];
} MAGICState;
static uint32_t magic_mem_readl(void *opaque, target_phys_addr_t addr)
{
int ret;
MAGICState *s = opaque;
if (s->magic_state == 0) {
ret = load_elf(s->saved_kfn, (uint8_t *)s->saved_addr);
if (ret < 0)
ret = load_kernel(s->saved_kfn, (uint8_t *)s->saved_addr);
if (ret < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
s->saved_kfn);
}
s->magic_state = 1; /* No more magic */
tb_flush();
return bswap32(ret);
}
return 0;
}
static void magic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
}
static CPUReadMemoryFunc *magic_mem_read[3] = {
magic_mem_readl,
magic_mem_readl,
magic_mem_readl,
};
static CPUWriteMemoryFunc *magic_mem_write[3] = {
magic_mem_writel,
magic_mem_writel,
magic_mem_writel,
};
void magic_init(const char *kfn, int kloadaddr, uint32_t addr)
{
int magic_io_memory;
MAGICState *s;
s = qemu_mallocz(sizeof(MAGICState));
if (!s)
return;
strcpy(s->saved_kfn, kfn);
s->saved_addr = kloadaddr;
s->magic_state = 0;
s->addr = addr;
magic_io_memory = cpu_register_io_memory(0, magic_mem_read, magic_mem_write, s);
cpu_register_physical_memory(addr, 4, magic_io_memory);
}
+10 -2
View File
@@ -246,7 +246,7 @@ static void ne2000_receive(void *opaque, const uint8_t *buf, int size)
static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
NE2000State *s = opaque;
int offset, page;
int offset, page, index;
addr &= 0xf;
#ifdef DEBUG_NE2000
@@ -264,10 +264,18 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
ne2000_update_irq(s);
}
if (val & E8390_TRANS) {
qemu_send_packet(s->nd, s->mem + (s->tpsr << 8), s->tcnt);
index = (s->tpsr << 8);
/* XXX: next 2 lines are a hack to make netware 3.11 work */
if (index >= NE2000_PMEM_END)
index -= NE2000_PMEM_SIZE;
/* fail safe: check range on the transmitted length */
if (index + s->tcnt <= NE2000_PMEM_END) {
qemu_send_packet(s->nd, s->mem + index, s->tcnt);
}
/* signal end of transfert */
s->tsr = ENTSR_PTX;
s->isr |= ENISR_TX;
s->cmd &= ~E8390_TRANS;
ne2000_update_irq(s);
}
}
+2 -2
View File
@@ -345,7 +345,7 @@ static void openpic_reset (openpic_t *opp)
int i;
opp->glbc = 0x80000000;
/* Initialise controler registers */
/* Initialise controller registers */
opp->frep = ((EXT_IRQ - 1) << 16) | ((MAX_CPU - 1) << 8) | VID;
opp->veni = VENI;
opp->spve = 0x000000FF;
@@ -629,7 +629,7 @@ static void openpic_timer_write (void *opaque, uint32_t addr, uint32_t val)
break;
case 0x10: /* TIBC */
if ((opp->timers[idx].ticc & 0x80000000) != 0 &&
(val & 0x800000000) == 0 &&
(val & 0x80000000) == 0 &&
(opp->timers[idx].tibc & 0x80000000) != 0)
opp->timers[idx].ticc &= ~0x80000000;
opp->timers[idx].tibc = val;
+183
View File
@@ -0,0 +1,183 @@
/*
* QEMU Parallel PORT emulation
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
//#define DEBUG_PARALLEL
/*
* These are the definitions for the Printer Status Register
*/
#define PARA_STS_BUSY 0x80 /* Busy complement */
#define PARA_STS_ACK 0x40 /* Acknowledge */
#define PARA_STS_PAPER 0x20 /* Out of paper */
#define PARA_STS_ONLINE 0x10 /* Online */
#define PARA_STS_ERROR 0x08 /* Error complement */
/*
* These are the definitions for the Printer Control Register
*/
#define PARA_CTR_INTEN 0x10 /* IRQ Enable */
#define PARA_CTR_SELECT 0x08 /* Select In complement */
#define PARA_CTR_INIT 0x04 /* Initialize Printer complement */
#define PARA_CTR_AUTOLF 0x02 /* Auto linefeed complement */
#define PARA_CTR_STROBE 0x01 /* Strobe complement */
struct ParallelState {
uint8_t data;
uint8_t status; /* read only register */
uint8_t control;
int irq;
int irq_pending;
CharDriverState *chr;
};
static void parallel_update_irq(ParallelState *s)
{
if (s->irq_pending)
pic_set_irq(s->irq, 1);
else
pic_set_irq(s->irq, 0);
}
static void parallel_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
ParallelState *s = opaque;
addr &= 7;
#ifdef DEBUG_PARALLEL
printf("parallel: write addr=0x%02x val=0x%02x\n", addr, val);
#endif
switch(addr) {
case 0:
s->data = val;
parallel_update_irq(s);
break;
case 2:
if ((val & PARA_CTR_INIT) == 0 ) {
s->status = PARA_STS_BUSY;
s->status |= PARA_STS_ACK;
s->status |= PARA_STS_ONLINE;
s->status |= PARA_STS_ERROR;
}
else if (val & PARA_CTR_SELECT) {
if (val & PARA_CTR_STROBE) {
s->status &= ~PARA_STS_BUSY;
if ((s->control & PARA_CTR_STROBE) == 0)
qemu_chr_write(s->chr, &s->data, 1);
} else {
if (s->control & PARA_CTR_INTEN) {
s->irq_pending = 1;
}
}
}
parallel_update_irq(s);
s->control = val;
break;
}
}
static uint32_t parallel_ioport_read(void *opaque, uint32_t addr)
{
ParallelState *s = opaque;
uint32_t ret = 0xff;
addr &= 7;
switch(addr) {
case 0:
ret = s->data;
break;
case 1:
ret = s->status;
s->irq_pending = 0;
if ((s->status & PARA_STS_BUSY) == 0 && (s->control & PARA_CTR_STROBE) == 0) {
/* XXX Fixme: wait 5 microseconds */
if (s->status & PARA_STS_ACK)
s->status &= ~PARA_STS_ACK;
else {
/* XXX Fixme: wait 5 microseconds */
s->status |= PARA_STS_ACK;
s->status |= PARA_STS_BUSY;
}
}
parallel_update_irq(s);
break;
case 2:
ret = s->control;
break;
}
#ifdef DEBUG_PARALLEL
printf("parallel: read addr=0x%02x val=0x%02x\n", addr, ret);
#endif
return ret;
}
static int parallel_can_receive(ParallelState *s)
{
return 0;
}
static void parallel_receive_byte(ParallelState *s, int ch)
{
}
static int parallel_can_receive1(void *opaque)
{
ParallelState *s = opaque;
return parallel_can_receive(s);
}
static void parallel_receive1(void *opaque, const uint8_t *buf, int size)
{
ParallelState *s = opaque;
parallel_receive_byte(s, buf[0]);
}
static void parallel_event(void *opaque, int event)
{
}
/* If fd is zero, it means that the parallel device uses the console */
ParallelState *parallel_init(int base, int irq, CharDriverState *chr)
{
ParallelState *s;
s = qemu_mallocz(sizeof(ParallelState));
if (!s)
return NULL;
s->irq = irq;
s->data = 0;
s->status = PARA_STS_BUSY;
s->status |= PARA_STS_ACK;
s->status |= PARA_STS_ONLINE;
s->status |= PARA_STS_ERROR;
s->control = PARA_CTR_SELECT;
s->control |= PARA_CTR_INIT;
register_ioport_write(base, 8, 1, parallel_ioport_write, s);
register_ioport_read(base, 8, 1, parallel_ioport_read, s);
s->chr = chr;
qemu_chr_add_read_handler(chr, parallel_can_receive1, parallel_receive1, s);
qemu_chr_add_event_handler(chr, parallel_event);
return s;
}
+27 -12
View File
@@ -217,19 +217,23 @@ static void cmos_init(int ram_size, int boot_device, BlockDriverState **hd_table
val = 0;
for (i = 0; i < 4; i++) {
if (hd_table[i]) {
int cylinders, heads, sectors;
uint8_t translation;
/* NOTE: bdrv_get_geometry_hint() returns the geometry
that the hard disk returns. It is always such that: 1 <=
sects <= 63, 1 <= heads <= 16, 1 <= cylinders <=
16383. The BIOS geometry can be different. */
bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, &sectors);
if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
/* No translation. */
translation = 0;
int cylinders, heads, sectors, translation;
/* NOTE: bdrv_get_geometry_hint() returns the physical
geometry. It is always such that: 1 <= sects <= 63, 1
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS
geometry can be different if a translation is done. */
translation = bdrv_get_translation_hint(hd_table[i]);
if (translation == BIOS_ATA_TRANSLATION_AUTO) {
bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, &sectors);
if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
/* No translation. */
translation = 0;
} else {
/* LBA translation. */
translation = 1;
}
} else {
/* LBA translation. */
translation = 1;
translation--;
}
val |= translation << (i * 2);
}
@@ -372,6 +376,9 @@ static int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
static int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
/* PC hardware initialisation */
void pc_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
@@ -523,6 +530,8 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device,
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
if (pci_enabled)
apic_init(cpu_single_env);
pic_init();
pit = pit_init(0x40, 0);
@@ -532,6 +541,12 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device,
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]);
}
}
if (pci_enabled) {
for(i = 0; i < nb_nics; i++) {
pci_ne2000_init(pci_bus, &nd_table[i]);
+11 -1
View File
@@ -494,7 +494,7 @@ PIIX3State *piix3_state;
static inline int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
{
int slot_addend;
slot_addend = (pci_dev->devfn >> 3);
slot_addend = (pci_dev->devfn >> 3) - 1;
return (irq_num + slot_addend) & 3;
}
@@ -694,6 +694,16 @@ PCIBus *pci_prep_init(void)
s = pci_register_bus();
s->set_irq = prep_set_irq;
register_ioport_write(0xcf8, 4, 4, pci_addr_writel, s);
register_ioport_read(0xcf8, 4, 4, pci_addr_readl, s);
register_ioport_write(0xcfc, 4, 1, pci_data_writeb, s);
register_ioport_write(0xcfc, 4, 2, pci_data_writew, s);
register_ioport_write(0xcfc, 4, 4, pci_data_writel, s);
register_ioport_read(0xcfc, 4, 1, pci_data_readb, s);
register_ioport_read(0xcfc, 4, 2, pci_data_readw, s);
register_ioport_read(0xcfc, 4, 4, pci_data_readl, s);
PPC_io_memory = cpu_register_io_memory(0, PPC_PCIIO_read,
PPC_PCIIO_write, s);
cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory);
+1 -2
View File
@@ -539,6 +539,7 @@ static void kbd_write_mouse(KBDState *s, int val)
s->mouse_sample_rate = 100;
s->mouse_resolution = 2;
s->mouse_status = 0;
s->mouse_type = 0;
kbd_queue(s, AUX_ACK, 1);
kbd_queue(s, 0xaa, 1);
kbd_queue(s, s->mouse_type, 1);
@@ -549,7 +550,6 @@ static void kbd_write_mouse(KBDState *s, int val)
break;
case AUX_SET_SAMPLE:
s->mouse_sample_rate = val;
#if 0
/* detect IMPS/2 or IMEX */
switch(s->mouse_detect_state) {
default:
@@ -576,7 +576,6 @@ static void kbd_write_mouse(KBDState *s, int val)
s->mouse_detect_state = 0;
break;
}
#endif
kbd_queue(s, AUX_ACK, 1);
s->mouse_write_cmd = -1;
break;
+1 -1
View File
@@ -207,7 +207,7 @@ void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
}
ide0_mem_index = pmac_ide_init(&bs_table[0], openpic, 0x13);
ide1_mem_index = pmac_ide_init(&bs_table[2], openpic, 0x13);
ide1_mem_index = pmac_ide_init(&bs_table[2], openpic, 0x14);
/* cuda also initialize ADB */
cuda_mem_index = cuda_init(openpic, 0x19);
+115 -10
View File
@@ -249,6 +249,7 @@ typedef struct sysctrl_t {
uint8_t state;
uint8_t syscontrol;
uint8_t fake_io[2];
int contiguous_map;
} sysctrl_t;
enum {
@@ -328,10 +329,7 @@ static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
break;
case 0x0850:
/* I/O map type register */
if (!(val & 0x01)) {
printf("No support for non-continuous I/O map mode\n");
abort();
}
sysctrl->contiguous_map = val & 0x01;
break;
default:
printf("ERROR: unaffected IO port write: %04lx => %02x\n",
@@ -375,6 +373,9 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
/* Motorola base module extended feature register */
retval = 0x39; /* No USB, CF and PCI bridge. NVRAM present */
break;
case 0x0814:
/* L2 invalidate: don't care */
break;
case 0x0818:
/* Keylock */
retval = 0x00;
@@ -391,7 +392,7 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
break;
case 0x0850:
/* I/O map type register */
retval = 0x01;
retval = sysctrl->contiguous_map;
break;
default:
printf("ERROR: unaffected IO port: %04lx read\n", (long)addr);
@@ -402,6 +403,108 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
return retval;
}
static inline target_phys_addr_t prep_IO_address (sysctrl_t *sysctrl,
target_phys_addr_t addr)
{
if (sysctrl->contiguous_map == 0) {
/* 64 KB contiguous space for IOs */
addr &= 0xFFFF;
} else {
/* 8 MB non-contiguous space for IOs */
addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7);
}
return addr;
}
static void PPC_prep_io_writeb (void *opaque, target_phys_addr_t addr,
uint32_t value)
{
sysctrl_t *sysctrl = opaque;
addr = prep_IO_address(sysctrl, addr);
cpu_outb(NULL, addr, value);
}
static uint32_t PPC_prep_io_readb (void *opaque, target_phys_addr_t addr)
{
sysctrl_t *sysctrl = opaque;
uint32_t ret;
addr = prep_IO_address(sysctrl, addr);
ret = cpu_inb(NULL, addr);
return ret;
}
static void PPC_prep_io_writew (void *opaque, target_phys_addr_t addr,
uint32_t value)
{
sysctrl_t *sysctrl = opaque;
addr = prep_IO_address(sysctrl, addr);
#ifdef TARGET_WORDS_BIGENDIAN
value = bswap16(value);
#endif
PPC_IO_DPRINTF("0x%08lx => 0x%08x\n", (long)addr, value);
cpu_outw(NULL, addr, value);
}
static uint32_t PPC_prep_io_readw (void *opaque, target_phys_addr_t addr)
{
sysctrl_t *sysctrl = opaque;
uint32_t ret;
addr = prep_IO_address(sysctrl, addr);
ret = cpu_inw(NULL, addr);
#ifdef TARGET_WORDS_BIGENDIAN
ret = bswap16(ret);
#endif
PPC_IO_DPRINTF("0x%08lx <= 0x%08x\n", (long)addr, ret);
return ret;
}
static void PPC_prep_io_writel (void *opaque, target_phys_addr_t addr,
uint32_t value)
{
sysctrl_t *sysctrl = opaque;
addr = prep_IO_address(sysctrl, addr);
#ifdef TARGET_WORDS_BIGENDIAN
value = bswap32(value);
#endif
PPC_IO_DPRINTF("0x%08lx => 0x%08x\n", (long)addr, value);
cpu_outl(NULL, addr, value);
}
static uint32_t PPC_prep_io_readl (void *opaque, target_phys_addr_t addr)
{
sysctrl_t *sysctrl = opaque;
uint32_t ret;
addr = prep_IO_address(sysctrl, addr);
ret = cpu_inl(NULL, addr);
#ifdef TARGET_WORDS_BIGENDIAN
ret = bswap32(ret);
#endif
PPC_IO_DPRINTF("0x%08lx <= 0x%08x\n", (long)addr, ret);
return ret;
}
CPUWriteMemoryFunc *PPC_prep_io_write[] = {
&PPC_prep_io_writeb,
&PPC_prep_io_writew,
&PPC_prep_io_writel,
};
CPUReadMemoryFunc *PPC_prep_io_read[] = {
&PPC_prep_io_readb,
&PPC_prep_io_readw,
&PPC_prep_io_readl,
};
extern CPUPPCState *global_env;
#define NVRAM_SIZE 0x2000
@@ -472,16 +575,18 @@ void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
initrd_size = 0;
}
/* Register CPU as a 74x/75x */
cpu_ppc_register(cpu_single_env, 0x00080000);
/* Register CPU as a 604 */
cpu_ppc_register(cpu_single_env, 0x00040000);
/* Set time-base frequency to 100 Mhz */
cpu_ppc_tb_init(cpu_single_env, 100UL * 1000UL * 1000UL);
isa_mem_base = 0xc0000000;
pci_bus = pci_prep_init();
/* Register 64 KB of ISA IO space */
PPC_io_memory = cpu_register_io_memory(0, PPC_io_read, PPC_io_write, NULL);
cpu_register_physical_memory(0x80000000, 0x00010000, PPC_io_memory);
// pci_bus = i440fx_init();
/* Register 8 MB of ISA IO space (needed for non-contiguous map) */
PPC_io_memory = cpu_register_io_memory(0, PPC_prep_io_read,
PPC_prep_io_write, sysctrl);
cpu_register_physical_memory(0x80000000, 0x00800000, PPC_io_memory);
/* init basic PC hardware */
vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size,
-268
View File
@@ -1,268 +0,0 @@
/*
* QEMU interrupt controller emulation
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
//#define DEBUG_IRQ_COUNT
/* These registers are used for sending/receiving irqs from/to
* different cpu's.
*/
struct sun4m_intreg_percpu {
unsigned int tbt; /* Intrs pending for this cpu, by PIL. */
/* These next two registers are WRITE-ONLY and are only
* "on bit" sensitive, "off bits" written have NO affect.
*/
unsigned int clear; /* Clear this cpus irqs here. */
unsigned int set; /* Set this cpus irqs here. */
};
/*
* djhr
* Actually the clear and set fields in this struct are misleading..
* according to the SLAVIO manual (and the same applies for the SEC)
* the clear field clears bits in the mask which will ENABLE that IRQ
* the set field sets bits in the mask to DISABLE the IRQ.
*
* Also the undirected_xx address in the SLAVIO is defined as
* RESERVED and write only..
*
* DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
* sun4m machines, for MP the layout makes more sense.
*/
struct sun4m_intreg_master {
unsigned int tbt; /* IRQ's that are pending, see sun4m masks. */
unsigned int irqs; /* Master IRQ bits. */
/* Again, like the above, two these registers are WRITE-ONLY. */
unsigned int clear; /* Clear master IRQ's by setting bits here. */
unsigned int set; /* Set master IRQ's by setting bits here. */
/* This register is both READ and WRITE. */
unsigned int undirected_target; /* Which cpu gets undirected irqs. */
};
#define SUN4M_INT_ENABLE 0x80000000
#define SUN4M_INT_E14 0x00000080
#define SUN4M_INT_E10 0x00080000
#define SUN4M_HARD_INT(x) (0x000000001 << (x))
#define SUN4M_SOFT_INT(x) (0x000010000 << (x))
#define SUN4M_INT_MASKALL 0x80000000 /* mask all interrupts */
#define SUN4M_INT_MODULE_ERR 0x40000000 /* module error */
#define SUN4M_INT_M2S_WRITE 0x20000000 /* write buffer error */
#define SUN4M_INT_ECC 0x10000000 /* ecc memory error */
#define SUN4M_INT_FLOPPY 0x00400000 /* floppy disk */
#define SUN4M_INT_MODULE 0x00200000 /* module interrupt */
#define SUN4M_INT_VIDEO 0x00100000 /* onboard video */
#define SUN4M_INT_REALTIME 0x00080000 /* system timer */
#define SUN4M_INT_SCSI 0x00040000 /* onboard scsi */
#define SUN4M_INT_AUDIO 0x00020000 /* audio/isdn */
#define SUN4M_INT_ETHERNET 0x00010000 /* onboard ethernet */
#define SUN4M_INT_SERIAL 0x00008000 /* serial ports */
#define SUN4M_INT_SBUSBITS 0x00003F80 /* sbus int bits */
#define SUN4M_INT_SBUS(x) (1 << (x+7))
#define SUN4M_INT_VME(x) (1 << (x))
typedef struct SCHEDState {
uint32_t addr, addrg;
uint32_t intreg_pending;
uint32_t intreg_enabled;
uint32_t intregm_pending;
uint32_t intregm_enabled;
} SCHEDState;
static SCHEDState *ps;
#ifdef DEBUG_IRQ_COUNT
static uint64_t irq_count[32];
#endif
static uint32_t intreg_mem_readl(void *opaque, target_phys_addr_t addr)
{
SCHEDState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
switch (saddr) {
case 0:
return s->intreg_pending;
break;
default:
break;
}
return 0;
}
static void intreg_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SCHEDState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
switch (saddr) {
case 0:
s->intreg_pending = val;
break;
case 1: // clear
s->intreg_enabled &= ~val;
break;
case 2: // set
s->intreg_enabled |= val;
break;
default:
break;
}
}
static CPUReadMemoryFunc *intreg_mem_read[3] = {
intreg_mem_readl,
intreg_mem_readl,
intreg_mem_readl,
};
static CPUWriteMemoryFunc *intreg_mem_write[3] = {
intreg_mem_writel,
intreg_mem_writel,
intreg_mem_writel,
};
static uint32_t intregm_mem_readl(void *opaque, target_phys_addr_t addr)
{
SCHEDState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addrg) >> 2;
switch (saddr) {
case 0:
return s->intregm_pending;
break;
case 1:
return s->intregm_enabled;
break;
default:
break;
}
return 0;
}
static void intregm_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SCHEDState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addrg) >> 2;
switch (saddr) {
case 0:
s->intregm_pending = val;
break;
case 1:
s->intregm_enabled = val;
break;
case 2: // clear
s->intregm_enabled &= ~val;
break;
case 3: // set
s->intregm_enabled |= val;
break;
default:
break;
}
}
static CPUReadMemoryFunc *intregm_mem_read[3] = {
intregm_mem_readl,
intregm_mem_readl,
intregm_mem_readl,
};
static CPUWriteMemoryFunc *intregm_mem_write[3] = {
intregm_mem_writel,
intregm_mem_writel,
intregm_mem_writel,
};
void pic_info(void)
{
term_printf("per-cpu: pending 0x%08x, enabled 0x%08x\n", ps->intreg_pending, ps->intreg_enabled);
term_printf("master: pending 0x%08x, enabled 0x%08x\n", ps->intregm_pending, ps->intregm_enabled);
}
void irq_info(void)
{
#ifndef DEBUG_IRQ_COUNT
term_printf("irq statistic code not compiled.\n");
#else
int i;
int64_t count;
term_printf("IRQ statistics:\n");
for (i = 0; i < 32; i++) {
count = irq_count[i];
if (count > 0)
term_printf("%2d: %lld\n", i, count);
}
#endif
}
static const unsigned int intr_to_mask[16] = {
0, 0, 0, 0, 0, 0, SUN4M_INT_ETHERNET, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
void pic_set_irq(int irq, int level)
{
if (irq < 16) {
unsigned int mask = intr_to_mask[irq];
ps->intreg_pending |= 1 << irq;
if (ps->intregm_enabled & mask) {
cpu_single_env->interrupt_index = irq;
cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
}
}
#ifdef DEBUG_IRQ_COUNT
if (level == 1)
irq_count[irq]++;
#endif
}
void sched_init(uint32_t addr, uint32_t addrg)
{
int intreg_io_memory, intregm_io_memory;
SCHEDState *s;
s = qemu_mallocz(sizeof(SCHEDState));
if (!s)
return;
s->addr = addr;
s->addrg = addrg;
intreg_io_memory = cpu_register_io_memory(0, intreg_mem_read, intreg_mem_write, s);
cpu_register_physical_memory(addr, 3, intreg_io_memory);
intregm_io_memory = cpu_register_io_memory(0, intregm_mem_read, intregm_mem_write, s);
cpu_register_physical_memory(addrg, 5, intregm_io_memory);
ps = s;
}
+335
View File
@@ -0,0 +1,335 @@
/*
* QEMU Sparc SLAVIO interrupt controller emulation
*
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
//#define DEBUG_IRQ_COUNT
//#define DEBUG_IRQ
#ifdef DEBUG_IRQ
#define DPRINTF(fmt, args...) \
do { printf("IRQ: " fmt , ##args); } while (0)
#else
#define DPRINTF(fmt, args...)
#endif
/*
* Registers of interrupt controller in sun4m.
*
* This is the interrupt controller part of chip STP2001 (Slave I/O), also
* produced as NCR89C105. See
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
*
* There is a system master controller and one for each cpu.
*
*/
#define MAX_CPUS 16
typedef struct SLAVIO_INTCTLState {
uint32_t intreg_pending[MAX_CPUS];
uint32_t intregm_pending;
uint32_t intregm_disabled;
uint32_t target_cpu;
#ifdef DEBUG_IRQ_COUNT
uint64_t irq_count[32];
#endif
} SLAVIO_INTCTLState;
#define INTCTL_MAXADDR 0xf
#define INTCTLM_MAXADDR 0xf
static void slavio_check_interrupts(void *opaque);
// per-cpu interrupt controller
static uint32_t slavio_intctl_mem_readl(void *opaque, target_phys_addr_t addr)
{
SLAVIO_INTCTLState *s = opaque;
uint32_t saddr;
int cpu;
cpu = (addr & (MAX_CPUS - 1) * TARGET_PAGE_SIZE) >> 12;
saddr = (addr & INTCTL_MAXADDR) >> 2;
switch (saddr) {
case 0:
return s->intreg_pending[cpu];
default:
break;
}
return 0;
}
static void slavio_intctl_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SLAVIO_INTCTLState *s = opaque;
uint32_t saddr;
int cpu;
cpu = (addr & (MAX_CPUS - 1) * TARGET_PAGE_SIZE) >> 12;
saddr = (addr & INTCTL_MAXADDR) >> 2;
switch (saddr) {
case 1: // clear pending softints
if (val & 0x4000)
val |= 80000000;
val &= 0xfffe0000;
s->intreg_pending[cpu] &= ~val;
DPRINTF("Cleared cpu %d irq mask %x, curmask %x\n", cpu, val, s->intreg_pending[cpu]);
break;
case 2: // set softint
val &= 0xfffe0000;
s->intreg_pending[cpu] |= val;
DPRINTF("Set cpu %d irq mask %x, curmask %x\n", cpu, val, s->intreg_pending[cpu]);
break;
default:
break;
}
}
static CPUReadMemoryFunc *slavio_intctl_mem_read[3] = {
slavio_intctl_mem_readl,
slavio_intctl_mem_readl,
slavio_intctl_mem_readl,
};
static CPUWriteMemoryFunc *slavio_intctl_mem_write[3] = {
slavio_intctl_mem_writel,
slavio_intctl_mem_writel,
slavio_intctl_mem_writel,
};
// master system interrupt controller
static uint32_t slavio_intctlm_mem_readl(void *opaque, target_phys_addr_t addr)
{
SLAVIO_INTCTLState *s = opaque;
uint32_t saddr;
saddr = (addr & INTCTLM_MAXADDR) >> 2;
switch (saddr) {
case 0:
return s->intregm_pending & 0x7fffffff;
case 1:
return s->intregm_disabled;
case 4:
return s->target_cpu;
default:
break;
}
return 0;
}
static void slavio_intctlm_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SLAVIO_INTCTLState *s = opaque;
uint32_t saddr;
saddr = (addr & INTCTLM_MAXADDR) >> 2;
switch (saddr) {
case 2: // clear (enable)
// Force clear unused bits
val &= ~0x7fb2007f;
s->intregm_disabled &= ~val;
DPRINTF("Enabled master irq mask %x, curmask %x\n", val, s->intregm_disabled);
slavio_check_interrupts(s);
break;
case 3: // set (disable, clear pending)
// Force clear unused bits
val &= ~0x7fb2007f;
s->intregm_disabled |= val;
s->intregm_pending &= ~val;
DPRINTF("Disabled master irq mask %x, curmask %x\n", val, s->intregm_disabled);
break;
case 4:
s->target_cpu = val & (MAX_CPUS - 1);
DPRINTF("Set master irq cpu %d\n", s->target_cpu);
break;
default:
break;
}
}
static CPUReadMemoryFunc *slavio_intctlm_mem_read[3] = {
slavio_intctlm_mem_readl,
slavio_intctlm_mem_readl,
slavio_intctlm_mem_readl,
};
static CPUWriteMemoryFunc *slavio_intctlm_mem_write[3] = {
slavio_intctlm_mem_writel,
slavio_intctlm_mem_writel,
slavio_intctlm_mem_writel,
};
void slavio_pic_info(void *opaque)
{
SLAVIO_INTCTLState *s = opaque;
int i;
for (i = 0; i < MAX_CPUS; i++) {
term_printf("per-cpu %d: pending 0x%08x\n", i, s->intreg_pending[i]);
}
term_printf("master: pending 0x%08x, disabled 0x%08x\n", s->intregm_pending, s->intregm_disabled);
}
void slavio_irq_info(void *opaque)
{
#ifndef DEBUG_IRQ_COUNT
term_printf("irq statistic code not compiled.\n");
#else
SLAVIO_INTCTLState *s = opaque;
int i;
int64_t count;
term_printf("IRQ statistics:\n");
for (i = 0; i < 32; i++) {
count = s->irq_count[i];
if (count > 0)
term_printf("%2d: %lld\n", i, count);
}
#endif
}
static const uint32_t intbit_to_level[32] = {
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 0, 0,
};
static void slavio_check_interrupts(void *opaque)
{
SLAVIO_INTCTLState *s = opaque;
uint32_t pending = s->intregm_pending;
unsigned int i, max = 0;
pending &= ~s->intregm_disabled;
if (pending && !(s->intregm_disabled & 0x80000000)) {
for (i = 0; i < 32; i++) {
if (pending & (1 << i)) {
if (max < intbit_to_level[i])
max = intbit_to_level[i];
}
}
if (cpu_single_env->interrupt_index == 0) {
DPRINTF("Triggered pil %d\n", max);
#ifdef DEBUG_IRQ_COUNT
s->irq_count[max]++;
#endif
cpu_single_env->interrupt_index = TT_EXTINT | max;
cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
}
else
DPRINTF("Not triggered (pending %x), pending exception %x\n", pending, cpu_single_env->interrupt_index);
}
else
DPRINTF("Not triggered (pending %x), disabled %x\n", pending, s->intregm_disabled);
}
/*
* "irq" here is the bit number in the system interrupt register to
* separate serial and keyboard interrupts sharing a level.
*/
void slavio_pic_set_irq(void *opaque, int irq, int level)
{
SLAVIO_INTCTLState *s = opaque;
DPRINTF("Set irq %d level %d\n", irq, level);
if (irq < 32) {
uint32_t mask = 1 << irq;
uint32_t pil = intbit_to_level[irq];
if (pil > 0) {
if (level) {
s->intregm_pending |= mask;
s->intreg_pending[s->target_cpu] |= 1 << pil;
}
else {
s->intregm_pending &= ~mask;
s->intreg_pending[s->target_cpu] &= ~(1 << pil);
}
}
}
slavio_check_interrupts(s);
}
static void slavio_intctl_save(QEMUFile *f, void *opaque)
{
SLAVIO_INTCTLState *s = opaque;
int i;
for (i = 0; i < MAX_CPUS; i++) {
qemu_put_be32s(f, &s->intreg_pending[i]);
}
qemu_put_be32s(f, &s->intregm_pending);
qemu_put_be32s(f, &s->intregm_disabled);
qemu_put_be32s(f, &s->target_cpu);
}
static int slavio_intctl_load(QEMUFile *f, void *opaque, int version_id)
{
SLAVIO_INTCTLState *s = opaque;
int i;
if (version_id != 1)
return -EINVAL;
for (i = 0; i < MAX_CPUS; i++) {
qemu_get_be32s(f, &s->intreg_pending[i]);
}
qemu_get_be32s(f, &s->intregm_pending);
qemu_get_be32s(f, &s->intregm_disabled);
qemu_get_be32s(f, &s->target_cpu);
return 0;
}
static void slavio_intctl_reset(void *opaque)
{
SLAVIO_INTCTLState *s = opaque;
int i;
for (i = 0; i < MAX_CPUS; i++) {
s->intreg_pending[i] = 0;
}
s->intregm_disabled = ~0xffb2007f;
s->intregm_pending = 0;
s->target_cpu = 0;
}
void *slavio_intctl_init(uint32_t addr, uint32_t addrg)
{
int slavio_intctl_io_memory, slavio_intctlm_io_memory, i;
SLAVIO_INTCTLState *s;
s = qemu_mallocz(sizeof(SLAVIO_INTCTLState));
if (!s)
return NULL;
for (i = 0; i < MAX_CPUS; i++) {
slavio_intctl_io_memory = cpu_register_io_memory(0, slavio_intctl_mem_read, slavio_intctl_mem_write, s);
cpu_register_physical_memory(addr + i * TARGET_PAGE_SIZE, INTCTL_MAXADDR, slavio_intctl_io_memory);
}
slavio_intctlm_io_memory = cpu_register_io_memory(0, slavio_intctlm_mem_read, slavio_intctlm_mem_write, s);
cpu_register_physical_memory(addrg, INTCTLM_MAXADDR, slavio_intctlm_io_memory);
register_savevm("slavio_intctl", addr, 1, slavio_intctl_save, slavio_intctl_load, s);
qemu_register_reset(slavio_intctl_reset, s);
slavio_intctl_reset(s);
return s;
}
+505
View File
@@ -0,0 +1,505 @@
/*
* QEMU Sparc SLAVIO serial port emulation
*
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
/* debug serial */
//#define DEBUG_SERIAL
/* debug keyboard */
//#define DEBUG_KBD
/* debug mouse */
//#define DEBUG_MOUSE
/*
* This is the serial port, mouse and keyboard part of chip STP2001
* (Slave I/O), also produced as NCR89C105. See
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
*
* The serial ports implement full AMD AM8530 or Zilog Z8530 chips,
* mouse and keyboard ports don't implement all functions and they are
* only asynchronous. There is no DMA.
*
*/
#ifdef DEBUG_SERIAL
#define SER_DPRINTF(fmt, args...) \
do { printf("SER: " fmt , ##args); } while (0)
#else
#define SER_DPRINTF(fmt, args...)
#endif
#ifdef DEBUG_KBD
#define KBD_DPRINTF(fmt, args...) \
do { printf("KBD: " fmt , ##args); } while (0)
#else
#define KBD_DPRINTF(fmt, args...)
#endif
#ifdef DEBUG_MOUSE
#define MS_DPRINTF(fmt, args...) \
do { printf("SER: " fmt , ##args); } while (0)
#else
#define MS_DPRINTF(fmt, args...)
#endif
typedef enum {
chn_a, chn_b,
} chn_id_t;
typedef enum {
ser, kbd, mouse,
} chn_type_t;
#define KBD_QUEUE_SIZE 256
typedef struct {
uint8_t data[KBD_QUEUE_SIZE];
int rptr, wptr, count;
} KBDQueue;
typedef struct ChannelState {
int irq;
int reg;
int rxint, txint;
chn_id_t chn; // this channel, A (base+4) or B (base+0)
chn_type_t type;
struct ChannelState *otherchn;
uint8_t rx, tx, wregs[16], rregs[16];
KBDQueue queue;
CharDriverState *chr;
} ChannelState;
struct SerialState {
struct ChannelState chn[2];
};
#define SERIAL_MAXADDR 7
static void handle_kbd_command(ChannelState *s, int val);
static int serial_can_receive(void *opaque);
static void serial_receive_byte(ChannelState *s, int ch);
static void put_queue(void *opaque, int b)
{
ChannelState *s = opaque;
KBDQueue *q = &s->queue;
KBD_DPRINTF("put: 0x%02x\n", b);
if (q->count >= KBD_QUEUE_SIZE)
return;
q->data[q->wptr] = b;
if (++q->wptr == KBD_QUEUE_SIZE)
q->wptr = 0;
q->count++;
serial_receive_byte(s, 0);
}
static uint32_t get_queue(void *opaque)
{
ChannelState *s = opaque;
KBDQueue *q = &s->queue;
int val;
if (q->count == 0) {
return 0;
} else {
val = q->data[q->rptr];
if (++q->rptr == KBD_QUEUE_SIZE)
q->rptr = 0;
q->count--;
}
KBD_DPRINTF("get 0x%02x\n", val);
if (q->count > 0)
serial_receive_byte(s, 0);
return val;
}
static void slavio_serial_update_irq(ChannelState *s)
{
if ((s->wregs[1] & 1) && // interrupts enabled
(((s->wregs[1] & 2) && s->txint == 1) || // tx ints enabled, pending
((((s->wregs[1] & 0x18) == 8) || ((s->wregs[1] & 0x18) == 0x10)) &&
s->rxint == 1) || // rx ints enabled, pending
((s->wregs[15] & 0x80) && (s->rregs[0] & 0x80)))) { // break int e&p
pic_set_irq(s->irq, 1);
} else {
pic_set_irq(s->irq, 0);
}
}
static void slavio_serial_reset_chn(ChannelState *s)
{
int i;
s->reg = 0;
for (i = 0; i < SERIAL_MAXADDR; i++) {
s->rregs[i] = 0;
s->wregs[i] = 0;
}
s->wregs[4] = 4;
s->wregs[9] = 0xc0;
s->wregs[11] = 8;
s->wregs[14] = 0x30;
s->wregs[15] = 0xf8;
s->rregs[0] = 0x44;
s->rregs[1] = 6;
s->rx = s->tx = 0;
s->rxint = s->txint = 0;
}
static void slavio_serial_reset(void *opaque)
{
SerialState *s = opaque;
slavio_serial_reset_chn(&s->chn[0]);
slavio_serial_reset_chn(&s->chn[1]);
}
static void slavio_serial_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SerialState *ser = opaque;
ChannelState *s;
uint32_t saddr;
int newreg, channel;
val &= 0xff;
saddr = (addr & 3) >> 1;
channel = (addr & SERIAL_MAXADDR) >> 2;
s = &ser->chn[channel];
switch (saddr) {
case 0:
SER_DPRINTF("Write channel %c, reg[%d] = %2.2x\n", channel? 'b' : 'a', s->reg, val & 0xff);
newreg = 0;
switch (s->reg) {
case 0:
newreg = val & 7;
val &= 0x38;
switch (val) {
case 8:
s->reg |= 0x8;
break;
case 0x20:
s->rxint = 0;
break;
case 0x28:
s->txint = 0;
break;
default:
break;
}
break;
case 1 ... 8:
case 10 ... 15:
s->wregs[s->reg] = val;
break;
case 9:
switch (val & 0xc0) {
case 0:
default:
break;
case 0x40:
slavio_serial_reset_chn(&ser->chn[1]);
return;
case 0x80:
slavio_serial_reset_chn(&ser->chn[0]);
return;
case 0xc0:
slavio_serial_reset(ser);
return;
}
break;
default:
break;
}
if (s->reg == 0)
s->reg = newreg;
else
s->reg = 0;
break;
case 1:
SER_DPRINTF("Write channel %c, ch %d\n", channel? 'b' : 'a', val);
if (s->wregs[5] & 8) { // tx enabled
s->tx = val;
if (s->chr)
qemu_chr_write(s->chr, &s->tx, 1);
else if (s->type == kbd) {
handle_kbd_command(s, val);
}
s->txint = 1;
s->rregs[0] |= 4;
// Interrupts reported only on channel A
if (s->chn == 0)
s->rregs[3] |= 0x10;
else {
s->otherchn->rregs[3] |= 2;
}
slavio_serial_update_irq(s);
}
break;
default:
break;
}
}
static uint32_t slavio_serial_mem_readb(void *opaque, target_phys_addr_t addr)
{
SerialState *ser = opaque;
ChannelState *s;
uint32_t saddr;
uint32_t ret;
int channel;
saddr = (addr & 3) >> 1;
channel = (addr & SERIAL_MAXADDR) >> 2;
s = &ser->chn[channel];
switch (saddr) {
case 0:
SER_DPRINTF("Read channel %c, reg[%d] = %2.2x\n", channel? 'b' : 'a', s->reg, s->rregs[s->reg]);
ret = s->rregs[s->reg];
s->reg = 0;
return ret;
case 1:
SER_DPRINTF("Read channel %c, ch %d\n", channel? 'b' : 'a', s->rx);
s->rregs[0] &= ~1;
if (s->type == kbd)
ret = get_queue(s);
else
ret = s->rx;
return ret;
default:
break;
}
return 0;
}
static int serial_can_receive(void *opaque)
{
ChannelState *s = opaque;
if (((s->wregs[3] & 1) == 0) // Rx not enabled
|| ((s->rregs[0] & 1) == 1)) // char already available
return 0;
else
return 1;
}
static void serial_receive_byte(ChannelState *s, int ch)
{
s->rregs[0] |= 1;
// Interrupts reported only on channel A
if (s->chn == 0)
s->rregs[3] |= 0x20;
else {
s->otherchn->rregs[3] |= 4;
}
s->rx = ch;
s->rxint = 1;
slavio_serial_update_irq(s);
}
static void serial_receive_break(ChannelState *s)
{
s->rregs[0] |= 0x80;
slavio_serial_update_irq(s);
}
static void serial_receive1(void *opaque, const uint8_t *buf, int size)
{
ChannelState *s = opaque;
serial_receive_byte(s, buf[0]);
}
static void serial_event(void *opaque, int event)
{
ChannelState *s = opaque;
if (event == CHR_EVENT_BREAK)
serial_receive_break(s);
}
static CPUReadMemoryFunc *slavio_serial_mem_read[3] = {
slavio_serial_mem_readb,
slavio_serial_mem_readb,
slavio_serial_mem_readb,
};
static CPUWriteMemoryFunc *slavio_serial_mem_write[3] = {
slavio_serial_mem_writeb,
slavio_serial_mem_writeb,
slavio_serial_mem_writeb,
};
static void slavio_serial_save_chn(QEMUFile *f, ChannelState *s)
{
qemu_put_be32s(f, &s->irq);
qemu_put_be32s(f, &s->reg);
qemu_put_be32s(f, &s->rxint);
qemu_put_be32s(f, &s->txint);
qemu_put_8s(f, &s->rx);
qemu_put_8s(f, &s->tx);
qemu_put_buffer(f, s->wregs, 16);
qemu_put_buffer(f, s->rregs, 16);
}
static void slavio_serial_save(QEMUFile *f, void *opaque)
{
SerialState *s = opaque;
slavio_serial_save_chn(f, &s->chn[0]);
slavio_serial_save_chn(f, &s->chn[1]);
}
static int slavio_serial_load_chn(QEMUFile *f, ChannelState *s, int version_id)
{
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, &s->irq);
qemu_get_be32s(f, &s->reg);
qemu_get_be32s(f, &s->rxint);
qemu_get_be32s(f, &s->txint);
qemu_get_8s(f, &s->rx);
qemu_get_8s(f, &s->tx);
qemu_get_buffer(f, s->wregs, 16);
qemu_get_buffer(f, s->rregs, 16);
return 0;
}
static int slavio_serial_load(QEMUFile *f, void *opaque, int version_id)
{
SerialState *s = opaque;
int ret;
ret = slavio_serial_load_chn(f, &s->chn[0], version_id);
if (ret != 0)
return ret;
ret = slavio_serial_load_chn(f, &s->chn[1], version_id);
return ret;
}
SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2)
{
int slavio_serial_io_memory, i;
SerialState *s;
s = qemu_mallocz(sizeof(SerialState));
if (!s)
return NULL;
slavio_serial_io_memory = cpu_register_io_memory(0, slavio_serial_mem_read, slavio_serial_mem_write, s);
cpu_register_physical_memory(base, SERIAL_MAXADDR, slavio_serial_io_memory);
s->chn[0].chr = chr1;
s->chn[1].chr = chr2;
for (i = 0; i < 2; i++) {
s->chn[i].irq = irq;
s->chn[i].chn = 1 - i;
s->chn[i].type = ser;
if (s->chn[i].chr) {
qemu_chr_add_read_handler(s->chn[i].chr, serial_can_receive, serial_receive1, &s->chn[i]);
qemu_chr_add_event_handler(s->chn[i].chr, serial_event);
}
}
s->chn[0].otherchn = &s->chn[1];
s->chn[1].otherchn = &s->chn[0];
register_savevm("slavio_serial", base, 1, slavio_serial_save, slavio_serial_load, s);
qemu_register_reset(slavio_serial_reset, s);
slavio_serial_reset(s);
return s;
}
static const uint8_t keycodes[128] = {
127, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 89, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 42, 99, 88, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 47, 19, 121, 119, 5, 6, 8, 10, 12,
14, 16, 17, 18, 7, 98, 23, 68, 69, 70, 71, 91, 92, 93, 125, 112,
113, 114, 94, 50, 0, 0, 124, 9, 11, 0, 0, 0, 0, 0, 0, 0,
90, 0, 46, 22, 13, 111, 52, 20, 96, 24, 28, 74, 27, 123, 44, 66,
0, 45, 2, 4, 48, 0, 0, 21, 0, 0, 0, 0, 0, 120, 122, 67,
};
static void sunkbd_event(void *opaque, int ch)
{
ChannelState *s = opaque;
int release = ch & 0x80;
ch = keycodes[ch & 0x7f];
KBD_DPRINTF("Keycode %d (%s)\n", ch, release? "release" : "press");
put_queue(s, ch | release);
}
static void handle_kbd_command(ChannelState *s, int val)
{
KBD_DPRINTF("Command %d\n", val);
switch (val) {
case 1: // Reset, return type code
put_queue(s, 0xff);
put_queue(s, 0xff);
put_queue(s, 5); // Type 5
break;
case 7: // Query layout
put_queue(s, 0xfe);
put_queue(s, 0x20); // XXX, layout?
break;
default:
break;
}
}
static void sunmouse_event(void *opaque,
int dx, int dy, int dz, int buttons_state)
{
ChannelState *s = opaque;
int ch;
// XXX
ch = 0x42;
serial_receive_byte(s, ch);
}
void slavio_serial_ms_kbd_init(int base, int irq)
{
int slavio_serial_io_memory, i;
SerialState *s;
s = qemu_mallocz(sizeof(SerialState));
if (!s)
return;
for (i = 0; i < 2; i++) {
s->chn[i].irq = irq;
s->chn[i].chn = 1 - i;
s->chn[i].chr = NULL;
}
s->chn[0].otherchn = &s->chn[1];
s->chn[1].otherchn = &s->chn[0];
s->chn[0].type = mouse;
s->chn[1].type = kbd;
slavio_serial_io_memory = cpu_register_io_memory(0, slavio_serial_mem_read, slavio_serial_mem_write, s);
cpu_register_physical_memory(base, SERIAL_MAXADDR, slavio_serial_io_memory);
qemu_add_mouse_event_handler(sunmouse_event, &s->chn[0]);
qemu_add_kbd_event_handler(sunkbd_event, &s->chn[1]);
qemu_register_reset(slavio_serial_reset, s);
slavio_serial_reset(s);
}
+295
View File
@@ -0,0 +1,295 @@
/*
* QEMU Sparc SLAVIO timer controller emulation
*
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
//#define DEBUG_TIMER
#ifdef DEBUG_TIMER
#define DPRINTF(fmt, args...) \
do { printf("TIMER: " fmt , ##args); } while (0)
#else
#define DPRINTF(fmt, args...)
#endif
/*
* Registers of hardware timer in sun4m.
*
* This is the timer/counter part of chip STP2001 (Slave I/O), also
* produced as NCR89C105. See
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
*
* The 31-bit counter is incremented every 500ns by bit 9. Bits 8..0
* are zero. Bit 31 is 1 when count has been reached.
*
*/
typedef struct SLAVIO_TIMERState {
uint32_t limit, count, counthigh;
int64_t count_load_time;
int64_t expire_time;
int64_t stop_time, tick_offset;
QEMUTimer *irq_timer;
int irq;
int reached, stopped;
int mode; // 0 = processor, 1 = user, 2 = system
} SLAVIO_TIMERState;
#define TIMER_MAXADDR 0x1f
#define CNT_FREQ 2000000
#define MAX_CPUS 16
// Update count, set irq, update expire_time
static void slavio_timer_get_out(SLAVIO_TIMERState *s)
{
int out;
int64_t diff, ticks, count;
uint32_t limit;
// There are three clock tick units: CPU ticks, register units
// (nanoseconds), and counter ticks (500 ns).
if (s->mode == 1 && s->stopped)
ticks = s->stop_time;
else
ticks = qemu_get_clock(vm_clock) - s->tick_offset;
out = (ticks >= s->expire_time);
if (out)
s->reached = 0x80000000;
if (!s->limit)
limit = 0x7fffffff;
else
limit = s->limit;
// Convert register units to counter ticks
limit = limit >> 9;
// Convert cpu ticks to counter ticks
diff = muldiv64(ticks - s->count_load_time, CNT_FREQ, ticks_per_sec);
// Calculate what the counter should be, convert to register
// units
count = diff % limit;
s->count = count << 9;
s->counthigh = count >> 22;
// Expire time: CPU ticks left to next interrupt
// Convert remaining counter ticks to CPU ticks
s->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ);
DPRINTF("irq %d limit %d reached %d d %lld count %d s->c %x diff %lld stopped %d mode %d\n", s->irq, limit, s->reached?1:0, (ticks-s->count_load_time), count, s->count, s->expire_time - ticks, s->stopped, s->mode);
if (s->mode != 1)
pic_set_irq(s->irq, out);
}
// timer callback
static void slavio_timer_irq(void *opaque)
{
SLAVIO_TIMERState *s = opaque;
if (!s->irq_timer)
return;
slavio_timer_get_out(s);
if (s->mode != 1)
qemu_mod_timer(s->irq_timer, s->expire_time);
}
static uint32_t slavio_timer_mem_readl(void *opaque, target_phys_addr_t addr)
{
SLAVIO_TIMERState *s = opaque;
uint32_t saddr;
saddr = (addr & TIMER_MAXADDR) >> 2;
switch (saddr) {
case 0:
// read limit (system counter mode) or read most signifying
// part of counter (user mode)
if (s->mode != 1) {
// clear irq
pic_set_irq(s->irq, 0);
s->count_load_time = qemu_get_clock(vm_clock);
s->reached = 0;
return s->limit;
}
else {
slavio_timer_get_out(s);
return s->counthigh & 0x7fffffff;
}
case 1:
// read counter and reached bit (system mode) or read lsbits
// of counter (user mode)
slavio_timer_get_out(s);
if (s->mode != 1)
return (s->count & 0x7fffffff) | s->reached;
else
return s->count;
case 3:
// read start/stop status
return s->stopped;
case 4:
// read user/system mode
return s->mode & 1;
default:
return 0;
}
}
static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
SLAVIO_TIMERState *s = opaque;
uint32_t saddr;
saddr = (addr & TIMER_MAXADDR) >> 2;
switch (saddr) {
case 0:
// set limit, reset counter
s->count_load_time = qemu_get_clock(vm_clock);
// fall through
case 2:
// set limit without resetting counter
if (!val)
s->limit = 0x7fffffff;
else
s->limit = val & 0x7fffffff;
slavio_timer_irq(s);
break;
case 3:
// start/stop user counter
if (s->mode == 1) {
if (val & 1) {
s->stop_time = qemu_get_clock(vm_clock);
s->stopped = 1;
}
else {
if (s->stopped)
s->tick_offset += qemu_get_clock(vm_clock) - s->stop_time;
s->stopped = 0;
}
}
break;
case 4:
// bit 0: user (1) or system (0) counter mode
if (s->mode == 0 || s->mode == 1)
s->mode = val & 1;
break;
default:
break;
}
}
static CPUReadMemoryFunc *slavio_timer_mem_read[3] = {
slavio_timer_mem_readl,
slavio_timer_mem_readl,
slavio_timer_mem_readl,
};
static CPUWriteMemoryFunc *slavio_timer_mem_write[3] = {
slavio_timer_mem_writel,
slavio_timer_mem_writel,
slavio_timer_mem_writel,
};
static void slavio_timer_save(QEMUFile *f, void *opaque)
{
SLAVIO_TIMERState *s = opaque;
qemu_put_be32s(f, &s->limit);
qemu_put_be32s(f, &s->count);
qemu_put_be32s(f, &s->counthigh);
qemu_put_be64s(f, &s->count_load_time);
qemu_put_be64s(f, &s->expire_time);
qemu_put_be64s(f, &s->stop_time);
qemu_put_be64s(f, &s->tick_offset);
qemu_put_be32s(f, &s->irq);
qemu_put_be32s(f, &s->reached);
qemu_put_be32s(f, &s->stopped);
qemu_put_be32s(f, &s->mode);
}
static int slavio_timer_load(QEMUFile *f, void *opaque, int version_id)
{
SLAVIO_TIMERState *s = opaque;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, &s->limit);
qemu_get_be32s(f, &s->count);
qemu_get_be32s(f, &s->counthigh);
qemu_get_be64s(f, &s->count_load_time);
qemu_get_be64s(f, &s->expire_time);
qemu_get_be64s(f, &s->stop_time);
qemu_get_be64s(f, &s->tick_offset);
qemu_get_be32s(f, &s->irq);
qemu_get_be32s(f, &s->reached);
qemu_get_be32s(f, &s->stopped);
qemu_get_be32s(f, &s->mode);
return 0;
}
static void slavio_timer_reset(void *opaque)
{
SLAVIO_TIMERState *s = opaque;
s->limit = 0;
s->count = 0;
s->count_load_time = qemu_get_clock(vm_clock);;
s->stop_time = s->count_load_time;
s->tick_offset = 0;
s->reached = 0;
s->mode &= 2;
s->stopped = 1;
slavio_timer_get_out(s);
}
static void slavio_timer_init_internal(uint32_t addr, int irq, int mode)
{
int slavio_timer_io_memory;
SLAVIO_TIMERState *s;
s = qemu_mallocz(sizeof(SLAVIO_TIMERState));
if (!s)
return;
s->irq = irq;
s->mode = mode;
s->irq_timer = qemu_new_timer(vm_clock, slavio_timer_irq, s);
slavio_timer_io_memory = cpu_register_io_memory(0, slavio_timer_mem_read,
slavio_timer_mem_write, s);
cpu_register_physical_memory(addr, TIMER_MAXADDR, slavio_timer_io_memory);
register_savevm("slavio_timer", addr, 1, slavio_timer_save, slavio_timer_load, s);
qemu_register_reset(slavio_timer_reset, s);
slavio_timer_reset(s);
}
void slavio_timer_init(uint32_t addr1, int irq1, uint32_t addr2, int irq2)
{
int i;
for (i = 0; i < MAX_CPUS; i++) {
slavio_timer_init_internal(addr1 + i * TARGET_PAGE_SIZE, irq1, 0);
}
slavio_timer_init_internal(addr2, irq2, 2);
}
+222 -50
View File
@@ -1,7 +1,7 @@
/*
* QEMU Sun4m System Emulator
*
* Copyright (c) 2003-2004 Fabrice Bellard
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,29 +25,36 @@
#include "m48t08.h"
#define KERNEL_LOAD_ADDR 0x00004000
#define MMU_CONTEXT_TBL 0x00003000
#define MMU_L1PTP (MMU_CONTEXT_TBL + 0x0400)
#define MMU_L2PTP (MMU_CONTEXT_TBL + 0x0800)
#define PROM_ADDR 0xffd04000
#define CMDLINE_ADDR 0x007ff000
#define INITRD_LOAD_ADDR 0x00800000
#define PROM_ADDR 0xffd00000
#define PROM_FILENAMEB "proll.bin"
#define PROM_FILENAMEE "proll.elf"
#define PROLL_MAGIC_ADDR 0x20000000
#define PHYS_JJ_EEPROM 0x71200000 /* [2000] MK48T08 */
#define PHYS_JJ_EEPROM 0x71200000 /* m48t08 */
#define PHYS_JJ_IDPROM_OFF 0x1FD8
#define PHYS_JJ_EEPROM_SIZE 0x2000
#define PHYS_JJ_IOMMU 0x10000000 /* First page of sun4m IOMMU */
#define PHYS_JJ_TCX_FB 0x50800000 /* Start address, frame buffer body */
#define PHYS_JJ_TCX_0E 0x5E000000 /* Top address, one byte used. */
#define PHYS_JJ_IOMMU 0x10000000 /* First page of sun4m IOMMU */
#define PHYS_JJ_LEDMA 0x78400010 /* ledma, off by 10 from unused SCSI */
#define PHYS_JJ_LE 0x78C00000 /* LANCE, typical sun4m */
#define PHYS_JJ_LE_IRQ 6
#define PHYS_JJ_CLOCK 0x71D00000
#define PHYS_JJ_CLOCK_IRQ 10
#define PHYS_JJ_CLOCK1 0x71D10000
#define PHYS_JJ_CLOCK1_IRQ 14
#define PHYS_JJ_INTR0 0x71E00000 /* CPU0 interrupt control registers */
// IRQs are not PIL ones, but master interrupt controller register
// bits
#define PHYS_JJ_IOMMU 0x10000000 /* I/O MMU */
#define PHYS_JJ_TCX_FB 0x50000000 /* TCX frame buffer */
#define PHYS_JJ_ESPDMA 0x78400000 /* ESP DMA controller */
#define PHYS_JJ_ESP 0x78800000 /* ESP SCSI */
#define PHYS_JJ_ESP_IRQ 18
#define PHYS_JJ_LEDMA 0x78400010 /* Lance DMA controller */
#define PHYS_JJ_LE 0x78C00000 /* Lance ethernet */
#define PHYS_JJ_LE_IRQ 16
#define PHYS_JJ_CLOCK 0x71D00000 /* Per-CPU timer/counter, L14 */
#define PHYS_JJ_CLOCK_IRQ 7
#define PHYS_JJ_CLOCK1 0x71D10000 /* System timer/counter, L10 */
#define PHYS_JJ_CLOCK1_IRQ 19
#define PHYS_JJ_INTR0 0x71E00000 /* Per-CPU interrupt control registers */
#define PHYS_JJ_INTR_G 0x71E10000 /* Master interrupt control registers */
#define PHYS_JJ_MS_KBD 0x71000000 /* Mouse and keyboard */
#define PHYS_JJ_MS_KBD_IRQ 14
#define PHYS_JJ_SER 0x71100000 /* Serial */
#define PHYS_JJ_SER_IRQ 15
#define PHYS_JJ_FDC 0x71400000 /* Floppy */
#define PHYS_JJ_FLOPPY_IRQ 22
/* TSC handling */
@@ -56,14 +63,145 @@ uint64_t cpu_get_tsc()
return qemu_get_clock(vm_clock);
}
void DMA_run() {}
void SB16_run() {}
int serial_can_receive(SerialState *s) { return 0; }
void serial_receive_byte(SerialState *s, int ch) {}
void serial_receive_break(SerialState *s) {}
int DMA_get_channel_mode (int nchan)
{
return 0;
}
int DMA_read_memory (int nchan, void *buf, int pos, int size)
{
return 0;
}
int DMA_write_memory (int nchan, void *buf, int pos, int size)
{
return 0;
}
void DMA_hold_DREQ (int nchan) {}
void DMA_release_DREQ (int nchan) {}
void DMA_schedule(int nchan) {}
void DMA_run (void) {}
void DMA_init (int high_page_enable) {}
void DMA_register_channel (int nchan,
DMA_transfer_handler transfer_handler,
void *opaque)
{
}
static void nvram_set_word (m48t08_t *nvram, uint32_t addr, uint16_t value)
{
m48t08_write(nvram, addr++, (value >> 8) & 0xff);
m48t08_write(nvram, addr++, value & 0xff);
}
static void nvram_set_lword (m48t08_t *nvram, uint32_t addr, uint32_t value)
{
m48t08_write(nvram, addr++, value >> 24);
m48t08_write(nvram, addr++, (value >> 16) & 0xff);
m48t08_write(nvram, addr++, (value >> 8) & 0xff);
m48t08_write(nvram, addr++, value & 0xff);
}
static void nvram_set_string (m48t08_t *nvram, uint32_t addr,
const unsigned char *str, uint32_t max)
{
unsigned int i;
for (i = 0; i < max && str[i] != '\0'; i++) {
m48t08_write(nvram, addr + i, str[i]);
}
m48t08_write(nvram, addr + max - 1, '\0');
}
static m48t08_t *nvram;
extern int nographic;
static void nvram_init(m48t08_t *nvram, uint8_t *macaddr, const char *cmdline,
int boot_device, uint32_t RAM_size,
uint32_t kernel_size,
int width, int height, int depth)
{
unsigned char tmp = 0;
int i, j;
// Try to match PPC NVRAM
nvram_set_string(nvram, 0x00, "QEMU_BIOS", 16);
nvram_set_lword(nvram, 0x10, 0x00000001); /* structure v1 */
// NVRAM_size, arch not applicable
m48t08_write(nvram, 0x2F, nographic & 0xff);
nvram_set_lword(nvram, 0x30, RAM_size);
m48t08_write(nvram, 0x34, boot_device & 0xff);
nvram_set_lword(nvram, 0x38, KERNEL_LOAD_ADDR);
nvram_set_lword(nvram, 0x3C, kernel_size);
if (cmdline) {
strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
nvram_set_lword(nvram, 0x40, CMDLINE_ADDR);
nvram_set_lword(nvram, 0x44, strlen(cmdline));
}
// initrd_image, initrd_size passed differently
nvram_set_word(nvram, 0x54, width);
nvram_set_word(nvram, 0x56, height);
nvram_set_word(nvram, 0x58, depth);
// Sun4m specific use
i = 0x1fd8;
m48t08_write(nvram, i++, 0x01);
m48t08_write(nvram, i++, 0x80); /* Sun4m OBP */
j = 0;
m48t08_write(nvram, i++, macaddr[j++]);
m48t08_write(nvram, i++, macaddr[j++]);
m48t08_write(nvram, i++, macaddr[j++]);
m48t08_write(nvram, i++, macaddr[j++]);
m48t08_write(nvram, i++, macaddr[j++]);
m48t08_write(nvram, i, macaddr[j]);
/* Calculate checksum */
for (i = 0x1fd8; i < 0x1fe7; i++) {
tmp ^= m48t08_read(nvram, i);
}
m48t08_write(nvram, 0x1fe7, tmp);
}
static void *slavio_intctl;
void pic_info()
{
slavio_pic_info(slavio_intctl);
}
void irq_info()
{
slavio_irq_info(slavio_intctl);
}
void pic_set_irq(int irq, int level)
{
slavio_pic_set_irq(slavio_intctl, irq, level);
}
static void *tcx;
void vga_update_display()
{
tcx_update_display(tcx);
}
void vga_invalidate_display()
{
tcx_invalidate_display(tcx);
}
void vga_screen_dump(const char *filename)
{
tcx_screen_dump(tcx, filename);
}
static void *iommu;
uint32_t iommu_translate(uint32_t addr)
{
return iommu_translate_local(iommu, addr);
}
/* Sun4m hardware initialisation */
void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
@@ -72,42 +210,76 @@ void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
{
char buf[1024];
int ret, linux_boot;
unsigned long bios_offset;
unsigned int i;
long vram_size = 0x100000, prom_offset, initrd_size, kernel_size;
linux_boot = (kernel_filename != NULL);
/* allocate RAM */
cpu_register_physical_memory(0, ram_size, 0);
bios_offset = ram_size;
iommu_init(PHYS_JJ_IOMMU);
sched_init(PHYS_JJ_INTR0, PHYS_JJ_INTR_G);
tcx_init(ds, PHYS_JJ_TCX_FB);
iommu = iommu_init(PHYS_JJ_IOMMU);
slavio_intctl = slavio_intctl_init(PHYS_JJ_INTR0, PHYS_JJ_INTR_G);
tcx = tcx_init(ds, PHYS_JJ_TCX_FB, phys_ram_base + ram_size, ram_size, vram_size, graphic_width, graphic_height);
lance_init(&nd_table[0], PHYS_JJ_LE_IRQ, PHYS_JJ_LE, PHYS_JJ_LEDMA);
nvram = m48t08_init(PHYS_JJ_EEPROM, PHYS_JJ_EEPROM_SIZE, &nd_table[0].macaddr);
timer_init(PHYS_JJ_CLOCK, PHYS_JJ_CLOCK_IRQ);
timer_init(PHYS_JJ_CLOCK1, PHYS_JJ_CLOCK1_IRQ);
magic_init(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR, PROLL_MAGIC_ADDR);
nvram = m48t08_init(PHYS_JJ_EEPROM, PHYS_JJ_EEPROM_SIZE);
slavio_timer_init(PHYS_JJ_CLOCK, PHYS_JJ_CLOCK_IRQ, PHYS_JJ_CLOCK1, PHYS_JJ_CLOCK1_IRQ);
slavio_serial_ms_kbd_init(PHYS_JJ_MS_KBD, PHYS_JJ_MS_KBD_IRQ);
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
slavio_serial_init(PHYS_JJ_SER, PHYS_JJ_SER_IRQ, serial_hds[1], serial_hds[0]);
fdctrl_init(PHYS_JJ_FLOPPY_IRQ, 0, 1, PHYS_JJ_FDC, fd_table);
esp_init(bs_table, PHYS_JJ_ESP_IRQ, PHYS_JJ_ESP, PHYS_JJ_ESPDMA);
/* We load Proll as the kernel and start it. It will issue a magic
IO to load the real kernel */
if (linux_boot) {
prom_offset = ram_size + vram_size;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAMEE);
ret = load_elf(buf, phys_ram_base + prom_offset);
if (ret < 0) {
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAMEB);
ret = load_kernel(buf,
phys_ram_base + KERNEL_LOAD_ADDR);
if (ret < 0) {
ret = load_image(buf, phys_ram_base + prom_offset);
}
if (ret < 0) {
fprintf(stderr, "qemu: could not load prom '%s'\n",
buf);
exit(1);
}
cpu_register_physical_memory(PROM_ADDR, (ret + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK,
prom_offset | IO_MEM_ROM);
kernel_size = 0;
if (linux_boot) {
kernel_size = load_elf(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
if (kernel_size < 0)
kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
buf);
exit(1);
kernel_filename);
exit(1);
}
/* load initrd */
initrd_size = 0;
if (initrd_filename) {
initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
}
if (initrd_size > 0) {
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
== 0x48647253) { // HdrS
stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
break;
}
}
}
}
/* Setup a MMU entry for entire address space */
stl_raw(phys_ram_base + MMU_CONTEXT_TBL, (MMU_L1PTP >> 4) | 1);
stl_raw(phys_ram_base + MMU_L1PTP, (MMU_L2PTP >> 4) | 1);
stl_raw(phys_ram_base + MMU_L1PTP + (0x01 << 2), (MMU_L2PTP >> 4) | 1); // 01.. == 00..
stl_raw(phys_ram_base + MMU_L1PTP + (0xff << 2), (MMU_L2PTP >> 4) | 1); // ff.. == 00..
stl_raw(phys_ram_base + MMU_L1PTP + (0xf0 << 2), (MMU_L2PTP >> 4) | 1); // f0.. == 00..
/* 3 = U:RWX S:RWX */
stl_raw(phys_ram_base + MMU_L2PTP, (3 << PTE_ACCESS_SHIFT) | 2);
stl_raw(phys_ram_base + MMU_L2PTP, ((0x01 << PTE_PPN_SHIFT) >> 4 ) | (3 << PTE_ACCESS_SHIFT) | 2);
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline, boot_device, ram_size, kernel_size, graphic_width, graphic_height, graphic_depth);
}
+239 -119
View File
@@ -1,7 +1,7 @@
/*
* QEMU Sun4m System Emulator
* QEMU TCX Frame buffer
*
* Copyright (c) 2003-2004 Fabrice Bellard
* Copyright (c) 2003-2005 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,179 +25,299 @@
#define MAXX 1024
#define MAXY 768
#define XSZ (8*80)
#define YSZ (24*11)
#define XOFF (MAXX-XSZ)
#define YOFF (MAXY-YSZ)
#define TCX_DAC_NREGS 16
typedef struct TCXState {
uint32_t addr;
DisplayState *ds;
uint8_t *vram;
unsigned long vram_offset;
uint16_t width, height;
uint8_t r[256], g[256], b[256];
uint8_t dac_index, dac_state;
} TCXState;
static TCXState *ts;
void vga_update_display()
static void tcx_draw_line32(TCXState *s1, uint8_t *d,
const uint8_t *s, int width)
{
dpy_update(ts->ds, 0, 0, XSZ, YSZ);
int x;
uint8_t val;
for(x = 0; x < width; x++) {
val = *s++;
*d++ = s1->b[val];
*d++ = s1->g[val];
*d++ = s1->r[val];
d++;
}
}
void vga_invalidate_display() {}
static void tcx_draw_line24(TCXState *s1, uint8_t *d,
const uint8_t *s, int width)
{
int x;
uint8_t val;
static uint32_t tcx_mem_readb(void *opaque, target_phys_addr_t addr)
for(x = 0; x < width; x++) {
val = *s++;
*d++ = s1->b[val];
*d++ = s1->g[val];
*d++ = s1->r[val];
}
}
static void tcx_draw_line8(TCXState *s1, uint8_t *d,
const uint8_t *s, int width)
{
int x;
uint8_t val;
for(x = 0; x < width; x++) {
val = *s++;
/* XXX translate between palettes? */
*d++ = val;
}
}
/* Fixed line length 1024 allows us to do nice tricks not possible on
VGA... */
void tcx_update_display(void *opaque)
{
TCXState *ts = opaque;
uint32_t page;
int y, page_min, page_max, y_start, dd, ds;
uint8_t *d, *s;
void (*f)(TCXState *s1, uint8_t *d, const uint8_t *s, int width);
if (ts->ds->depth == 0)
return;
page = ts->vram_offset;
y_start = -1;
page_min = 0x7fffffff;
page_max = -1;
d = ts->ds->data;
s = ts->vram;
dd = ts->ds->linesize;
ds = 1024;
switch (ts->ds->depth) {
case 32:
f = tcx_draw_line32;
break;
case 24:
f = tcx_draw_line24;
break;
default:
case 8:
f = tcx_draw_line8;
break;
case 0:
return;
}
for(y = 0; y < ts->height; y += 4, page += TARGET_PAGE_SIZE) {
if (cpu_physical_memory_get_dirty(page, VGA_DIRTY_FLAG)) {
if (y_start < 0)
y_start = y;
if (page < page_min)
page_min = page;
if (page > page_max)
page_max = page;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
f(ts, d, s, ts->width);
d += dd;
s += ds;
} else {
if (y_start >= 0) {
/* flush to display */
dpy_update(ts->ds, 0, y_start,
ts->width, y - y_start);
y_start = -1;
}
d += dd * 4;
s += ds * 4;
}
}
if (y_start >= 0) {
/* flush to display */
dpy_update(ts->ds, 0, y_start,
ts->width, y - y_start);
}
/* reset modified pages */
if (page_max != -1) {
cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
}
void tcx_invalidate_display(void *opaque)
{
TCXState *s = opaque;
uint32_t saddr;
unsigned int x, y;
int i;
saddr = addr - s->addr - YOFF*MAXX - XOFF;
y = saddr / MAXX;
x = saddr - y * MAXX;
if (x < XSZ && y < YSZ) {
return s->vram[y * XSZ + x];
for (i = 0; i < MAXX*MAXY; i += TARGET_PAGE_SIZE) {
cpu_physical_memory_set_dirty(s->vram_offset + i);
}
}
static void tcx_save(QEMUFile *f, void *opaque)
{
TCXState *s = opaque;
qemu_put_be32s(f, (uint32_t *)&s->addr);
qemu_put_be32s(f, (uint32_t *)&s->vram);
qemu_put_be16s(f, (uint16_t *)&s->height);
qemu_put_be16s(f, (uint16_t *)&s->width);
qemu_put_buffer(f, s->r, 256);
qemu_put_buffer(f, s->g, 256);
qemu_put_buffer(f, s->b, 256);
qemu_put_8s(f, &s->dac_index);
qemu_put_8s(f, &s->dac_state);
}
static int tcx_load(QEMUFile *f, void *opaque, int version_id)
{
TCXState *s = opaque;
if (version_id != 1)
return -EINVAL;
qemu_get_be32s(f, (uint32_t *)&s->addr);
qemu_get_be32s(f, (uint32_t *)&s->vram);
qemu_get_be16s(f, (uint16_t *)&s->height);
qemu_get_be16s(f, (uint16_t *)&s->width);
qemu_get_buffer(f, s->r, 256);
qemu_get_buffer(f, s->g, 256);
qemu_get_buffer(f, s->b, 256);
qemu_get_8s(f, &s->dac_index);
qemu_get_8s(f, &s->dac_state);
return 0;
}
static uint32_t tcx_mem_readw(void *opaque, target_phys_addr_t addr)
static void tcx_reset(void *opaque)
{
uint32_t v;
#ifdef TARGET_WORDS_BIGENDIAN
v = tcx_mem_readb(opaque, addr) << 8;
v |= tcx_mem_readb(opaque, addr + 1);
#else
v = tcx_mem_readb(opaque, addr);
v |= tcx_mem_readb(opaque, addr + 1) << 8;
#endif
return v;
TCXState *s = opaque;
/* Initialize palette */
memset(s->r, 0, 256);
memset(s->g, 0, 256);
memset(s->b, 0, 256);
s->r[255] = s->g[255] = s->b[255] = 255;
memset(s->vram, 0, MAXX*MAXY);
cpu_physical_memory_reset_dirty(s->vram_offset, s->vram_offset + MAXX*MAXY,
VGA_DIRTY_FLAG);
s->dac_index = 0;
s->dac_state = 0;
}
static uint32_t tcx_mem_readl(void *opaque, target_phys_addr_t addr)
static uint32_t tcx_dac_readl(void *opaque, target_phys_addr_t addr)
{
uint32_t v;
#ifdef TARGET_WORDS_BIGENDIAN
v = tcx_mem_readb(opaque, addr) << 24;
v |= tcx_mem_readb(opaque, addr + 1) << 16;
v |= tcx_mem_readb(opaque, addr + 2) << 8;
v |= tcx_mem_readb(opaque, addr + 3);
#else
v = tcx_mem_readb(opaque, addr);
v |= tcx_mem_readb(opaque, addr + 1) << 8;
v |= tcx_mem_readb(opaque, addr + 2) << 16;
v |= tcx_mem_readb(opaque, addr + 3) << 24;
#endif
return v;
return 0;
}
static void tcx_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
static void tcx_dac_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
TCXState *s = opaque;
uint32_t saddr;
unsigned int x, y;
char *sptr;
saddr = addr - s->addr - YOFF*MAXX - XOFF;
y = saddr / MAXX;
x = saddr - y * MAXX;
if (x < XSZ && y < YSZ) {
sptr = s->ds->data;
if (sptr) {
if (s->ds->depth == 24 || s->ds->depth == 32) {
/* XXX need to do CLUT translation */
sptr[y * s->ds->linesize + x*4] = val & 0xff;
sptr[y * s->ds->linesize + x*4+1] = val & 0xff;
sptr[y * s->ds->linesize + x*4+2] = val & 0xff;
}
else if (s->ds->depth == 8) {
sptr[y * s->ds->linesize + x] = val & 0xff;
}
saddr = (addr & (TCX_DAC_NREGS - 1)) >> 2;
switch (saddr) {
case 0:
s->dac_index = val >> 24;
s->dac_state = 0;
break;
case 1:
switch (s->dac_state) {
case 0:
s->r[s->dac_index] = val >> 24;
s->dac_state++;
break;
case 1:
s->g[s->dac_index] = val >> 24;
s->dac_state++;
break;
case 2:
s->b[s->dac_index] = val >> 24;
default:
s->dac_state = 0;
break;
}
cpu_physical_memory_set_dirty(addr);
s->vram[y * XSZ + x] = val & 0xff;
break;
default:
break;
}
return;
}
static void tcx_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
{
#ifdef TARGET_WORDS_BIGENDIAN
tcx_mem_writeb(opaque, addr, (val >> 8) & 0xff);
tcx_mem_writeb(opaque, addr + 1, val & 0xff);
#else
tcx_mem_writeb(opaque, addr, val & 0xff);
tcx_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
#endif
}
static void tcx_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
#ifdef TARGET_WORDS_BIGENDIAN
tcx_mem_writeb(opaque, addr, (val >> 24) & 0xff);
tcx_mem_writeb(opaque, addr + 1, (val >> 16) & 0xff);
tcx_mem_writeb(opaque, addr + 2, (val >> 8) & 0xff);
tcx_mem_writeb(opaque, addr + 3, val & 0xff);
#else
tcx_mem_writeb(opaque, addr, val & 0xff);
tcx_mem_writeb(opaque, addr + 1, (val >> 8) & 0xff);
tcx_mem_writeb(opaque, addr + 2, (val >> 16) & 0xff);
tcx_mem_writeb(opaque, addr + 3, (val >> 24) & 0xff);
#endif
}
static CPUReadMemoryFunc *tcx_mem_read[3] = {
tcx_mem_readb,
tcx_mem_readw,
tcx_mem_readl,
static CPUReadMemoryFunc *tcx_dac_read[3] = {
tcx_dac_readl,
tcx_dac_readl,
tcx_dac_readl,
};
static CPUWriteMemoryFunc *tcx_mem_write[3] = {
tcx_mem_writeb,
tcx_mem_writew,
tcx_mem_writel,
static CPUWriteMemoryFunc *tcx_dac_write[3] = {
tcx_dac_writel,
tcx_dac_writel,
tcx_dac_writel,
};
void tcx_init(DisplayState *ds, uint32_t addr)
void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
unsigned long vram_offset, int vram_size, int width, int height)
{
TCXState *s;
int tcx_io_memory;
int io_memory;
s = qemu_mallocz(sizeof(TCXState));
if (!s)
return;
return NULL;
s->ds = ds;
s->addr = addr;
ts = s;
tcx_io_memory = cpu_register_io_memory(0, tcx_mem_read, tcx_mem_write, s);
cpu_register_physical_memory(addr, 0x100000,
tcx_io_memory);
s->vram = qemu_mallocz(XSZ*YSZ);
dpy_resize(s->ds, XSZ, YSZ);
s->vram = vram_base;
s->vram_offset = vram_offset;
s->width = width;
s->height = height;
cpu_register_physical_memory(addr + 0x800000, vram_size, vram_offset);
io_memory = cpu_register_io_memory(0, tcx_dac_read, tcx_dac_write, s);
cpu_register_physical_memory(addr + 0x200000, TCX_DAC_NREGS, io_memory);
register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
qemu_register_reset(tcx_reset, s);
tcx_reset(s);
dpy_resize(s->ds, width, height);
return s;
}
void vga_screen_dump(const char *filename)
void tcx_screen_dump(void *opaque, const char *filename)
{
TCXState *s = ts;
TCXState *s = opaque;
FILE *f;
uint8_t *d, *d1;
unsigned int v;
uint8_t *d, *d1, v;
int y, x;
f = fopen(filename, "wb");
if (!f)
return -1;
fprintf(f, "P6\n%d %d\n%d\n",
XSZ, YSZ, 255);
return;
fprintf(f, "P6\n%d %d\n%d\n", s->width, s->height, 255);
d1 = s->vram;
for(y = 0; y < YSZ; y++) {
for(y = 0; y < s->height; y++) {
d = d1;
for(x = 0; x < XSZ; x++) {
for(x = 0; x < s->width; x++) {
v = *d;
fputc((v) & 0xff, f);
fputc((v) & 0xff, f);
fputc((v) & 0xff, f);
fputc(s->r[v], f);
fputc(s->g[v], f);
fputc(s->b[v], f);
d++;
}
d1 += XSZ;
d1 += MAXX;
}
fclose(f);
return;
-97
View File
@@ -1,97 +0,0 @@
/*
* QEMU Sparc timer controller emulation
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "vl.h"
/*
* Registers of hardware timer in sun4m.
*/
struct sun4m_timer_percpu {
volatile unsigned int l14_timer_limit; /* Initial value is 0x009c4000 */
volatile unsigned int l14_cur_count;
};
struct sun4m_timer_global {
volatile unsigned int l10_timer_limit;
volatile unsigned int l10_cur_count;
};
typedef struct TIMERState {
uint32_t addr;
uint32_t timer_regs[2];
int irq;
} TIMERState;
static uint32_t timer_mem_readl(void *opaque, target_phys_addr_t addr)
{
TIMERState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
switch (saddr) {
default:
return s->timer_regs[saddr];
break;
}
return 0;
}
static void timer_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
{
TIMERState *s = opaque;
uint32_t saddr;
saddr = (addr - s->addr) >> 2;
switch (saddr) {
default:
s->timer_regs[saddr] = val;
break;
}
}
static CPUReadMemoryFunc *timer_mem_read[3] = {
timer_mem_readl,
timer_mem_readl,
timer_mem_readl,
};
static CPUWriteMemoryFunc *timer_mem_write[3] = {
timer_mem_writel,
timer_mem_writel,
timer_mem_writel,
};
void timer_init(uint32_t addr, int irq)
{
int timer_io_memory;
TIMERState *s;
s = qemu_mallocz(sizeof(TIMERState));
if (!s)
return;
s->addr = addr;
s->irq = irq;
timer_io_memory = cpu_register_io_memory(0, timer_mem_read, timer_mem_write, s);
cpu_register_physical_memory(addr, 2, timer_io_memory);
}
+8 -66
View File
@@ -28,12 +28,8 @@
//#define DEBUG_VGA_MEM
//#define DEBUG_VGA_REG
//#define DEBUG_S3
//#define DEBUG_BOCHS_VBE
/* S3 VGA is deprecated - another graphic card will be emulated */
//#define CONFIG_S3VGA
/* force some bits to zero */
const uint8_t sr_mask[8] = {
(uint8_t)~0xfc,
@@ -224,11 +220,6 @@ static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
val = s->cr[s->cr_index];
#ifdef DEBUG_VGA_REG
printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
#endif
#ifdef DEBUG_S3
if (s->cr_index >= 0x20)
printf("S3: CR read index=0x%x val=0x%x\n",
s->cr_index, val);
#endif
break;
case 0x3ba:
@@ -359,43 +350,10 @@ static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
case 0x12: /* veritcal display end */
s->cr[s->cr_index] = val;
break;
#ifdef CONFIG_S3VGA
/* S3 registers */
case 0x2d:
case 0x2e:
case 0x2f:
case 0x30:
/* chip ID, cannot write */
break;
case 0x31:
/* update start address */
{
int v;
s->cr[s->cr_index] = val;
v = (val >> 4) & 3;
s->cr[0x69] = (s->cr[69] & ~0x03) | v;
}
break;
case 0x51:
/* update start address */
{
int v;
s->cr[s->cr_index] = val;
v = val & 3;
s->cr[0x69] = (s->cr[69] & ~0x0c) | (v << 2);
}
break;
#endif
default:
s->cr[s->cr_index] = val;
break;
}
#ifdef DEBUG_S3
if (s->cr_index >= 0x20)
printf("S3: CR write index=0x%x val=0x%x\n",
s->cr_index, val);
#endif
break;
case 0x3ba:
case 0x3da:
@@ -954,22 +912,10 @@ static void vga_get_offsets(VGAState *s,
{
/* compute line_offset in bytes */
line_offset = s->cr[0x13];
#ifdef CONFIG_S3VGA
{
uinr32_t v;
v = (s->cr[0x51] >> 4) & 3; /* S3 extension */
if (v == 0)
v = (s->cr[0x43] >> 2) & 1; /* S3 extension */
line_offset |= (v << 8);
}
#endif
line_offset <<= 3;
/* starting address */
start_addr = s->cr[0x0d] | (s->cr[0x0c] << 8);
#ifdef CONFIG_S3VGA
start_addr |= (s->cr[0x69] & 0x1f) << 16; /* S3 extension */
#endif
}
*pline_offset = line_offset;
*pstart_addr = start_addr;
@@ -1454,11 +1400,13 @@ static void vga_draw_graphic(VGAState *s, int full_update)
}
page0 = s->vram_offset + (addr & TARGET_PAGE_MASK);
page1 = s->vram_offset + ((addr + bwidth - 1) & TARGET_PAGE_MASK);
update = full_update | cpu_physical_memory_is_dirty(page0) |
cpu_physical_memory_is_dirty(page1);
update = full_update |
cpu_physical_memory_get_dirty(page0, VGA_DIRTY_FLAG) |
cpu_physical_memory_get_dirty(page1, VGA_DIRTY_FLAG);
if ((page1 - page0) > TARGET_PAGE_SIZE) {
/* if wide line, can use another page */
update |= cpu_physical_memory_is_dirty(page0 + TARGET_PAGE_SIZE);
update |= cpu_physical_memory_get_dirty(page0 + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
/* explicit invalidation for the hardware cursor */
update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1;
@@ -1501,7 +1449,8 @@ static void vga_draw_graphic(VGAState *s, int full_update)
}
/* reset modified pages */
if (page_max != -1) {
cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE);
cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
VGA_DIRTY_FLAG);
}
memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);
}
@@ -1594,13 +1543,6 @@ void vga_invalidate_display(void)
static void vga_reset(VGAState *s)
{
memset(s, 0, sizeof(VGAState));
#ifdef CONFIG_S3VGA
/* chip ID for 8c968 */
s->cr[0x2d] = 0x88;
s->cr[0x2e] = 0xb0;
s->cr[0x2f] = 0x01; /* XXX: check revision code */
s->cr[0x30] = 0xe1;
#endif
s->graphic_mode = -1; /* force full update */
}
+211
View File
@@ -0,0 +1,211 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf64-ia64-little", "elf64-ia64-little",
"elf64-ia64-little")
OUTPUT_ARCH(ia64)
ENTRY(_start)
SEARCH_DIR("/usr/ia64-linux/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x60000000); . = 0x60000000 + SIZEOF_HEADERS;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.rela.IA_64.pltoff : { *(.rela.IA_64.pltoff) }
.init :
{
KEEP (*(.init))
} =0x00300000010070000002000001000400
.plt : { *(.plt) }
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0x00300000010070000002000001000400
.fini :
{
KEEP (*(.fini))
} =0x00300000010070000002000001000400
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.opd : { *(.opd) }
.IA_64.unwind_info : { *(.IA_64.unwind_info* .gnu.linkonce.ia64unwi.*) }
.IA_64.unwind : { *(.IA_64.unwind* .gnu.linkonce.ia64unw.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(0x10000) + (. & (0x10000 - 1));
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(64 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { *(.preinit_array) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { *(.init_array) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { *(.fini_array) }
PROVIDE (__fini_array_end = .);
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.dynamic : { *(.dynamic) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
/* Ensure __gp is outside the range of any normal data. We need to
do this to avoid the linker optimizing the code in op.o and getting
it out of sync with the relocs that we read when processing that
file. A better solution might be to ensure that the dynamically
generated code and static qemu code share a single gp-value. */
__gp = . + 0x200000;
.got : { *(.got.plt) *(.got) }
.IA_64.pltoff : { *(.IA_64.pltoff) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.bss :
{
. += 0x400000; /* ensure .bss stuff is out of reach of gp */
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(64 / 8);
}
. = ALIGN(64 / 8);
_end = .;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/DISCARD/ : { *(.note.GNU-stack) }
}
+143
View File
@@ -0,0 +1,143 @@
/*
* QEMU keysym to keycode conversion using rdesktop keymaps
*
* Copyright (c) 2004 Johannes Schindelin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
static int get_keysym(const char *name)
{
name2keysym_t *p;
for(p = name2keysym; p->name != NULL; p++) {
if (!strcmp(p->name, name))
return p->keysym;
}
return 0;
}
#define MAX_NORMAL_KEYCODE 512
#define MAX_EXTRA_COUNT 256
typedef struct {
uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
struct {
int keysym;
uint16_t keycode;
} keysym2keycode_extra[MAX_EXTRA_COUNT];
int extra_count;
} kbd_layout_t;
static kbd_layout_t *parse_keyboard_layout(const char *language,
kbd_layout_t * k)
{
FILE *f;
char file_name[1024];
char line[1024];
int len;
snprintf(file_name, sizeof(file_name),
"%s/keymaps/%s", bios_dir, language);
if (!k)
k = qemu_mallocz(sizeof(kbd_layout_t));
if (!k)
return 0;
if (!(f = fopen(file_name, "r"))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", file_name);
return 0;
}
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;
len = strlen(line);
if (len > 0 && line[len - 1] == '\n')
line[len - 1] = '\0';
if (line[0] == '#')
continue;
if (!strncmp(line, "map ", 4))
continue;
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(line + 8, k);
} else {
char *end_of_keysym = line;
while (*end_of_keysym != 0 && *end_of_keysym != ' ')
end_of_keysym++;
if (*end_of_keysym) {
int keysym;
*end_of_keysym = 0;
keysym = get_keysym(line);
if (keysym == 0) {
// fprintf(stderr, "Warning: unknown keysym %s\n", line);
} else {
const char *rest = end_of_keysym + 1;
int keycode = strtol(rest, NULL, 0);
/* if(keycode&0x80)
keycode=(keycode<<8)^0x80e0; */
if (keysym < MAX_NORMAL_KEYCODE) {
//fprintf(stderr,"Setting keysym %s (%d) to %d\n",line,keysym,keycode);
k->keysym2keycode[keysym] = keycode;
} else {
if (k->extra_count >= MAX_EXTRA_COUNT) {
fprintf(stderr,
"Warning: Could not assign keysym %s (0x%x) because of memory constraints.\n",
line, keysym);
} else {
fprintf(stderr, "Setting %d: %d,%d\n",
k->extra_count, keysym, keycode);
k->keysym2keycode_extra[k->extra_count].
keysym = keysym;
k->keysym2keycode_extra[k->extra_count].
keycode = keycode;
k->extra_count++;
}
}
}
}
}
}
fclose(f);
return k;
}
static void *init_keyboard_layout(const char *language)
{
return parse_keyboard_layout(language, 0);
}
static int keysym2scancode(void *kbd_layout, int keysym)
{
kbd_layout_t *k = kbd_layout;
if (keysym < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[keysym] == 0)
fprintf(stderr, "Warning: no scancode found for keysym %d\n",
keysym);
return k->keysym2keycode[keysym];
} else {
int i;
#ifdef XK_ISO_Left_Tab
if (keysym == XK_ISO_Left_Tab)
keysym = XK_Tab;
#endif
for (i = 0; i < k->extra_count; i++)
if (k->keysym2keycode_extra[i].keysym == keysym)
return k->keysym2keycode_extra[i].keycode;
}
return 0;
}
+98
View File
@@ -0,0 +1,98 @@
# generated from XKB map ar
include common
map 0x401
exclam 0x02 shift
at 0x03 shift
numbersign 0x04 shift
dollar 0x05 shift
percent 0x06 shift
asciicircum 0x07 shift
ampersand 0x08 shift
asterisk 0x09 shift
parenleft 0x0a shift
parenright 0x0b shift
minus 0x0c
underscore 0x0c shift
equal 0x0d
plus 0x0d shift
Arabic_dad 0x10 altgr
Arabic_fatha 0x10 shift altgr
Arabic_sad 0x11 altgr
Arabic_fathatan 0x11 shift altgr
Arabic_theh 0x12 altgr
Arabic_damma 0x12 shift altgr
Arabic_qaf 0x13 altgr
Arabic_dammatan 0x13 shift altgr
Arabic_feh 0x14 altgr
UFEF9 0x14 shift altgr
Arabic_ghain 0x15 altgr
Arabic_hamzaunderalef 0x15 shift altgr
Arabic_ain 0x16 altgr
grave 0x16 shift altgr
Arabic_ha 0x17 altgr
division 0x17 shift altgr
Arabic_khah 0x18 altgr
multiply 0x18 shift altgr
Arabic_hah 0x19 altgr
Arabic_semicolon 0x19 shift altgr
bracketleft 0x1a
braceleft 0x1a shift
Arabic_jeem 0x1a altgr
bracketright 0x1b
braceright 0x1b shift
Arabic_dal 0x1b altgr
Arabic_sheen 0x1e altgr
backslash 0x1e shift altgr
Arabic_seen 0x1f altgr
Arabic_yeh 0x20 altgr
bracketleft 0x20 shift altgr
Arabic_beh 0x21 altgr
bracketright 0x21 shift altgr
Arabic_lam 0x22 altgr
UFEF7 0x22 shift altgr
Arabic_alef 0x23 altgr
Arabic_hamzaonalef 0x23 shift altgr
Arabic_teh 0x24 altgr
Arabic_tatweel 0x24 shift altgr
Arabic_noon 0x25 altgr
Arabic_comma 0x25 shift altgr
Arabic_meem 0x26 altgr
slash 0x26 shift altgr
semicolon 0x27
colon 0x27 shift
Arabic_kaf 0x27 altgr
apostrophe 0x28
quotedbl 0x28 shift
Arabic_tah 0x28 altgr
grave 0x29
asciitilde 0x29 shift
Arabic_thal 0x29 altgr
Arabic_shadda 0x29 shift altgr
backslash 0x2b
bar 0x2b shift
less 0x2b altgr
greater 0x2b shift altgr
Arabic_hamzaonyeh 0x2c altgr
asciitilde 0x2c shift altgr
Arabic_hamza 0x2d altgr
Arabic_sukun 0x2d shift altgr
Arabic_hamzaonwaw 0x2e altgr
Arabic_kasra 0x2e shift altgr
Arabic_ra 0x2f altgr
Arabic_kasratan 0x2f shift altgr
UFEFB 0x30 altgr
UFEF5 0x30 shift altgr
Arabic_alefmaksura 0x31 altgr
Arabic_maddaonalef 0x31 shift altgr
Arabic_tehmarbuta 0x32 altgr
apostrophe 0x32 shift altgr
comma 0x33
less 0x33 shift
Arabic_waw 0x33 altgr
period 0x34
greater 0x34 shift
Arabic_zain 0x34 altgr
slash 0x35
question 0x35 shift
Arabic_zah 0x35 altgr
Arabic_question_mark 0x35 shift altgr
+157
View File
@@ -0,0 +1,157 @@
include modifiers
#
# Top row
#
1 0x2
2 0x3
3 0x4
4 0x5
5 0x6
6 0x7
7 0x8
8 0x9
9 0xa
0 0xb
BackSpace 0xe
#
# QWERTY first row
#
Tab 0xf localstate
ISO_Left_Tab 0xf shift
q 0x10 addupper
w 0x11 addupper
e 0x12 addupper
r 0x13 addupper
t 0x14 addupper
y 0x15 addupper
u 0x16 addupper
i 0x17 addupper
o 0x18 addupper
p 0x19 addupper
#
# QWERTY second row
#
a 0x1e addupper
s 0x1f addupper
d 0x20 addupper
f 0x21 addupper
g 0x22 addupper
h 0x23 addupper
j 0x24 addupper
k 0x25 addupper
l 0x26 addupper
Return 0x1c localstate
#
# QWERTY third row
#
z 0x2c addupper
x 0x2d addupper
c 0x2e addupper
v 0x2f addupper
b 0x30 addupper
n 0x31 addupper
m 0x32 addupper
space 0x39 localstate
less 0x56
greater 0x56 shift
bar 0x56 altgr
brokenbar 0x56 shift altgr
#
# Esc and Function keys
#
Escape 0x1 localstate
F1 0x3b localstate
F2 0x3c localstate
F3 0x3d localstate
F4 0x3e localstate
F5 0x3f localstate
F6 0x40 localstate
F7 0x41 localstate
F8 0x42 localstate
F9 0x43 localstate
F10 0x44 localstate
F11 0x57 localstate
F12 0x58 localstate
# Printscreen, Scrollock and Pause
# Printscreen really requires four scancodes (0xe0, 0x2a, 0xe0, 0x37),
# but (0xe0, 0x37) seems to work.
Print 0xb7 localstate
Sys_Req 0xb7 localstate
Execute 0xb7 localstate
Scroll_Lock 0x46
#
# Insert - PgDown
#
Insert 0xd2 localstate
Delete 0xd3 localstate
Home 0xc7 localstate
End 0xcf localstate
Page_Up 0xc9 localstate
Page_Down 0xd1 localstate
#
# Arrow keys
#
Left 0xcb localstate
Up 0xc8 localstate
Down 0xd0 localstate
Right 0xcd localstate
#
# Numpad
#
Num_Lock 0x45
KP_Divide 0xb5
KP_Multiply 0x37
KP_Subtract 0x4a
KP_Add 0x4e
KP_Enter 0x9c
KP_Decimal 0x53 numlock
KP_Separator 0x53 numlock
KP_Delete 0x53
KP_0 0x52 numlock
KP_Insert 0x52
KP_1 0x4f numlock
KP_End 0x4f
KP_2 0x50 numlock
KP_Down 0x50
KP_3 0x51 numlock
KP_Next 0x51
KP_4 0x4b numlock
KP_Left 0x4b
KP_5 0x4c numlock
KP_Begin 0x4c
KP_6 0x4d numlock
KP_Right 0x4d
KP_7 0x47 numlock
KP_Home 0x47
KP_8 0x48 numlock
KP_Up 0x48
KP_9 0x49 numlock
KP_Prior 0x49
Caps_Lock 0x3a
#
# Inhibited keys
#
Multi_key 0x0 inhibit
+120
View File
@@ -0,0 +1,120 @@
# generated from XKB map dk
include common
map 0x406
exclam 0x02 shift
exclamdown 0x02 altgr
onesuperior 0x02 shift altgr
quotedbl 0x03 shift
at 0x03 altgr
twosuperior 0x03 shift altgr
numbersign 0x04 shift
sterling 0x04 altgr
threesuperior 0x04 shift altgr
currency 0x05 shift
dollar 0x05 altgr
onequarter 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
cent 0x06 shift altgr
ampersand 0x07 shift
yen 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
division 0x08 shift altgr
parenleft 0x09 shift
bracketleft 0x09 altgr
guillemotleft 0x09 shift altgr
parenright 0x0a shift
bracketright 0x0a altgr
guillemotright 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
plus 0x0c
question 0x0c shift
plusminus 0x0c altgr
questiondown 0x0c shift altgr
dead_acute 0x0d
dead_grave 0x0d shift
bar 0x0d altgr
brokenbar 0x0d shift altgr
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
cent 0x12 shift altgr
registered 0x13 altgr
thorn 0x14 altgr
THORN 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oe 0x18 altgr
OE 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
aring 0x1a
Aring 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
dead_diaeresis 0x1b
dead_circumflex 0x1b shift
dead_tilde 0x1b altgr
dead_caron 0x1b shift altgr
ordfeminine 0x1e altgr
masculine 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
ae 0x27
AE 0x27 shift
oslash 0x28
Ooblique 0x28 shift
dead_caron 0x28 shift altgr
onehalf 0x29
section 0x29 shift
threequarters 0x29 altgr
paragraph 0x29 shift altgr
apostrophe 0x2b
asterisk 0x2b shift
dead_doubleacute 0x2b altgr
multiply 0x2b shift altgr
guillemotleft 0x2c altgr
guillemotright 0x2d altgr
copyright 0x2e altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
dead_cedilla 0x33 altgr
dead_ogonek 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
dead_abovedot 0x34 shift altgr
minus 0x35
underscore 0x35 shift
hyphen 0x35 altgr
macron 0x35 shift altgr
nobreakspace 0x39 altgr
less 0x56
greater 0x56 shift
backslash 0x56 altgr
notsign 0x56 shift altgr
+114
View File
@@ -0,0 +1,114 @@
# generated from XKB map de
include common
map 0x407
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
quotedbl 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
section 0x04 shift
threesuperior 0x04 altgr
sterling 0x04 shift altgr
dollar 0x05 shift
onequarter 0x05 altgr
currency 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
ampersand 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
parenleft 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
parenright 0x0a shift
bracketright 0x0a altgr
plusminus 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
ssharp 0x0c
question 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
acute 0x0d
dead_acute 0x0d
grave 0x0d shift
dead_grave 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
z 0x15 addupper
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
udiaeresis 0x1a
Udiaeresis 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
plus 0x1b
asterisk 0x1b shift
asciitilde 0x1b altgr
dead_tilde 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
odiaeresis 0x27
Odiaeresis 0x27 shift
dead_doubleacute 0x27 altgr
adiaeresis 0x28
Adiaeresis 0x28 shift
dead_caron 0x28 shift altgr
asciicircum 0x29
dead_circumflex 0x29
degree 0x29 shift
notsign 0x29 altgr
numbersign 0x2b
apostrophe 0x2b shift
dead_breve 0x2b shift altgr
y 0x2c addupper
guillemotleft 0x2c altgr
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
minus 0x35
underscore 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+169
View File
@@ -0,0 +1,169 @@
# rdesktop Swiss-German (de-ch) keymap file
# 2003-06-03 by noldi@tristar.ch
#
include common
map 0x00000807
#
# Scan Code 1
section 0x29
degree 0x29 shift
notsign 0x29 altgr inhibit
#
# Scan Code 2
plus 0x2 shift
brokenbar 0x02 altgr
#
# Scan Code 3
quotedbl 0x03 shift
at 0x03 altgr
#
# Scan Code 4
asterisk 0x04 shift
numbersign 0x04 altgr
#
# Scan Code 5
ccedilla 0x05 shift
onequarter 0x05 altgr inhibit
#
# Scan Code 6
percent 0x06 shift
onehalf 0x06 altgr inhibit
#
# Scan Code 7
ampersand 0x07 shift
notsign 0x07 altgr
#
# Scan Code 8
slash 0x08 shift
bar 0x08 altgr
#
# Scan Code 9
parenleft 0x09 shift
cent 0x09 altgr
#
# Scan Code 10
parenright 0x0a shift
#
# Scan Code 11
equal 0x0b shift
braceright 0x0b altgr inhibit
#
# Scan Code 12
apostrophe 0x0c
question 0x0c shift
dead_acute 0x0c altgr
#
# Scan Code 13
dead_circumflex 0x0d
dead_grave 0x0d shift
dead_tilde 0x0d altgr
#
# Scan Code 19
EuroSign 0x12 altgr
#
# Scan Code 22
z 0x15 addupper
#
# Scan Code 27
udiaeresis 0x1a
egrave 0x1a shift
bracketleft 0x1a altgr
#
# Scan Code 28
dead_diaeresis 0x1b
exclam 0x1b shift
bracketright 0x1b altgr
#
# Scan Code 40
odiaeresis 0x27
eacute 0x27 shift
#
# Scan Code 41
adiaeresis 0x28
agrave 0x28 shift
braceleft 0x28 altgr
#
# Scan Code 42 (only on international keyboards)
dollar 0x2b
sterling 0x2b shift
braceright 0x2b altgr
#
# Scan Code 45 (only on international keyboards)
backslash 0x56 altgr
#
# Scan Code 46
y 0x2c addupper
#
# Scan Code 53
comma 0x33
semicolon 0x33 shift
#
# Scan Code 54
period 0x34
colon 0x34 shift
#
# Scan Code 55
minus 0x35
underscore 0x35 shift
#
# Suppress Windows unsupported AltGr keys
#
# Scan Code 17
paragraph 0x10 altgr inhibit
#
# Scan Code 21
tslash 0x14 altgr inhibit
#
# Scan Code 22
leftarrow 0x15 altgr inhibit
#
# Scan Code 23
downarrow 0x16 altgr inhibit
#
# Scan Code 24
rightarrow 0x17 altgr inhibit
#
# Scan Code 25
oslash 0x18 altgr inhibit
#
# Scan Code 26
thorn 0x19 altgr inhibit
#
# Scan Code 31
ae 0x1e altgr inhibit
#
# Scan Code 32
ssharp 0x1f altgr inhibit
#
# Scan Code 33
eth 0x20 altgr inhibit
#
# Scan Code 34
dstroke 0x21 altgr inhibit
#
# Scan Code 35
eng 0x22 altgr inhibit
#
# Scan Code 36
hstroke 0x23 altgr inhibit
#
# Scan Code 38
kra 0x25 altgr inhibit
#
# Scan Code 39
lstroke 0x26 altgr inhibit
#
# Scan Code 46
guillemotleft 0x2c altgr inhibit
#
# Scan Code 47
guillemotright 0x2d altgr inhibit
#
# Scan Code 49
leftdoublequotemark 0x2f altgr inhibit
#
# Scan Code 50
rightdoublequotemark 0x30 altgr inhibit
#
# Scan Code 52
mu 0x32 altgr inhibit
+119
View File
@@ -0,0 +1,119 @@
# generated from XKB map gb
include common
map 0x809
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
quotedbl 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
sterling 0x04 shift
threesuperior 0x04 altgr
dollar 0x05 shift
EuroSign 0x05 altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
asciicircum 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
ampersand 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
asterisk 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
parenleft 0x0a shift
bracketright 0x0a altgr
plusminus 0x0a shift altgr
parenright 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
minus 0x0c
underscore 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
equal 0x0d
plus 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
bracketleft 0x1a
braceleft 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
bracketright 0x1b
braceright 0x1b shift
dead_tilde 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
semicolon 0x27
colon 0x27 shift
dead_acute 0x27 altgr
dead_doubleacute 0x27 shift altgr
apostrophe 0x28
at 0x28 shift
dead_circumflex 0x28 altgr
dead_caron 0x28 shift altgr
grave 0x29
notsign 0x29 shift
bar 0x29 altgr
numbersign 0x2b
asciitilde 0x2b shift
dead_grave 0x2b altgr
dead_breve 0x2b shift altgr
guillemotleft 0x2c altgr
less 0x2c shift altgr
guillemotright 0x2d altgr
greater 0x2d shift altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
less 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
greater 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
slash 0x35
question 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
backslash 0x56
bar 0x56 shift
+35
View File
@@ -0,0 +1,35 @@
# generated from XKB map us
include common
map 0x409
exclam 0x02 shift
at 0x03 shift
numbersign 0x04 shift
dollar 0x05 shift
percent 0x06 shift
asciicircum 0x07 shift
ampersand 0x08 shift
asterisk 0x09 shift
parenleft 0x0a shift
parenright 0x0b shift
minus 0x0c
underscore 0x0c shift
equal 0x0d
plus 0x0d shift
bracketleft 0x1a
braceleft 0x1a shift
bracketright 0x1b
braceright 0x1b shift
semicolon 0x27
colon 0x27 shift
apostrophe 0x28
quotedbl 0x28 shift
grave 0x29
asciitilde 0x29 shift
backslash 0x2b
bar 0x2b shift
comma 0x33
less 0x33 shift
period 0x34
greater 0x34 shift
slash 0x35
question 0x35 shift
+105
View File
@@ -0,0 +1,105 @@
# generated from XKB map es
include common
map 0x40a
exclam 0x02 shift
bar 0x02 altgr
quotedbl 0x03 shift
at 0x03 altgr
oneeighth 0x03 shift altgr
periodcentered 0x04 shift
numbersign 0x04 altgr
sterling 0x04 shift altgr
dollar 0x05 shift
asciitilde 0x05 altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
ampersand 0x07 shift
notsign 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
seveneighths 0x08 shift altgr
parenleft 0x09 shift
trademark 0x09 shift altgr
parenright 0x0a shift
plusminus 0x0a shift altgr
equal 0x0b shift
degree 0x0b shift altgr
apostrophe 0x0c
question 0x0c shift
exclamdown 0x0d
questiondown 0x0d shift
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
dead_grave 0x1a
dead_circumflex 0x1a shift
bracketleft 0x1a altgr
dead_abovering 0x1a shift altgr
plus 0x1b
asterisk 0x1b shift
bracketright 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
ntilde 0x27
Ntilde 0x27 shift
dead_doubleacute 0x27 shift altgr
dead_acute 0x28
dead_diaeresis 0x28 shift
braceleft 0x28 altgr
masculine 0x29
ordfeminine 0x29 shift
backslash 0x29 altgr
ccedilla 0x2b
Ccedilla 0x2b shift
braceright 0x2b altgr
dead_breve 0x2b shift altgr
guillemotleft 0x2c altgr
less 0x56
greater 0x56 shift
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
division 0x34 shift altgr
minus 0x35
underscore 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+86
View File
@@ -0,0 +1,86 @@
map 0x00000425
include common
#
# Top row
#
dead_caron 0x29
dead_tilde 0x29 shift
# 1
exclam 0x2 shift
# 2
quotedbl 0x3 shift
at 0x3 altgr
# 3
numbersign 0x4 shift
sterling 0x4 altgr
# 4
currency 0x5 shift
dollar 0x5 altgr
# 5
percent 0x6 shift
# 6
ampersand 0x7 shift
# 7
slash 0x8 shift
braceleft 0x8 altgr
# 8
parenleft 0x9 shift
bracketleft 0x9 altgr
# 9
parenright 0xa shift
bracketright 0xa altgr
# 0
equal 0xb shift
braceright 0xb altgr
plus 0xc
question 0xc shift
backslash 0xc altgr
acute 0xd
dead_acute 0xd
grave 0xd shift
dead_grave 0xd shift
#
# QWERTY first row
#
EuroSign 0x12 altgr
udiaeresis 0x1a
Udiaeresis 0x1a shift
otilde 0x1b
Otilde 0x1b shift
section 0x1b altgr
#
# QWERTY second row
#
scaron 0x1f altgr
Scaron 0x1f altgr shift
odiaeresis 0x27
Odiaeresis 0x27 shift
adiaeresis 0x28
Adiaeresis 0x28 shift
asciicircum 0x28 altgr
apostrophe 0x2b
asterisk 0x2b shift
onehalf 0x2b altgr
#
# QWERTY third row
#
less 0x56
greater 0x56 shift
bar 0x56 altgr
zcaron 0x2c altgr
Zcaron 0x2c altgr shift
comma 0x33
semicolon 0x33 shift
period 0x34
colon 0x34 shift
minus 0x35
underscore 0x35 shift
+124
View File
@@ -0,0 +1,124 @@
# generated from XKB map se_FI
include common
map 0x40b
exclam 0x02 shift
exclamdown 0x02 altgr
onesuperior 0x02 shift altgr
quotedbl 0x03 shift
at 0x03 altgr
twosuperior 0x03 shift altgr
numbersign 0x04 shift
sterling 0x04 altgr
threesuperior 0x04 shift altgr
currency 0x05 shift
dollar 0x05 altgr
onequarter 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
cent 0x06 shift altgr
ampersand 0x07 shift
yen 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
division 0x08 shift altgr
parenleft 0x09 shift
bracketleft 0x09 altgr
guillemotleft 0x09 shift altgr
parenright 0x0a shift
bracketright 0x0a altgr
guillemotright 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
plus 0x0c
question 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
dead_acute 0x0d
dead_grave 0x0d shift
plusminus 0x0d altgr
notsign 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
cent 0x12 shift altgr
registered 0x13 altgr
thorn 0x14 altgr
THORN 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oe 0x18 altgr
OE 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
aring 0x1a
Aring 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
dead_diaeresis 0x1b
dead_circumflex 0x1b shift
dead_tilde 0x1b altgr
dead_caron 0x1b shift altgr
ordfeminine 0x1e altgr
masculine 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
ampersand 0x25 shift altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
odiaeresis 0x27
Odiaeresis 0x27 shift
oslash 0x27 altgr
Ooblique 0x27 shift altgr
adiaeresis 0x28
Adiaeresis 0x28 shift
ae 0x28 altgr
AE 0x28 shift altgr
section 0x29
onehalf 0x29 shift
paragraph 0x29 altgr
threequarters 0x29 shift altgr
apostrophe 0x2b
asterisk 0x2b shift
acute 0x2b altgr
multiply 0x2b shift altgr
guillemotleft 0x2c altgr
less 0x2c shift altgr
guillemotright 0x2d altgr
greater 0x2d shift altgr
copyright 0x2e altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
apostrophe 0x30 shift altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
dead_cedilla 0x33 altgr
dead_ogonek 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
dead_abovedot 0x34 shift altgr
minus 0x35
underscore 0x35 shift
hyphen 0x35 altgr
macron 0x35 shift altgr
nobreakspace 0x39 altgr
+77
View File
@@ -0,0 +1,77 @@
map 0x438
include common
#
# Top row
#
onehalf 0x29
section 0x29 shift
# 1
exclam 0x2 shift
# 2
quotedbl 0x3 shift
at 0x3 altgr
# 3
numbersign 0x4 shift
sterling 0x4 altgr
# 4
currency 0x5 shift
dollar 0x5 altgr
# 5
percent 0x6 shift
# 6
ampersand 0x7 shift
# 7
slash 0x8 shift
braceleft 0x8 altgr
# 8
parenleft 0x9 shift
bracketleft 0x9 altgr
# 9
parenright 0xa shift
bracketright 0xa altgr
# 0
equal 0xb shift
braceright 0xb altgr
plus 0xc
question 0xc shift
plusminus 0xc altgr
bar 0xd altgr
dead_acute 0xd
#
# QWERTY first row
#
EuroSign 0x12 altgr
aring 0x1a
Aring 0x1a shift
eth 0x1b addupper
asciitilde 0x1b altgr
#
# QWERTY second row
#
ae 0x27 addupper
oslash 0x28
Ooblique 0x28 shift
apostrophe 0x2b
asterisk 0x2b shift
#
# QWERTY third row
#
less 0x56
greater 0x56 shift
backslash 0x56 altgr
comma 0x33
semicolon 0x33 shift
period 0x34
colon 0x34 shift
minus 0x35
underscore 0x35 shift
+181
View File
@@ -0,0 +1,181 @@
include common
map 0x40c
#
# Top row
#
twosuperior 0x29
notsign 0x29 altgr
ampersand 0x02
1 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
eacute 0x03
2 0x03 shift
asciitilde 0x03 altgr
oneeighth 0x03 shift altgr
quotedbl 0x04
3 0x04 shift
numbersign 0x04 altgr
apostrophe 0x05
4 0x05 shift
braceleft 0x05 altgr
parenleft 0x06
5 0x06 shift
bracketleft 0x06 altgr
threeeighths 0x06 shift altgr
minus 0x07
6 0x07 shift
bar 0x07 altgr
fiveeighths 0x07 shift altgr
egrave 0x08
7 0x08 shift
grave 0x08 altgr
seveneighths 0x08 shift altgr
underscore 0x09
8 0x09 shift
backslash 0x09 altgr
trademark 0x09 shift altgr
ccedilla 0x0a
9 0x0a shift
asciicircum 0x0a altgr
plusminus 0x0a shift altgr
agrave 0x0b
0 0x0b shift
at 0x0b altgr
parenright 0x0c
degree 0x0c shift
bracketright 0x0c altgr
questiondown 0x0c shift altgr
equal 0x0d
plus 0x0d shift
braceright 0x0d altgr
dead_ogonek 0x0d shift altgr
#
# AZERTY first row
#
a 0x10 addupper
ae 0x10 altgr
AE 0x10 shift altgr
z 0x11 addupper
guillemotleft 0x11 altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
dead_circumflex 0x1a
dead_diaeresis 0x1a shift
dead_abovering 0x1a shift altgr
dollar 0x1b
sterling 0x1b shift
currency 0x1b altgr
dead_macron 0x1b shift altgr
#
# AZERTY second row
#
q 0x1e addupper
Greek_OMEGA 0x1e shift altgr
ssharp 0x1f altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
m 0x27 addupper
masculine 0x27 shift altgr
ugrave 0x28
percent 0x28 shift
dead_caron 0x28 shift altgr
asterisk 0x2b
mu 0x2b shift
dead_grave 0x2b altgr
dead_breve 0x2b shift altgr
#
# AZERTY third row
#
less 0x56
greater 0x56 shift
w 0x2c addupper
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
rightdoublequotemark 0x30 altgr
comma 0x32
question 0x32 shift
dead_acute 0x32 altgr
dead_doubleacute 0x32 shift altgr
semicolon 0x33
period 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
colon 0x34
slash 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
exclam 0x35
section 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+140
View File
@@ -0,0 +1,140 @@
# generated from XKB map be
include common
map 0x80c
ampersand 0x02
1 0x02 shift
bar 0x02 altgr
exclamdown 0x02 shift altgr
eacute 0x03
2 0x03 shift
at 0x03 altgr
oneeighth 0x03 shift altgr
quotedbl 0x04
3 0x04 shift
numbersign 0x04 altgr
sterling 0x04 shift altgr
apostrophe 0x05
4 0x05 shift
onequarter 0x05 altgr
dollar 0x05 shift altgr
parenleft 0x06
5 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
section 0x07
6 0x07 shift
asciicircum 0x07 altgr
fiveeighths 0x07 shift altgr
egrave 0x08
7 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
exclam 0x09
8 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
ccedilla 0x0a
9 0x0a shift
braceleft 0x0a altgr
plusminus 0x0a shift altgr
agrave 0x0b
0 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
parenright 0x0c
degree 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
minus 0x0d
underscore 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
a 0x10 addupper
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
z 0x11 addupper
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
cent 0x12 shift altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
dead_circumflex 0x1a
dead_diaeresis 0x1a shift
bracketleft 0x1a altgr
dead_abovering 0x1a shift altgr
dollar 0x1b
asterisk 0x1b shift
bracketright 0x1b altgr
dead_macron 0x1b shift altgr
q 0x1e addupper
ae 0x1e altgr
AE 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
ampersand 0x25 shift altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
m 0x27 addupper
dead_acute 0x27 altgr
dead_doubleacute 0x27 shift altgr
ugrave 0x28
percent 0x28 shift
dead_acute 0x28 altgr
dead_caron 0x28 shift altgr
twosuperior 0x29
threesuperior 0x29 shift
notsign 0x29 altgr
mu 0x2b
sterling 0x2b shift
dead_grave 0x2b altgr
dead_breve 0x2b shift altgr
w 0x2c addupper
guillemotleft 0x2c altgr
less 0x2c shift altgr
guillemotright 0x2d altgr
greater 0x2d shift altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
apostrophe 0x30 shift altgr
comma 0x32
question 0x32 shift
dead_cedilla 0x32 altgr
masculine 0x32 shift altgr
semicolon 0x33
period 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
colon 0x34
slash 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
equal 0x35
plus 0x35 shift
dead_tilde 0x35 altgr
dead_abovedot 0x35 shift altgr
backslash 0x56 altgr
+50
View File
@@ -0,0 +1,50 @@
# Canadian French
# By Simon Germain
include common
map 0xc0c
backslash 0x29 altgr
plusminus 0x2 altgr
at 0x3 altgr
sterling 0x4 altgr
cent 0x5 altgr
currency 0x6 altgr
notsign 0x7 altgr
bar 0x29 shift
twosuperior 0x9 altgr
threesuperior 0xa altgr
onequarter 0xb altgr
onehalf 0xc altgr
threequarters 0xd altgr
section 0x18 altgr
paragraph 0x19 altgr
bracketleft 0x1a altgr
bracketright 0x1b altgr
asciitilde 0x27 altgr
braceleft 0x28 altgr
braceright 0x2b altgr
less 0x2b
greater 0x2b shift
guillemotleft 0x56
guillemotright 0x56 shift
degree 0x56 altgr
mu 0x32 altgr
eacute 0x35
dead_acute 0x35 altgr
dead_grave 0x28
dead_circumflex 0x1a
dead_circumflex 0x1a shift
dead_cedilla 0x1b
dead_diaeresis 0x1b shift
exclam 0x2 shift
quotedbl 0x3 shift
slash 0x4 shift
dollar 0x5 shift
percent 0x6 shift
question 0x7 shift
ampersand 0x8 shift
asterisk 0x9 shift
parenleft 0xa shift
parenright 0xb shift
underscore 0xc shift
plus 0xd shift
+114
View File
@@ -0,0 +1,114 @@
# generated from XKB map fr_CH
include common
map 0x100c
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
quotedbl 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
section 0x04 shift
threesuperior 0x04 altgr
sterling 0x04 shift altgr
dollar 0x05 shift
onequarter 0x05 altgr
currency 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
ampersand 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
parenleft 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
parenright 0x0a shift
bracketright 0x0a altgr
plusminus 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
ssharp 0x0c
question 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
acute 0x0d
dead_acute 0x0d
grave 0x0d shift
dead_grave 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
z 0x15 addupper
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
udiaeresis 0x1a
Udiaeresis 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
plus 0x1b
asterisk 0x1b shift
asciitilde 0x1b altgr
dead_tilde 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
odiaeresis 0x27
Odiaeresis 0x27 shift
dead_doubleacute 0x27 altgr
adiaeresis 0x28
Adiaeresis 0x28 shift
dead_caron 0x28 shift altgr
asciicircum 0x29
dead_circumflex 0x29
degree 0x29 shift
notsign 0x29 altgr
numbersign 0x2b
apostrophe 0x2b shift
dead_breve 0x2b shift altgr
y 0x2c addupper
guillemotleft 0x2c altgr
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
minus 0x35
underscore 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+125
View File
@@ -0,0 +1,125 @@
# generated from XKB map hr
include common
map 0x41a
exclam 0x02 shift
asciitilde 0x02 altgr
dead_tilde 0x02 shift altgr
quotedbl 0x03 shift
dead_caron 0x03 altgr
caron 0x03 shift altgr
numbersign 0x04 shift
asciicircum 0x04 altgr
dead_circumflex 0x04 shift altgr
dollar 0x05 shift
dead_breve 0x05 altgr
breve 0x05 shift altgr
percent 0x06 shift
degree 0x06 altgr
dead_abovering 0x06 shift altgr
ampersand 0x07 shift
dead_ogonek 0x07 altgr
ogonek 0x07 shift altgr
slash 0x08 shift
grave 0x08 altgr
dead_grave 0x08 shift altgr
parenleft 0x09 shift
dead_abovedot 0x09 altgr
abovedot 0x09 shift altgr
parenright 0x0a shift
dead_acute 0x0a altgr
apostrophe 0x0a shift altgr
equal 0x0b shift
dead_doubleacute 0x0b altgr
doubleacute 0x0b shift altgr
apostrophe 0x0c
question 0x0c shift
dead_diaeresis 0x0c altgr
diaeresis 0x0c shift altgr
plus 0x0d
asterisk 0x0d shift
dead_cedilla 0x0d altgr
cedilla 0x0d shift altgr
backslash 0x10 altgr
Greek_OMEGA 0x10 shift altgr
bar 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
z 0x15 addupper
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
scaron 0x1a
Scaron 0x1a shift
division 0x1a altgr
dead_abovering 0x1a shift altgr
dstroke 0x1b
Dstroke 0x1b shift
multiply 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
bracketleft 0x21 altgr
ordfeminine 0x21 shift altgr
bracketright 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
lstroke 0x25 altgr
ampersand 0x25 shift altgr
Lstroke 0x26 altgr
ccaron 0x27
Ccaron 0x27 shift
dead_acute 0x27 altgr
dead_doubleacute 0x27 shift altgr
cacute 0x28
Cacute 0x28 shift
ssharp 0x28 altgr
dead_caron 0x28 shift altgr
dead_cedilla 0x29
dead_diaeresis 0x29 shift
notsign 0x29 altgr
zcaron 0x2b
Zcaron 0x2b shift
currency 0x2b altgr
dead_breve 0x2b shift altgr
y 0x2c addupper
guillemotleft 0x2c altgr
less 0x2c shift altgr
guillemotright 0x2d altgr
greater 0x2d shift altgr
cent 0x2e altgr
copyright 0x2e shift altgr
at 0x2f altgr
grave 0x2f shift altgr
braceleft 0x30 altgr
apostrophe 0x30 shift altgr
braceright 0x31 altgr
section 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
minus 0x35
underscore 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+115
View File
@@ -0,0 +1,115 @@
# Hungarian keyboard layout (QWERTZ)
# Created by: The NeverGone <never@delfin.klte.hu>
include common
map 0x40e
# AltGr keys:
notsign 0x29 altgr
asciitilde 0x02 altgr
caron 0x03 altgr
asciicircum 0x04 altgr
breve 0x05 altgr
degree 0x06 altgr
ogonek 0x07 altgr
grave 0x08 altgr
abovedot 0x09 altgr
acute 0x0a altgr
doubleacute 0x0b altgr
diaeresis 0x0c altgr
cedilla 0x0d altgr
backslash 0x10 altgr
bar 0x11 altgr
EuroSign 0x12 altgr
Iacute 0x17 altgr
division 0x1a altgr
multiply 0x1b altgr
dstroke 0x1f altgr
Dstroke 0x20 altgr
bracketleft 0x21 altgr
bracketright 0x22 altgr
iacute 0x24 altgr
lstroke 0x25 altgr
Lstroke 0x26 altgr
dollar 0x27 altgr
ssharp 0x28 altgr
currency 0x2b altgr
less 0x56 altgr
greater 0x2c altgr
numbersign 0x2d altgr
ampersand 0x2e altgr
at 0x2f altgr
braceleft 0x30 altgr
braceright 0x31 altgr
semicolon 0x33 altgr
asterisk 0x35 altgr
# Shift keys:
section 0x29 shift
apostrophe 0x02 shift
quotedbl 0x03 shift
plus 0x04 shift
exclam 0x05 shift
percent 0x06 shift
slash 0x07 shift
equal 0x08 shift
parenleft 0x09 shift
parenright 0x0a shift
Odiaeresis 0x0b shift
Udiaeresis 0x0c shift
Oacute 0x0d shift
Z 0x15 shift
Odoubleacute 0x1a shift
Uacute 0x1b shift
Eacute 0x27 shift
Aacute 0x28 shift
Udoubleacute 0x2b shift
Y 0x2c shift
question 0x33 shift
colon 0x34 shift
underscore 0x35 shift
F13 0x3b shift
F14 0x3c shift
F15 0x3d shift
F16 0x3e shift
F17 0x3f shift
F18 0x40 shift
F19 0x41 shift
F20 0x42 shift
F21 0x43 shift
F22 0x44 shift
F23 0x57 shift
F24 0x58 shift
# Ctrl keys:
F25 0x3b ctrl
F26 0x3c ctrl
F27 0x3d ctrl
F28 0x3e ctrl
F29 0x3f ctrl
F30 0x40 ctrl
F31 0x41 ctrl
F32 0x42 ctrl
F33 0x43 ctrl
F34 0x44 ctrl
F35 0x57 ctrl
#NoSymbol 0x58 ctrl
0 0x29
odiaeresis 0x0b
udiaeresis 0x0c
oacute 0x0d
z 0x15
odoubleacute 0x1a
uacute 0x1b
eacute 0x27
aacute 0x28
udoubleacute 0x2b
y 0x2c
comma 0x33
period 0x34
minus 0x35
+140
View File
@@ -0,0 +1,140 @@
# 2004-03-16 Halldór Guðmundsson and Morten Lange
# Keyboard definition file for the Icelandic keyboard
# to be used in rdesktop 1.3.x ( See rdesktop.org)
# generated from XKB map de, and changed manually
# Location for example /usr/local/share/rdesktop/keymaps/is
include common
map 0x40f
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
quotedbl 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
#section 0x04 shift
numbersign 0x04 shift
threesuperior 0x04 altgr
sterling 0x04 shift altgr
dollar 0x05 shift
onequarter 0x05 altgr
currency 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
ampersand 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
parenleft 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
parenright 0x0a shift
bracketright 0x0a altgr
plusminus 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
#ssharp 0x0c
odiaeresis 0x0c
#question 0x0c shift
Odiaeresis 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
#acute 0x0d
minus 0x0d
#dead_acute 0x0d
#grave 0x0d shift
#dead_grave 0x0d shift
underscore 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
EuroSign 0x12 altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
#z 0x15 addupper
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
#thorn 0x19 altgr
#THORN 0x19 shift altgr
#udiaeresis 0x1a
#Udiaeresis 0x1a shift
#dead_diaeresis 0x1a altgr
#dead_abovering 0x1a shift altgr
eth 0x1a
ETH 0x1a shift
apostrophe 0x1b
question 0x1b shift
#plus 0x1b
#asterisk 0x1b shift
asciitilde 0x1b altgr
#grave 0x1b altgr
#dead_tilde 0x1b altgr
#dead_macron 0x1b shift altgr
#ae 0x1e altgr
#AE 0x1e shift altgr
#eth 0x20 altgr
#eth 0x20
#ETH 0x20 shift altgr
#ETH 0x20 shift
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
#adiaeresis 0x27
#Adiaeresis 0x27 shift
ae 0x27
AE 0x27 shift
dead_doubleacute 0x27 altgr
#adiaeresis 0x28
#Adiaeresis 0x28 shift
#dead_caron 0x28 shift altgr
#asciicircum 0x29
acute 0x28
dead_acute 0x28
#dead_circumflex 0x29
#degree 0x29 shift
#notsign 0x29 altgr
plus 0x2b
asterisk 0x2b shift
grave 0x2b altgr
#numbersign 0x2b
#apostrophe 0x2b shift
#dead_breve 0x2b shift altgr
#y 0x2c addupper
guillemotleft 0x2c altgr
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
#minus 0x35
#underscore 0x35 shift
thorn 0x35
THORN 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+115
View File
@@ -0,0 +1,115 @@
# generated from XKB map it
include common
map 0x410
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
quotedbl 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
sterling 0x04 shift
threesuperior 0x04 altgr
dollar 0x05 shift
onequarter 0x05 altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
ampersand 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
slash 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
parenleft 0x09 shift
trademark 0x09 shift altgr
parenright 0x0a shift
plusminus 0x0a shift altgr
equal 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
apostrophe 0x0c
question 0x0c shift
grave 0x0c altgr
questiondown 0x0c shift altgr
igrave 0x0d
asciicircum 0x0d shift
asciitilde 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
EuroSign 0x12 altgr
cent 0x12 shift altgr
paragraph 0x13 altgr
registered 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
downarrow 0x16 altgr
uparrow 0x16 shift altgr
rightarrow 0x17 altgr
idotless 0x17 shift altgr
oslash 0x18 altgr
Ooblique 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
egrave 0x1a
eacute 0x1a shift
bracketleft 0x1a altgr
dead_abovering 0x1a shift altgr
plus 0x1b
asterisk 0x1b shift
bracketright 0x1b altgr
dead_macron 0x1b shift altgr
ae 0x1e altgr
AE 0x1e shift altgr
ssharp 0x1f altgr
section 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
eng 0x22 altgr
ENG 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kra 0x25 altgr
lstroke 0x26 altgr
Lstroke 0x26 shift altgr
ograve 0x27
ccedilla 0x27 shift
at 0x27 altgr
dead_doubleacute 0x27 shift altgr
agrave 0x28
degree 0x28 shift
numbersign 0x28 altgr
backslash 0x29
bar 0x29 shift
notsign 0x29 altgr
ugrave 0x2b
section 0x2b shift
dead_grave 0x2b altgr
dead_breve 0x2b shift altgr
guillemotleft 0x2c altgr
guillemotright 0x2d altgr
cent 0x2e altgr
copyright 0x2e shift altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
semicolon 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
colon 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
minus 0x35
underscore 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
+104
View File
@@ -0,0 +1,104 @@
# generated from XKB map jp106
include common
map 0x411
exclam 0x02 shift
kana_NU 0x02 altgr
quotedbl 0x03 shift
kana_FU 0x03 altgr
numbersign 0x04 shift
kana_A 0x04 altgr
kana_a 0x04 shift altgr
dollar 0x05 shift
kana_U 0x05 altgr
kana_u 0x05 shift altgr
percent 0x06 shift
kana_E 0x06 altgr
kana_e 0x06 shift altgr
ampersand 0x07 shift
kana_O 0x07 altgr
kana_o 0x07 shift altgr
apostrophe 0x08 shift
kana_YA 0x08 altgr
kana_ya 0x08 shift altgr
parenleft 0x09 shift
kana_YU 0x09 altgr
kana_yu 0x09 shift altgr
parenright 0x0a shift
kana_YO 0x0a altgr
kana_yo 0x0a shift altgr
asciitilde 0x0b shift
kana_WA 0x0b altgr
kana_WO 0x0b shift altgr
minus 0x0c
equal 0x0c shift
kana_HO 0x0c altgr
asciicircum 0x0d
asciitilde 0x0d shift
kana_HE 0x0d altgr
kana_TA 0x10 altgr
kana_TE 0x11 altgr
kana_I 0x12 altgr
kana_i 0x12 shift altgr
kana_SU 0x13 altgr
kana_KA 0x14 altgr
kana_N 0x15 altgr
kana_NA 0x16 altgr
kana_NI 0x17 altgr
kana_RA 0x18 altgr
kana_SE 0x19 altgr
at 0x1a
grave 0x1a shift
voicedsound 0x1a altgr
bracketleft 0x1b
braceleft 0x1b shift
semivoicedsound 0x1b altgr
kana_openingbracket 0x1b shift altgr
kana_CHI 0x1e altgr
kana_TO 0x1f altgr
kana_SHI 0x20 altgr
kana_HA 0x21 altgr
kana_KI 0x22 altgr
kana_KU 0x23 altgr
kana_MA 0x24 altgr
kana_NO 0x25 altgr
kana_RI 0x26 altgr
semicolon 0x27
plus 0x27 shift
kana_RE 0x27 altgr
colon 0x28
asterisk 0x28 shift
kana_KE 0x28 altgr
Zenkaku_Hankaku 0x29
bracketright 0x2b
braceright 0x2b shift
kana_MU 0x2b altgr
kana_closingbracket 0x2b shift altgr
kana_TSU 0x2c altgr
kana_tsu 0x2c shift altgr
kana_SA 0x2d altgr
kana_SO 0x2e altgr
kana_HI 0x2f altgr
kana_KO 0x30 altgr
kana_MI 0x31 altgr
kana_MO 0x32 altgr
comma 0x33
less 0x33 shift
kana_NE 0x33 altgr
kana_comma 0x33 shift altgr
period 0x34
greater 0x34 shift
kana_RU 0x34 altgr
kana_fullstop 0x34 shift altgr
slash 0x35
question 0x35 shift
kana_ME 0x35 altgr
kana_conjunctive 0x35 shift altgr
Eisu_toggle 0x3a shift
Execute 0x54 shift
Kanji 0x70
backslash 0x73
bar 0x7d shift
underscore 0x73 shift
Henkan_Mode 0x79
Katakana 0x70
Muhenkan 0x7b
+57
View File
@@ -0,0 +1,57 @@
# generated from XKB map lt
include common
map 0x427
exclam 0x02 shift
aogonek 0x02 altgr
Aogonek 0x02 shift altgr
at 0x03 shift
ccaron 0x03 altgr
Ccaron 0x03 shift altgr
numbersign 0x04 shift
eogonek 0x04 altgr
Eogonek 0x04 shift altgr
dollar 0x05 shift
eabovedot 0x05 altgr
Eabovedot 0x05 shift altgr
percent 0x06 shift
iogonek 0x06 altgr
Iogonek 0x06 shift altgr
asciicircum 0x07 shift
scaron 0x07 altgr
Scaron 0x07 shift altgr
ampersand 0x08 shift
uogonek 0x08 altgr
Uogonek 0x08 shift altgr
asterisk 0x09 shift
umacron 0x09 altgr
Umacron 0x09 shift altgr
parenleft 0x0a shift
doublelowquotemark 0x0a altgr
parenright 0x0b shift
leftdoublequotemark 0x0b altgr
minus 0x0c
underscore 0x0c shift
equal 0x0d
plus 0x0d shift
zcaron 0x0d altgr
Zcaron 0x0d shift altgr
bracketleft 0x1a
braceleft 0x1a shift
bracketright 0x1b
braceright 0x1b shift
semicolon 0x27
colon 0x27 shift
apostrophe 0x28
quotedbl 0x28 shift
grave 0x29
asciitilde 0x29 shift
backslash 0x2b
bar 0x2b shift
comma 0x33
less 0x33 shift
period 0x34
greater 0x34 shift
slash 0x35
question 0x35 shift
endash 0x56
EuroSign 0x56 shift
+128
View File
@@ -0,0 +1,128 @@
# generated from XKB map lv
include common
map 0x426
exclam 0x02 shift
onesuperior 0x02 altgr
exclamdown 0x02 shift altgr
at 0x03 shift
twosuperior 0x03 altgr
oneeighth 0x03 shift altgr
numbersign 0x04 shift
threesuperior 0x04 altgr
sterling 0x04 shift altgr
dollar 0x05 shift
EuroSign 0x05 altgr
cent 0x05 shift altgr
percent 0x06 shift
onehalf 0x06 altgr
threeeighths 0x06 shift altgr
asciicircum 0x07 shift
threequarters 0x07 altgr
fiveeighths 0x07 shift altgr
ampersand 0x08 shift
braceleft 0x08 altgr
seveneighths 0x08 shift altgr
asterisk 0x09 shift
bracketleft 0x09 altgr
trademark 0x09 shift altgr
parenleft 0x0a shift
bracketright 0x0a altgr
plusminus 0x0a shift altgr
parenright 0x0b shift
braceright 0x0b altgr
degree 0x0b shift altgr
minus 0x0c
underscore 0x0c shift
backslash 0x0c altgr
questiondown 0x0c shift altgr
equal 0x0d
plus 0x0d shift
dead_cedilla 0x0d altgr
dead_ogonek 0x0d shift altgr
at 0x10 altgr
Greek_OMEGA 0x10 shift altgr
lstroke 0x11 altgr
Lstroke 0x11 shift altgr
emacron 0x12 altgr
Emacron 0x12 shift altgr
rcedilla 0x13 altgr
Rcedilla 0x13 shift altgr
tslash 0x14 altgr
Tslash 0x14 shift altgr
leftarrow 0x15 altgr
yen 0x15 shift altgr
umacron 0x16 altgr
Umacron 0x16 shift altgr
imacron 0x17 altgr
Imacron 0x17 shift altgr
omacron 0x18 altgr
Omacron 0x18 shift altgr
thorn 0x19 altgr
THORN 0x19 shift altgr
bracketleft 0x1a
braceleft 0x1a shift
dead_diaeresis 0x1a altgr
dead_abovering 0x1a shift altgr
bracketright 0x1b
braceright 0x1b shift
dead_tilde 0x1b altgr
dead_macron 0x1b shift altgr
ISO_Next_Group 0x1c shift
amacron 0x1e altgr
Amacron 0x1e shift altgr
scaron 0x1f altgr
Scaron 0x1f shift altgr
eth 0x20 altgr
ETH 0x20 shift altgr
dstroke 0x21 altgr
ordfeminine 0x21 shift altgr
gcedilla 0x22 altgr
Gcedilla 0x22 shift altgr
hstroke 0x23 altgr
Hstroke 0x23 shift altgr
kcedilla 0x25 altgr
Kcedilla 0x25 shift altgr
lcedilla 0x26 altgr
Lcedilla 0x26 shift altgr
semicolon 0x27
colon 0x27 shift
dead_acute 0x27 altgr
dead_doubleacute 0x27 shift altgr
apostrophe 0x28
quotedbl 0x28 shift
leftdoublequotemark 0x28 altgr
doublelowquotemark 0x28 shift altgr
grave 0x29
asciitilde 0x29 shift
notsign 0x29 altgr
backslash 0x2b
bar 0x2b shift
dead_grave 0x2b altgr
dead_breve 0x2b shift altgr
zcaron 0x2c altgr
Zcaron 0x2c shift altgr
guillemotright 0x2d altgr
greater 0x2d shift altgr
ccaron 0x2e altgr
Ccaron 0x2e shift altgr
leftdoublequotemark 0x2f altgr
grave 0x2f shift altgr
rightdoublequotemark 0x30 altgr
apostrophe 0x30 shift altgr
ncedilla 0x31 altgr
Ncedilla 0x31 shift altgr
mu 0x32 altgr
masculine 0x32 shift altgr
comma 0x33
less 0x33 shift
horizconnector 0x33 altgr
multiply 0x33 shift altgr
period 0x34
greater 0x34 shift
periodcentered 0x34 altgr
division 0x34 shift altgr
slash 0x35
question 0x35 shift
dead_belowdot 0x35 altgr
dead_abovedot 0x35 shift altgr
nobreakspace 0x39 altgr
+101
View File
@@ -0,0 +1,101 @@
# generated from XKB map mk
include common
map 0x42f
exclam 0x02 shift
at 0x03 shift
doublelowquotemark 0x03 shift altgr
numbersign 0x04 shift
leftdoublequotemark 0x04 shift altgr
dollar 0x05 shift
percent 0x06 shift
asciicircum 0x07 shift
ampersand 0x08 shift
asterisk 0x09 shift
parenleft 0x0a shift
parenright 0x0b shift
minus 0x0c
underscore 0x0c shift
equal 0x0d
plus 0x0d shift
Cyrillic_lje 0x10 altgr
Cyrillic_LJE 0x10 shift altgr
Cyrillic_nje 0x11 altgr
Cyrillic_NJE 0x11 shift altgr
Cyrillic_ie 0x12 altgr
Cyrillic_IE 0x12 shift altgr
Cyrillic_er 0x13 altgr
Cyrillic_ER 0x13 shift altgr
Cyrillic_te 0x14 altgr
Cyrillic_TE 0x14 shift altgr
Macedonia_dse 0x15 altgr
Macedonia_DSE 0x15 shift altgr
Cyrillic_u 0x16 altgr
Cyrillic_U 0x16 shift altgr
Cyrillic_i 0x17 altgr
Cyrillic_I 0x17 shift altgr
Cyrillic_o 0x18 altgr
Cyrillic_O 0x18 shift altgr
Cyrillic_pe 0x19 altgr
Cyrillic_PE 0x19 shift altgr
bracketleft 0x1a
braceleft 0x1a shift
Cyrillic_sha 0x1a altgr
Cyrillic_SHA 0x1a shift altgr
bracketright 0x1b
braceright 0x1b shift
Macedonia_gje 0x1b altgr
Macedonia_GJE 0x1b shift altgr
Cyrillic_a 0x1e altgr
Cyrillic_A 0x1e shift altgr
Cyrillic_es 0x1f altgr
Cyrillic_ES 0x1f shift altgr
Cyrillic_de 0x20 altgr
Cyrillic_DE 0x20 shift altgr
Cyrillic_ef 0x21 altgr
Cyrillic_EF 0x21 shift altgr
Cyrillic_ghe 0x22 altgr
Cyrillic_GHE 0x22 shift altgr
Cyrillic_ha 0x23 altgr
Cyrillic_HA 0x23 shift altgr
Cyrillic_je 0x24 altgr
Cyrillic_JE 0x24 shift altgr
Cyrillic_ka 0x25 altgr
Cyrillic_KA 0x25 shift altgr
Cyrillic_el 0x26 altgr
Cyrillic_EL 0x26 shift altgr
semicolon 0x27
colon 0x27 shift
Cyrillic_che 0x27 altgr
Cyrillic_CHE 0x27 shift altgr
apostrophe 0x28
quotedbl 0x28 shift
Macedonia_kje 0x28 altgr
Macedonia_KJE 0x28 shift altgr
grave 0x29
asciitilde 0x29 shift
backslash 0x2b
bar 0x2b shift
Cyrillic_zhe 0x2b altgr
Cyrillic_ZHE 0x2b shift altgr
Cyrillic_ze 0x2c altgr
Cyrillic_ZE 0x2c shift altgr
Cyrillic_dzhe 0x2d altgr
Cyrillic_DZHE 0x2d shift altgr
Cyrillic_tse 0x2e altgr
Cyrillic_TSE 0x2e shift altgr
Cyrillic_ve 0x2f altgr
Cyrillic_VE 0x2f shift altgr
Cyrillic_be 0x30 altgr
Cyrillic_BE 0x30 shift altgr
Cyrillic_en 0x31 altgr
Cyrillic_EN 0x31 shift altgr
Cyrillic_em 0x32 altgr
Cyrillic_EM 0x32 shift altgr
comma 0x33
less 0x33 shift
semicolon 0x33 shift altgr
period 0x34
greater 0x34 shift
colon 0x34 shift altgr
slash 0x35
question 0x35 shift
+17
View File
@@ -0,0 +1,17 @@
Shift_R 0x36
Shift_L 0x2a
Alt_R 0xb8
Mode_switch 0xb8
Alt_L 0x38
Control_R 0x9d
Control_L 0x1d
# Translate Super to Windows keys.
# This is hardcoded. See documentation for details.
Super_R 0xdb
Super_L 0xdc
# Translate Menu to the Windows Application key.
Menu 0xdd
Loaded 100 of 214 files, more files were not shown because too many files have changed in this diff. Show more