Initial import for store (USB experimental project for mass storage)
This commit is contained in:
150
usb/store/host/aranym/aranym-hcd.c
Normal file
150
usb/store/host/aranym/aranym-hcd.c
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
NatFeat USB host chip emulator
|
||||
|
||||
ARAnyM (C) 2010 David Gálvez
|
||||
|
||||
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 ---*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mint/cookie.h>
|
||||
#include <mint/osbind.h>
|
||||
|
||||
#include "nf_ops.h"
|
||||
#include "usbhost_nfapi.h"
|
||||
#include "../../config.h"
|
||||
#include "../../asm-m68k/io.h"
|
||||
#include "../../usb.h"
|
||||
#include "../../debug.h"
|
||||
|
||||
/*--- Defines ---*/
|
||||
|
||||
#ifndef EINVFN
|
||||
#define EINVFN -32
|
||||
#endif
|
||||
|
||||
#ifndef DEV_CONSOLE
|
||||
#define DEV_CONSOLE 2
|
||||
#endif
|
||||
|
||||
#define DRIVER_NAME "ARAnyM USB host chip emulator"
|
||||
#define VERSION "v0.1"
|
||||
|
||||
|
||||
/*--- Functions prototypes ---*/
|
||||
|
||||
static void press_any_key(void);
|
||||
|
||||
|
||||
/*--- Local variables ---*/
|
||||
|
||||
static struct nf_ops *nfOps;
|
||||
static unsigned long nfUsbHostId;
|
||||
|
||||
|
||||
/*--- Functions ---*/
|
||||
|
||||
|
||||
static void press_any_key(void)
|
||||
{
|
||||
|
||||
(void) Cconws("- Press any key to continue -\r\n");
|
||||
while (Bconstat(DEV_CONSOLE) == 0) { };
|
||||
}
|
||||
|
||||
|
||||
/* --- Transfer functions -------------------------------------------------- */
|
||||
|
||||
int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int len, int interval)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = nfOps->call(USBHOST(USBHOST_SUBMIT_INT_MSG), dev, pipe, buffer, len, interval);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int len, struct devrequest *setup)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = nfOps->call(USBHOST(USBHOST_SUBMIT_CONTROL_MSG), dev, pipe, buffer, len, setup);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
||||
int len)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = nfOps->call(USBHOST(USBHOST_SUBMIT_BULK_MSG), dev, pipe, buffer, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --- Init functions ------------------------------------------------------ */
|
||||
|
||||
int usb_lowlevel_init(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
(void) Cconws(
|
||||
"\033p " DRIVER_NAME " " VERSION " \033q\r\n"
|
||||
"Copyright (c) ARAnyM Development Team, " __DATE__ "\r\n"
|
||||
);
|
||||
|
||||
nfOps = nf_init();
|
||||
if (!nfOps) {
|
||||
(void) Cconws("__NF cookie not present on this system\r\n");
|
||||
press_any_key();
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfUsbHostId=nfOps->get_id("USBHOST");
|
||||
if (nfUsbHostId == 0) {
|
||||
(void) Cconws("NF USBHOST functions not present on this system\r\n");
|
||||
press_any_key();
|
||||
}
|
||||
|
||||
/* List present devices */
|
||||
|
||||
r = nfOps->call(USBHOST(USBHOST_LOWLEVEL_INIT));
|
||||
|
||||
if (!r)
|
||||
(void) Cconws(" USB Init \r\n");
|
||||
else
|
||||
(void) Cconws(" Couldn't init aranym host chip emulator \r\n");
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int usb_lowlevel_stop(void)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = nfOps->call(USBHOST(USBHOST_LOWLEVEL_STOP));
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
118
usb/store/host/aranym/natfeat.c
Normal file
118
usb/store/host/aranym/natfeat.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* ARAnyM native features interface.
|
||||
* (c) 2005-2008 ARAnyM development team
|
||||
*
|
||||
* In 2006 updated with FreeMiNT headers and code.
|
||||
* In 2008 converted from "__NF" cookie to direct usage of NF instructions
|
||||
*
|
||||
**/
|
||||
|
||||
/*
|
||||
* Copied from FreeMiNT source tree where Native Features were added recently
|
||||
*
|
||||
* Copyright 2003 Frank Naumann <fnaumann@freemint.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*
|
||||
* Author: Frank Naumann <fnaumann@freemint.de>
|
||||
* Started: 2003-12-13
|
||||
*
|
||||
*/
|
||||
|
||||
# include <compiler.h>
|
||||
# include <mint/osbind.h>
|
||||
# include "nf_ops.h"
|
||||
|
||||
|
||||
#define ARANYM 1
|
||||
# ifdef ARANYM
|
||||
|
||||
|
||||
static unsigned long nf_get_id_instr = 0x73004e75UL;
|
||||
static unsigned long nf_call_instr = 0x73014e75UL;
|
||||
|
||||
static struct nf_ops _nf_ops = { (void*)&nf_get_id_instr, (void*)&nf_call_instr };
|
||||
static struct nf_ops *nf_ops = 0UL;
|
||||
|
||||
extern int detect_native_features(void);
|
||||
|
||||
struct nf_ops *
|
||||
nf_init(void)
|
||||
{
|
||||
if (Supexec(detect_native_features))
|
||||
{
|
||||
nf_ops = &_nf_ops;
|
||||
return nf_ops;
|
||||
}
|
||||
|
||||
return 0UL;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
nf_name(void)
|
||||
{
|
||||
static char buf[64] = "Unknown emulator";
|
||||
|
||||
if (nf_ops)
|
||||
{
|
||||
static int done = 0;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
long nfid_name = nf_ops->get_id("NF_NAME");
|
||||
|
||||
if (nfid_name)
|
||||
nf_ops->call(nfid_name, buf, sizeof(buf));
|
||||
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
nf_debug(const char *msg)
|
||||
{
|
||||
if (nf_ops)
|
||||
{
|
||||
long nfid_stderr = nf_ops->get_id("NF_STDERR");
|
||||
|
||||
if (nfid_stderr)
|
||||
{
|
||||
nf_ops->call(nfid_stderr, msg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nf_shutdown(void)
|
||||
{
|
||||
if (nf_ops)
|
||||
{
|
||||
long shutdown_id = nf_ops->get_id("NF_SHUTDOWN");
|
||||
|
||||
if (shutdown_id)
|
||||
nf_ops->call(shutdown_id);
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
76
usb/store/host/aranym/natfeat_asm.S
Normal file
76
usb/store/host/aranym/natfeat_asm.S
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* ARAnyM native features interface.
|
||||
* (c) 2005-2008 ARAnyM development team
|
||||
*
|
||||
* In 2006 updated with FreeMiNT headers and code.
|
||||
* In 2008 converted from "__NF" cookie to direct usage of NF instructions
|
||||
*
|
||||
**/
|
||||
|
||||
/*
|
||||
* Copied from FreeMiNT source tree where Native Features were added recently
|
||||
*
|
||||
* Copyright 2003 Frank Naumann <fnaumann@freemint.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*
|
||||
* Author: Frank Naumann <fnaumann@freemint.de>
|
||||
* Started: 2003-12-13
|
||||
*
|
||||
* please send suggestions, patches or bug reports to me or
|
||||
* the MiNT mailing list
|
||||
*
|
||||
*/
|
||||
|
||||
#define ARANYM 1
|
||||
# ifdef ARANYM
|
||||
|
||||
.text
|
||||
|
||||
.globl _detect_native_features
|
||||
|
||||
/*
|
||||
* NatFeats test (routine retuns TRUE/FALSE (1/0) in D0)
|
||||
*/
|
||||
_detect_native_features:
|
||||
|
||||
clr.l d0 // assume no NatFeats available
|
||||
move.l sp,a1 // save the ssp
|
||||
move.l (0x0010).w,a0 // illegal instruction vector
|
||||
move.l #fail_natfeat,(0x0010).w
|
||||
|
||||
nop // flush pipelines (for 68040+)
|
||||
|
||||
pea (nf_version_name).w(pc)
|
||||
subq.l #4,sp
|
||||
dc.w 0x7300 // Jump to NATFEAT_ID
|
||||
tst.l d0
|
||||
beq.s fail_natfeat
|
||||
moveq #1,d0 // NatFeats detected
|
||||
|
||||
fail_natfeat:
|
||||
move.l a1,sp
|
||||
move.l a0,(0x0010).w
|
||||
|
||||
nop // flush pipelines (for 68040+)
|
||||
|
||||
rts
|
||||
|
||||
nf_version_name:
|
||||
.ascii "NF_VERSION\0"
|
||||
|
||||
# endif
|
||||
63
usb/store/host/aranym/nf_ops.h
Normal file
63
usb/store/host/aranym/nf_ops.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* $Id: nf_ops.h,v 1.2 2006-01-31 16:21:22 standa Exp $
|
||||
*
|
||||
* ARAnyM Native Features suite.
|
||||
*
|
||||
* This file was taken from FreeMiNT.
|
||||
*
|
||||
* Copyright 2003 Frank Naumann <fnaumann@freemint.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*
|
||||
* Author: Frank Naumann <fnaumann@freemint.de>
|
||||
* Started: 2003-12-14
|
||||
*
|
||||
* Please send suggestions, patches or bug reports to me or
|
||||
* the MiNT mailing list.
|
||||
*
|
||||
*/
|
||||
|
||||
# ifndef _m68k_nf_ops_h
|
||||
# define _m68k_nf_ops_h
|
||||
|
||||
#include <compiler.h> /* for __CDECL */
|
||||
|
||||
|
||||
struct nf_ops
|
||||
{
|
||||
long __CDECL (*get_id)(const char *);
|
||||
long __CDECL (*call)(long id, ...);
|
||||
long res[3];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to intialize Native Features.
|
||||
*
|
||||
* @return the pointer to 'struct nf_ops' or NULL when
|
||||
* not available.
|
||||
**/
|
||||
struct nf_ops *nf_init(void);
|
||||
|
||||
|
||||
/* basic set native feature functions */
|
||||
const char *nf_name(void);
|
||||
int nf_debug(const char *msg);
|
||||
void nf_shutdown(void);
|
||||
|
||||
|
||||
# endif /* _m68k_nf_ops_h */
|
||||
40
usb/store/host/aranym/usbhost_nfapi.h
Normal file
40
usb/store/host/aranym/usbhost_nfapi.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
NatFeat USB Host chip emulator
|
||||
|
||||
ARAnyM (C) 2010 David Gálvez
|
||||
|
||||
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 _USBHOST_NFAPI_H
|
||||
#define _USBHOST_NFAPI_H
|
||||
|
||||
/* if you change anything in the enum {} below you have to increase
|
||||
this ARAUSBHOST_NFAPI_VERSION!
|
||||
*/
|
||||
#define ARAUSBHOST_NFAPI_VERSION 0x00000000
|
||||
|
||||
enum {
|
||||
GET_VERSION = 0, /* no parameters, return NFAPI_VERSION in d0 */
|
||||
USBHOST_LOWLEVEL_INIT,
|
||||
USBHOST_LOWLEVEL_STOP,
|
||||
USBHOST_SUBMIT_CONTROL_MSG,
|
||||
USBHOST_SUBMIT_INT_MSG,
|
||||
USBHOST_SUBMIT_BULK_MSG
|
||||
};
|
||||
|
||||
#define USBHOST(a) (nfUsbHostId + a)
|
||||
|
||||
#endif /* _USBHOST_NFAPI_H */
|
||||
Reference in New Issue
Block a user