Commit c6ff2236 authored by Jeffrey Lee's avatar Jeffrey Lee

Tidy source a bit

Detail:
  Makefile, !MkDebug,fd7 - Rewritten to use makefile fragments
  c/svcprint, h/debug - Removed obsolete svcprint code
  c/module - Collapse MESSAGES option. Use STANDALONE #define instead of ROM_MODULE to decide whether resources are embedded or not.
Admin:
  Tested in softload on Iyonix


Version 0.15. Tagged as 'SCSISoftUSB-0_15'
parent 3f82d388
......@@ -13,4 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine debug THROWBACK=-throwback
amu_machine all THROWBACK=-throwback DEBUG=TRUE
......@@ -21,97 +21,32 @@
# ---- ---- -----------
# 29-Apr-2003 BJGA Created.
COMPONENT = SCSISoftUSB
TARGET = SCSISoftUSB
DIRS = local_dirs
CFLAGS = -ffah -wp -wc -we -zM -zps1 -ITCPIPLibs:,C:USB -DDISABLE_PACKED -D_KERNEL ${DEFINES}
RAM_OBJS = o.module ${OBJS} o.resmess
ROM_OBJS = o.moduleROM ${OBJS}
OBJS = o.svcprint o.glue o.umass o.umass_quirks o.global o.asm o.modhdr #o.resmess
DBG_OBJS = do.module do.svcprint do.glue do.umass do.umass_quirks do.global o.asm o.modhdr #o.resmess
LIBDIR = <Lib$Dir>
LIBS =
DBG_LIBS = ${DEBUGLIB} ${LIBS} ${MODMALLOCLIB} ${WILDLIB} ${DDTLIB} ${DESKLIB} ${CALLXLIB} ${ASMUTILS} ${TBOXLIBS} ${LIBDIR}.DebugLib.o.debuglibzm TCPIPLibs:o.socklib5zm TCPIPLibs:o.inetlibzm
DBG_MODULE = drm.${TARGET}
EXPORTS =
#MERGEDMDIR = o.${MACHINE}._Messages_
#MERGEDMSGS = ${MERGEDMDIR}.${TARGET}
RESDIR = <resource$dir>.Resources2.SCSISoftUSB
include Makefiles:StdTools
include Makefiles:ModuleLibs
include Makefiles:ModStdRule
include Makefiles:RAMCModule
include Makefiles:ROMCModule
.SUFFIXES: .do
.c.do:; ${CC} ${CFLAGS} -DDEBUGLIB -DUMASS_DEBUG -o $@ $<
local_dirs:
${MKDIR} gpa
${MKDIR} aif
${MKDIR} do
${MKDIR} o
export: ${EXPORTS}
@${ECHO} ${COMPONENT}: export complete
${EXPORTS}:
#resources: Messages${CMDHELP}
# ${MKDIR} ${RESDIR}.${COMPONENT}
# ${CP} Messages${CMDHELP} ${RESDIR}.${COMPONENT}.Messages ${CPFLAGS}
# ${RM} Messages${CMDHELP}
# @${ECHO} ${COMPONENT}: resource files copied
aif.${COMPONENT}: ${RAM_OBJS} ${RAM_LIBS} ${CLIB} ${DIRS}
link -base 0 -aif -bin -d -o $@ ${RAM_OBJS} ${RAM_LIBS} ${CLIB}
gpa.${COMPONENT}: aif.${COMPONENT}
togpa -s aif.${COMPONENT} $@
clean:
${RM} Messages
${RM} h.modhdr
ifthere linked then wipe linked ${WFLAGS}
ifthere aof then wipe aof ${WFLAGS}
ifthere aif then wipe aif ${WFLAGS}
ifthere gpa then wipe gpa ${WFLAGS}
ifthere drm then wipe drm ${WFLAGS}
ifthere do then wipe do ${WFLAGS}
ifthere rm then wipe rm ${WFLAGS}
ifthere o then wipe o ${WFLAGS}
@${ECHO} ${COMPONENT}: cleaned
debug: ${DBG_MODULE}
@${ECHO} ${COMPONENT}: debug module built
${DBG_MODULE}: ${DBG_OBJS} ${DBG_LIBS} ${CLIB} ${DIRS}
${MKDIR} drm
${LD} ${LDFLAGS} -o $@ -rmf ${DBG_OBJS} ${DBG_LIBS} ${CLIB}
${CHMOD} -R a+rx drm
o.module: modhdr.h
do.module: modhdr.h
o.glue: modhdr.h
do.glue: modhdr.h
moduleROM.o: module.c modhdr.h
${CC} ${CFLAGS} -DROM_MODULE -o moduleROM.o module.c
resources:
${MKDIR} ${RESDIR}
${CP} LocalRes:Messages ${RESDIR}.Messages ${CPFLAGS}
@echo SCSISoftUSB: Resources copied to Messages module
resmess.o: ${MERGEDMSGS}
ResGen resmess_ResourcesFiles o.resmess LocalRes:Messages Resources.SCSISoftUSB.Messages
#${MERGEDMSGS}:
# ${MKDIR} ${MERGEDMDIR}
# IfThere LocalRes:Messages Then ${CP} LocalRes:Messages $@ ${CPFLAGS} Else Create $@
# IfThere LocalRes:CmdHelp Then FAppend $@ $@ LocalRes:CmdHelp
DEBUG ?= FALSE
ifeq ($(DEBUG),TRUE)
CFLAGS += -DDEBUGLIB -DUMASS_DEBUG -DUSB_DEBUG
CMHGFLAGS += -DDEBUGLIB -DUMASS_DEBUG -DUSB_DEBUG
LIBS = ${DEBUGLIBS} ${NET5LIBS}
endif
COMPONENT = SCSISoftUSB
TARGET = SCSISoftUSB
OBJS = global glue module umass umass_quirks asm
CMHGFILE = modhdr
HDRS =
CINCLUDES = -ITCPIPLibs:,C:USB
CFLAGS += -ffah -wp -wc -we -zM -zps1 -DDISABLE_PACKED -D_KERNEL
CMHGDEPENDS = glue module
RAMCDEFINES = -DSTANDALONE
RES_OBJ = resmess
RES_AREA = resmess_ResourcesFiles
include StdTools
include ModStdRule
include ModuleLibs
include DbgRules
include CModule
# Dynamic dependencies:
/* (0.14)
/* (0.15)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.14
#define Module_MajorVersion_CMHG 0.15
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 24 Jul 2011
#define Module_Date_CMHG 27 Nov 2011
#define Module_MajorVersion "0.14"
#define Module_Version 14
#define Module_MajorVersion "0.15"
#define Module_Version 15
#define Module_MinorVersion ""
#define Module_Date "24 Jul 2011"
#define Module_Date "27 Nov 2011"
#define Module_ApplicationDate "24-Jul-11"
#define Module_ApplicationDate "27-Nov-11"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.14"
#define Module_HelpVersion "0.14 (24 Jul 2011)"
#define Module_LibraryVersionInfo "0:14"
#define Module_FullVersion "0.15"
#define Module_HelpVersion "0.15 (27 Nov 2011)"
#define Module_LibraryVersionInfo "0:15"
......@@ -57,7 +57,7 @@
/*****************************************************************************
* MACROS
*****************************************************************************/
#define MESSAGES
/*****************************************************************************
* New type definitions
......@@ -84,7 +84,6 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
static _kernel_oserror *CheckDisconnectedDevice(const char *device_name);
static _kernel_oserror *RemoveAllDevices(void);
/*****************************************************************************
* Functions
*****************************************************************************/
......@@ -114,12 +113,10 @@ static _kernel_oserror *RemoveAllDevices(void);
_kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
{
_kernel_oserror *e = NULL;
#ifdef MESSAGES
#ifndef ROM_MODULE
#ifdef STANDALONE
bool FileRegistered = false;
#endif
bool MessagesOpen = false;
#endif
bool OnUpCallV = false;
bool CallbackSet = false;
No_New_Stuff = false;
......@@ -146,9 +143,7 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
if (!e)
{
#ifdef MESSAGES
#ifndef ROM_MODULE
#ifdef STANDALONE
e = _swix(ResourceFS_RegisterFiles, _IN(0),
resmess_ResourcesFiles());
}
......@@ -165,7 +160,6 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
if (!e)
{
MessagesOpen = true;
#endif
}
if (!e)
{
......@@ -239,13 +233,11 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
module_upcallv_handler,
global_PrivateWord);
if (e) RemoveAllDevices();
#ifdef MESSAGES
if (e && MessagesOpen) _swix(MessageTrans_CloseFile, _IN(0),
&global_MessageFD);
#ifndef ROM_MODULE
#ifdef STANDALONE
if (e && FileRegistered) _swix(ResourceFS_DeregisterFiles, _IN(0),
resmess_ResourcesFiles());
#endif
#endif
return e;
}
......@@ -330,13 +322,11 @@ _kernel_oserror *module_Final(int fatal, int podule, void *pw)
UpCallV,
module_upcallv_handler,
global_PrivateWord);
#ifdef MESSAGES
_swix(MessageTrans_CloseFile, _IN(0),
&global_MessageFD);
#ifndef ROM_MODULE
#ifdef STANDALONE
_swix(ResourceFS_DeregisterFiles, _IN(0),
resmess_ResourcesFiles());
#endif
#endif
_kernel_irqs_on();
return NULL;
......@@ -368,14 +358,12 @@ void module_Service(int service_number, _kernel_swi_regs *r, void *pw)
switch (service_number)
{
case Service_MessageFileClosed:
#ifdef MESSAGES
/* We might want to use our message file descriptor from the background, */
/* so re-open message file now, when filing system re-entrancy isn't an issue */
_swix(MessageTrans_OpenFile, _INR(0,2),
&global_MessageFD,
Module_MessagesFile,
0);
#endif
break;
case Service_ModulePostInit:
......
/* Copyright 2003 Tematic Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -*-C-*-
*
* svcprint.c
*
* print debugging information down the TML tube link.
*
* provides:
* %s - string
* %C - character in range 20->7F (space printed if outside range)
* %c - any character
* %X - reverses order of bytes if >2 (or >4) specified as width
* %x - hex
* %B - reverses order of bytes if >2 (or >4) specified as width
* %b - binary
* %D - reverses order of bytes if >2 (or >4) specified as width
* %d - decimal
*
* field width can be specified by placing a decimal number after the "%"
* character... if the width is started by a "0" then numbers are padded
* with "0"...
*
* standard format specifiers o,u,e,f and g are NOT supported
*/
#include "kernel.h"
#include "swis.h"
#include "debug.h"
#ifndef NO_SVCPRINT
#ifndef NULL
# define NULL ((void *)0)
#endif
/**********************************************************************/
static unsigned short ntohs(unsigned short n)
{
return(((n << 8) & 0xff00) | ((n >> 8) & 0x00ff));
}
/**********************************************************************/
static unsigned long ntohl(unsigned long n)
{
return(((n >> 24) & 0x000000ff) | ((n >> 8) & 0x0000ff00) |
((n << 8) & 0x00ff0000) | ((n << 24) & 0xff000000) );
}
/**********************************************************************/
/*
* call processor mode independant character output routine
*/
static void oswrch(unsigned char ch)
{
_kernel_swi_regs regset;
/*
* use HostFS_WriteC (SWI 0x40102) to print the character
*/
regset.r[0] = ch;
(void)_kernel_swi(0x40102, &regset, &regset);
}
/**********************************************************************/
/*
* Printn prints a number n in base b, minimum width w adding pad chars
* if needed.
*/
static void printn(unsigned n, unsigned b, int w, char pad)
{
if( n >= b )
{
printn(n / b, b, --w, pad);
oswrch("0123456789abcdef"[n % b]);
}
else
{
while (--w > 0)
oswrch(pad);
oswrch("0123456789abcdef"[n]);
}
}
/**********************************************************************/
static void prf(char *format, unsigned *argp, ...)
{
register int b; /* base to be used when displaying numbers */
register int c; /* current character read from format string */
register int w; /* field width */
char pad; /* field padding character */
unsigned val; /* value of argument */
loop:
val = *argp;
w = 0;
pad = ' ';
while( (c = *format++) != '%' )
{
if( c == '\0' )
return;
if( c == '\n' )
{
oswrch('\n');
oswrch('\r');
}
else
{
oswrch(c);
}
}
again:
/*
* we have a special format command
*/
c = *format++;
switch( c )
{
case 's':
{
/* string */
char *p = (char *)*argp++;
int width = 0;
if (p != NULL)
{
/* NOT a NULL pointer */
while (*p)
{
oswrch(*p++);
width++;
}
}
while( width++ < w )
oswrch(' ');
goto loop;
}
case 'C':
if( (*argp < ' ') || (*argp > '~') )
{
oswrch(' ');
argp++;
goto loop;
}
case 'c':
/* character */
oswrch(*argp++);
goto loop;
case '0':
if (w == 0)
pad = '0';
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* field width */
w = (w * 10) + ((int) c - '0');
goto again;
case 'X':
/* hex number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'x':
/* hex number */
b = 16;
goto number;
case 'B':
/* binary number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if( w > 2 )
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'b':
/* binary number */
b = 2;
goto number;
case 'D':
/* decimal number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'd':
b = 10;
/*
* NB
*
* fall through to write number
*/
number:
printn(val,b,w,pad);
argp++;
break;
} /* switch */
goto loop;
}
/**********************************************************************/
#if 0
# define USETUBE
#endif /* 0/1 */
void Printf(char *format, ...)
{
unsigned *argp = (unsigned *)&format;
#ifdef USETUBE
_kernel_swi_regs reglist;
_kernel_oserror *err;
reglist.r[0] = (int)"HostVDU";
if( (err = _kernel_swi(OS_CLI, &reglist, &reglist)) != NULL )
{
prf("HostVDU: ", 0);
prf(err->errmess, 0);
return;
}
#endif /* USETUBE */
prf(format, (argp + 1));
#ifdef USETUBE
reglist.r[0] = (int)"TubeVDU";
if( (err = _kernel_swi(OS_CLI, &reglist, &reglist)) != NULL )
{
prf("TubeVDU: ", 0);
prf(err->errmess, 0);
return;
}
#endif /* USETUBE */
}
#endif
/**********************************************************************/
/* EOF svcprint.c */
......@@ -13,18 +13,10 @@
* limitations under the License.
*/
#undef DEBUGGING
#ifndef DEBUGGING
#define NO_SVCPRINT
#ifdef UMASS_DEBUG
#define DEBUGf logprintf
#else
#define DEBUGf(...)
#endif
#else
extern void Printf(char *format,...);
#define DEBUGf Printf
#define DEBUGf(...) (void) 0
#endif
/* EOF debug.h */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment