Added patch 884060 from Martin Battig
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1607
This commit is contained in:
parent
2b88ae212e
commit
3e170dbdcf
5 changed files with 126 additions and 1 deletions
|
@ -166,6 +166,9 @@ case "$target" in
|
|||
AC_DEFINE(MACOSX, 1, [Compiling on Mac OS X])
|
||||
LIBS="$LIBS -framework AudioUnit"
|
||||
;;
|
||||
*-*-linux-gnu*)
|
||||
AC_DEFINE(LINUX, 1, [Compiling on GNU/Linux])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_OUTPUT([
|
||||
|
|
|
@ -6,4 +6,4 @@ libdos_a_SOURCES = dos.cpp dos_devices.cpp dos_execute.cpp dos_files.cpp dos_ioc
|
|||
dos_misc.cpp dos_classes.cpp dos_programs.cpp dos_tables.cpp \
|
||||
drives.cpp drives.h drive_virtual.cpp drive_local.cpp drive_cache.cpp \
|
||||
dev_con.h dos_mscdex.cpp \
|
||||
cdrom.h cdrom.cpp cdrom_ioctl_win32.cpp cdrom_aspi_win32.cpp
|
||||
cdrom.h cdrom.cpp cdrom_ioctl_win32.cpp cdrom_aspi_win32.cpp cdrom_ioctl_linux.cpp
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
#define MAX_ASPI_CDROM 5
|
||||
|
||||
#include <string.h>
|
||||
#include "dosbox.h"
|
||||
#include "mem.h"
|
||||
#include "SDL.h"
|
||||
|
||||
|
||||
#define RAW_SECTOR_SIZE 2352
|
||||
#define COOKED_SECTOR_SIZE 2048
|
||||
|
||||
|
@ -181,4 +183,21 @@ private:
|
|||
|
||||
#endif /* WIN 32 */
|
||||
|
||||
#if defined (LINUX)
|
||||
|
||||
class CDROM_Interface_Ioctl : public CDROM_Interface_SDL
|
||||
{
|
||||
public:
|
||||
CDROM_Interface_Ioctl (void);
|
||||
|
||||
bool SetDevice (char* path, int forceCD);
|
||||
bool GetUPC (unsigned char& attr, char* upc);
|
||||
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
|
||||
|
||||
private:
|
||||
char device_name[512];
|
||||
};
|
||||
|
||||
#endif /* LINUX */
|
||||
|
||||
#endif /* __CDROM_INTERFACE__ */
|
||||
|
|
96
src/dos/cdrom_ioctl_linux.cpp
Normal file
96
src/dos/cdrom_ioctl_linux.cpp
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2004 The DOSBox Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "cdrom.h"
|
||||
|
||||
#if defined (LINUX)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/cdrom.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
CDROM_Interface_Ioctl::CDROM_Interface_Ioctl(void) : CDROM_Interface_SDL()
|
||||
{
|
||||
strcpy(device_name, "");
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Ioctl::GetUPC(unsigned char& attr, char* upc)
|
||||
{
|
||||
int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
|
||||
if (cdrom_fd <= 0) return false;
|
||||
|
||||
struct cdrom_mcn cdrom_mcn;
|
||||
int ret = ioctl(cdrom_fd, CDROM_GET_MCN, &cdrom_mcn);
|
||||
|
||||
close(cdrom_fd);
|
||||
|
||||
if (ret > 0) {
|
||||
attr = 0;
|
||||
strncpy(upc, (char*)cdrom_mcn.medium_catalog_number, 14);
|
||||
}
|
||||
|
||||
return (ret > 0);
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num)
|
||||
{
|
||||
int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
|
||||
if (cdrom_fd <= 0) return false;
|
||||
|
||||
Bitu buflen = raw ? num * CD_FRAMESIZE_RAW : num * CD_FRAMESIZE;
|
||||
Bit8u* buf = new Bit8u[buflen];
|
||||
int ret;
|
||||
|
||||
if (raw) {
|
||||
struct cdrom_read cdrom_read;
|
||||
cdrom_read.cdread_lba = sector;
|
||||
cdrom_read.cdread_bufaddr = (char*)buf;
|
||||
cdrom_read.cdread_buflen = buflen;
|
||||
|
||||
ret = ioctl(cdrom_fd, CDROMREADRAW, &cdrom_read);
|
||||
} else {
|
||||
ret = lseek(cdrom_fd, sector * CD_FRAMESIZE, SEEK_SET);
|
||||
if (ret >= 0) ret = read(cdrom_fd, buf, buflen);
|
||||
if (ret != buflen) ret = -1;
|
||||
}
|
||||
close(cdrom_fd);
|
||||
|
||||
MEM_BlockWrite(buffer, buf, buflen);
|
||||
delete[] buf;
|
||||
|
||||
return (ret > 0);
|
||||
}
|
||||
|
||||
bool CDROM_Interface_Ioctl::SetDevice(char* path, int forceCD)
|
||||
{
|
||||
bool success = CDROM_Interface_SDL::SetDevice(path, forceCD);
|
||||
|
||||
if (success) {
|
||||
const char* tmp = SDL_CDName(forceCD);
|
||||
if (tmp) strncpy(device_name, tmp, 512);
|
||||
else success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -260,6 +260,13 @@ int CMscdex::AddDrive(Bit16u _drive, char* physicalPath, Bit8u& subUnit)
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined (LINUX)
|
||||
if (useCdromInterface==CDROM_USE_IOCTL) {
|
||||
cdrom[numDrives] = new CDROM_Interface_Ioctl();
|
||||
LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: IOCTL Interface.");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
cdrom[numDrives] = new CDROM_Interface_SDL();
|
||||
LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: SDL Interface.");
|
||||
} break;
|
||||
|
|
Loading…
Add table
Reference in a new issue