diff options
| author | kx <kx@radix-linux.su> | 2026-10-09 18:00:15 +0300 |
|---|---|---|
| committer | kx <kx@radix-linux.su> | 2026-10-09 18:00:15 +0300 |
| commit | 065da3509019b15dd0e678072e6be629e5330bef (patch) | |
| tree | 69c934c9e786ac048b4fbe8f4c4c5571661521f4 /sysroot | |
| parent | d130fe27fa753be02ed76fd9b277aa3c3d928eb9 (diff) | |
| download | libmcpu-0.4.0.tar.xz | |
Version 0.4.00.4.0
Diffstat (limited to 'sysroot')
| -rw-r--r-- | sysroot/Makefile.am | 41 | ||||
| -rw-r--r-- | sysroot/README | 52 | ||||
| -rw-r--r-- | sysroot/etc/mcpu-ld.conf | 18 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/dirent.h | 23 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/errno.h | 155 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/fcntl.h | 50 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/mpu-errno.h | 42 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/select.h | 18 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/stat.h | 34 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/syscall.h | 47 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/time.h | 22 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/types.h | 16 | ||||
| -rw-r--r-- | sysroot/include/sys/asm/unistd.h | 23 | ||||
| -rw-r--r-- | sysroot/usr/src/mcpu/crt/crt0.S | 22 | ||||
| -rw-r--r-- | sysroot/usr/src/mcpu/crt/crt1.S | 58 | ||||
| -rw-r--r-- | sysroot/usr/src/mcpu/crt/crti.S | 67 | ||||
| -rw-r--r-- | sysroot/usr/src/mcpu/crt/crtn.S | 20 |
17 files changed, 708 insertions, 0 deletions
diff --git a/sysroot/Makefile.am b/sysroot/Makefile.am new file mode 100644 index 0000000..6285067 --- /dev/null +++ b/sysroot/Makefile.am @@ -0,0 +1,41 @@ + +mcpuconfdir = @MCPU_ETCDIR@ + +dist_mcpuconf_DATA = etc/mcpu-ld.conf + +crt_srcdir = $(srcdir)/usr/src/mcpu/crt +crt_builddir = $(builddir)/lib/mcpu + +crt_objects = $(crt_builddir)/crt0.o \ + $(crt_builddir)/crt1.o \ + $(crt_builddir)/crti.o \ + $(crt_builddir)/crtn.o + +mcpucrtobjectsdir = @MCPU_ROOT@/lib/mcpu +nodist_mcpucrtobjects_DATA = $(crt_objects) + +all-local: $(crt_objects) + +$(crt_builddir)/crt0.o: $(crt_srcdir)/crt0.S $(top_builddir)/utils/mcpu-as + $(MKDIR_P) $(crt_builddir) + $(top_builddir)/utils/mcpu-as -o $@ $(crt_srcdir)/crt0.S + +$(crt_builddir)/crt1.o: $(crt_srcdir)/crt1.S $(top_builddir)/utils/mcpu-as + $(MKDIR_P) $(crt_builddir) + $(top_builddir)/utils/mcpu-as -o $@ $(crt_srcdir)/crt1.S + +$(crt_builddir)/crti.o: $(crt_srcdir)/crti.S $(top_builddir)/utils/mcpu-as + $(MKDIR_P) $(crt_builddir) + $(top_builddir)/utils/mcpu-as -o $@ $(crt_srcdir)/crti.S + +$(crt_builddir)/crtn.o: $(crt_srcdir)/crtn.S $(top_builddir)/utils/mcpu-as + $(MKDIR_P) $(crt_builddir) + $(top_builddir)/utils/mcpu-as -o $@ $(crt_srcdir)/crtn.S + +EXTRA_DIST = README \ + usr/src/mcpu/crt/crt0.S \ + usr/src/mcpu/crt/crt1.S \ + usr/src/mcpu/crt/crti.S \ + usr/src/mcpu/crt/crtn.S + +CLEANFILES = $(crt_objects) diff --git a/sysroot/README b/sysroot/README new file mode 100644 index 0000000..93401f8 --- /dev/null +++ b/sysroot/README @@ -0,0 +1,52 @@ + +MCPU sysroot source tree +======================== + +This directory is the canonical build-time source image of the target MCPU +system root. It contains target-facing ABI/configuration material and CRT +sources; it does not contain manual examples or regression-only emulators. + +Runtime-root configuration +-------------------------- + +The canonical LibMCPU runtime-root configuration source is: + + sysroot/etc/mcpu-ld.conf + +`make install` installs it as: + + <MCPU-root>/etc/mcpu-ld.conf + +where `<MCPU-root>` is the configured target MCPU root (normally +`$(libdir)/mcpu`). The installed runtime path is unchanged; only source-tree +ownership now follows the sysroot layout. + +Assembler ABI headers +--------------------- + +The canonical public assembler ABI headers are: + + sysroot/include/sys/asm/ + +They are the only source used by the LibMCPU build to install +`<MCPU-root>/include/sys/asm/` and by regression tests that validate the public +assembler ABI. + +HLL CRT +------- + +The canonical LibMCPU CRT assembler sources are: + + sysroot/usr/src/mcpu/crt/ + +They are assembled out-of-tree into: + + $builddir/sysroot/lib/mcpu/ + +and `make install` installs `crt0.o`, `crt1.o`, `crti.o`, and `crtn.o` under: + + <MCPU-root>/lib/mcpu/ + +The target sysroot intentionally contains no `libc-stub` or `hll-emul` +development trees. HLL/CRT regression fixtures belong to `tests/fixtures/`; +real MCPU Libc and compiler-output examples are separate projects/packages. diff --git a/sysroot/etc/mcpu-ld.conf b/sysroot/etc/mcpu-ld.conf new file mode 100644 index 0000000..cd3ecbe --- /dev/null +++ b/sysroot/etc/mcpu-ld.conf @@ -0,0 +1,18 @@ +/* + * LibMCPU linker/runtime configuration. + * + * Effective root of the MCPU system library tree. + * + * The default is not stored as an absolute installation path in this file. + * At run time mcpu-ld and mcpu-run locate their real executable, take the + * parent of its executable directory as the MCPU installation root, and use + * <runtime-root>/lib. A higher-priority system or per-user configuration may + * replace that path completely by defining MCPU_LD_SYSTEM_LIBRARY_PATH. + * Set an empty value in an override configuration to disable the configured + * system library tree. + * + * Example override: + * MCPU_LD_SYSTEM_LIBRARY_PATH = $HOME/mcpu-next/lib; + */ + +/* MCPU_LD_SYSTEM_LIBRARY_PATH = $HOME/mcpu-next/lib; */ diff --git a/sysroot/include/sys/asm/dirent.h b/sysroot/include/sys/asm/dirent.h new file mode 100644 index 0000000..d761bf6 --- /dev/null +++ b/sysroot/include/sys/asm/dirent.h @@ -0,0 +1,23 @@ + +#ifndef __MCPU_SYS_ASM_DIRENT_H +#define __MCPU_SYS_ASM_DIRENT_H + +/* Fixed external MCPU assembler ABI corresponding to struct __cpu_dirent. */ +#define __MCPU_DIRENT_SIZE 288 +#define __MCPU_DIRENT_D_INO 0 +#define __MCPU_DIRENT_D_OFF 8 +#define __MCPU_DIRENT_D_RECLEN 16 +#define __MCPU_DIRENT_D_TYPE 24 +#define __MCPU_DIRENT_D_NAME 32 +#define __MCPU_DIRENT_NAME_SIZE 256 + +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 + +#endif /* __MCPU_SYS_ASM_DIRENT_H */ diff --git a/sysroot/include/sys/asm/errno.h b/sysroot/include/sys/asm/errno.h new file mode 100644 index 0000000..f018923 --- /dev/null +++ b/sysroot/include/sys/asm/errno.h @@ -0,0 +1,155 @@ + +#ifndef __MCPU_SYS_ASM_ERRNO_H +#define __MCPU_SYS_ASM_ERRNO_H + +/* + * Stable MCPU system-call error numbers. + * + * These are MCPU ABI values. They are not HOST errno numbers even when + * the numeric values happen to coincide on a particular HOST system. + */ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Invalid system call number */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ + +#define EWOULDBLOCK EAGAIN /* Operation would block */ + +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK /* File locking deadlock */ + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Cannot access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted syscall should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ +#define ERFKILL 132 /* Operation not possible due to RF-kill */ +#define EHWPOISON 133 /* Memory page has hardware error */ +#define EFTYPE 134 /* Wrong file type for intended operation */ + +#define ENOTSUP EOPNOTSUPP /* Operation not supported */ + +#define EUNKNOWN 4095 /* Unknown or unmapped HOST error */ + +#endif /* __MCPU_SYS_ASM_ERRNO_H */ diff --git a/sysroot/include/sys/asm/fcntl.h b/sysroot/include/sys/asm/fcntl.h new file mode 100644 index 0000000..921c3b7 --- /dev/null +++ b/sysroot/include/sys/asm/fcntl.h @@ -0,0 +1,50 @@ + +#ifndef __MCPU_SYS_ASM_FCNTL_H +#define __MCPU_SYS_ASM_FCNTL_H + +/* MCPU open(2) ABI flags. They are guest values, not HOST O_* values. */ +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#define O_CREAT 00000100 +#define O_EXCL 00000200 +#define O_NOCTTY 00000400 +#define O_TRUNC 00001000 +#define O_APPEND 00002000 +#define O_NONBLOCK 00004000 + +/* MCPU pipe2(2) descriptor-creation flag. */ +#define O_CLOEXEC 02000000 + +/* MCPU fcntl(2) commands. These are guest ABI values. */ +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 + +/* Guest descriptor flags. */ +#define FD_CLOEXEC 1 + +/* MCPU permission/mode bits used by open/creat/mkdir/chmod/fchmod. */ +#define S_ISUID 00004000 +#define S_ISGID 00002000 +#define S_ISVTX 00001000 + +#define S_IRWXU 00000700 +#define S_IRUSR 00000400 +#define S_IWUSR 00000200 +#define S_IXUSR 00000100 + +#define S_IRWXG 00000070 +#define S_IRGRP 00000040 +#define S_IWGRP 00000020 +#define S_IXGRP 00000010 + +#define S_IRWXO 00000007 +#define S_IROTH 00000004 +#define S_IWOTH 00000002 +#define S_IXOTH 00000001 + +#endif /* __MCPU_SYS_ASM_FCNTL_H */ diff --git a/sysroot/include/sys/asm/mpu-errno.h b/sysroot/include/sys/asm/mpu-errno.h new file mode 100644 index 0000000..3f42751 --- /dev/null +++ b/sysroot/include/sys/asm/mpu-errno.h @@ -0,0 +1,42 @@ + +#ifndef __MCPU_SYS_ASM_MPU_ERRNO_H +#define __MCPU_SYS_ASM_MPU_ERRNO_H + +/* + * MPU -- Math Processor Unit error numbers. + * + * These values describe the error-state registers of the MCPU mathematical + * coprocessor and intentionally preserve the LibMPU 1.0.25 names and values. + */ +#define __EUNKNOWN__ 0 /* Unknown error type */ + +/* Integer error types. */ +#define __I_ESIZE__ 1 /* Invalid size of operand(s) */ +#define __I_ESHIFT__ 2 /* Invalid number of shifts */ +#define __I_ENUMBER__ 3 /* Invalid number */ +#define __I_ERADIX__ 4 /* Invalid radix */ +#define __I_MAX_ERRNO 5 + +/* Real error types. */ +#define __R_ESIZE__ 1 /* Invalid size of operand(s) */ +#define __R_ETRUNC__ 2 /* Invalid number of TRUNC bits */ +#define __R_MAX_ERRNO 3 + +/* Complex error types. */ +#define __C_EDIVZEROBYZERO__ 1 /* Complex division by zero */ +#define __C_ELOGOFZERO__ 2 /* LOG of zero magnitude */ +#define __C_EPOWOFZERO__ 3 /* POW of zero magnitude */ +#define __C_MAX_ERRNO 4 + +/* Math error types. */ +#define __DOMAIN__ 1 /* Argument domain error */ +#define __SING__ 2 /* Argument singularity */ +#define __OVERFLOW__ 3 /* Overflow range error */ +#define __UNDERFLOW__ 4 /* Underflow range error */ +#define __TLOSS__ 5 /* Total loss of precision */ +#define __PLOSS__ 6 /* Partial loss of precision */ +#define __INVALID__ 7 /* Invalid operation */ +#define __INEXACT__ 8 /* Inexact result */ +#define __M_MAX_ERRNO 9 + +#endif /* __MCPU_SYS_ASM_MPU_ERRNO_H */ diff --git a/sysroot/include/sys/asm/select.h b/sysroot/include/sys/asm/select.h new file mode 100644 index 0000000..2e3c8d1 --- /dev/null +++ b/sysroot/include/sys/asm/select.h @@ -0,0 +1,18 @@ + +#ifndef __MCPU_SYS_ASM_SELECT_H +#define __MCPU_SYS_ASM_SELECT_H + +#include <sys/asm/time.h> + +/* MCPU select(2) descriptor-set ABI. The set covers all 256 guest fd values. */ +#define __MCPU_FD_SETSIZE 256 +#define __MCPU_FD_SET_WORDS 4 +#define __MCPU_FD_SET_SIZE 32 + +/* A set is four target-order u64 words. Bit n selects guest fd n. */ +#define __MCPU_FD_SET_WORD0 0 +#define __MCPU_FD_SET_WORD1 8 +#define __MCPU_FD_SET_WORD2 16 +#define __MCPU_FD_SET_WORD3 24 + +#endif /* __MCPU_SYS_ASM_SELECT_H */ diff --git a/sysroot/include/sys/asm/stat.h b/sysroot/include/sys/asm/stat.h new file mode 100644 index 0000000..dd83d94 --- /dev/null +++ b/sysroot/include/sys/asm/stat.h @@ -0,0 +1,34 @@ + +#ifndef __MCPU_SYS_ASM_STAT_H +#define __MCPU_SYS_ASM_STAT_H + +/* Fixed external MCPU assembler ABI layout corresponding to struct __cpu_stat. */ +#define __MCPU_STAT_SIZE 128 +#define __MCPU_STAT_ST_DEV 0 +#define __MCPU_STAT_ST_INO 8 +#define __MCPU_STAT_ST_MODE 16 +#define __MCPU_STAT_ST_NLINK 24 +#define __MCPU_STAT_ST_UID 32 +#define __MCPU_STAT_ST_GID 40 +#define __MCPU_STAT_ST_RDEV 48 +#define __MCPU_STAT_ST_SIZE 56 +#define __MCPU_STAT_ST_BLKSIZE 64 +#define __MCPU_STAT_ST_BLOCKS 72 +#define __MCPU_STAT_ST_ATIME_SEC 80 +#define __MCPU_STAT_ST_ATIME_NSEC 88 +#define __MCPU_STAT_ST_MTIME_SEC 96 +#define __MCPU_STAT_ST_MTIME_NSEC 104 +#define __MCPU_STAT_ST_CTIME_SEC 112 +#define __MCPU_STAT_ST_CTIME_NSEC 120 + +/* MCPU st_mode file-type bits. */ +#define S_IFMT 000170000 +#define S_IFIFO 000010000 +#define S_IFCHR 000020000 +#define S_IFDIR 000040000 +#define S_IFBLK 000060000 +#define S_IFREG 000100000 +#define S_IFLNK 000120000 +#define S_IFSOCK 000140000 + +#endif /* __MCPU_SYS_ASM_STAT_H */ diff --git a/sysroot/include/sys/asm/syscall.h b/sysroot/include/sys/asm/syscall.h new file mode 100644 index 0000000..9d5d630 --- /dev/null +++ b/sysroot/include/sys/asm/syscall.h @@ -0,0 +1,47 @@ + +#ifndef __MCPU_SYS_ASM_SYSCALL_H +#define __MCPU_SYS_ASM_SYSCALL_H + +/* MCPU system call numbers. */ +#define __NR_brk 10 +#define __NR_gettimeofday 0x01c +#define __NR_clock_getres 0x021 +#define __NR_clock_gettime 0x022 +#define __NR_nanosleep 0x030 +#define __NR_clock_nanosleep 0x031 + +#define __NR_read 0x100 +#define __NR_write 0x101 +#define __NR_lseek 0x102 +#define __NR_open 0x103 +#define __NR_creat 0x104 +#define __NR_close 0x105 +#define __NR_link 0x106 +#define __NR_unlink 0x107 +#define __NR_chdir 0x108 +#define __NR_mkdir 0x109 +#define __NR_chmod 0x10b +#define __NR_chown 0x10c +#define __NR_access 0x10f +#define __NR_rename 0x111 +#define __NR_rmdir 0x112 +#define __NR_symlink 0x113 +#define __NR_readlink 0x114 + +#define __NR_stat 0x115 +#define __NR_fstat 0x116 +#define __NR_lstat 0x117 +#define __NR_fcntl 0x119 +#define __NR_pipe2 0x11a +#define __NR_getdents 0x11d +#define __NR_select 0x11e +#define __NR_fsync 0x120 +#define __NR_truncate 0x121 +#define __NR_ftruncate 0x122 +#define __NR_fchmod 0x123 +#define __NR_fchown 0x124 +#define __NR_fchdir 0x125 +#define __NR_dup 0x126 +#define __NR_dup2 0x127 + +#endif /* __MCPU_SYS_ASM_SYSCALL_H */ diff --git a/sysroot/include/sys/asm/time.h b/sysroot/include/sys/asm/time.h new file mode 100644 index 0000000..38932d5 --- /dev/null +++ b/sysroot/include/sys/asm/time.h @@ -0,0 +1,22 @@ + +#ifndef __MCPU_SYS_ASM_TIME_H +#define __MCPU_SYS_ASM_TIME_H + +/* HOST-independent MCPU clock IDs. */ +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 + +/* MCPU clock_nanosleep(2) flag. */ +#define TIMER_ABSTIME 1 + +/* Fixed MCPU timeval ABI: two signed 64-bit fields. */ +#define __MCPU_TIMEVAL_SIZE 16 +#define __MCPU_TIMEVAL_TV_SEC 0 +#define __MCPU_TIMEVAL_TV_USEC 8 + +/* Fixed MCPU timespec ABI: two signed 64-bit fields. */ +#define __MCPU_TIMESPEC_SIZE 16 +#define __MCPU_TIMESPEC_TV_SEC 0 +#define __MCPU_TIMESPEC_TV_NSEC 8 + +#endif /* __MCPU_SYS_ASM_TIME_H */ diff --git a/sysroot/include/sys/asm/types.h b/sysroot/include/sys/asm/types.h new file mode 100644 index 0000000..7866f0f --- /dev/null +++ b/sysroot/include/sys/asm/types.h @@ -0,0 +1,16 @@ + +#ifndef __MCPU_SYS_ASM_TYPES_H +#define __MCPU_SYS_ASM_TYPES_H + +/* Scalar widths of the descriptor-I/O syscall ABI. */ +#define __MCPU_FD_BITS 32 +#define __MCPU_SIZE_BITS 64 +#define __MCPU_SSIZE_BITS 64 +#define __MCPU_OFF_BITS 64 +#define __MCPU_MODE_BITS 32 +#define __MCPU_UID_BITS 64 +#define __MCPU_GID_BITS 64 +#define __MCPU_ID_NO_CHANGE -1 +#define __MCPU_PTR_BITS 64 + +#endif /* __MCPU_SYS_ASM_TYPES_H */ diff --git a/sysroot/include/sys/asm/unistd.h b/sysroot/include/sys/asm/unistd.h new file mode 100644 index 0000000..4ff629c --- /dev/null +++ b/sysroot/include/sys/asm/unistd.h @@ -0,0 +1,23 @@ + +#ifndef __MCPU_SYS_ASM_UNISTD_H +#define __MCPU_SYS_ASM_UNISTD_H + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* pipe2(2) writes two u64 guest descriptors to this fixed output array. */ +#define __MCPU_PIPEFD_SIZE 16 +#define __MCPU_PIPEFD_READ 0 +#define __MCPU_PIPEFD_WRITE 8 + +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#endif /* __MCPU_SYS_ASM_UNISTD_H */ diff --git a/sysroot/usr/src/mcpu/crt/crt0.S b/sysroot/usr/src/mcpu/crt/crt0.S new file mode 100644 index 0000000..47a0bc0 --- /dev/null +++ b/sysroot/usr/src/mcpu/crt/crt0.S @@ -0,0 +1,22 @@ +; MCPU HLL PROGRAM adapter. + +.global __mcpu_crt_startup +.global main + +.text +__mcpu_crt_hll_program: +_start_life: + CALL __mcpu_crt_startup + + ; Persistent McpuStartup is again at top-level SP after RET. + LDSP r64@0x7fe00, 8 + LDSP r64@0x7fe08, 16 + + ; main(int64 argc, PTR64 argv) + ADJSP -16 + STSP 0, r64@0x7fe00 + STSP 8, r64@0x7fe08 + CALL main + ADJSP 16 + + EXIT r32@0x7fffc diff --git a/sysroot/usr/src/mcpu/crt/crt1.S b/sysroot/usr/src/mcpu/crt/crt1.S new file mode 100644 index 0000000..34880e1 --- /dev/null +++ b/sysroot/usr/src/mcpu/crt/crt1.S @@ -0,0 +1,58 @@ +; MCPU HLL MODEL adapter. + +.global __mcpu_crt_startup +.global init +.global life + +.init +__mcpu_crt_hll_model: +_start: + CALL __mcpu_crt_startup + + ; init(int64 argc, PTR64 argv) + LDSP r64@0x7fe00, 8 + LDSP r64@0x7fe08, 16 + ADJSP -16 + STSP 0, r64@0x7fe00 + STSP 8, r64@0x7fe08 + CALL init + ADJSP 16 + + CLR r32@0x7fe10 + ICMP r32@0x7fffc, r32@0x7fe10 + JZ .L_init_ok + EXIT r32@0x7fffc + +.L_init_ok: + END + +.text +_life: +.L_life_loop: + CALL life + + ; LIFE_CONTINUE == INT32_MIN == -2147483648. + LDI r32@0x7fe10, -2147483648 + ICMP r32@0x7fffc, r32@0x7fe10 + JZ .L_life_continue + + CLR r32@0x7fe10 + ICMP r32@0x7fffc, r32@0x7fe10 + JZ .L_life_end + JS .L_life_reserved + + ; Positive status is a MODEL error. + EXIT r32@0x7fffc + +.L_life_continue: + END + JMP .L_life_loop + +.L_life_end: + EXIT r32@0x7fffc + +.L_life_reserved: + ; Negative values other than INT32_MIN are reserved by ABI v1. + ; Current CRT maps programmer-contract violation to status 1. + LDI r32@0x7fe10, 1 + EXIT r32@0x7fe10 diff --git a/sysroot/usr/src/mcpu/crt/crti.S b/sysroot/usr/src/mcpu/crt/crti.S new file mode 100644 index 0000000..042a1b0 --- /dev/null +++ b/sysroot/usr/src/mcpu/crt/crti.S @@ -0,0 +1,67 @@ +; Common MCPU HLL startup support. +; +; This object is part of LibMCPU CRT. It validates McpuStartup, initializes +; the target runtime hooks, and records whether normal HLL lifetime has begun. + +.global __mcpu_libc_init +.global __mcpu_init_array +.global __mcpu_crt_startup +.global __mcpu_crt_state + +.data +.align 8 +__mcpu_crt_state: + .integer 64, 0 + +.text +__mcpu_crt_startup: + ; CALL pushed one 8-byte return PC. McpuStartup therefore begins at + ; SP+8 while this helper is active. + CLR r64@0x7ff00 + STORE __mcpu_crt_state, r64@0x7ff00 + + ; McpuStartup.version == 1. + LDSP r32@0x7ff08, 8 + LDI r32@0x7ff0c, 1 + ICMP r32@0x7ff08, r32@0x7ff0c + JNZ .L_startup_failure + + ; McpuStartup.size == 32. + LDSP r32@0x7ff08, 12 + LDI r32@0x7ff0c, 32 + ICMP r32@0x7ff08, r32@0x7ff0c + JNZ .L_startup_failure + + ; HLL argc is int64. Reject uint64 values with the sign bit set, + ; equivalently argc > 0x7fffffffffffffff. + LDSP r64@0x7ff10, 16 + CLR r64@0x7ff18 + ICMP r64@0x7ff10, r64@0x7ff18 + JS .L_startup_failure + + ; argv must be the canonical persistent array immediately following + ; the 32-byte McpuStartup structure. + LDSP r64@0x7ff20, 24 + LEASP r64@0x7ff28, 40 + ICMP r64@0x7ff20, r64@0x7ff28 + JNZ .L_startup_failure + + ; McpuStartup.reserved is zero in version 1. + LDSP r64@0x7ff30, 32 + ICMP r64@0x7ff30, r64@0x7ff18 + JNZ .L_startup_failure + + CALL __mcpu_libc_init + CALL __mcpu_init_array + + LDI r64@0x7ff00, 1 + STORE __mcpu_crt_state, r64@0x7ff00 + RET + +.L_startup_failure: + ; EXIT must happen with the top-level STACK state restored. Discard + ; this helper's return PC without RET, then terminate. _fini sees + ; PRE_RUNTIME state and therefore performs END only. + ADJSP 8 + LDI r32@0x7ff38, 1 + EXIT r32@0x7ff38 diff --git a/sysroot/usr/src/mcpu/crt/crtn.S b/sysroot/usr/src/mcpu/crt/crtn.S new file mode 100644 index 0000000..aeed44c --- /dev/null +++ b/sysroot/usr/src/mcpu/crt/crtn.S @@ -0,0 +1,20 @@ +; Common MCPU HLL finalization. + +.global __mcpu_crt_state +.global fini +.global __mcpu_fini_array +.global __mcpu_libc_fini + +.fini +_fini: + LOAD r64@0x7fd00, __mcpu_crt_state + LDI r64@0x7fd08, 1 + ICMP r64@0x7fd00, r64@0x7fd08 + JNZ .L_pre_runtime + + CALL fini + CALL __mcpu_fini_array + CALL __mcpu_libc_fini + +.L_pre_runtime: + END |
