ref: de356dd855bb912e40a60592d6292d2066351ffd
parent: 16acf605e21e55e8f0520cf54016bfec5291802e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Feb 10 18:07:37 EST 2014
acid: update acid libraries for amd64
--- a/sys/lib/acid/kernel
+++ b/sys/lib/acid/kernel
@@ -34,12 +34,12 @@
while h != 0 do {
complex Image h;
- d=(Dev)(*(devtab+4*h.type));
+ d=(Dev)devtab[h.type];
p = "*closed*";
if h.c != 0 then
p = path(h.c.path);
q = h.qid;
- print (h\X, " ref=", h.ref, " pgref=", h.pgref, "\t#", d.dc\r, h.dev\D, " (",
+ print (h\A, " ref=", h.ref, " pgref=", h.pgref, "\t#", d.dc\r, h.dev\D, " (",
q.path, " ", q.vers\D, " ", q.type\X, ") ", p, "\n");
h = h.hash;
}
@@ -59,12 +59,12 @@
local d, q;
c = (Chan)c;
- d=(Dev)(*(devtab+4*c.type));
+ d= (Dev)devtab[c.type];
q=c.qid;
- print("chan(", c\X, "): ref=", c.ref\D, " #", d.dc\r, c.dev\D, " (", q.path, " ", q.vers\D, " ", q.type\X, ")");
+ print("chan(", c\A, "): ref=", c.ref\D, " #", d.dc\r, c.dev\D, " (", q.path, " ", q.vers\D, " ", q.type\X, ")");
print(" fid=", c.fid\D, " iounit=", c.iounit\D);
if c.ref != 0 then {
- print(" ", path(c.path), " mchan=", c.mchan\X);
+ print(" ", path(c.path), " mchan=", c.mchan\A);
if c.mchan != 0 then {
print(" ", path(c.mchan.path));
}
@@ -176,7 +176,7 @@
}
}
if bad != "" then
- print("chan(", c\X, "):", bad, "\n");
+ print("chan(", c\A, "):", bad, "\n");
}
c = (Chan)c.link;
}
@@ -190,7 +190,7 @@
m = cache.hash[i];
while m != 0 do {
complex Mntcache m;
- print(m\X, " dev ", m.dev\D, " type ", m.type, " qid (",
+ print(m\A, " dev ", m.dev\D, " type ", m.type, " qid (",
m.qid.path, " ", m.qid.vers\D, ")\n");
c = findchan(m.dev, m.type, m.qid.path);
if c != 0 then {
@@ -219,7 +219,7 @@
} else {
s = *(s\s);
}
- print(p\X, " ", p.pid, ": ", *(p.text\s), " ", *(p.user\s), " pc ", p.pc\X, " ", s, " (", *(statename[p.state]\s), ") ut ", p.time[0]\D, " st ", p.time[1]\D, " qpc ", p.qpc\X, "\n");
+ print(p\A, " ", p.pid, ": ", *(p.text\s), " ", *(p.user\s), " pc ", p.pc, " ", s, " (", *(statename[p.state]\s), ") ut ", p.time[0]\D, " st ", p.time[1]\D, " qpc ", p.qpc, "\n");
}
}
@@ -240,6 +240,9 @@
}
KSTACK=4096;
+if objtype=="amd64" then {
+ KSTACK=16*1024;
+}
defn procstksize(p) {
complex Proc p;
@@ -258,7 +261,7 @@
if p.state != 0 then { // 0 is Dead
l = p.sched;
- if objtype=="386" then
+ if objtype=="386" || objtype=="amd64" then
_stk(gotolabel, *l, linkreg(0), 0);
else
_stk(*(l+4), *l, linkreg(0), 0);
@@ -313,7 +316,7 @@
complex Segment s;
if s != 0 then {
- print(s\X, " ", segtypes[s.type&SG_TYPE], " ", s.base\X, "-", s.top\X, " image ", s.image\X, "\n");
+ print(s\A, " ", segtypes[s.type&SG_TYPE], " ", s.base, "-", s.top, " image ", s.image, "\n");
}
}
@@ -362,7 +365,7 @@
}
complex Page pg;
- return (KZERO|(pg.pa+(a%BY2PG)))\X;
+ return (KZERO|(pg.pa+(a%BY2PG)))\A;
}
defn kzero() {
@@ -369,17 +372,27 @@
return main - (main & 0x0FFFFFFF);
}
-// PC only
PTEMAPMEM = (1024*1024);
BY2PG = 4096;
PTEPERTAB = (PTEMAPMEM/BY2PG);
defn up() {
- local mach;
+ if objtype == "386" then {
+ local mach;
- MACHADDR = KZERO+0x15000;
- mach = MACHADDR;
- complex Mach mach;
- return mach.externup;
+ MACHADDR = KZERO+0x15000;
+ mach = MACHADDR;
+ complex Mach mach;
+ return mach.externup;
+ }
+ if objtype == "amd64" then {
+ local proc;
+
+ proc = *R14;
+ complex Proc proc;
+ return proc;
+ }
+ print("up() not implemented for", objtype, "\n");
+ return -1;
}
defn intrcount() {
@@ -397,8 +410,6 @@
}
}
-print("/sys/lib/acid/kernel");
-
defn needacid(s){
print("\trc(\"cd /sys/src/9/", kdir, "; mk ", s, ".acid\")\n");
print("\tinclude(\"/sys/src/9/", kdir, "/", s, ".acid\")\n");
@@ -412,6 +423,10 @@
if objtype == "386" then {
map({"*data", KZERO, 0xffffffff, KZERO});
kdir="pc";
+ }
+ if objtype == "amd64" then {
+ map({"*data", KZERO, 0xffffffffffffffff, KZERO});
+ kdir="pc64";
}
if (objtype == "mips" || objtype == "mips2") then {
kdir = "ch";
--- a/sys/lib/acid/leak
+++ b/sys/lib/acid/leak
@@ -1,7 +1,7 @@
//
// usage: acid -l pool -l leak
//
-include("/sys/src/libc/port/pool.acid");
+include("/sys/src/libc/port/pool." + objchar + ".acid");
defn
dumppool(p, sum)
@@ -9,7 +9,7 @@
complex Pool p;
a = p.arenalist;
- print("A: ", p.arenalist\X, "\n");
+ print("A: ", p.arenalist\A, "\n");
while a != 0 do {
complex Arena a;
dumparena(a, sum);
@@ -25,25 +25,25 @@
atail = A2TB(arena);
complex Bhdr arena;
b = a;
- print("B: ", b\X, " ", atail\X, "\n");
+ print("B: ", b\A, " ", atail\A, "\n");
while b < atail && b.magic != ARENATAIL_MAGIC do {
dumpblock(b, sum);
nb = B2NB(b);
if nb == b then {
- print("B2NB(", b\X, ") = b\n");
+ print("B2NB(", b\A, ") = b\n");
b = atail; // end loop
}
if nb > atail then {
b = (Bhdr)(b+4);
- print("lost at block ", (b-4)\X, ", scanning forward\n");
+ print("lost at block ", (b-4)\A, ", scanning forward\n");
while b < atail && b.magic != ALLOC_MAGIC && b.magic != FREE_MAGIC do
b = (Bhdr)(b+4);
- print("stopped at ", b\X, " ", *b\X, "\n");
+ print("stopped at ", b\A, " ", *b\A, "\n");
}else
b = nb;
}
if b != atail then
- print("found wrong tail to arena ", arena\X, " wanted ", atail\X, "\n");
+ print("found wrong tail to arena ", arena\A, " wanted ", atail\A, "\n");
}
defn
@@ -70,17 +70,26 @@
}
defn
+sxpc(addr)
+{
+ if objtype == "amd64" && addr & 0x80000000 then {
+ return addr | 0xffffffff00000000;
+ }
+ return addr;
+}
+
+defn
dumpblock(addr, sum)
{
complex Bhdr addr;
if addr.magic == ALLOC_MAGIC || (!sum && addr.magic == FREE_MAGIC) then {
- local a, x, s;
+ local a, x, s, allocpc, reallocpc;
a = addr;
complex Alloc a;
- x = addr+sizeofBhdr;
+ x = fmt(addr+sizeofBhdr, 'X');
if addr.magic == ALLOC_MAGIC then {
// for mallocalign()
while *x == ALIGN_MAGIC do {
@@ -87,10 +96,12 @@
x = x + 4;
}
}
+ allocpc=sxpc(x[0]);
+ reallocpc=sxpc(x[1]);
if sum then {
- if *x != lastalloc then {
+ if allocpc != lastalloc then {
emitsum();
- lastalloc = *x;
+ lastalloc = allocpc;
}
lastcount = lastcount+1;
lastsize = lastsize+a.size;
@@ -99,8 +110,8 @@
s = "block";
} else
s = "free";
- print(s, " ", addr\X, " ", a.size\X, " ");
- print(*x\X, " ", *(x+4)\X, " ", *x\a, " ", *(x+4)\a, "\n");
+ print(s, " ", addr\A, " ", a.size\X, " ");
+ print(x[0]\X, " ", x[1]\X, " ", allocpc\a, " ", reallocpc\a, "\n");
}
}
}
@@ -191,3 +202,5 @@
emitsum();
print("==BLOCK END==\n");
}
+
+print("/sys/lib/acid/leak");
--- a/sys/lib/acid/pool
+++ b/sys/lib/acid/pool
@@ -1,4 +1,4 @@
-include("/sys/src/libc/port/pool.acid");
+include("/sys/src/libc/port/pool." + objchar + ".acid");
aggr Byte {
'b' 0 byte;
@@ -308,3 +308,4 @@
return addr;
}
+print("/sys/lib/acid/pool");
--- a/sys/lib/acid/syscall
+++ b/sys/lib/acid/syscall
@@ -80,53 +80,53 @@
syscalls = {
{ 0, {"sysr1", "s", code(0)}},
- { 1, {"_errstr", "s", code(*sys_errstr:arg)}},
- { 2, {"bind", "ssX", code(*sysbind:arg)}},
- { 3, {"chdir", "s", code(*sysbind:arg)}},
- { 4, {"close", "D", code(*sysclose:arg)}},
- { 5, {"dup", "DD", code(*sysdup:arg)}},
- { 6, {"alarm", "D", code(*sysalarm:arg)}},
- { 7, {"exec", "sS", code(*sysexec:arg)}},
- { 8, {"exits", "s", code(*sysexits:arg)}},
- { 9, {"_fsession", "DX", code(*sys_fsession:arg)}},
- {10, {"fauth", "DX", code(*sysfauth:arg)}},
- {11, {"_fstat", "DX", code(*sys_fstat:arg)}},
- {12, {"segbrk", "XX", code(*syssegbrk:arg)}},
- {13, {"_mount", "DsXs", code(*sys_mount:arg)}},
- {14, {"open", "sD", code(*sysopen:arg)}},
- {15, {"_read", "DXD", code(*sys_read:arg)}},
- {16, {"oseek", "DDD", code(*sysoseek:arg)}},
- {17, {"sleep", "D", code(*syssleep:arg)}},
- {18, {"_stat", "sX", code(*sys_stat:arg)}},
- {19, {"rfork", "X", code(*sysstat:arg)}},
- {20, {"_write", "DXD", code(*sys_write:arg)}},
- {21, {"pipe", "X", code(*syspipe:arg)}},
- {22, {"create", "sDO", code(*syscreate:arg)}},
- {23, {"fd2path", "DXD", code(*sysfd2path:arg)}},
- {24, {"brk_", "X", code(*sysbrk_:arg)}},
- {25, {"remove", "s", code(*sysremove:arg)}},
- {26, {"_wstat", "sX", code(*sys_wstat:arg)}},
- {27, {"_fwstat", "DX", code(*sys_fwstat:arg)}},
- {28, {"notify", "X", code(*sysnotify:arg)}},
- {29, {"noted", "D", code(*sysnoted:arg)}},
- {30, {"segattach", "DsXD", code(*syssegattach:arg)}},
- {31, {"segdetach", "X", code(*syssegdetach:arg)}},
- {32, {"segfree", "XD", code(*syssegfree:arg)}},
- {33, {"segflush", "XD", code(*syssegflush:arg)}},
- {34, {"rendezvous", "XX", code(*sysrendezvous:arg)}},
- {35, {"unmount", "ss", code(*sysunmount:arg)}},
- {36, {"_wait", "X", code(*sys_wait:arg)}},
- {39, {"seek", "XDVD", code(*sysseek:arg)}},
- {40, {"fversion", "DDsD", code(*sysfversion:arg)}},
- {41, {"errstr", "TD", code(*syserrstr:arg)}},
- {42, {"stat", "sXD", code(*sysstat:arg)}},
- {43, {"fstat", "DXD", code(*sysfstat:arg)}},
- {44, {"wstat", "sXD", code(*syswstat:arg)}},
- {45, {"fwstat", "DXD", code(*sysfwstat:arg)}},
- {46, {"mount", "DDsXs", code(*sysmount:arg)}},
- {47, {"await", "TD", code(*sysawait:arg)}},
- {50, {"pread", "DXDZ", code(*syspread:arg)}},
- {51, {"pwrite", "DTDZ", code(*syspwrite:arg)}},
+ { 1, {"_errstr", "s", code(*sys_errstr:list)}},
+ { 2, {"bind", "ssX", code(*sysbind:list)}},
+ { 3, {"chdir", "s", code(*sysbind:list)}},
+ { 4, {"close", "D", code(*sysclose:list)}},
+ { 5, {"dup", "DD", code(*sysdup:list)}},
+ { 6, {"alarm", "D", code(*sysalarm:list)}},
+ { 7, {"exec", "sS", code(*sysexec:list)}},
+ { 8, {"exits", "s", code(*sysexits:list)}},
+ { 9, {"_fsession", "DX", code(*sys_fsession:list)}},
+ {10, {"fauth", "DX", code(*sysfauth:list)}},
+ {11, {"_fstat", "DX", code(*sys_fstat:list)}},
+ {12, {"segbrk", "XX", code(*syssegbrk:list)}},
+ {13, {"_mount", "DsXs", code(*sys_mount:list)}},
+ {14, {"open", "sD", code(*sysopen:list)}},
+ {15, {"_read", "DXD", code(*sys_read:list)}},
+ {16, {"oseek", "DDD", code(*sysoseek:list)}},
+ {17, {"sleep", "D", code(*syssleep:list)}},
+ {18, {"_stat", "sX", code(*sys_stat:list)}},
+ {19, {"rfork", "X", code(*sysstat:list)}},
+ {20, {"_write", "DXD", code(*sys_write:list)}},
+ {21, {"pipe", "X", code(*syspipe:list)}},
+ {22, {"create", "sDO", code(*syscreate:list)}},
+ {23, {"fd2path", "DXD", code(*sysfd2path:list)}},
+ {24, {"brk_", "X", code(*sysbrk_:list)}},
+ {25, {"remove", "s", code(*sysremove:list)}},
+ {26, {"_wstat", "sX", code(*sys_wstat:list)}},
+ {27, {"_fwstat", "DX", code(*sys_fwstat:list)}},
+ {28, {"notify", "X", code(*sysnotify:list)}},
+ {29, {"noted", "D", code(*sysnoted:list)}},
+ {30, {"segattach", "DsXD", code(*syssegattach:list)}},
+ {31, {"segdetach", "X", code(*syssegdetach:list)}},
+ {32, {"segfree", "XD", code(*syssegfree:list)}},
+ {33, {"segflush", "XD", code(*syssegflush:list)}},
+ {34, {"rendezvous", "XX", code(*sysrendezvous:list)}},
+ {35, {"unmount", "ss", code(*sysunmount:list)}},
+ {36, {"_wait", "X", code(*sys_wait:list)}},
+ {39, {"seek", "XDVD", code(*sysseek:list)}},
+ {40, {"fversion", "DDsD", code(*sysfversion:list)}},
+ {41, {"errstr", "TD", code(*syserrstr:list)}},
+ {42, {"stat", "sXD", code(*sysstat:list)}},
+ {43, {"fstat", "DXD", code(*sysfstat:list)}},
+ {44, {"wstat", "sXD", code(*syswstat:list)}},
+ {45, {"fwstat", "DXD", code(*sysfwstat:list)}},
+ {46, {"mount", "DDsXs", code(*sysmount:list)}},
+ {47, {"await", "TD", code(*sysawait:list)}},
+ {50, {"pread", "DXDZ", code(*syspread:list)}},
+ {51, {"pwrite", "DTDZ", code(*syspwrite:list)}},
};
defn syscall() {
--- a/sys/lib/acid/thread
+++ b/sys/lib/acid/thread
@@ -1,8 +1,8 @@
-include("/sys/src/libthread/sched.acid");
+include("/sys/src/libthread/sched." + objchar + ".acid");
defn labpc(l)
{
- if objtype == "386" then
+ if objtype == "386" || objtype == "amd64" then
return longjmp;
return *(l+4);
}
--- a/sys/src/cmd/mksyslib
+++ b/sys/src/cmd/mksyslib
@@ -36,8 +36,8 @@
nuke:V:
rm -f *.[$OS] [$OS].out $CLEANFILES $LIB
-%.acid: %.$O $HFILES
- $CC $CFLAGS -a $stem.c >$target
+%.acid:V:
+ $CC $CFLAGS -a `{basename $stem .$O}^.c >$target
update:V:
update $UPDATEFLAGS $UPDATE