Browse Source

All single-source added and test compiling/linking. It does not means that every program runs as expected. Libsec, libmp and libmach are patched to bypass compiling/linking process. Libmach differs from elf64 specification in kernel, so programs that use it probably won't work. TODO: add programs with their own subdirs to stuff.

Elbing 8 years ago
parent
commit
28685094f9

+ 9 - 7
sys/src/cmd/cmd.json

@@ -22,16 +22,11 @@
 	"-static",
 	"-e_main",
 	"-L../../../amd64/lib",
-	"-l9p",
-	"-lauth",
-	"-lauthsrv",
 	"-lavl",
 	"-lbin",
-	"-lbio",
 	"-lcomplete",
 	"-lcontrol",
 	"-ldisk",
-	"-ldraw",
 	"-lflate",
 	"-lframe",
 	"-lgeometry",
@@ -40,18 +35,25 @@
 	"-lip",
 	"-ll",
 	"-llex",
-	"-lmach",
 	"-lmemdraw",
 	"-lmemlayer",
-	"-lmp",
+	"-ldraw",
 	"-lndb",
 	"-lplumb",
 	"-lregexp",
 	"-lstdio",
 	"-lString",
 	"-lsunrpc",
+	"-l9p",
+	"-lauth",
+	"-lauthsrv",
+	"-lsec",
+	"-lauth",
+	"-lmp",
 	"-lthread",
 	"-lventi",
