Compare commits
10 Commits
add_nes
...
dtrg-exper
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f09da5045 | ||
|
|
33b4873932 | ||
|
|
d91a1dc1a6 | ||
|
|
b9b808e01a | ||
|
|
99d7f513f2 | ||
|
|
bcfb3d802f | ||
|
|
8e2d027c49 | ||
|
|
8d0261473d | ||
|
|
c93cb69959 | ||
|
|
c8fdcff960 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
*~
|
||||
*.o
|
||||
.*
|
||||
-.gitignore
|
||||
10
README
10
README
@@ -1,7 +1,8 @@
|
||||
THE AMSTERDAM COMPILER KIT V6.0pre4
|
||||
===================================
|
||||
THE AMSTERDAM COMPILER KIT V6.0pre4
|
||||
===================================
|
||||
|
||||
© 1987-2005 Vrije Universiteit, Amsterdam 2010-08-08
|
||||
© 1987-2005 Vrije Universiteit, Amsterdam
|
||||
2010-08-08
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
@@ -164,3 +165,6 @@ David Given (dtrg on Sourceforge)
|
||||
dg@cowlark.com
|
||||
2010-08-08
|
||||
|
||||
# $Source$
|
||||
# $State$
|
||||
# $Revision$
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#define DO_TOSTACK 23
|
||||
#define DO_KILLREG 24
|
||||
#define DO_LABDEF 25
|
||||
#define DO_STACKADJUST 26
|
||||
|
||||
#ifndef MAXATT
|
||||
#define MAXATT TOKENSIZE
|
||||
@@ -133,6 +134,7 @@ typedef struct exprnode *node_p;
|
||||
#define EX_ISROM 44
|
||||
#define EX_TOPELTSIZE 45
|
||||
#define EX_FALLTHROUGH 46
|
||||
#define EX_STACKOFFSET 47
|
||||
|
||||
|
||||
typedef struct { /* to stack coercions */
|
||||
|
||||
5
h/out.h
5
h/out.h
@@ -61,7 +61,10 @@ struct outname {
|
||||
#define RELSZ 0x07 /* relocation length */
|
||||
#define RELO1 1 /* 1 byte */
|
||||
#define RELO2 2 /* 2 bytes */
|
||||
#define RELO4 4 /* 4 bytes */
|
||||
#define RELO4 3 /* 4 bytes */
|
||||
#define RELOPPC 4 /* PowerPC 26-bit address */
|
||||
#define RELOH2 5 /* write top 2 bytes of 4 byte word */
|
||||
|
||||
#define RELPC 0x08 /* pc relative */
|
||||
#define RELBR 0x10 /* High order byte lowest address. */
|
||||
#define RELWR 0x20 /* High order word lowest address. */
|
||||
|
||||
@@ -14,8 +14,8 @@ del = 0177
|
||||
.sect .text
|
||||
.diagnos:
|
||||
movem.l d0/d1/d2/a0, -(sp)
|
||||
move.l (.lino), -(sp)
|
||||
move.l (.filn), d2
|
||||
move.l (hol0), -(sp)
|
||||
move.l (hol0+4), d2
|
||||
beq 1f
|
||||
move.l d2, a0
|
||||
move.l #40, d0
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
move.l (.limhp),-(sp)
|
||||
move.l (.reghp),-(sp)
|
||||
pea (12, sp)
|
||||
move.l (.lino),-(sp)
|
||||
move.l (hol0),-(sp)
|
||||
pea (fmt)
|
||||
jsr (.diagnos)
|
||||
lea (20, sp), sp
|
||||
|
||||
38
mach/m68020/libem/pmfile
Normal file
38
mach/m68020/libem/pmfile
Normal file
@@ -0,0 +1,38 @@
|
||||
-- $Source: /cvsroot/tack/Ack/mach/i386/libem/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."mach/m68020/libem/"
|
||||
|
||||
libem_m68020 = acklibrary {
|
||||
outputs = {"%U%/libem-%PLATFORM%.a"},
|
||||
|
||||
ACKINCLUDES = {PARENT, ROOTDIR.."h"},
|
||||
|
||||
ackfile (d.."fp68881.s"),
|
||||
ackfile (d.."aar.s"),
|
||||
ackfile (d.."lar.s"),
|
||||
ackfile (d.."sar.s"),
|
||||
ackfile (d.."csa.s"),
|
||||
ackfile (d.."csb.s"),
|
||||
ackfile (d.."shp.s"),
|
||||
ackfile (d.."set.s"),
|
||||
ackfile (d.."inn.s"),
|
||||
ackfile (d.."fat.s"),
|
||||
ackfile (d.."trp.s"),
|
||||
ackfile (d.."trpstr.c"),
|
||||
ackfile (d.."mon.s"),
|
||||
ackfile (d.."nop.s"),
|
||||
ackfile (d.."dia.s"),
|
||||
ackfile (d.."cii.s"),
|
||||
ackfile (d.."cuu.s"),
|
||||
ackfile (d.."cmi.s"),
|
||||
ackfile (d.."cms.s"),
|
||||
ackfile (d.."cmu.s"),
|
||||
ackfile (d.."cvf.s"),
|
||||
ackfile (d.."exg.s"),
|
||||
ackfile (d.."los.s"),
|
||||
ackfile (d.."sts.s"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"),
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fmt: .asciz "%s\n"
|
||||
move.l d0, (12, sp)
|
||||
cmp.l #16, d0
|
||||
bcc 1f
|
||||
move.l (.trpim), d1
|
||||
move.l (.ignmask), d1
|
||||
btst d0, d1
|
||||
bne 3f
|
||||
1:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <em_abs.h>
|
||||
|
||||
char *
|
||||
_trpstr(d)
|
||||
{
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
! $Source: /cvsroot/tack/Ack/mach/i386/libend/em_end.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.2 $
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
.define endtext,enddata,endbss,__end
|
||||
.sect .text
|
||||
.align 4
|
||||
.sect .rom
|
||||
.align 4
|
||||
.sect .data
|
||||
.align 4
|
||||
.sect .bss
|
||||
.align 4
|
||||
.sect .end ! only for declaration of _end, __end and endbss.
|
||||
.define endtext, endrom, enddata, endbss, __end
|
||||
|
||||
.sect .text
|
||||
.align 4
|
||||
endtext:
|
||||
.sect .rom
|
||||
.align 4
|
||||
endrom:
|
||||
.sect .data
|
||||
.align 4
|
||||
enddata:
|
||||
.sect .end
|
||||
.align 4
|
||||
__end:
|
||||
endbss:
|
||||
|
||||
16
mach/m68020/libend/pmfile
Normal file
16
mach/m68020/libend/pmfile
Normal file
@@ -0,0 +1,16 @@
|
||||
-- $Source: /cvsroot/tack/Ack/mach/i386/libend/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."mach/m68020/libend/"
|
||||
|
||||
libend_m68020 = acklibrary {
|
||||
outputs = {"%U%/libend-%PLATFORM%.a"},
|
||||
|
||||
ackfile (d.."edata.s"),
|
||||
ackfile (d.."em_end.s"),
|
||||
ackfile (d.."end.s"),
|
||||
ackfile (d.."etext.s"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"),
|
||||
}
|
||||
@@ -5840,7 +5840,7 @@ with any_int STACK
|
||||
jsr {absolute4, ".exg"}
|
||||
|
||||
pat fil
|
||||
gen move_l {ext_addr, $1}, {absolute4, ".filn"}
|
||||
gen move_l {ext_addr, $1}, {absolute4, "hol0+4"}
|
||||
|
||||
pat gto
|
||||
with STACK
|
||||
@@ -5854,15 +5854,15 @@ with STACK
|
||||
jmp {indirect4, %a}
|
||||
#endif
|
||||
|
||||
pat lim yields {absolute_int, ".trpim"}
|
||||
pat lim yields {absolute_int, ".ignmask"}
|
||||
|
||||
pat lin
|
||||
kills posextern
|
||||
gen move_i {const, $1}, {absolute_int, ".lino"}
|
||||
gen move_i {const, $1}, {absolute_int, "hol0"}
|
||||
|
||||
pat lni
|
||||
kills posextern
|
||||
gen add_i {const, 1}, {absolute_int, ".lino"}
|
||||
gen add_i {const, 1}, {absolute_int, "hol0"}
|
||||
|
||||
pat lor $1==0 yields lb
|
||||
|
||||
@@ -5955,7 +5955,7 @@ with any4
|
||||
pat sim
|
||||
with any_int
|
||||
kills posextern
|
||||
gen move_i %1, {absolute_int, ".trpim"}
|
||||
gen move_i %1, {absolute_int, ".ignmask"}
|
||||
|
||||
pat str $1==0
|
||||
with any4 STACK
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
#define WORD_SIZE 4 /* should be 2 or 4 */
|
||||
#define TBL68020 1 /* should be TBL68020 or TBL68000 */
|
||||
/* #define TBL68881 1 /* use floating point processor */
|
||||
#define TBL68881 1 /* use floating point processor */
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
local d = ROOTDIR.."mach/m68020/"
|
||||
|
||||
include (d.."libem/pmfile")
|
||||
include (d.."libend/pmfile")
|
||||
|
||||
mach_m68020 = group {
|
||||
ARCH = "m68020",
|
||||
|
||||
@@ -10,20 +13,11 @@ mach_m68020 = group {
|
||||
proto_ncg { ARCHDIR = "m68020" },
|
||||
proto_top,
|
||||
ego_descr,
|
||||
|
||||
install = {
|
||||
pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"),
|
||||
}
|
||||
}
|
||||
|
||||
-- Revision history
|
||||
-- $Log$
|
||||
-- Revision 1.3 2006-07-22 12:31:19 dtrg
|
||||
-- Added support for the top target peephole optimiser.
|
||||
--
|
||||
-- Revision 1.2 2006/07/22 00:52:01 dtrg
|
||||
-- Added support for the ego global optimisation suite.
|
||||
--
|
||||
-- Revision 1.1 2006/07/20 23:18:18 dtrg
|
||||
-- First version in CVS.
|
||||
--
|
||||
support_m68020 = group {
|
||||
OPTIMISATION = "-O6",
|
||||
|
||||
libem_m68020,
|
||||
libend_m68020,
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ PROPERTIES
|
||||
GPR24 GPR25 GPR26 GPR27 GPR28 GPR29 GPR30 GPR31
|
||||
|
||||
CR0 CR1
|
||||
|
||||
|
||||
FPR0 FPR1 FPR2 FPR3 FPR4 FPR5 FPR6 FPR7
|
||||
FPR8 FPR9 FPR10 FPR11 FPR12 FPR13 FPR14 FPR15
|
||||
FPR16 FPR17 FPR18 FPR19 FPR20 FPR21 FPR22 FPR23
|
||||
FPR24 FPR25 FPR26 FPR27 FPR28 FPR29 FPR30 FPR31
|
||||
|
||||
|
||||
REGISTERS
|
||||
|
||||
/* Reverse order to encourage ncg to allocate them from r31 down */
|
||||
@@ -95,7 +95,7 @@ REGISTERS
|
||||
FP("fp") : GPR, GPRFP.
|
||||
SP("sp") : GPR, GPRSP.
|
||||
R0("r0") : GPR, GPR0.
|
||||
|
||||
|
||||
F31("f31") : FPR, FREG, FPR31.
|
||||
F30("f30") : FPR, FREG, FPR30.
|
||||
F29("f29") : FPR, FREG, FPR29.
|
||||
@@ -1996,7 +1996,7 @@ PATTERNS
|
||||
|
||||
/* All very cheap and nasty --- this needs to be properly integrated into
|
||||
* the code generator. ncg doesn't like having separate FPU registers. */
|
||||
|
||||
|
||||
/* Single-precision */
|
||||
|
||||
pat zrf $1==INT32 /* Push zero */
|
||||
@@ -2158,4 +2158,3 @@ PATTERNS
|
||||
gen
|
||||
bl {LABEL, ".fif8"}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#define GENLAB "I" /* compiler generated labels */
|
||||
|
||||
#define valu_t short /* type of expression values */
|
||||
#define valu_t long /* type of expression values */
|
||||
#define ADDR_T unsigned short /* type of dot */
|
||||
#define word_t short /* type of keyword value */
|
||||
/*
|
||||
@@ -113,6 +113,7 @@ _include <signal.h>
|
||||
#define lowb(z) ((int)(z) & 0xFF)
|
||||
#define loww(z) ((int)(z) & 0xFFFF)
|
||||
|
||||
#define fitx(x, d) ((((x) + (1<<(d-1))) & ~((int)(1<<(d))-1)) == 0)
|
||||
#define fitb(x) ((((x) + 0x80) & ~((int)0xFF)) == 0)
|
||||
#define fitw(x) ((((x) + 0x8000L) & ~0xFFFFL) == 0)
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
local d = ROOTDIR.."mach/proto/cg/"
|
||||
|
||||
local make_tables = cgg {
|
||||
CGGINCLUDEDIR = (ROOTDIR.."mach/%ARCH%/cg/"),
|
||||
file (ROOTDIR.."mach/%ARCH%/cg/table")
|
||||
CGGINCLUDEDIR = (ROOTDIR.."mach/%PLATFORM%/cg/"),
|
||||
file (ROOTDIR.."mach/%PLATFORM%/cg/table")
|
||||
}
|
||||
|
||||
local cfile_with_tables = cfile {
|
||||
class = "cfile_with_tables",
|
||||
dynamicheaders = {
|
||||
make_tables,
|
||||
file (ROOTDIR.."mach/%ARCH%/cg/"),
|
||||
file (ROOTDIR.."mach/%PLATFORM%/cg/"),
|
||||
file (ROOTDIR.."mach/")
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ proto_cg = cprogram {
|
||||
cfile {
|
||||
ith { make_tables, i = 1 },
|
||||
dynamicheaders = {
|
||||
file (ROOTDIR.."mach/%ARCH%/cg/"),
|
||||
file (ROOTDIR.."mach/%PLATFORM%/cg/"),
|
||||
file (d)
|
||||
}
|
||||
},
|
||||
@@ -47,8 +47,8 @@ proto_cg = cprogram {
|
||||
lib_em_data,
|
||||
lib_flt_arith,
|
||||
|
||||
outputs = {"%U%/%ARCH%-cg"},
|
||||
install = pm.install("%BINDIR%%PLATDEP%/%ARCH%/cg")
|
||||
outputs = {"%U%/%PLATFORM%-cg"},
|
||||
install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/cg")
|
||||
}
|
||||
|
||||
-- Revision history
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#undef NDEBUG
|
||||
#ifndef NDEBUG
|
||||
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
|
||||
#else
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
@@ -778,7 +780,10 @@ normalfailed: if (stackpad!=tokpatlen) {
|
||||
compute(&enodes[nodeno], &result);
|
||||
assert(result.e_typ!=EV_INT && result.e_typ!=EV_ADDR);
|
||||
if (result.e_typ==EV_REG)
|
||||
erasereg(result.e_v.e_reg);
|
||||
{
|
||||
int regno = result.e_v.e_reg;
|
||||
erasereg(regno);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DO_TOKREPLACE: {
|
||||
@@ -904,6 +909,23 @@ normalfailed: if (stackpad!=tokpatlen) {
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_NOFRAMEPOINTER
|
||||
case DO_STACKADJUST: {
|
||||
result_t result;
|
||||
int nodeno;
|
||||
|
||||
DEBUG("STACKADJUST");
|
||||
/* The offset is an expression, which we need to evaluate. */
|
||||
|
||||
getint(nodeno,codep);
|
||||
compute(&enodes[nodeno], &result);
|
||||
assert(result.e_typ==EV_INT);
|
||||
|
||||
if (toplevel)
|
||||
stackoffset += result.e_v.e_con;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "equiv.h"
|
||||
#include "param.h"
|
||||
|
||||
@@ -20,6 +20,9 @@ extern rl_p curreglist; /* side effect of findcoerc() */
|
||||
#ifndef NDEBUG
|
||||
extern int Debug; /* on/off debug printout */
|
||||
#endif
|
||||
#ifdef USE_NOFRAMEPOINTER
|
||||
extern int stackoffset; /* offset from localbase to sp */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Next descriptions are external declarations for tables created
|
||||
@@ -52,3 +55,6 @@ extern struct reginfo **reglist[]; /* lists of registers per property */
|
||||
extern int nregvar[]; /* # of register variables per type */
|
||||
extern int *rvnumbers[]; /* lists of numbers */
|
||||
#endif
|
||||
|
||||
extern FILE *codefile;
|
||||
extern FILE *freopen();
|
||||
|
||||
@@ -60,8 +60,6 @@ long con();
|
||||
#define get8() getc(emfile)
|
||||
|
||||
FILE *emfile;
|
||||
extern FILE *codefile;
|
||||
extern FILE *freopen();
|
||||
|
||||
int nextispseu,savetab1;
|
||||
int opcode;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <em_spec.h>
|
||||
#include <em_flag.h>
|
||||
#include "assert.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Source: /cvsroot/tack/Ack/mach/proto/ncg/pmfile,v $
|
||||
-- $State: Exp $
|
||||
|
||||
local d = ROOTDIR.."mach/proto/ncg/"
|
||||
|
||||
@@ -18,6 +18,8 @@ local cfile_with_tables = cfile {
|
||||
proto_ncg = cprogram {
|
||||
class = "proto_ncg",
|
||||
|
||||
exename = "ncg",
|
||||
|
||||
CINCLUDES = {
|
||||
PARENT,
|
||||
"mach/%PLATFORM%/ncg",
|
||||
@@ -50,6 +52,6 @@ proto_ncg = cprogram {
|
||||
lib_em_data,
|
||||
lib_flt_arith,
|
||||
|
||||
outputs = {"%U%/%PLATFORM%-ncg"},
|
||||
install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/ncg")
|
||||
outputs = {"%U%/%PLATFORM%-%exename%"},
|
||||
install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/%exename%")
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -3,6 +3,7 @@ static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "assert.h"
|
||||
#include "param.h"
|
||||
#include "tables.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_exit.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_hol0.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.1 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/brk.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/close.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/creat.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/errno.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.1 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/getpid.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/gettimeofday.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
13
plat/linux/liblinux/isatty.c
Normal file
13
plat/linux/liblinux/isatty.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/isatty.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int isatty(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/kill.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/libsys.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef LIBSYS_H
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/lseek.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/open.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
29
plat/linux/liblinux/pmfile
Normal file
29
plat/linux/liblinux/pmfile
Normal file
@@ -0,0 +1,29 @@
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."plat/linux/liblinux/"
|
||||
|
||||
liblinux = acklibrary {
|
||||
ACKINCLUDES = {"%BINDIR%include"},
|
||||
|
||||
ackfile (d.."errno.s"),
|
||||
ackfile (d.."_hol0.s"),
|
||||
|
||||
ackfile (d.."brk.c"),
|
||||
ackfile (d.."close.c"),
|
||||
ackfile (d.."creat.c"),
|
||||
ackfile (d.."getpid.c"),
|
||||
ackfile (d.."gettimeofday.c"),
|
||||
ackfile (d.."_exit.c"),
|
||||
ackfile (d.."isatty.c"),
|
||||
ackfile (d.."kill.c"),
|
||||
ackfile (d.."lseek.c"),
|
||||
ackfile (d.."open.c"),
|
||||
ackfile (d.."read.c"),
|
||||
ackfile (d.."sbrk.c"),
|
||||
ackfile (d.."signal.c"),
|
||||
ackfile (d.."write.c"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/liblinux.a"),
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/read.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,35 +1,32 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/sbrk.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
#define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */
|
||||
|
||||
static char* current = NULL;
|
||||
extern char _end[1];
|
||||
|
||||
static char* current = _end;
|
||||
|
||||
void* sbrk(intptr_t increment)
|
||||
{
|
||||
char* old;
|
||||
char* new;
|
||||
char* actual;
|
||||
|
||||
if (!current)
|
||||
current = (char*) _syscall(__NR_brk, 0, 0, 0);
|
||||
|
||||
if (increment == 0)
|
||||
return current;
|
||||
|
||||
old = current;
|
||||
new = old + increment;
|
||||
|
||||
actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0);
|
||||
if (actual < new)
|
||||
if (brk(new) < 0)
|
||||
return OUT_OF_MEMORY;
|
||||
|
||||
current = actual;
|
||||
current = new;
|
||||
return old;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/signal.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/syscalls.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef SYSCALLS_H
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/write.c,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -59,7 +59,9 @@ name led
|
||||
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
|
||||
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
|
||||
{FLOATS?} \
|
||||
(.e:{TAIL}={PLATFORMDIR}/libem.a \
|
||||
(.e:{TAIL}={PLATFORMDIR}/liblinux.a \
|
||||
{PLATFORMDIR}/libem.a \
|
||||
{PLATFORMDIR}/liblinux.a \
|
||||
{PLATFORMDIR}/libsys.a \
|
||||
{PLATFORMDIR}/libend.a)
|
||||
linker
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
#include "syscalls.h"
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int isatty(int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,33 +1,13 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Revision$
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."plat/linux386/libsys/"
|
||||
|
||||
libsys_linux386 = acklibrary {
|
||||
ACKBUILDFLAGS = {PARENT, "-ansi"},
|
||||
ACKINCLUDES = {"%BINDIR%include"},
|
||||
|
||||
ackfile (d.."errno.s"),
|
||||
ackfile (d.."_hol0.s"),
|
||||
ackfile (d.."_syscall.s"),
|
||||
|
||||
ackfile (d.."brk.c"),
|
||||
ackfile (d.."close.c"),
|
||||
ackfile (d.."creat.c"),
|
||||
ackfile (d.."getpid.c"),
|
||||
ackfile (d.."gettimeofday.c"),
|
||||
ackfile (d.."_exit.c"),
|
||||
ackfile (d.."isatty.c"),
|
||||
ackfile (d.."kill.c"),
|
||||
ackfile (d.."lseek.c"),
|
||||
ackfile (d.."open.c"),
|
||||
ackfile (d.."read.c"),
|
||||
ackfile (d.."sbrk.c"),
|
||||
ackfile (d.."signal.c"),
|
||||
ackfile (d.."write.c"),
|
||||
ackfile (d.."unlink.c"),
|
||||
ackfile (d.."remove.c"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include "libsys.h"
|
||||
|
||||
int remove(const char* path)
|
||||
{
|
||||
return unlink(path);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include "libsys.h"
|
||||
|
||||
int unlink(const char* path)
|
||||
{
|
||||
return _syscall(__NR_unlink, (quad) path, 0, 0);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
local d = ROOTDIR.."plat/linux386/"
|
||||
|
||||
include (d.."libsys/pmfile")
|
||||
include "plat/linux/liblinux/pmfile"
|
||||
|
||||
local bootsector = ackfile {
|
||||
file (d.."boot.s"),
|
||||
@@ -41,6 +42,7 @@ platform_linux386 = group {
|
||||
|
||||
-- Build the PC standalone syscall library.
|
||||
|
||||
liblinux,
|
||||
libsys_linux386,
|
||||
bootsector,
|
||||
}
|
||||
|
||||
@@ -5,20 +5,22 @@ README
|
||||
include/ack/config.h
|
||||
include/unistd.h
|
||||
libsys/pmfile
|
||||
libsys/_exit.c
|
||||
libsys/_hol0.s
|
||||
libsys/_syscall.s
|
||||
libsys/brk.c
|
||||
libsys/close.c
|
||||
libsys/creat.c
|
||||
libsys/errno.s
|
||||
libsys/getpid.c
|
||||
libsys/gettimeofday.c
|
||||
libsys/isatty.c
|
||||
libsys/kill.c
|
||||
libsys/libsys.h
|
||||
libsys/lseek.c
|
||||
libsys/open.c
|
||||
libsys/read.c
|
||||
libsys/sbrk.c
|
||||
libsys/signal.c
|
||||
libsys/time.c
|
||||
libsys/syscalls.h
|
||||
libsys/write.c
|
||||
libsys/_sys_rawread.s
|
||||
libsys/_sys_rawwrite.s
|
||||
42
plat/linux68k/README
Normal file
42
plat/linux68k/README
Normal file
@@ -0,0 +1,42 @@
|
||||
# $Source: /cvsroot/tack/Ack/plat/linux386/README,v $
|
||||
# $State: Exp $
|
||||
# $Revision: 1.2 $
|
||||
|
||||
|
||||
The linux386 platform
|
||||
=====================
|
||||
|
||||
linux386 is an i386-based BSP that produces Linux ELF executables.
|
||||
|
||||
This port only implements a very limited number of system calls; basically,
|
||||
just enough to make the demo apps run. Adding more is easy, but there are some
|
||||
subtleties that require more thought. The port should be considered only in
|
||||
proof-of-concept stage right now.
|
||||
|
||||
Important note: you *can't* link access ELF shared libraries from these
|
||||
executables. In other words, you have to all your work from inside ACK.
|
||||
|
||||
IEEE floating point is available, but requires an FPU.
|
||||
|
||||
The executables are generated with aelfslod and are extremely simple; there's
|
||||
one rwx ELF section which contains all the application's code and data. This
|
||||
is not optimal, but it does work.
|
||||
|
||||
|
||||
Bugs
|
||||
====
|
||||
|
||||
isatty() is a stub and always returns 0.
|
||||
|
||||
|
||||
Example command line
|
||||
====================
|
||||
|
||||
ack -mlinux386 -O -o linux386.exe examples/paranoia.c
|
||||
|
||||
The file linux386.exe can then be run on a i386 Linux machine (or on an
|
||||
emulation thereof).
|
||||
|
||||
|
||||
David Given
|
||||
dg@cowlark.com
|
||||
87
plat/linux68k/boot.s
Normal file
87
plat/linux68k/boot.s
Normal file
@@ -0,0 +1,87 @@
|
||||
#
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.3 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
begtext:
|
||||
! This code is placed at the beginning of the ELF executable and is the
|
||||
! first thing that runs.
|
||||
!
|
||||
! On entry, the stack looks like this:
|
||||
!
|
||||
! sp+.. NULL
|
||||
! sp+8+(4*argc) env (X quads)
|
||||
! sp+4+(4*argc) NULL
|
||||
! sp+4 argv (argc quads)
|
||||
! sp argc
|
||||
!
|
||||
! The ACK actually expects:
|
||||
!
|
||||
! sp+8 argc
|
||||
! sp+4 argv
|
||||
! sp env
|
||||
|
||||
move.l (0, sp), d0 ! d0 = argc
|
||||
move.l (4, sp), d1 ! d1 = argv
|
||||
move.l d0, d2
|
||||
asl.l #2, d2
|
||||
move.l (sp, d2), d2
|
||||
add.l #12, d2 ! d2 = environ
|
||||
|
||||
move.l d2, -(sp) ! environ
|
||||
move.l d0, -(sp) ! argc
|
||||
move.l d1, -(sp) ! argv
|
||||
pea (0) ! dummy, representing the return address
|
||||
|
||||
jmp (__m_a_i_n)
|
||||
|
||||
#if 0
|
||||
mov eax, (esp) ! eax = argc
|
||||
lea ebx, 4(esp) ! ebx = argv
|
||||
lea ecx, (esp)(eax*4)
|
||||
add ecx, 12 ! environ
|
||||
|
||||
push ecx ! environ
|
||||
push ebx ! argc
|
||||
push eax ! argv
|
||||
push eax ! dummy, representing the return argument
|
||||
xor ebp, ebp
|
||||
#endif
|
||||
|
||||
! This provides an emergency exit routine used by EM.
|
||||
|
||||
.define EXIT
|
||||
.extern EXIT
|
||||
EXIT:
|
||||
pea (1)
|
||||
jmp (__exit)
|
||||
|
||||
! This is used by the trap routine for diagnostics.
|
||||
|
||||
.define WRITE
|
||||
.extern WRITE
|
||||
WRITE:
|
||||
jmp (_write)
|
||||
|
||||
! Define symbols at the beginning of our various segments, so that we can find
|
||||
! them. (Except .text, which has already been done.)
|
||||
|
||||
.sect .data; begdata:
|
||||
.sect .rom; begrom:
|
||||
.sect .bss; begbss:
|
||||
|
||||
! Some magic data. All EM systems need these.
|
||||
|
||||
.define .trppc, .ignmask, _errno
|
||||
.comm .trppc, 4
|
||||
.comm .ignmask, 4
|
||||
.comm _errno, 4
|
||||
@@ -1,21 +1,25 @@
|
||||
# $Source$
|
||||
# $State$
|
||||
# $Revision$
|
||||
# $Source: /cvsroot/tack/Ack/plat/linux386/descr,v $
|
||||
# $State: Exp $
|
||||
# $Revision: 1.1 $
|
||||
|
||||
var w=2
|
||||
var p=2
|
||||
var w=4
|
||||
var p=4
|
||||
var s=2
|
||||
var l=4
|
||||
var f=4
|
||||
var d=8
|
||||
var ARCH=6500
|
||||
var PLATFORM=nes
|
||||
var ARCH=m68020
|
||||
var PLATFORM=linux68k
|
||||
var PLATFORMDIR={EM}/lib/{PLATFORM}
|
||||
var CPP_F=
|
||||
var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1
|
||||
var MACHOPT_F=-m8
|
||||
var CPP_F=-D__unix -D__mc68020 -D__m68k -D__mc68000 -D__M68020
|
||||
var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08000054
|
||||
var C_LIB={PLATFORMDIR}/libc-ansi.a
|
||||
# bitfields reversed for compatibility with (g)cc.
|
||||
var CC_ALIGN=-Vr
|
||||
var OLD_C_LIB={C_LIB}
|
||||
var MACHOPT_F=-ml10
|
||||
|
||||
# Override the setting in fe so that files compiled for linux386 can see
|
||||
# Override the setting in fe so that files compiled for linux68k can see
|
||||
# the platform-specific headers.
|
||||
|
||||
var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
|
||||
@@ -24,7 +28,8 @@ name be
|
||||
from .m.g
|
||||
to .s
|
||||
program {EM}/lib.bin/{PLATFORM}/ncg
|
||||
args <
|
||||
mapflag -gdb GF=-gdb
|
||||
args {GF?} <
|
||||
stdout
|
||||
need .e
|
||||
end
|
||||
@@ -40,8 +45,7 @@ name led
|
||||
to .out
|
||||
program {EM}/lib.bin/em_led
|
||||
mapflag -l* LNAME={PLATFORMDIR}/lib*
|
||||
mapflag -i SEPID=-b1:0
|
||||
mapflag -fp FLOATS={EM}/{ILIB}fp
|
||||
mapflag -fp FLOATS={EM}/{LIB}fp
|
||||
args {ALIGN} {SEPID?} \
|
||||
(.e:{HEAD}={PLATFORMDIR}/boot.o) \
|
||||
({RTS}:.ocm.b={PLATFORMDIR}/c-ansi.o) \
|
||||
@@ -56,14 +60,15 @@ name led
|
||||
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
|
||||
{FLOATS?} \
|
||||
(.e:{TAIL}={PLATFORMDIR}/libem.a \
|
||||
{PLATFORMDIR}/liblinux.a \
|
||||
{PLATFORMDIR}/libsys.a \
|
||||
{PLATFORMDIR}/libend.a)
|
||||
linker
|
||||
end
|
||||
name cv
|
||||
from .out
|
||||
to .img
|
||||
program {EM}/bin/aslod
|
||||
args < >
|
||||
outfile nes.img
|
||||
to .exe
|
||||
program {EM}/bin/aelflod
|
||||
args -m4 -b < >
|
||||
outfile linux68k.exe
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/ack/config.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef _ACK_CONFIG_H
|
||||
@@ -9,6 +9,6 @@
|
||||
/* We're providing a time() system call rather than wanting a wrapper around
|
||||
* gettimeofday() in the libc. */
|
||||
|
||||
#define ACKCONF_TIME_IS_A_SYSCALL
|
||||
/* #define ACKCONF_TIME_IS_A_SYSCALL */
|
||||
|
||||
#endif
|
||||
76
plat/linux68k/include/sys/ioctl.h
Normal file
76
plat/linux68k/include/sys/ioctl.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/sys/ioctl.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IOCTL_H
|
||||
#define _SYS_IOCTL_H
|
||||
|
||||
/* These are copied from the ioctl_list(2) man page. */
|
||||
|
||||
/* <include/asm-i386/socket.h> */
|
||||
|
||||
#define FIOSETOWN 0x00008901
|
||||
#define SIOCSPGRP 0x00008902
|
||||
#define FIOGETOWN 0x00008903
|
||||
#define SIOCGPGRP 0x00008904
|
||||
#define SIOCATMARK 0x00008905
|
||||
#define SIOCGSTAMP 0x00008906
|
||||
|
||||
/* <include/asm-i386/termios.h> */
|
||||
|
||||
#define TCGETS 0x00005401
|
||||
#define TCSETS 0x00005402
|
||||
#define TCSETSW 0x00005403
|
||||
#define TCSETSF 0x00005404
|
||||
#define TCGETA 0x00005405
|
||||
#define TCSETA 0x00005406
|
||||
#define TCSETAW 0x00005407
|
||||
#define TCSETAF 0x00005408
|
||||
#define TCSBRK 0x00005409
|
||||
#define TCXONC 0x0000540A
|
||||
#define TCFLSH 0x0000540B
|
||||
#define TIOCEXCL 0x0000540C
|
||||
#define TIOCNXCL 0x0000540D
|
||||
#define TIOCSCTTY 0x0000540E
|
||||
#define TIOCGPGRP 0x0000540F
|
||||
#define TIOCSPGRP 0x00005410
|
||||
#define TIOCOUTQ 0x00005411
|
||||
#define TIOCSTI 0x00005412
|
||||
#define TIOCGWINSZ 0x00005413
|
||||
#define TIOCSWINSZ 0x00005414
|
||||
#define TIOCMGET 0x00005415
|
||||
#define TIOCMBIS 0x00005416
|
||||
#define TIOCMBIC 0x00005417
|
||||
#define TIOCMSET 0x00005418
|
||||
#define TIOCGSOFTCAR 0x00005419
|
||||
#define TIOCSSOFTCAR 0x0000541A
|
||||
#define FIONREAD 0x0000541B
|
||||
#define TIOCINQ 0x0000541B
|
||||
#define TIOCLINUX 0x0000541C
|
||||
#define TIOCCONS 0x0000541D
|
||||
#define TIOCGSERIAL 0x0000541E
|
||||
#define TIOCSSERIAL 0x0000541F
|
||||
#define TIOCPKT 0x00005420
|
||||
#define FIONBIO 0x00005421
|
||||
#define TIOCNOTTY 0x00005422
|
||||
#define TIOCSETD 0x00005423
|
||||
#define TIOCGETD 0x00005424
|
||||
#define TCSBRKP 0x00005425
|
||||
#define TIOCTTYGSTRUCT 0x00005426
|
||||
#define FIONCLEX 0x00005450
|
||||
#define FIOCLEX 0x00005451
|
||||
#define FIOASYNC 0x00005452
|
||||
#define TIOCSERCONFIG 0x00005453
|
||||
#define TIOCSERGWILD 0x00005454
|
||||
#define TIOCSERSWILD 0x00005455
|
||||
#define TIOCGLCKTRMIOS 0x00005456
|
||||
#define TIOCSLCKTRMIOS 0x00005457
|
||||
#define TIOCSERGSTRUCT 0x00005458
|
||||
#define TIOCSERGETLSR 0x00005459
|
||||
#define TIOCSERGETMULTI 0x0000545A
|
||||
#define TIOCSERSETMULTI 0x0000545B
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
123
plat/linux68k/include/unistd.h
Normal file
123
plat/linux68k/include/unistd.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* unistd.h - standard system calls
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _UNISTD_H
|
||||
#define _UNISTD_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef int pid_t;
|
||||
typedef int mode_t;
|
||||
|
||||
typedef long suseconds_t;
|
||||
|
||||
/* Time handling. */
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
}; /* obsolete, unused */
|
||||
|
||||
extern int gettimeofday(struct timeval* tv, struct timezone* tz);
|
||||
extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
|
||||
|
||||
/* File access. */
|
||||
|
||||
enum
|
||||
{
|
||||
O_ACCMODE = 0x3,
|
||||
|
||||
O_RDONLY = 0,
|
||||
O_WRONLY = 1,
|
||||
O_RDWR = 2,
|
||||
|
||||
O_CREAT = 0x10,
|
||||
O_TRUNC = 0x20,
|
||||
O_APPEND = 0x40
|
||||
};
|
||||
|
||||
extern int open(const char* path, int access, ...);
|
||||
extern int creat(const char* path, mode_t mode);
|
||||
extern int close(int d);
|
||||
extern int read(int fd, void* buffer, size_t count);
|
||||
extern int write(int fd, void* buffer, size_t count);
|
||||
extern off_t lseek(int fildes, off_t offset, int whence);
|
||||
extern int fcntl(int fd, int op, ...);
|
||||
|
||||
/* Special variables */
|
||||
|
||||
extern char** environ;
|
||||
|
||||
/* Implemented system calls */
|
||||
|
||||
extern void _exit(int);
|
||||
extern pid_t getpid(void);
|
||||
extern int brk(void* ptr);
|
||||
extern void* sbrk(intptr_t increment);
|
||||
extern int isatty(int d);
|
||||
|
||||
/* Signal handling */
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
|
||||
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
|
||||
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
|
||||
|
||||
#define SIGHUP 1 /* Hangup (POSIX). */
|
||||
#define SIGINT 2 /* Interrupt (ANSI). */
|
||||
#define SIGQUIT 3 /* Quit (POSIX). */
|
||||
#define SIGILL 4 /* Illegal instruction (ANSI). */
|
||||
#define SIGTRAP 5 /* Trace trap (POSIX). */
|
||||
#define SIGABRT 6 /* Abort (ANSI). */
|
||||
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
|
||||
#define SIGBUS 7 /* BUS error (4.2 BSD). */
|
||||
#define SIGFPE 8 /* Floating-point exception (ANSI). */
|
||||
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
|
||||
#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
|
||||
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
|
||||
#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
|
||||
#define SIGPIPE 13 /* Broken pipe (POSIX). */
|
||||
#define SIGALRM 14 /* Alarm clock (POSIX). */
|
||||
#define SIGTERM 15 /* Termination (ANSI). */
|
||||
#define SIGSTKFLT 16 /* Stack fault. */
|
||||
#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
|
||||
#define SIGCHLD 17 /* Child status has changed (POSIX). */
|
||||
#define SIGCONT 18 /* Continue (POSIX). */
|
||||
#define SIGSTOP 19 /* Stop, unblockable (POSIX). */
|
||||
#define SIGTSTP 20 /* Keyboard stop (POSIX). */
|
||||
#define SIGTTIN 21 /* Background read from tty (POSIX). */
|
||||
#define SIGTTOU 22 /* Background write to tty (POSIX). */
|
||||
#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */
|
||||
#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
|
||||
#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
|
||||
#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
|
||||
#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
|
||||
#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
|
||||
#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
|
||||
#define SIGIO 29 /* I/O now possible (4.2 BSD). */
|
||||
#define SIGPWR 30 /* Power failure restart (System V). */
|
||||
#define SIGSYS 31 /* Bad system call. */
|
||||
#define SIGUNUSED 31
|
||||
|
||||
#define _NSIG 32 /* Biggest signal number + 1
|
||||
(not including real-time signals). */
|
||||
typedef void (*sighandler_t)(int);
|
||||
extern sighandler_t signal(int signum, sighandler_t handler);
|
||||
extern int raise(int signum);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
45
plat/linux68k/libsys/_syscall.s
Normal file
45
plat/linux68k/libsys/_syscall.s
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.1 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
EINVAL = 22
|
||||
|
||||
! Perform a Linux system call.
|
||||
|
||||
.define __syscall
|
||||
__syscall:
|
||||
move.l (4, sp), d0
|
||||
move.l (8, sp), d1
|
||||
move.l (12, sp), d2
|
||||
move.l (16, sp), d3
|
||||
trap #0
|
||||
|
||||
tst.l d0
|
||||
bmi 1f
|
||||
rts
|
||||
|
||||
1:
|
||||
neg.l d0
|
||||
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
|
||||
cmp.l #1, d0
|
||||
blt 2f
|
||||
cmp.l #34, d0
|
||||
bgt 2f
|
||||
move.l d0, (_errno)
|
||||
3:
|
||||
move.l #-1, d0
|
||||
rts
|
||||
|
||||
2:
|
||||
move.l #EINVAL, (_errno)
|
||||
bra 3b
|
||||
13
plat/linux68k/libsys/pmfile
Normal file
13
plat/linux68k/libsys/pmfile
Normal file
@@ -0,0 +1,13 @@
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."plat/linux68k/libsys/"
|
||||
|
||||
libsys_linux68k = acklibrary {
|
||||
ACKINCLUDES = {"%BINDIR%include"},
|
||||
|
||||
ackfile (d.."_syscall.s"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
|
||||
}
|
||||
48
plat/linux68k/pmfile
Normal file
48
plat/linux68k/pmfile
Normal file
@@ -0,0 +1,48 @@
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.3 $
|
||||
|
||||
local d = ROOTDIR.."plat/linux68k/"
|
||||
|
||||
include (d.."libsys/pmfile")
|
||||
include "plat/linux/liblinux/pmfile"
|
||||
|
||||
local bootsector = ackfile {
|
||||
file (d.."boot.s"),
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"),
|
||||
}
|
||||
|
||||
local descr = group {
|
||||
install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr")
|
||||
}
|
||||
|
||||
local headers = group {
|
||||
install = {
|
||||
pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"),
|
||||
pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"),
|
||||
}
|
||||
}
|
||||
|
||||
platform_linux68k = group {
|
||||
ARCH = "m68020",
|
||||
PLATFORM = "linux68k",
|
||||
OPTIMISATION = "-O6",
|
||||
|
||||
-- Ensure the descr and headers are installed first because we'll need it
|
||||
-- to build the libraries.
|
||||
|
||||
descr,
|
||||
headers,
|
||||
|
||||
-- Build the back-end support.
|
||||
|
||||
mach_m68020,
|
||||
support_m68020,
|
||||
lang_runtimes,
|
||||
|
||||
-- Build the PC standalone syscall library.
|
||||
|
||||
liblinux,
|
||||
libsys_linux68k,
|
||||
bootsector,
|
||||
}
|
||||
26
plat/linuxppc/.distr
Normal file
26
plat/linuxppc/.distr
Normal file
@@ -0,0 +1,26 @@
|
||||
descr
|
||||
boot.s
|
||||
pmfile
|
||||
README
|
||||
include/ack/config.h
|
||||
include/unistd.h
|
||||
libsys/pmfile
|
||||
libsys/_exit.c
|
||||
libsys/_hol0.s
|
||||
libsys/_syscall.s
|
||||
libsys/brk.c
|
||||
libsys/close.c
|
||||
libsys/creat.c
|
||||
libsys/errno.s
|
||||
libsys/getpid.c
|
||||
libsys/gettimeofday.c
|
||||
libsys/isatty.c
|
||||
libsys/kill.c
|
||||
libsys/libsys.h
|
||||
libsys/lseek.c
|
||||
libsys/open.c
|
||||
libsys/read.c
|
||||
libsys/sbrk.c
|
||||
libsys/signal.c
|
||||
libsys/syscalls.h
|
||||
libsys/write.c
|
||||
42
plat/linuxppc/README
Normal file
42
plat/linuxppc/README
Normal file
@@ -0,0 +1,42 @@
|
||||
# $Source: /cvsroot/tack/Ack/plat/linux386/README,v $
|
||||
# $State: Exp $
|
||||
# $Revision: 1.2 $
|
||||
|
||||
|
||||
The linux386 platform
|
||||
=====================
|
||||
|
||||
linux386 is an i386-based BSP that produces Linux ELF executables.
|
||||
|
||||
This port only implements a very limited number of system calls; basically,
|
||||
just enough to make the demo apps run. Adding more is easy, but there are some
|
||||
subtleties that require more thought. The port should be considered only in
|
||||
proof-of-concept stage right now.
|
||||
|
||||
Important note: you *can't* link access ELF shared libraries from these
|
||||
executables. In other words, you have to all your work from inside ACK.
|
||||
|
||||
IEEE floating point is available, but requires an FPU.
|
||||
|
||||
The executables are generated with aelfslod and are extremely simple; there's
|
||||
one rwx ELF section which contains all the application's code and data. This
|
||||
is not optimal, but it does work.
|
||||
|
||||
|
||||
Bugs
|
||||
====
|
||||
|
||||
isatty() is a stub and always returns 0.
|
||||
|
||||
|
||||
Example command line
|
||||
====================
|
||||
|
||||
ack -mlinux386 -O -o linux386.exe examples/paranoia.c
|
||||
|
||||
The file linux386.exe can then be run on a i386 Linux machine (or on an
|
||||
emulation thereof).
|
||||
|
||||
|
||||
David Given
|
||||
dg@cowlark.com
|
||||
56
plat/linuxppc/boot.s
Normal file
56
plat/linuxppc/boot.s
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/boot.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.3 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
begtext:
|
||||
! This code is placed at the beginning of the ELF executable and is the
|
||||
! first thing that runs.
|
||||
!
|
||||
! On entry, the stack looks like this:
|
||||
!
|
||||
! sp+... NULL
|
||||
! sp+8+(4*argc) env (X quads)
|
||||
! sp+4+(4*argc) NULL
|
||||
! sp+4 argv (argc quads)
|
||||
! sp argc
|
||||
!
|
||||
! The ACK actually expects:
|
||||
!
|
||||
! sp+8 argc
|
||||
! sp+4 ptr to argv
|
||||
! sp ptr to env
|
||||
|
||||
lwz r3, 0(sp) ! r3 = argc
|
||||
addi r4, sp, 4 ! r4 = argv
|
||||
rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits
|
||||
add r5, r5, r4
|
||||
addi r5, r5, 8 ! r5 = env
|
||||
|
||||
stwu r5, -4(sp)
|
||||
stwu r4, -4(sp)
|
||||
stwu r3, -4(sp)
|
||||
|
||||
b __m_a_i_n
|
||||
|
||||
! Some magic data. All EM systems need these.
|
||||
|
||||
.define _errno
|
||||
.comm _errno, 4 ! Posix errno storage
|
||||
|
||||
.define .trppc, .ignmask
|
||||
.comm .trppc, 4 ! ptr to user trap handler
|
||||
.comm .ignmask, 4 ! user trap ignore mask
|
||||
|
||||
.define .linenumber, .filename
|
||||
.comm .linenumber, 4 ! current linenumber (used for debugging)
|
||||
.comm .filename, 4 ! ptr to current filename (used for debugging)
|
||||
81
plat/linuxppc/descr
Normal file
81
plat/linuxppc/descr
Normal file
@@ -0,0 +1,81 @@
|
||||
# $Source: /cvsroot/tack/Ack/plat/linux386/descr,v $
|
||||
# $State: Exp $
|
||||
# $Revision: 1.1 $
|
||||
|
||||
var w=4
|
||||
var p=4
|
||||
var s=2
|
||||
var l=4
|
||||
var f=4
|
||||
var d=8
|
||||
var ARCH=powerpc
|
||||
var PLATFORM=linuxppc
|
||||
var PLATFORMDIR={EM}/lib/{PLATFORM}
|
||||
var CPP_F=-D__unix -D__POWERPC
|
||||
var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054
|
||||
var C_LIB={PLATFORMDIR}/libc-ansi.a
|
||||
# bitfields reversed for compatibility with (g)cc.
|
||||
var CC_ALIGN=-Vr
|
||||
var OLD_C_LIB={C_LIB}
|
||||
var MACHOPT_F=
|
||||
|
||||
# Override the setting in fe so that files compiled for linuxppc can see
|
||||
# the platform-specific headers.
|
||||
|
||||
var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
|
||||
|
||||
name be
|
||||
from .m.g
|
||||
to .s
|
||||
program {EM}/lib.bin/{PLATFORM}/ncg
|
||||
mapflag -gdb GF=-gdb
|
||||
args {GF?} <
|
||||
stdout
|
||||
need .e
|
||||
end
|
||||
name asopt
|
||||
from .s
|
||||
to .so
|
||||
program {EM}/lib.bin/{PLATFORM}/top
|
||||
args
|
||||
optimizer
|
||||
stdin
|
||||
stdout
|
||||
end
|
||||
name as
|
||||
from .s.so
|
||||
to .o
|
||||
program {EM}/lib.bin/{PLATFORM}/as
|
||||
args - -o > <
|
||||
prep cond
|
||||
end
|
||||
name led
|
||||
from .o.a
|
||||
to .out
|
||||
program {EM}/lib.bin/em_led
|
||||
mapflag -l* LNAME={PLATFORMDIR}/lib*
|
||||
mapflag -fp FLOATS={EM}/{LIB}fp
|
||||
args {ALIGN} {SEPID?} \
|
||||
{PLATFORMDIR}/boot.o \
|
||||
({RTS}:.ocm.b.c={PLATFORMDIR}/c-ansi.o) \
|
||||
({RTS}:.mod={PLATFORMDIR}/modula2.o) \
|
||||
({RTS}:.p={PLATFORMDIR}/pascal.o) \
|
||||
-o > < \
|
||||
(.p:{TAIL}={PLATFORMDIR}/libpascal.a) \
|
||||
(.b:{TAIL}={PLATFORMDIR}/libbasic.a) \
|
||||
(.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \
|
||||
(.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
|
||||
(.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
|
||||
{PLATFORMDIR}/liblinux.a \
|
||||
{PLATFORMDIR}/libem.a \
|
||||
{PLATFORMDIR}/libsys.a \
|
||||
{PLATFORMDIR}/libend.a
|
||||
linker
|
||||
end
|
||||
name cv
|
||||
from .out
|
||||
to .exe
|
||||
program {EM}/bin/aelflod
|
||||
args -m20 -b < >
|
||||
outfile linuxppc.exe
|
||||
end
|
||||
18
plat/linuxppc/include/ack/config.h
Normal file
18
plat/linuxppc/include/ack/config.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/ack/config.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef _ACK_CONFIG_H
|
||||
#define _ACK_CONFIG_H
|
||||
|
||||
/* We're providing a time() system call rather than wanting a wrapper around
|
||||
* gettimeofday() in the libc. */
|
||||
|
||||
/* #define ACKCONF_TIME_IS_A_SYSCALL */
|
||||
|
||||
/* We don't support floating point right now. */
|
||||
|
||||
/* #define ACKCONF_NO_STDIO_FLOAT */
|
||||
|
||||
#endif
|
||||
76
plat/linuxppc/include/sys/ioctl.h
Normal file
76
plat/linuxppc/include/sys/ioctl.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $Source: /cvsroot/tack/Ack/plat/linux386/include/sys/ioctl.h,v $
|
||||
* $State: Exp $
|
||||
* $Revision: 1.1 $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_IOCTL_H
|
||||
#define _SYS_IOCTL_H
|
||||
|
||||
/* These are copied from the ioctl_list(2) man page. */
|
||||
|
||||
/* <include/asm-i386/socket.h> */
|
||||
|
||||
#define FIOSETOWN 0x00008901
|
||||
#define SIOCSPGRP 0x00008902
|
||||
#define FIOGETOWN 0x00008903
|
||||
#define SIOCGPGRP 0x00008904
|
||||
#define SIOCATMARK 0x00008905
|
||||
#define SIOCGSTAMP 0x00008906
|
||||
|
||||
/* <include/asm-i386/termios.h> */
|
||||
|
||||
#define TCGETS 0x00005401
|
||||
#define TCSETS 0x00005402
|
||||
#define TCSETSW 0x00005403
|
||||
#define TCSETSF 0x00005404
|
||||
#define TCGETA 0x00005405
|
||||
#define TCSETA 0x00005406
|
||||
#define TCSETAW 0x00005407
|
||||
#define TCSETAF 0x00005408
|
||||
#define TCSBRK 0x00005409
|
||||
#define TCXONC 0x0000540A
|
||||
#define TCFLSH 0x0000540B
|
||||
#define TIOCEXCL 0x0000540C
|
||||
#define TIOCNXCL 0x0000540D
|
||||
#define TIOCSCTTY 0x0000540E
|
||||
#define TIOCGPGRP 0x0000540F
|
||||
#define TIOCSPGRP 0x00005410
|
||||
#define TIOCOUTQ 0x00005411
|
||||
#define TIOCSTI 0x00005412
|
||||
#define TIOCGWINSZ 0x00005413
|
||||
#define TIOCSWINSZ 0x00005414
|
||||
#define TIOCMGET 0x00005415
|
||||
#define TIOCMBIS 0x00005416
|
||||
#define TIOCMBIC 0x00005417
|
||||
#define TIOCMSET 0x00005418
|
||||
#define TIOCGSOFTCAR 0x00005419
|
||||
#define TIOCSSOFTCAR 0x0000541A
|
||||
#define FIONREAD 0x0000541B
|
||||
#define TIOCINQ 0x0000541B
|
||||
#define TIOCLINUX 0x0000541C
|
||||
#define TIOCCONS 0x0000541D
|
||||
#define TIOCGSERIAL 0x0000541E
|
||||
#define TIOCSSERIAL 0x0000541F
|
||||
#define TIOCPKT 0x00005420
|
||||
#define FIONBIO 0x00005421
|
||||
#define TIOCNOTTY 0x00005422
|
||||
#define TIOCSETD 0x00005423
|
||||
#define TIOCGETD 0x00005424
|
||||
#define TCSBRKP 0x00005425
|
||||
#define TIOCTTYGSTRUCT 0x00005426
|
||||
#define FIONCLEX 0x00005450
|
||||
#define FIOCLEX 0x00005451
|
||||
#define FIOASYNC 0x00005452
|
||||
#define TIOCSERCONFIG 0x00005453
|
||||
#define TIOCSERGWILD 0x00005454
|
||||
#define TIOCSERSWILD 0x00005455
|
||||
#define TIOCGLCKTRMIOS 0x00005456
|
||||
#define TIOCSLCKTRMIOS 0x00005457
|
||||
#define TIOCSERGSTRUCT 0x00005458
|
||||
#define TIOCSERGETLSR 0x00005459
|
||||
#define TIOCSERGETMULTI 0x0000545A
|
||||
#define TIOCSERSETMULTI 0x0000545B
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
123
plat/linuxppc/include/unistd.h
Normal file
123
plat/linuxppc/include/unistd.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* unistd.h - standard system calls
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _UNISTD_H
|
||||
#define _UNISTD_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef int pid_t;
|
||||
typedef int mode_t;
|
||||
|
||||
typedef long suseconds_t;
|
||||
|
||||
/* Time handling. */
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
}; /* obsolete, unused */
|
||||
|
||||
extern int gettimeofday(struct timeval* tv, struct timezone* tz);
|
||||
extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
|
||||
|
||||
/* File access. */
|
||||
|
||||
enum
|
||||
{
|
||||
O_ACCMODE = 0x3,
|
||||
|
||||
O_RDONLY = 0,
|
||||
O_WRONLY = 1,
|
||||
O_RDWR = 2,
|
||||
|
||||
O_CREAT = 0x10,
|
||||
O_TRUNC = 0x20,
|
||||
O_APPEND = 0x40
|
||||
};
|
||||
|
||||
extern int open(const char* path, int access, ...);
|
||||
extern int creat(const char* path, mode_t mode);
|
||||
extern int close(int d);
|
||||
extern int read(int fd, void* buffer, size_t count);
|
||||
extern int write(int fd, void* buffer, size_t count);
|
||||
extern off_t lseek(int fildes, off_t offset, int whence);
|
||||
extern int fcntl(int fd, int op, ...);
|
||||
|
||||
/* Special variables */
|
||||
|
||||
extern char** environ;
|
||||
|
||||
/* Implemented system calls */
|
||||
|
||||
extern void _exit(int);
|
||||
extern pid_t getpid(void);
|
||||
extern int brk(void* ptr);
|
||||
extern void* sbrk(intptr_t increment);
|
||||
extern int isatty(int d);
|
||||
|
||||
/* Signal handling */
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
|
||||
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
|
||||
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
|
||||
|
||||
#define SIGHUP 1 /* Hangup (POSIX). */
|
||||
#define SIGINT 2 /* Interrupt (ANSI). */
|
||||
#define SIGQUIT 3 /* Quit (POSIX). */
|
||||
#define SIGILL 4 /* Illegal instruction (ANSI). */
|
||||
#define SIGTRAP 5 /* Trace trap (POSIX). */
|
||||
#define SIGABRT 6 /* Abort (ANSI). */
|
||||
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
|
||||
#define SIGBUS 7 /* BUS error (4.2 BSD). */
|
||||
#define SIGFPE 8 /* Floating-point exception (ANSI). */
|
||||
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
|
||||
#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */
|
||||
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
|
||||
#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */
|
||||
#define SIGPIPE 13 /* Broken pipe (POSIX). */
|
||||
#define SIGALRM 14 /* Alarm clock (POSIX). */
|
||||
#define SIGTERM 15 /* Termination (ANSI). */
|
||||
#define SIGSTKFLT 16 /* Stack fault. */
|
||||
#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
|
||||
#define SIGCHLD 17 /* Child status has changed (POSIX). */
|
||||
#define SIGCONT 18 /* Continue (POSIX). */
|
||||
#define SIGSTOP 19 /* Stop, unblockable (POSIX). */
|
||||
#define SIGTSTP 20 /* Keyboard stop (POSIX). */
|
||||
#define SIGTTIN 21 /* Background read from tty (POSIX). */
|
||||
#define SIGTTOU 22 /* Background write to tty (POSIX). */
|
||||
#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */
|
||||
#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
|
||||
#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
|
||||
#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
|
||||
#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
|
||||
#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
|
||||
#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
|
||||
#define SIGIO 29 /* I/O now possible (4.2 BSD). */
|
||||
#define SIGPWR 30 /* Power failure restart (System V). */
|
||||
#define SIGSYS 31 /* Bad system call. */
|
||||
#define SIGUNUSED 31
|
||||
|
||||
#define _NSIG 32 /* Biggest signal number + 1
|
||||
(not including real-time signals). */
|
||||
typedef void (*sighandler_t)(int);
|
||||
extern sighandler_t signal(int signum, sighandler_t handler);
|
||||
extern int raise(int signum);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
53
plat/linuxppc/libsys/_syscall.s
Normal file
53
plat/linuxppc/libsys/_syscall.s
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.1 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
EINVAL = 22
|
||||
|
||||
#define IFFALSE 4
|
||||
#define IFTRUE 12
|
||||
#define ALWAYS 20
|
||||
|
||||
#define LT 0
|
||||
#define GT 1
|
||||
#define EQ 2
|
||||
#define OV 3
|
||||
|
||||
! Perform a Linux system call.
|
||||
|
||||
.define __syscall
|
||||
__syscall:
|
||||
lwz r0, 0(sp)
|
||||
lwz r3, 4(sp)
|
||||
lwz r4, 8(sp)
|
||||
lwz r5, 12(sp)
|
||||
sc 0
|
||||
bclr IFFALSE, OV, 0
|
||||
|
||||
! On error, r3 contains the errno.
|
||||
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
|
||||
cmpi cr0, 0, r3, 1
|
||||
bc IFTRUE, LT, 2f
|
||||
cmpi cr0, 0, r3, 34
|
||||
bc IFTRUE, GT, 2f
|
||||
|
||||
3:
|
||||
addis r4, r0, <_errno
|
||||
ori r4, r4, >_errno
|
||||
stw r3, 0(r4)
|
||||
addi r3, r0, -1
|
||||
bclr ALWAYS, 0, 0
|
||||
|
||||
2:
|
||||
addi r3, r0, EINVAL
|
||||
b 3b
|
||||
14
plat/linuxppc/libsys/pmfile
Normal file
14
plat/linuxppc/libsys/pmfile
Normal file
@@ -0,0 +1,14 @@
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.1 $
|
||||
|
||||
local d = ROOTDIR.."plat/linuxppc/libsys/"
|
||||
|
||||
libsys_linuxppc = acklibrary {
|
||||
ACKINCLUDES = {"%BINDIR%include"},
|
||||
|
||||
ackfile (d.."_syscall.s"),
|
||||
ackfile (d.."trap.s"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
|
||||
}
|
||||
108
plat/linuxppc/libsys/trap.s
Normal file
108
plat/linuxppc/libsys/trap.s
Normal file
@@ -0,0 +1,108 @@
|
||||
#
|
||||
! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
|
||||
! $State: Exp $
|
||||
! $Revision: 1.1 $
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
#define IFFALSE 4
|
||||
#define IFTRUE 12
|
||||
#define ALWAYS 20
|
||||
|
||||
#define LT 0
|
||||
#define GT 1
|
||||
#define EQ 2
|
||||
#define OV 3
|
||||
|
||||
EARRAY = 0
|
||||
ERANGE = 1
|
||||
ESET = 2
|
||||
EIOVFL = 3
|
||||
EFOVFL = 4
|
||||
EFUNFL = 5
|
||||
EIDIVZ = 6
|
||||
EFDIVZ = 7
|
||||
EIUND = 8
|
||||
EFUND = 9
|
||||
ECONV = 10
|
||||
ESTACK = 16
|
||||
EHEAP = 17
|
||||
EILLINS = 18
|
||||
EODDZ = 19
|
||||
ECASE = 20
|
||||
EMEMFLT = 21
|
||||
EBADPTR = 22
|
||||
EBADPC = 23
|
||||
EBADLAE = 24
|
||||
EBADMON = 25
|
||||
EBADLIN = 26
|
||||
EBADGTO = 27
|
||||
EUNIMPL = 63 ! unimplemented em-instruction called
|
||||
|
||||
! EM trap handling.
|
||||
|
||||
.define .trap_ecase
|
||||
.trap_ecase:
|
||||
addi r3, r0, ECASE
|
||||
b .trap
|
||||
|
||||
.define .trap_earray
|
||||
.trap_earray:
|
||||
addi r3, r0, EARRAY
|
||||
b .trap
|
||||
|
||||
.define .trap
|
||||
.trap:
|
||||
cmpi cr0, 0, r3, 15 ! traps >15 can't be ignored
|
||||
bc IFTRUE, LT, 1f
|
||||
|
||||
addi r4, r0, 1
|
||||
rlwnm r4, r4, r3, 0, 31 ! calculate trap bit
|
||||
addis r5, r0, <.ignmask
|
||||
ori r5, r5, >.ignmask
|
||||
lwz r5, 0(r5) ! load ignore mask
|
||||
and. r4, r4, r5 ! compare
|
||||
bclr IFFALSE, EQ, 0 ! return if non-zero
|
||||
|
||||
1:
|
||||
addis r4, r0, <.trppc
|
||||
ori r4, r4, >.trppc
|
||||
lwz r5, 0(r4) ! load user trap routine
|
||||
or. r5, r5, r5 ! test
|
||||
bc IFTRUE, EQ, fatal ! if no user trap routine, bail out
|
||||
|
||||
addi r0, r0, 0
|
||||
stw r0, 0(r4) ! reset trap routine
|
||||
|
||||
mfspr r0, lr
|
||||
stwu r0, -4(sp) ! save old lr
|
||||
|
||||
stwu r3, -4(sp)
|
||||
mtspr ctr, r5
|
||||
bcctrl ALWAYS, 0, 0 ! call trap routine
|
||||
|
||||
lwz r0, 4(sp) ! load old lr again
|
||||
addi sp, sp, 8 ! retract over stack usage
|
||||
bclr ALWAYS, 0, 0 ! return
|
||||
|
||||
fatal:
|
||||
addi r3, r0, 1
|
||||
addis r4, r0, <message
|
||||
ori r4, r4, >message
|
||||
addi r5, r0, 6
|
||||
addi r0, r0, 4 ! write()
|
||||
sc 0
|
||||
|
||||
addi r0, r0, 1 ! exit()
|
||||
sc 0
|
||||
|
||||
.sect .rom
|
||||
message:
|
||||
.ascii "TRAP!\n"
|
||||
@@ -1,14 +1,15 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Revision$
|
||||
-- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $
|
||||
-- $State: Exp $
|
||||
-- $Revision: 1.3 $
|
||||
|
||||
local d = ROOTDIR.."plat/nes/"
|
||||
local d = ROOTDIR.."plat/linuxppc/"
|
||||
|
||||
include (d.."libsys/pmfile")
|
||||
include "plat/linux/liblinux/pmfile"
|
||||
|
||||
local bootsector = ackfile {
|
||||
file (d.."boot.s"),
|
||||
install = pm.install("%BINDIR%lib/nes/boot.o"),
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"),
|
||||
}
|
||||
|
||||
local descr = group {
|
||||
@@ -22,24 +23,26 @@ local headers = group {
|
||||
}
|
||||
}
|
||||
|
||||
platform_nes = group {
|
||||
ARCH = "6500",
|
||||
PLATFORM = "nes",
|
||||
platform_linuxppc = group {
|
||||
ARCH = "powerpc",
|
||||
PLATFORM = "linuxppc",
|
||||
OPTIMISATION = "-O",
|
||||
|
||||
-- Ensure the descr and headers are installed first because we'll need
|
||||
-- them to build the libraries.
|
||||
|
||||
|
||||
-- Ensure the descr and headers are installed first because we'll need it
|
||||
-- to build the libraries.
|
||||
|
||||
descr,
|
||||
headers,
|
||||
|
||||
|
||||
-- Build the back-end support.
|
||||
|
||||
mach_6500,
|
||||
support_6500,
|
||||
|
||||
mach_powerpc,
|
||||
support_powerpc,
|
||||
lang_runtimes,
|
||||
-- Build the NES library.
|
||||
|
||||
libsys_nes,
|
||||
bootsector
|
||||
-- Build the PC standalone syscall library.
|
||||
|
||||
liblinux,
|
||||
libsys_linuxppc,
|
||||
bootsector,
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
# $Source$
|
||||
# $State$
|
||||
# $Revision$
|
||||
|
||||
|
||||
The NES platform
|
||||
=================
|
||||
|
||||
NES is a platform for the Nintendo Entertainment System.
|
||||
|
||||
Example command line
|
||||
====================
|
||||
|
||||
ack -mnes -O -o nes.img examples/paranoia.c
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
|
||||
start2:
|
||||
jmp _main
|
||||
|
||||
.define __exit
|
||||
.extern __exit
|
||||
.define EXIT
|
||||
.extern EXIT
|
||||
__exit:
|
||||
EXIT:
|
||||
|
||||
.define begtext, begdata, begbss
|
||||
.sect .data; begdata:
|
||||
.sect .rom; begrom:
|
||||
.sect .bss; begbss:
|
||||
|
||||
! Some magic data. All EM systems need these.
|
||||
|
||||
.define .trppc, .ignmask, _errno
|
||||
.comm .trppc, 4
|
||||
.comm .ignmask, 4
|
||||
.comm _errno, 4
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* unistd.h - standard system calls
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _UNISTD_H
|
||||
#define _UNISTD_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef int pid_t;
|
||||
typedef int mode_t;
|
||||
|
||||
/* Constants for file access (open and friends) */
|
||||
|
||||
enum
|
||||
{
|
||||
O_ACCMODE = 0x3,
|
||||
|
||||
O_RDONLY = 0,
|
||||
O_WRONLY = 1,
|
||||
O_RDWR = 2,
|
||||
|
||||
O_CREAT = 0100,
|
||||
O_TRUNC = 01000,
|
||||
O_APPEND = 02000,
|
||||
O_NONBLOCK = 04000
|
||||
};
|
||||
|
||||
/* Special variables */
|
||||
|
||||
extern char** environ;
|
||||
|
||||
/* Implemented system calls */
|
||||
|
||||
extern void _exit(int);
|
||||
extern pid_t getpid(void);
|
||||
extern void* sbrk(intptr_t increment);
|
||||
extern int isatty(int d);
|
||||
extern off_t lseek(int fildes, off_t offset, int whence);
|
||||
extern int close(int d);
|
||||
extern int open(const char* path, int access, ...);
|
||||
extern int creat(const char* path, mode_t mode);
|
||||
extern int read(int fd, void* buffer, size_t count);
|
||||
extern int write(int fd, void* buffer, size_t count);
|
||||
|
||||
/* Unimplemented system calls (these are just prototypes to let the library
|
||||
* compile). */
|
||||
|
||||
extern int fcntl(int fd, int op, ...);
|
||||
|
||||
/* Signal handling */
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_ERR ((sighandler_t) -1) /* Error return. */
|
||||
#define SIG_DFL ((sighandler_t) 0) /* Default action. */
|
||||
#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */
|
||||
|
||||
#define SIGABRT 6 /* Abort (ANSI) */
|
||||
#define SIGILL 11 /* Illegal instruction */
|
||||
|
||||
#define _NSIG 32 /* Biggest signal number + 1
|
||||
(not including real-time signals). */
|
||||
typedef void (*sighandler_t)(int);
|
||||
extern sighandler_t signal(int signum, sighandler_t handler);
|
||||
extern int raise(int signum);
|
||||
|
||||
#endif
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .bss
|
||||
|
||||
! This data block is used to store information about the current line number
|
||||
! and file.
|
||||
|
||||
.define hol0
|
||||
.comm hol0, 8
|
||||
@@ -1,23 +0,0 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
! Reads a single byte.
|
||||
|
||||
.define __sys_rawread
|
||||
__sys_rawread:
|
||||
xorb ah, ah
|
||||
int 0x16
|
||||
xorb ah, ah
|
||||
ret
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
.sect .text
|
||||
|
||||
! Writes a single byte to the console.
|
||||
|
||||
.define __sys_rawwrite
|
||||
.extern __sys_rawwrite
|
||||
|
||||
__sys_rawwrite:
|
||||
push bp
|
||||
mov bp, sp
|
||||
|
||||
movb al, 4(bp)
|
||||
movb ah, 0x0E
|
||||
mov bx, 0x0007
|
||||
int 0x10
|
||||
jmp .cret
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */
|
||||
#define STACK_BUFFER 128 /* number of bytes to leave for stack */
|
||||
|
||||
extern char _end[1];
|
||||
static char* current = _end;
|
||||
|
||||
int brk(void* newend)
|
||||
{
|
||||
/* This variable is used to figure out the current stack pointer,
|
||||
* by taking its address. */
|
||||
char dummy;
|
||||
char* p = newend;
|
||||
|
||||
if ((p > (&dummy - STACK_BUFFER)) ||
|
||||
(p < _end))
|
||||
return -1;
|
||||
|
||||
current = p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* sbrk(intptr_t increment)
|
||||
{
|
||||
char* old;
|
||||
|
||||
if (increment == 0)
|
||||
return current;
|
||||
|
||||
old = current;
|
||||
if (brk(old + increment) < 0)
|
||||
return OUT_OF_MEMORY;
|
||||
|
||||
return old;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int close(int fd)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
int open(const char* path, int access, ...)
|
||||
{
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
! $Source$
|
||||
! $State$
|
||||
! $Revision$
|
||||
|
||||
! Declare segments (the order is important).
|
||||
|
||||
.sect .text
|
||||
.sect .rom
|
||||
.sect .data
|
||||
.sect .bss
|
||||
|
||||
#define D(e) .define e; e
|
||||
|
||||
.sect .data
|
||||
|
||||
! Define various ACK error numbers. Note that these are *not* ANSI C
|
||||
! errnos, and are used for different purposes.
|
||||
|
||||
D(ERANGE) = 1
|
||||
D(ESET) = 2
|
||||
D(EIDIVZ) = 6
|
||||
D(EHEAP) = 17
|
||||
D(EILLINS) = 18
|
||||
D(EODDZ) = 19
|
||||
D(ECASE) = 20
|
||||
D(EBADMON) = 25
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pid_t getpid(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
int hello(void)
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int isatty(int fd)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int kill(pid_t pid, int sig)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#ifndef LIBSYS_H
|
||||
#define LIBSYS_H
|
||||
|
||||
extern void _sys_rawwrite(unsigned char b);
|
||||
extern unsigned char _sys_rawread(void);
|
||||
|
||||
extern void _sys_write_tty(char c);
|
||||
|
||||
/* extern int _sys_ttyflags; */
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
int creat(const char* path, int mode)
|
||||
{
|
||||
return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
-- $Source$
|
||||
-- $State$
|
||||
-- $Revision$
|
||||
|
||||
local d = ROOTDIR.."plat/nes/libsys/"
|
||||
|
||||
libsys_nes = acklibrary {
|
||||
ACKBUILDFLAGS = {PARENT, "-ansi"},
|
||||
ACKINCLUDES = {"%BINDIR%include"},
|
||||
|
||||
-- ackfile (d.."errno.s"),
|
||||
-- ackfile (d.."_hol0.s"),
|
||||
-- ackfile (d.."_sys_rawread.s"),
|
||||
-- ackfile (d.."_sys_rawwrite.s"),
|
||||
-- ackfile (d.."open.c"),
|
||||
-- ackfile (d.."creat.c"),
|
||||
-- ackfile (d.."close.c"),
|
||||
-- ackfile (d.."read.c"),
|
||||
-- ackfile (d.."write.c"),
|
||||
-- ackfile (d.."brk.c"),
|
||||
-- ackfile (d.."getpid.c"),
|
||||
-- ackfile (d.."kill.c"),
|
||||
-- ackfile (d.."isatty.c"),
|
||||
-- ackfile (d.."lseek.c"),
|
||||
-- ackfile (d.."time.c"),
|
||||
-- ackfile (d.."signal.c"),
|
||||
|
||||
ackfile (d.."hello.c"),
|
||||
|
||||
install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"),
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
int read(int fd, void* buffer, size_t count)
|
||||
{
|
||||
char i;
|
||||
|
||||
/* We're only allowed to read from fd 0, 1 or 2. */
|
||||
|
||||
if ((fd < 0) || (fd > 2))
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Empty buffer? */
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
/* Read one byte. */
|
||||
|
||||
i = _sys_rawread();
|
||||
#if 0
|
||||
if ((i == '\r') && !(_sys_ttyflags & RAW))
|
||||
i = '\n';
|
||||
if (_sys_ttyflags & ECHO)
|
||||
_sys_write_tty(i);
|
||||
#endif
|
||||
if (i == '\r')
|
||||
i = '\n';
|
||||
_sys_write_tty(i);
|
||||
|
||||
*(char*)buffer = i;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "libsys.h"
|
||||
|
||||
sighandler_t signal(int signum, sighandler_t handler)
|
||||
{
|
||||
return SIG_DFL;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include "libsys.h"
|
||||
|
||||
time_t time(time_t* t)
|
||||
{
|
||||
if (t)
|
||||
*t = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/* $Source$
|
||||
* $State$
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "libsys.h"
|
||||
|
||||
void _sys_write_tty(char c)
|
||||
{
|
||||
_sys_rawwrite(c);
|
||||
#if 0
|
||||
if ((c == '\n') && !(_sys_ttyflags & RAW))
|
||||
_sys_rawwrite('\r');
|
||||
#endif
|
||||
if (c == '\n')
|
||||
_sys_rawwrite('\r');
|
||||
}
|
||||
|
||||
int write(int fd, void* buffer, size_t count)
|
||||
{
|
||||
int i;
|
||||
char* p = buffer;
|
||||
|
||||
/* We're only allowed to write to fd 0, 1 or 2. */
|
||||
|
||||
if ((fd < 0) || (fd > 2))
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Write all data. */
|
||||
|
||||
i = 0;
|
||||
while (i < count)
|
||||
{
|
||||
_sys_write_tty(*p++);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
/* No failures. */
|
||||
|
||||
return count;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user