Commit Graph

83 Commits

Author SHA1 Message Date
Paul Menzel d53aea0241 cdrom: Demote `scsi_is_ready` return print to debug level
Printing the return value of `scsi_is_ready()` is a debug message, so
change the log level from 1 to 5.

    Booting from DVD/CD...
    Device reports MEDIUM NOT PRESENT
    scsi_is_ready returned -1
    Boot failed: Could not read from CDROM (code 0003)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2020-05-21 13:38:27 -04:00
Gerd Hoffmann 14221cd86e pretty boot menu entry for cdrom drives
Show the volume label of bootable cdroms.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-10-05 13:28:27 +02:00
Kevin O'Connor e5a0b61637 block: Rename disk_op_s->drive_gf to drive_fl
Now that the drive_s struct does not need to be in the f-segment,
rename references to drive_gf in the generic drive code to drive_fl.

This is just variable renames - no code changes.

Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-27 19:02:28 -04:00
Kevin O'Connor 8c76bd6811 Minor - move declaration of CDRom_locks to code that uses it
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-24 13:17:38 -04:00
Kevin O'Connor 1785645243 block: Rename process_XXX_op() functions to XXX_process_op()
Rename disk driver dispatch functions to a consistent naming style.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-14 14:40:08 -04:00
Kevin O'Connor 4dbe829059 block: Route scsi style commands through 'struct disk_op_s'
Support sending scsi style "command data block" commands (cdbcmd)
through the 'struct disk_op_s' command request structure.  And change
the blockcmd.c and cdrom.c code to route these commands through the
process_op() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-14 14:40:07 -04:00
Kevin O'Connor 85c72c6feb block: Introduce default_process_op() with common command handling codes
Most disk drivers only implement a couple of the available bios
commands.  Unify the common fallback handling code into a new function
default_process_op() to reduce boiler-plate code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-14 14:40:07 -04:00
Kevin O'Connor 3abdc7c018 Make sure all code checks for malloc failures
This is the result of an audit of callers of the malloc_XXX() and
memalign_XXX() calls.  All callers need to check if these functions
return NULL.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-07-04 14:23:01 -04:00
Stefan Berger 2aff1c1095 Add 'measurement' code to the BIOS
This patch adds invocations of functions that measure various parts of the
code and data through various parts of the BIOS code. It follows TCG
specifications on what needs to be measured. It also adds the implementation
of the called functions.

Reference for what needs to be measured can be found in specs found here:

http://www.trustedcomputinggroup.org/resources/pc_client_work_group_specific_implementation_specification_for_conventional_bios

The first measurements are done once the ACPI tables have been initialized.

