Search
lxdream.org :: lxdream :: r520:7d6f8584897f
lxdream 0.9.1
released Jun 29
Download Now
changeset520:7d6f8584897f
parent519:ef9a7f176401
child521:33d2d92784c7
authornkeynes
dateFri Nov 16 23:51:23 2007 +0000 (12 years ago)
Move native cd drivers under the drivers directory
src/Makefile.am
src/Makefile.in
src/drivers/cd_linux.c
src/drivers/cd_none.c
src/gdrom/cdnone.c
src/gdrom/linux.c
1.1 --- a/src/Makefile.am Thu Nov 15 12:10:08 2007 +0000
1.2 +++ b/src/Makefile.am Fri Nov 16 23:51:23 2007 +0000
1.3 @@ -48,9 +48,9 @@
1.4 drivers/gl_sl.c drivers/gl_slsrc.c
1.5
1.6 if CDROM_LINUX
1.7 -lxdream_SOURCES += gdrom/linux.c
1.8 +lxdream_SOURCES += drivers/cd_linux.c
1.9 else
1.10 -lxdream_SOURCES += gdrom/cdnone.c
1.11 +lxdream_SOURCES += drivers/cd_none.c
1.12 endif
1.13
1.14 lxdream_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) -lesd
2.1 --- a/src/Makefile.in Thu Nov 15 12:10:08 2007 +0000
2.2 +++ b/src/Makefile.in Fri Nov 16 23:51:23 2007 +0000
2.3 @@ -35,16 +35,25 @@
2.4 NORMAL_UNINSTALL = :
2.5 PRE_UNINSTALL = :
2.6 POST_UNINSTALL = :
2.7 -@CDROM_LINUX_TRUE@am__append_1 = gdrom/linux.c
2.8 -@CDROM_LINUX_FALSE@am__append_2 = gdrom/cdnone.c
2.9 +@CDROM_LINUX_TRUE@am__append_1 = drivers/cd_linux.c
2.10 +@CDROM_LINUX_FALSE@am__append_2 = drivers/cd_none.c
2.11 ACLOCAL = @ACLOCAL@
2.12 AMDEP_FALSE = @AMDEP_FALSE@
2.13 AMDEP_TRUE = @AMDEP_TRUE@
2.14 AMTAR = @AMTAR@
2.15 +ARMCC = @ARMCC@
2.16 +ARMLD = @ARMLD@
2.17 +ARMOBJCOPY = @ARMOBJCOPY@
2.18 AUTOCONF = @AUTOCONF@
2.19 AUTOHEADER = @AUTOHEADER@
2.20 AUTOMAKE = @AUTOMAKE@
2.21 AWK = @AWK@
2.22 +BUILD_ARMTEST_FALSE = @BUILD_ARMTEST_FALSE@
2.23 +BUILD_ARMTEST_TRUE = @BUILD_ARMTEST_TRUE@
2.24 +BUILD_SH4X86_FALSE = @BUILD_SH4X86_FALSE@
2.25 +BUILD_SH4X86_TRUE = @BUILD_SH4X86_TRUE@
2.26 +BUILD_SYSTEST_FALSE = @BUILD_SYSTEST_FALSE@
2.27 +BUILD_SYSTEST_TRUE = @BUILD_SYSTEST_TRUE@
2.28 CATALOGS = @CATALOGS@
2.29 CATOBJEXT = @CATOBJEXT@
2.30 CC = @CC@
2.31 @@ -99,7 +108,10 @@
2.32 PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
2.33 PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
2.34 SET_MAKE = @SET_MAKE@
2.35 +SHCC = @SHCC@
2.36 SHELL = @SHELL@
2.37 +SHLD = @SHLD@
2.38 +SHOBJCOPY = @SHOBJCOPY@
2.39 STRIP = @STRIP@
2.40 USE_NLS = @USE_NLS@
2.41 VERSION = @VERSION@
2.42 @@ -111,7 +123,11 @@
2.43 am__leading_dot = @am__leading_dot@
2.44 am__quote = @am__quote@
2.45 bindir = @bindir@
2.46 +build = @build@
2.47 build_alias = @build_alias@
2.48 +build_cpu = @build_cpu@
2.49 +build_os = @build_os@
2.50 +build_vendor = @build_vendor@
2.51 datadir = @datadir@
2.52 datarootdir = @datarootdir@
2.53 docdir = @docdir@
2.54 @@ -249,9 +265,9 @@
2.55 drivers/video_gtk.c drivers/video_gtk.h drivers/video_x11.c \
2.56 drivers/video_x11.h drivers/gl_common.c drivers/gl_common.h \
2.57 drivers/gl_fbo.c drivers/gl_sl.c drivers/gl_slsrc.c \
2.58 - gdrom/linux.c gdrom/cdnone.c
2.59 -@CDROM_LINUX_TRUE@am__objects_1 = linux.$(OBJEXT)
2.60 -@CDROM_LINUX_FALSE@am__objects_2 = cdnone.$(OBJEXT)
2.61 + drivers/cd_linux.c drivers/cd_none.c
2.62 +@CDROM_LINUX_TRUE@am__objects_1 = cd_linux.$(OBJEXT)
2.63 +@CDROM_LINUX_FALSE@am__objects_2 = cd_none.$(OBJEXT)
2.64 am_lxdream_OBJECTS = main.$(OBJEXT) config.$(OBJEXT) mem.$(OBJEXT) \
2.65 watch.$(OBJEXT) asic.$(OBJEXT) syscall.$(OBJEXT) bios.$(OBJEXT) \
2.66 dcload.$(OBJEXT) ide.$(OBJEXT) gdimage.$(OBJEXT) \
2.67 @@ -301,22 +317,22 @@
2.68 @AMDEP_TRUE@ ./$(DEPDIR)/armmem.Po ./$(DEPDIR)/asic.Po \
2.69 @AMDEP_TRUE@ ./$(DEPDIR)/audio.Po ./$(DEPDIR)/audio_esd.Po \
2.70 @AMDEP_TRUE@ ./$(DEPDIR)/audio_null.Po ./$(DEPDIR)/bios.Po \
2.71 -@AMDEP_TRUE@ ./$(DEPDIR)/bootstrap.Po ./$(DEPDIR)/cdi.Po \
2.72 -@AMDEP_TRUE@ ./$(DEPDIR)/cdnone.Po ./$(DEPDIR)/config.Po \
2.73 -@AMDEP_TRUE@ ./$(DEPDIR)/controller.Po ./$(DEPDIR)/ctrl_dlg.Po \
2.74 -@AMDEP_TRUE@ ./$(DEPDIR)/dcload.Po ./$(DEPDIR)/debug_win.Po \
2.75 -@AMDEP_TRUE@ ./$(DEPDIR)/dis-buf.Po ./$(DEPDIR)/dis-init.Po \
2.76 -@AMDEP_TRUE@ ./$(DEPDIR)/display.Po ./$(DEPDIR)/dmac.Po \
2.77 -@AMDEP_TRUE@ ./$(DEPDIR)/dreamcast.Po ./$(DEPDIR)/dump_win.Po \
2.78 -@AMDEP_TRUE@ ./$(DEPDIR)/eventq.Po ./$(DEPDIR)/gdi.Po \
2.79 -@AMDEP_TRUE@ ./$(DEPDIR)/gdimage.Po ./$(DEPDIR)/gdrom.Po \
2.80 -@AMDEP_TRUE@ ./$(DEPDIR)/gdrom_menu.Po ./$(DEPDIR)/gendec.Po \
2.81 -@AMDEP_TRUE@ ./$(DEPDIR)/genglsl.Po ./$(DEPDIR)/gl_common.Po \
2.82 -@AMDEP_TRUE@ ./$(DEPDIR)/gl_fbo.Po ./$(DEPDIR)/gl_sl.Po \
2.83 -@AMDEP_TRUE@ ./$(DEPDIR)/gl_slsrc.Po ./$(DEPDIR)/gtkcb.Po \
2.84 -@AMDEP_TRUE@ ./$(DEPDIR)/gtkui.Po ./$(DEPDIR)/i386-dis.Po \
2.85 -@AMDEP_TRUE@ ./$(DEPDIR)/ide.Po ./$(DEPDIR)/insparse.Po \
2.86 -@AMDEP_TRUE@ ./$(DEPDIR)/intc.Po ./$(DEPDIR)/linux.Po \
2.87 +@AMDEP_TRUE@ ./$(DEPDIR)/bootstrap.Po ./$(DEPDIR)/cd_linux.Po \
2.88 +@AMDEP_TRUE@ ./$(DEPDIR)/cd_none.Po ./$(DEPDIR)/cdi.Po \
2.89 +@AMDEP_TRUE@ ./$(DEPDIR)/config.Po ./$(DEPDIR)/controller.Po \
2.90 +@AMDEP_TRUE@ ./$(DEPDIR)/ctrl_dlg.Po ./$(DEPDIR)/dcload.Po \
2.91 +@AMDEP_TRUE@ ./$(DEPDIR)/debug_win.Po ./$(DEPDIR)/dis-buf.Po \
2.92 +@AMDEP_TRUE@ ./$(DEPDIR)/dis-init.Po ./$(DEPDIR)/display.Po \
2.93 +@AMDEP_TRUE@ ./$(DEPDIR)/dmac.Po ./$(DEPDIR)/dreamcast.Po \
2.94 +@AMDEP_TRUE@ ./$(DEPDIR)/dump_win.Po ./$(DEPDIR)/eventq.Po \
2.95 +@AMDEP_TRUE@ ./$(DEPDIR)/gdi.Po ./$(DEPDIR)/gdimage.Po \
2.96 +@AMDEP_TRUE@ ./$(DEPDIR)/gdrom.Po ./$(DEPDIR)/gdrom_menu.Po \
2.97 +@AMDEP_TRUE@ ./$(DEPDIR)/gendec.Po ./$(DEPDIR)/genglsl.Po \
2.98 +@AMDEP_TRUE@ ./$(DEPDIR)/gl_common.Po ./$(DEPDIR)/gl_fbo.Po \
2.99 +@AMDEP_TRUE@ ./$(DEPDIR)/gl_sl.Po ./$(DEPDIR)/gl_slsrc.Po \
2.100 +@AMDEP_TRUE@ ./$(DEPDIR)/gtkcb.Po ./$(DEPDIR)/gtkui.Po \
2.101 +@AMDEP_TRUE@ ./$(DEPDIR)/i386-dis.Po ./$(DEPDIR)/ide.Po \
2.102 +@AMDEP_TRUE@ ./$(DEPDIR)/insparse.Po ./$(DEPDIR)/intc.Po \
2.103 @AMDEP_TRUE@ ./$(DEPDIR)/loader.Po ./$(DEPDIR)/main.Po \
2.104 @AMDEP_TRUE@ ./$(DEPDIR)/main_win.Po ./$(DEPDIR)/maple.Po \
2.105 @AMDEP_TRUE@ ./$(DEPDIR)/mem.Po ./$(DEPDIR)/mmio_win.Po \
2.106 @@ -422,8 +438,9 @@
2.107 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_null.Po@am__quote@
2.108 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bios.Po@am__quote@
2.109 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bootstrap.Po@am__quote@
2.110 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cd_linux.Po@am__quote@
2.111 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cd_none.Po@am__quote@
2.112 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdi.Po@am__quote@
2.113 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdnone.Po@am__quote@
2.114 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@
2.115 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller.Po@am__quote@
2.116 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctrl_dlg.Po@am__quote@
2.117 @@ -452,7 +469,6 @@
2.118 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ide.Po@am__quote@
2.119 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insparse.Po@am__quote@
2.120 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intc.Po@am__quote@
2.121 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux.Po@am__quote@
2.122 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loader.Po@am__quote@
2.123 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
2.124 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main_win.Po@am__quote@
2.125 @@ -1878,49 +1894,49 @@
2.126 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.127 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_slsrc.obj `if test -f 'drivers/gl_slsrc.c'; then $(CYGPATH_W) 'drivers/gl_slsrc.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_slsrc.c'; fi`
2.128
2.129 -linux.o: gdrom/linux.c
2.130 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linux.o -MD -MP -MF "$(DEPDIR)/linux.Tpo" \
2.131 -@am__fastdepCC_TRUE@ -c -o linux.o `test -f 'gdrom/linux.c' || echo '$(srcdir)/'`gdrom/linux.c; \
2.132 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/linux.Tpo" "$(DEPDIR)/linux.Po"; \
2.133 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/linux.Tpo"; exit 1; \
2.134 +cd_linux.o: drivers/cd_linux.c
2.135 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cd_linux.o -MD -MP -MF "$(DEPDIR)/cd_linux.Tpo" \
2.136 +@am__fastdepCC_TRUE@ -c -o cd_linux.o `test -f 'drivers/cd_linux.c' || echo '$(srcdir)/'`drivers/cd_linux.c; \
2.137 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cd_linux.Tpo" "$(DEPDIR)/cd_linux.Po"; \
2.138 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cd_linux.Tpo"; exit 1; \
2.139 @am__fastdepCC_TRUE@ fi
2.140 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gdrom/linux.c' object='linux.o' libtool=no @AMDEPBACKSLASH@
2.141 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/linux.Po' tmpdepfile='$(DEPDIR)/linux.TPo' @AMDEPBACKSLASH@
2.142 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cd_linux.c' object='cd_linux.o' libtool=no @AMDEPBACKSLASH@
2.143 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cd_linux.Po' tmpdepfile='$(DEPDIR)/cd_linux.TPo' @AMDEPBACKSLASH@
2.144 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.145 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linux.o `test -f 'gdrom/linux.c' || echo '$(srcdir)/'`gdrom/linux.c
2.146 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cd_linux.o `test -f 'drivers/cd_linux.c' || echo '$(srcdir)/'`drivers/cd_linux.c
2.147
2.148 -linux.obj: gdrom/linux.c
2.149 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linux.obj -MD -MP -MF "$(DEPDIR)/linux.Tpo" \
2.150 -@am__fastdepCC_TRUE@ -c -o linux.obj `if test -f 'gdrom/linux.c'; then $(CYGPATH_W) 'gdrom/linux.c'; else $(CYGPATH_W) '$(srcdir)/gdrom/linux.c'; fi`; \
2.151 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/linux.Tpo" "$(DEPDIR)/linux.Po"; \
2.152 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/linux.Tpo"; exit 1; \
2.153 +cd_linux.obj: drivers/cd_linux.c
2.154 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cd_linux.obj -MD -MP -MF "$(DEPDIR)/cd_linux.Tpo" \
2.155 +@am__fastdepCC_TRUE@ -c -o cd_linux.obj `if test -f 'drivers/cd_linux.c'; then $(CYGPATH_W) 'drivers/cd_linux.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cd_linux.c'; fi`; \
2.156 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cd_linux.Tpo" "$(DEPDIR)/cd_linux.Po"; \
2.157 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cd_linux.Tpo"; exit 1; \
2.158 @am__fastdepCC_TRUE@ fi
2.159 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gdrom/linux.c' object='linux.obj' libtool=no @AMDEPBACKSLASH@
2.160 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/linux.Po' tmpdepfile='$(DEPDIR)/linux.TPo' @AMDEPBACKSLASH@
2.161 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cd_linux.c' object='cd_linux.obj' libtool=no @AMDEPBACKSLASH@
2.162 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cd_linux.Po' tmpdepfile='$(DEPDIR)/cd_linux.TPo' @AMDEPBACKSLASH@
2.163 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.164 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linux.obj `if test -f 'gdrom/linux.c'; then $(CYGPATH_W) 'gdrom/linux.c'; else $(CYGPATH_W) '$(srcdir)/gdrom/linux.c'; fi`
2.165 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cd_linux.obj `if test -f 'drivers/cd_linux.c'; then $(CYGPATH_W) 'drivers/cd_linux.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cd_linux.c'; fi`
2.166
2.167 -cdnone.o: gdrom/cdnone.c
2.168 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdnone.o -MD -MP -MF "$(DEPDIR)/cdnone.Tpo" \
2.169 -@am__fastdepCC_TRUE@ -c -o cdnone.o `test -f 'gdrom/cdnone.c' || echo '$(srcdir)/'`gdrom/cdnone.c; \
2.170 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cdnone.Tpo" "$(DEPDIR)/cdnone.Po"; \
2.171 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cdnone.Tpo"; exit 1; \
2.172 +cd_none.o: drivers/cd_none.c
2.173 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cd_none.o -MD -MP -MF "$(DEPDIR)/cd_none.Tpo" \
2.174 +@am__fastdepCC_TRUE@ -c -o cd_none.o `test -f 'drivers/cd_none.c' || echo '$(srcdir)/'`drivers/cd_none.c; \
2.175 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cd_none.Tpo" "$(DEPDIR)/cd_none.Po"; \
2.176 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cd_none.Tpo"; exit 1; \
2.177 @am__fastdepCC_TRUE@ fi
2.178 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gdrom/cdnone.c' object='cdnone.o' libtool=no @AMDEPBACKSLASH@
2.179 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cdnone.Po' tmpdepfile='$(DEPDIR)/cdnone.TPo' @AMDEPBACKSLASH@
2.180 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cd_none.c' object='cd_none.o' libtool=no @AMDEPBACKSLASH@
2.181 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cd_none.Po' tmpdepfile='$(DEPDIR)/cd_none.TPo' @AMDEPBACKSLASH@
2.182 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.183 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdnone.o `test -f 'gdrom/cdnone.c' || echo '$(srcdir)/'`gdrom/cdnone.c
2.184 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cd_none.o `test -f 'drivers/cd_none.c' || echo '$(srcdir)/'`drivers/cd_none.c
2.185
2.186 -cdnone.obj: gdrom/cdnone.c
2.187 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdnone.obj -MD -MP -MF "$(DEPDIR)/cdnone.Tpo" \
2.188 -@am__fastdepCC_TRUE@ -c -o cdnone.obj `if test -f 'gdrom/cdnone.c'; then $(CYGPATH_W) 'gdrom/cdnone.c'; else $(CYGPATH_W) '$(srcdir)/gdrom/cdnone.c'; fi`; \
2.189 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cdnone.Tpo" "$(DEPDIR)/cdnone.Po"; \
2.190 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cdnone.Tpo"; exit 1; \
2.191 +cd_none.obj: drivers/cd_none.c
2.192 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cd_none.obj -MD -MP -MF "$(DEPDIR)/cd_none.Tpo" \
2.193 +@am__fastdepCC_TRUE@ -c -o cd_none.obj `if test -f 'drivers/cd_none.c'; then $(CYGPATH_W) 'drivers/cd_none.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cd_none.c'; fi`; \
2.194 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cd_none.Tpo" "$(DEPDIR)/cd_none.Po"; \
2.195 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/cd_none.Tpo"; exit 1; \
2.196 @am__fastdepCC_TRUE@ fi
2.197 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gdrom/cdnone.c' object='cdnone.obj' libtool=no @AMDEPBACKSLASH@
2.198 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cdnone.Po' tmpdepfile='$(DEPDIR)/cdnone.TPo' @AMDEPBACKSLASH@
2.199 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cd_none.c' object='cd_none.obj' libtool=no @AMDEPBACKSLASH@
2.200 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/cd_none.Po' tmpdepfile='$(DEPDIR)/cd_none.TPo' @AMDEPBACKSLASH@
2.201 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.202 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdnone.obj `if test -f 'gdrom/cdnone.c'; then $(CYGPATH_W) 'gdrom/cdnone.c'; else $(CYGPATH_W) '$(srcdir)/gdrom/cdnone.c'; fi`
2.203 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cd_none.obj `if test -f 'drivers/cd_none.c'; then $(CYGPATH_W) 'drivers/cd_none.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cd_none.c'; fi`
2.204
2.205 testsh4x86.o: test/testsh4x86.c
2.206 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT testsh4x86.o -MD -MP -MF "$(DEPDIR)/testsh4x86.Tpo" \
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/drivers/cd_linux.c Fri Nov 16 23:51:23 2007 +0000
3.3 @@ -0,0 +1,299 @@
3.4 +/**
3.5 + * $Id: linux.c,v 1.9 2007-11-04 05:07:49 nkeynes Exp $
3.6 + *
3.7 + * Linux cd-rom device driver.
3.8 + *
3.9 + * Copyright (c) 2005 Nathan Keynes.
3.10 + *
3.11 + * This program is free software; you can redistribute it and/or modify
3.12 + * it under the terms of the GNU General Public License as published by
3.13 + * the Free Software Foundation; either version 2 of the License, or
3.14 + * (at your option) any later version.
3.15 + *
3.16 + * This program is distributed in the hope that it will be useful,
3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.19 + * GNU General Public License for more details.
3.20 + */
3.21 +#include <unistd.h>
3.22 +#include <stdlib.h>
3.23 +#include <stdio.h>
3.24 +#include <string.h>
3.25 +#include <errno.h>
3.26 +#include <linux/cdrom.h>
3.27 +#include <sys/stat.h>
3.28 +#include <sys/ioctl.h>
3.29 +#include <fstab.h>
3.30 +#include <fcntl.h>
3.31 +
3.32 +#include "gdrom/gdrom.h"
3.33 +#include "gdrom/packet.h"
3.34 +#include "dream.h"
3.35 +
3.36 +#define MAXTOCENTRIES 600 /* This is a fairly generous overestimate really */
3.37 +#define MAXTOCSIZE 4 + (MAXTOCENTRIES*11)
3.38 +#define MAX_SECTORS_PER_CALL 1
3.39 +
3.40 +#define MSFTOLBA( m,s,f ) (f + (s*CD_FRAMES) + (m*CD_FRAMES*CD_SECS))
3.41 +
3.42 +static uint32_t inline lbatomsf( uint32_t lba ) {
3.43 + union cdrom_addr addr;
3.44 + lba = lba + CD_MSF_OFFSET;
3.45 + addr.msf.frame = lba % CD_FRAMES;
3.46 + int seconds = lba / CD_FRAMES;
3.47 + addr.msf.second = seconds % CD_SECS;
3.48 + addr.msf.minute = seconds / CD_SECS;
3.49 + return addr.lba;
3.50 +}
3.51 +
3.52 +#define LBATOMSF( lba ) lbatomsf(lba)
3.53 +
3.54 +
3.55 +static gboolean linux_image_is_valid( FILE *f );
3.56 +static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f );
3.57 +static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc );
3.58 +static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,
3.59 + int mode, unsigned char *buf, uint32_t *length );
3.60 +static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,
3.61 + int direction );
3.62 +static int linux_drive_status( gdrom_disc_t disc );
3.63 +
3.64 +struct gdrom_image_class cdrom_device_class = { "Linux", NULL,
3.65 + linux_image_is_valid, linux_open_device };
3.66 +GList *gdrom_get_native_devices(void)
3.67 +{
3.68 + GList *list = NULL;
3.69 + struct fstab *ent;
3.70 + struct stat st;
3.71 + setfsent();
3.72 + while( (ent = getfsent()) != NULL ) {
3.73 + if( (stat(ent->fs_spec, &st) != -1) &&
3.74 + S_ISBLK(st.st_mode) ) {
3.75 + /* Got a valid block device - is it a CDROM? */
3.76 + int fd = open(ent->fs_spec, O_RDONLY|O_NONBLOCK);
3.77 + if( fd == -1 )
3.78 + continue;
3.79 + int caps = ioctl(fd, CDROM_GET_CAPABILITY);
3.80 + if( caps != -1 ) {
3.81 + /* Appears to support CDROM functions */
3.82 + list = g_list_append( list, g_strdup(ent->fs_spec) );
3.83 + }
3.84 + close(fd);
3.85 + }
3.86 + }
3.87 + return list;
3.88 +}
3.89 +
3.90 +static gboolean linux_image_is_valid( FILE *f )
3.91 +{
3.92 + struct stat st;
3.93 + struct cdrom_tochdr tochdr;
3.94 +
3.95 + if( fstat(fileno(f), &st) == -1 ) {
3.96 + return FALSE; /* can't stat device? */
3.97 + }
3.98 + if( !S_ISBLK(st.st_mode) ) {
3.99 + return FALSE; /* Not a block device */
3.100 + }
3.101 +
3.102 + if( ioctl(fileno(f), CDROMREADTOCHDR, &tochdr) == -1 ) {
3.103 + /* Quick check that this is really a CD */
3.104 + return FALSE;
3.105 + }
3.106 +
3.107 + return TRUE;
3.108 +}
3.109 +
3.110 +static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f )
3.111 +{
3.112 + gdrom_disc_t disc;
3.113 +
3.114 + disc = gdrom_image_new(filename, f);
3.115 + if( disc == NULL ) {
3.116 + ERROR("Unable to allocate memory!");
3.117 + return NULL;
3.118 + }
3.119 +
3.120 + gdrom_error_t status = linux_read_disc_toc( (gdrom_image_t)disc );
3.121 + if( status != 0 ) {
3.122 + gdrom_image_destroy_no_close(disc);
3.123 + if( status == 0xFFFF ) {
3.124 + ERROR("Unable to load disc table of contents (%s)", strerror(errno));
3.125 + } else {
3.126 + ERROR("Unable to load disc table of contents (sense %d,%d)",
3.127 + status &0xFF, status >> 8 );
3.128 + }
3.129 + return NULL;
3.130 + }
3.131 + disc->read_sector = linux_read_sector;
3.132 + disc->drive_status = linux_drive_status;
3.133 + ((gdrom_image_t)disc)->disc_type = IDE_DISC_CDROM;
3.134 + return disc;
3.135 +}
3.136 +
3.137 +static int linux_drive_status( gdrom_disc_t disc )
3.138 +{
3.139 + int fd = fileno(((gdrom_image_t)disc)->file);
3.140 + int status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
3.141 + if( status == CDS_DISC_OK ) {
3.142 + status = ioctl(fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);
3.143 + if( status != 0 ) {
3.144 + linux_read_disc_toc( (gdrom_image_t)disc);
3.145 + }
3.146 + return ((gdrom_image_t)disc)->disc_type | IDE_DISC_READY;
3.147 + } else {
3.148 + return IDE_DISC_NONE;
3.149 + }
3.150 +}
3.151 +/**
3.152 + * Read the full table of contents into the disc from the device.
3.153 + */
3.154 +static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc )
3.155 +{
3.156 + int fd = fileno(disc->file);
3.157 + unsigned char buf[MAXTOCSIZE];
3.158 + size_t buflen = sizeof(buf);
3.159 + char cmd[12] = { 0x43, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
3.160 +
3.161 + cmd[7] = (sizeof(buf))>>8;
3.162 + cmd[8] = (sizeof(buf))&0xFF;
3.163 + memset( buf, 0, sizeof(buf) );
3.164 + gdrom_error_t status = linux_send_command( fd, cmd, buf, &buflen, CGC_DATA_READ );
3.165 + if( status != 0 ) {
3.166 + return status;
3.167 + }
3.168 +
3.169 + int max_track = 0;
3.170 + int last_track = -1;
3.171 + int leadout = -1;
3.172 + int len = (buf[0] << 8) | buf[1];
3.173 + int session_type = GDROM_MODE1;
3.174 + int i;
3.175 + for( i = 4; i<len; i+=11 ) {
3.176 + int session = buf[i];
3.177 + int adr = buf[i+1] >> 4;
3.178 + int point = buf[i+3];
3.179 + if( adr == 0x01 && point > 0 && point < 100 ) {
3.180 + /* Track info */
3.181 + int trackno = point-1;
3.182 + if( point > max_track ) {
3.183 + max_track = point;
3.184 + }
3.185 + disc->track[trackno].flags = (buf[i+1] & 0x0F) << 4;
3.186 + disc->track[trackno].session = session - 1;
3.187 + disc->track[trackno].lba = MSFTOLBA(buf[i+8],buf[i+9],buf[i+10]);
3.188 + if( disc->track[trackno].flags & TRACK_DATA ) {
3.189 + disc->track[trackno].mode = GDROM_MODE1;
3.190 + } else {
3.191 + disc->track[trackno].mode = GDROM_CDDA;
3.192 + }
3.193 + if( last_track != -1 ) {
3.194 + disc->track[last_track].sector_count = disc->track[trackno].lba -
3.195 + disc->track[last_track].lba;
3.196 + }
3.197 + last_track = trackno;
3.198 + } else switch( (adr << 8) | point ) {
3.199 + case 0x1A0: /* session info */
3.200 + if( buf[i+9] == 0x20 ) {
3.201 + session_type = GDROM_MODE2;
3.202 + } else {
3.203 + session_type = GDROM_MODE1;
3.204 + }
3.205 + case 0x1A2: /* leadout */
3.206 + leadout = MSFTOLBA(buf[i+8], buf[i+9], buf[i+10]);
3.207 + break;
3.208 + }
3.209 + }
3.210 + disc->track_count = max_track;
3.211 +
3.212 + if( leadout != -1 && last_track != -1 ) {
3.213 + disc->track[last_track].sector_count = leadout - disc->track[last_track].lba;
3.214 + }
3.215 + return 0;
3.216 +}
3.217 +
3.218 + gdrom_error_t linux_play_audio( gdrom_disc_t disc, uint32_t lba, uint32_t endlba )
3.219 +{
3.220 + int fd = fileno( ((gdrom_image_t)disc)->file );
3.221 + uint32_t real_sector = lba - CD_MSF_OFFSET;
3.222 + uint32_t length = endlba - lba;
3.223 + uint32_t buflen = 0;
3.224 + char cmd[12] = { 0xA5, 0,0,0, 0,0,0,0, 0,0,0,0 };
3.225 + cmd[2] = (real_sector >> 24) & 0xFF;
3.226 + cmd[3] = (real_sector >> 16) & 0xFF;
3.227 + cmd[4] = (real_sector >> 8) & 0xFF;
3.228 + cmd[5] = real_sector & 0xFF;
3.229 + cmd[6] = (length >> 24) & 0xFF;
3.230 + cmd[7] = (length >> 16) & 0xFF;
3.231 + cmd[8] = (length >> 8) & 0xFF;
3.232 + cmd[9] = length & 0xFF;
3.233 +
3.234 + return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
3.235 +}
3.236 +
3.237 +gdrom_error_t linux_stop_audio( gdrom_disc_t disc )
3.238 +{
3.239 + int fd = fileno( ((gdrom_image_t)disc)->file );
3.240 + uint32_t buflen = 0;
3.241 + char cmd[12] = {0x4E,0,0,0, 0,0,0,0, 0,0,0,0};
3.242 + return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
3.243 +}
3.244 +
3.245 +static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,
3.246 + int mode, unsigned char *buf, uint32_t *length )
3.247 +{
3.248 + gdrom_image_t image = (gdrom_image_t)disc;
3.249 + int fd = fileno(image->file);
3.250 + uint32_t real_sector = sector - CD_MSF_OFFSET;
3.251 + uint32_t sector_size = MAX_SECTOR_SIZE;
3.252 + char cmd[12] = { 0xBE, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
3.253 +
3.254 + cmd[1] = (mode & 0x0E) << 1;
3.255 + cmd[2] = (real_sector >> 24) & 0xFF;
3.256 + cmd[3] = (real_sector >> 16) & 0xFF;
3.257 + cmd[4] = (real_sector >> 8) & 0xFF;
3.258 + cmd[5] = real_sector & 0xFF;
3.259 + cmd[6] = 0;
3.260 + cmd[7] = 0;
3.261 + cmd[8] = 1;
3.262 + cmd[9] = 0x10;
3.263 +
3.264 + gdrom_error_t status = linux_send_command( fd, cmd, buf, &sector_size, CGC_DATA_READ );
3.265 + if( status != 0 ) {
3.266 + return status;
3.267 + }
3.268 + *length = 2048;
3.269 + return 0;
3.270 +}
3.271 +
3.272 +/**
3.273 + * Send a packet command to the device and wait for a response.
3.274 + * @return 0 on success, -1 on an operating system error, or a sense error
3.275 + * code on a device error.
3.276 + */
3.277 +static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,
3.278 + int direction )
3.279 +{
3.280 + struct request_sense sense;
3.281 + struct cdrom_generic_command cgc;
3.282 +
3.283 + memset( &cgc, 0, sizeof(cgc) );
3.284 + memset( &sense, 0, sizeof(sense) );
3.285 + memcpy( cgc.cmd, cmd, 12 );
3.286 + cgc.buffer = buffer;
3.287 + cgc.buflen = *buflen;
3.288 + cgc.sense = &sense;
3.289 + cgc.data_direction = direction;
3.290 +
3.291 + if( ioctl(fd, CDROM_SEND_PACKET, &cgc) == -1 ) {
3.292 + if( sense.sense_key == 0 ) {
3.293 + return -1;
3.294 + } else {
3.295 + /* TODO: Map newer codes back to the ones used by the gd-rom. */
3.296 + return sense.sense_key | (sense.asc<<8);
3.297 + }
3.298 + } else {
3.299 + *buflen = cgc.buflen;
3.300 + return 0;
3.301 + }
3.302 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/drivers/cd_none.c Fri Nov 16 23:51:23 2007 +0000
4.3 @@ -0,0 +1,40 @@
4.4 +/**
4.5 + * $Id: cdnone.c,v 1.1 2007-11-04 05:07:49 nkeynes Exp $
4.6 + *
4.7 + * The "null" cdrom device driver. Just provides a couple of empty stubs.
4.8 + *
4.9 + * Copyright (c) 2005 Nathan Keynes.
4.10 + *
4.11 + * This program is free software; you can redistribute it and/or modify
4.12 + * it under the terms of the GNU General Public License as published by
4.13 + * the Free Software Foundation; either version 2 of the License, or
4.14 + * (at your option) any later version.
4.15 + *
4.16 + * This program is distributed in the hope that it will be useful,
4.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.19 + * GNU General Public License for more details.
4.20 + */
4.21 +
4.22 +#include "gdrom/gdrom.h"
4.23 +
4.24 +static gboolean cdnone_image_is_valid( FILE *f );
4.25 +static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f );
4.26 +
4.27 +struct gdrom_image_class cdrom_device_class = { "None", NULL,
4.28 + cdnone_image_is_valid, cdnone_open_device };
4.29 +
4.30 +GList *gdrom_get_native_devices(void)
4.31 +{
4.32 + return NULL;
4.33 +}
4.34 +
4.35 +static gboolean cdnone_image_is_valid( FILE *f )
4.36 +{
4.37 + return FALSE;
4.38 +}
4.39 +
4.40 +static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f )
4.41 +{
4.42 + return NULL;
4.43 +}
5.1 --- a/src/gdrom/cdnone.c Thu Nov 15 12:10:08 2007 +0000
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,40 +0,0 @@
5.4 -/**
5.5 - * $Id: cdnone.c,v 1.1 2007-11-04 05:07:49 nkeynes Exp $
5.6 - *
5.7 - * The "null" cdrom device driver. Just provides a couple of empty stubs.
5.8 - *
5.9 - * Copyright (c) 2005 Nathan Keynes.
5.10 - *
5.11 - * This program is free software; you can redistribute it and/or modify
5.12 - * it under the terms of the GNU General Public License as published by
5.13 - * the Free Software Foundation; either version 2 of the License, or
5.14 - * (at your option) any later version.
5.15 - *
5.16 - * This program is distributed in the hope that it will be useful,
5.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.19 - * GNU General Public License for more details.
5.20 - */
5.21 -
5.22 -#include "gdrom/gdrom.h"
5.23 -
5.24 -static gboolean cdnone_image_is_valid( FILE *f );
5.25 -static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f );
5.26 -
5.27 -struct gdrom_image_class cdrom_device_class = { "None", NULL,
5.28 - cdnone_image_is_valid, cdnone_open_device };
5.29 -
5.30 -GList *gdrom_get_native_devices(void)
5.31 -{
5.32 - return NULL;
5.33 -}
5.34 -
5.35 -static gboolean cdnone_image_is_valid( FILE *f )
5.36 -{
5.37 - return FALSE;
5.38 -}
5.39 -
5.40 -static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f )
5.41 -{
5.42 - return NULL;
5.43 -}
6.1 --- a/src/gdrom/linux.c Thu Nov 15 12:10:08 2007 +0000
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,299 +0,0 @@
6.4 -/**
6.5 - * $Id: linux.c,v 1.9 2007-11-04 05:07:49 nkeynes Exp $
6.6 - *
6.7 - * Linux cd-rom device driver.
6.8 - *
6.9 - * Copyright (c) 2005 Nathan Keynes.
6.10 - *
6.11 - * This program is free software; you can redistribute it and/or modify
6.12 - * it under the terms of the GNU General Public License as published by
6.13 - * the Free Software Foundation; either version 2 of the License, or
6.14 - * (at your option) any later version.
6.15 - *
6.16 - * This program is distributed in the hope that it will be useful,
6.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.19 - * GNU General Public License for more details.
6.20 - */
6.21 -#include <unistd.h>
6.22 -#include <stdlib.h>
6.23 -#include <stdio.h>
6.24 -#include <string.h>
6.25 -#include <errno.h>
6.26 -#include <linux/cdrom.h>
6.27 -#include <sys/stat.h>
6.28 -#include <sys/ioctl.h>
6.29 -#include <fstab.h>
6.30 -#include <fcntl.h>
6.31 -
6.32 -#include "gdrom/gdrom.h"
6.33 -#include "gdrom/packet.h"
6.34 -#include "dream.h"
6.35 -
6.36 -#define MAXTOCENTRIES 600 /* This is a fairly generous overestimate really */
6.37 -#define MAXTOCSIZE 4 + (MAXTOCENTRIES*11)
6.38 -#define MAX_SECTORS_PER_CALL 1
6.39 -
6.40 -#define MSFTOLBA( m,s,f ) (f + (s*CD_FRAMES) + (m*CD_FRAMES*CD_SECS))
6.41 -
6.42 -static uint32_t inline lbatomsf( uint32_t lba ) {
6.43 - union cdrom_addr addr;
6.44 - lba = lba + CD_MSF_OFFSET;
6.45 - addr.msf.frame = lba % CD_FRAMES;
6.46 - int seconds = lba / CD_FRAMES;
6.47 - addr.msf.second = seconds % CD_SECS;
6.48 - addr.msf.minute = seconds / CD_SECS;
6.49 - return addr.lba;
6.50 -}
6.51 -
6.52 -#define LBATOMSF( lba ) lbatomsf(lba)
6.53 -
6.54 -
6.55 -static gboolean linux_image_is_valid( FILE *f );
6.56 -static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f );
6.57 -static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc );
6.58 -static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,
6.59 - int mode, unsigned char *buf, uint32_t *length );
6.60 -static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,
6.61 - int direction );
6.62 -static int linux_drive_status( gdrom_disc_t disc );
6.63 -
6.64 -struct gdrom_image_class cdrom_device_class = { "Linux", NULL,
6.65 - linux_image_is_valid, linux_open_device };
6.66 -GList *gdrom_get_native_devices(void)
6.67 -{
6.68 - GList *list = NULL;
6.69 - struct fstab *ent;
6.70 - struct stat st;
6.71 - setfsent();
6.72 - while( (ent = getfsent()) != NULL ) {
6.73 - if( (stat(ent->fs_spec, &st) != -1) &&
6.74 - S_ISBLK(st.st_mode) ) {
6.75 - /* Got a valid block device - is it a CDROM? */
6.76 - int fd = open(ent->fs_spec, O_RDONLY|O_NONBLOCK);
6.77 - if( fd == -1 )
6.78 - continue;
6.79 - int caps = ioctl(fd, CDROM_GET_CAPABILITY);
6.80 - if( caps != -1 ) {
6.81 - /* Appears to support CDROM functions */
6.82 - list = g_list_append( list, g_strdup(ent->fs_spec) );
6.83 - }
6.84 - close(fd);
6.85 - }
6.86 - }
6.87 - return list;
6.88 -}
6.89 -
6.90 -static gboolean linux_image_is_valid( FILE *f )
6.91 -{
6.92 - struct stat st;
6.93 - struct cdrom_tochdr tochdr;
6.94 -
6.95 - if( fstat(fileno(f), &st) == -1 ) {
6.96 - return FALSE; /* can't stat device? */
6.97 - }
6.98 - if( !S_ISBLK(st.st_mode) ) {
6.99 - return FALSE; /* Not a block device */
6.100 - }
6.101 -
6.102 - if( ioctl(fileno(f), CDROMREADTOCHDR, &tochdr) == -1 ) {
6.103 - /* Quick check that this is really a CD */
6.104 - return FALSE;
6.105 - }
6.106 -
6.107 - return TRUE;
6.108 -}
6.109 -
6.110 -static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f )
6.111 -{
6.112 - gdrom_disc_t disc;
6.113 -
6.114 - disc = gdrom_image_new(filename, f);
6.115 - if( disc == NULL ) {
6.116 - ERROR("Unable to allocate memory!");
6.117 - return NULL;
6.118 - }
6.119 -
6.120 - gdrom_error_t status = linux_read_disc_toc( (gdrom_image_t)disc );
6.121 - if( status != 0 ) {
6.122 - gdrom_image_destroy_no_close(disc);
6.123 - if( status == 0xFFFF ) {
6.124 - ERROR("Unable to load disc table of contents (%s)", strerror(errno));
6.125 - } else {
6.126 - ERROR("Unable to load disc table of contents (sense %d,%d)",
6.127 - status &0xFF, status >> 8 );
6.128 - }
6.129 - return NULL;
6.130 - }
6.131 - disc->read_sector = linux_read_sector;
6.132 - disc->drive_status = linux_drive_status;
6.133 - ((gdrom_image_t)disc)->disc_type = IDE_DISC_CDROM;
6.134 - return disc;
6.135 -}
6.136 -
6.137 -static int linux_drive_status( gdrom_disc_t disc )
6.138 -{
6.139 - int fd = fileno(((gdrom_image_t)disc)->file);
6.140 - int status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
6.141 - if( status == CDS_DISC_OK ) {
6.142 - status = ioctl(fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);
6.143 - if( status != 0 ) {
6.144 - linux_read_disc_toc( (gdrom_image_t)disc);
6.145 - }
6.146 - return ((gdrom_image_t)disc)->disc_type | IDE_DISC_READY;
6.147 - } else {
6.148 - return IDE_DISC_NONE;
6.149 - }
6.150 -}
6.151 -/**
6.152 - * Read the full table of contents into the disc from the device.
6.153 - */
6.154 -static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc )
6.155 -{
6.156 - int fd = fileno(disc->file);
6.157 - unsigned char buf[MAXTOCSIZE];
6.158 - size_t buflen = sizeof(buf);
6.159 - char cmd[12] = { 0x43, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
6.160 -
6.161 - cmd[7] = (sizeof(buf))>>8;
6.162 - cmd[8] = (sizeof(buf))&0xFF;
6.163 - memset( buf, 0, sizeof(buf) );
6.164 - gdrom_error_t status = linux_send_command( fd, cmd, buf, &buflen, CGC_DATA_READ );
6.165 - if( status != 0 ) {
6.166 - return status;
6.167 - }
6.168 -
6.169 - int max_track = 0;
6.170 - int last_track = -1;
6.171 - int leadout = -1;
6.172 - int len = (buf[0] << 8) | buf[1];
6.173 - int session_type = GDROM_MODE1;
6.174 - int i;
6.175 - for( i = 4; i<len; i+=11 ) {
6.176 - int session = buf[i];
6.177 - int adr = buf[i+1] >> 4;
6.178 - int point = buf[i+3];
6.179 - if( adr == 0x01 && point > 0 && point < 100 ) {
6.180 - /* Track info */
6.181 - int trackno = point-1;
6.182 - if( point > max_track ) {
6.183 - max_track = point;
6.184 - }
6.185 - disc->track[trackno].flags = (buf[i+1] & 0x0F) << 4;
6.186 - disc->track[trackno].session = session - 1;
6.187 - disc->track[trackno].lba = MSFTOLBA(buf[i+8],buf[i+9],buf[i+10]);
6.188 - if( disc->track[trackno].flags & TRACK_DATA ) {
6.189 - disc->track[trackno].mode = GDROM_MODE1;
6.190 - } else {
6.191 - disc->track[trackno].mode = GDROM_CDDA;
6.192 - }
6.193 - if( last_track != -1 ) {
6.194 - disc->track[last_track].sector_count = disc->track[trackno].lba -
6.195 - disc->track[last_track].lba;
6.196 - }
6.197 - last_track = trackno;
6.198 - } else switch( (adr << 8) | point ) {
6.199 - case 0x1A0: /* session info */
6.200 - if( buf[i+9] == 0x20 ) {
6.201 - session_type = GDROM_MODE2;
6.202 - } else {
6.203 - session_type = GDROM_MODE1;
6.204 - }
6.205 - case 0x1A2: /* leadout */
6.206 - leadout = MSFTOLBA(buf[i+8], buf[i+9], buf[i+10]);
6.207 - break;
6.208 - }
6.209 - }
6.210 - disc->track_count = max_track;
6.211 -
6.212 - if( leadout != -1 && last_track != -1 ) {
6.213 - disc->track[last_track].sector_count = leadout - disc->track[last_track].lba;
6.214 - }
6.215 - return 0;
6.216 -}
6.217 -
6.218 - gdrom_error_t linux_play_audio( gdrom_disc_t disc, uint32_t lba, uint32_t endlba )
6.219 -{
6.220 - int fd = fileno( ((gdrom_image_t)disc)->file );
6.221 - uint32_t real_sector = lba - CD_MSF_OFFSET;
6.222 - uint32_t length = endlba - lba;
6.223 - uint32_t buflen = 0;
6.224 - char cmd[12] = { 0xA5, 0,0,0, 0,0,0,0, 0,0,0,0 };
6.225 - cmd[2] = (real_sector >> 24) & 0xFF;
6.226 - cmd[3] = (real_sector >> 16) & 0xFF;
6.227 - cmd[4] = (real_sector >> 8) & 0xFF;
6.228 - cmd[5] = real_sector & 0xFF;
6.229 - cmd[6] = (length >> 24) & 0xFF;
6.230 - cmd[7] = (length >> 16) & 0xFF;
6.231 - cmd[8] = (length >> 8) & 0xFF;
6.232 - cmd[9] = length & 0xFF;
6.233 -
6.234 - return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
6.235 -}
6.236 -
6.237 -gdrom_error_t linux_stop_audio( gdrom_disc_t disc )
6.238 -{
6.239 - int fd = fileno( ((gdrom_image_t)disc)->file );
6.240 - uint32_t buflen = 0;
6.241 - char cmd[12] = {0x4E,0,0,0, 0,0,0,0, 0,0,0,0};
6.242 - return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
6.243 -}
6.244 -
6.245 -static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,
6.246 - int mode, unsigned char *buf, uint32_t *length )
6.247 -{
6.248 - gdrom_image_t image = (gdrom_image_t)disc;
6.249 - int fd = fileno(image->file);
6.250 - uint32_t real_sector = sector - CD_MSF_OFFSET;
6.251 - uint32_t sector_size = MAX_SECTOR_SIZE;
6.252 - char cmd[12] = { 0xBE, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
6.253 -
6.254 - cmd[1] = (mode & 0x0E) << 1;
6.255 - cmd[2] = (real_sector >> 24) & 0xFF;
6.256 - cmd[3] = (real_sector >> 16) & 0xFF;
6.257 - cmd[4] = (real_sector >> 8) & 0xFF;
6.258 - cmd[5] = real_sector & 0xFF;
6.259 - cmd[6] = 0;
6.260 - cmd[7] = 0;
6.261 - cmd[8] = 1;
6.262 - cmd[9] = 0x10;
6.263 -
6.264 - gdrom_error_t status = linux_send_command( fd, cmd, buf, &sector_size, CGC_DATA_READ );
6.265 - if( status != 0 ) {
6.266 - return status;
6.267 - }
6.268 - *length = 2048;
6.269 - return 0;
6.270 -}
6.271 -
6.272 -/**
6.273 - * Send a packet command to the device and wait for a response.
6.274 - * @return 0 on success, -1 on an operating system error, or a sense error
6.275 - * code on a device error.
6.276 - */
6.277 -static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,
6.278 - int direction )
6.279 -{
6.280 - struct request_sense sense;
6.281 - struct cdrom_generic_command cgc;
6.282 -
6.283 - memset( &cgc, 0, sizeof(cgc) );
6.284 - memset( &sense, 0, sizeof(sense) );
6.285 - memcpy( cgc.cmd, cmd, 12 );
6.286 - cgc.buffer = buffer;
6.287 - cgc.buflen = *buflen;
6.288 - cgc.sense = &sense;
6.289 - cgc.data_direction = direction;
6.290 -
6.291 - if( ioctl(fd, CDROM_SEND_PACKET, &cgc) == -1 ) {
6.292 - if( sense.sense_key == 0 ) {
6.293 - return -1;
6.294 - } else {
6.295 - /* TODO: Map newer codes back to the ones used by the gd-rom. */
6.296 - return sense.sense_key | (sense.asc<<8);
6.297 - }
6.298 - } else {
6.299 - *buflen = cgc.buflen;
6.300 - return 0;
6.301 - }
6.302 -}
.