1988-06-22 16:57:09 +00:00
|
|
|
/*
|
|
|
|
Moving system structs between UNIX and EM
|
|
|
|
*/
|
|
|
|
|
1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#include "sysidf.h"
|
|
|
|
#include "v7ioctl.h"
|
|
|
|
#include "global.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "monstruct.h"
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
#include "whatever.h"
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
1991-12-03 11:03:58 +00:00
|
|
|
#if __STDC__
|
|
|
|
#include <time.h>
|
|
|
|
#endif
|
1988-06-22 16:57:09 +00:00
|
|
|
#include <sys/times.h>
|
2005-06-24 22:11:27 +00:00
|
|
|
|
|
|
|
#ifdef WANT_SGTTY
|
1988-06-22 16:57:09 +00:00
|
|
|
#include <sgtty.h>
|
2005-06-24 22:11:27 +00:00
|
|
|
#endif
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef BSD_X /* from system.h */
|
|
|
|
#include <sys/timeb.h>
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* BSD_X */
|
1988-06-22 16:57:09 +00:00
|
|
|
#ifdef SYS_V /* from system.h */
|
|
|
|
struct timeb { /* non-existing; we use an ad-hoc definition */
|
|
|
|
long time;
|
|
|
|
unsigned short millitm;
|
|
|
|
short timezone, dstflag;
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* SYS_V */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
/******** System to EM memory ********/
|
|
|
|
|
|
|
|
PRIVATE mem_stfld(addr, offset, length, val)
|
|
|
|
ptr addr;
|
|
|
|
size offset, length;
|
|
|
|
long val;
|
|
|
|
{
|
|
|
|
mem_stn(addr + offset, val, length);
|
|
|
|
}
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
int stat2mem(ptr addr, struct stat *statb)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
if (memfault(addr, V7st_sz))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7st_dev, (long) statb->st_dev);
|
|
|
|
mem_stfld(addr, V7st_ino, (long) statb->st_ino);
|
|
|
|
mem_stfld(addr, V7st_mode, (long) statb->st_mode);
|
|
|
|
mem_stfld(addr, V7st_nlink, (long) statb->st_nlink);
|
|
|
|
mem_stfld(addr, V7st_uid, (long) statb->st_uid);
|
|
|
|
mem_stfld(addr, V7st_gid, (long) statb->st_gid);
|
|
|
|
mem_stfld(addr, V7st_rdev, (long) statb->st_rdev);
|
|
|
|
mem_stfld(addr, V7st_size, (long) statb->st_size);
|
|
|
|
mem_stfld(addr, V7st_atime, (long) statb->st_atime);
|
|
|
|
mem_stfld(addr, V7st_mtime, (long) statb->st_mtime);
|
|
|
|
mem_stfld(addr, V7st_ctime, (long) statb->st_ctime);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
int timeb2mem(ptr addr, struct timeb *timebb)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
if (memfault(addr, V7tb_sz))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7tb_time, (long) timebb->time);
|
|
|
|
mem_stfld(addr, V7tb_millitm, (long) timebb->millitm);
|
|
|
|
mem_stfld(addr, V7tb_timezone, (long) timebb->timezone);
|
|
|
|
mem_stfld(addr, V7tb_dstflag, (long) timebb->dstflag);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Cut down some clang warnings
Edit C code to reduce warnings from clang. Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().
Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c. Such changes don't silence warnings; I make
such changes while I silence warnings in the same file. In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.
Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning. I wrongly added the `const` in d347207.
For warnings about implicit declarations of functions, the fix is to
declare the function before calling it. For example, my OpenBSD
system needs <sys/wait.h> to declare wait().
In util/int, add "whatever.h" to declare more functions. Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-23 20:06:36 +00:00
|
|
|
int tms2mem(ptr addr, struct tms *tmsb)
|
1988-06-22 16:57:09 +00:00
|
|
|
{
|
|
|
|
if (memfault(addr, V7tms_sz))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7tms_utime, (long) tmsb->tms_utime);
|
|
|
|
mem_stfld(addr, V7tms_stime, (long) tmsb->tms_stime);
|
|
|
|
mem_stfld(addr, V7tms_cutime, (long) tmsb->tms_cutime);
|
|
|
|
mem_stfld(addr, V7tms_cstime, (long) tmsb->tms_cstime);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-06-24 22:11:27 +00:00
|
|
|
#ifdef WANT_SGTTY
|
|
|
|
/* FIXME: see the related fixme in sysidf.h. --- dtrg */
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
int sgttyb2mem(addr, sgttybb)
|
|
|
|
ptr addr;
|
|
|
|
struct sgttyb *sgttybb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7sg_sz))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7sg_ispeed, (long) sgttybb->sg_ispeed);
|
|
|
|
mem_stfld(addr, V7sg_ospeed, (long) sgttybb->sg_ospeed);
|
|
|
|
mem_stfld(addr, V7sg_erase, (long) sgttybb->sg_erase);
|
|
|
|
mem_stfld(addr, V7sg_kill, (long) sgttybb->sg_kill);
|
|
|
|
mem_stfld(addr, V7sg_flags, (long) sgttybb->sg_flags);
|
|
|
|
return 1;
|
|
|
|
}
|
2005-06-24 21:42:11 +00:00
|
|
|
#endif
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef BSD_X /* from system.h */
|
|
|
|
int tchars2mem(addr, tcharsb)
|
|
|
|
ptr addr;
|
|
|
|
struct tchars *tcharsb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7t_sz_tch))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7t_intrc, (long) tcharsb->t_intrc);
|
|
|
|
mem_stfld(addr, V7t_quitc, (long) tcharsb->t_quitc);
|
|
|
|
mem_stfld(addr, V7t_startc, (long) tcharsb->t_startc);
|
|
|
|
mem_stfld(addr, V7t_stopc, (long) tcharsb->t_stopc);
|
|
|
|
mem_stfld(addr, V7t_eofc, (long) tcharsb->t_eofc);
|
|
|
|
mem_stfld(addr, V7t_brkc, (long) tcharsb->t_brkc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef V7IOCTL
|
|
|
|
int ltchars2mem(addr, ltcharsb)
|
|
|
|
ptr addr;
|
|
|
|
struct ltchars *ltcharsb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7t_sz_ltch))
|
|
|
|
return 0;
|
|
|
|
mem_stfld(addr, V7t_suspc, (long) ltcharsb->t_suspc);
|
|
|
|
mem_stfld(addr, V7t_dsuspc, (long) ltcharsb->t_dsuspc);
|
|
|
|
mem_stfld(addr, V7t_rprntc, (long) ltcharsb->t_rprntc);
|
|
|
|
mem_stfld(addr, V7t_flushc, (long) ltcharsb->t_flushc);
|
|
|
|
mem_stfld(addr, V7t_werasc, (long) ltcharsb->t_werasc);
|
|
|
|
mem_stfld(addr, V7t_lnextc, (long) ltcharsb->t_lnextc);
|
|
|
|
return 1;
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* V7IOCTL */
|
|
|
|
#endif /* BSD_X */
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
/******** EM memory to system ********/
|
|
|
|
|
|
|
|
PRIVATE unsigned long mem_ldfld(addr, offset, length)
|
|
|
|
ptr addr;
|
|
|
|
size offset, length;
|
|
|
|
{
|
|
|
|
return mem_ldu(addr + offset, length);
|
|
|
|
}
|
|
|
|
|
2005-06-24 22:11:27 +00:00
|
|
|
#ifdef WANT_SGTTY
|
|
|
|
/* FIXME: see the related fixme in sysidf.h. --- dtrg */
|
|
|
|
|
1988-06-22 16:57:09 +00:00
|
|
|
int mem2sgtty(addr, sgttybb)
|
|
|
|
ptr addr;
|
|
|
|
struct sgttyb *sgttybb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7sg_sz))
|
|
|
|
return 0;
|
|
|
|
sgttybb->sg_ispeed = (char) mem_ldfld(addr, V7sg_ispeed);
|
|
|
|
sgttybb->sg_ospeed = (char) mem_ldfld(addr, V7sg_ospeed);
|
|
|
|
sgttybb->sg_erase = (char) mem_ldfld(addr, V7sg_erase);
|
|
|
|
sgttybb->sg_kill = (char) mem_ldfld(addr, V7sg_kill);
|
|
|
|
sgttybb->sg_flags = (short) mem_ldfld(addr, V7sg_flags);
|
|
|
|
return 1;
|
|
|
|
}
|
2005-06-24 21:42:11 +00:00
|
|
|
#endif
|
1988-06-22 16:57:09 +00:00
|
|
|
|
|
|
|
#ifdef BSD_X /* from system.h */
|
|
|
|
int mem2tchars(addr, tcharsb)
|
|
|
|
ptr addr;
|
|
|
|
struct tchars *tcharsb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7t_sz_tch))
|
|
|
|
return 0;
|
|
|
|
tcharsb->t_intrc = (char) mem_ldfld(addr, V7t_intrc);
|
|
|
|
tcharsb->t_quitc = (char) mem_ldfld(addr, V7t_quitc);
|
|
|
|
tcharsb->t_startc = (char) mem_ldfld(addr, V7t_startc);
|
|
|
|
tcharsb->t_stopc = (char) mem_ldfld(addr, V7t_stopc);
|
|
|
|
tcharsb->t_eofc = (char) mem_ldfld(addr, V7t_eofc);
|
|
|
|
tcharsb->t_brkc = (char) mem_ldfld(addr, V7t_brkc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef V7IOCTL
|
|
|
|
int mem2ltchars(addr, ltcharsb)
|
|
|
|
ptr addr;
|
|
|
|
struct ltchars *ltcharsb;
|
|
|
|
{
|
|
|
|
if (memfault(addr, V7t_sz_ltch))
|
|
|
|
return 0;
|
|
|
|
ltcharsb->t_suspc = (char) mem_ldfld(addr, V7t_suspc);
|
|
|
|
ltcharsb->t_dsuspc = (char) mem_ldfld(addr, V7t_dsuspc);
|
|
|
|
ltcharsb->t_rprntc = (char) mem_ldfld(addr, V7t_rprntc);
|
|
|
|
ltcharsb->t_flushc = (char) mem_ldfld(addr, V7t_flushc);
|
|
|
|
ltcharsb->t_werasc = (char) mem_ldfld(addr, V7t_werasc);
|
|
|
|
ltcharsb->t_lnextc = (char) mem_ldfld(addr, V7t_lnextc);
|
|
|
|
return 1;
|
|
|
|
}
|
1991-12-17 15:28:58 +00:00
|
|
|
#endif /* V7IOCTL */
|
|
|
|
#endif /* BSD_X */
|
1988-06-22 16:57:09 +00:00
|
|
|
|