2 // OS specific CDROM interface (linux)
4 // by James L. Hammons and Niels Wagenaar
6 // NOTE : This CD-ROM code *could* work with other UN*X related OS. However,
7 // we/I are not sure on this matter.
9 // This is very experimental and I have the feeling that this won't even compile.
10 // Hell, I don't even have a Linux dev system (broken) or Jaguar CD releases to
13 // Big thanks to the DOSBOX team which provided us with great knowlegde about
14 // CD-ROM access and Linux/UN*X.
16 #ifdef LINUX_JAGUAR_CDROM
18 // *** OS dependent CDROM stuffola ***
21 #include <linux/cdrom.h>
22 #include <sys/ioctl.h>
24 #include <sys/types.h>
26 // *** End OS dependent ***
30 // *** Virtual Jaguar dependent ***
31 //#include "SDL.h" // Yes, we use SDL for initializing the CD-ROM and
32 // // give us access to certain CD-ROM states. But not just yet.
34 // *** SDL CD-ROM dependent *** // Not yet needed!
35 // SDL_CD *cdrom; // Our variable for SDL CD-ROM access.
36 // CDstatus status; // Let us get our status.
39 // *** Local variables ***
40 char device_name[512] ; // Devicename, for example /dev/cdrom
43 // Linux support functions
44 // OS specific implementation of OS agnostic functions
49 // Setting device_name to /deb/cdrom. /dev/cdrom is the default CD-ROM
50 // drive on most UN*X systems. Well, I think it is.
52 // In the future we can probably use SDL for getting CDROM states and
53 // CD-ROM specific information.
54 strcpy(device_name, "/dev/cdrom");
56 // Let us open the device_name and check if we can open the CD-ROM.
57 int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
61 // CD-ROM isn't accessable.
62 // Write the error in the log file and return false.
63 WriteLog("CDINTF: CDIntfInit - Unable to open CDROM!\n");
68 // CD-ROM is accessable.
69 // Write the success in the log file and return true.
70 WriteLog("CDINTF: CDIntfInit - Succesfully opened CDROM!\n");
79 // Just in case : closing device_name.
80 WriteLog("CDINTF: CDIntfDone - Closing CDROM!\n");
84 bool CDIntfReadBlock(uint32 sector, uint8 * buffer)
86 unsigned int buflen = CD_FRAMESIZE_RAW; // Raw read, 2352 bytes per sector
87 //unsigned char *buf = new unsigned int[buflen]; // DOSBOX, do we need this?
89 struct cdrom_read cdrom_read;
91 // Let us open the device_name and check if we can open the CD-ROM.
92 int cdrom_fd = open(device_name, O_RDONLY | O_NONBLOCK);
95 // CD-ROM isn't accessable.
96 // Write the error in the log file and return false.
97 WriteLog("CDINTF: CDIntfReadBlock - Unable to open CDROM!\n");
101 // Setting up the cdrom_read struct :
102 cdrom_read.cdread_lba = sector; // Which sector to read.
103 cdrom_read.cdread_bufaddr = (char*)buffer; // Where to put the data (?)
104 cdrom_read.cdread_buflen = buflen; // 2352 bytes/sector -> RAW read
106 // Let us read the content we want. -1 (false) when it didn't work.
107 ret = ioctl(cdrom_fd, CDROMREADRAW, &cdrom_read);
112 // The following was taken from DOSBOX. After reading the content, they write
113 // back the information from buf (based upon the size of buflen) to buffer.
114 // I think that this is not needed. *fingers crossed*
116 // MEM_BlockWrite(buffer, buf, buflen);
119 // Uncomment the following for debug reasons.
121 // WriteLog("CDINTF: CDIntfReadBlock - Reading sector %d!\n", sector);
127 uint32 CDIntfGetNumSessions(void)
129 // Still need relevant code here...
133 void CDIntfSelectDrive(uint32 driveNum)
135 WriteLog("CDINTF: SelectDrive unimplemented!\n");
138 uint32 CDIntfGetCurrentDrive(void)
140 WriteLog("CDINTF: GetCurrentDrive unimplemented!\n");
144 const uint8 * CDIntfGetDriveName(uint32)
146 WriteLog("CDINTF: GetDriveName unimplemented!\n");
150 uint8 CDIntfGetSessionInfo(uint32 session, uint32 offset)
152 WriteLog("CDINTF: GetSessionInfo unimplemented!\n");
156 uint8 CDIntfGetTrackInfo(uint32 track, uint32 offset)
158 WriteLog("CDINTF: GetTrackInfo unimplemented!\n");
167 // Linux support functions
168 // OS specific implementation of OS agnostic functions
171 bool CDIntfInit(void)
173 WriteLog("CDINTF: Init unimplemented!\n");
177 void CDIntfDone(void)
181 bool CDIntfReadBlock(uint32 sector, uint8 * buffer)
183 WriteLog("CDINTF: ReadBlock unimplemented!\n");
187 uint32 CDIntfGetNumSessions(void)
189 // Still need relevant code here... !!! FIX !!!
193 void CDIntfSelectDrive(uint32 driveNum)
195 WriteLog("CDINTF: SelectDrive unimplemented!\n");
198 uint32 CDIntfGetCurrentDrive(void)
200 WriteLog("CDINTF: GetCurrentDrive unimplemented!\n");
204 const uint8 * CDIntfGetDriveName(uint32)
206 WriteLog("CDINTF: GetDriveName unimplemented!\n");
210 uint8 CDIntfGetSessionInfo(uint32 session, uint32 offset)
212 WriteLog("CDINTF: GetSessionInfo unimplemented!\n");
216 uint8 CDIntfGetTrackInfo(uint32 track, uint32 offset)
218 WriteLog("CDINTF: GetTrackInfo unimplemented!\n");