Commit f4b50277 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Initial import of the sources of the "defmod" tool, used to build OSLib.

  These sources represent the GPLed version of defmod available with OSLib
  5.5, with modifications to support -26bit and -32bit options to choose the
  APCS variant being used.
   
Detail:
  The code has been reorganised to remove dependencies on path variables
  which are not appropriate for our build structure.  The sources directory
  contains the main code sources; the bs directory contains bootstrap headers
  to enable defmod to be build without OSLib headers being available; the
  support directory contains derivatives of JCoxhead's support library.
  
  Code changes are a switch in support.s.riscosa to support 32-bit builds of
  defmod itself; sources.y.defmod includes VersionNum and uses Module_Date
  and Module_FullVersion in the -help output; sources.c.objasm has a new
  apcs32 flag which controls MOV vs. MOVS and LDM vs. LDM^ for veneer exits.
   
  The Makefile is a complete rewrite.
  
  Do not define __GNUC__ as zero even if the compiler wants you to - it
    breaks other things (due to inconsistent use of #ifdef and #if)
 
Admin:
  Checked output is correct by inspecting AOF files generated by ToolAction.
  This tool sits in the GNU sources directory as it is released the GPL.
  This tool exports its binary to the Library.Build directory because that
    is where it lives in the library at the moment.


Tagged as defmod-5_50_prerelease
  
parents
Dir <Obey$Dir>
amu_machine all THROWBACK=-throwback
Dir <Obey$Dir>
amu_machine clean
stripdepnd Makefile
Dir <Obey$Dir>
amu_machine install THROWBACK=-throwback INSTDIR=<Install$Dir>
**/Hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/h/** gitlab-language=c linguist-language=c linguist-detectable=true
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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 1, 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
# Makefile for GNU defmod
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 16-Nov-99 SNB Created.
#
#
# Paths
#
LIBDIR = ${INSTDIR}.Library.Build
INSTAPP = ${INSTDIR}.Apps.!DefMod
VPATH = @ sources bs support
#
# Generic options:
#
MKDIR = do mkdir -p
AS = objasm
CP = copy
CC = cc
CM = cmhg
RM = remove
LD = link
LB = libfile
TOUCH = create
SQZ = squeeze
WIPE = -wipe
YACC = GNU.bison
CCFLAGS = -c -depend !Depend -ffa ${INCLUDES} ${THROWBACK} -DTRACE=0 -Wp
YACCDEFS= -DYYDEBUG=0 -DYYMAXDEPTH=0
ASFLAGS = -depend !Depend -Stamp -quit ${THROWBACK} ${ASMINC}
CPFLAGS = ~cfr~v
LBFLAGS = -c
WFLAGS = ~CFR~V
SQZFLAGS = -f
YACCFLAGS = -y
#
# Libraries
#
CLIB = CLIB:o.stubs
RLIB = RISCOSLIB:o.risc_oslib
RSTUBS = RISCOSLIB:o.rstubs
ROMSTUBS = RISCOSLIB:o.romstubs
ROMCSTUBS = RISCOSLIB:o.romcstubs
ABSSYM = RISC_OSLib:o.AbsSym
UNIXLIB = TCPIPLibs:o.unixlib
DIRS=o._dirs
#
# Include files
#
INCLUDES = -Jbs.,support.,C: -Ibs -Isources -Isupport -IC:
ASMINC = -Ibs -Isources -Isupport
#
# Program specific options:
#
COMPONENT = defmod
ICOMPONENT = !Run
TARGET = ${COMPONENT}
SOURCE =
EXPORTS =
OBJS=o.asmhelp o.callback o.chelp o.def o.defmod o.cheader o.hdr \
o.lookup o.objasm o.realloc o.resource o.riscos o.riscosa o.cstrong
LIBS=${CLIB}
#
# Rule patterns
#
.SUFFIXES: .o .c .y .s
.c.o:; ${CC} ${CCFLAGS} -o $@ $<
.s.o:; ${AS} ${ASFLAGS} -o $@ $<
.y.c:; ${YACC} ${YACCFLAGS} -o $@ $<
o.defmod: c.defmod
${CC} ${CCFLAGS} ${YACCDEFS} -o $@ c.defmod
#
# build defmod
#
all: ${TARGET}
@|
install: all
${MKDIR} ${LIBDIR}.DefMod
${CP} ${TARGET} ${LIBDIR}.DefMod.!Run ${CPFLAGS}
@echo Installation of tool ${COMPONENT} complete
#
# RISC OS ROM build rules:
#
rom: ${TARGET}
@echo ${COMPONENT}: rom module built
export: export_${PHASE}
install_rom: ${TARGET}
@echo ${COMPONENT}: rom module installed
clean:
${WIPE} c ${WFLAGS}
${WIPE} o ${WFLAGS}
${RM} ${COMPONENT}
@echo ${COMPONENT}: cleaned
export_hdrs:
@echo ${COMPONENT}: export complete (hdrs)
export_libs:
@echo ${COMPONENT}: export complete (libs)
${DIRS}:
${MKDIR} c
${MKDIR} o
create $@
#
# Final link
#
${TARGET}: ${OBJS} ${LIBS} ${DIRS}
${LD} ${LDFLAGS} -o ${COMPONENT} ${OBJS} ${LIBS}
${SQZ} ${SQZFLAGS} $@
# Dynamic dependencies:
/* (5.50)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.50
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 18 Nov 1999
#define Module_MajorVersion "5.50"
#define Module_Version 550
#define Module_MinorVersion ""
#define Module_Date "29 Nov 1999"
#define Module_FullVersion "5.50"
[ :LNOT: :DEF: Get_Types
GBLS Get_Types
]
[ :LNOT: :DEF: Types_Hdr
Get_Types SETS "GET Hdr.Types"
|
Get_Types SETS ""
]
$Get_Types
[ :LNOT: :DEF: OS_Hdr
GBLS OS_Hdr
XOS_ReadVarVal * &20023
OS_ReadVarVal * &23
;Entry
; R0 -> var (String)
; R1 = value (pointer to String)
; R2 = size (Int)
; R3 = context (Int)
; R4 = var_type (OS_VarType)
;Exit
; R0 corrupted
; R2 = used (Int)
; R3 = context_out (Int)
; R4 = var_type_out (OS_VarType)
]
END
[ :LNOT: :DEF: Types_Hdr
GBLL Types_Hdr
R0 RN 0
R1 RN 1
R2 RN 2
R3 RN 3
R4 RN 4
R5 RN 5
R6 RN 6
R7 RN 7
R8 RN 8
R9 RN 9
R10 RN 10
R11 RN 11
R12 RN 12
R13 RN 13
R14 RN 14
R15 RN 15
A1 RN 0
A2 RN 1
A3 RN 2
A4 RN 3
V1 RN 4
V2 RN 5
V3 RN 6
V4 RN 7
V5 RN 8
V6 RN 9
R RN 0
SL RN 10
FP RN 11
IP RN 12
SP RN 13
LR RN 14
PC RN 15
Int * 4
Bits * 4
Bool * 4
Short * 2
Char * 1
Byte * 1
Ptr * 4
Float * 4
Double * 8
Null * 0
False * 0
True * 1
None * 0
All * &FFFFFFFF
Skip * 0
;may be used as a "don't care" value
V * 1 :SHL: 28
C * 1 :SHL: 29
Z * 1 :SHL: 30
N * 1 :SHL: 31
Error * -2
]
END
#ifndef fileswitch_H
#define fileswitch_H
/* C header file for FileSwitch
* written by Jonathan Coxhead, jonathan@doves.demon.co.uk.
*/
/*OSLib---efficient, type-safe, transparent, extensible,
register-safe A P I coverage of RISC O S*/
/*Copyright 1994 Jonathan Coxhead*/
/*
OSLib 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 1, or (at your option)
any later version.
OSLib 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 programme; if not, write to the Free Software
Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, U S A.
*/
#ifndef types_H
#include "types.h"
#endif
#ifndef os_H
#include "os.h"
#endif
/**********************************
* SWI names and SWI reason codes *
**********************************/
#undef OS_BGet
#define OS_BGet 0xA
#undef XOS_BGet
#define XOS_BGet 0x2000A
#undef BGetV
#define BGetV 0xA
#undef OS_BPut
#define OS_BPut 0xB
#undef XOS_BPut
#define XOS_BPut 0x2000B
#undef BPutV
#define BPutV 0xB
#undef Service_StartUpFS
#define Service_StartUpFS 0x12
#undef Service_FSRedeclare
#define Service_FSRedeclare 0x40
#undef Service_CloseFile
#define Service_CloseFile 0x68
/************************************
* Structure and union declarations *
************************************/
typedef union fileswitch_info_words fileswitch_info_words;
/********************
* Type definitions *
********************/
typedef byte fileswitch_fs_no;
typedef bits fileswitch_fs_info;
typedef bits fileswitch_fs_extra_info;
typedef int fileswitch_object_type;
typedef bits fileswitch_attr;
union fileswitch_info_words
{ os_date_and_time date_and_time;
struct
{ bits exec_addr;
bits load_addr;
}
addrs;
};
/************************
* Constant definitions *
************************/
#define error_FILE_SWITCH_NO_CLAIM 0x400u
/*Unable to claim FileSwitch workspace*/
#define error_BAD_FS_CONTROL_REASON 0x401u
/*Bad FSControl call*/
#define error_BAD_OS_FILE_REASON 0x402u
/*Bad OSFile call*/
#define error_BAD_OS_ARGS_REASON 0x403u
/*Bad OSArgs call*/
#define error_BAD_OSGBPB_REASON 0x404u
/*Bad OSGBPB call*/
#define error_BAD_MODE_FOR_OS_FIND 0x405u
/*Bad mode for OSFind*/
#define error_NO_ROOM_FOR_TRANSIENT 0x406u
/*No room to run transient*/
#define error_EXEC_ADDR_NOT_IN_CODE 0x407u
/*Execution address not within code*/
#define error_EXEC_ADDR_TOO_LOW 0x408u
/*Code runs too low*/
#define error_UNKNOWN_ACTION_TYPE 0x409u
/*No run action for this file type*/
#define error_TOO_MANY_LEVELS 0x40Au
/*Too many levels*/
#define error_NO_SELECTED_FILING_SYSTEM 0x40Bu
/*No selected filing system*/
#define error_CANT_REMOVE_FS_BY_NUMBER 0x40Cu
/*Can't remove filing system by number*/
#define error_UNALIGNED_FS_ENTRY 0x40Du
/*Unaligned filing system entry point*/
#define error_UNSUPPORTED_FS_ENTRY 0x40Eu
/*Filing system does not support this operation*/
#define error_FS_NOT_SPECIAL 0x40Fu
/*Filing system does not support special fields*/
#define error_CORE_NOT_READABLE 0x410u
/*No readable memory at this address*/
#define error_CORE_NOT_WRITEABLE 0x411u
/*No writable memory at this address*/