Once booted into Linux, the current measurements produce the following logs
which can be found in /sys/kernel/security/tpm0/ascii_bios_measurements.
The below log also shows measurements from trusted grub.

 1 3fb240d2a04085a4e84f81e4398e070ed5a18163 06 [SMBIOS]
 2 cc812353fc277c1fab99e0b721752a1392984566 06 [Option ROM]
 2 9dbd87163112e5670378abe4510491259a61f411 05 [Start Option ROM Scan]
 2 6f74e357331b8dee11bbad85f27bc66cb873106c 06 [Option ROM]
 2 5626eb7ac05c7231e46d7461e7d3839b03ae9fad 06 [Option ROM]
 4 c1e25c3f6b0dc78d57296aa2870ca6f782ccf80f 05 [Calling INT 19h]
 0 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 1 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 2 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 3 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 4 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 5 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 6 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 7 d9be6524a5f5047db5866813acf3277892a7a30a 04 []
 4 8cf2fe6c87d4d0b2998a43da630292e6d85ee8b6 05 [Booting BCV device 80h (HDD)]
 4 5dff94459a3e2d13a433ef94afdc306144565bf7 0d [IPL]
 5 d1b33afde65ad47502332af957c60f20c84c1edc 0e [IPL Partition Data]
 4 487ce764b527ccad17f1d04243d0136fa981e6c4 0d [IPL]
 4 91d285e4dead566324c8938a3cc75803f462d9a1 0d [IPL]
 4 8ba79ac98bb491524fef29defc724daaf6263d35 0d [IPL]
 4 c591c15b82e4ff30e7383a4ff1ef3b41b38521ac 06 []
 4 8cdc27ec545eda33fbba1e8b8dae4da5c7206972 04 [Grub Event Separator]
 5 8cdc27ec545eda33fbba1e8b8dae4da5c7206972 04 [Grub Event Separator]
 5 e8673b9e14b02dc12d8ccfd0176bca7a3de7fc3c 0e [IPL Partition Data]
 5 0163e375a0af7525c5dac1a8e74b277359e40d1d 1105 []
 8 4be30f67c3d48ab7f04d9c0fd07f06d4c68379be 1205 []
 8 54c83965978de9708d026016ecb0e70660e04388 1305 []
 5 2431ed60130faeaf3a045f21963f71cacd46a029 04 [OS Event Separator]
 8 2431ed60130faeaf3a045f21963f71cacd46a029 04 [OS Event Separator]
 8 f3973cae05d6e2055062119d6e6e1e077b7df876 1005 []

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-06-01 12:15:18 -04:00
Kevin O'Connor c08ef9a777 cdrom: Break up very large read requests into smaller requests
A cdrom boot image could be over 64K in size, but the low level
drivers may not support very large reads.  If a large cdrom image is
found, issue multiple reads so that a read request over 64K is never
issued.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-12-29 10:15:57 -05:00
Kevin O'Connor 8ed94b42c0 cdrom: call scsi_process_op() instead of cdb_read()
Use the scsi_process_op() function instead of the lower level
cdb_read() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-12-29 09:48:24 -05:00
Kevin O'Connor c029a912d3 Move cdemu call interface and disk_ret helper code to disk.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Kevin O'Connor 02f7676421 cdemu: store internal cdemu fields in standard "el-torito" spec format.
Store the fields necessary to export the "el-torito" spec information
directly in an internal copy of the "el-torito" struct.  This
simplifies the interface and obviates the need for an internal home
grown struct with the same info.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-04 11:06:58 -04:00
Kevin O'Connor b7558a3620 Remove unnecesary updates of the disk op->count field.
Now that the op->count field is cleared in a global location on simple
errors, remove various local clears done in individual drivers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-27 12:40:30 -05:00
Kevin O'Connor 1902c94de0 Convert op->drive_g from a 16bit pointer to a 32 bit "GLOBALFLAT" pointer.
The "drive" structure is always malloc'ed and therefore always starts
off described as a 32-bit "flat" pointer.  Instead of switching
to/from 16bit pointers, make all the code use the 32bit pointer.  This
eliminates the confusing 16/32 bit pointer switches.

This patch also removes the "_g" suffixes on local variables in
functions that are always called in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-26 11:48:06 -04:00
Kevin O'Connor 8ab9a34d67 Rename fields of 'struct chs_s' and use in floppy lba2chs().
Rename the fields of 'struct chs_s' so that it can be used both to
describe a drive and to describe a particular sector on a drive.

Update floppy.c:lba2chs() to return a 'struct chs_s' instead of
passing the results via pointers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-10-14 21:37:56 -04:00
Kevin O'Connor 135f3f676d Split disk.h into block.h and std/disk.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 2d2fa31b37 Move function definitions for output.c from util.h to new file output.h.
Also, sort the order of include files in the c files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 9dea59025f Move malloc code from pmm.c to new files malloc.c and malloc.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor fa9c66a656 Rename util.c to string.c and introduce string.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 5d369d8d9e Move code centered around specific hardware devices to src/hw/
Move many C files from the src/ directory to the new src/hw/ directory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02 20:48:46 -04:00
Kevin O'Connor e52ad390c7 Use CONFIG_ prefix for Kconfig variables; use BUILD_ for others.
Rename remaining "build" settings in config.h that used the CONFIG_
prefix to use a BUILD_ prefix.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-20 23:48:22 -05:00
Kevin O'Connor 89a2f96de4 Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.
Convert all users of the alternative variable exports to VARFSEG.
There isn't a significant distinction between the existing types of
exports, so it's simpler to just use one type going forward.

The new VARFSEG declaration is only emitting when in 32bit mode, so
update and move some variables as needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18 23:36:03 -05:00
Kevin O'Connor d83c87bb20 Normalize POST initialization function name suffixes.
The POST phase has to invoke many initialization functions, and these
functions can have complex inter-dependencies.  Try to categorize the
functions into 4 classes:

