Merge pull request #96 from kernigh/kernigh-emu-1

Fixes to build emulators, ass, int on OpenBSD
This commit is contained in:
David Given 2018-06-20 22:30:01 +02:00 committed by GitHub
commit 60b7d8de6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 47 deletions

View file

@ -1,3 +1,3 @@
This is a copy of the Karl Stenerud's Musashi m68k emulator, available from This is a modified copy of the Karl Stenerud's Musashi m68k emulator,
https://github.com/kstenerud/Musashi. It's MIT licensed and so is compatible available from https://github.com/kstenerud/Musashi. It's MIT licensed
with the ACK. and so is compatible with the ACK.

View file

@ -562,7 +562,6 @@ void m68k_set_instr_hook_callback(void (*callback)(void))
CALLBACK_INSTR_HOOK = callback ? callback : default_instr_hook_callback; CALLBACK_INSTR_HOOK = callback ? callback : default_instr_hook_callback;
} }
#include <stdio.h>
/* Set the CPU type. */ /* Set the CPU type. */
void m68k_set_cpu_type(unsigned int cpu_type) void m68k_set_cpu_type(unsigned int cpu_type)
{ {

View file

@ -1,4 +1,3 @@
The x86emu directory contains a copy of the xorg 8086 emulation library from The x86emu directory contains a modified copy of the xorg 8086 emulation
the X server. It's distributable under the MIT/X11 license, and so is library from the X server. It's distributable under the MIT/X11 license,
compatible with the ACK. and so is compatible with the ACK.

View file

@ -189,7 +189,7 @@ extern "C" { /* Use "C" linkage when in C++ mode */
#endif #endif
extern void x86emu_inc_decoded_inst_len(int x); extern void x86emu_inc_decoded_inst_len(int x);
extern void x86emu_decode_printf(const char *x, ...) _X_ATTRIBUTE_PRINTF(1,2); extern void x86emu_decode_printf(const char *x, ...);
extern void x86emu_just_disassemble(void); extern void x86emu_just_disassemble(void);
extern void x86emu_single_step(void); extern void x86emu_single_step(void);
extern void x86emu_end_instr(void); extern void x86emu_end_instr(void);

View file

@ -39,8 +39,6 @@
#ifndef __X86EMU_REGS_H #ifndef __X86EMU_REGS_H
#define __X86EMU_REGS_H #define __X86EMU_REGS_H
#include <X11/Xfuncproto.h>
/*---------------------- Macros and type definitions ----------------------*/ /*---------------------- Macros and type definitions ----------------------*/
#ifdef PACK #ifdef PACK
@ -331,8 +329,7 @@ extern "C" { /* Use "C" linkage when in C++ mode */
/* Function to log information at runtime */ /* Function to log information at runtime */
void printk(const char *fmt, ...) void printk(const char *fmt, ...);
_X_ATTRIBUTE_PRINTF(1, 2);
#ifdef __cplusplus #ifdef __cplusplus
} /* End of "C" linkage for C++ */ } /* End of "C" linkage for C++ */

View file

@ -369,7 +369,7 @@ end_module() {
*/ */
align(wordsize) ; align(wordsize) ;
setmode(DATA_NUL); set_mode(DATA_NUL);
dump(100); dump(100);
enmd_pro(); enmd_pro();
enmd_glo(); enmd_glo();

View file

@ -280,7 +280,7 @@ int icount(size) {
return amount ; return amount ;
} }
setmode(mode) { set_mode(mode) {
if (datamode==mode) { /* in right mode already */ if (datamode==mode) { /* in right mode already */
switch ( datamode ) { switch ( datamode ) {
@ -302,8 +302,8 @@ setmode(mode) {
default: default:
return ; return ;
} }
setmode(DATA_NUL) ; /* flush current descriptor */ set_mode(DATA_NUL) ; /* flush current descriptor */
setmode(mode) ; set_mode(mode) ;
return; return;
} }
switch(datamode) { /* terminate current mode */ switch(datamode) { /* terminate current mode */
@ -376,7 +376,7 @@ setmode(mode) {
ext8(HEADBSS) ; ext8(HEADBSS) ;
break; break;
default: default:
fatal("Unknown mode in setmode") ; fatal("Unknown mode in set_mode") ;
} }
} }

View file

@ -699,10 +699,10 @@ chkstart() {
if ( absout ) return ; if ( absout ) return ;
if ( !oksizes ) fatal("missing size specification") ; if ( !oksizes ) fatal("missing size specification") ;
setmode(DATA_CONST) ; set_mode(DATA_CONST) ;
extconst((cons_t)0) ; extconst((cons_t)0) ;
databytes= wordsize ; databytes= wordsize ;
setmode(DATA_REP) ; set_mode(DATA_REP) ;
if ( wordsize<ABSSIZE ) { if ( wordsize<ABSSIZE ) {
register factor = ABSSIZE/wordsize - 1 ; register factor = ABSSIZE/wordsize - 1 ;
extadr( (cons_t) factor ) ; extadr( (cons_t) factor ) ;
@ -724,14 +724,14 @@ sizealign(size) cons_t size ; {
align(size) int size ; { align(size) int size ; {
while ( databytes%size ) { while ( databytes%size ) {
setmode(DATA_BYTES) ; set_mode(DATA_BYTES) ;
ext8(0) ; ext8(0) ;
databytes++ ; databytes++ ;
} }
} }
extconst(n) cons_t n ; { extconst(n) cons_t n ; {
setmode(DATA_CONST); set_mode(DATA_CONST);
extword(n); extword(n);
} }
@ -747,7 +747,7 @@ extbss(n) cons_t n ; {
} }
return ; return ;
} }
setmode(DATA_NUL) ; /* flush descriptor */ set_mode(DATA_NUL) ; /* flush descriptor */
objsize= valsize(); objsize= valsize();
if ( objsize==0 ) { if ( objsize==0 ) {
werror("Unexpected end-of-line"); werror("Unexpected end-of-line");
@ -765,18 +765,18 @@ extbss(n) cons_t n ; {
putval(); putval();
amount= n/objsize ; amount= n/objsize ;
if ( amount>1 ) { if ( amount>1 ) {
setmode(DATA_REP); set_mode(DATA_REP);
extadr(amount-1) ; extadr(amount-1) ;
} }
} }
else { else {
n = (n + wordsize - 1) / wordsize; n = (n + wordsize - 1) / wordsize;
while (n > MAXBYTE) { while (n > MAXBYTE) {
setmode(DATA_BSS); set_mode(DATA_BSS);
ext8(MAXBYTE); ext8(MAXBYTE);
n -= MAXBYTE; n -= MAXBYTE;
} }
setmode(DATA_BSS); set_mode(DATA_BSS);
ext8((int) n); ext8((int) n);
} }
} }
@ -787,7 +787,7 @@ extloc(lbp) register locl_t *lbp; {
* assemble a pointer constant from a local label. * assemble a pointer constant from a local label.
* For example con *1 * For example con *1
*/ */
setmode(DATA_IPTR); set_mode(DATA_IPTR);
data_reloc( chp_cast lbp,dataoff,RELLOC); data_reloc( chp_cast lbp,dataoff,RELLOC);
extadr((cons_t)0); extadr((cons_t)0);
} }
@ -800,7 +800,7 @@ extglob(agbp,off) glob_t *agbp; cons_t off; {
* Various relocation has to be prepared here in some cases * Various relocation has to be prepared here in some cases
*/ */
gbp=agbp; gbp=agbp;
setmode(DATA_DPTR); set_mode(DATA_DPTR);
if ( gbp->g_status&DEF ) { if ( gbp->g_status&DEF ) {
extadr(gbp->g_val.g_addr+off); extadr(gbp->g_val.g_addr+off);
} else { } else {
@ -813,7 +813,7 @@ extpro(aprp) proc_t *aprp; {
/* /*
* generate a addres that is defined by a procedure descriptor. * generate a addres that is defined by a procedure descriptor.
*/ */
consiz= ptrsize ; setmode(DATA_UCON); consiz= ptrsize ; set_mode(DATA_UCON);
extarb((int)ptrsize,(long)(aprp->p_num)); extarb((int)ptrsize,(long)(aprp->p_num));
} }
@ -825,7 +825,7 @@ extstring() {
* generate data for a string. * generate data for a string.
*/ */
for(n=strlngth,s=string ; n--; ) { for(n=strlngth,s=string ; n--; ) {
setmode(DATA_BYTES) ; set_mode(DATA_BYTES) ;
ext8(*s++); ext8(*s++);
} }
return ; return ;
@ -839,7 +839,7 @@ extxcon(header) {
* generate data for a floating constant initialized by a string. * generate data for a floating constant initialized by a string.
*/ */
setmode(header); set_mode(header);
s = string ; s = string ;
for (n=strlngth ; n-- ;) { for (n=strlngth ; n-- ;) {
if ( *s==0 ) error("Zero byte in initializer") ; if ( *s==0 ) error("Zero byte in initializer") ;
@ -875,7 +875,7 @@ extvcon(header) {
* generate data for a constant initialized by a string. * generate data for a constant initialized by a string.
*/ */
setmode(header); set_mode(header);
if ( consiz>4 ) { if ( consiz>4 ) {
error("Size of initializer exceeds loader capability") ; error("Size of initializer exceeds loader capability") ;
} }

View file

@ -11,12 +11,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#if __STDC__
#include <time.h>
#endif
#include <sys/times.h> #include <sys/times.h>
#include <errno.h>
extern int errno; /* UNIX error number */ #include <time.h>
#include <unistd.h>
extern int running; /* from main.c */ extern int running; /* from main.c */
extern int fd_limit; /* from io.c */ extern int fd_limit; /* from io.c */
@ -39,10 +37,7 @@ struct timeb { /* non-existing; we use an ad-hoc definition */
#endif /* BSD4_2 */ #endif /* BSD4_2 */
#ifdef SYS_V #ifdef SYS_V
#include <sys/errno.h>
#undef ERANGE /* collision with trap.h */
#include <fcntl.h> #include <fcntl.h>
#include <time.h>
#endif /* SYS_V */ #endif /* SYS_V */
#include <em_abs.h> #include <em_abs.h>
@ -57,13 +52,6 @@ struct timeb { /* non-existing; we use an ad-hoc definition */
#define DUPMASK 0x40 #define DUPMASK 0x40
extern long lseek();
#ifdef SYS_V
extern unsigned int alarm();
extern long time();
extern void sync();
#endif /* SYS_V */
#define INT2SIZE max(wsize, 2L) #define INT2SIZE max(wsize, 2L)
#define INT4SIZE max(wsize, 4L) #define INT4SIZE max(wsize, 4L)
@ -548,6 +536,7 @@ moncall()
LOG(("@m9 Getpid: succeeded, pid = %d", pid)); LOG(("@m9 Getpid: succeeded, pid = %d", pid));
break; break;
#ifdef WANT_MOUNT_UMOUNT
case 21: /* Mount */ case 21: /* Mount */
dsp1 = pop_ptr(); dsp1 = pop_ptr();
@ -587,6 +576,7 @@ moncall()
LOG(("@m9 Mount: succeeded, dsp1 = %lu", dsp1)); LOG(("@m9 Mount: succeeded, dsp1 = %lu", dsp1));
} }
break; break;
#endif
case 23: /* Setuid */ case 23: /* Setuid */
@ -612,6 +602,7 @@ moncall()
LOG(("@m9 Getuid(part 2): eff uid = %d", userid)); LOG(("@m9 Getuid(part 2): eff uid = %d", userid));
break; break;
#ifdef WANT_STIME
case 25: /* Stime */ case 25: /* Stime */
tm = pop_int4(); tm = pop_int4();
@ -632,6 +623,7 @@ moncall()
LOG(("@m9 Stime: succeeded, tm = %ld", tm)); LOG(("@m9 Stime: succeeded, tm = %ld", tm));
} }
break; break;
#endif
case 26: /* Ptrace */ case 26: /* Ptrace */

View file

@ -25,3 +25,8 @@
* seems to be the standard that won. --- dtrg */ * seems to be the standard that won. --- dtrg */
//#define WANT_SGTTY //#define WANT_SGTTY
/* FIXME: Uncomment to enable these calls in moncalls.c */
//#define WANT_MOUNT_UMOUNT
//#define WANT_STIME