Compare commits
18 Commits
R_0_9
...
i2cspi_BaS
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91f2dc9a16 | ||
|
|
a180851b50 | ||
|
|
d7d3b396d0 | ||
|
|
e842b2fdcd | ||
|
|
a822d3f8f5 | ||
|
|
9b9caf98e4 | ||
|
|
cc5720fea0 | ||
|
|
cf397f08c6 | ||
|
|
59e6ab844c | ||
|
|
457e781301 | ||
|
|
b19dead15f | ||
|
|
a9c85a1e94 | ||
|
|
143ad622a3 | ||
|
|
a51f325fb5 | ||
|
|
0f870ad920 | ||
|
|
e054082d95 | ||
|
|
adafdb01db | ||
|
|
f9d5a29740 |
60
.cproject
60
.cproject
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.500844171">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.500844171" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
@@ -127,8 +129,9 @@
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1712307593" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder id="cdt.managedbuild.builder.gnu.cross.1872779390" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1693427002" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option id="gnu.c.compiler.option.include.paths.559413321" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<option id="gnu.c.compiler.option.include.paths.559413321" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/m68k-elf/include"/>
|
||||
<listOptionValue builtIn="false" value="/usr/lib/gcc/m68k-elf/4.6.3/include"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.589685537" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
@@ -212,34 +215,9 @@
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.283290301;cdt.managedbuild.tool.gnu.c.compiler.input.1445023059">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171;cdt.managedbuild.toolchain.gnu.cross.base.500844171.251316721;cdt.managedbuild.tool.gnu.cross.c.compiler.1346392496;cdt.managedbuild.tool.gnu.c.compiler.input.2036594113">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171;cdt.managedbuild.toolchain.gnu.cross.base.500844171.251316721;cdt.managedbuild.tool.gnu.cross.c.compiler.915906842;cdt.managedbuild.tool.gnu.c.compiler.input.1420707322">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.c"" command="m68k-atari-mint-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171;cdt.managedbuild.toolchain.gnu.cross.base.500844171.2140460233;cdt.managedbuild.tool.gnu.cross.c.compiler.915906842.729509112;cdt.managedbuild.tool.gnu.c.compiler.input.2002421488">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.359669870;cdt.managedbuild.tool.gnu.c.compiler.input.374200372">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.1024005096;cdt.managedbuild.tool.gnu.c.compiler.input.1427165564">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
@@ -253,5 +231,33 @@
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.283290301;cdt.managedbuild.tool.gnu.c.compiler.input.1445023059">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD "${plugin_state_location}/specs.c"" command="m68k-atari-mint-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686;cdt.managedbuild.toolchain.gnu.cross.base.500844171.756690686.;cdt.managedbuild.tool.gnu.cross.c.compiler.359669870;cdt.managedbuild.tool.gnu.c.compiler.input.374200372">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171;cdt.managedbuild.toolchain.gnu.cross.base.500844171.251316721;cdt.managedbuild.tool.gnu.cross.c.compiler.915906842;cdt.managedbuild.tool.gnu.c.compiler.input.1420707322">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.500844171;cdt.managedbuild.toolchain.gnu.cross.base.500844171.2140460233;cdt.managedbuild.tool.gnu.cross.c.compiler.915906842.729509112;cdt.managedbuild.tool.gnu.c.compiler.input.2002421488">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1557606920;cdt.managedbuild.toolchain.gnu.cross.base.1557606920.894087346;cdt.managedbuild.tool.gnu.cross.c.compiler.1693427002;cdt.managedbuild.tool.gnu.c.compiler.input.589685537">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
||||
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
27
Makefile
27
Makefile
@@ -10,7 +10,7 @@
|
||||
|
||||
# can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint
|
||||
# toolchain
|
||||
COMPILE_ELF=Y
|
||||
COMPILE_ELF=N
|
||||
|
||||
ifeq (Y,$(COMPILE_ELF))
|
||||
TCPREFIX=m68k-elf-
|
||||
@@ -36,7 +36,7 @@ CFLAGS=-mcpu=5474\
|
||||
-Wno-multichar\
|
||||
-Winline\
|
||||
-O \
|
||||
-fno-omit-frame-pointer\
|
||||
-fomit-frame-pointer\
|
||||
-fno-strict-aliasing\
|
||||
-ffreestanding\
|
||||
-fleading-underscore\
|
||||
@@ -71,7 +71,19 @@ CSRCS= \
|
||||
$(SRCDIR)/sd_card.c \
|
||||
$(SRCDIR)/wait.c \
|
||||
$(SRCDIR)/s19reader.c \
|
||||
$(SRCDIR)/flash.c
|
||||
$(SRCDIR)/flash.c \
|
||||
$(SRCDIR)/fifo.c \
|
||||
$(SRCDIR)/i2c_firebee.c \
|
||||
$(SRCDIR)/usb.c \
|
||||
$(SRCDIR)/usb_kbd.c \
|
||||
$(SRCDIR)/usb_mem.c \
|
||||
$(SRCDIR)/usb_mouse.c \
|
||||
$(SRCDIR)/usb_storage.c \
|
||||
$(SRCDIR)/ehci-hcd.c \
|
||||
$(SRCDIR)/ohci-hcd.c \
|
||||
$(SRCDIR)/flash.c \
|
||||
$(SRCDIR)/xhdi_sd.c \
|
||||
$(SRCDIR)/xhdi_interface.c
|
||||
|
||||
ASRCS= \
|
||||
$(SRCDIR)/startcf.S \
|
||||
@@ -79,8 +91,9 @@ ASRCS= \
|
||||
$(SRCDIR)/mmu.S \
|
||||
$(SRCDIR)/exceptions.S \
|
||||
$(SRCDIR)/supervisor.S \
|
||||
$(SRCDIR)/illegal_instruction.S
|
||||
|
||||
$(SRCDIR)/illegal_instruction.S \
|
||||
$(SRCDIR)/xhdi_vec.S
|
||||
|
||||
COBJS=$(patsubst $(SRCDIR)/%.o,$(OBJDIR)/%.o,$(patsubst %.c,%.o,$(CSRCS)))
|
||||
AOBJS=$(patsubst $(SRCDIR)/%.o,$(OBJDIR)/%.o,$(patsubst %.S,%.o,$(ASRCS)))
|
||||
|
||||
@@ -136,7 +149,7 @@ endif
|
||||
$(LIBBAS): $(OBJS)
|
||||
$(AR) rv $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
# compile init_fpga with -mbitfield for testing purposes
|
||||
#$(OBJDIR)/init_fpga.o: CFLAGS += -mbitfield
|
||||
|
||||
@@ -154,7 +167,7 @@ $(OBJDIR)/%.o:$(SRCDIR)/%.S
|
||||
depend: $(ASRCS) $(CSRCS)
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -M $(ASRCS) $(CSRCS) | sed -e 's/^\(.*\).o:/$(OBJDIR)\/\1.o:/' > depend
|
||||
|
||||
|
||||
|
||||
ifneq (clean,$(MAKECMDGOALS))
|
||||
-include depend
|
||||
endif
|
||||
|
||||
@@ -44,6 +44,9 @@ SECTIONS
|
||||
objs/exceptions.o(.text)
|
||||
objs/supervisor.o(.text)
|
||||
objs/illegal_instruction.o(.text)
|
||||
objs/xhdi_sd.o(.text)
|
||||
objs/xhdi_interface.o(text)
|
||||
objs/xhdi_vec.o(text)
|
||||
*(.data)
|
||||
*(.bss)
|
||||
|
||||
|
||||
@@ -17,10 +17,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef _BAS_PRINTF_H_
|
||||
#define _BAS_PRINTF_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
typedef uint32_t size_t;
|
||||
#include <stddef.h>
|
||||
|
||||
extern void xvsnprintf(char *str, size_t size, const char *fmt, va_list va);
|
||||
extern void xvprintf(const char *fmt, va_list va);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
extern int strncmp(const char *s1, const char *s2, int max);
|
||||
extern char *strcpy(char *dst, const char *src);
|
||||
char *strncpy(char *dst, const char *src, int max);
|
||||
extern size_t strlen(const char *str);
|
||||
extern char *strcat(char *dst, const char *src);
|
||||
extern char *strncat(char *dst, const char *src, int max);
|
||||
|
||||
115
include/config.h
Normal file
115
include/config.h
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#ifndef COLDFIRE
|
||||
#define COLDFIRE
|
||||
#endif
|
||||
|
||||
/* DEBUG */
|
||||
#define DEBUG
|
||||
|
||||
/* DBUG */
|
||||
#define DBUG
|
||||
|
||||
/* PCI XBIOS */
|
||||
#undef PCI_XBIOS /* faster by cookie */
|
||||
|
||||
/* NETWORK */
|
||||
#ifdef COLDFIRE
|
||||
#define NETWORK
|
||||
#define ETHERNET_PORT 0 /* FEC channel */
|
||||
#undef TEST_NETWORK
|
||||
#undef DEBUG_PRINT
|
||||
#define LWIP
|
||||
#define WEB_LIGHT
|
||||
#undef FTP_SERVER
|
||||
#define ERRNO
|
||||
#define MCD_PROGQUERY
|
||||
#undef MCD_DEBUG
|
||||
|
||||
#ifdef MCF5445X /* target untested */
|
||||
#ifndef LWIP
|
||||
#undef NETWORK /* to do */
|
||||
#endif /* LWIP */
|
||||
#endif /* MCF5445X */
|
||||
|
||||
/* XBIOS */
|
||||
#define TOS_ATARI_LOGO /* defined for use TOS4.04 logo */
|
||||
|
||||
/* BDOS */
|
||||
#define NEWCODE
|
||||
#endif /* COLDFIRE */
|
||||
|
||||
/* fVDI */
|
||||
#define FVDI_STRUCT_2006
|
||||
|
||||
/* NVDI */
|
||||
#define PATCH_NVDI
|
||||
|
||||
/* VDI */
|
||||
#undef TOS_TABLES /* defined for use TOS4.04 index tables */
|
||||
|
||||
/* X86 emulator */
|
||||
#undef DEBUG_X86EMU
|
||||
#undef DEBUG_X86EMU_PCI
|
||||
#define __BIG_ENDIAN__
|
||||
#define NO_LONG_LONG
|
||||
|
||||
/* Radeon */
|
||||
#define DEFAULT_MONITOR_LAYOUT ""
|
||||
#define ATI_LOGO
|
||||
#define CONFIG_FB_RADEON_I2C
|
||||
#define CONFIG_FB_MODE_HELPERS
|
||||
#undef RADEON_TILING /* normally faster but tile 16 x 16 is not compatible with accel.c read_pixel, blit/expand_area and writes on screen frame buffer */
|
||||
#ifndef COLDFIRE
|
||||
#define RADEON_RENDER
|
||||
#endif
|
||||
#undef RADEON_THEATRE /* unfinished */
|
||||
#define RADEON_DIRECT_ACCESS /* MMIO access faster but don't check endian - little -> big conversion !!! */
|
||||
|
||||
/* Radeon VIDIX */
|
||||
#undef VIDIX_FILTER
|
||||
#undef VIDIX_ENABLE_BM /* unfinished */
|
||||
|
||||
/* RTC M5485EVB */
|
||||
#undef USE_RTC
|
||||
|
||||
/* LynxEM M5485EVB */
|
||||
#ifdef COLDFIRE
|
||||
#ifndef MCF5445X
|
||||
#ifndef MCF547X
|
||||
#undef CONFIG_VIDEO_SMI_LYNXEM
|
||||
#endif
|
||||
#endif
|
||||
#endif /* COLDFIRE */
|
||||
|
||||
/* XBIOS Setscreen */
|
||||
#define MAX_WIDTH_EMU_MONO 1024
|
||||
#define MAX_HEIGHT_EMU_MONO 768
|
||||
|
||||
/* AC97 */
|
||||
#define SOUND_AC97
|
||||
|
||||
/* USB */
|
||||
#undef USB_DEVICE /* Coldfire USB device */
|
||||
#define USB_BUFFER_SIZE 0x10000
|
||||
#define CONFIG_USB_OHCI /* PCI USB 1.1 */
|
||||
#define CONFIG_USB_EHCI /* PCI USB 2.0 */
|
||||
#undef CONFIG_EHCI_DCACHE
|
||||
#define CONFIG_SYS_OHCI_SWAP_REG_ACCESS
|
||||
#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 15
|
||||
#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 15
|
||||
#if defined(COLDFIRE) && !defined(MCF547X)
|
||||
#undef CONFIG_USB_INTERRUPT_POLLING
|
||||
#else
|
||||
#define CONFIG_USB_INTERRUPT_POLLING
|
||||
#endif /* COLDFIRE */
|
||||
#undef CONFIG_LEGACY_USB_INIT_SEQ
|
||||
#define CONFIG_USB_KEYBOARD
|
||||
#define CONFIG_USB_MOUSE
|
||||
#define CONFIG_USB_STORAGE
|
||||
#ifdef COLDFIRE
|
||||
#define CONFIG_USB_MEM_NO_CACHE
|
||||
#endif /* COLDFIRE */
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
207
include/ehci.h
Normal file
207
include/ehci.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/*-
|
||||
* Copyright (c) 2007-2008, Juniper Networks, Inc.
|
||||
* Copyright (c) 2008, Michael Trimarchi <trimarchimichael@yahoo.it>
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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 version 2 of
|
||||
* the License.
|
||||
*
|
||||
* 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 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
|
||||
*/
|
||||
|
||||
#ifndef USB_EHCI_H
|
||||
#define USB_EHCI_H
|
||||
|
||||
#if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
|
||||
#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
|
||||
#endif
|
||||
|
||||
/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
|
||||
#define DeviceRequest \
|
||||
((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
|
||||
|
||||
#define DeviceOutRequest \
|
||||
((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
|
||||
|
||||
#define InterfaceRequest \
|
||||
((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
|
||||
|
||||
#define EndpointRequest \
|
||||
((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
|
||||
|
||||
#define EndpointOutRequest \
|
||||
((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
|
||||
|
||||
/*
|
||||
* Register Space.
|
||||
*/
|
||||
struct ehci_hccr {
|
||||
uint32_t cr_capbase;
|
||||
#define HC_LENGTH(p) (((p) >> 0) & 0x00ff)
|
||||
#define HC_VERSION(p) (((p) >> 16) & 0xffff)
|
||||
uint32_t cr_hcsparams;
|
||||
#define HCS_PPC(p) ((p) & (1 << 4))
|
||||
#define HCS_INDICATOR(p) ((p) & (1 << 16)) /* Port indicators */
|
||||
#define HCS_N_PORTS(p) (((p) >> 0) & 0xf)
|
||||
uint32_t cr_hccparams;
|
||||
uint8_t cr_hcsp_portrt[8];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ehci_hcor {
|
||||
uint32_t or_usbcmd;
|
||||
#define CMD_PARK (1 << 11) /* enable "park" */
|
||||
#define CMD_PARK_CNT(c) (((c) >> 8) & 3) /* how many transfers to park */
|
||||
#define CMD_ASE (1 << 5) /* async schedule enable */
|
||||
#define CMD_LRESET (1 << 7) /* partial reset */
|
||||
#define CMD_IAAD (1 << 5) /* "doorbell" interrupt */
|
||||
#define CMD_PSE (1 << 4) /* periodic schedule enable */
|
||||
#define CMD_RESET (1 << 1) /* reset HC not bus */
|
||||
#define CMD_RUN (1 << 0) /* start/stop HC */
|
||||
uint32_t or_usbsts;
|
||||
#define STD_ASS (1 << 15)
|
||||
#define STS_PSSTAT (1 << 14)
|
||||
#define STS_RECL ( 1 << 13)
|
||||
#define STS_HALT (1 << 12)
|
||||
#define STS_IAA (1 << 5)
|
||||
#define STS_HSE (1 << 4)
|
||||
#define STS_FLR (1 << 3)
|
||||
#define STS_PCD (1 << 2)
|
||||
#define STS_USBERRINT (1 << 1)
|
||||
#define STS_USBINT (1 << 0)
|
||||
uint32_t or_usbintr;
|
||||
#define INTR_IAAE (1 << 5)
|
||||
#define INTR_HSEE (1 << 4)
|
||||
#define INTR_FLRE (1 << 3)
|
||||
#define INTR_PCDE (1 << 2)
|
||||
#define INTR_USBERRINTE (1 << 1)
|
||||
#define INTR_USBINTE (1 << 0)
|
||||
uint32_t or_frindex;
|
||||
uint32_t or_ctrldssegment;
|
||||
uint32_t or_periodiclistbase;
|
||||
uint32_t or_asynclistaddr;
|
||||
uint32_t _reserved_[9];
|
||||
uint32_t or_configflag;
|
||||
#define FLAG_CF (1 << 0) /* true: we'll support "high speed" */
|
||||
uint32_t or_portsc[CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS];
|
||||
uint32_t or_systune;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USBMODE 0x68 /* USB Device mode */
|
||||
#define USBMODE_SDIS (1 << 3) /* Stream disable */
|
||||
#define USBMODE_BE (1 << 2) /* BE/LE endiannes select */
|
||||
#define USBMODE_CM_HC (3 << 0) /* host controller mode */
|
||||
#define USBMODE_CM_IDLE (0 << 0) /* idle state */
|
||||
|
||||
/* Interface descriptor */
|
||||
struct usb_linux_interface_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bInterfaceNumber;
|
||||
unsigned char bAlternateSetting;
|
||||
unsigned char bNumEndpoints;
|
||||
unsigned char bInterfaceClass;
|
||||
unsigned char bInterfaceSubClass;
|
||||
unsigned char bInterfaceProtocol;
|
||||
unsigned char iInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Configuration descriptor information.. */
|
||||
struct usb_linux_config_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short wTotalLength;
|
||||
unsigned char bNumInterfaces;
|
||||
unsigned char bConfigurationValue;
|
||||
unsigned char iConfiguration;
|
||||
unsigned char bmAttributes;
|
||||
unsigned char MaxPower;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
|
||||
#define ehci_readl(x) (*((volatile u32 *)(x)))
|
||||
#define ehci_writel(a, b) (*((volatile u32 *)(a)) = ((volatile u32)b))
|
||||
#else
|
||||
#define ehci_readl(x) cpu_to_le32((*((volatile u32 *)(x))))
|
||||
#define ehci_writel(a, b) (*((volatile u32 *)(a)) = cpu_to_le32(((volatile u32)b)))
|
||||
#endif
|
||||
|
||||
#if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
|
||||
#define hc32_to_cpu(x) be32_to_cpu((x))
|
||||
#define cpu_to_hc32(x) cpu_to_be32((x))
|
||||
#else
|
||||
#define hc32_to_cpu(x) le32_to_cpu((x))
|
||||
#define cpu_to_hc32(x) cpu_to_le32((x))
|
||||
#endif
|
||||
|
||||
#define EHCI_PS_WKOC_E (1 << 22) /* RW wake on over current */
|
||||
#define EHCI_PS_WKDSCNNT_E (1 << 21) /* RW wake on disconnect */
|
||||
#define EHCI_PS_WKCNNT_E (1 << 20) /* RW wake on connect */
|
||||
#define EHCI_PS_PO (1 << 13) /* RW port owner */
|
||||
#define EHCI_PS_PP (1 << 12) /* RW,RO port power */
|
||||
#define EHCI_PS_LS (3 << 10) /* RO line status */
|
||||
#define EHCI_PS_PR (1 << 8) /* RW port reset */
|
||||
#define EHCI_PS_SUSP (1 << 7) /* RW suspend */
|
||||
#define EHCI_PS_FPR (1 << 6) /* RW force port resume */
|
||||
#define EHCI_PS_OCC (1 << 5) /* RWC over current change */
|
||||
#define EHCI_PS_OCA (1 << 4) /* RO over current active */
|
||||
#define EHCI_PS_PEC (1 << 3) /* RWC port enable change */
|
||||
#define EHCI_PS_PE (1 << 2) /* RW port enable */
|
||||
#define EHCI_PS_CSC (1 << 1) /* RWC connect status change */
|
||||
#define EHCI_PS_CS (1 << 0) /* RO connect status */
|
||||
#define EHCI_PS_CLEAR (EHCI_PS_OCC | EHCI_PS_PEC | EHCI_PS_CSC)
|
||||
|
||||
#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == (1 << 10))
|
||||
|
||||
/*
|
||||
* Schedule Interface Space.
|
||||
*
|
||||
* IMPORTANT: Software must ensure that no interface data structure
|
||||
* reachable by the EHCI host controller spans a 4K page boundary!
|
||||
*
|
||||
* Periodic transfers (i.e. isochronous and interrupt transfers) are
|
||||
* not supported.
|
||||
*/
|
||||
|
||||
/* Queue Element Transfer Descriptor (qTD). */
|
||||
struct qTD {
|
||||
uint32_t qt_next;
|
||||
#define QT_NEXT_TERMINATE 1
|
||||
uint32_t qt_altnext;
|
||||
uint32_t qt_token;
|
||||
uint32_t qt_buffer[5];
|
||||
};
|
||||
|
||||
/* Queue Head (QH). */
|
||||
struct QH {
|
||||
uint32_t qh_link;
|
||||
#define QH_LINK_TERMINATE 1
|
||||
#define QH_LINK_TYPE_ITD 0
|
||||
#define QH_LINK_TYPE_QH 2
|
||||
#define QH_LINK_TYPE_SITD 4
|
||||
#define QH_LINK_TYPE_FSTN 6
|
||||
uint32_t qh_endpt1;
|
||||
uint32_t qh_endpt2;
|
||||
uint32_t qh_curtd;
|
||||
struct qTD qh_overlay;
|
||||
/*
|
||||
* Add dummy fill value to make the size of this struct
|
||||
* aligned to 32 bytes
|
||||
*/
|
||||
uint8_t fill[16];
|
||||
};
|
||||
|
||||
/* Low level init functions */
|
||||
int ehci_hcd_init(void);
|
||||
int ehci_hcd_stop(void);
|
||||
|
||||
#endif /* USB_EHCI_H */
|
||||
55
include/fifo.h
Normal file
55
include/fifo.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This is taken from general implementations
|
||||
* on the internet, and definately needs some
|
||||
* work.
|
||||
*
|
||||
* good enough for now.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FIREBEE_FIFO
|
||||
#define FIREBEE_FIFO
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/*
|
||||
* FIFO
|
||||
*
|
||||
* Make this look exactly like IOREC, so that
|
||||
* we can interchange the two. But ignore the
|
||||
* low, high watermarks. For now.
|
||||
*
|
||||
* in IOREC, the notion of head/tail is opposite
|
||||
* to ours. So we place our head/tail, in the
|
||||
* equivalent positions as TOS use is. So
|
||||
* we can use this structure, intermittantly
|
||||
* with TOS.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char * buf;
|
||||
int16_t size;
|
||||
int16_t tail;
|
||||
int16_t head;
|
||||
int16_t low;
|
||||
int16_t high;
|
||||
} fifo_t;
|
||||
|
||||
void fifo_init(fifo_t*, char*, int16_t);
|
||||
void fifo_advance(fifo_t*, int16_t*);
|
||||
|
||||
uint8_t fifo_get(fifo_t*);
|
||||
void fifo_put(fifo_t*, uint8_t);
|
||||
|
||||
void fifo_clear(fifo_t*);
|
||||
|
||||
int fifo_used(fifo_t*);
|
||||
int fifo_unused(fifo_t*);
|
||||
|
||||
int fifo_full(fifo_t*);
|
||||
int fifo_empty(fifo_t*);
|
||||
|
||||
int fifo_read(fifo_t*, unsigned char *, int16_t);
|
||||
int fifo_write(fifo_t*, const unsigned char*, int16_t);
|
||||
|
||||
#endif
|
||||
48
include/i2c_firebee.h
Normal file
48
include/i2c_firebee.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* i2c.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef I2CFIREBEE_h
|
||||
#define I2CFIREBEE_h
|
||||
|
||||
#include <fifo.h>
|
||||
|
||||
#ifndef BUFSIZ
|
||||
#define BUFSIZ 512
|
||||
#endif
|
||||
|
||||
#define I2CTLREAD (('i'<<8) | 1)
|
||||
#define I2CTLWRITE (('i'<<8) | 2)
|
||||
#define I2CTLSBUF (('i'<<8) | 3)
|
||||
#define I2CTLINIT (('i'<<8) | 4)
|
||||
#define I2CTLDEV (('i'<<8) | 5)
|
||||
|
||||
// Set a specific bit
|
||||
#define set_bit(p,bit) p |= (bit)
|
||||
#define set_bit_nr(p,nr) set_bit(p,(1<<(nr)))
|
||||
|
||||
// Clear a specific bit
|
||||
#define clear_bit(p,bit) p &= ~(bit)
|
||||
#define clear_bit_nr(p,nr) clear_bit(p,(1<<(nr)))
|
||||
|
||||
#define ELAPSED(t) (t - ReadTimer())
|
||||
|
||||
#define I2C_BUFFER_LENGTH 32
|
||||
|
||||
#define I2C_READY 0
|
||||
#define I2C_MXRX 1
|
||||
#define I2C_MXTX 2
|
||||
|
||||
#define I2C_ADDR 6
|
||||
|
||||
#define I2C_READ 1
|
||||
#define I2C_WRITE 0
|
||||
|
||||
unsigned long ReadTimer();
|
||||
void DelayMicroSec(unsigned long);
|
||||
|
||||
void I2C_Init();
|
||||
int I2C_ioctl(unsigned int, unsigned long);
|
||||
|
||||
#endif
|
||||
165
include/mod_devicetable.h
Normal file
165
include/mod_devicetable.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef MOD_DEVICETABLE_H
|
||||
#define MOD_DEVICETABLE_H
|
||||
|
||||
#define PCI_ANY_ID (~0)
|
||||
|
||||
struct pci_device_id {
|
||||
unsigned long vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
|
||||
unsigned long subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
|
||||
unsigned long class, class_mask; /* (class,subclass,prog-if) triplet */
|
||||
unsigned long driver_data; /* Data private to the driver */
|
||||
};
|
||||
|
||||
#define IEEE1394_MATCH_VENDOR_ID 0x0001
|
||||
#define IEEE1394_MATCH_MODEL_ID 0x0002
|
||||
#define IEEE1394_MATCH_SPECIFIER_ID 0x0004
|
||||
#define IEEE1394_MATCH_VERSION 0x0008
|
||||
|
||||
struct ieee1394_device_id {
|
||||
unsigned long match_flags;
|
||||
unsigned long vendor_id;
|
||||
unsigned long model_id;
|
||||
unsigned long specifier_id;
|
||||
unsigned long version;
|
||||
unsigned long driver_data;
|
||||
};
|
||||
|
||||
/*
|
||||
* Device table entry for "new style" table-driven USB drivers.
|
||||
* User mode code can read these tables to choose which modules to load.
|
||||
* Declare the table as a MODULE_DEVICE_TABLE.
|
||||
*
|
||||
* A probe() parameter will point to a matching entry from this table.
|
||||
* Use the driver_info field for each match to hold information tied
|
||||
* to that match: device quirks, etc.
|
||||
*
|
||||
* Terminate the driver's table with an all-zeroes entry.
|
||||
* Use the flag values to control which fields are compared.
|
||||
*/
|
||||
|
||||
/**
|
||||
* struct usb_device_id - identifies USB devices for probing and hotplugging
|
||||
* @match_flags: Bit mask controlling of the other fields are used to match
|
||||
* against new devices. Any field except for driver_info may be used,
|
||||
* although some only make sense in conjunction with other fields.
|
||||
* This is usually set by a USB_DEVICE_*() macro, which sets all
|
||||
* other fields in this structure except for driver_info.
|
||||
* @idVendor: USB vendor ID for a device; numbers are assigned
|
||||
* by the USB forum to its members.
|
||||
* @idProduct: Vendor-assigned product ID.
|
||||
* @bcdDevice_lo: Low end of range of vendor-assigned product version numbers.
|
||||
* This is also used to identify individual product versions, for
|
||||
* a range consisting of a single device.
|
||||
* @bcdDevice_hi: High end of version number range. The range of product
|
||||
* versions is inclusive.
|
||||
* @bDeviceClass: Class of device; numbers are assigned
|
||||
* by the USB forum. Products may choose to implement classes,
|
||||
* or be vendor-specific. Device classes specify behavior of all
|
||||
* the interfaces on a devices.
|
||||
* @bDeviceSubClass: Subclass of device; associated with bDeviceClass.
|
||||
* @bDeviceProtocol: Protocol of device; associated with bDeviceClass.
|
||||
* @bInterfaceClass: Class of interface; numbers are assigned
|
||||
* by the USB forum. Products may choose to implement classes,
|
||||
* or be vendor-specific. Interface classes specify behavior only
|
||||
* of a given interface; other interfaces may support other classes.
|
||||
* @bInterfaceSubClass: Subclass of interface; associated with bInterfaceClass.
|
||||
* @bInterfaceProtocol: Protocol of interface; associated with bInterfaceClass.
|
||||
* @driver_info: Holds information used by the driver. Usually it holds
|
||||
* a pointer to a descriptor understood by the driver, or perhaps
|
||||
* device flags.
|
||||
*
|
||||
* In most cases, drivers will create a table of device IDs by using
|
||||
* USB_DEVICE(), or similar macros designed for that purpose.
|
||||
* They will then export it to userspace using MODULE_DEVICE_TABLE(),
|
||||
* and provide it to the USB core through their usb_driver structure.
|
||||
*
|
||||
* See the usb_match_id() function for information about how matches are
|
||||
* performed. Briefly, you will normally use one of several macros to help
|
||||
* construct these entries. Each entry you provide will either identify
|
||||
* one or more specific products, or will identify a class of products
|
||||
* which have agreed to behave the same. You should put the more specific
|
||||
* matches towards the beginning of your table, so that driver_info can
|
||||
* record quirks of specific products.
|
||||
*/
|
||||
struct usb_device_id {
|
||||
/* which fields to match against? */
|
||||
unsigned short match_flags;
|
||||
|
||||
/* Used for product specific matches; range is inclusive */
|
||||
unsigned short idVendor;
|
||||
unsigned short idProduct;
|
||||
unsigned short bcdDevice_lo;
|
||||
unsigned short bcdDevice_hi;
|
||||
|
||||
/* Used for device class matches */
|
||||
unsigned char bDeviceClass;
|
||||
unsigned char bDeviceSubClass;
|
||||
unsigned char bDeviceProtocol;
|
||||
|
||||
/* Used for interface class matches */
|
||||
unsigned char bInterfaceClass;
|
||||
unsigned char bInterfaceSubClass;
|
||||
unsigned char bInterfaceProtocol;
|
||||
|
||||
/* not matched against */
|
||||
unsigned long driver_info;
|
||||
};
|
||||
|
||||
/* Some useful macros to use to create struct usb_device_id */
|
||||
#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
|
||||
#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
|
||||
#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
|
||||
#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
|
||||
#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
|
||||
#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
|
||||
#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
|
||||
#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
|
||||
#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
|
||||
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
|
||||
|
||||
/* s390 CCW devices */
|
||||
struct ccw_device_id {
|
||||
unsigned short match_flags; /* which fields to match against */
|
||||
|
||||
unsigned short cu_type; /* control unit type */
|
||||
unsigned short dev_type; /* device type */
|
||||
unsigned char cu_model; /* control unit model */
|
||||
unsigned char dev_model; /* device model */
|
||||
|
||||
unsigned long driver_info;
|
||||
};
|
||||
|
||||
#define CCW_DEVICE_ID_MATCH_CU_TYPE 0x01
|
||||
#define CCW_DEVICE_ID_MATCH_CU_MODEL 0x02
|
||||
#define CCW_DEVICE_ID_MATCH_DEVICE_TYPE 0x04
|
||||
#define CCW_DEVICE_ID_MATCH_DEVICE_MODEL 0x08
|
||||
|
||||
|
||||
#define PNP_ID_LEN 8
|
||||
#define PNP_MAX_DEVICES 8
|
||||
|
||||
struct pnp_device_id {
|
||||
unsigned char id[PNP_ID_LEN];
|
||||
unsigned long driver_data;
|
||||
};
|
||||
|
||||
struct pnp_card_device_id {
|
||||
unsigned char id[PNP_ID_LEN];
|
||||
unsigned long driver_data;
|
||||
struct {
|
||||
unsigned char id[PNP_ID_LEN];
|
||||
} devs[PNP_MAX_DEVICES];
|
||||
};
|
||||
|
||||
|
||||
#define SERIO_ANY 0xff
|
||||
|
||||
struct serio_device_id {
|
||||
unsigned char type;
|
||||
unsigned char extra;
|
||||
unsigned char id;
|
||||
unsigned char proto;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MOD_DEVICETABLE_H */
|
||||
480
include/ohci.h
Normal file
480
include/ohci.h
Normal file
@@ -0,0 +1,480 @@
|
||||
/*
|
||||
* URB OHCI HCD (Host Controller Driver) for USB.
|
||||
*
|
||||
* (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
|
||||
* (C) Copyright 2000-2001 David Brownell <dbrownell@users.sourceforge.net>
|
||||
*
|
||||
* usb-ohci.h
|
||||
*/
|
||||
|
||||
static int cc_to_error[16] = {
|
||||
|
||||
/* mapping of the OHCI CC status to error codes */
|
||||
/* No Error */ 0,
|
||||
/* CRC Error */ USB_ST_CRC_ERR,
|
||||
/* Bit Stuff */ USB_ST_BIT_ERR,
|
||||
/* Data Togg */ USB_ST_CRC_ERR,
|
||||
/* Stall */ USB_ST_STALLED,
|
||||
/* DevNotResp */ -1,
|
||||
/* PIDCheck */ USB_ST_BIT_ERR,
|
||||
/* UnExpPID */ USB_ST_BIT_ERR,
|
||||
/* DataOver */ USB_ST_BUF_ERR,
|
||||
/* DataUnder */ USB_ST_BUF_ERR,
|
||||
/* reservd */ -1,
|
||||
/* reservd */ -1,
|
||||
/* BufferOver */ USB_ST_BUF_ERR,
|
||||
/* BuffUnder */ USB_ST_BUF_ERR,
|
||||
/* Not Access */ -1,
|
||||
/* Not Access */ -1
|
||||
};
|
||||
|
||||
static const char *cc_to_string[16] = {
|
||||
"No Error",
|
||||
"CRC: Last data packet from endpoint contained a CRC error.",
|
||||
"BITSTUFFING:\r\nLast data packet from endpoint contained a bit stuffing violation",
|
||||
"DATATOGGLEMISMATCH:\r\n Last packet from endpoint had data toggle PID\r\n" \
|
||||
"that did not match the expected value.",
|
||||
"STALL: TD was moved to the Done Queue because the endpoint returned a STALL PID",
|
||||
"DEVICENOTRESPONDING:\r\nDevice did not respond to token (IN) or did\r\n" \
|
||||
"not provide a handshake (OUT)",
|
||||
"PIDCHECKFAILURE:\r\nCheck bits on PID from endpoint failed on data PID\r\n"\
|
||||
"(IN) or handshake (OUT)",
|
||||
"UNEXPECTEDPID:\r\nReceive PID was not valid when encountered or PID\r\n" \
|
||||
"value is not defined.",
|
||||
"DATAOVERRUN:\r\nThe amount of data returned by the endpoint exceeded\r\n" \
|
||||
"either the size of the maximum data packet allowed\r\n" \
|
||||
"from the endpoint (found in MaximumPacketSize field\r\n" \
|
||||
"of ED) or the remaining buffer size.",
|
||||
"DATAUNDERRUN:\r\nThe endpoint returned less than MaximumPacketSize\r\n" \
|
||||
"and that amount was not sufficient to fill the\r\n" \
|
||||
"specified buffer",
|
||||
"reserved1",
|
||||
"reserved2",
|
||||
"BUFFEROVERRUN:\r\nDuring an IN, HC received data from endpoint faster\r\n" \
|
||||
"than it could be written to system memory",
|
||||
"BUFFERUNDERRUN:\r\nDuring an OUT, HC could not retrieve data from\r\n" \
|
||||
"system memory fast enough to keep up with data USB data rate.",
|
||||
"NOT ACCESSED:\r\nThis code is set by software before the TD is placed\r\n" \
|
||||
"on a list to be processed by the HC.(1)",
|
||||
"NOT ACCESSED:\r\nThis code is set by software before the TD is placed\r\n" \
|
||||
"on a list to be processed by the HC.(2)",
|
||||
};
|
||||
|
||||
/* ED States */
|
||||
|
||||
#define ED_NEW 0x00
|
||||
#define ED_UNLINK 0x01
|
||||
#define ED_OPER 0x02
|
||||
#define ED_DEL 0x04
|
||||
#define ED_URB_DEL 0x08
|
||||
|
||||
/* usb_ohci_ed */
|
||||
struct ed {
|
||||
__u32 hwINFO;
|
||||
__u32 hwTailP;
|
||||
__u32 hwHeadP;
|
||||
__u32 hwNextED;
|
||||
|
||||
struct ed *ed_prev;
|
||||
__u8 int_period;
|
||||
__u8 int_branch;
|
||||
__u8 int_load;
|
||||
__u8 int_interval;
|
||||
__u8 state;
|
||||
__u8 type;
|
||||
__u16 last_iso;
|
||||
struct ed *ed_rm_list;
|
||||
|
||||
struct usb_device *usb_dev;
|
||||
void *purb;
|
||||
__u32 unused[2];
|
||||
} __attribute__((aligned(16)));
|
||||
typedef struct ed ed_t;
|
||||
|
||||
|
||||
/* TD info field */
|
||||
#define TD_CC 0xf0000000
|
||||
#define TD_CC_GET(td_p) ((td_p >>28) & 0x0f)
|
||||
#define TD_CC_SET(td_p, cc) (td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)
|
||||
#define TD_EC 0x0C000000
|
||||
#define TD_T 0x03000000
|
||||
#define TD_T_DATA0 0x02000000
|
||||
#define TD_T_DATA1 0x03000000
|
||||
#define TD_T_TOGGLE 0x00000000
|
||||
#define TD_R 0x00040000
|
||||
#define TD_DI 0x00E00000
|
||||
#define TD_DI_SET(X) (((X) & 0x07)<< 21)
|
||||
#define TD_DP 0x00180000
|
||||
#define TD_DP_SETUP 0x00000000
|
||||
#define TD_DP_IN 0x00100000
|
||||
#define TD_DP_OUT 0x00080000
|
||||
|
||||
#define TD_ISO 0x00010000
|
||||
#define TD_DEL 0x00020000
|
||||
|
||||
/* CC Codes */
|
||||
#define TD_CC_NOERROR 0x00
|
||||
#define TD_CC_CRC 0x01
|
||||
#define TD_CC_BITSTUFFING 0x02
|
||||
#define TD_CC_DATATOGGLEM 0x03
|
||||
#define TD_CC_STALL 0x04
|
||||
#define TD_DEVNOTRESP 0x05
|
||||
#define TD_PIDCHECKFAIL 0x06
|
||||
#define TD_UNEXPECTEDPID 0x07
|
||||
#define TD_DATAOVERRUN 0x08
|
||||
#define TD_DATAUNDERRUN 0x09
|
||||
#define TD_BUFFEROVERRUN 0x0C
|
||||
#define TD_BUFFERUNDERRUN 0x0D
|
||||
#define TD_NOTACCESSED 0x0F
|
||||
|
||||
|
||||
#define MAXPSW 1
|
||||
|
||||
struct td {
|
||||
__u32 hwINFO;
|
||||
__u32 hwCBP; /* Current Buffer Pointer */
|
||||
__u32 hwNextTD; /* Next TD Pointer */
|
||||
__u32 hwBE; /* Memory Buffer End Pointer */
|
||||
|
||||
__u16 hwPSW[MAXPSW];
|
||||
__u8 unused;
|
||||
__u8 index;
|
||||
struct ed *ed;
|
||||
struct td *next_dl_td;
|
||||
struct usb_device *usb_dev;
|
||||
int transfer_len;
|
||||
__u32 data;
|
||||
|
||||
__u32 unused2[2];
|
||||
} __attribute__((aligned(32)));
|
||||
typedef struct td td_t;
|
||||
|
||||
#define OHCI_ED_SKIP (1 << 14)
|
||||
|
||||
/*
|
||||
* The HCCA (Host Controller Communications Area) is a 256 byte
|
||||
* structure defined in the OHCI spec. that the host controller is
|
||||
* told the base address of. It must be 256-byte aligned.
|
||||
*/
|
||||
|
||||
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||
struct ohci_hcca {
|
||||
__u32 int_table[NUM_INTS]; /* Interrupt ED table */
|
||||
#if defined(CONFIG_MPC5200)
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
__u16 frame_no; /* current frame number */
|
||||
#else
|
||||
__u16 frame_no; /* current frame number */
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
#endif
|
||||
__u32 done_head; /* info returned for an interrupt */
|
||||
u8 reserved_for_hc[116];
|
||||
} __attribute__((aligned(256)));
|
||||
|
||||
|
||||
/*
|
||||
* Maximum number of root hub ports.
|
||||
*/
|
||||
#ifndef CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS
|
||||
# error "CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS undefined!"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is the structure of the OHCI controller's memory mapped I/O
|
||||
* region. This is Memory Mapped I/O. You must use the readl() and
|
||||
* writel() macros defined in asm/io.h to access these!!
|
||||
*/
|
||||
struct ohci_regs {
|
||||
/* control and status registers */
|
||||
__u32 revision;
|
||||
__u32 control;
|
||||
__u32 cmdstatus;
|
||||
__u32 intrstatus;
|
||||
__u32 intrenable;
|
||||
__u32 intrdisable;
|
||||
/* memory pointers */
|
||||
__u32 hcca;
|
||||
__u32 ed_periodcurrent;
|
||||
__u32 ed_controlhead;
|
||||
__u32 ed_controlcurrent;
|
||||
__u32 ed_bulkhead;
|
||||
__u32 ed_bulkcurrent;
|
||||
__u32 donehead;
|
||||
/* frame counters */
|
||||
__u32 fminterval;
|
||||
__u32 fmremaining;
|
||||
__u32 fmnumber;
|
||||
__u32 periodicstart;
|
||||
__u32 lsthresh;
|
||||
/* Root hub ports */
|
||||
struct ohci_roothub_regs {
|
||||
__u32 a;
|
||||
__u32 b;
|
||||
__u32 status;
|
||||
__u32 portstatus[CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS];
|
||||
} roothub;
|
||||
} __attribute__((aligned(32)));
|
||||
|
||||
/* Some EHCI controls */
|
||||
#define EHCI_USBCMD_OFF 0x20
|
||||
#define EHCI_USBCMD_HCRESET (1 << 1)
|
||||
|
||||
/* OHCI CONTROL AND STATUS REGISTER MASKS */
|
||||
|
||||
/*
|
||||
* HcControl (control) register masks
|
||||
*/
|
||||
#define OHCI_CTRL_CBSR (3 << 0) /* control/bulk service ratio */
|
||||
#define OHCI_CTRL_PLE (1 << 2) /* periodic list enable */
|
||||
#define OHCI_CTRL_IE (1 << 3) /* isochronous enable */
|
||||
#define OHCI_CTRL_CLE (1 << 4) /* control list enable */
|
||||
#define OHCI_CTRL_BLE (1 << 5) /* bulk list enable */
|
||||
#define OHCI_CTRL_HCFS (3 << 6) /* host controller functional state */
|
||||
#define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
|
||||
#define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
|
||||
#define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */
|
||||
|
||||
/* pre-shifted values for HCFS */
|
||||
# define OHCI_USB_RESET (0 << 6)
|
||||
# define OHCI_USB_RESUME (1 << 6)
|
||||
# define OHCI_USB_OPER (2 << 6)
|
||||
# define OHCI_USB_SUSPEND (3 << 6)
|
||||
|
||||
/*
|
||||
* HcCommandStatus (cmdstatus) register masks
|
||||
*/
|
||||
#define OHCI_HCR (1 << 0) /* host controller reset */
|
||||
#define OHCI_CLF (1 << 1) /* control list filled */
|
||||
#define OHCI_BLF (1 << 2) /* bulk list filled */
|
||||
#define OHCI_OCR (1 << 3) /* ownership change request */
|
||||
#define OHCI_SOC (3 << 16) /* scheduling overrun count */
|
||||
|
||||
/*
|
||||
* masks used with interrupt registers:
|
||||
* HcInterruptStatus (intrstatus)
|
||||
* HcInterruptEnable (intrenable)
|
||||
* HcInterruptDisable (intrdisable)
|
||||
*/
|
||||
#define OHCI_INTR_SO (1 << 0) /* scheduling overrun */
|
||||
#define OHCI_INTR_WDH (1 << 1) /* writeback of done_head */
|
||||
#define OHCI_INTR_SF (1 << 2) /* start frame */
|
||||
#define OHCI_INTR_RD (1 << 3) /* resume detect */
|
||||
#define OHCI_INTR_UE (1 << 4) /* unrecoverable error */
|
||||
#define OHCI_INTR_FNO (1 << 5) /* frame number overflow */
|
||||
#define OHCI_INTR_RHSC (1 << 6) /* root hub status change */
|
||||
#define OHCI_INTR_OC (1 << 30) /* ownership change */
|
||||
#define OHCI_INTR_MIE (1 << 31) /* master interrupt enable */
|
||||
|
||||
|
||||
/* Virtual Root HUB */
|
||||
struct virt_root_hub {
|
||||
int devnum; /* Address of Root Hub endpoint */
|
||||
void *dev; /* was urb */
|
||||
void *int_addr;
|
||||
int send;
|
||||
int interval;
|
||||
};
|
||||
|
||||
/* USB HUB CONSTANTS (not OHCI-specific; see hub.h) */
|
||||
|
||||
/* destination of request */
|
||||
#define RH_INTERFACE 0x01
|
||||
#define RH_ENDPOINT 0x02
|
||||
#define RH_OTHER 0x03
|
||||
|
||||
#define RH_CLASS 0x20
|
||||
#define RH_VENDOR 0x40
|
||||
|
||||
/* Requests: bRequest << 8 | bmRequestType */
|
||||
#define RH_GET_STATUS 0x0080
|
||||
#define RH_CLEAR_FEATURE 0x0100
|
||||
#define RH_SET_FEATURE 0x0300
|
||||
#define RH_SET_ADDRESS 0x0500
|
||||
#define RH_GET_DESCRIPTOR 0x0680
|
||||
#define RH_SET_DESCRIPTOR 0x0700
|
||||
#define RH_GET_CONFIGURATION 0x0880
|
||||
#define RH_SET_CONFIGURATION 0x0900
|
||||
#define RH_GET_STATE 0x0280
|
||||
#define RH_GET_INTERFACE 0x0A80
|
||||
#define RH_SET_INTERFACE 0x0B00
|
||||
#define RH_SYNC_FRAME 0x0C80
|
||||
/* Our Vendor Specific Request */
|
||||
#define RH_SET_EP 0x2000
|
||||
|
||||
|
||||
/* Hub port features */
|
||||
#define RH_PORT_CONNECTION 0x00
|
||||
#define RH_PORT_ENABLE 0x01
|
||||
#define RH_PORT_SUSPEND 0x02
|
||||
#define RH_PORT_OVER_CURRENT 0x03
|
||||
#define RH_PORT_RESET 0x04
|
||||
#define RH_PORT_POWER 0x08
|
||||
#define RH_PORT_LOW_SPEED 0x09
|
||||
|
||||
#define RH_C_PORT_CONNECTION 0x10
|
||||
#define RH_C_PORT_ENABLE 0x11
|
||||
#define RH_C_PORT_SUSPEND 0x12
|
||||
#define RH_C_PORT_OVER_CURRENT 0x13
|
||||
#define RH_C_PORT_RESET 0x14
|
||||
|
||||
/* Hub features */
|
||||
#define RH_C_HUB_LOCAL_POWER 0x00
|
||||
#define RH_C_HUB_OVER_CURRENT 0x01
|
||||
|
||||
#define RH_DEVICE_REMOTE_WAKEUP 0x00
|
||||
#define RH_ENDPOINT_STALL 0x01
|
||||
|
||||
#define RH_ACK 0x01
|
||||
#define RH_REQ_ERR -1
|
||||
#define RH_NACK 0x00
|
||||
|
||||
|
||||
/* OHCI ROOT HUB REGISTER MASKS */
|
||||
|
||||
/* roothub.portstatus [i] bits */
|
||||
#define RH_PS_CCS 0x00000001 /* current connect status */
|
||||
#define RH_PS_PES 0x00000002 /* port enable status*/
|
||||
#define RH_PS_PSS 0x00000004 /* port suspend status */
|
||||
#define RH_PS_POCI 0x00000008 /* port over current indicator */
|
||||
#define RH_PS_PRS 0x00000010 /* port reset status */
|
||||
#define RH_PS_PPS 0x00000100 /* port power status */
|
||||
#define RH_PS_LSDA 0x00000200 /* low speed device attached */
|
||||
#define RH_PS_CSC 0x00010000 /* connect status change */
|
||||
#define RH_PS_PESC 0x00020000 /* port enable status change */
|
||||
#define RH_PS_PSSC 0x00040000 /* port suspend status change */
|
||||
#define RH_PS_OCIC 0x00080000 /* over current indicator change */
|
||||
#define RH_PS_PRSC 0x00100000 /* port reset status change */
|
||||
|
||||
/* roothub.status bits */
|
||||
#define RH_HS_LPS 0x00000001 /* local power status */
|
||||
#define RH_HS_OCI 0x00000002 /* over current indicator */
|
||||
#define RH_HS_DRWE 0x00008000 /* device remote wakeup enable */
|
||||
#define RH_HS_LPSC 0x00010000 /* local power status change */
|
||||
#define RH_HS_OCIC 0x00020000 /* over current indicator change */
|
||||
#define RH_HS_CRWE 0x80000000 /* clear remote wakeup enable */
|
||||
|
||||
/* roothub.b masks */
|
||||
#define RH_B_DR 0x0000ffff /* device removable flags */
|
||||
#define RH_B_PPCM 0xffff0000 /* port power control mask */
|
||||
|
||||
/* roothub.a masks */
|
||||
#define RH_A_NDP (0xff << 0) /* number of downstream ports */
|
||||
#define RH_A_PSM (1 << 8) /* power switching mode */
|
||||
#define RH_A_NPS (1 << 9) /* no power switching */
|
||||
#define RH_A_DT (1 << 10) /* device type (mbz) */
|
||||
#define RH_A_OCPM (1 << 11) /* over current protection mode */
|
||||
#define RH_A_NOCP (1 << 12) /* no over current protection */
|
||||
#define RH_A_POTPGT (0xff << 24) /* power on to power good time */
|
||||
|
||||
/* urb */
|
||||
#define N_URB_TD 48
|
||||
typedef struct
|
||||
{
|
||||
ed_t *ed;
|
||||
__u16 length; /* number of tds associated with this request */
|
||||
__u16 td_cnt; /* number of tds already serviced */
|
||||
struct usb_device *dev;
|
||||
int state;
|
||||
unsigned long pipe;
|
||||
void *transfer_buffer;
|
||||
int transfer_buffer_length;
|
||||
int interval;
|
||||
int actual_length;
|
||||
int finished;
|
||||
td_t *td[N_URB_TD]; /* list pointer to all corresponding TDs associated with this request */
|
||||
} urb_priv_t;
|
||||
#define URB_DEL 1
|
||||
|
||||
#define NUM_EDS 8 /* num of preallocated endpoint descriptors */
|
||||
|
||||
struct ohci_device {
|
||||
ed_t ed[NUM_EDS];
|
||||
int ed_cnt;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the full ohci controller description
|
||||
*
|
||||
* Note how the "proper" USB information is just
|
||||
* a subset of what the full implementation needs. (Linus)
|
||||
*/
|
||||
|
||||
typedef struct ohci {
|
||||
/* ------- common part -------- */
|
||||
long handle; /* PCI BIOS */
|
||||
const struct pci_device_id *ent;
|
||||
int usbnum;
|
||||
/* ---- end of common part ---- */
|
||||
int big_endian; /* PCI BIOS */
|
||||
int controller;
|
||||
struct ohci_hcca *hcca_unaligned;
|
||||
struct ohci_hcca *hcca; /* hcca */
|
||||
td_t *td_unaligned;
|
||||
struct ohci_device *ohci_dev_unaligned;
|
||||
/* this allocates EDs for all possible endpoints */
|
||||
struct ohci_device *ohci_dev;
|
||||
|
||||
int irq_enabled;
|
||||
int stat_irq;
|
||||
int irq;
|
||||
int disabled; /* e.g. got a UE, we're hung */
|
||||
int sleeping;
|
||||
#define OHCI_FLAGS_NEC 0x80000000
|
||||
unsigned long flags; /* for HC bugs */
|
||||
|
||||
unsigned long offset;
|
||||
unsigned long dma_offset;
|
||||
struct ohci_regs *regs; /* OHCI controller's memory */
|
||||
|
||||
int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/
|
||||
ed_t *ed_rm_list[2]; /* lists of all endpoints to be removed */
|
||||
ed_t *ed_bulktail; /* last endpoint of bulk list */
|
||||
ed_t *ed_controltail; /* last endpoint of control list */
|
||||
int intrstatus;
|
||||
__u32 hc_control; /* copy of the hc control reg */
|
||||
struct virt_root_hub rh;
|
||||
|
||||
const char *slot_name;
|
||||
|
||||
/* device which was disconnected */
|
||||
struct usb_device *devgone;
|
||||
} ohci_t;
|
||||
|
||||
/* hcd */
|
||||
/* endpoint */
|
||||
static int ep_link(ohci_t * ohci, ed_t * ed);
|
||||
static int ep_unlink(ohci_t * ohci, ed_t * ed);
|
||||
static ed_t * ep_add_ed(ohci_t * ohci, struct usb_device * usb_dev, unsigned long pipe, int interval, int load);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* we need more TDs than EDs */
|
||||
#define NUM_TD 64
|
||||
|
||||
/* pointers to aligned storage */
|
||||
td_t *ptd;
|
||||
|
||||
/* TDs ... */
|
||||
static inline struct td *td_alloc(struct usb_device *usb_dev)
|
||||
{
|
||||
int i;
|
||||
struct td *td;
|
||||
td = NULL;
|
||||
for(i = 0; i < NUM_TD; i++)
|
||||
{
|
||||
if(ptd[i].usb_dev == NULL)
|
||||
{
|
||||
td = &ptd[i];
|
||||
td->usb_dev = usb_dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
static inline void ed_free(struct ed *ed)
|
||||
{
|
||||
ed->usb_dev = NULL;
|
||||
}
|
||||
|
||||
|
||||
89
include/part.h
Normal file
89
include/part.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* (C) Copyright 2000-2004
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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
|
||||
*/
|
||||
#ifndef _PART_H
|
||||
#define _PART_H
|
||||
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long lbaint_t;
|
||||
|
||||
typedef struct block_dev_desc {
|
||||
int if_type; /* type of the interface */
|
||||
int dev; /* device number */
|
||||
unsigned char part_type; /* partition type */
|
||||
unsigned char target; /* target SCSI ID */
|
||||
unsigned char lun; /* target LUN */
|
||||
unsigned char type; /* device type */
|
||||
unsigned char removable; /* removable device */
|
||||
#ifdef CONFIG_LBA48
|
||||
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
|
||||
#endif
|
||||
lbaint_t lba; /* number of blocks */
|
||||
unsigned long blksz; /* block size */
|
||||
char vendor [40+1]; /* IDE model, SCSI Vendor */
|
||||
char product[20+1]; /* IDE Serial no, SCSI product */
|
||||
char revision[8+1]; /* firmware revision */
|
||||
long (*block_read)(int dev, unsigned long start, lbaint_t blkcnt, void *buffer);
|
||||
long (*block_write)(int dev, unsigned long start, lbaint_t blkcnt, const void *buffer);
|
||||
void *priv; /* driver private struct pointer */
|
||||
}block_dev_desc_t;
|
||||
|
||||
/* Interface types: */
|
||||
#define IF_TYPE_UNKNOWN 0
|
||||
#define IF_TYPE_IDE 1
|
||||
#define IF_TYPE_SCSI 2
|
||||
#define IF_TYPE_ATAPI 3
|
||||
#define IF_TYPE_USB 4
|
||||
#define IF_TYPE_DOC 5
|
||||
#define IF_TYPE_MMC 6
|
||||
#define IF_TYPE_SD 7
|
||||
#define IF_TYPE_SATA 8
|
||||
|
||||
/* Part types */
|
||||
#define PART_TYPE_UNKNOWN 0x00
|
||||
#define PART_TYPE_MAC 0x01
|
||||
#define PART_TYPE_DOS 0x02
|
||||
#define PART_TYPE_ISO 0x03
|
||||
#define PART_TYPE_AMIGA 0x04
|
||||
#define PART_TYPE_EFI 0x05
|
||||
#define PART_TYPE_GEMDOS 0x06
|
||||
|
||||
/*
|
||||
* Type string for U-Boot bootable partitions
|
||||
*/
|
||||
#define BOOT_PART_TYPE "U-Boot" /* primary boot partition type */
|
||||
#define BOOT_PART_COMP "PPCBoot" /* PPCBoot compatibility type */
|
||||
|
||||
/* device types */
|
||||
#define DEV_TYPE_UNKNOWN 0xff /* not connected */
|
||||
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
|
||||
#define DEV_TYPE_TAPE 0x01 /* Tape */
|
||||
#define DEV_TYPE_CDROM 0x05 /* CD-ROM */
|
||||
#define DEV_TYPE_OPDISK 0x07 /* optical disk */
|
||||
|
||||
void print_part(block_dev_desc_t *dev_desc);
|
||||
void init_part(block_dev_desc_t *dev_desc);
|
||||
void dev_print(block_dev_desc_t *dev_desc);
|
||||
|
||||
int fat_register_device(block_dev_desc_t *dev_desc, int part_no, unsigned long *part_type, unsigned long *part_offset, unsigned long *part_size);
|
||||
|
||||
#endif /* _PART_H */
|
||||
2624
include/pci_ids.h
Normal file
2624
include/pci_ids.h
Normal file
File diff suppressed because it is too large
Load Diff
348
include/pcixbios.h
Normal file
348
include/pcixbios.h
Normal file
@@ -0,0 +1,348 @@
|
||||
/* TOS 4.04 Xbios PCI for the CT60 board
|
||||
* Didier Mequignon 2005, e-mail: aniplay@wanadoo.fr
|
||||
*
|
||||
* 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.1 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
|
||||
*/
|
||||
|
||||
#ifndef _CT60_XBIOS_PCI_H
|
||||
#define _CT60_XBIOS_PCI_H
|
||||
|
||||
#define PCIIDR 0x00 /* PCI Configuration ID Register */
|
||||
#define PCICSR 0x04 /* PCI Command/Status Register */
|
||||
#define PCICR 0x04 /* PCI Command Register */
|
||||
#define PCISR 0x06 /* PCI Status Register */
|
||||
#define PCIREV 0x08 /* PCI Revision ID Register */
|
||||
#define PCICCR 0x09 /* PCI Class Code Register */
|
||||
#define PCICLSR 0x0C /* PCI Cache Line Size Register */
|
||||
#define PCILTR 0x0D /* PCI Latency Timer Register */
|
||||
#define PCIHTR 0x0E /* PCI Header Type Register */
|
||||
#define PCIBISTR 0x0F /* PCI Build-In Self Test Register */
|
||||
#define PCIBAR0 0x10 /* PCI Base Address Register for Memory
|
||||
Accesses to Local, Runtime, and DMA */
|
||||
#define PCIBAR1 0x14 /* PCI Base Address Register for I/O
|
||||
Accesses to Local, Runtime, and DMA */
|
||||
#define PCIBAR2 0x18 /* PCI Base Address Register for Memory
|
||||
Accesses to Local Address Space 0 */
|
||||
#define PCIBAR3 0x1C /* PCI Base Address Register for Memory
|
||||
Accesses to Local Address Space 1 */
|
||||
#define PCIBAR4 0x20 /* PCI Base Address Register, reserved */
|
||||
#define PCIBAR5 0x24 /* PCI Base Address Register, reserved */
|
||||
#define PCICIS 0x28 /* PCI Cardbus CIS Pointer, not support*/
|
||||
#define PCISVID 0x2C /* PCI Subsystem Vendor ID */
|
||||
#define PCISID 0x2E /* PCI Subsystem ID */
|
||||
#define PCIERBAR 0x30 /* PCI Expansion ROM Base Register */
|
||||
#define CAP_PTR 0x34 /* New Capability Pointer */
|
||||
#define PCIILR 0x3C /* PCI Interrupt Line Register */
|
||||
#define PCIIPR 0x3D /* PCI Interrupt Pin Register */
|
||||
#define PCIMGR 0x3E /* PCI Min_Gnt Register */
|
||||
#define PCIMLR 0x3F /* PCI Max_Lat Register */
|
||||
#define PMCAPID 0x40 /* Power Management Capability ID */
|
||||
#define PMNEXT 0x41 /* Power Management Next Capability
|
||||
Pointer */
|
||||
#define PMC 0x42 /* Power Management Capabilities */
|
||||
#define PMCSR 0x44 /* Power Management Control/Status */
|
||||
#define PMCSR_BSE 0x46 /* PMCSR Bridge Support Extensions */
|
||||
#define PMDATA 0x47 /* Power Management Data */
|
||||
#define HS_CNTL 0x48 /* Hot Swap Control */
|
||||
#define HS_NEXT 0x49 /* Hot Swap Next Capability Pointer */
|
||||
#define HS_CSR 0x4A /* Hot Swap Control/Status */
|
||||
#define PVPDCNTL 0x4C /* PCI Vital Product Data Control */
|
||||
#define PVPD_NEXT 0x4D /* PCI Vital Product Data Next
|
||||
Capability Pointer */
|
||||
#define PVPDAD 0x4E /* PCI Vital Product Data Address */
|
||||
#define PVPDATA 0x50 /* PCI VPD Data */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long *subcookie;
|
||||
unsigned long version;
|
||||
long routine[45];
|
||||
} PCI_COOKIE;
|
||||
|
||||
typedef struct /* structure of resource descriptor */
|
||||
{
|
||||
unsigned short next; /* length of the following structure */
|
||||
unsigned short flags; /* type of resource and misc. flags */
|
||||
unsigned long start; /* start-address of resource */
|
||||
unsigned long length; /* length of resource */
|
||||
unsigned long offset; /* offset PCI to phys. CPU Address */
|
||||
unsigned long dmaoffset; /* offset for DMA-transfers */
|
||||
} PCI_RSC_DESC;
|
||||
|
||||
typedef struct /* structure of address conversion */
|
||||
{
|
||||
unsigned long adr; /* calculated address (CPU<->PCI) */
|
||||
unsigned long len; /* length of memory range */
|
||||
} PCI_CONV_ADR;
|
||||
|
||||
/******************************************************************************/
|
||||
/* PCI-BIOS Error Codes */
|
||||
/******************************************************************************/
|
||||
#define PCI_SUCCESSFUL 0 /* everything's fine */
|
||||
#define PCI_FUNC_NOT_SUPPORTED -2 /* function not supported */
|
||||
#define PCI_BAD_VENDOR_ID -3 /* wrong Vendor ID */
|
||||
#define PCI_DEVICE_NOT_FOUND -4 /* PCI-Device not found */
|
||||
#define PCI_BAD_REGISTER_NUMBER -5 /* wrong register number */
|
||||
#define PCI_SET_FAILED -6 /* reserved for later use */
|
||||
#define PCI_BUFFER_TOO_SMALL -7 /* reserved for later use */
|
||||
#define PCI_GENERAL_ERROR -8 /* general BIOS error code */
|
||||
#define PCI_BAD_HANDLE -9 /* wrong/unknown PCI-handle */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Flags used in Resource-Descriptor */
|
||||
/******************************************************************************/
|
||||
#define FLG_IO 0x4000 /* Ressource in IO range */
|
||||
#define FLG_ROM 0x2000 /* Expansion ROM */
|
||||
#define FLG_LAST 0x8000 /* last ressource */
|
||||
#define FLG_8BIT 0x0100 /* 8 bit accesses allowed */
|
||||
#define FLG_16BIT 0x0200 /* 16 bit accesses allowed */
|
||||
#define FLG_32BIT 0x0400 /* 32 bit accesses allowed */
|
||||
#define FLG_ENDMASK 0x000F /* mask for byte ordering */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Values used in FLG_ENDMASK for Byte Ordering */
|
||||
/******************************************************************************/
|
||||
#define ORD_MOTOROLA 0 /* Motorola (big endian) */
|
||||
#define ORD_INTEL_AS 1 /* Intel (little endian), addr.swapped */
|
||||
#define ORD_INTEL_LS 2 /* Intel (little endian), lane swapped */
|
||||
#define ORD_UNKNOWN 15 /* unknown (BIOS-calls allowed only) */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Status Info used in Device-Descriptor */
|
||||
/******************************************************************************/
|
||||
#define DEVICE_FREE 0 /* Device is not used */
|
||||
#define DEVICE_USED 1 /* Device is used by another driver */
|
||||
#define DEVICE_CALLBACK 2 /* used, but driver can be cancelled */
|
||||
#define DEVICE_AVAILABLE 3 /* used, not available */
|
||||
#define NO_DEVICE -1 /* no device detected */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Callback-Routine */
|
||||
/******************************************************************************/
|
||||
#define GET_DRIVER_ID 0 /* CB-Routine 0: Get Driver ID */
|
||||
#define REMOVE_DRIVER 1 /* CB-Routine 1: Remove Driver */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
#ifndef OSBIND_CLOBBER_LIST
|
||||
#define OSBIND_CLOBBER_LIST "d0", "d1", "d2", "a0", "a1", "a2", "memory"
|
||||
#endif
|
||||
|
||||
#ifndef trap_14_wlw
|
||||
#define trap_14_wlw(n, a, b) \
|
||||
__extension__ \
|
||||
({ \
|
||||
register long retvalue __asm__("d0"); \
|
||||
long _a = (long) (a); \
|
||||
short _b = (short) (b); \
|
||||
\
|
||||
__asm__ volatile ( \
|
||||
"movw %3,sp@-\n\t" \
|
||||
"movl %2,sp@-\n\t" \
|
||||
"movw %1,sp@-\n\t" \
|
||||
"trap #14\n\t" \
|
||||
"lea sp@(8),sp" \
|
||||
: "=r"(retvalue) \
|
||||
: "g"(n), "r"(_a), "r"(_b) \
|
||||
: OSBIND_CLOBBER_LIST \
|
||||
); \
|
||||
retvalue; \
|
||||
})
|
||||
#endif
|
||||
#ifndef trap_14_wll
|
||||
#define trap_14_wll(n, a, b) \
|
||||
__extension__ \
|
||||
({ \
|
||||
register long retvalue __asm__("d0"); \
|
||||
long _a = (long) (a); \
|
||||
long _b = (long) (b); \
|
||||
\
|
||||
__asm__ volatile ( \
|
||||
"movl %3,sp@-\n\t" \
|
||||
"movl %2,sp@-\n\t" \
|
||||
"movw %1,sp@-\n\t" \
|
||||
"trap #14\n\t" \
|
||||
"lea sp@(10),sp" \
|
||||
: "=r"(retvalue) \
|
||||
: "g"(n), "r"(_a), "r"(_b) \
|
||||
: OSBIND_CLOBBER_LIST \
|
||||
); \
|
||||
retvalue; \
|
||||
})
|
||||
#endif
|
||||
#ifndef trap_14_wlww
|
||||
#define trap_14_wlww(n, a, b, c) \
|
||||
__extension__ \
|
||||
({ \
|
||||
register long retvalue __asm__("d0"); \
|
||||
long _a = (long) (a); \
|
||||
short _b = (short) (b); \
|
||||
short _c = (short) (c); \
|
||||
\
|
||||
__asm__ volatile ( \
|
||||
"movl %4,sp@-\n\t" \
|
||||
"movw %3,sp@-\n\t" \
|
||||
"movw %2,sp@-\n\t" \
|
||||
"movw %1,sp@-\n\t" \
|
||||
"trap #14\n\t" \
|
||||
"lea sp@(10),sp" \
|
||||
: "=r"(retvalue) \
|
||||
: "g"(n), "r"(_a), "r"(_b), "r"(_c) \
|
||||
: OSBIND_CLOBBER_LIST \
|
||||
); \
|
||||
retvalue; \
|
||||
})
|
||||
#endif
|
||||
#ifndef trap_14_wlwl
|
||||
#define trap_14_wlwl(n, a, b, c) \
|
||||
__extension__ \
|
||||
({ \
|
||||
register long retvalue __asm__("d0"); \
|
||||
long _a = (long) (a); \
|
||||
short _b = (short) (b); \
|
||||
long _c = (long) (c); \
|
||||
\
|
||||
__asm__ volatile ( \
|
||||
"movl %4,sp@-\n\t" \
|
||||
"movw %3,sp@-\n\t" \
|
||||
"movl %2,sp@-\n\t" \
|
||||
"movw %1,sp@-\n\t" \
|
||||
"trap #14\n\t" \
|
||||
"lea sp@(12),sp" \
|
||||
: "=r"(retvalue) \
|
||||
: "g"(n), "r"(_a), "r"(_b), "r"(_c) \
|
||||
: OSBIND_CLOBBER_LIST \
|
||||
); \
|
||||
retvalue; \
|
||||
})
|
||||
#endif
|
||||
#ifndef trap_14_wlll
|
||||
#define trap_14_wlll(n, a, b, c) \
|
||||
__extension__ \
|
||||
({ \
|
||||
register long retvalue __asm__("d0"); \
|
||||
long _a = (long) (a); \
|
||||
long _b = (long) (b); \
|
||||
long _c = (long) (c); \
|
||||
\
|
||||
__asm__ volatile ( \
|
||||
"movl %4,sp@-\n\t" \
|
||||
"movl %3,sp@-\n\t" \
|
||||
"movl %2,sp@-\n\t" \
|
||||
"movw %1,sp@-\n\t" \
|
||||
"trap #14\n\t" \
|
||||
"lea sp@(14),sp" \
|
||||
: "=r"(retvalue) \
|
||||
: "g"(n), "r"(_a), "r"(_b), "r"(_c) \
|
||||
: OSBIND_CLOBBER_LIST \
|
||||
); \
|
||||
retvalue; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define find_pci_device(id,index) (long)trap_14_wlw((short)(300),(unsigned long)(id),(unsigned short)(index))
|
||||
#define find_pci_classcode(classcode,index) (long)trap_14_wlw((short)(301),(unsigned long)(classcode),(unsigned short)(index))
|
||||
#define read_config_byte(handle,reg,address) (long)trap_14_wlwl((short)(302),(long)(handle),(unsigned short)(reg),(unsigned char *)(address))
|
||||
#define read_config_word(handle,reg,address) (long)trap_14_wlwl((short)(303),(long)(handle),(unsigned short)(reg),(unsigned short *)(address))
|
||||
#define read_config_longword(handle,reg,address) (long)trap_14_wlwl((short)(304),(long)(handle),(unsigned short)(reg),(unsigned long *)(address))
|
||||
#define fast_read_config_byte(handle,reg) (unsigned char)trap_14_wlw((short)(305),(long)(handle),(unsigned short)(reg))
|
||||
#define fast_read_config_word(handle,reg) (unsigned short)trap_14_wlw((short)(306),(long)(handle),(unsigned short)(reg))
|
||||
#define fast_read_config_longword(handle,reg) (unsigned long)trap_14_wlw((short)(307),(long)(handle),(unsigned short)(reg))
|
||||
#define write_config_byte(handle,reg,data) (long)trap_14_wlww((short)(308),(long)(handle),(unsigned short)(reg),(unsigned short)(data))
|
||||
#define write_config_word(handle,reg,data) (long)trap_14_wlww((short)(309),(long)(handle),(unsigned short)(reg),(unsigned short)(data))
|
||||
#define write_config_longword(handle,reg,data) (long)trap_14_wlwl((short)(310),(long)(handle),(unsigned short)(reg),(unsigned long)(data))
|
||||
#define hook_interrupt(handle,routine,parameter) (long)trap_14_wlll((short)(311),(long)(handle),(unsigned long *)(routine),(unsigned long *)(parameter))
|
||||
#define unhook_interrupt(handle) (long)trap_14_wl((short)(312),(long)(handle))
|
||||
#define special_cycle(bus_number,special_cycle) (long)trap_14_wwl((short)(313),(unsigned short)(bus_number),(unsigned long)(special_cycle))
|
||||
#define get_routing(handle) (long)trap_14_wl((short)(314),(long)(handle))
|
||||
#define set_interrupt(handle,mode) (long)trap_14_wlw((short)(315),(long)(handle),(short)(mode))
|
||||
#define get_resource(handle) (long)trap_14_wl((short)(316),(long)(handle))
|
||||
#define get_card_used(handle,callback) (long)trap_14_wll((short)(317),(long)(handle),(long *)(address))
|
||||
#define set_card_used(handle,callback) (long)trap_14_wll((short)(318),(long)(handle),(long *)(callback))
|
||||
#define read_mem_byte(handle,offset,address) (long)trap_14_wlll((short)(319),(long)(handle),(unsigned long)(offset),(unsigned char *)(address))
|
||||
#define read_mem_word(handle,offset,address) (long)trap_14_wlll((short)(320),(unsigned long)(offset),(unsigned short *)(address))
|
||||
#define read_mem_longword(handle,offset,address) (long)trap_14_wlll((short)(321),(unsigned long)(offset),(unsigned long *)(address))
|
||||
#define fast_read_mem_byte(handle,offset) (unsigned char)trap_14_wll((short)(322),(long)(handle),(unsigned long)(offset))
|
||||
#define fast_read_mem_word(handle,offset) (unsigned short)trap_14_wll((short)(323),(long)(handle),(unsigned long)(offset))
|
||||
#define fast_read_mem_longword(handle,offset) (unsigned long)trap_14_wll((short)(324),(long)(handle),(unsigned long)(offset))
|
||||
#define write_mem_byte(handle,offset,data) (long)trap_14_wllw((short)(325),(long)(handle),(unsigned long)(offset),(unsigned short)(data))
|
||||
#define write_mem_word(handle,offset,data) (long)trap_14_wllw((short)(326),(long)(handle),(unsigned long)(offset),(unsigned short)(data))
|
||||
#define write_mem_longword(handle,offset,data) (long)trap_14_wlll((short)(327),(long)(handle),(unsigned long)(offset),(unsigned long)(data))
|
||||
#define read_io_byte(handle,offset,address) (long)trap_14_wlll((short)(328),(long)(handle),(unsigned long)(offset),(unsigned char *)(address))
|
||||
#define read_io_word(handle,offset,address) (long)trap_14_wlll((short)(329),(long)(handle),(unsigned long)(offset),(unsigned short *)(address))
|
||||
#define read_io_longword(handle,offset,address) (long)trap_14_wlll((short)(330),(long)(handle),(unsigned long)(offset),(unsigned long *)(address))
|
||||
#define fast_read_io_byte(handle,offset) (unsigned char)trap_14_wll((short)(331),(long)(handle),(unsigned long)(offset))
|
||||
#define fast_read_io_word(handle,offset) (unsigned short)trap_14_wll((short)(332),(long)(handle),(unsigned long)(offset))
|
||||
#define fast_read_io_longword(handle,offset) (unsigned long)trap_14_wll((short)(333),(long)(handle),(unsigned long)(offset))
|
||||
#define write_io_byte(handle,offset,data) (long)trap_14_wllw((short)(334),(long)(handle),(unsigned long)(offset),(unsigned short)(data))
|
||||
#define write_io_word(handle,offset,data) (long)trap_14_wllw((short)(335),(long)(handle),(unsigned long)(offset),(unsigned short)(data))
|
||||
#define write_io_longword(handle,offset,data) (long)trap_14_wlll((short)(336),(long)(handle),(unsigned long)(offset),(unsigned long)(data))
|
||||
#define get_machine_id() (long)trap_14_w((short)(337))
|
||||
#define get_pagesize() (long)trap_14_w((short)(338))
|
||||
#define virt_to_bus(handle,address,pointer) (long)trap_14_wlll((short)(339),(long)(handle),(unsigned long)(address),(unsigned long *)(pointer))
|
||||
#define bus_to_virt(handle,address,pointer) (long)trap_14_wlll((short)(340),(long)(handle),(unsigned long)(address),(unsigned long *)(pointer))
|
||||
#define virt_to_phys(address,pointer) (long)trap_14_wll((short)(341),(unsigned long)(address),(unsigned long *)(pointer))
|
||||
#define phys_to_virt(address,pointer) (long)trap_14_wll((short)(342),(unsigned long)(address),(unsigned long *)(pointer))
|
||||
#define dma_setbuffer(pci_address,local_address,size) (long)trap_14_wlll((short)(350),(unsigned long)(pci_address),(unsigned long)(local_address),(unsigned long)(size))
|
||||
#define dma_buffoper(mode) (long)trap_14_ww((short)(351),(short)(mode))
|
||||
#define read_mailbox(mailbox,pointer) (long)trap_14_wwl((short)(352),(short)(mailbox),(unsigned long *)(pointer))
|
||||
#define write_mailbox(mailbox,data) (long)trap_14_wwl((short)(353),(short)(mailbox),(unsigned long)(data))
|
||||
|
||||
extern long Find_pci_device(unsigned long id, unsigned short index);
|
||||
extern long Find_pci_classcode(unsigned long class, unsigned short index);
|
||||
extern long Read_config_byte(long handle, unsigned short reg, unsigned char *address);
|
||||
extern long Read_config_word(long handle, unsigned short reg, unsigned short *address);
|
||||
extern long Read_config_longword(long handle, unsigned short reg, unsigned long *address);
|
||||
extern unsigned char Fast_read_config_byte(long handle, unsigned short reg);
|
||||
extern unsigned short Fast_read_config_word(long handle, unsigned short reg);
|
||||
extern unsigned long Fast_read_config_longword(long handle, unsigned short reg);
|
||||
extern long Write_config_byte(long handle, unsigned short reg, unsigned short val);
|
||||
extern long Write_config_word(long handle, unsigned short reg, unsigned short val);
|
||||
extern long Write_config_longword(long handle, unsigned short reg, unsigned long val);
|
||||
extern long Hook_interrupt(long handle, unsigned long *routine, unsigned long *parameter);
|
||||
extern long Unhook_interrupt(long handle);
|
||||
extern long Special_cycle(unsigned short bus, unsigned long data);
|
||||
extern long Get_routing(long handle);
|
||||
extern long Set_interrupt(long handle);
|
||||
extern long Get_resource(long handle);
|
||||
extern long Get_card_used(long handle, unsigned long *address);
|
||||
extern long Set_card_used(long handle, unsigned long *callback);
|
||||
extern long Read_mem_byte(long handle, unsigned long offset, unsigned char *address);
|
||||
extern long Read_mem_word(long handle, unsigned long offset, unsigned short *address);
|
||||
extern long Read_mem_longword(long handle, unsigned long offset, unsigned long *address);
|
||||
extern unsigned char Fast_read_mem_byte(long handle, unsigned long offset);
|
||||
extern unsigned short Fast_read_mem_word(long handle, unsigned long offset);
|
||||
extern unsigned long Fast_read_mem_longword(long handle, unsigned long offset);
|
||||
extern long Write_mem_byte(long handle, unsigned long offset, unsigned short val);
|
||||
extern long Write_mem_word(long handle, unsigned long offset, unsigned short val);
|
||||
extern long Write_mem_longword(long handle, unsigned long offset, unsigned long val);
|
||||
extern long Read_io_byte(long handle, unsigned long offset, unsigned char *address);
|
||||
extern long Read_io_word(long handle, unsigned long offset, unsigned short *address);
|
||||
extern long Read_io_longword(long handle, unsigned long offset, unsigned long *address);
|
||||
extern unsigned char Fast_read_io_byte(long handle, unsigned long offset);
|
||||
extern unsigned short Fast_read_io_word(long handle, unsigned long offset);
|
||||
extern unsigned long Fast_read_io_longword(long handle, unsigned long offset);
|
||||
extern long Write_io_byte(long handle, unsigned long offset, unsigned short val);
|
||||
extern long Write_io_word(long handle, unsigned long offset, unsigned short val);
|
||||
extern long Write_io_longword(long handle, unsigned long offset, unsigned long val);
|
||||
extern long Get_machine_id(void);
|
||||
extern long Get_pagesize(void);
|
||||
extern long Virt_to_bus(long handle, unsigned long address, PCI_CONV_ADR *pointer);
|
||||
extern long Bus_to_virt(long handle, unsigned long address, PCI_CONV_ADR *pointer);
|
||||
extern long Virt_to_phys(unsigned long address, PCI_CONV_ADR *pointer);
|
||||
extern long Phys_to_virt(unsigned long address, PCI_CONV_ADR *pointer);
|
||||
|
||||
#endif
|
||||
209
include/scsi.h
Normal file
209
include/scsi.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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
|
||||
*
|
||||
*/
|
||||
#ifndef _SCSI_H
|
||||
#define _SCSI_H
|
||||
|
||||
typedef struct SCSI_cmd_block{
|
||||
unsigned char cmd[16]; /* command */
|
||||
unsigned char sense_buf[64]; /* for request sense */
|
||||
unsigned char status; /* SCSI Status */
|
||||
unsigned char target; /* Target ID */
|
||||
unsigned char lun; /* Target LUN */
|
||||
unsigned char cmdlen; /* command len */
|
||||
unsigned long datalen; /* Total data length */
|
||||
unsigned char * pdata; /* pointer to data */
|
||||
unsigned char msgout[12]; /* Messge out buffer (NOT USED) */
|
||||
unsigned char msgin[12]; /* Message in buffer */
|
||||
unsigned char sensecmdlen; /* Sense command len */
|
||||
unsigned long sensedatalen; /* Sense data len */
|
||||
unsigned char sensecmd[6]; /* Sense command */
|
||||
unsigned long contr_stat; /* Controller Status */
|
||||
unsigned long trans_bytes; /* tranfered bytes */
|
||||
|
||||
unsigned int priv;
|
||||
}ccb;
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
**
|
||||
** SCSI constants.
|
||||
**
|
||||
**-----------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
** Messages
|
||||
*/
|
||||
|
||||
#define M_COMPLETE (0x00)
|
||||
#define M_EXTENDED (0x01)
|
||||
#define M_SAVE_DP (0x02)
|
||||
#define M_RESTORE_DP (0x03)
|
||||
#define M_DISCONNECT (0x04)
|
||||
#define M_ID_ERROR (0x05)
|
||||
#define M_ABORT (0x06)
|
||||
#define M_REJECT (0x07)
|
||||
#define M_NOOP (0x08)
|
||||
#define M_PARITY (0x09)
|
||||
#define M_LCOMPLETE (0x0a)
|
||||
#define M_FCOMPLETE (0x0b)
|
||||
#define M_RESET (0x0c)
|
||||
#define M_ABORT_TAG (0x0d)
|
||||
#define M_CLEAR_QUEUE (0x0e)
|
||||
#define M_INIT_REC (0x0f)
|
||||
#define M_REL_REC (0x10)
|
||||
#define M_TERMINATE (0x11)
|
||||
#define M_SIMPLE_TAG (0x20)
|
||||
#define M_HEAD_TAG (0x21)
|
||||
#define M_ORDERED_TAG (0x22)
|
||||
#define M_IGN_RESIDUE (0x23)
|
||||
#define M_IDENTIFY (0x80)
|
||||
|
||||
#define M_X_MODIFY_DP (0x00)
|
||||
#define M_X_SYNC_REQ (0x01)
|
||||
#define M_X_WIDE_REQ (0x03)
|
||||
#define M_X_PPR_REQ (0x04)
|
||||
|
||||
|
||||
/*
|
||||
** Status
|
||||
*/
|
||||
|
||||
#define S_GOOD (0x00)
|
||||
#define S_CHECK_COND (0x02)
|
||||
#define S_COND_MET (0x04)
|
||||
#define S_BUSY (0x08)
|
||||
#define S_INT (0x10)
|
||||
#define S_INT_COND_MET (0x14)
|
||||
#define S_CONFLICT (0x18)
|
||||
#define S_TERMINATED (0x20)
|
||||
#define S_QUEUE_FULL (0x28)
|
||||
#define S_ILLEGAL (0xff)
|
||||
#define S_SENSE (0x80)
|
||||
|
||||
/*
|
||||
* Sense_keys
|
||||
*/
|
||||
|
||||
#define SENSE_NO_SENSE 0x0
|
||||
#define SENSE_RECOVERED_ERROR 0x1
|
||||
#define SENSE_NOT_READY 0x2
|
||||
#define SENSE_MEDIUM_ERROR 0x3
|
||||
#define SENSE_HARDWARE_ERROR 0x4
|
||||
#define SENSE_ILLEGAL_REQUEST 0x5
|
||||
#define SENSE_UNIT_ATTENTION 0x6
|
||||
#define SENSE_DATA_PROTECT 0x7
|
||||
#define SENSE_BLANK_CHECK 0x8
|
||||
#define SENSE_VENDOR_SPECIFIC 0x9
|
||||
#define SENSE_COPY_ABORTED 0xA
|
||||
#define SENSE_ABORTED_COMMAND 0xB
|
||||
#define SENSE_VOLUME_OVERFLOW 0xD
|
||||
#define SENSE_MISCOMPARE 0xE
|
||||
|
||||
|
||||
#define SCSI_CHANGE_DEF 0x40 /* Change Definition (Optional) */
|
||||
#define SCSI_COMPARE 0x39 /* Compare (O) */
|
||||
#define SCSI_COPY 0x18 /* Copy (O) */
|
||||
#define SCSI_COP_VERIFY 0x3A /* Copy and Verify (O) */
|
||||
#define SCSI_INQUIRY 0x12 /* Inquiry (MANDATORY) */
|
||||
#define SCSI_LOG_SELECT 0x4C /* Log Select (O) */
|
||||
#define SCSI_LOG_SENSE 0x4D /* Log Sense (O) */
|
||||
#define SCSI_MODE_SEL6 0x15 /* Mode Select 6-byte (Device Specific) */
|
||||
#define SCSI_MODE_SEL10 0x55 /* Mode Select 10-byte (Device Specific) */
|
||||
#define SCSI_MODE_SEN6 0x1A /* Mode Sense 6-byte (Device Specific) */
|
||||
#define SCSI_MODE_SEN10 0x5A /* Mode Sense 10-byte (Device Specific) */
|
||||
#define SCSI_READ_BUFF 0x3C /* Read Buffer (O) */
|
||||
#define SCSI_REQ_SENSE 0x03 /* Request Sense (MANDATORY) */
|
||||
#define SCSI_SEND_DIAG 0x1D /* Send Diagnostic (O) */
|
||||
#define SCSI_TST_U_RDY 0x00 /* Test Unit Ready (MANDATORY) */
|
||||
#define SCSI_WRITE_BUFF 0x3B /* Write Buffer (O) */
|
||||
/***************************************************************************
|
||||
* %%% Commands Unique to Direct Access Devices %%%
|
||||
***************************************************************************/
|
||||
#define SCSI_COMPARE 0x39 /* Compare (O) */
|
||||
#define SCSI_FORMAT 0x04 /* Format Unit (MANDATORY) */
|
||||
#define SCSI_LCK_UN_CAC 0x36 /* Lock Unlock Cache (O) */
|
||||
#define SCSI_PREFETCH 0x34 /* Prefetch (O) */
|
||||
#define SCSI_MED_REMOVL 0x1E /* Prevent/Allow medium Removal (O) */
|
||||
#define SCSI_READ6 0x08 /* Read 6-byte (MANDATORY) */
|
||||
#define SCSI_READ10 0x28 /* Read 10-byte (MANDATORY) */
|
||||
#define SCSI_RD_CAPAC 0x25 /* Read Capacity (MANDATORY) */
|
||||
#define SCSI_RD_DEFECT 0x37 /* Read Defect Data (O) */
|
||||
#define SCSI_READ_LONG 0x3E /* Read Long (O) */
|
||||
#define SCSI_REASS_BLK 0x07 /* Reassign Blocks (O) */
|
||||
#define SCSI_RCV_DIAG 0x1C /* Receive Diagnostic Results (O) */
|
||||
#define SCSI_RELEASE 0x17 /* Release Unit (MANDATORY) */
|
||||
#define SCSI_REZERO 0x01 /* Rezero Unit (O) */
|
||||
#define SCSI_SRCH_DAT_E 0x31 /* Search Data Equal (O) */
|
||||
#define SCSI_SRCH_DAT_H 0x30 /* Search Data High (O) */
|
||||
#define SCSI_SRCH_DAT_L 0x32 /* Search Data Low (O) */
|
||||
#define SCSI_SEEK6 0x0B /* Seek 6-Byte (O) */
|
||||
#define SCSI_SEEK10 0x2B /* Seek 10-Byte (O) */
|
||||
#define SCSI_SEND_DIAG 0x1D /* Send Diagnostics (MANDATORY) */
|
||||
#define SCSI_SET_LIMIT 0x33 /* Set Limits (O) */
|
||||
#define SCSI_START_STP 0x1B /* Start/Stop Unit (O) */
|
||||
#define SCSI_SYNC_CACHE 0x35 /* Synchronize Cache (O) */
|
||||
#define SCSI_VERIFY 0x2F /* Verify (O) */
|
||||
#define SCSI_WRITE6 0x0A /* Write 6-Byte (MANDATORY) */
|
||||
#define SCSI_WRITE10 0x2A /* Write 10-Byte (MANDATORY) */
|
||||
#define SCSI_WRT_VERIFY 0x2E /* Write and Verify (O) */
|
||||
#define SCSI_WRITE_LONG 0x3F /* Write Long (O) */
|
||||
#define SCSI_WRITE_SAME 0x41 /* Write Same (O) */
|
||||
|
||||
#if 0
|
||||
/****************************************************************************
|
||||
* decleration of functions which have to reside in the LowLevel Part Driver
|
||||
*/
|
||||
|
||||
void scsi_print_error(ccb *pccb);
|
||||
int scsi_exec(ccb *pccb);
|
||||
void scsi_bus_reset(void);
|
||||
void scsi_low_level_init(int busdevfunc);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* functions residing inside cmd_scsi.c
|
||||
*/
|
||||
void scsi_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
#define SCSI_IDENTIFY 0xC0 /* not used */
|
||||
|
||||
/* Hardware errors */
|
||||
#define SCSI_SEL_TIME_OUT 0x00000101 /* Selection time out */
|
||||
#define SCSI_HNS_TIME_OUT 0x00000102 /* Handshake */
|
||||
#define SCSI_MA_TIME_OUT 0x00000103 /* Phase error */
|
||||
#define SCSI_UNEXP_DIS 0x00000104 /* unexpected disconnect */
|
||||
|
||||
#define SCSI_INT_STATE 0x00010000 /* unknown Interrupt number is stored in 16 LSB */
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif /* _SCSI_H */
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
#define SYSTEM_CLOCK 133
|
||||
#define cf_stack
|
||||
|
||||
#define DIP_SWITCH (*(volatile uint8_t *)(&_MBAR[0xA2C]))
|
||||
|
||||
524
include/usb.h
Normal file
524
include/usb.h
Normal file
@@ -0,0 +1,524 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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
|
||||
*
|
||||
* Note: Part of this code has been derived from linux
|
||||
*
|
||||
*/
|
||||
#ifndef _USB_H_
|
||||
#define _USB_H_
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <bas_printf.h>
|
||||
#include "pcixbios.h"
|
||||
#include "mod_devicetable.h"
|
||||
#include "pci_ids.h"
|
||||
#include "part.h"
|
||||
#include "wait.h"
|
||||
|
||||
#ifdef PCI_XBIOS
|
||||
|
||||
#define in8(addr) fast_read_mem_byte(usb_handle,addr)
|
||||
#define in16r(addr) fast_read_mem_word(usb_handle,addr)
|
||||
#define in32r(addr) fast_read_mem_longword(usb_handle,addr)
|
||||
#define out8(addr,val) write_mem_byte(usb_handle,addr,val)
|
||||
#define out16r(addr,val) write_mem_word(usb_handle,addr,val)
|
||||
#define out32r(addr,val) write_mem_longword(usb_handle,addr,val)
|
||||
|
||||
#else /* !PCI_XBIOS */
|
||||
|
||||
extern long *tab_funcs_pci;
|
||||
|
||||
#define in8(addr) Fast_read_mem_byte(usb_handle,addr)
|
||||
#define in16r(addr) Fast_read_mem_word(usb_handle,addr)
|
||||
#define in32r(addr) Fast_read_mem_longword(usb_handle,addr)
|
||||
#define out8(addr,val) Write_mem_byte(usb_handle,addr,val)
|
||||
#define out16r(addr,val) Write_mem_word(usb_handle,addr,val)
|
||||
#define out32r(addr,val) Write_mem_longword(usb_handle,addr,val)
|
||||
|
||||
#endif /* PCI_XBIOS */
|
||||
|
||||
#define __u8 unsigned char
|
||||
#define __u16 unsigned short
|
||||
#define __u32 unsigned long
|
||||
#define u8 unsigned char
|
||||
#define u16 unsigned short
|
||||
#define u32 unsigned long
|
||||
#define uint8_t unsigned char
|
||||
#define uint32_t unsigned long
|
||||
#define uint16_t unsigned short
|
||||
|
||||
extern void kprint(const char *fmt, ...);
|
||||
extern int sprintD(char *s, const char *fmt, ...);
|
||||
#if defined(COLDFIRE) && defined(NETWORK) && defined(LWIP)
|
||||
extern void board_printf(const char *fmt, ...);
|
||||
#else
|
||||
#define board_printf kprint
|
||||
#endif
|
||||
|
||||
#include "usb_defs.h"
|
||||
|
||||
/* Everything is aribtrary */
|
||||
#define USB_ALTSETTINGALLOC 4
|
||||
#define USB_MAXALTSETTING 128 /* Hard limit */
|
||||
|
||||
#define USB_MAX_BUS 3
|
||||
#define USB_MAX_DEVICE 16
|
||||
#define USB_MAXCONFIG 8
|
||||
#define USB_MAXINTERFACES 8
|
||||
#define USB_MAXENDPOINTS 16
|
||||
#define USB_MAXCHILDREN 8 /* This is arbitrary */
|
||||
#define USB_MAX_HUB 16
|
||||
|
||||
#define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
|
||||
|
||||
/* String descriptor */
|
||||
struct usb_string_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short wData[1];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* device request (setup) */
|
||||
struct devrequest {
|
||||
unsigned char requesttype;
|
||||
unsigned char request;
|
||||
unsigned short value;
|
||||
unsigned short index;
|
||||
unsigned short length;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* All standard descriptors have these 2 fields in common */
|
||||
struct usb_descriptor_header {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Device descriptor */
|
||||
struct usb_device_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short bcdUSB;
|
||||
unsigned char bDeviceClass;
|
||||
unsigned char bDeviceSubClass;
|
||||
unsigned char bDeviceProtocol;
|
||||
unsigned char bMaxPacketSize0;
|
||||
unsigned short idVendor;
|
||||
unsigned short idProduct;
|
||||
unsigned short bcdDevice;
|
||||
unsigned char iManufacturer;
|
||||
unsigned char iProduct;
|
||||
unsigned char iSerialNumber;
|
||||
unsigned char bNumConfigurations;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Endpoint descriptor */
|
||||
struct usb_endpoint_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bEndpointAddress;
|
||||
unsigned char bmAttributes;
|
||||
unsigned short wMaxPacketSize;
|
||||
unsigned char bInterval;
|
||||
unsigned char bRefresh;
|
||||
unsigned char bSynchAddress;
|
||||
} __attribute__ ((packed)) __attribute__ ((aligned(2)));
|
||||
|
||||
/* Interface descriptor */
|
||||
struct usb_interface_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bInterfaceNumber;
|
||||
unsigned char bAlternateSetting;
|
||||
unsigned char bNumEndpoints;
|
||||
unsigned char bInterfaceClass;
|
||||
unsigned char bInterfaceSubClass;
|
||||
unsigned char bInterfaceProtocol;
|
||||
unsigned char iInterface;
|
||||
|
||||
unsigned char no_of_ep;
|
||||
unsigned char num_altsetting;
|
||||
unsigned char act_altsetting;
|
||||
|
||||
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/* Configuration descriptor information.. */
|
||||
struct usb_config_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short wTotalLength;
|
||||
unsigned char bNumInterfaces;
|
||||
unsigned char bConfigurationValue;
|
||||
unsigned char iConfiguration;
|
||||
unsigned char bmAttributes;
|
||||
unsigned char MaxPower;
|
||||
|
||||
unsigned char no_of_if; /* number of interfaces */
|
||||
struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
enum {
|
||||
/* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
|
||||
PACKET_SIZE_8 = 0,
|
||||
PACKET_SIZE_16 = 1,
|
||||
PACKET_SIZE_32 = 2,
|
||||
PACKET_SIZE_64 = 3,
|
||||
};
|
||||
|
||||
struct usb_device {
|
||||
int devnum; /* Device number on USB bus */
|
||||
int speed; /* full/low/high */
|
||||
char mf[32]; /* manufacturer */
|
||||
char prod[32]; /* product */
|
||||
char serial[32]; /* serial number */
|
||||
|
||||
/* Maximum packet size; one of: PACKET_SIZE_* */
|
||||
int maxpacketsize;
|
||||
/* one bit for each endpoint ([0] = IN, [1] = OUT) */
|
||||
unsigned int toggle[2];
|
||||
/* endpoint halts; one bit per endpoint # & direction;
|
||||
* [0] = IN, [1] = OUT
|
||||
*/
|
||||
unsigned int halted[2];
|
||||
int epmaxpacketin[16]; /* INput endpoint specific maximums */
|
||||
int epmaxpacketout[16]; /* OUTput endpoint specific maximums */
|
||||
|
||||
int configno; /* selected config number */
|
||||
struct usb_device_descriptor descriptor; /* Device Descriptor */
|
||||
struct usb_config_descriptor config; /* config descriptor */
|
||||
|
||||
int have_langid; /* whether string_langid is valid yet */
|
||||
int string_langid; /* language ID for strings */
|
||||
int (*irq_handle)(struct usb_device *dev);
|
||||
unsigned long irq_status;
|
||||
int irq_act_len; /* transfered bytes */
|
||||
void *privptr;
|
||||
/*
|
||||
* Child devices - if this is a hub device
|
||||
* Each instance needs its own set of data structures.
|
||||
*/
|
||||
unsigned long status;
|
||||
int act_len; /* transfered bytes */
|
||||
int maxchild; /* Number of ports if hub */
|
||||
int portnr;
|
||||
struct usb_device *parent;
|
||||
struct usb_device *children[USB_MAXCHILDREN];
|
||||
void *priv_hcd;
|
||||
int (*deregister)(struct usb_device *dev);
|
||||
|
||||
struct usb_hub_device *hub;
|
||||
int usbnum;
|
||||
};
|
||||
|
||||
/* Structure returned by Iorec() */
|
||||
typedef struct {
|
||||
char *ibuf;
|
||||
short ibufsiz;
|
||||
volatile short ibufhd;
|
||||
volatile short ibuftl;
|
||||
short ibuflow;
|
||||
short ibufhi;
|
||||
} _IOREC;
|
||||
/**********************************************************************
|
||||
* this is how the lowlevel part communicate with the outer world
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined(CONFIG_USB_EHCI)
|
||||
|
||||
#ifdef CONFIG_USB_UHCI
|
||||
int uhci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv);
|
||||
int uhci_usb_lowlevel_stop(void *priv);
|
||||
int uhci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len);
|
||||
int uhci_submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
int uhci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void uhci_usb_event_poll(int interrupt);
|
||||
#else
|
||||
void uhci_usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
#endif /* CONFIG_USB_UHCI */
|
||||
|
||||
#ifdef CONFIG_USB_OHCI
|
||||
int ohci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv);
|
||||
int ohci_usb_lowlevel_stop(void *priv);
|
||||
int ohci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len);
|
||||
int ohci_submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
int ohci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void ohci_usb_event_poll(int interrupt);
|
||||
#else
|
||||
void ohci_usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
#endif /* CONFIG_USB_OHCI */
|
||||
|
||||
#ifdef CONFIG_USB_EHCI
|
||||
int ehci_usb_lowlevel_init(long handle, const struct pci_device_id *ent, void **priv);
|
||||
int ehci_usb_lowlevel_stop(void *priv);
|
||||
int ehci_submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len);
|
||||
int ehci_submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup);
|
||||
int ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void ehci_usb_event_poll(int interrupt);
|
||||
#else
|
||||
void ehci_usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
#endif /* CONFIG_USB_EHCI */
|
||||
|
||||
#else
|
||||
#error USB Lowlevel not defined
|
||||
#endif /* defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined(CONFIG_USB_EHCI) */
|
||||
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
void usb_event_poll(int interrupt);
|
||||
#else
|
||||
void usb_enable_interrupt(int enable);
|
||||
#endif /* CONFIG_USB_INTERRUPT_POLLING */
|
||||
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
#define USB_MAX_STOR_DEV 5
|
||||
block_dev_desc_t *usb_stor_get_dev(int index);
|
||||
int usb_stor_scan(void);
|
||||
int usb_stor_info(void);
|
||||
int usb_stor_register(struct usb_device *dev);
|
||||
int usb_stor_deregister(struct usb_device *dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_KEYBOARD
|
||||
int drv_usb_kbd_init(void);
|
||||
int usb_kbd_register(struct usb_device *dev);
|
||||
int usb_kbd_deregister(struct usb_device *dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_MOUSE
|
||||
int drv_usb_mouse_init(void);
|
||||
int usb_mouse_register(struct usb_device *dev);
|
||||
int usb_mouse_deregister(struct usb_device *dev);
|
||||
#endif
|
||||
|
||||
extern char usb_error_str[256];
|
||||
|
||||
/* memory */
|
||||
void *usb_malloc(long amount);
|
||||
int usb_free(void *addr);
|
||||
int usb_mem_init(void);
|
||||
void usb_mem_stop(void);
|
||||
|
||||
/* routines */
|
||||
int usb_init(long handle, const struct pci_device_id *ent); /* initialize the USB Controller */
|
||||
int usb_stop(void); /* stop the USB Controller */
|
||||
|
||||
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol);
|
||||
int usb_set_idle(struct usb_device *dev, int ifnum, int duration, int report_id);
|
||||
struct usb_device *usb_get_dev_index(int index, int bus);
|
||||
int usb_control_msg(struct usb_device *dev, unsigned int pipe, unsigned char request, unsigned char requesttype, unsigned short value,
|
||||
unsigned short index, void *data, unsigned short size, int timeout);
|
||||
int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout);
|
||||
int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval);
|
||||
void usb_disable_asynch(int disable);
|
||||
int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
|
||||
|
||||
int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, int cfgno);
|
||||
int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size);
|
||||
int usb_get_class_descriptor(struct usb_device *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size);
|
||||
int usb_clear_halt(struct usb_device *dev, int pipe);
|
||||
int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
|
||||
int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
||||
|
||||
/* big endian -> little endian conversion */
|
||||
/* some CPUs are already little endian e.g. the ARM920T */
|
||||
#define __swap_16(x) \
|
||||
({ unsigned short x_ = (unsigned short)x; \
|
||||
(unsigned short)( \
|
||||
((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8)); \
|
||||
})
|
||||
#define __swap_32(x) \
|
||||
({ unsigned long x_ = (unsigned long)x; \
|
||||
(unsigned long)( \
|
||||
((x_ & 0x000000FFUL) << 24) | \
|
||||
((x_ & 0x0000FF00UL) << 8) | \
|
||||
((x_ & 0x00FF0000UL) >> 8) | \
|
||||
((x_ & 0xFF000000UL) >> 24)); \
|
||||
})
|
||||
|
||||
#define swap_16(x) __swap_16(x)
|
||||
#define swap_32(x) __swap_32(x)
|
||||
|
||||
extern unsigned short swap_short(unsigned short val);
|
||||
extern unsigned long swap_long(unsigned long val);
|
||||
|
||||
#define le16_to_cpu cpu_to_le16
|
||||
#define le32_to_cpu cpu_to_le32
|
||||
#define cpu_to_be32(a) a
|
||||
|
||||
static inline unsigned short cpu_to_le16(unsigned short val)
|
||||
{
|
||||
return(swap_short(val));
|
||||
}
|
||||
static inline unsigned long cpu_to_le32(unsigned long val)
|
||||
{
|
||||
return(swap_long(val));
|
||||
}
|
||||
|
||||
static inline void le16_to_cpus(unsigned short *val)
|
||||
{
|
||||
*val = le16_to_cpu(*val);
|
||||
}
|
||||
static inline void le32_to_cpus(unsigned long *val)
|
||||
{
|
||||
*val = le32_to_cpu(*val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calling this entity a "pipe" is glorifying it. A USB pipe
|
||||
* is something embarrassingly simple: it basically consists
|
||||
* of the following information:
|
||||
* - device number (7 bits)
|
||||
* - endpoint number (4 bits)
|
||||
* - current Data0/1 state (1 bit)
|
||||
* - direction (1 bit)
|
||||
* - speed (2 bits)
|
||||
* - max packet size (2 bits: 8, 16, 32 or 64)
|
||||
* - pipe type (2 bits: control, interrupt, bulk, isochronous)
|
||||
*
|
||||
* That's 18 bits. Really. Nothing more. And the USB people have
|
||||
* documented these eighteen bits as some kind of glorious
|
||||
* virtual data structure.
|
||||
*
|
||||
* Let's not fall in that trap. We'll just encode it as a simple
|
||||
* unsigned int. The encoding is:
|
||||
*
|
||||
* - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64)
|
||||
* - direction: bit 7 (0 = Host-to-Device [Out],
|
||||
* (1 = Device-to-Host [In])
|
||||
* - device: bits 8-14
|
||||
* - endpoint: bits 15-18
|
||||
* - Data0/1: bit 19
|
||||
* - speed: bit 26 (0 = Full, 1 = Low Speed, 2 = High)
|
||||
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
|
||||
* 10 = control, 11 = bulk)
|
||||
*
|
||||
* Why? Because it's arbitrary, and whatever encoding we select is really
|
||||
* up to us. This one happens to share a lot of bit positions with the UHCI
|
||||
* specification, so that much of the uhci driver can just mask the bits
|
||||
* appropriately.
|
||||
*/
|
||||
/* Create various pipes... */
|
||||
#define create_pipe(dev,endpoint) \
|
||||
(((dev)->devnum << 8) | (endpoint << 15) | \
|
||||
((dev)->speed << 26) | (dev)->maxpacketsize)
|
||||
#define default_pipe(dev) ((dev)->speed << 26)
|
||||
|
||||
#define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
|
||||
create_pipe(dev, endpoint))
|
||||
#define usb_rcvctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
|
||||
create_pipe(dev, endpoint) | \
|
||||
USB_DIR_IN)
|
||||
#define usb_sndisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \
|
||||
create_pipe(dev, endpoint))
|
||||
#define usb_rcvisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \
|
||||
create_pipe(dev, endpoint) | \
|
||||
USB_DIR_IN)
|
||||
#define usb_sndbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \
|
||||
create_pipe(dev, endpoint))
|
||||
#define usb_rcvbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \
|
||||
create_pipe(dev, endpoint) | \
|
||||
USB_DIR_IN)
|
||||
#define usb_sndintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \
|
||||
create_pipe(dev, endpoint))
|
||||
#define usb_rcvintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \
|
||||
create_pipe(dev, endpoint) | \
|
||||
USB_DIR_IN)
|
||||
#define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | \
|
||||
default_pipe(dev))
|
||||
#define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | \
|
||||
default_pipe(dev) | \
|
||||
USB_DIR_IN)
|
||||
|
||||
/* The D0/D1 toggle bits */
|
||||
#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1)
|
||||
#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep))
|
||||
#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = \
|
||||
((dev)->toggle[out] & \
|
||||
~(1 << ep)) | ((bit) << ep))
|
||||
|
||||
/* Endpoint halt control/status */
|
||||
#define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1)
|
||||
#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
|
||||
#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
|
||||
#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
|
||||
|
||||
#define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : \
|
||||
USB_PID_OUT)
|
||||
|
||||
#define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1)
|
||||
#define usb_pipein(pipe) (((pipe) >> 7) & 1)
|
||||
#define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f)
|
||||
#define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff)
|
||||
#define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
|
||||
#define usb_pipedata(pipe) (((pipe) >> 19) & 1)
|
||||
#define usb_pipespeed(pipe) (((pipe) >> 26) & 3)
|
||||
#define usb_pipeslow(pipe) (usb_pipespeed(pipe) == USB_SPEED_LOW)
|
||||
#define usb_pipetype(pipe) (((pipe) >> 30) & 3)
|
||||
#define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
|
||||
#define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT)
|
||||
#define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL)
|
||||
#define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK)
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Hub Stuff
|
||||
*/
|
||||
struct usb_port_status {
|
||||
unsigned short wPortStatus;
|
||||
unsigned short wPortChange;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct usb_hub_status {
|
||||
unsigned short wHubStatus;
|
||||
unsigned short wHubChange;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/* Hub descriptor */
|
||||
struct usb_hub_descriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bNbrPorts;
|
||||
unsigned short wHubCharacteristics;
|
||||
unsigned char bPwrOn2PwrGood;
|
||||
unsigned char bHubContrCurrent;
|
||||
unsigned char DeviceRemovable[(USB_MAXCHILDREN+1+7)/8];
|
||||
unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
|
||||
/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
|
||||
bitmaps that hold max 255 entries. (bit0 is ignored) */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct usb_hub_device {
|
||||
struct usb_device *pusb_dev;
|
||||
struct usb_hub_descriptor desc;
|
||||
};
|
||||
|
||||
#endif /*_USB_H_ */
|
||||
251
include/usb_defs.h
Normal file
251
include/usb_defs.h
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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
|
||||
*
|
||||
* Note: Part of this code has been derived from linux
|
||||
*
|
||||
*/
|
||||
#ifndef _USB_DEFS_H_
|
||||
#define _USB_DEFS_H_
|
||||
|
||||
/* USB constants */
|
||||
|
||||
/* Device and/or Interface Class codes */
|
||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_DATA 10
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
/* some HID sub classes */
|
||||
#define USB_SUB_HID_NONE 0
|
||||
#define USB_SUB_HID_BOOT 1
|
||||
|
||||
/* some UID Protocols */
|
||||
#define USB_PROT_HID_NONE 0
|
||||
#define USB_PROT_HID_KEYBOARD 1
|
||||
#define USB_PROT_HID_MOUSE 2
|
||||
|
||||
|
||||
/* Sub STORAGE Classes */
|
||||
#define US_SC_RBC 1 /* Typically, flash devices */
|
||||
#define US_SC_8020 2 /* CD-ROM */
|
||||
#define US_SC_QIC 3 /* QIC-157 Tapes */
|
||||
#define US_SC_UFI 4 /* Floppy */
|
||||
#define US_SC_8070 5 /* Removable media */
|
||||
#define US_SC_SCSI 6 /* Transparent */
|
||||
#define US_SC_MIN US_SC_RBC
|
||||
#define US_SC_MAX US_SC_SCSI
|
||||
|
||||
/* STORAGE Protocols */
|
||||
#define US_PR_CB 1 /* Control/Bulk w/o interrupt */
|
||||
#define US_PR_CBI 0 /* Control/Bulk/Interrupt */
|
||||
#define US_PR_BULK 0x50 /* bulk only */
|
||||
|
||||
/* USB types */
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
/* USB recipients */
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
|
||||
/* USB directions */
|
||||
#define USB_DIR_OUT 0
|
||||
#define USB_DIR_IN 0x80
|
||||
|
||||
/* USB device speeds */
|
||||
#define USB_SPEED_FULL 0x0 /* 12Mbps */
|
||||
#define USB_SPEED_LOW 0x1 /* 1.5Mbps */
|
||||
#define USB_SPEED_HIGH 0x2 /* 480Mbps */
|
||||
#define USB_SPEED_RESERVED 0x3
|
||||
|
||||
/* Descriptor types */
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
|
||||
#define USB_DT_HID (USB_TYPE_CLASS | 0x01)
|
||||
#define USB_DT_REPORT (USB_TYPE_CLASS | 0x02)
|
||||
#define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
|
||||
#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
|
||||
|
||||
/* Descriptor sizes per descriptor type */
|
||||
#define USB_DT_DEVICE_SIZE 18
|
||||
#define USB_DT_CONFIG_SIZE 9
|
||||
#define USB_DT_INTERFACE_SIZE 9
|
||||
#define USB_DT_ENDPOINT_SIZE 7
|
||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||
#define USB_DT_HID_SIZE 9
|
||||
|
||||
/* Endpoints */
|
||||
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||
|
||||
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||
#define USB_ENDPOINT_XFER_ISOC 1
|
||||
#define USB_ENDPOINT_XFER_BULK 2
|
||||
#define USB_ENDPOINT_XFER_INT 3
|
||||
|
||||
/* USB Packet IDs (PIDs) */
|
||||
#define USB_PID_UNDEF_0 0xf0
|
||||
#define USB_PID_OUT 0xe1
|
||||
#define USB_PID_ACK 0xd2
|
||||
#define USB_PID_DATA0 0xc3
|
||||
#define USB_PID_UNDEF_4 0xb4
|
||||
#define USB_PID_SOF 0xa5
|
||||
#define USB_PID_UNDEF_6 0x96
|
||||
#define USB_PID_UNDEF_7 0x87
|
||||
#define USB_PID_UNDEF_8 0x78
|
||||
#define USB_PID_IN 0x69
|
||||
#define USB_PID_NAK 0x5a
|
||||
#define USB_PID_DATA1 0x4b
|
||||
#define USB_PID_PREAMBLE 0x3c
|
||||
#define USB_PID_SETUP 0x2d
|
||||
#define USB_PID_STALL 0x1e
|
||||
#define USB_PID_UNDEF_F 0x0f
|
||||
|
||||
/* Standard requests */
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
|
||||
/* HID requests */
|
||||
#define USB_REQ_GET_REPORT 0x01
|
||||
#define USB_REQ_GET_IDLE 0x02
|
||||
#define USB_REQ_GET_PROTOCOL 0x03
|
||||
#define USB_REQ_SET_REPORT 0x09
|
||||
#define USB_REQ_SET_IDLE 0x0A
|
||||
#define USB_REQ_SET_PROTOCOL 0x0B
|
||||
|
||||
|
||||
/* "pipe" definitions */
|
||||
|
||||
#define PIPE_ISOCHRONOUS 0
|
||||
#define PIPE_INTERRUPT 1
|
||||
#define PIPE_CONTROL 2
|
||||
#define PIPE_BULK 3
|
||||
#define PIPE_DEVEP_MASK 0x0007ff00
|
||||
|
||||
#define USB_ISOCHRONOUS 0
|
||||
#define USB_INTERRUPT 1
|
||||
#define USB_CONTROL 2
|
||||
#define USB_BULK 3
|
||||
|
||||
/* USB-status codes: */
|
||||
#define USB_ST_ACTIVE 0x1 /* TD is active */
|
||||
#define USB_ST_STALLED 0x2 /* TD is stalled */
|
||||
#define USB_ST_BUF_ERR 0x4 /* buffer error */
|
||||
#define USB_ST_BABBLE_DET 0x8 /* Babble detected */
|
||||
#define USB_ST_NAK_REC 0x10 /* NAK Received*/
|
||||
#define USB_ST_CRC_ERR 0x20 /* CRC/timeout Error */
|
||||
#define USB_ST_BIT_ERR 0x40 /* Bitstuff error */
|
||||
#define USB_ST_NOT_PROC 0x80000000L /* Not yet processed */
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Hub defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hub request types
|
||||
*/
|
||||
|
||||
#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
|
||||
#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
|
||||
|
||||
/*
|
||||
* Hub Class feature numbers
|
||||
*/
|
||||
#define C_HUB_LOCAL_POWER 0
|
||||
#define C_HUB_OVER_CURRENT 1
|
||||
|
||||
/*
|
||||
* Port feature numbers
|
||||
*/
|
||||
#define USB_PORT_FEAT_CONNECTION 0
|
||||
#define USB_PORT_FEAT_ENABLE 1
|
||||
#define USB_PORT_FEAT_SUSPEND 2
|
||||
#define USB_PORT_FEAT_OVER_CURRENT 3
|
||||
#define USB_PORT_FEAT_RESET 4
|
||||
#define USB_PORT_FEAT_POWER 8
|
||||
#define USB_PORT_FEAT_LOWSPEED 9
|
||||
#define USB_PORT_FEAT_HIGHSPEED 10
|
||||
#define USB_PORT_FEAT_C_CONNECTION 16
|
||||
#define USB_PORT_FEAT_C_ENABLE 17
|
||||
#define USB_PORT_FEAT_C_SUSPEND 18
|
||||
#define USB_PORT_FEAT_C_OVER_CURRENT 19
|
||||
#define USB_PORT_FEAT_C_RESET 20
|
||||
|
||||
/* wPortStatus bits */
|
||||
#define USB_PORT_STAT_CONNECTION 0x0001
|
||||
#define USB_PORT_STAT_ENABLE 0x0002
|
||||
#define USB_PORT_STAT_SUSPEND 0x0004
|
||||
#define USB_PORT_STAT_OVERCURRENT 0x0008
|
||||
#define USB_PORT_STAT_RESET 0x0010
|
||||
#define USB_PORT_STAT_POWER 0x0100
|
||||
#define USB_PORT_STAT_LOW_SPEED 0x0200
|
||||
#define USB_PORT_STAT_HIGH_SPEED 0x0400 /* support for EHCI */
|
||||
#define USB_PORT_STAT_SPEED \
|
||||
(USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED)
|
||||
|
||||
/* wPortChange bits */
|
||||
#define USB_PORT_STAT_C_CONNECTION 0x0001
|
||||
#define USB_PORT_STAT_C_ENABLE 0x0002
|
||||
#define USB_PORT_STAT_C_SUSPEND 0x0004
|
||||
#define USB_PORT_STAT_C_OVERCURRENT 0x0008
|
||||
#define USB_PORT_STAT_C_RESET 0x0010
|
||||
|
||||
/* wHubCharacteristics (masks) */
|
||||
#define HUB_CHAR_LPSM 0x0003
|
||||
#define HUB_CHAR_COMPOUND 0x0004
|
||||
#define HUB_CHAR_OCPM 0x0018
|
||||
|
||||
/*
|
||||
*Hub Status & Hub Change bit masks
|
||||
*/
|
||||
#define HUB_STATUS_LOCAL_POWER 0x0001
|
||||
#define HUB_STATUS_OVERCURRENT 0x0002
|
||||
|
||||
#define HUB_CHANGE_LOCAL_POWER 0x0001
|
||||
#define HUB_CHANGE_OVERCURRENT 0x0002
|
||||
|
||||
#endif /*_USB_DEFS_H_ */
|
||||
@@ -28,6 +28,8 @@
|
||||
#define _WAIT_H_
|
||||
|
||||
#include <bas_types.h>
|
||||
#include <stdint.h>
|
||||
#include "MCF5475.h"
|
||||
|
||||
typedef bool (*checker_func)(void);
|
||||
|
||||
|
||||
137
include/xhdi_sd.h
Normal file
137
include/xhdi_sd.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* xhdi_sd.h
|
||||
*
|
||||
* This file is part of BaS_gcc.
|
||||
*
|
||||
* BaS_gcc 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* BaS_gcc 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with BaS_gcc. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Created on: 01.05.2013
|
||||
* Copyright 2012 M. Fröschle
|
||||
*/
|
||||
#ifndef _XHDI_SD_H_
|
||||
#define _XHDI_SD_H_
|
||||
|
||||
/* XHDI function numbers */
|
||||
|
||||
#define XHDI_VERSION 0
|
||||
#define XHDI_INQUIRE_TARGET 1
|
||||
#define XHDI_RESERVE 2
|
||||
#define XHDI_LOCK 3
|
||||
#define XHDI_STOP 4
|
||||
#define XHDI_EJECT 5
|
||||
#define XHDI_DRIVEMAP 6
|
||||
#define XHDI_INQUIRE_DEVICE 7
|
||||
#define XHDI_INQUIRE_DRIVER 8
|
||||
#define XHDI_NEW_COOKIE 9
|
||||
#define XHDI_READ_WRITE 10
|
||||
#define XHDI_INQUIRE_TARGET2 11
|
||||
#define XHDI_INQUIRE_DEVICE2 12
|
||||
#define XHDI_DRIVER_SPECIAL 13
|
||||
#define XHDI_GET_CAPACITY 14
|
||||
#define XHDI_MEDIUM_CHANGED 15
|
||||
#define XHDI_MINT_INFO 16
|
||||
#define XHDI_DOS_LIMITS 17
|
||||
#define XHDI_LAST_ACCESS 18
|
||||
#define XHDI_REACCESS 19
|
||||
|
||||
/* XHDI error codes */
|
||||
|
||||
#define E_OK 0 /* OK */
|
||||
#define ERROR -1 /* unspecified error */
|
||||
#define EDRVNR -2 /* drive not ready */
|
||||
#define EUNDEV -15 /* invalid device/target number */
|
||||
#define EINVFN -32 /* invalid function number */
|
||||
#define EACCDN -36 /* access denied (device currently reserved) */
|
||||
#define EDRIVE -46 /* BIOS device not served by driver */
|
||||
|
||||
/* XHDI device capabilities */
|
||||
|
||||
#define XH_TARGET_STOPPABLE (1 << 0)
|
||||
#define XH_TARGET_REMOVABLE (1 << 1)
|
||||
#define XH_TARGET_LOCKABLE (1 << 2)
|
||||
#define XH_TARGET_EJECTABLE (1 << 3)
|
||||
#define XH_TARGET_LOCKED (1 << 29)
|
||||
#define XH_TARGET_STOPPED (1 << 30)
|
||||
#define XH_TARGET_RESERVED (1 << 31)
|
||||
|
||||
typedef struct _BPB
|
||||
{
|
||||
uint16_t recsiz; /* Bytes per sector */
|
||||
uint16_t clsiz; /* Sectors per cluster */
|
||||
uint16_t clsizb; /* Bytes per cluster */
|
||||
uint16_t rdlen; /* Directory length */
|
||||
uint16_t fsiz; /* Length of the FAT */
|
||||
uint16_t fatrec; /* Start of the 2nd FAT */
|
||||
uint16_t datrec; /* 1st free sector */
|
||||
uint16_t numcl; /* Total numbr of clusters */
|
||||
uint16_t bflags; /* Flags as bit-vector */
|
||||
/* Bit 0: 0 (12-Bit-FAT), 1 16-Bit-FAT */
|
||||
/* Bit 1: 0 (two FATs), 1 (one FAT) */
|
||||
/* only available since TOS 2.06 */
|
||||
} BPB;
|
||||
|
||||
/* a riddle: how do you typedef a function pointer to a function that returns its own type? ;) */
|
||||
typedef void* (*xhdi_call_fun)(int xhdi_fun, ...);
|
||||
|
||||
extern unsigned long xhdi_call(uint16_t *stack);
|
||||
|
||||
extern xhdi_call_fun xhdi_sd_install(xhdi_call_fun old_vector) __attribute__((__interrupt__));
|
||||
|
||||
extern uint16_t xhdi_version(void); /* XHDI 0 */
|
||||
|
||||
extern uint32_t xhdi_inquire_target(uint16_t major, uint16_t minor, uint32_t *block_size, uint32_t *flags,
|
||||
char *product_name); /* XHDI 1 */
|
||||
|
||||
extern uint32_t xhdi_reserve(uint16_t major, uint16_t minor, uint16_t do_reserve, uint16_t key); /* XHDI 2 */
|
||||
|
||||
extern uint32_t xhdi_lock(uint16_t major, uint16_t minor, uint16_t do_lock, uint16_t key); /* XHDI 3 */
|
||||
|
||||
extern uint32_t xhdi_stop(uint16_t major, uint16_t minor, uint16_t do_stop, uint16_t key); /* XHDI 4 */
|
||||
|
||||
extern uint32_t xhdi_eject(uint16_t major, uint16_t minor, uint16_t do_eject, uint16_t key); /* XHDI 5 */
|
||||
|
||||
extern uint32_t xhdi_drivemap(void); /* XHDI 6 */
|
||||
|
||||
extern uint32_t xhdi_inquire_device(uint16_t bios_device, uint16_t *major, uint16_t *minor,
|
||||
uint32_t *start_sector, /* BPB */ void *bpb); /* XHDI 7 */
|
||||
|
||||
extern uint32_t xhdi_inquire_driver(uint16_t bios_device, char *name, char *version,
|
||||
char *company, uint16_t *ahdi_version, uint16_t *maxIPL); /* XHDI 8 */
|
||||
|
||||
extern uint32_t xhdi_new_cookie(uint32_t newcookie); /* XHDI 9 */
|
||||
|
||||
extern uint32_t xhdi_read_write(uint16_t major, uint16_t minor, uint16_t rwflag,
|
||||
uint32_t recno, uint16_t count, void *buf); /* XHDI 10 */
|
||||
|
||||
extern uint32_t xhdi_inquire_target2(uint16_t major, uint16_t minor, uint32_t *block_size,
|
||||
uint32_t *device_flags, char *product_name, uint16_t stringlen); /* XHDI 11 */
|
||||
|
||||
extern uint32_t xhdi_inquire_device2(uint16_t bios_device, uint16_t *major, uint16_t *minor,
|
||||
uint32_t *start_sector, BPB *bpb, uint32_t *blocks, char *partid); /* XHDI 12 */
|
||||
|
||||
extern uint32_t xhdi_driver_special(uint32_t key1, uint32_t key2, uint16_t subopcode, void *data); /* XHDI 13 */
|
||||
|
||||
extern uint32_t xhdi_get_capacity(uint16_t major, uint16_t minor, uint32_t *blocks, uint32_t *bs); /* XHDI 14 */
|
||||
|
||||
extern uint32_t xhdi_medium_changed(uint16_t major, uint16_t minor); /* XHDI 15 */
|
||||
|
||||
extern uint32_t xhdi_mint_info(uint16_t opcode, void *data); /* XHDI 16 */
|
||||
|
||||
extern uint32_t xhdi_dos_limits(uint16_t which, uint32_t limit); /* XHDI 17 */
|
||||
|
||||
extern uint32_t xhdi_last_access(uint16_t major, uint16_t minor, uint32_t *ms); /* XHDI 18 */
|
||||
|
||||
extern uint32_t xhdi_reaccess(uint16_t major, uint16_t minor); /* XHDI 19 */
|
||||
|
||||
#endif /* _XHDI_SD_H_ */
|
||||
@@ -28,6 +28,13 @@ char *strcpy(char *dst, const char *src)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *strncpy(char *dst, const char *src, int max)
|
||||
{
|
||||
char *ptr = dst;
|
||||
|
||||
while ((*dst++ = *src++) != '\0' && max-- >= 0);
|
||||
return ptr;
|
||||
}
|
||||
int atoi(const char *c)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
514
sources/cmd_usb.c
Normal file
514
sources/cmd_usb.c
Normal file
@@ -0,0 +1,514 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* Most of this source has been derived from the Linux USB
|
||||
* project.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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 "config.h"
|
||||
#include <stdarg.h>
|
||||
#include "usb.h"
|
||||
|
||||
#undef RESET_START_STOP_CMDS
|
||||
#undef CONFIG_USB_STORAGE
|
||||
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined(CONFIG_USB_EHCI)
|
||||
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
extern int usb_stor_curr_dev; /* current device */
|
||||
#endif
|
||||
|
||||
#if defined(COLDFIRE) && defined(NETWORK) && defined(LWIP)
|
||||
extern long pxCurrentTCB, tid_TOS;
|
||||
// #define info(format, arg...) do { if(pxCurrentTCB == tid_TOS) kprint(format, ## arg); else board_printf(format, ## arg); } while(0)
|
||||
#else
|
||||
#define info(format, arg...) kprint(format, ## arg)
|
||||
#endif
|
||||
|
||||
#if defined(COLDFIRE) && defined(NETWORK) && defined(LWIP)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int dest;
|
||||
void (*func)(char);
|
||||
char *loc;
|
||||
} PRINTK_INFO;
|
||||
|
||||
#define DEST_CONSOLE (1)
|
||||
#define DEST_STRING (2)
|
||||
|
||||
extern int printk(PRINTK_INFO *info, const char *fmt, va_list ap);
|
||||
|
||||
static void info(const char *const fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
PRINTK_INFO info;
|
||||
static char buf[1024];
|
||||
info.dest = DEST_STRING;
|
||||
info.loc = buf;
|
||||
va_start(ap, fmt);
|
||||
printk(&info, fmt, ap);
|
||||
*info.loc = '\0';
|
||||
if(pxCurrentTCB == tid_TOS)
|
||||
kprint(buf);
|
||||
else
|
||||
board_printf(buf);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#endif /* defined(COLDFIRE) && defined(NETWORK) && defined(LWIP) */
|
||||
|
||||
/* some display routines (info command) */
|
||||
char *usb_get_class_desc(unsigned char dclass)
|
||||
{
|
||||
switch (dclass)
|
||||
{
|
||||
case USB_CLASS_PER_INTERFACE: return "See Interface";
|
||||
case USB_CLASS_AUDIO: return "Audio";
|
||||
case USB_CLASS_COMM: return "Communication";
|
||||
case USB_CLASS_HID: return "Human Interface";
|
||||
case USB_CLASS_PRINTER: return "Printer";
|
||||
case USB_CLASS_MASS_STORAGE: return "Mass Storage";
|
||||
case USB_CLASS_HUB: return "Hub";
|
||||
case USB_CLASS_DATA: return "CDC Data";
|
||||
case USB_CLASS_VENDOR_SPEC: return "Vendor specific";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_class_sub(unsigned char dclass, unsigned char subclass, unsigned char proto)
|
||||
{
|
||||
switch(dclass)
|
||||
{
|
||||
case USB_CLASS_PER_INTERFACE:
|
||||
info("See Interface");
|
||||
break;
|
||||
case USB_CLASS_HID:
|
||||
info("Human Interface, Subclass: ");
|
||||
switch(subclass)
|
||||
{
|
||||
case USB_SUB_HID_NONE: info("None"); break;
|
||||
case USB_SUB_HID_BOOT:
|
||||
info("Boot ");
|
||||
switch(proto)
|
||||
{
|
||||
case USB_PROT_HID_NONE: info("None"); break;
|
||||
case USB_PROT_HID_KEYBOARD: info("Keyboard"); break;
|
||||
case USB_PROT_HID_MOUSE: info("Mouse"); break;
|
||||
default: info("reserved"); break;
|
||||
}
|
||||
break;
|
||||
default: info("reserved"); break;
|
||||
}
|
||||
break;
|
||||
case USB_CLASS_MASS_STORAGE:
|
||||
info("Mass Storage, ");
|
||||
switch(subclass)
|
||||
{
|
||||
case US_SC_RBC: info("RBC "); break;
|
||||
case US_SC_8020: info("SFF-8020i (ATAPI)"); break;
|
||||
case US_SC_QIC: info("QIC-157 (Tape)"); break;
|
||||
case US_SC_UFI: info("UFI"); break;
|
||||
case US_SC_8070: info("SFF-8070"); break;
|
||||
case US_SC_SCSI: info("Transp. SCSI"); break;
|
||||
default: info("reserved"); break;
|
||||
}
|
||||
info(", ");
|
||||
switch (proto)
|
||||
{
|
||||
case US_PR_CB: info("Command/Bulk"); break;
|
||||
case US_PR_CBI: info("Command/Bulk/Int"); break;
|
||||
case US_PR_BULK: info("Bulk only"); break;
|
||||
default: info("reserved"); break;
|
||||
}
|
||||
break;
|
||||
default: info("%s", usb_get_class_desc(dclass)); break;
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_string(struct usb_device *dev, int index)
|
||||
{
|
||||
char buffer[256];
|
||||
if(index != 0)
|
||||
{
|
||||
if(usb_string(dev, index, &buffer[0], 256) > 0)
|
||||
info("String: \"%s\"", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_desc(struct usb_device *dev)
|
||||
{
|
||||
if(dev->descriptor.bDescriptorType == USB_DT_DEVICE)
|
||||
{
|
||||
info("%d: %s, USB Revision %x.%x\r\n", dev->devnum, usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), (dev->descriptor.bcdUSB>>8) & 0xff, dev->descriptor.bcdUSB & 0xff);
|
||||
if(strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
|
||||
info(" - %s %s %s\r\n", dev->mf, dev->prod, dev->serial);
|
||||
if(dev->descriptor.bDeviceClass)
|
||||
{
|
||||
info(" - Class: ");
|
||||
usb_display_class_sub(dev->descriptor.bDeviceClass, dev->descriptor.bDeviceSubClass, dev->descriptor.bDeviceProtocol);
|
||||
info("\r\n");
|
||||
}
|
||||
else
|
||||
info(" - Class: (from Interface) %s\r\n", usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass));
|
||||
info(" - PacketSize: %d Configurations: %d\r\n",
|
||||
dev->descriptor.bMaxPacketSize0,
|
||||
dev->descriptor.bNumConfigurations);
|
||||
info(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\r\n", dev->descriptor.idVendor, dev->descriptor.idProduct, (dev->descriptor.bcdDevice>>8) & 0xff, dev->descriptor.bcdDevice & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_conf_desc(struct usb_config_descriptor *config, struct usb_device *dev)
|
||||
{
|
||||
info(" Configuration: %d\r\n", config->bConfigurationValue);
|
||||
info(" - Interfaces: %d %s%s%dmA\r\n", config->bNumInterfaces, (config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ", (config->bmAttributes & 0x20) ? "Remote Wakeup " : "", config->MaxPower*2);
|
||||
if(config->iConfiguration)
|
||||
{
|
||||
info(" - ");
|
||||
usb_display_string(dev, config->iConfiguration);
|
||||
info("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_if_desc(struct usb_interface_descriptor *ifdesc, struct usb_device *dev)
|
||||
{
|
||||
info(" Interface: %d\r\n", ifdesc->bInterfaceNumber);
|
||||
info(" - Alternate Setting %d, Endpoints: %d\r\n", ifdesc->bAlternateSetting, ifdesc->bNumEndpoints);
|
||||
info(" - Class ");
|
||||
usb_display_class_sub(ifdesc->bInterfaceClass, ifdesc->bInterfaceSubClass, ifdesc->bInterfaceProtocol);
|
||||
info("\r\n");
|
||||
if(ifdesc->iInterface)
|
||||
{
|
||||
info(" - ");
|
||||
usb_display_string(dev, ifdesc->iInterface);
|
||||
info("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
|
||||
{
|
||||
info(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf, (epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
|
||||
switch((epdesc->bmAttributes & 0x03))
|
||||
{
|
||||
case 0: info("Control"); break;
|
||||
case 1: info("Isochronous"); break;
|
||||
case 2: info("Bulk"); break;
|
||||
case 3: info("Interrupt"); break;
|
||||
}
|
||||
info(" MaxPacket %d", epdesc->wMaxPacketSize);
|
||||
if((epdesc->bmAttributes & 0x03) == 0x3)
|
||||
info(" Interval %dms", epdesc->bInterval);
|
||||
info("\r\n");
|
||||
}
|
||||
|
||||
/* main routine to diasplay the configs, interfaces and endpoints */
|
||||
void usb_display_config(struct usb_device *dev)
|
||||
{
|
||||
struct usb_config_descriptor *config;
|
||||
struct usb_interface_descriptor *ifdesc;
|
||||
struct usb_endpoint_descriptor *epdesc;
|
||||
int i, ii;
|
||||
config = &dev->config;
|
||||
usb_display_conf_desc(config, dev);
|
||||
for(i = 0; i < config->no_of_if; i++)
|
||||
{
|
||||
ifdesc = &config->if_desc[i];
|
||||
usb_display_if_desc(ifdesc, dev);
|
||||
for(ii = 0; ii < ifdesc->no_of_ep; ii++)
|
||||
{
|
||||
epdesc = &ifdesc->ep_desc[ii];
|
||||
usb_display_ep_desc(epdesc);
|
||||
}
|
||||
}
|
||||
info("\r\n");
|
||||
}
|
||||
|
||||
static inline char *portspeed(int speed)
|
||||
{
|
||||
if(speed == USB_SPEED_HIGH)
|
||||
return "480 Mb/s";
|
||||
else if(speed == USB_SPEED_LOW)
|
||||
return "1.5 Mb/s";
|
||||
else
|
||||
return "12 Mb/s";
|
||||
}
|
||||
|
||||
/* shows the device tree recursively */
|
||||
void usb_show_tree_graph(struct usb_device *dev, char *pre)
|
||||
{
|
||||
int i, index;
|
||||
int has_child, last_child, port;
|
||||
index = strlen(pre);
|
||||
info(" %s", pre);
|
||||
/* check if the device has connected children */
|
||||
has_child = 0;
|
||||
for(i = 0; i < dev->maxchild; i++)
|
||||
{
|
||||
if(dev->children[i] != NULL)
|
||||
has_child = 1;
|
||||
}
|
||||
/* check if we are the last one */
|
||||
last_child = 1;
|
||||
if(dev->parent != NULL)
|
||||
{
|
||||
for(i = 0; i < dev->parent->maxchild; i++)
|
||||
{
|
||||
/* search for children */
|
||||
if(dev->parent->children[i] == dev)
|
||||
{
|
||||
/* found our pointer, see if we have a little sister */
|
||||
port = i;
|
||||
while(i++ < dev->parent->maxchild)
|
||||
{
|
||||
if(dev->parent->children[i] != NULL)
|
||||
{
|
||||
/* found a sister */
|
||||
last_child = 0;
|
||||
break;
|
||||
} /* if */
|
||||
} /* while */
|
||||
} /* device found */
|
||||
} /* for all children of the parent */
|
||||
info("\b+-");
|
||||
/* correct last child */
|
||||
if(last_child)
|
||||
pre[index-1] = ' ';
|
||||
} /* if not root hub */
|
||||
else
|
||||
info(" ");
|
||||
info("%d ", dev->devnum);
|
||||
pre[index++] = ' ';
|
||||
pre[index++] = has_child ? '|' : ' ';
|
||||
pre[index] = 0;
|
||||
info(" %s (%s, %dmA)\r\n", usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass), portspeed(dev->speed), dev->config.MaxPower * 2);
|
||||
if(strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
|
||||
info(" %s %s %s %s\r\n", pre, dev->mf, dev->prod, dev->serial);
|
||||
info(" %s\r\n", pre);
|
||||
if(dev->maxchild > 0)
|
||||
{
|
||||
for(i = 0; i < dev->maxchild; i++)
|
||||
{
|
||||
if(dev->children[i] != NULL)
|
||||
{
|
||||
usb_show_tree_graph(dev->children[i], pre);
|
||||
pre[index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* main routine for the tree command */
|
||||
void usb_show_tree(struct usb_device *dev)
|
||||
{
|
||||
char preamble[32];
|
||||
memset(preamble, 0, 32);
|
||||
usb_show_tree_graph(dev, &preamble[0]);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* usb command intepreter
|
||||
*/
|
||||
int uif_cmd_usb(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
struct usb_device *dev = NULL;
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
block_dev_desc_t *stor_dev;
|
||||
#endif
|
||||
#ifdef RESET_START_STOP_CMDS
|
||||
extern char usb_started;
|
||||
if((strncmp(argv[1], "reset", 5) == 0) || (strncmp(argv[1], "start", 5) == 0))
|
||||
{
|
||||
usb_stop();
|
||||
info("(Re)start USB...\r\n");
|
||||
i = usb_init(0, NULL);
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
/* try to recognize storage devices immediately */
|
||||
if(i >= 0)
|
||||
usb_stor_curr_dev = usb_stor_scan();
|
||||
#endif /* CONFIG_USB_STORAGE */
|
||||
return 0;
|
||||
}
|
||||
if(strncmp(argv[1], "stop", 4) == 0)
|
||||
{
|
||||
#ifdef CONFIG_USB_KEYBOARD
|
||||
if(argc == 2)
|
||||
{
|
||||
if(usb_kbd_deregister() != 0)
|
||||
{
|
||||
info("USB not stopped: usbkbd still using USB\r\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else /* forced stop, switch console in to serial */
|
||||
usb_kbd_deregister();
|
||||
#endif /* CONFIG_USB_KEYBOARD */
|
||||
info("stopping USB..\r\n");
|
||||
usb_stop();
|
||||
return 0;
|
||||
}
|
||||
if(!usb_started)
|
||||
{
|
||||
info("USB is stopped. Please issue 'usb start' first.\r\n");
|
||||
return 1;
|
||||
}
|
||||
#endif /* RESET_START_STOP_CMDS */
|
||||
if(strncmp(argv[1], "tree", 4) == 0)
|
||||
{
|
||||
info("\r\nUSB Device Tree:\r\n");
|
||||
for(i = 0; i < USB_MAX_BUS; i++)
|
||||
{
|
||||
struct usb_device *dev = usb_get_dev_index(0, i);
|
||||
if(dev == NULL)
|
||||
break;
|
||||
info(" USB controller %d:\r\n", i);
|
||||
usb_show_tree(dev);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(strncmp(argv[1], "inf", 3) == 0)
|
||||
{
|
||||
int b, d;
|
||||
if(argc == 2)
|
||||
{
|
||||
for(b = 0; b < USB_MAX_BUS; b++)
|
||||
{
|
||||
for(d = 0; d < USB_MAX_DEVICE; d++)
|
||||
{
|
||||
dev = usb_get_dev_index(d, b);
|
||||
if(dev == NULL)
|
||||
break;
|
||||
if(!d)
|
||||
info("USB controller %d:\r\n\n", b);
|
||||
usb_display_desc(dev);
|
||||
usb_display_config(dev);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int d;
|
||||
i = strtoul(argv[2], NULL, 16);
|
||||
info("config for device %d\r\n", i);
|
||||
for(d = 0; d < USB_MAX_DEVICE; d++)
|
||||
{
|
||||
dev = usb_get_dev_index(d, 0);
|
||||
if(dev == NULL)
|
||||
break;
|
||||
if(dev->devnum == i)
|
||||
break;
|
||||
}
|
||||
if(dev == NULL)
|
||||
{
|
||||
info("*** NO Device avaiable ***\r\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_display_desc(dev);
|
||||
usb_display_config(dev);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_USB_STORAGE
|
||||
if(strncmp(argv[1], "stor", 4) == 0)
|
||||
return usb_stor_info();
|
||||
if(strcmp(argv[1], "read") == 0)
|
||||
{
|
||||
if(usb_stor_curr_dev < 0)
|
||||
{
|
||||
info("no current device selected\r\n");
|
||||
return 1;
|
||||
}
|
||||
if(argc == 5)
|
||||
{
|
||||
unsigned long addr = strtoul(argv[2], NULL, 16);
|
||||
unsigned long blk = strtoul(argv[3], NULL, 16);
|
||||
unsigned long cnt = strtoul(argv[4], NULL, 16);
|
||||
unsigned long n;
|
||||
info("\r\nUSB read: device %d block # %ld, count %ld ... ", usb_stor_curr_dev, blk, cnt);
|
||||
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
|
||||
n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, (unsigned long *)addr);
|
||||
info("%ld blocks read: %s\r\n", n, (n == cnt) ? "OK" : "ERROR");
|
||||
if(n == cnt)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(strncmp(argv[1], "dev", 3) == 0)
|
||||
{
|
||||
if(argc == 3)
|
||||
{
|
||||
int dev = (int)strtoul(argv[2], NULL, 10);
|
||||
info("\r\nUSB device %d: ", dev);
|
||||
if(dev >= USB_MAX_STOR_DEV)
|
||||
{
|
||||
info("unknown device\r\n");
|
||||
return 1;
|
||||
}
|
||||
info("\r\n Device %d: ", dev);
|
||||
stor_dev = usb_stor_get_dev(dev);
|
||||
dev_print(stor_dev);
|
||||
if(stor_dev->type == DEV_TYPE_UNKNOWN)
|
||||
return 1;
|
||||
usb_stor_curr_dev = dev;
|
||||
info("... is now current device\r\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
info("\r\nUSB device %d: ", usb_stor_curr_dev);
|
||||
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
|
||||
dev_print(stor_dev);
|
||||
if(stor_dev->type == DEV_TYPE_UNKNOWN)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
info(
|
||||
#ifdef RESET_START_STOP_CMDS
|
||||
"usb reset - reset (rescan) USB controller\r\n"
|
||||
"usb stop [f] - stop USB [f]=force stop\r\n"
|
||||
#endif
|
||||
"usb tree - show USB device tree\r\n"
|
||||
"usb info [dev] - show available USB devices\r\n"
|
||||
"usb storage - show details of USB storage devices\r\n"
|
||||
"usb dev [dev] - show or set current USB storage device\r\n"
|
||||
"usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\r\n"
|
||||
" to memory address `addr'\r\n");
|
||||
#else /* !CONFIG_USB_STORAGE */
|
||||
info(
|
||||
#ifdef RESET_START_STOP_CMDS
|
||||
"usb reset - reset (rescan) USB controller\r\n"
|
||||
"usb stop [f] - stop USB [f]=force stop\r\n"
|
||||
#endif
|
||||
"usb tree - show USB device tree\r\n"
|
||||
"usb info [dev] - show available USB devices\r\n");
|
||||
#endif /* CONFIG_USB_STORAGE */
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USB_UHCI || CONFIG_USB_OHCI || CONFIG_USB_EHCI */
|
||||
1180
sources/ehci-hcd.c
Normal file
1180
sources/ehci-hcd.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@
|
||||
.extern _video_tlb
|
||||
.extern _video_sbt
|
||||
.extern cpusha
|
||||
.extern _xhdi_sd_install /* trap #0 exception vector for installation of xhdi SD card driver */
|
||||
|
||||
/* Register read/write macros */
|
||||
#define MCF_MMU_MMUCR __MMUBAR
|
||||
@@ -131,31 +132,31 @@
|
||||
|
||||
move.w #0x2700,sr // disable interrupt
|
||||
subq.l #8,a7
|
||||
movem.l d0/a5,(a7) // register sichern
|
||||
movem.l d0/a5,(a7) // save registers
|
||||
lea MCF_EPORT_EPFR,a5
|
||||
move.b #\clr_int,(a5) // clear int pending
|
||||
// test auf protect mode ---------------------
|
||||
move.b DIP_SWITCHa,d0
|
||||
btst #7,d0
|
||||
bne irq_protect // ja->
|
||||
bne irq_protect // ja->
|
||||
// -------------------------------------------
|
||||
movem.l (a7),d0/a5 // register zurück
|
||||
movem.l (a7),d0/a5 // restore registers
|
||||
addq.l #8,a7
|
||||
move.l \vector,-(a7)
|
||||
move #0x2\int_mask\()00,sr
|
||||
rts
|
||||
irq_protect:
|
||||
move.l usp,a5 // usp holen
|
||||
tst.b _rt_mod // supervisor?
|
||||
bne sev_supint // ja ->
|
||||
mov3q.l #-1,_rt_mod // auf supervisor setzen
|
||||
move.l a5,_rt_usp // rt_usp speichern
|
||||
move.l _rt_ssp,a5 // rt_ssp holen
|
||||
move.l usp,a5 // get usp
|
||||
tst.b _rt_mod // supervisor mode active?
|
||||
bne sev_supint // yes ->
|
||||
mov3q.l #-1,_rt_mod // enable supervisor mode
|
||||
move.l a5,_rt_usp // save rt_usp
|
||||
move.l _rt_ssp,a5 // get rt_ssp
|
||||
#ifdef cf_stack
|
||||
move.l 12(a7),-(a5) // pc transferieren
|
||||
move.l 12(a7),-(a5) // transfer pc
|
||||
move.l 8(a7),-(a5) // sr,vec
|
||||
#else
|
||||
move.w 8(a7),-(a5) // vector nr.
|
||||
move.w 8(a7),-(a5) // vector no
|
||||
move.l 12(a7),-(a5) // pc verschieben
|
||||
move.w 10(a7),-(a5) // sr verschieben
|
||||
#endif
|
||||
@@ -209,15 +210,15 @@ _vec_init:
|
||||
clr.l _rt_ssp
|
||||
clr.l _rt_usp
|
||||
clr.l _rt_vbr
|
||||
move.l #__RAMBAR0,d0 // sind in rambar0
|
||||
move.l #__RAMBAR0,d0 // exception vectors reside in rambar0
|
||||
movec d0,VBR
|
||||
move.l d0,a0
|
||||
move.l a0,a2
|
||||
init_vec:
|
||||
move.l #256,d0
|
||||
lea std_exc_vec(pc),a1 // standard vector
|
||||
lea std_exc_vec(pc),a1 // standard vector
|
||||
init_vec_loop:
|
||||
move.l a1,(a2)+ // mal standard vector f<EFBFBD>r alle setzen
|
||||
move.l a1,(a2)+ // set standard vector for all exceptions
|
||||
subq.l #1,d0
|
||||
bne init_vec_loop
|
||||
|
||||
@@ -265,6 +266,10 @@ init_vec_loop:
|
||||
move.l a1,0xdc(a0)
|
||||
no_protect_vectors:
|
||||
|
||||
// trap #0 (without any parameters for now) is used to provide BaS' XHDI
|
||||
// routine address to EmuTOS.
|
||||
lea _xhdi_sd_install,a1
|
||||
move.l a1,0x80(a0) // trap #0 exception vector
|
||||
|
||||
// int 1-7
|
||||
lea irq1(pc),a1
|
||||
@@ -360,14 +365,14 @@ sev_sup:
|
||||
add.l _rt_vbr,d0 // + basis
|
||||
move.l d0,a5
|
||||
move.l (a5),12(a7) // hier geht's weiter
|
||||
movem.l (a7),d0/a5 // register zur<EFBFBD>ck
|
||||
movem.l (a7),d0/a5 // register zurück
|
||||
addq.l #8,a7
|
||||
rte // und weg
|
||||
//*******************************************
|
||||
reset_vector:
|
||||
move.w #0x2700,sr // disable interrupt
|
||||
move.l #0x31415926,d0
|
||||
cmp.l 0x426,d0 // reset vector g<EFBFBD>ltg?
|
||||
cmp.l 0x426,d0 // reset vector gültg?
|
||||
beq std_exc_vec // ja->
|
||||
jmp _rom_entry // sonst kaltstart
|
||||
acess:
|
||||
@@ -467,7 +472,7 @@ irq6: // mfp
|
||||
// test auf timeout screen adr change -------------------------------------------------------
|
||||
move.l _video_sbt,d0
|
||||
beq irq6_non_sca // wenn 0 nichts zu tun
|
||||
sub.l #0x70000000,d0 // 14 sec abz<EFBFBD>hlen
|
||||
sub.l #0x70000000,d0 // 14 sec abzählen
|
||||
lea MCF_SLT0_SCNT,a5
|
||||
cmp.l (a5),d0 // aktuelle zeit weg
|
||||
ble irq6_non_sca // noch nicht abgelaufen
|
||||
@@ -487,13 +492,13 @@ irq6: // mfp
|
||||
swap d4
|
||||
move.l d4,MCF_MMU_MMUAR
|
||||
mvz.w #0x10e,d4
|
||||
move.l d4,MCF_MMU_MMUOR // eintr<EFBFBD>ge holen aus mmu
|
||||
move.l d4,MCF_MMU_MMUOR // einträge holen aus mmu
|
||||
nop
|
||||
move.l MCF_MMU_MMUTR,d4 // ID holen
|
||||
lsr.l #2,d4 // bit 9 bis 2
|
||||
cmp.w #sca_page_ID,d4 // ist screen change ID?
|
||||
bne irq6_sca_pn // nein -> page keine screen area next
|
||||
// eintrag <EFBFBD>ndern
|
||||
// eintrag <EFBFBD>ndern
|
||||
add.l #std_mmutr,d0
|
||||
move.l d3,d1 // page 0?
|
||||
beq irq6_sca_pn0 // ja ->
|
||||
@@ -527,9 +532,9 @@ irq6_sca_pn:
|
||||
|
||||
move.l #0x2000,d0
|
||||
move.l d0,_video_tlb // anfangszustand wieder herstellen
|
||||
clr.l _video_sbt // zeit l<EFBFBD>schen
|
||||
clr.l _video_sbt // zeit löschen
|
||||
|
||||
movem.l (a7),d0-d4/a0-a1 // register zur<EFBFBD>ck
|
||||
movem.l (a7),d0-d4/a0-a1 // register zurück
|
||||
lea 28(a7),a7
|
||||
irq6_non_sca:
|
||||
// test auf acsi dma -----------------------------------------------------------------
|
||||
@@ -566,9 +571,9 @@ irq6_2:
|
||||
move.l 0xF0020000,a5 // vector holen
|
||||
add.l _rt_vbr,a5 // basis
|
||||
move.l (a5),d0 // vector holen
|
||||
move.l 4(a7),a5 // a5 zur<EFBFBD>ck
|
||||
move.l 4(a7),a5 // a5 zurück
|
||||
move.l d0,4(a7) // vector eintragen
|
||||
move.l (a7)+,d0 // d0 zur<EFBFBD>ck
|
||||
move.l (a7)+,d0 // d0 zurück
|
||||
move #0x2600,sr
|
||||
rts
|
||||
irq6_3:
|
||||
@@ -590,7 +595,7 @@ irq6_3:
|
||||
move.l 0xF0020000,a5 // vector holen: intack routine
|
||||
add.l _rt_vbr,a5 // virtuelle VBR des Systems
|
||||
move.l (a5),12(a7) // hier gehts weiter
|
||||
movem.l (a7),d0/a5 // register zur<EFBFBD>ck
|
||||
movem.l (a7),d0/a5 // register zurück
|
||||
addq.l #8,a7
|
||||
move.b #6,2(a7) // intmaske setzen
|
||||
rte // und weg
|
||||
@@ -609,7 +614,7 @@ sev_sup6:
|
||||
move.l 0xF0020000,a5 // vector holen: intack routine
|
||||
add.l _rt_vbr,a5 // virtuelle VBR des Systems
|
||||
move.l (a5),12(a7) // hier gehts weiter
|
||||
movem.l (a7),d0/a5 // register zur<EFBFBD>ck
|
||||
movem.l (a7),d0/a5 // register zurück
|
||||
rts
|
||||
|
||||
.data
|
||||
@@ -626,9 +631,9 @@ acsi_dma: // atari dma
|
||||
move.l d1,-(a7)
|
||||
|
||||
lea MCF_PSC0_PSCTB_8BIT,a1 // ++ vr
|
||||
mchar move.l, 'D,'M','A,'\ ,(a1)
|
||||
mchar move.l, 'D','M','A','\'' ,(a1)
|
||||
//move.l #"DMA ",(a1)
|
||||
mchar move.l,'I,'N,'T,'!,(a1)
|
||||
mchar move.l,'I','N','T','!',(a1)
|
||||
// move.l #'INT!',(a1)
|
||||
|
||||
lea 0xf0020110,a5 // fifo daten
|
||||
|
||||
108
sources/fifo.c
Normal file
108
sources/fifo.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* fifo.c
|
||||
*
|
||||
* A general implementation of a fifo buffer
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fifo.h>
|
||||
|
||||
//This initializes the FIFO structure with the given buffer and size
|
||||
void fifo_init(fifo_t * f, char * buf, int16_t size)
|
||||
{
|
||||
f->head = 0;
|
||||
f->tail = 0;
|
||||
f->size = size;
|
||||
f->buf = buf;
|
||||
f->low = 0;
|
||||
f->high = 0;
|
||||
}
|
||||
|
||||
// Get one byte from the fifo buffer
|
||||
uint8_t fifo_get(fifo_t *f)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
|
||||
if( !fifo_empty(f) )
|
||||
{
|
||||
fifo_advance(f,&f->tail);
|
||||
ch = f->buf[f->tail];
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
// Put one byte into the buffer
|
||||
void fifo_put(fifo_t *f, uint8_t byte)
|
||||
{
|
||||
if( fifo_unused(f) <= 0 )
|
||||
return;
|
||||
fifo_advance(f,&f->head);
|
||||
f->buf[f->head] = byte;
|
||||
}
|
||||
|
||||
void fifo_clear(fifo_t *f)
|
||||
{
|
||||
f->head = f->tail = 0;
|
||||
}
|
||||
|
||||
int fifo_used(fifo_t *f)
|
||||
{
|
||||
if( f->head > f->tail )
|
||||
return (f->head - f->tail);
|
||||
return (f->size - f->tail + f->head);
|
||||
}
|
||||
|
||||
int fifo_unused(fifo_t *f)
|
||||
{
|
||||
if( f->head > f->tail )
|
||||
return (f->size-f->head+f->tail);
|
||||
return (f->tail-f->head);
|
||||
}
|
||||
|
||||
int fifo_full(fifo_t *f)
|
||||
{
|
||||
if( f->head+1 >= f->size )
|
||||
return (f->tail == 0);
|
||||
return (f->head+1 == f->tail);
|
||||
}
|
||||
|
||||
int fifo_empty(fifo_t *f)
|
||||
{
|
||||
return (f->head == f->tail);
|
||||
}
|
||||
|
||||
void fifo_advance(fifo_t *f, int16_t *ix)
|
||||
{
|
||||
if( ++*ix > f->size )
|
||||
*ix=0;
|
||||
}
|
||||
|
||||
//This reads at most nbytes bytes from the FIFO
|
||||
//The number of bytes read is returned
|
||||
int fifo_read(fifo_t *f, unsigned char *buf, int16_t nbytes){
|
||||
int n = 0;
|
||||
|
||||
while( n < nbytes && !fifo_empty(f) )
|
||||
{
|
||||
n++;
|
||||
*buf++ = fifo_get(f);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
//This writes up to nbytes bytes to the FIFO
|
||||
//If the head runs in to the tail, not all bytes are written
|
||||
//The number of bytes written is returned
|
||||
int fifo_write(fifo_t *f, const unsigned char *buf, int16_t nbytes){
|
||||
int n = 0;
|
||||
|
||||
while( n < nbytes && !fifo_full(f) )
|
||||
{
|
||||
fifo_put(f,*buf++);
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
208
sources/i2c_firebee.c
Normal file
208
sources/i2c_firebee.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* i2c.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include <MCF5475.h>
|
||||
#include <i2c_firebee.h>
|
||||
|
||||
#include <fifo.h>
|
||||
|
||||
int register_handler(uint8_t,uint8_t,void (*func)());
|
||||
|
||||
static struct
|
||||
{
|
||||
uint8_t state;
|
||||
long delay;
|
||||
uint16_t len;
|
||||
fifo_t fifo;
|
||||
unsigned char *_buf;
|
||||
uint16_t device;
|
||||
} i2c_param;
|
||||
|
||||
char local_buf[BUFSIZ];
|
||||
|
||||
#define FIFO &i2c_param.fifo
|
||||
|
||||
void __attribute__ ((interrupt)) I2C_InterruptHandler(void)
|
||||
{
|
||||
char ch;
|
||||
|
||||
clear_bit(MCF_I2C_I2SR, MCF_I2C_I2SR_IIF);
|
||||
if (MCF_I2C_I2CR & MCF_I2C_I2CR_MSTA)
|
||||
{ // Masters of the known universe
|
||||
if (MCF_I2C_I2SR & MCF_I2C_I2SR_ICF)
|
||||
{
|
||||
switch (i2c_param.state)
|
||||
{
|
||||
case I2C_MXRX:
|
||||
if (fifo_used(&i2c_param.fifo) + 1 == i2c_param.len)
|
||||
{
|
||||
clear_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MSTA);
|
||||
i2c_param.state = I2C_READY;
|
||||
}
|
||||
else if (fifo_used(&i2c_param.fifo) + 2 == i2c_param.len)
|
||||
{
|
||||
set_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_TXAK);
|
||||
i2c_param.state = I2C_READY;
|
||||
}
|
||||
fifo_put(&i2c_param.fifo, MCF_I2C_I2DR );
|
||||
break;
|
||||
case I2C_ADDR:
|
||||
if (fifo_empty(&i2c_param.fifo))
|
||||
{
|
||||
i2c_param.state = I2C_MXRX;
|
||||
clear_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MTX); // Receive mode
|
||||
set_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_RSTA);
|
||||
ch = MCF_I2C_I2DR; // Dummy read
|
||||
break;
|
||||
}
|
||||
case I2C_MXTX:
|
||||
if (fifo_empty(&i2c_param.fifo)
|
||||
|| (MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK))
|
||||
{
|
||||
clear_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MSTA);
|
||||
i2c_param.state = I2C_READY;
|
||||
}
|
||||
else
|
||||
MCF_I2C_I2DR = fifo_get(&i2c_param.fifo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Slave mode.
|
||||
int set;
|
||||
|
||||
if ((set = (MCF_I2C_I2SR & MCF_I2C_I2SR_IAL)))
|
||||
clear_bit(MCF_I2C_I2SR, MCF_I2C_I2SR_IAL);
|
||||
if (MCF_I2C_I2SR & MCF_I2C_I2SR_IAAS)
|
||||
{
|
||||
if (MCF_I2C_I2SR & MCF_I2C_I2SR_SRW)
|
||||
{
|
||||
set_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MTX);
|
||||
fifo_put(&i2c_param.fifo, MCF_I2C_I2DR );
|
||||
}
|
||||
else
|
||||
{
|
||||
clear_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MTX);
|
||||
ch = MCF_I2C_I2DR;
|
||||
}
|
||||
}
|
||||
else if (!set)
|
||||
{
|
||||
if (MCF_I2C_I2CR & MCF_I2C_I2CR_MTX)
|
||||
{
|
||||
if (MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK)
|
||||
MCF_I2C_I2DR = fifo_get(&i2c_param.fifo);
|
||||
else
|
||||
{
|
||||
clear_bit(MCF_I2C_I2CR, MCF_I2C_I2CR_MTX);
|
||||
ch = MCF_I2C_I2DR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fifo_put(&i2c_param.fifo, MCF_I2C_I2DR );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I2Cinit: I2C initilazation as master
|
||||
*
|
||||
* Parameters: None.
|
||||
*
|
||||
* Return : None.
|
||||
*/
|
||||
void I2C_Init()
|
||||
{
|
||||
i2c_param.fifo.buf = local_buf;
|
||||
i2c_param.fifo.size = BUFSIZ;
|
||||
i2c_param.delay = 133 * 10L; // We can safely ignore this
|
||||
i2c_param.len = 0;
|
||||
I2C_ioctl(0, 0);
|
||||
register_handler(1,40,I2C_InterruptHandler);
|
||||
xprintf("Registered I2C Handler ...\n\r");
|
||||
}
|
||||
|
||||
void I2C_send(unsigned short device, unsigned char *buf, unsigned short len)
|
||||
{
|
||||
if (len > i2c_param.fifo.size)
|
||||
return;
|
||||
i2c_param.len = len;
|
||||
fifo_clear(&i2c_param.fifo);
|
||||
if (device > 127) // Use I2C 10 bit address
|
||||
{
|
||||
fifo_put(FIFO, 0b11110 | ((device >> 5) & 6) | I2C_WRITE);
|
||||
fifo_put(FIFO, device & 255);
|
||||
}
|
||||
else
|
||||
fifo_put(FIFO, ((device << 1) & 0xFE) | I2C_WRITE);
|
||||
fifo_write(FIFO, buf, len);
|
||||
i2c_param.state = I2C_MXTX;
|
||||
}
|
||||
|
||||
void I2C_receive(unsigned short device, unsigned char *buf, unsigned short len)
|
||||
{
|
||||
if (len > i2c_param.fifo.size)
|
||||
return;
|
||||
i2c_param.len = len;
|
||||
fifo_clear(FIFO);
|
||||
if (device > 127) // Use I2C 10 bit address
|
||||
{
|
||||
fifo_put(FIFO, 0b11110 | ((device >> 5) & 6) | I2C_READ);
|
||||
fifo_put(FIFO, device & 255);
|
||||
}
|
||||
else
|
||||
fifo_put(FIFO, ((device << 1) & 0xFE) | I2C_READ);
|
||||
i2c_param.state = I2C_ADDR;
|
||||
}
|
||||
|
||||
int I2C_ioctl(unsigned int index, unsigned long val)
|
||||
{
|
||||
unsigned short len = val;
|
||||
uint8_t temp;
|
||||
|
||||
// Set device as slave or
|
||||
switch (index)
|
||||
{
|
||||
case I2CTLINIT: // make me master
|
||||
/* set the frequency near 400KHz */
|
||||
MCF_I2C_I2FDR = MCF_I2C_I2FDR_IC(0x10);
|
||||
/* start the module */
|
||||
MCF_I2C_I2CR = MCF_I2C_I2CR_IIEN | MCF_I2C_I2CR_IEN;
|
||||
/* if bit busy set, send a stop condition to slave module */
|
||||
if (MCF_I2C_I2SR & MCF_I2C_I2SR_IBB)
|
||||
{
|
||||
MCF_I2C_I2CR = 0; /* clear control register */
|
||||
MCF_I2C_I2CR = MCF_I2C_I2CR_IIEN | MCF_I2C_I2CR_IEN
|
||||
| MCF_I2C_I2CR_MSTA; /* enable module & send a START condition */
|
||||
temp = MCF_I2C_I2DR; /* dummy read */
|
||||
MCF_I2C_I2SR = 0; /* clear status register */
|
||||
MCF_I2C_I2CR = 0; /* clear control register */
|
||||
MCF_I2C_I2CR = MCF_I2C_I2CR_IIEN | MCF_I2C_I2CR_IEN; /* enable the module again */
|
||||
}
|
||||
i2c_param.state = I2C_READY;
|
||||
i2c_param._buf = 0;
|
||||
break;
|
||||
case I2CTLSBUF:
|
||||
i2c_param._buf = (unsigned char *) val;
|
||||
break;
|
||||
case I2CTLDEV:
|
||||
i2c_param.device = val;
|
||||
break;
|
||||
case I2CTLREAD:
|
||||
if (i2c_param._buf == 0 || i2c_param.device == 0)
|
||||
return -1;
|
||||
I2C_receive(i2c_param.device, i2c_param._buf, len);
|
||||
break;
|
||||
case I2CTLWRITE:
|
||||
if (i2c_param._buf == 0 || i2c_param.device == 0)
|
||||
return -1;
|
||||
I2C_send(i2c_param.device, i2c_param._buf, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
70
sources/interrupts.c
Normal file
70
sources/interrupts.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Interrupts
|
||||
*
|
||||
* Handle interrupts, the levels.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <i2c_firebee.h>
|
||||
|
||||
#include <MCF5475.h>
|
||||
|
||||
int
|
||||
register_handler(uint8_t priority, uint8_t intr, void (*func)())
|
||||
{
|
||||
int i;
|
||||
uint8_t level = 0b01111111;
|
||||
uint32_t *adr = MBAR_ADDRESS;
|
||||
uint8_t ol = 0,op = 0;
|
||||
|
||||
intr &= 63;
|
||||
priority &= 7;
|
||||
|
||||
if( intr <= 0 )
|
||||
return -1;
|
||||
|
||||
for(i=1;i<64;i++)
|
||||
if( i!=intr )
|
||||
{
|
||||
if( MCF_INTC_ICR(i)&7 == priority )
|
||||
clear_bit_nr(level,(MCF_INTC_ICR(i)>>3)&7);
|
||||
}
|
||||
|
||||
for(i=0;1<7;i++)
|
||||
if( level&(1<<i) )
|
||||
break;
|
||||
|
||||
if( i>=7 )
|
||||
return -1;
|
||||
|
||||
// Make sure priority level is high, before changing registers
|
||||
__asm__ volatile (
|
||||
"move.w sr,d0\n\t" \
|
||||
"move.w d0,-(sp) \n\t" \
|
||||
"move.w #0x2700,sr\n\t" \
|
||||
: \
|
||||
: \
|
||||
: "sp","d0","memory" \
|
||||
);
|
||||
|
||||
if( intr < 32 )
|
||||
clear_bit(MCF_INTC_IMRL,(1<<intr));
|
||||
else
|
||||
clear_bit(MCF_INTC_IMRH,(1<<(intr-32)));
|
||||
|
||||
MCF_INTC_ICR(intr) = MCF_INTC_ICR_IP(priority)|MCF_INTC_ICR_IL(i);
|
||||
adr[intr*4] = func;
|
||||
|
||||
// Return the saved priority level
|
||||
__asm__ volatile (
|
||||
"move.w (sp)+,d2\n\t" \
|
||||
"move.w d2,sr\n\t"
|
||||
: \
|
||||
: \
|
||||
: "sp","d2","memory" \
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -26,9 +26,9 @@
|
||||
#define CS_LOW() { dspi_fifo_val |= MCF_DSPI_DTFR_CS5; }
|
||||
|
||||
#define SPICLK_FAST() { MCF_DSPI_DCTAR0 = MCF_DSPI_DCTAR_TRSZ(0b111) | /* transfer size = 8 bit */ \
|
||||
MCF_DSPI_DCTAR_PCSSCK(0b01) | /* 1 clock DSPICS to DSPISCK delay prescaler */ \
|
||||
MCF_DSPI_DCTAR_PASC_1CLK | /* 1 clock DSPISCK to DSPICS negation prescaler */ \
|
||||
MCF_DSPI_DCTAR_PDT_1CLK | /* 1 clock delay between DSPICS assertions prescaler */ \
|
||||
MCF_DSPI_DCTAR_PCSSCK(0b11) | /* 1 clock DSPICS to DSPISCK delay prescaler */ \
|
||||
MCF_DSPI_DCTAR_PASC_3CLK | /* 1 clock DSPISCK to DSPICS negation prescaler */ \
|
||||
MCF_DSPI_DCTAR_PDT_3CLK | /* 1 clock delay between DSPICS assertions prescaler */ \
|
||||
MCF_DSPI_DCTAR_PBR_3CLK | /* 3 clock Baudrate prescaler */ \
|
||||
MCF_DSPI_DCTAR_ASC(0b0000) | /* 2 */ \
|
||||
MCF_DSPI_DCTAR_DT(0b0000) | /* 2 */ \
|
||||
@@ -249,7 +249,7 @@ int rcvr_datablock ( /* 1:OK, 0:Error */
|
||||
)
|
||||
{
|
||||
uint8_t token;
|
||||
uint32_t target = MCF_SLT_SCNT(0) - (200 * 1000L * 132);
|
||||
uint32_t target = MCF_SLT_SCNT(0) - (400 * 1000L * 132);
|
||||
|
||||
do { /* Wait for DataStart token in timeout of 200ms */
|
||||
token = xchg_spi(0xFF);
|
||||
|
||||
2115
sources/ohci-hcd.c
Normal file
2115
sources/ohci-hcd.c
Normal file
File diff suppressed because it is too large
Load Diff
1684
sources/usb.c
Normal file
1684
sources/usb.c
Normal file
File diff suppressed because it is too large
Load Diff
1332
sources/usb_kbd.c
Normal file
1332
sources/usb_kbd.c
Normal file
File diff suppressed because it is too large
Load Diff
272
sources/usb_mem.c
Normal file
272
sources/usb_mem.c
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* usb_mem.c
|
||||
*
|
||||
* based from Emutos / BDOS
|
||||
*
|
||||
* Copyright (c) 2001 Lineo, Inc.
|
||||
*
|
||||
* Authors: Karl T. Braun, Martin Doering, Laurent Vogel
|
||||
*
|
||||
* This file is distributed under the GPL, version 2 or at your
|
||||
* option any later version.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include "usb.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#undef USB_MEM_DEBUG
|
||||
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined(CONFIG_USB_EHCI)
|
||||
|
||||
#ifdef USB_MEM_DEBUG
|
||||
#define USB_MEM_PRINTF(fmt,args...) board_printf(fmt ,##args)
|
||||
#else
|
||||
#define USB_MEM_PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_MEM_NO_CACHE
|
||||
|
||||
extern char __NO_CACHE_MEMORY_BASE[];
|
||||
extern char __NO_CACHE_MEMORY_SIZE[];
|
||||
|
||||
#endif /* CONFIG_USB_MEM_NO_CACHE */
|
||||
|
||||
static void *usb_buffer;
|
||||
extern int asm_set_ipl(int level);
|
||||
extern void *info_fvdi;
|
||||
extern long offscren_reserved(void);
|
||||
|
||||
/* MD - Memory Descriptor */
|
||||
|
||||
#define MD struct _md_
|
||||
|
||||
MD
|
||||
{
|
||||
MD *m_link;
|
||||
long m_start;
|
||||
long m_length;
|
||||
};
|
||||
|
||||
/* MPB - Memory Partition Block */
|
||||
|
||||
#define MPB struct _mpb
|
||||
|
||||
MPB
|
||||
{
|
||||
MD *mp_mfl;
|
||||
MD *mp_mal;
|
||||
MD *mp_rover;
|
||||
};
|
||||
|
||||
#define MAXMD 100
|
||||
|
||||
static int count_md;
|
||||
static MD tab_md[MAXMD];
|
||||
static MPB pmd;
|
||||
|
||||
static MD *ffit(long amount, MPB *mp)
|
||||
{
|
||||
MD *p,*q,*p1; /* free list is composed of MD's */
|
||||
int maxflg;
|
||||
long maxval;
|
||||
if(amount != -1)
|
||||
{
|
||||
amount += 15; /* 16 bytes alignment */
|
||||
amount &= 0xFFFFFFF0;
|
||||
}
|
||||
if((q = mp->mp_rover) == 0) /* get rotating pointer */
|
||||
return(0) ;
|
||||
maxval = 0;
|
||||
maxflg = (amount == -1 ? TRUE : FALSE) ;
|
||||
p = q->m_link; /* start with next MD */
|
||||
do /* search the list for an MD with enough space */
|
||||
{
|
||||
if(p == 0)
|
||||
{
|
||||
/* at end of list, wrap back to start */
|
||||
q = (MD *) &mp->mp_mfl; /* q => mfl field */
|
||||
p = q->m_link; /* p => 1st MD */
|
||||
}
|
||||
if((!maxflg) && (p->m_length >= amount))
|
||||
{
|
||||
/* big enough */
|
||||
if(p->m_length == amount)
|
||||
q->m_link = p->m_link; /* take the whole thing */
|
||||
else
|
||||
{
|
||||
/* break it up - 1st allocate a new
|
||||
MD to describe the remainder */
|
||||
if(count_md >= MAXMD)
|
||||
return(0);
|
||||
p1 = &tab_md[count_md++];
|
||||
/* init new MD */
|
||||
p1->m_length = p->m_length - amount;
|
||||
p1->m_start = p->m_start + amount;
|
||||
p1->m_link = p->m_link;
|
||||
p->m_length = amount; /* adjust allocated block */
|
||||
q->m_link = p1;
|
||||
}
|
||||
/* link allocate block into allocated list,
|
||||
mark owner of block, & adjust rover */
|
||||
p->m_link = mp->mp_mal;
|
||||
mp->mp_mal = p;
|
||||
mp->mp_rover = (q == (MD *) &mp->mp_mfl ? q->m_link : q);
|
||||
return(p); /* got some */
|
||||
}
|
||||
else if(p->m_length > maxval)
|
||||
maxval = p->m_length;
|
||||
p = ( q=p )->m_link;
|
||||
}
|
||||
while(q != mp->mp_rover);
|
||||
/* return either the max, or 0 (error) */
|
||||
if(maxflg)
|
||||
{
|
||||
maxval -= 15; /* 16 bytes alignment */
|
||||
if(maxval < 0)
|
||||
maxval = 0;
|
||||
else
|
||||
maxval &= 0xFFFFFFF0;
|
||||
}
|
||||
return(maxflg ? (MD *) maxval : 0);
|
||||
}
|
||||
|
||||
static void freeit(MD *m, MPB *mp)
|
||||
{
|
||||
MD *p, *q;
|
||||
q = 0;
|
||||
for(p = mp->mp_mfl; p ; p = (q=p) -> m_link)
|
||||
{
|
||||
if(m->m_start <= p->m_start)
|
||||
break;
|
||||
}
|
||||
m->m_link = p;
|
||||
if(q)
|
||||
q->m_link = m;
|
||||
else
|
||||
mp->mp_mfl = m;
|
||||
if(!mp->mp_rover)
|
||||
mp->mp_rover = m;
|
||||
if(p)
|
||||
{
|
||||
if(m->m_start + m->m_length == p->m_start)
|
||||
{ /* join to higher neighbor */
|
||||
m->m_length += p->m_length;
|
||||
m->m_link = p->m_link;
|
||||
if(p == mp->mp_rover)
|
||||
mp->mp_rover = m;
|
||||
if(count_md>=0)
|
||||
count_md--;
|
||||
}
|
||||
}
|
||||
if(q)
|
||||
{
|
||||
if(q->m_start + q->m_length == m->m_start)
|
||||
{ /* join to lower neighbor */
|
||||
q->m_length += m->m_length;
|
||||
q->m_link = m->m_link;
|
||||
if(m == mp->mp_rover)
|
||||
mp->mp_rover = q;
|
||||
if(count_md>=0)
|
||||
count_md--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define EFAULT -40
|
||||
|
||||
int usb_free(void *addr)
|
||||
{
|
||||
int level;
|
||||
MD *p, **q;
|
||||
MPB *mpb;
|
||||
mpb = &pmd;
|
||||
if(usb_buffer == NULL)
|
||||
return(EFAULT);
|
||||
level = asm_set_ipl(7);
|
||||
for(p = *(q = &mpb->mp_mal); p; p = *(q = &p->m_link))
|
||||
{
|
||||
if((long)addr == p->m_start)
|
||||
break;
|
||||
}
|
||||
if(!p)
|
||||
{
|
||||
asm_set_ipl(level);
|
||||
return(EFAULT);
|
||||
}
|
||||
*q = p->m_link;
|
||||
freeit(p, mpb);
|
||||
asm_set_ipl(level);
|
||||
USB_MEM_PRINTF("usb_free(0x%08X)\r\n", addr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void *usb_malloc(long amount)
|
||||
{
|
||||
int level;
|
||||
MD *m;
|
||||
if(usb_buffer == NULL)
|
||||
return(NULL);
|
||||
if(amount == -1L)
|
||||
return((void *)ffit(-1L,&pmd));
|
||||
if(amount <= 0 )
|
||||
return(0);
|
||||
if((amount & 1))
|
||||
amount++;
|
||||
level = asm_set_ipl(7);
|
||||
m = ffit(amount, &pmd);
|
||||
asm_set_ipl(level);
|
||||
USB_MEM_PRINTF("usb_malloc(%d) = 0x%08X\r\n", amount, (m == NULL) ? 0 : m->m_start);
|
||||
if(m == NULL)
|
||||
return(NULL);
|
||||
return((void *)m->m_start);
|
||||
}
|
||||
|
||||
int usb_mem_init(void)
|
||||
{
|
||||
if(usb_buffer != NULL)
|
||||
return(0);
|
||||
#ifdef CONFIG_USB_MEM_NO_CACHE
|
||||
pmd.mp_mfl = pmd.mp_rover = &tab_md[0];
|
||||
tab_md[0].m_link = (MD *)NULL;
|
||||
usb_buffer = (void *)__NO_CACHE_MEMORY_BASE;
|
||||
tab_md[0].m_start = (long)usb_buffer;
|
||||
tab_md[0].m_length = (long)__NO_CACHE_MEMORY_SIZE;
|
||||
#else /* !CONFIG_USB_MEM_NO_CACHE */
|
||||
#if 0
|
||||
usb_buffer = (void *)offscren_reserved();
|
||||
if(usb_buffer == NULL)
|
||||
#endif
|
||||
usb_buffer = (void *)Mxalloc(USB_BUFFER_SIZE + 16, 0); /* STRAM - cache in writethough */
|
||||
if(usb_buffer == NULL)
|
||||
return(-1);
|
||||
pmd.mp_mfl = pmd.mp_rover = &tab_md[0];
|
||||
tab_md[0].m_link = (MD *)NULL;
|
||||
tab_md[0].m_start = ((long)usb_buffer + 15) & ~15;
|
||||
tab_md[0].m_length = USB_BUFFER_SIZE;
|
||||
#endif /* CONFIG_USB_MEM_NO_CACHE */
|
||||
pmd.mp_mal = (MD *)NULL;
|
||||
memset(usb_buffer, 0, tab_md[0].m_length);
|
||||
USB_MEM_PRINTF("USB malloc buffer at 0x%08X size %d\r\n", tab_md[0].m_start, tab_md[0].m_length);
|
||||
count_md = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
void usb_mem_stop(void)
|
||||
{
|
||||
#ifndef CONFIG_USB_MEM_NO_CACHE
|
||||
if(usb_buffer != NULL)
|
||||
Mfree(usb_buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USB_UHCI || CONFIG_USB_OHCI || CONFIG_USB_EHCI */
|
||||
|
||||
|
||||
244
sources/usb_mouse.c
Normal file
244
sources/usb_mouse.c
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* 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 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 "config.h"
|
||||
#include "usb.h"
|
||||
|
||||
#undef USB_MOUSE_DEBUG
|
||||
|
||||
#if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || defined(CONFIG_USB_EHCI)
|
||||
#ifdef CONFIG_USB_MOUSE
|
||||
|
||||
#ifdef USB_MOUSE_DEBUG
|
||||
#define USB_MOUSE_PRINTF(fmt,args...) board_printf(fmt ,##args)
|
||||
#else
|
||||
#define USB_MOUSE_PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
extern void ltoa(char *buf, long n, unsigned long base);
|
||||
extern void call_mousevec(unsigned char *data, void (**mousevec)(void *));
|
||||
extern void call_ikbdvec(unsigned char code, _IOREC *iorec, void (**ikbdvec)());
|
||||
extern int asm_set_ipl(int level);
|
||||
|
||||
static unsigned char *new;
|
||||
static unsigned char old[8];
|
||||
static int mouse_installed;
|
||||
|
||||
extern void (**mousevec)(void *);
|
||||
extern _IOREC *iorec;
|
||||
extern void (**ikbdvec)();
|
||||
|
||||
/* forward declaration */
|
||||
static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum);
|
||||
|
||||
/* deregistering the mouse */
|
||||
int usb_mouse_deregister(struct usb_device *dev)
|
||||
{
|
||||
dev->irq_handle = NULL;
|
||||
if(new != NULL)
|
||||
{
|
||||
usb_free(new);
|
||||
new = NULL;
|
||||
}
|
||||
mouse_installed = 0;
|
||||
USB_MOUSE_PRINTF("USB MOUSE deregister\r\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* registering the mouse */
|
||||
int usb_mouse_register(struct usb_device *dev)
|
||||
{
|
||||
if(!mouse_installed && (dev->devnum != -1) && (usb_mouse_probe(dev, 0) == 1))
|
||||
{ /* Ok, we found a mouse */
|
||||
USB_MOUSE_PRINTF("USB MOUSE found (USB: %d, devnum: %d)\r\n", dev->usbnum, dev->devnum);
|
||||
mouse_installed = 1;
|
||||
dev->deregister = usb_mouse_deregister;
|
||||
return 1;
|
||||
}
|
||||
/* no USB Mouse found */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* search for mouse and register it if found */
|
||||
int drv_usb_mouse_init(void)
|
||||
{
|
||||
int i, j;
|
||||
if(mouse_installed)
|
||||
return -1;
|
||||
/* scan all USB Devices */
|
||||
for(j = 0; j < USB_MAX_BUS; j++)
|
||||
{
|
||||
for(i = 0; i < USB_MAX_DEVICE; i++)
|
||||
{
|
||||
struct usb_device *dev = usb_get_dev_index(i, j); /* get device */
|
||||
if(dev == NULL)
|
||||
break;
|
||||
if(usb_mouse_register(dev) > 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* no USB Mouse found */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Low Level drivers
|
||||
*/
|
||||
static void usb_kbd_send_code(unsigned char code)
|
||||
{
|
||||
if((iorec != NULL) && (ikbdvec != NULL))
|
||||
call_ikbdvec(code, iorec, ikbdvec);
|
||||
}
|
||||
|
||||
/* Interrupt service routine */
|
||||
static int usb_mouse_irq(struct usb_device *dev)
|
||||
{
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
int level;
|
||||
#endif
|
||||
int i, change = 0;
|
||||
if((dev->irq_status != 0) || (dev->irq_act_len < 3) || (dev->irq_act_len > 8))
|
||||
{
|
||||
USB_MOUSE_PRINTF("USB MOUSE error %lX, len %d\r\n", dev->irq_status, dev->irq_act_len);
|
||||
return 1;
|
||||
}
|
||||
for(i = 0; i < dev->irq_act_len; i++)
|
||||
{
|
||||
if(new[i] != old[i])
|
||||
{
|
||||
change = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(change)
|
||||
{
|
||||
char wheel = 0, buttons, old_buttons;
|
||||
USB_MOUSE_PRINTF("USB MOUSE len:%d %02X %02X %02X %02X %02X %02X\r\n", dev->irq_act_len, new[0], new[1], new[2], new[3], new[4], new[5]);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
level = asm_set_ipl(7); /* mask interrupts */
|
||||
#endif
|
||||
if((dev->irq_act_len >= 6) && (new[0] == 1)) /* report-ID */
|
||||
{
|
||||
buttons = new[1];
|
||||
old_buttons = old[1];
|
||||
new[0] = ((new[1] & 1) << 1) + ((new[1] & 2) >> 1) + 0xF8;
|
||||
new[1] = new[2];
|
||||
new[2] = new[3];
|
||||
wheel = new[4];
|
||||
}
|
||||
else /* boot report */
|
||||
{
|
||||
buttons = new[0];
|
||||
old_buttons = old[0];
|
||||
new[0] = ((new[0] & 1) << 1) + ((new[0] & 2) >> 1) + 0xF8;
|
||||
if(dev->irq_act_len >= 3)
|
||||
wheel = new[3];
|
||||
}
|
||||
if((buttons ^ old_buttons) & 4) /* 3rd button */
|
||||
{
|
||||
if(buttons & 4)
|
||||
{
|
||||
usb_kbd_send_code(0x72); /* ENTER */
|
||||
usb_kbd_send_code(0xF2);
|
||||
}
|
||||
}
|
||||
if(wheel != 0) /* actually like Eiffel */
|
||||
{
|
||||
#define REPEAT_WHEEL 3
|
||||
int i;
|
||||
if(wheel > 0)
|
||||
{
|
||||
for(i = 0; i < REPEAT_WHEEL; i++)
|
||||
{
|
||||
usb_kbd_send_code(0x48); /* UP */
|
||||
usb_kbd_send_code(0xC8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = 0; i < REPEAT_WHEEL; i++)
|
||||
{
|
||||
usb_kbd_send_code(0x50); /* DOWN */
|
||||
usb_kbd_send_code(0xD0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mousevec != NULL)
|
||||
call_mousevec(new, mousevec);
|
||||
#ifdef CONFIG_USB_INTERRUPT_POLLING
|
||||
asm_set_ipl(level);
|
||||
#endif
|
||||
old[0] = new[0];
|
||||
old[1] = new[1];
|
||||
old[2] = new[2];
|
||||
old[3] = new[3];
|
||||
old[4] = new[4];
|
||||
old[5] = new[5];
|
||||
}
|
||||
return 1; /* install IRQ Handler again */
|
||||
}
|
||||
|
||||
/* probes the USB device dev for mouse type */
|
||||
static int usb_mouse_probe(struct usb_device *dev, unsigned int ifnum)
|
||||
{
|
||||
struct usb_interface_descriptor *iface;
|
||||
struct usb_endpoint_descriptor *ep;
|
||||
int pipe, maxp;
|
||||
if(dev->descriptor.bNumConfigurations != 1)
|
||||
return 0;
|
||||
iface = &dev->config.if_desc[ifnum];
|
||||
if(iface->bInterfaceClass != 3)
|
||||
return 0;
|
||||
if(iface->bInterfaceSubClass != 1)
|
||||
return 0;
|
||||
if(iface->bInterfaceProtocol != 2)
|
||||
return 0;
|
||||
if(iface->bNumEndpoints != 1)
|
||||
return 0;
|
||||
ep = &iface->ep_desc[0];
|
||||
if(!(ep->bEndpointAddress & 0x80))
|
||||
return 0;
|
||||
if((ep->bmAttributes & 3) != 3)
|
||||
return 0;
|
||||
new = (unsigned char *)usb_malloc(8);
|
||||
if(new == NULL)
|
||||
return 0;
|
||||
USB_MOUSE_PRINTF("USB MOUSE found set protocol...\r\n");
|
||||
/* ok, we found a USB Mouse, install it */
|
||||
pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
|
||||
maxp = usb_maxpacket(dev, pipe);
|
||||
// if(maxp < 6)
|
||||
// usb_set_protocol(dev, iface->bInterfaceNumber, 0); /* boot */
|
||||
// else
|
||||
usb_set_protocol(dev, iface->bInterfaceNumber, 1); /* report */
|
||||
USB_MOUSE_PRINTF("USB MOUSE found set idle...\r\n");
|
||||
usb_set_idle(dev, iface->bInterfaceNumber, 0, 0); /* report infinite */
|
||||
memset(&new[0], 0, 8);
|
||||
memset(&old[0], 0, 8);
|
||||
dev->irq_handle = usb_mouse_irq;
|
||||
USB_MOUSE_PRINTF("USB MOUSE enable interrupt pipe (maxp: %d)...\r\n", maxp);
|
||||
usb_submit_int_msg(dev, pipe, &new[0], maxp > 8 ? 8 : maxp, ep->bInterval);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USB_MOUSE */
|
||||
#endif /* CONFIG_USB_UHCI || CONFIG_USB_OHCI || CONFIG_USB_EHCI */
|
||||
1669
sources/usb_storage.c
Normal file
1669
sources/usb_storage.c
Normal file
File diff suppressed because it is too large
Load Diff
314
sources/xhdi_interface.c
Normal file
314
sources/xhdi_interface.c
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* xhdi_sd.c
|
||||
*
|
||||
* This file is part of BaS_gcc.
|
||||
*
|
||||
* BaS_gcc 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* BaS_gcc 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with BaS_gcc. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Created on: 01.05.2013
|
||||
* Copyright 2012: M. Fröschle
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "xhdi_sd.h"
|
||||
#include "bas_printf.h"
|
||||
|
||||
|
||||
unsigned long xhdi_call(uint16_t *stack)
|
||||
{
|
||||
uint16_t opcode = *stack;
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case XHDI_VERSION:
|
||||
return xhdi_version();
|
||||
break;
|
||||
|
||||
case XHDI_INQUIRE_TARGET:
|
||||
{
|
||||
struct XHINQTARGET_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint32_t *blocksize;
|
||||
uint32_t *deviceflags;
|
||||
char *productname;
|
||||
} *args = (struct XHINQTARGET_args *) stack;
|
||||
|
||||
return xhdi_inquire_target(args->major, args->minor, args->blocksize,
|
||||
args->deviceflags, args->productname);
|
||||
}
|
||||
break;
|
||||
|
||||
case XHDI_RESERVE:
|
||||
{
|
||||
struct XHRESERVE_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t do_reserve;
|
||||
uint16_t key;
|
||||
} *args = (struct XHRESERVE_args *) stack;
|
||||
|
||||
return xhdi_reserve(args->major, args->minor, args->do_reserve, args->key);
|
||||
}
|
||||
|
||||
case XHDI_LOCK:
|
||||
{
|
||||
struct XHLOCK_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t do_lock;
|
||||
uint16_t key;
|
||||
} *args = (struct XHLOCK_args *) stack;
|
||||
|
||||
return xhdi_lock(args->major, args->minor, args->do_lock, args->key);
|
||||
}
|
||||
|
||||
case XHDI_STOP:
|
||||
{
|
||||
struct XHSTOP_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t do_stop;
|
||||
uint16_t key;
|
||||
} *args = (struct XHSTOP_args *) stack;
|
||||
|
||||
return xhdi_stop(args->major, args->minor, args->do_stop, args->key);
|
||||
}
|
||||
|
||||
case XHDI_EJECT:
|
||||
{
|
||||
struct XHEJECT_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t do_eject;
|
||||
uint16_t key;
|
||||
} *args = (struct XHEJECT_args *) stack;
|
||||
|
||||
return xhdi_eject(args->major, args->minor, args->do_eject, args->key);
|
||||
}
|
||||
|
||||
case XHDI_DRIVEMAP:
|
||||
{
|
||||
return xhdi_drivemap();
|
||||
}
|
||||
|
||||
case XHDI_INQUIRE_DEVICE:
|
||||
{
|
||||
struct XHINQDEV_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t drv;
|
||||
uint16_t *major;
|
||||
uint16_t *minor;
|
||||
uint32_t *start;
|
||||
BPB *bpb;
|
||||
} *args = (struct XHINQDEV_args *) stack;
|
||||
|
||||
return xhdi_inquire_device(args->drv, args->major, args->minor, args->start,
|
||||
args->bpb);
|
||||
}
|
||||
|
||||
case XHDI_INQUIRE_DRIVER:
|
||||
{
|
||||
struct XHINQDRIVER_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t dev;
|
||||
char *name;
|
||||
char *version;
|
||||
char *company;
|
||||
uint16_t *ahdi_version;
|
||||
uint16_t *maxIPL;
|
||||
} *args = (struct XHINQDRIVER_args *) stack;
|
||||
|
||||
return xhdi_inquire_driver(args->dev, args->name, args->version, args->company,
|
||||
args->ahdi_version, args->maxIPL);
|
||||
}
|
||||
|
||||
case XHDI_NEW_COOKIE:
|
||||
{
|
||||
struct XHNEWCOOKIE_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint32_t newcookie;
|
||||
} *args = (struct XHNEWCOOKIE_args *) stack;
|
||||
|
||||
return xhdi_new_cookie(args->newcookie);
|
||||
}
|
||||
|
||||
case XHDI_READ_WRITE:
|
||||
{
|
||||
struct XHREADWRITE_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t rw;
|
||||
uint32_t sector;
|
||||
uint16_t count;
|
||||
void *buf;
|
||||
} *args = (struct XHREADWRITE_args *) stack;
|
||||
|
||||
return xhdi_read_write(args->major, args->minor,
|
||||
args->rw, args->sector,
|
||||
args->count, args->buf);
|
||||
}
|
||||
|
||||
case XHDI_INQUIRE_TARGET2:
|
||||
{
|
||||
struct XHINQTARGET2_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint32_t *blocksize;
|
||||
uint32_t *deviceflags;
|
||||
char *productname;
|
||||
uint16_t stringlen;
|
||||
} *args = (struct XHINQTARGET2_args *) stack;
|
||||
|
||||
return xhdi_inquire_target2(args->major, args->minor, args->blocksize,
|
||||
args->deviceflags, args->productname, args->stringlen);
|
||||
}
|
||||
|
||||
case XHDI_INQUIRE_DEVICE2:
|
||||
{
|
||||
struct XHINQDEV2_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t drv;
|
||||
uint16_t *major;
|
||||
uint16_t *minor;
|
||||
uint32_t *start;
|
||||
BPB *bpb;
|
||||
uint32_t *blocks;
|
||||
char *partid;
|
||||
} *args = (struct XHINQDEV2_args *) stack;
|
||||
|
||||
return xhdi_inquire_device2(args->drv, args->major, args->minor, args->start,
|
||||
args->bpb, args->blocks, args->partid);
|
||||
}
|
||||
|
||||
case XHDI_DRIVER_SPECIAL:
|
||||
{
|
||||
struct XHDRIVERSPECIAL_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint32_t key1;
|
||||
uint32_t key2;
|
||||
uint16_t subopcode;
|
||||
void *data;
|
||||
} *args = (struct XHDRIVERSPECIAL_args *) stack;
|
||||
|
||||
return xhdi_driver_special(args->key1, args->key2, args->subopcode,
|
||||
args->data);
|
||||
}
|
||||
|
||||
case XHDI_GET_CAPACITY:
|
||||
{
|
||||
struct XHGETCAPACITY_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint32_t *blocks;
|
||||
uint32_t *blocksize;
|
||||
} *args = (struct XHGETCAPACITY_args *) stack;
|
||||
|
||||
return xhdi_get_capacity(args->major, args->minor, args->blocks,
|
||||
args->blocksize);
|
||||
}
|
||||
|
||||
case XHDI_MEDIUM_CHANGED:
|
||||
{
|
||||
struct XHMEDIUMCHANGED_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
} *args = (struct XHMEDIUMCHANGED_args *) stack;
|
||||
|
||||
return xhdi_medium_changed(args->major, args->minor);
|
||||
}
|
||||
|
||||
case XHDI_MINT_INFO:
|
||||
{
|
||||
struct XHMINTINFO_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t subopcode;
|
||||
void *data;
|
||||
} *args = (struct XHMINTINFO_args *) stack;
|
||||
|
||||
return xhdi_mint_info(args->subopcode, args->data);
|
||||
}
|
||||
|
||||
case XHDI_DOS_LIMITS:
|
||||
{
|
||||
struct XHDOSLIMITS_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t which;
|
||||
uint32_t limit;
|
||||
} *args = (struct XHDOSLIMITS_args *) stack;
|
||||
|
||||
return xhdi_dos_limits(args->which, args->limit);
|
||||
}
|
||||
|
||||
case XHDI_LAST_ACCESS:
|
||||
{
|
||||
struct XHLASTACCESS_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint32_t *ms;
|
||||
} *args = (struct XHLASTACCESS_args *) stack;
|
||||
|
||||
return xhdi_last_access(args->major, args->minor, args->ms);
|
||||
}
|
||||
|
||||
case XHDI_REACCESS:
|
||||
{
|
||||
struct XHREACCESS_args
|
||||
{
|
||||
uint16_t opcode;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
} *args = (struct XHREACCESS_args *) stack;
|
||||
|
||||
return xhdi_reaccess(args->major, args->minor);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
xprintf("unknown XHDI function 0x%x\r\n", opcode);
|
||||
return EINVFN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
215
sources/xhdi_sd.c
Normal file
215
sources/xhdi_sd.c
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* xhdi_sd.c
|
||||
*
|
||||
* This file is part of BaS_gcc.
|
||||
*
|
||||
* BaS_gcc 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* BaS_gcc 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with BaS_gcc. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Created on: 01.05.2013
|
||||
* Copyright 2012 M. Fröschle
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "xhdi_sd.h"
|
||||
#include "bas_printf.h"
|
||||
#include "bas_string.h"
|
||||
#include "diskio.h"
|
||||
|
||||
#define DRIVER_VERSION 0x130
|
||||
|
||||
#define MY_MAJOR 65
|
||||
#define MY_MINOR 0
|
||||
|
||||
uint16_t xhdi_version(void)
|
||||
{
|
||||
return DRIVER_VERSION;
|
||||
}
|
||||
|
||||
uint32_t xhdi_inquire_target(uint16_t major, uint16_t minor, uint32_t *block_size, uint32_t *flags,
|
||||
char *product_name)
|
||||
{
|
||||
return xhdi_inquire_target2(major, minor, block_size, flags, product_name, 33);
|
||||
}
|
||||
|
||||
uint32_t xhdi_reserve(uint16_t major, uint16_t minor, uint16_t do_reserve, uint16_t key)
|
||||
{
|
||||
return ERROR; /* device cannot be reserved */
|
||||
}
|
||||
|
||||
uint32_t xhdi_lock(uint16_t major, uint16_t minor, uint16_t do_lock, uint16_t key)
|
||||
{
|
||||
return ERROR; /* device cannot be locked */
|
||||
}
|
||||
|
||||
uint32_t xhdi_stop(uint16_t major, uint16_t minor, uint16_t do_stop, uint16_t key)
|
||||
{
|
||||
return ERROR; /* device cannot be locked */
|
||||
}
|
||||
|
||||
uint32_t xhdi_eject(uint16_t major, uint16_t minor, uint16_t do_eject, uint16_t key)
|
||||
{
|
||||
return ERROR; /* device cannot be ejected */
|
||||
}
|
||||
|
||||
uint32_t xhdi_drivemap(void)
|
||||
{
|
||||
long map = (1 << ('S' - 'A'));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
#define MY_MAJOR 65
|
||||
#define MY_MINOR 0
|
||||
|
||||
uint32_t xhdi_inquire_device(uint16_t bios_device, uint16_t *major, uint16_t *minor,
|
||||
uint32_t *start_sector, /* BPB */ void *bpb)
|
||||
{
|
||||
if (major != NULL) *major = MY_MAJOR;
|
||||
if (minor != NULL) *minor = MY_MINOR;
|
||||
if (start_sector != NULL) *start_sector = 0;
|
||||
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
uint32_t xhdi_inquire_driver(uint16_t bios_device, char *name, char *version,
|
||||
char *company, uint16_t *ahdi_version, uint16_t *maxIPL)
|
||||
{
|
||||
if (bios_device == 'S' - 'A')
|
||||
{
|
||||
if (name != NULL) strcpy(name, "BaS SD-card driver");
|
||||
if (version != NULL) strcpy(version, "0.1");
|
||||
if (company != NULL) strcpy(company, "Markus Fröschle");
|
||||
if (ahdi_version != NULL) *ahdi_version = 300;
|
||||
if (maxIPL != NULL) *maxIPL = 7;
|
||||
|
||||
return E_OK;
|
||||
}
|
||||
return EUNDEV;
|
||||
}
|
||||
|
||||
uint32_t xhdi_new_cookie(uint32_t newcookie)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_read_write(uint16_t major, uint16_t minor, uint16_t rwflag,
|
||||
uint32_t recno, uint16_t count, void *buf)
|
||||
{
|
||||
int ret;
|
||||
uint16_t num_sectors;
|
||||
int16_t s_count = count;
|
||||
uint16_t retries;
|
||||
const uint16_t max_retries = 5;
|
||||
|
||||
if (major == MY_MAJOR)
|
||||
{
|
||||
do {
|
||||
num_sectors = ((s_count > 1) ? 1 : s_count);
|
||||
|
||||
retries = 0;
|
||||
do {
|
||||
ret = ((rwflag & 1) ? disk_write(0, buf, recno, num_sectors) : disk_read(0, buf, recno, num_sectors));
|
||||
if (ret != RES_OK && retries > max_retries)
|
||||
{
|
||||
xprintf("error: %d\r\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
else if (ret != RES_OK)
|
||||
{
|
||||
retries++;
|
||||
continue;
|
||||
}
|
||||
} while (retries < max_retries && ret != RES_OK);
|
||||
|
||||
buf += num_sectors * 512;
|
||||
recno += num_sectors;
|
||||
s_count -= num_sectors;
|
||||
} while (s_count > 0);
|
||||
|
||||
return E_OK;
|
||||
}
|
||||
return EUNDEV;
|
||||
}
|
||||
|
||||
uint32_t xhdi_inquire_target2(uint16_t major, uint16_t minor, uint32_t *block_size,
|
||||
uint32_t *device_flags, char *product_name, uint16_t stringlen)
|
||||
{
|
||||
if (major == MY_MAJOR)
|
||||
{
|
||||
if (block_size != NULL) *block_size = 512;
|
||||
if (device_flags != NULL) *device_flags = XH_TARGET_REMOVABLE;
|
||||
if (product_name != NULL) strncpy(product_name, "BaS SD driver", stringlen);
|
||||
|
||||
return E_OK;
|
||||
|
||||
}
|
||||
return EUNDEV;
|
||||
}
|
||||
|
||||
uint32_t xhdi_inquire_device2(uint16_t bios_device, uint16_t *major, uint16_t *minor,
|
||||
uint32_t *start_sector, BPB *bpb, uint32_t *blocks, char *partid)
|
||||
{
|
||||
|
||||
if (bios_device == 'S' - 'A')
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
return EUNDEV;
|
||||
}
|
||||
|
||||
uint32_t xhdi_driver_special(uint32_t key1, uint32_t key2, uint16_t subopcode, void *data)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_get_capacity(uint16_t major, uint16_t minor, uint32_t *blocks, uint32_t *bs)
|
||||
{
|
||||
if (major == MY_MAJOR)
|
||||
{
|
||||
if (disk_ioctl(0, GET_SECTOR_COUNT, blocks) != RES_OK)
|
||||
return ERROR;
|
||||
if (disk_ioctl(0, GET_SECTOR_SIZE, bs) != RES_OK)
|
||||
return ERROR;
|
||||
*bs = 512;
|
||||
return E_OK;
|
||||
}
|
||||
return EUNDEV;
|
||||
}
|
||||
|
||||
uint32_t xhdi_medium_changed(uint16_t major, uint16_t minor)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_mint_info(uint16_t opcode, void *data)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_dos_limits(uint16_t which, uint32_t limit)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_last_access(uint16_t major, uint16_t minor, uint32_t *ms)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
uint32_t xhdi_reaccess(uint16_t major, uint16_t minor)
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
40
sources/xhdi_vec.S
Normal file
40
sources/xhdi_vec.S
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// XHDI entry point
|
||||
//
|
||||
.extern _xhdi_call
|
||||
|
||||
.globl _xhdi_vec
|
||||
.globl _xhdi_sd_install
|
||||
|
||||
//
|
||||
// this is where the XHDI cookie points to:
|
||||
//
|
||||
|
||||
.text
|
||||
_xhdi_vec:
|
||||
lea -12(sp),sp // save all used registers according to XHDI spec
|
||||
movem.l d1/a0-a1,(sp)
|
||||
|
||||
pea 16(sp) // forward address of parameters on stack
|
||||
jsr _xhdi_call // to internal routine
|
||||
addq.l #4,sp // correct stack
|
||||
|
||||
movem.l (sp),d1/a0-a1 // restore registers
|
||||
lea 12(sp),sp
|
||||
rts
|
||||
|
||||
.data
|
||||
_old_vector:
|
||||
.ds.l 1
|
||||
|
||||
.text
|
||||
|
||||
//
|
||||
// trap #0 handler to bring the address of the disk routines into TOS
|
||||
//
|
||||
_xhdi_sd_install:
|
||||
move.l 4(sp),d0 // address of the old XHDI vector
|
||||
move.l d0,_old_vector // save it - just in case we need it later
|
||||
move.l #_xhdi_vec,d0 // return our BaS vector to TOS
|
||||
move.l d0,a0 //
|
||||
rte
|
||||
Reference in New Issue
Block a user