preinit - functions called very early in POST where function ordering
    is very important and the code has limited access to other
    interfaces.

init - functions that initialize internal interfaces and standard
    external interfaces.  This code is generally not dependent on
    particular hardware and typically does not communicate directly
    with any hardware devices.

setup - functions which access hardware or are dependent on particular
    hardware or platform devices.

prepboot - functions that finalize internal interfaces and that
    prepare for the boot phase.

This patch attempts to normalize the suffixes - functions that used
_init(), _setup(), _finalize(), or similar that did not follow the
above pattern were renamed.  Other than function name changes, there
should be no code impact to this patch.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-05 20:00:29 -05:00
Kevin O'Connor bd6afe5d11 Unify ATAPI command processing.
Unify the ATA and AHCI ATAPI command processing into one function in
block.c (process_atapi_op).

This patch disables the existing handlers for ATA ATAPI isready and
reset.  However, it's unlikely that support is needed and it does not
appear that the implemented support is fully correct.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-07-21 12:29:48 -04:00
Kevin O'Connor e51316d0cc Minor - remove CLEARBITS_BDA and SETBITS_BDA macros.
Remove these infrequently used macros and replace with explicit
GET_BDA/SET_BDA calls.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-06-10 09:09:22 -04:00
Kevin O'Connor d314083a41 Convert disk code EBDA variables to VARLOW variables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-20 18:11:05 -04:00
Paolo Bonzini 8c976e3ea2 usb-msc: go through TEST UNIT READY for hard disks.
Add the wait loop that CDs are already using to usb-msc in the HD
case, to cope with a NOT READY or UNIT ATTENTION condition.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-11-17 21:21:02 -05:00
Paolo Bonzini 0082374caa cdrom: use TEST UNIT READY to detect ready medium
The READ CAPACITY output is not used except for some debugging messages.
In the future, we will use this code for USB sticks too, but those
already send READ CAPACITY.  To avoid code duplication, switch to TEST
UNIT READY for this task.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-11-17 21:01:31 -05:00
Gerd Hoffmann d7a7cf3a43 ahci/cdrom: shared bounce buffer
This patch creates a common bounce buffer in block.c which
is shared by the cdrom and ahci drivers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-08-06 13:57:52 -04:00
Kevin O'Connor a0842f8d49 Remove Drives global struct in favor of independent global variables.
The "Drives" struct just held three global variables - declare the
three global variables independently.
2010-12-29 13:26:26 -05:00
Gleb Natapov 4c90a20f86 Create separate IPL entry for each CD/DVD
Current code creates only one IPL entry of type IPL_TYPE_CDROM even if
there are more then one CDROM drive present. If CDROM that the entry
refers to is not bootable there is no way to retry boot from another
CDROM. Fix this by creating IPL entry for each CDROM drive found. First
CDROM will always be placed in IPL entry 3 for backwards compatibility.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
2010-12-12 14:12:59 -05:00
Kevin O'Connor 4d96edc76b Cleanup - it's no longer necessary to manually reset global variables.
Now that a soft-reboot forces a hard-reboot, it is no longer necessary
to manually reset global variables.
2010-09-25 14:53:15 -04:00
Kevin O'Connor d5d02b6c97 Allocate cdemu buffer in low mem instead of ebda.
Using the low memory buffer gives more flexibility with the final
location of the buffer.

Don't allocate the buffer at all if no cdrom drives are present.
2010-06-06 16:18:03 -04:00
Kevin O'Connor 144817be2d Rename check_time() to check_tsc(). 2010-05-23 10:46:49 -04:00
Kevin O'Connor 8f469b9676 Dynamically allocate ata_channel info; introduce custom atadrive_s struct.
Don't limit the number of ATA controllers supported - just dynamically
allocate the structs.

Create an atadrive_s struct that extends the standard 'struct drive_s'
and have the new struct store a pointer to the ata channel info.