+	"-lmach",
+	"-lbio",
 	"-lc"
     ],
     "Post": [

+ 0 - 1
sys/src/libc/klibc.json

@@ -162,7 +162,6 @@
 	"port/cistrstr.c",
 	"port/charstod.c",
 	"port/cleanname.c",
-	"port/crypt.c",
 	"port/ctype.c",
 	"port/encodefmt.c",
 	"port/execl.c",

+ 0 - 1
sys/src/libc/libc.json

@@ -162,7 +162,6 @@
 	"port/cistrstr.c",
 	"port/charstod.c",
 	"port/cleanname.c",
-	"port/crypt.c",
 	"port/ctype.c",
 	"port/encodefmt.c",
 	"port/execl.c",

+ 1 - 1
sys/src/libmach/6.c

@@ -13,7 +13,7 @@
 #include <u.h>
 #include <libc.h>
 #include <bio.h>
-#include "/amd64/include/ureg.h"
+#include <ureg.h>
 #include <mach.h>
 
 #define	REGOFF(x)	offsetof(struct Ureg, x)

+ 23 - 0
sys/src/libmach/libmach.json

@@ -0,0 +1,23 @@
+{
+	"Name": "libmach",
+	"Library": "libmach.a",
+	"Include": ["../lib.json"],
+	"Pre": [
+	],
+    "SourceFiles": [
+	"6.c",
+	"6obj.c",
+	"8db.c",
+	"access.c",
+	"executable.c",
+	"machdata.c",
+	"map.c",
+	"obj.c",
+	"setmach.c",
+	"swap.c",
+	"sym.c"
+	],
+	"Post": [
+	"ar rv ../../../amd64/lib/libmach.a *.o"
+	]
+}

+ 9 - 9
sys/src/libmach/obj.c

@@ -62,16 +62,16 @@ struct	Obj		/* functions to handle each intermediate (.$O) file */
 
 static Obj	obj[] =
 {			/* functions to identify and parse each type of obj */
-	[Obj68020]	"68020 .2",	_is2, _read2,
+//	[Obj68020]	"68020 .2",	_is2, _read2,
 	[ObjAmd64]	"amd64 .6",	_is6, _read6,
-	[ObjArm]	"arm .5",	_is5, _read5,
-	[ObjAlpha]	"alpha .7",	_is7, _read7,
-	[Obj386]	"386 .8",	_is8, _read8,
-	[ObjSparc]	"sparc .k",	_isk, _readk,
-	[ObjPower]	"power .q",	_isq, _readq,
-	[ObjMips]	"mips .v",	_isv, _readv,
-	[ObjSparc64]	"sparc64 .u",	_isu, _readu,
-	[ObjPower64]	"power64 .9",	_is9, _read9,
+//	[ObjArm]	"arm .5",	_is5, _read5,
+//	[ObjAlpha]	"alpha .7",	_is7, _read7,
+//	[Obj386]	"386 .8",	_is8, _read8,
+//	[ObjSparc]	"sparc .k",	_isk, _readk,
+//	[ObjPower]	"power .q",	_isq, _readq,
+//	[ObjMips]	"mips .v",	_isv, _readv,
+//	[ObjSparc64]	"sparc64 .u",	_isu, _readu,
+//	[ObjPower64]	"power64 .9",	_is9, _read9,
 	[Maxobjtype]	0, 0
 };
 

+ 6 - 1
sys/src/libmach/setmach.c

@@ -37,6 +37,7 @@ extern	Machdata	mipsmach, mipsmachle, sparcmach, m68020mach, i386mach,
  */
 Machtab	machines[] =
 {
+#ifdef FOO
 	{	"68020",			/*68020*/
 		F68020,
 		F68020B,
@@ -103,12 +104,14 @@ Machtab	machines[] =
 		AI8086,
 		&mi386,
 		&i386mach,	},
+#endif
 	{	"amd64",			/*amd64*/
 		FAMD64,
 		FAMD64B,
 		AAMD64,
 		&mamd64,
 		&i386mach,	},
+#ifdef FOO
 	{	"arm",				/*ARM*/
 		FARM,
 		FARMB,
@@ -139,6 +142,7 @@ Machtab	machines[] =
 		ASPARC64,
 		&msparc64,
 		&sparc64mach,	},
+#endif
 	{	0		},		/*the terminator*/
 };
 
@@ -165,13 +169,14 @@ int
 machbyname(char *name)
 {
 	Machtab *mp;
-
+#ifdef FOO
 	if (!name) {
 		asstype = AMIPS;
 		machdata = &mipsmach;
 		mach = &mmips;
 		return 1;
 	}
+#endif
 	for (mp = machines; mp->name; mp++){
 		if (strcmp(mp->name, name) == 0) {
 			asstype = mp->asstype;

+ 19 - 17
sys/src/libmp/libmp.json

@@ -5,36 +5,38 @@
 	"Pre": [
 	],
     "SourceFiles": [
-	"port/mpaux.c",
-	"port/mpfmt.c",
-	"port/strtomp.c",
-	"port/mptobe.c",
-	"port/mptole.c",
 	"port/betomp.c",
+	"port/crt.c",
+	"port/crttest.c",
 	"port/letomp.c",
 	"port/mpadd.c",
-	"port/mpsub.c",
+	"port/mpaux.c",
 	"port/mpcmp.c",
-	"port/mpfactorial.c",
-	"port/mpmul.c",
-	"port/mpleft.c",
-	"port/mpright.c",
-	"port/mpvecadd.c",
-	"port/mpvecsub.c",
-	"port/mpvecdigmuladd.c",
-	"port/mpveccmp.c",
 	"port/mpdigdiv.c",
 	"port/mpdiv.c",
+	"port/mpeuclid.c",
 	"port/mpexp.c",
-	"port/mpmod.c",
 	"port/mpextendedgcd.c",
+	"port/mpfactorial.c",
+	"port/mpfmt.c",
 	"port/mpinvert.c",
+	"port/mpleft.c",
+	"port/mpmod.c",
+	"port/mpmul.c",
 	"port/mprand.c",
-	"port/crt.c",
+	"port/mpright.c",
+	"port/mpsub.c",
+	"port/mptobe.c",
 	"port/mptoi.c",
+	"port/mptole.c",
 	"port/mptoui.c",
+	"port/mptouv.c",
 	"port/mptov.c",
-	"port/mptouv.c"
+	"port/mpvecadd.c",
+	"port/mpveccmp.c",
+	"port/mpvecdigmuladd.c",
+	"port/mpvecsub.c",
+	"port/strtomp.c"
 	],
 	"Post": [
 	"ar rv ../../../amd64/lib/libmp.a *.o"

+ 3 - 0
sys/src/libs.json

@@ -21,11 +21,14 @@
 	"/sys/src/libhtml/libhtml.json",
 	"/sys/src/libhttpd/libhttpd.json",
 	"/sys/src/liblex/liblex.json",
+	"/sys/src/libmach/libmach.json",
 	"/sys/src/libmemdraw/libmemdraw.json",
 	"/sys/src/libmemlayer/libmemlayer.json",
+	"/sys/src/libmp/libmp.json",
 	"/sys/src/libndb/libndb.json",
 	"/sys/src/libplumb/libplumb.json",
 	"/sys/src/libregexp/libregexp.json",
+	"/sys/src/libsec/libsec.json",
 	"/sys/src/libstdio/libstdio.json",
 	"/sys/src/libsunrpc/libsunrpc.json",
 	"/sys/src/libthread/libthread.json",

+ 67 - 0
sys/src/libsec/libsec.json

@@ -0,0 +1,67 @@
+{
+	"Name": "libsec",
+	"Library": "libsec.a",
+	"Include": ["../lib.json"],
+	"Pre": [
+	],
+    "SourceFiles": [
+    "port/aes.c",
+	"port/blowfish.c",
+	"port/crypt.c",
+	"port/decodepem.c",
+	"port/des3CBC.c",
+	"port/des3ECB.c",
+	"port/des.c",
+	"port/desCBC.c",
+	"port/desECB.c",
+	"port/desmodes.c",
+	"port/dsaalloc.c",
+	"port/dsagen.c",
+	"port/dsaprimes.c",
+	"port/dsaprivtopub.c",
+	"port/dsasign.c",
+	"port/dsaverify.c",
+	"port/egalloc.c",
+	"port/egdecrypt.c",
+	"port/egencrypt.c",
+	"port/eggen.c",
+	"port/egprivtopub.c",
+	"port/egsign.c",
+	"port/egverify.c",
+	"port/fastrand.c",
+	"port/genprime.c",
+	"port/genrandom.c",
+	"port/gensafeprime.c",
+	"port/genstrongprime.c",
+	"port/hmac.c",
+	"port/md4.c",
+	"port/md5block.c",
+	"port/md5.c",
+	"port/md5pickle.c",
+	"port/nfastrand.c",
+	"port/prng.c",
+	"port/probably_prime.c",
+	"port/rc4.c",
+	"port/readcert.c",
+	"port/rsaalloc.c",
+	"port/rsadecrypt.c",
+	"port/rsaencrypt.c",
+	"port/rsafill.c",
+	"port/rsagen.c",
+	"port/rsaprivtopub.c",
+	"port/sha1block.c",
+	"port/sha1.c",
+	"port/sha1pickle.c",
+	"port/sha2_128.c",
+	"port/sha2_64.c",
+	"port/sha2block128.c",
+	"port/sha2block64.c",
+	"port/smallprimes.c",
+	"port/thumb.c",
+	"port/tlshand.c",
+	"port/x509.c"
+	],
+	"Post": [
+	"ar rv ../../../amd64/lib/libsec.a *.o"
+	]
+}

+ 77 - 0
sys/src/libsec/port/crypt.c

@@ -0,0 +1,77 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+/*
+ *	Data Encryption Standard
+ *	D.P.Mitchell  83/06/08.
+ *
+ *	block_cipher(key, block, decrypting)
+ *
+ *	these routines use the non-standard 7 byte format
+ *	for DES keys.
+ */
+#include <u.h>
+#include <libc.h>
+#include <auth.h>
+#include <libsec.h>
+
+/*
+ * destructively encrypt the buffer, which
+ * must be at least 8 characters long.
+ */
+int
+encrypt(void *key, void *vbuf, int n)
+{
+	uint32_t ekey[32];
+	uint8_t *buf;
+	int i, r;
+
+	if(n < 8)
+		return 0;
+	key_setup(key, ekey);
+	buf = vbuf;
+	n--;
+	r = n % 7;
+	n /= 7;
+	for(i = 0; i < n; i++){
+		block_cipher(ekey, buf, 0);
+		buf += 7;
+	}
+	if(r)
+		block_cipher(ekey, buf - 7 + r, 0);
+	return 1;
+}
+
+/*
+ * destructively decrypt the buffer, which
+ * must be at least 8 characters long.
+ */
+int
+decrypt(void *key, void *vbuf, int n)
+{
+	uint32_t ekey[128];
+	uint8_t *buf;
+	int i, r;
+
+	if(n < 8)
+		return 0;
+	key_setup(key, ekey);
+	buf = vbuf;
+	n--;
+	r = n % 7;
+	n /= 7;
+	buf += n * 7;
+	if(r)
+		block_cipher(ekey, buf - 7 + r, 1);
+	for(i = 0; i < n; i++){
+		buf -= 7;
+		block_cipher(ekey, buf, 1);
+	}
+	return 1;
+}

+ 12 - 0
sys/src/libsec/port/os.h

@@ -0,0 +1,12 @@
+/*
+ * This file is part of the UCB release of Plan 9. It is subject to the license
+ * terms in the LICENSE file found in the top-level directory of this
+ * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
+ * part of the UCB release of Plan 9, including this file, may be copied,
+ * modified, propagated, or distributed except according to the terms contained
+ * in the LICENSE file.
+ */
+
+#include <u.h>
+#include <libc.h>
+