Also, prefer storing drive_s pointers as 32bit "flat" pointers -
adjust them as needed in the 16bit code.
2010-02-28 01:28:11 -05:00
Kevin O'Connor 76977b2d8d Move common "command data block" functions to new file blockcmd.c.
Move common "cdb" request functions to a new file.
2010-02-17 01:01:32 -05:00
Kevin O'Connor d7e998fdd0 Dynamically allocate each drive_g with malloc_fseg().
This eliminates the limit on the number of available drives.  It also
allows for each driver to allocate additional custom fields.
2010-02-15 22:48:28 -05:00
Kevin O'Connor 7d7002512e Add common "block command" definitions and update cdrom code.
Introduce standard definitions and names for the "command data block"
commands used in the cdrom code.
2010-02-15 19:19:11 -05:00
Kevin O'Connor 1ca05b0f39 Be sure to add "void" to all function prototypes that take no args.
Omitting "void" leads to a K&R style declaration which was not intended.
2010-01-03 17:43:37 -05:00
Kevin O'Connor 89eb6241e5 Handle tsc rollover.
Handle case where timetamp counter overflows while waiting.
2009-10-22 22:30:37 -04:00
Kevin O'Connor 77d227b650 Pass 'drive_s' pointer instead of driveid.
Pass a pointer to the drive_s struct instead of a driveid array offset.
Don't allocate ata drive's until a real drive found.
Introduce getDrive() and allocDrive() functions.
2009-10-22 21:48:39 -04:00
Kevin O'Connor 36c93a5e97 Unify cd emulation access and main disk access code.
Add a new backend driver for cd emulation (DTYPE_CDEMU).  This backend
    driver now does the work of scheduling mis-sized reads.
Add mechanism for obtaining emulated drive geometry.
Extend disk_1308() to support cdrom emulation.
Use regular disk_13*() calls even for cdemu.
Also, unify the X_SECTOR_SIZE definitions.
2009-09-12 19:35:04 -04:00
Kevin O'Connor 51cfbe7670 Merge cdrom 13xx handlers with main disk 13xx handlers.
Most of the cdrom_13 code did the same thing as disk_13 - so merge
    them together.
Add definitions for 0xe0 (EXTSTART_CD) and 0x80 (EXTSTART_HD).
This changes the behavior for cdroms on 1315 and 1316 calls -
    previously 1315 returned an error and set ah=2, now it sets ah=1
    and doesn't return an error; previously 1316 returned ok, not it
    returns EPARAM.
2009-08-18 22:38:49 -04:00
Kevin O'Connor 0a0e42e985 Add floppy controllers to "drives" list also.
The Drives.drives list now contains floppies, harddrives, and cdroms.
Add mapping table for external/internal drive ids for floppies.
Rename CONFIG_FLOPPY_SUPPORT to CONFIG_FLOPPY (for consistency).
Be consistent with "driveid" and "floppyid" variable names.
Replace switch statements of drive parameters into a global array.
There are some externally visible changes with this patch:
  - Some calls will now return EPARAM instead of ETIMEOUT (or ECHANGED)
  - floppy_1301/1308 are now only available when regs->dl is valid
  - floppy_1308/1315 return EPARAM on invalid drives
2009-08-16 12:09:44 -04:00
Kevin O'Connor 669e644956 Store cdrom emulated driveid directly. 2009-08-11 22:36:30 -04:00
Kevin O'Connor 707298a786 Use variable name "driveid" consistently (instead of "device"). 2009-08-11 22:27:51 -04:00
Kevin O'Connor c892b138d8 Separate ATA code from generic disk code.
Move generic code from ata.c to new file block.c.
Rename atabits.h to ata.h and move ata header definitions from disk.h.
Rename ATA.channels to ATA_channels.
Rename ATA structure to Drives.
Support both CONFIG_DRIVES and CONFIG_ATA options.
2009-08-11 21:59:37 -04:00
Kevin O'Connor 42337662b0 Misc ATA cleanups.
Remove some unused defines.
Rename ATA_TYPE_* to DTYPE_* and move from atabits.h to disk.h.
Rename ATA_TRANSLATION_* to TRANSLATION_* and move from atabits.h to disk.h.
Convert bios is-drive-ready call to use send_disk_op().
Only add atapi devices to the cdmap if they are cd/dvd roms.
Remove 'device' from struct ata_devices_s.
2009-08-10 00:06:37 -04:00
Kevin O'Connor 3f6c278a59 Route disk_op commands by drive type - not by command.
Don't confuse op->command with low-level ata cmd->command.
Modify __send_disk_op to route commands by drive type.
Add commands for verify and seek operations.
Do ata resets via disk_op also.
2009-08-09 19:17:11 -04:00