Browse Source

move go tools to harvey go repo, add gocmds project

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 3 years ago
parent
commit
32c95c6d8a

+ 2 - 9
bootstrap.sh

@@ -6,8 +6,8 @@ HOSTBIN=$(go env GOHOSTOS)_$(go env GOHOSTARCH)/bin
 export GOBIN=$(pwd)/$HOSTBIN
 echo GOBIN is now $GOBIN
 
-echo Building the build tool into $HOSTBIN
-GO111MODULE=on go get ./util/src/harvey/cmd/...
+echo Building harvey-os.org commands into $HOSTBIN
+GO111MODULE=on go get harvey-os.org/cmd/...
 
 echo Building u-root into $HOSTBIN
 GO111MODULE=on go get github.com/u-root/u-root@c370a343c8b0b01faac358c1dafb409e5576ae1a
@@ -16,13 +16,6 @@ GO111MODULE=on go get github.com/u-root/u-root@c370a343c8b0b01faac358c1dafb409e5
 # and https://github.com/u-root/u-root/issues/583
 GO111MODULE=off go get -d github.com/u-root/u-root
 
-echo Building harvey-os.org commands into $HOSTBIN
-GO111MODULE=on go get harvey-os.org/cmd/...@fdc9a5f1c6ed2f37b77c16e82b80b1ed6df8fa17
-
-echo FIXME -- once we get more architectures, this needs to be done in sys/src/cmds/build.json
-echo Building tmpfs command into plan9_amd64/bin
-GO111MODULE=on GOOS=plan9 GOARCH=amd64 go build -o plan9_amd64/bin/tmpfs harvey-os.org/cmd/tmpfs
-
 # this will make booting a VM easier
 mkdir -p tmp
 

+ 3 - 11
go.mod

@@ -1,16 +1,8 @@
 module github.com/Harvey-OS/harvey
 
-go 1.13
+go 1.15
 
 require (
-	github.com/dustin/go-humanize v1.0.0 // indirect
-	github.com/google/goexpect v0.0.0-20200703111054-623d5ca06f56 // indirect
-	github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f // indirect
-	github.com/u-root/u-root v7.0.1-0.20200915215200-c370a343c8b0+incompatible
-	github.com/ulikunitz/xz v0.5.8 // indirect
-	golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
-	golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
-	golang.org/x/tools v0.0.0-20200811215021-48a8ffc5b207 // indirect
-	google.golang.org/grpc v1.30.0 // indirect
-	harvey-os.org v0.0.0-20201212154226-fdc9a5f1c6ed // indirect
+	github.com/u-root/u-root v7.0.1-0.20200915215200-c370a343c8b0+incompatible // indirect
+	harvey-os.org v0.1.0 // indirect
 )

+ 10 - 42
go.sum

@@ -9,7 +9,6 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
-github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -19,8 +18,8 @@ github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/goexpect v0.0.0-20200703111054-623d5ca06f56 h1:sXtmz0BQBeXxoxCNb376WLx6r9HKVTJvD4PQQ/kL604=
-github.com/google/goexpect v0.0.0-20200703111054-623d5ca06f56/go.mod h1:qtE5aAEkt0vOSA84DBh8aJsz6riL8ONfqfULY7lBjqc=
+github.com/google/goexpect v0.0.0-20200816234442-b5b77125c2c5 h1:WgPsDN4gp2CYXtwRcIgjbx4TmWX8XumZI9Q8iJov450=
+github.com/google/goexpect v0.0.0-20200816234442-b5b77125c2c5/go.mod h1:n1ej5+FqyEytMt/mugVDZLIiqTMO+vsrgY+kM6ohzN0=
 github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=
 github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
 github.com/hugelgupf/socketpair v0.0.0-20190730060125-05d35a94e714/go.mod h1:2Goc3h8EklBH5mspfHFxBnEoURQCGzQQH1ga9Myjvis=
@@ -33,31 +32,21 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/u-root/u-root v6.0.0+incompatible h1:YqPGmRoRyYmeg17KIWFRSyVq6LX5T6GSzawyA6wG6EE=
-github.com/u-root/u-root v6.0.0+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
 github.com/u-root/u-root v6.0.1-0.20200728234108-3441aaa6cf0c+incompatible h1:vRAKYyEfhZV7SDTcaE3Cuop7tjDMOrapnBb59wVCcyE=
 github.com/u-root/u-root v6.0.1-0.20200728234108-3441aaa6cf0c+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
-github.com/u-root/u-root v6.0.1-0.20200822172051-c6181ee270c5+incompatible h1:CpPPb4peXHrnpXuWbKtFbnjdEOWRtzduR1VSTv8mBHk=
-github.com/u-root/u-root v6.0.1-0.20200822172051-c6181ee270c5+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
-github.com/u-root/u-root v7.0.0+incompatible h1:u+KSS04pSxJGI5E7WE4Bs9+Zd75QjFv+REkjy/aoAc8=
-github.com/u-root/u-root v7.0.0+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
 github.com/u-root/u-root v7.0.1-0.20200915215200-c370a343c8b0+incompatible h1:72xpS/5zzWaJJSlPmvgUG4QCLFjCatyQMwKQ+xuyp+w=
 github.com/u-root/u-root v7.0.1-0.20200915215200-c370a343c8b0+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY=
 github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
 github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
-github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/ziutek/telnet v0.0.0-20180329124119-c3b780dc415b/go.mod h1:IZpXDfkJ6tWD3PhBK5YzgQT+xJWh7OsdwiG8hA2MkO4=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc h1:c0o/qxkaO2LF5t6fQrT4b5hzyggAkLLlCUjqfRxd8Q4=
-golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
+golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
-golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
-golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -65,37 +54,26 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
 golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
-golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190606122018-79a91cf218c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
-golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE=
 golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20200811215021-48a8ffc5b207 h1:8Kg+JssU1jBZs8GIrL5pl4nVyaqyyhdmHAR4D1zGErg=
-golang.org/x/tools v0.0.0-20200811215021-48a8ffc5b207/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
-golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@@ -105,22 +83,12 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
 google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
 google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
-google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
-google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI=
+google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-harvey-os.org v0.0.0-20200727215830-5b0d35efdc89 h1:SoXYkGtBs+F1uLdGh7BL9W3oNYSlcQtljEMfty7yVco=
-harvey-os.org v0.0.0-20200727215830-5b0d35efdc89/go.mod h1:/HMTYlPsfQz7ekcuJuh28eeYCI6ZUQ7pdj6iaUZdyHU=
-harvey-os.org v0.0.0-20200818173457-bcfa7228c80c h1:FoxPIIGfbaLYWvK6NNhXs2qblOcxMMYtgCwPVHZ0FkA=
-harvey-os.org v0.0.0-20200818173457-bcfa7228c80c/go.mod h1:Nv7W5iTyeAM1h/Mmu+HnKiuZOAdmKBOEBMpZspUXBTQ=
-harvey-os.org v0.0.0-20200902150504-b086005f2d31 h1:M9jAgHW9tkEuh6n7BaHGNz/Sj2AdoQQ/D6vUHhhjnQI=
-harvey-os.org v0.0.0-20200902150504-b086005f2d31/go.mod h1:X8NM+nWMbxt33lc30c6Lp9mhrYoTPfSpqdG1HDJpDEk=
-harvey-os.org v0.0.0-20200907032339-e21673138b63 h1:g6SZnr+RdIZdblyoscrNmtOc4uK//Tt7VbWRtX+KyXo=
-harvey-os.org v0.0.0-20200907032339-e21673138b63/go.mod h1:X8NM+nWMbxt33lc30c6Lp9mhrYoTPfSpqdG1HDJpDEk=
-harvey-os.org v0.0.0-20200920202139-8978eaed4898 h1:DuaDKqF/tn+cRzOP6+SsfGgmukEbZmg9hKS4Ugg9ykY=
-harvey-os.org v0.0.0-20200920202139-8978eaed4898/go.mod h1:5zX4kLiAhPOUt+aJjT6Awqgc2MENFhYR7uS3SOWcluw=
-harvey-os.org v0.0.0-20201212154226-fdc9a5f1c6ed h1:dC74qhkdhcfRbyLrBCRpsCI77USLSkBFYHp+adInoSw=
-harvey-os.org v0.0.0-20201212154226-fdc9a5f1c6ed/go.mod h1:e0wFHdlCDjfCMaSNv4M2Dbdc93tW3L7M+v040gNULHM=
+harvey-os.org v0.1.0 h1:LELav7R8g9pzeLMD0ktDc4UsDRwL6/xKUL0rBObkYbA=
+harvey-os.org v0.1.0/go.mod h1:be+ly3If0RfRAZ6wZRRSC6sZH4SF0Ve4Ne3TC3JShck=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 pack.ag/tftp v1.0.0 h1:q7iP8mKRtqTAWfxbQ4XY5/flZ5JmuThvrEmHPn8cN9A=

+ 5 - 5
sys/src/9/amd64/build.json

@@ -2,16 +2,16 @@
 	{
 		"Name": "cpu",
 		"Env": [
-			"CONF=cpu",
-			"GO111MODULE=off",
-			"GOOS=plan9",
-			"GOARCH=amd64"
+			"CONF=cpu"
 		],
 		"Include": [
 			"core.json",
 			"../386/386.json",
 			"../ip/ip.json",
-			"../port/port.json",
+			"../port/port.json"
+		],
+		"Projects": [
+			"gocmds.json",
 			"u-root.json"
 		],
 		"Kernel": {

+ 13 - 0
sys/src/9/amd64/gocmds.json

@@ -0,0 +1,13 @@
+[
+	{
+		"Name": "gocmds",
+		"Env": [
+			"GO111MODULE=on",
+			"GOOS=plan9",
+			"GOARCH=amd64"
+		],
+		"Pre": [
+			"go build -o /plan9_amd64/bin/tmpfs harvey-os.org/cmd/tmpfs"
+		]
+	}
+]

+ 7 - 0
tools.go

@@ -0,0 +1,7 @@
+// +build tools
+
+package harveytools
+
+import (
+	_ "harvey-os.org"
+)

+ 0 - 790
util/src/harvey/cmd/build/build.go

@@ -1,790 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-// Build builds code as directed by json files.
-// We slurp in the JSON, and recursively process includes.
-// At the end, we issue a single cc command for all the files.
-// Compilers are fast.
-//
-// ENVIRONMENT
-//
-// Needed: CC, HARVEY, ARCH
-//
-// HARVEY should point to a harvey root.
-// A best-effort to autodetect the harvey root is made if not explicitly set.
-//
-// Optional: AR, LD, RANLIB, STRIP, SH, TOOLPREFIX
-//
-// These all control how the needed tools are found.
-//
-package main
-
-import (
-	"encoding/json"
-	"errors"
-	"flag"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"log"
-	"os"
-	"os/exec"
-	"path"
-	"path/filepath"
-	"regexp"
-	"strings"
-)
-
-type kernconfig struct {
-	Code []string
-	Dev  []string
-	Ip   []string
-	Link []string
-	Sd   []string
-	Uart []string
-	VGA  []string
-}
-
-type kernel struct {
-	Systab   string
-	Config   kernconfig
-	Ramfiles map[string]string
-}
-
-type build struct {
-	// jsons is unexported so can not be set in a .json file
-	jsons []string
-	path  string
-	Name  string
-	// Projects name a whole subproject which is built independently of
-	// this one. We'll need to be able to use environment variables at some point.
-	Projects    []string
-	Pre         []string
-	Post        []string
-	Cflags      []string
-	Oflags      []string
-	Include     []string
-	SourceFiles []string
-	ObjectFiles []string
-	Libs        []string
-	Env         []string
-	SourceDeps  []string
-	// cmd's
-	SourceFilesCmd []string
-	// Targets.
-	Program string
-	Library string
-	Install string // where to place the resulting binary/lib
-	Kernel  *kernel
-}
-
-type buildfile []build
-
-func globby(s []string) []string {
-	all := []string{}
-
-	for _, n := range s {
-		l, err := filepath.Glob(n)
-		if err != nil || len(l) == 0 {
-			all = append(all, n)
-		} else {
-			all = append(all, l...)
-		}
-	}
-
-	debug("Glob of '%v' is '%v'", s, all)
-	return all
-}
-
-// UnmarshalJSON works like the stdlib unmarshal would, except it adjusts all
-// paths.
-func (bf *buildfile) UnmarshalJSON(s []byte) error {
-	r := make([]build, 0)
-	if err := json.Unmarshal(s, &r); err != nil {
-		return err
-	}
-
-	for k, b := range r {
-		// we're getting a copy of the struct, remember.
-		b.jsons = []string{}
-		b.Projects = adjust(b.Projects)
-		b.Libs = adjust(b.Libs)
-		b.SourceDeps = adjust(b.SourceDeps)
-		b.Cflags = adjust(b.Cflags)
-		b.Oflags = adjust(b.Oflags)
-		b.SourceFiles = globby(adjust(b.SourceFiles))
-		b.SourceFilesCmd = globby(adjust(b.SourceFilesCmd))
-		b.ObjectFiles = adjust(b.ObjectFiles)
-		b.Include = adjust(b.Include)
-		b.Install = fromRoot(b.Install)
-		for i, e := range b.Env {
-			b.Env[i] = os.ExpandEnv(e)
-		}
-		r[k] = b
-	}
-	*bf = r
-	return nil
-}
-
-func (b *build) includedJson(filename string) bool {
-	for _, includedJson := range b.jsons {
-		if includedJson == filename {
-			return true
-		}
-	}
-	return false
-}
-
-var (
-	harvey    string
-	regexpAll = []*regexp.Regexp{regexp.MustCompile(".")}
-
-	// findTools looks at all env vars and absolutizes these paths
-	// also respects TOOLPREFIX
-	tools = map[string]string{
-		"cc":     "gcc",
-		"ar":     "ar",
-		"ld":     "ld",
-		"ranlib": "ranlib",
-		"strip":  "strip",
-	}
-	arch = map[string]bool{
-		"amd64":   true,
-		"riscv":   true,
-		"aarch64": true,
-	}
-	debugPrint     = flag.Bool("debug", false, "enable debug prints")
-	depends        = flag.Bool("D", false, "Do dependency checking")
-	staticAnalysis = flag.Bool("analyze", false, "Do static analysis")
-	shellhack      = flag.Bool("shellhack", false, "spawn every command in a shell (forced on if LD_PRELOAD is set)")
-)
-
-func debug(fmt string, s ...interface{}) {
-	if *debugPrint {
-		log.Printf(fmt, s...)
-	}
-}
-
-func fail(err error) {
-	if err != nil {
-		log.Fatalf("%s\n", err.Error())
-	}
-}
-
-func adjust(s []string) []string {
-	for i, v := range s {
-		s[i] = fromRoot(v)
-	}
-	return s
-}
-
-// return the given absolute path as an absolute path rooted at the harvey tree.
-func fromRoot(p string) string {
-	expandedPath := os.ExpandEnv(p)
-	if path.IsAbs(expandedPath) {
-		expandedPath = path.Join(harvey, expandedPath)
-	}
-
-	if strings.Contains(p, "$CC") {
-		// Travis has versioned CCs of the form clang-X.Y.  We don't want to have
-		// a file for each version of the compilers, so check if the versioned
-		// file exists first.  If it doesn't, fall back to the unversioned file.
-		expandedCc := os.Getenv("CC")
-		expandedCcTokens := strings.Split(expandedCc, "-")
-		fallbackCc := expandedCcTokens[0]
-		//fmt.Printf(">>>CC=%v fallback=%v\n", expandedCc, fallbackCc)
-		if len(expandedCcTokens) > 1 {
-			if _, err := os.Stat(expandedPath); err != nil {
-				if os.IsNotExist(err) {
-					oldCc := os.Getenv("CC")
-					os.Setenv("CC", fallbackCc)
-					expandedPath = fromRoot(p)
-					os.Setenv("CC", oldCc)
-				}
-			}
-		}
-	}
-
-	return expandedPath
-}
-
-func include(f string, targ string, b *build) {
-	debug("include(%s, %s, %v)", f, targ, b)
-
-	if b.includedJson(f) {
-		return
-	}
-	b.jsons = append(b.jsons, f)
-
-	log.Printf("Including %s", f)
-	builds := unmarshalBuild(f)
-
-	for _, build := range builds {
-		t := target(&build)
-		if t != "" {
-			targ = t
-			break
-		}
-	}
-
-	for _, build := range builds {
-		log.Printf("Merging %s", build.Name)
-		b.Cflags = append(b.Cflags, build.Cflags...)
-		b.Oflags = append(b.Oflags, build.Oflags...)
-		b.Pre = append(b.Pre, build.Pre...)
-		b.Post = append(b.Post, build.Post...)
-		b.Libs = append(b.Libs, build.Libs...)
-		b.Projects = append(b.Projects, build.Projects...)
-		b.Env = append(b.Env, build.Env...)
-		for _, v := range build.SourceFilesCmd {
-			_, t := cmdTarget(&build, v)
-			if uptodate(t, append(b.SourceDeps, v)) {
-				continue
-			}
-			b.SourceFilesCmd = append(b.SourceFilesCmd, v)
-		}
-		if build.Install != "" {
-			if b.Install != "" && build.Install != b.Install {
-				log.Fatalf("In file %s (target %s) included by %s (target %s): redefined Install: was %s, redefined to %s.", f, b.Name, build.path, build.Name, b.Install, build.Install)
-			}
-			b.Install = build.Install
-		}
-		b.ObjectFiles = append(b.ObjectFiles, build.ObjectFiles...)
-		// For each source file, assume we create an object file with the last char replaced
-		// with 'o'. We can get smarter later.
-		b.SourceDeps = append(b.SourceDeps, build.SourceDeps...)
-
-		var s []string
-		for _, v := range build.SourceFiles {
-			if uptodate(targ, append(b.SourceDeps, v)) {
-				continue
-			}
-			s = append(s, v)
-		}
-		if *depends && build.Program != "" {
-			if len(s) == 0 {
-				build.SourceFiles = []string{}
-				build.Program = ""
-			}
-		}
-
-		if *depends && b.Library != "" {
-			build.SourceFiles = s
-		}
-
-		for _, v := range build.SourceFiles {
-			b.SourceFiles = append(b.SourceFiles, v)
-			fi := path.Base(v)
-			ext := path.Ext(v)
-			o := fi[:len(fi)-len(ext)+1] + "o"
-			b.ObjectFiles = append(b.ObjectFiles, o)
-		}
-
-		for _, v := range build.Include {
-			if !path.IsAbs(v) {
-				wd := path.Dir(f)
-				v = path.Join(wd, v)
-			}
-			include(v, targ, b)
-		}
-		b.Program += build.Program
-		b.Library += build.Library
-	}
-}
-
-func contains(a []string, s string) bool {
-	for i := range a {
-		if a[i] == s {
-			return true
-		}
-	}
-	return false
-}
-
-func unmarshalBuild(f string) buildfile {
-	d, err := ioutil.ReadFile(f)
-	fail(err)
-
-	var builds buildfile
-	fail(json.Unmarshal(d, &builds))
-	return builds
-}
-
-func process(f string, r []*regexp.Regexp) []build {
-	log.Printf("Processing %s", f)
-	var results []build
-
-	builds := unmarshalBuild(f)
-
-	for _, build := range builds {
-		build.jsons = []string{}
-		skip := true
-		for _, re := range r {
-			if re.MatchString(build.Name) {
-				skip = false
-				break
-			}
-		}
-		if skip {
-			continue
-		}
-		log.Printf("Running %s", build.Name)
-
-		build.jsons = append(build.jsons, f)
-		build.path = path.Dir(f)
-
-		// Figure out which of these are up to date.
-		var s []string
-		for _, v := range build.SourceFilesCmd {
-			_, targ := cmdTarget(&build, v)
-			if uptodate(targ, append(build.SourceDeps, v)) {
-				continue
-			}
-			s = append(s, v)
-		}
-		build.SourceFilesCmd = s
-		// For each source file, assume we create an object file with the last char replaced
-		// with 'o'. We can get smarter later.
-		t := target(&build)
-		deps := targetDepends(&build)
-		debug("\ttarget is '%s', deps are '%v'", t, deps)
-		for _, v := range build.SourceFiles {
-			if uptodate(t, append(deps, v)) {
-				continue
-			}
-			s = append(s, v)
-		}
-
-		if *depends && build.Program != "" {
-			if len(s) == 0 {
-				build.SourceFiles = []string{}
-				build.Program = ""
-			}
-		}
-
-		if *depends && build.Library != "" {
-			build.SourceFiles = s
-		}
-
-		for _, v := range build.SourceFiles {
-			f := path.Base(v)
-			ext := path.Ext(f)
-			l := len(f) - len(ext) + 1
-			o := f[:l]
-			o += "o"
-			if !contains(build.ObjectFiles, o) {
-				build.ObjectFiles = append(build.ObjectFiles, o)
-			}
-		}
-
-		for _, v := range build.Include {
-			include(v, t, &build)
-		}
-		results = append(results, build)
-	}
-	return results
-}
-
-func buildkernel(b *build) {
-	if b.Kernel == nil {
-		return
-	}
-	codebuf := confcode(b.path, b.Kernel)
-	fail(ioutil.WriteFile(b.Name+".c", codebuf, 0666))
-}
-
-func uptodate(n string, d []string) bool {
-	debug("uptodate: %s, %v\n", n, d)
-	if !*depends {
-		debug("\t no\n")
-		return false
-	}
-
-	fi, err := os.Stat(n)
-	// If it does not exist, by definition it's not up to date
-	if err != nil {
-		debug("\t target '%s' doesn't exist\n", n)
-		return false
-	}
-
-	m := fi.ModTime()
-
-	debug("older: time is %v\n", m)
-	if len(d) == 0 {
-		log.Fatalf("update has nothing to check for %v", n)
-	}
-	for _, d := range d {
-		debug("\tCheck %s:", d)
-		di, err := os.Stat(d)
-		if err != nil {
-			return false
-		}
-		if !di.ModTime().Before(m) {
-			debug("%v is newer\n", di.ModTime())
-			return false
-		}
-		debug("%v is older\n", di.ModTime())
-	}
-
-	debug("all is older\n")
-	return true
-}
-
-func targetDepends(b *build) []string {
-	return append(b.SourceDeps, fromRoot("/sys/include/libc.h"), fromRoot("/$ARCH/include/u.h"))
-}
-
-func target(b *build) string {
-	if b.Program != "" {
-		return path.Join(b.Install, b.Program)
-	}
-	if b.Library != "" {
-		return path.Join(b.Install, b.Library)
-	}
-	return ""
-}
-
-func cmdTarget(b *build, n string) (string, string) {
-	ext := filepath.Ext(n)
-	exe := n[:len(n)-len(ext)]
-	return exe, b.Install
-}
-
-func compile(b *build) {
-	log.Printf("Building %s\n", b.Name)
-
-	// N.B. Plan 9 has a very well defined include structure, just three things:
-	// /amd64/include, /sys/include, .
-	args := []string{
-		"-std=c11",
-		"-c",
-		"-I", fromRoot("/$ARCH/include"),
-		"-I", fromRoot("/sys/include"),
-		"-I", ".",
-	}
-
-	ccCommand := tools["cc"]
-	command := ccCommand
-	if *staticAnalysis {
-		command = "scan-build"
-		args = append([]string{ccCommand}, args...)
-	}
-
-	args = append(args, b.Cflags...)
-	if len(b.SourceFilesCmd) > 0 {
-		for _, sourceFile := range b.SourceFilesCmd {
-			cmd := exec.Command(command, append(args, sourceFile)...)
-			run(b, *shellhack, cmd)
-		}
-		return
-	}
-	args = append(args, b.SourceFiles...)
-	cmd := exec.Command(command, args...)
-	run(b, *shellhack, cmd)
-}
-
-func link(b *build) {
-	log.Printf("Linking %s\n", b.Name)
-	if len(b.SourceFilesCmd) > 0 {
-		for _, n := range b.SourceFilesCmd {
-			// Split off the last element of the file
-			var ext = filepath.Ext(n)
-			if len(ext) == 0 {
-				log.Fatalf("refusing to overwrite extension-less source file %v", n)
-				continue
-			}
-			n = n[:len(n)-len(ext)]
-			f := path.Base(n)
-			o := f[:len(f)] + ".o"
-			args := []string{"-o", n, o}
-			args = append(args, "-L", fromRoot("/$ARCH/lib"))
-			args = append(args, b.Libs...)
-			args = append(args, b.Oflags...)
-			run(b, *shellhack, exec.Command(tools["ld"], args...))
-		}
-		return
-	}
-	args := []string{"-o", b.Program}
-	args = append(args, b.ObjectFiles...)
-	args = append(args, "-L", fromRoot("/$ARCH/lib"))
-	args = append(args, b.Libs...)
-	args = append(args, b.Oflags...)
-	run(b, *shellhack, exec.Command(tools["ld"], args...))
-}
-
-func install(b *build) {
-	if b.Install == "" {
-		return
-	}
-
-	log.Printf("Installing %s\n", b.Name)
-	fail(os.MkdirAll(b.Install, 0755))
-
-	switch {
-	case len(b.SourceFilesCmd) > 0:
-		for _, n := range b.SourceFilesCmd {
-			move(cmdTarget(b, n))
-		}
-	case len(b.Program) > 0:
-		move(b.Program, b.Install)
-	case len(b.Library) > 0:
-		libpath := path.Join(b.Install, b.Library)
-		args := append([]string{"-rs", libpath}, b.ObjectFiles...)
-		run(b, *shellhack, exec.Command(tools["ar"], args...))
-		run(b, *shellhack, exec.Command(tools["ranlib"], libpath))
-	}
-}
-
-func move(from, to string) {
-	final := path.Join(to, from)
-	log.Printf("move %s %s\n", from, final)
-	_ = os.Remove(final)
-	fail(os.Link(from, final))
-	fail(os.Remove(from))
-}
-
-func run(b *build, pipe bool, cmd *exec.Cmd) {
-	sh := os.Getenv("SHELL")
-	if sh == "" {
-		sh = "sh"
-	}
-
-	if b != nil {
-		cmd.Env = append(os.Environ(), b.Env...)
-	}
-	cmd.Stdout = os.Stdout
-	cmd.Stderr = os.Stderr
-	if pipe {
-		// Sh sends cmd to a shell. It's needed to enable $LD_PRELOAD tricks,
-		// see https://github.com/Harvey-OS/harvey/issues/8#issuecomment-131235178
-		shell := exec.Command(sh)
-		shell.Env = cmd.Env
-		shell.Stderr = os.Stderr
-		shell.Stdout = os.Stdout
-
-		commandString := cmd.Args[0]
-		for _, a := range cmd.Args[1:] {
-			if strings.Contains(a, "=") {
-				commandString += " '" + a + "'"
-			} else {
-				commandString += " " + a
-			}
-		}
-		shStdin, err := shell.StdinPipe()
-		if err != nil {
-			log.Fatalf("cannot pipe [%v] to %s: %v", commandString, sh, err)
-		}
-		go func() {
-			defer shStdin.Close()
-			io.WriteString(shStdin, commandString)
-		}()
-
-		log.Printf("%q | %s\n", commandString, sh)
-		fail(shell.Run())
-		return
-	}
-	log.Println(strings.Join(cmd.Args, " "))
-	fail(cmd.Run())
-}
-
-func projects(b *build, r []*regexp.Regexp) {
-	for _, v := range b.Projects {
-		f, err := findBuildfile(v)
-		log.Printf("Doing %s\n", f)
-		if err != nil {
-			log.Println(err)
-		}
-		project(f, r)
-	}
-}
-
-func dirPop(s string) {
-	fmt.Printf("Leaving directory `%v'\n", s)
-	fail(os.Chdir(s))
-}
-
-func dirPush(s string) {
-	fmt.Printf("Entering directory `%v'\n", s)
-	fail(os.Chdir(s))
-}
-
-func runCmds(b *build, s []string) {
-	for _, c := range s {
-		args := adjust(strings.Split(c, " "))
-		var exp []string
-		for _, v := range args {
-			e, err := filepath.Glob(v)
-			debug("glob %v to %v err %v", v, e, err)
-			if len(e) == 0 || err != nil {
-				exp = append(exp, v)
-			} else {
-				exp = append(exp, e...)
-			}
-		}
-		run(b, *shellhack, exec.Command(exp[0], exp[1:]...))
-	}
-}
-
-// assumes we are in the wd of the project.
-func project(bf string, which []*regexp.Regexp) {
-	cwd, err := os.Getwd()
-	fail(err)
-	debug("Start new project cwd is %v", cwd)
-	defer dirPop(cwd)
-	dir := path.Dir(bf)
-	root := path.Base(bf)
-	debug("CD to %v and build using %v", dir, root)
-	dirPush(dir)
-	builds := process(root, which)
-	debug("Processing %v: %d target", root, len(builds))
-	for _, b := range builds {
-		debug("Processing %v: %v", b.Name, b)
-		projects(&b, regexpAll)
-		runCmds(&b, b.Pre)
-		buildkernel(&b)
-		if len(b.SourceFiles) > 0 || len(b.SourceFilesCmd) > 0 {
-			compile(&b)
-		}
-		if b.Program != "" || len(b.SourceFilesCmd) > 0 {
-			link(&b)
-		}
-		install(&b)
-		runCmds(&b, b.Post)
-	}
-}
-
-func main() {
-	log.SetFlags(0)
-
-	// A small amount of setup is done in the paths*.go files. They are
-	// OS-specific path setup/manipulation. "harvey" is set there and $PATH is
-	// adjusted.
-	flag.Parse()
-	findTools(os.Getenv("TOOLPREFIX"))
-
-	if os.Getenv("CC") == "" {
-		log.Fatalf("You need to set the CC environment variable (e.g. gcc, clang, clang-3.6, ...)")
-	}
-
-	a := os.Getenv("ARCH")
-	if a == "" || !arch[a] {
-		s := []string{}
-		for i := range arch {
-			s = append(s, i)
-		}
-		log.Fatalf("You need to set the ARCH environment variable from: %v", s)
-	}
-
-	// ensure this is exported, in case we used a default value
-	os.Setenv("HARVEY", harvey)
-
-	if os.Getenv("LD_PRELOAD") != "" {
-		log.Println("Using shellhack")
-		*shellhack = true
-	}
-
-	// If there is'n args, we search for a 'build.json' file
-	// Otherwise the first argument could be
-	// A path to a json file
-	// or a directory containing the 'build.json' file
-	// or a regular expression to apply assuming 'build.json'
-	// Further arguments are considered regex.
-	consumedArgs := 0
-	var bf string
-	if flag.NArg() > 0 {
-		f, err := findBuildfile(flag.Arg(0))
-		fail(err)
-
-		if f == "" {
-			fb, err := findBuildfile("build.json")
-			fail(err)
-			bf = fb
-		} else {
-			consumedArgs = 1
-			bf = f
-		}
-	} else {
-		f, err := findBuildfile("build.json")
-		fail(err)
-		bf = f
-	}
-
-	re := []*regexp.Regexp{regexp.MustCompile(".")}
-	if len(flag.Args()) > consumedArgs {
-		re = re[:0]
-		for _, r := range flag.Args()[consumedArgs:] {
-			rx, err := regexp.Compile(r)
-			fail(err)
-			re = append(re, rx)
-		}
-	}
-	project(bf, re)
-}
-
-func findTools(toolprefix string) {
-	var err error
-	for k, v := range tools {
-		if x := os.Getenv(strings.ToUpper(k)); x != "" {
-			v = x
-		}
-		v, err = exec.LookPath(toolprefix + v)
-		fail(err)
-		tools[k] = v
-	}
-}
-
-func isDir(f string) (bool, error) {
-	fi, err := os.Stat(f)
-	if err != nil {
-		return false, err
-	}
-	return fi.IsDir(), nil
-}
-
-// disambiguate the buildfile argument
-func findBuildfile(f string) (string, error) {
-	if !strings.HasSuffix(f, ".json") {
-		b, err := isDir(f)
-		if err != nil {
-			// the path didn't exist
-			return "", errors.New("unable to find buildfile " + f)
-		}
-		if b {
-			f = path.Join(f, "build.json")
-		} else {
-			// this is a file without .json suffix
-			return "", errors.New("buildfile must be a .json file, " + f + " is not a valid name")
-		}
-	}
-	if b, err := isDir(f); err != nil || b {
-		return "", errors.New("unable to find buildfile " + f)
-	}
-	return f, nil
-}

+ 0 - 236
util/src/harvey/cmd/build/codegen.go

@@ -1,236 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"debug/elf"
-	"fmt"
-	"io/ioutil"
-	"os"
-	"os/exec"
-	"sort"
-	"text/template"
-)
-
-const kernconfTmpl = `
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-#include "../port/error.h"
-#include "io.h"
-
-{{ range .Rootcodes }}
-{{ . }}
-{{ end }}
-
-{{ range .Config.Dev }}extern Dev {{ . }}devtab;
-{{ end }}
-Dev *devtab[] = {
-{{ range .Config.Dev }}
-	&{{ . }}devtab,
-{{ end }}
-	nil,
-};
-
-{{ range .Config.Link }}extern void {{ . }}link(void);
-{{ end }}
-void
-links(void)
-{
-{{ range .Rootnames }}addbootfile("{{ . }}", ramfs_{{ . }}_code, ramfs_{{ . }}_len);
-{{ end }}
-{{ range .Config.Link }}{{ . }}link();
-{{ end }}
-}
-
-#include "../ip/ip.h"
-{{ range .Config.Ip }}extern void {{ . }}init(Fs*);
-{{ end }}
-void (*ipprotoinit[])(Fs*) = {
-{{ range .Config.Ip }}	{{ . }}init,
-{{ end }}
-	nil,
-};
-
-#include "../port/sd.h"
-{{ range .Config.Sd }}extern SDifc {{ . }}ifc;
-{{ end }}
-SDifc* sdifc[] = {
-{{ range .Config.Sd }}	&{{ . }}ifc,
-{{ end }}
-	nil,
-};
-
-{{ range .Config.Uart }}extern PhysUart {{ . }}physuart;
-{{ end }}
-PhysUart* physuart[] = {
-{{ range .Config.Uart }}	&{{ . }}physuart,
-{{ end }}
-	nil,
-};`
-
-const vgaconfTmpl = `
-#define	Image	IMAGE
-#include <draw.h>
-#include <memdraw.h>
-#include <cursor.h>
-#include "screen.h"
-{{ range .Config.VGA }}extern VGAdev {{ . }}dev;
-{{ end }}
-VGAdev* vgadev[] = {
-{{ range .Config.VGA }}	&{{ . }}dev,
-{{ end }}
-	nil,
-};
-
-{{ range .Config.VGA }}extern VGAcur {{ . }}cur;
-{{ end }}
-VGAcur* vgacur[] = {
-{{ range .Config.VGA }}	&{{ . }}cur,
-{{ end }}
-	nil,
-};
-
-Physseg physseg[8] = {
-	{
-		.attr = SG_SHARED|SG_READ|SG_WRITE,
-		.name = "shared",
-		.size = SEGMAXPG,
-	},
-	{
-		.attr = SG_BSS|SG_READ|SG_WRITE,
-		.name = "memory",
-		.size = SEGMAXPG,
-	},
-};
-int nphysseg = 8;
-
-{{ range .Config.Code }}{{ . }}
-{{ end }}
-
-char* conffile = "{{ .Path }}";
-
-`
-
-// These are the two big code generation functions.
-
-// data2c takes the file at path and creates a C byte array containing it.
-func data2c(name string, path string) string {
-	var out []byte
-	var in []byte
-
-	if elf, err := elf.Open(path); err == nil {
-		elf.Close()
-		cwd, err := os.Getwd()
-		tmpf, err := ioutil.TempFile(cwd, name)
-		fail(err)
-
-		run(nil, *shellhack, exec.Command(tools["strip"], "-o", tmpf.Name(), path))
-
-		in, err = ioutil.ReadAll(tmpf)
-		fail(err)
-
-		tmpf.Close()
-		os.Remove(tmpf.Name())
-	} else {
-		var file *os.File
-		var err error
-
-		file, err = os.Open(path)
-		fail(err)
-
-		in, err = ioutil.ReadAll(file)
-		fail(err)
-
-		file.Close()
-	}
-
-	total := len(in)
-
-	out = []byte(fmt.Sprintf("static unsigned char ramfs_%s_code[] = {\n", name))
-	for len(in) > 0 {
-		for j := 0; j < 16 && len(in) > 0; j++ {
-			out = append(out, []byte(fmt.Sprintf("0x%02x, ", in[0]))...)
-			in = in[1:]
-		}
-		out = append(out, '\n')
-	}
-
-	out = append(out, []byte(fmt.Sprintf("0,\n};\nint ramfs_%s_len = %v;\n", name, total))...)
-
-	return string(out)
-}
-
-// confcode creates a kernel configuration header.
-func confcode(path string, kern *kernel) []byte {
-	var rootcodes []string
-	var rootnames []string
-
-	// Sort keys so we can guaranteed order of iteration over ramfiles
-	var ramfilenames []string
-	for name := range kern.Ramfiles {
-		ramfilenames = append(ramfilenames, name)
-	}
-	sort.Strings(ramfilenames)
-
-	for _, name := range ramfilenames {
-		path := kern.Ramfiles[name]
-		code := data2c(name, fromRoot(path))
-		rootcodes = append(rootcodes, code)
-		rootnames = append(rootnames, name)
-	}
-
-	vars := struct {
-		Path      string
-		Config    kernconfig
-		Rootnames []string
-		Rootcodes []string
-	}{
-		path,
-		kern.Config,
-		rootnames,
-		rootcodes,
-	}
-	tmpl := template.Must(template.New("kernconf").Parse(kernconfTmpl))
-	codebuf := &bytes.Buffer{}
-	fail(tmpl.Execute(codebuf, vars))
-	fmt.Printf("VGA IS %v len %d\n", vars.Config.VGA, len(vars.Config.VGA))
-	if len(vars.Config.VGA) > 0 {
-		tmpl = template.Must(template.New("vgaconf").Parse(vgaconfTmpl))
-		vgabuf := &bytes.Buffer{}
-		fail(tmpl.Execute(codebuf, vars))
-		codebuf.Write(vgabuf.Bytes())
-	}
-	return codebuf.Bytes()
-}

+ 0 - 213
util/src/harvey/cmd/build/doc.go

@@ -1,213 +0,0 @@
-/*
- Copyright 2018 Harvey OS Team
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its contributors
-    may be used to endorse or promote products derived from this software
-    without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*
-BUILDFILE FORMAT
-
-A buildfile is a json object containing build objects. By convention, it's
-broken out onto multiple lines indented by tabs, and the keys are TitleCased.
-
-The environment varibles HARVEY and ARCH are guarenteed to be set for the
-buildfile. PATH is modified so that "$HARVEY/util" is included.
-
-Any key that takes a path or array of paths as its value has absolute paths
-re-rooted to the harvey tree and variables in the string expanded once.
-
-The shell commands in the "Pre" and "Post" steps must be in the subset of
-syntax that's accepted by both POSIX sh and rc. Practically, this means
-arguments with a "=" must be single-quoted, "test" must be called as
-"test" (not "["), "if" statements may not have an "else" clause, "switch"
-statements may not be used, "for" statements may only have one body command,
-and redirection to a file descriptor cannont be used.
-
-BUILD OBJECT
-
-A build object has the following keys and types:
-
-	Projects        []string
-	Pre             []string
-	Post            []string
-	Cflags          []string
-	Oflags          []string
-	Include         []string
-	SourceFiles     []string
-	ObjectFiles     []string
-	Libs            []string
-	Env             []string
-	SourceFilesCmd  []string
-	Program         string
-	Library         string
-	Install         string
-	Kernel          kernel
-
-These are the steps taken, in order:
-
-	Env
-	Include
-	Projects
-	Pre
-	Kernel
-	[compile] SourceFiles SourceFilesCmd Cflags Program
-	[link] ObjectFiles Libs Oflags Library
-	Install
-	Post
-
-"[compile]" and "[link]" are steps synthesized from the specified keys.
-
-The meaning of the keys is as follows:
-
-"Env" is an array of environment variables to be put in the environment of
-every command run in a build. They are expanded once and only available for
-use in other steps.
-
-"Include" is an array of buildfiles to "merge" into the current one. This
-is done before other projects are built.
-
-"Projects" is an array of buildfiles to build in their entirety before
-starting the current build.
-
-"Pre" is an array of commands to run before starting the build.
-
-"Kernel" is a kernel build object. See the kernel object section.
-
-"Cflags" is an array of flags to pass to the C compiler. They are in addition
-to the standard flags of
-
-	-std=c11 -c -I /$ARCH/include -I /sys/include -I .
-
-The standard include paths are re-rooted to the harvey tree if not on a harvey
-system.
-
-"SourceFilesCmd" is an array of C files where each one should result in an
-executable. If this key is provided, "SourceFiles" and "Program" are ignored.
-
-"SourceFiles" is an array of C files that will ultimately produce a single
-binary or library, named by "Program" or "Library" respectively.
-
-"Program" is the name of the final executable for the files specified by
-"SourceFiles".
-
-"Oflags" is an array of flags to pass to the linker. They are in addition
-to the standard flags of
-
-	-o $program $objfiles -L /$ARCH/lib $libs
-
-The lib path is re-rooted to the harvey tree if not on a harvey system.
-
-"ObjectFiles" is an array of strings specifying object files to be linked
-into the final program specified by "Program". Any object files produced
-by the preceeding "[compile]" step are automatically added to this before
-beginning the "[link]" step.
-
-"Libs" is a an array of library arguments to pass to the linker.
-
-"Library" is the name of the archive resulting from bundling "SourceFiles"
-into a library. The resulting archive has 'ranlib' run on it automatically.
-
-"Install" is a directory where the result of the "[link]" step is moved
-to. If it does not exist, it is created.
-
-"Post" is an array of commands to run last during the build.
-
-KERNEL OBJECT
-
-A build object has the following keys and types:
-
-	Systab   string
-	Ramfiles map[string]string
-	Config   {
-		Code []string
-		Dev  []string
-		Ip   []string
-		Link []string
-		Sd   []string
-		Uart []string
-		VGA  []string
-	}
-
-"Systab" is the header that defines the syscall table.
-
-"Ramfiles" is an object of name, path pairs of binaries at "path" that will
-be baked into the kernel and available at a binary named "name".
-
-"Config" is an object used to generate the kernel configuration source. "Dev",
-"Ip", "Sd", "Uart", "Link", and "VGA" control which drivers of the various
-types are included. "Code" is lines of arbitrary C code.
-
-*/
-package main
-
-import (
-	"flag"
-	"fmt"
-	"os"
-	"strings"
-)
-
-var helptext = `
-The buildfile is looked for at these positions, in this order:
-
-  ./$arg
-  ./$arg/build.json
-  /sys/src/$arg.json
-  /sys/src/$arg/build.json
-
-If the buildfile argument is not provided, it defaults to "build.json".
-
-After the buildfile, a number of regexps specifying targets may be provided.
-If a target matches any supplied regexp, it is acted on. These regexps only
-apply to the top-level buildfile.
-
-BUILDFILE
-
-See the build godoc for more information about the buildfile format.
-
-ENVIRONMENT
-
-ARCH is needed. Current acceptable vaules are: aarch64 amd64 riscv
-
-HARVEY may be supplied to point at a harvey tree. The default on harvey is "/".
-The default on Linux and OSX is to attempt to find the top level of a git
-repository.
-`
-
-func init() {
-	flag.Usage = func() {
-		fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
-		fmt.Fprintf(os.Stderr, "  %s [options] [buildfile] [target...]\n\n", os.Args[0])
-		flag.PrintDefaults()
-		fmt.Fprintln(os.Stderr, helptext)
-		fmt.Fprintln(os.Stderr, "Tools to be used with current settings:")
-		fmt.Fprintf(os.Stderr, "  prefix ($TOOLPREFIX): %q\n", os.Getenv("TOOLPREFIX"))
-		for k, v := range tools {
-			fmt.Fprintf(os.Stderr, "  %s ($%s): %s\n", k, strings.ToUpper(k), v)
-		}
-	}
-}

+ 0 - 57
util/src/harvey/cmd/build/paths.go

@@ -1,57 +0,0 @@
-// +build !harvey
-
-/*
- Copyright 2018 Harvey OS Team
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its contributors
-    may be used to endorse or promote products derived from this software
-    without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"log"
-	"os"
-	"os/exec"
-	"strings"
-)
-
-func init() {
-	harvey = os.Getenv("HARVEY")
-	if harvey == "" {
-		// Try figuring it out from git instead
-		out, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
-		if err == nil {
-			harvey = strings.TrimSpace(string(out))
-		}
-	}
-	// If we still haven't found the path, bail out.
-	if harvey == "" {
-		log.Fatal("Set the HARVEY environment variable or run from a git checkout.")
-	}
-
-	os.Setenv("PATH", strings.Join([]string{fromRoot("/util"), os.Getenv("PATH")}, string(os.PathListSeparator)))
-}

+ 0 - 47
util/src/harvey/cmd/build/paths_harvey.go

@@ -1,47 +0,0 @@
-// +build harvey
-
-/*
- Copyright 2018 Harvey OS Team
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
-    this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
-
- 3. Neither the name of the copyright holder nor the names of its contributors
-    may be used to endorse or promote products derived from this software
-    without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"os"
-	"strings"
-)
-
-func init() {
-	harvey = os.Getenv("HARVEY")
-	if harvey != "" {
-		return
-	}
-	harvey = "/"
-	os.Setenv("path", strings.Join([]string{fromRoot("/util"), os.Getenv("path")}, string(os.PathListSeparator)))
-}

+ 0 - 185
util/src/harvey/cmd/convert/convert.go

@@ -1,185 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"io/ioutil"
-	"log"
-	"os"
-	"path/filepath"
-)
-
-var config = struct {
-	Harvey   string
-	Args     []string
-	Except   map[string]bool
-	CmdName  string
-	FullPath string
-	Src      string
-	Uroot    string
-	Cwd      string
-	Bbsh     string
-
-	Goroot    string
-	Gosrcroot string
-	Arch      string
-	Goos      string
-	Gopath    string
-	TempDir   string
-	Go        string
-	Debug     bool
-	Fail      bool
-}{
-	Harvey: os.Getenv("HARVEY"),
-	Except: map[string]bool{"sysconf.json": true},
-}
-
-type fixup func(string, map[string]interface{})
-
-func cflags(n string, jsmap map[string]interface{}) {
-	if _, ok := jsmap["Cflags"]; ok {
-		log.Printf("Deleting Cflags from %v", n)
-		delete(jsmap, "Cflags")
-		// TODO: once we have another ARCH, use it.
-		a := []string{"/amd64/include/cflags.json"}
-		switch tval := jsmap["Include"].(type) {
-		case []interface{}:
-			for _, v := range tval {
-				a = append(a, v.(string))
-			}
-		}
-		jsmap["Include"] = a
-	}
-}
-
-func removeempty(n string, jsmap map[string]interface{}) {
-	for key, val := range jsmap {
-		switch tval := val.(type) {
-		case map[string]interface{}:
-			log.Printf("%s: tval %s", n, tval)
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		case []interface{}:
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		}
-	}
-}
-
-func checkname(n string, jsmap map[string]interface{}) {
-	if _, ok := jsmap["Name"]; !ok {
-		log.Printf("File %v has no \"Name\" key", n)
-	}
-}
-
-func one(n string, f ...fixup) error {
-	buf, err := ioutil.ReadFile(n)
-	if err != nil {
-		return err
-	}
-
-	var jsmap map[string]interface{}
-	if err := json.Unmarshal(buf, &jsmap); err != nil {
-		return err
-	}
-	if config.Debug {
-		log.Printf("%v: %v", n, jsmap)
-	}
-
-	mapname := jsmap["Name"].(string)
-	delete(jsmap, "Name")
-	var nmap = make(map[string]map[string]interface{})
-	nmap[mapname] = jsmap
-	buf, err = json.MarshalIndent(nmap, "", "\t")
-	if err != nil {
-		return err
-	}
-	buf = append(buf, '\n')
-
-	if config.Debug {
-		os.Stdout.Write(buf)
-	} else {
-		ioutil.WriteFile(n, buf, 0666)
-	}
-	return nil
-}
-
-func init() {
-	if config.Harvey == "" {
-		log.Fatalf("Please set $HARVEY")
-	}
-
-	if len(config.Args) == 0 {
-		config.Args = []string{config.Harvey}
-	}
-}
-
-func main() {
-	var err error
-
-	flag.BoolVar(&config.Debug, "d", true, "Enable debug prints")
-	flag.Parse()
-	config.Args = flag.Args()
-	for _, n := range config.Args {
-		err = filepath.Walk(n, func(name string, fi os.FileInfo, err error) error {
-			if err != nil {
-				return err
-			}
-			if fi.IsDir() {
-				return nil
-			}
-			n := fi.Name()
-			if len(n) < 5 || n[len(n)-5:] != ".json" {
-				return nil
-			}
-			if config.Except[fi.Name()] {
-				return nil
-			}
-			todo := []fixup{removeempty, checkname}
-			log.Printf("process %s", name)
-			err = one(name, todo...)
-			if err != nil {
-				log.Printf("%s: %s\n", name, err)
-				return err
-			}
-			return nil
-		})
-
-		if err != nil {
-			log.Fatalf("%v", err)
-
-		}
-	}
-}

+ 0 - 76
util/src/harvey/cmd/data2c/data2c.go

@@ -1,76 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"flag"
-	"fmt"
-	"io/ioutil"
-	"os"
-)
-
-func main() {
-	flag.Parse()
-	a := flag.Args()
-	if len(a) != 3 {
-		fmt.Fprintf(os.Stderr, "[%v]usage: data2s name input-file output-file\n", a)
-		os.Exit(1)
-	}
-
-	n := a[0]
-	i := a[1]
-	in, err := ioutil.ReadFile(i)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v\n", err)
-		os.Exit(1)
-	}
-
-	total := len(in)
-
-	o := a[2]
-	b := &bytes.Buffer{}
-	fmt.Fprintf(b, "unsigned char %vcode[] = {\n", n)
-	for len(in) > 0 {
-		for j := 0; j < 16 && len(in) > 0; j++ {
-			fmt.Fprintf(b, "0x%02x, ", in[0])
-			in = in[1:]
-		}
-		fmt.Fprintf(b, "\n")
-
-	}
-
-	fmt.Fprintf(b, "0,\n};\nint %vlen = %v;\n", n, total)
-
-	if err := ioutil.WriteFile(o, b.Bytes(), 0644); err != nil {
-		fmt.Fprintf(os.Stderr, "Write to %s failed: %v\n", o, err)
-	}
-}

+ 0 - 146
util/src/harvey/cmd/elf2c/elf2c.go

@@ -1,146 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"debug/elf"
-	"flag"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"math"
-	"os"
-	"path"
-)
-
-var dry = flag.Bool("dryrun", true, "don't really do it")
-
-func gencode(w io.Writer, n, t string, m []byte, start, end uint64) {
-	fmt.Fprintf(os.Stderr, "Write %v %v start %v end %v\n", n, t, start, end)
-	fmt.Fprintf(w, "int %v_%v_start = %v;\n", n, t, start)
-	fmt.Fprintf(w, "int %v_%v_end = %v;\n", n, t, end)
-	fmt.Fprintf(w, "int %v_%v_len = %v;\n", n, t, end-start)
-	fmt.Fprintf(w, "uint8_t %v_%v_out[] = {\n", n, t)
-	for i := uint64(start); i < end; i += 16 {
-		for j := uint64(0); i+j < end && j < 16; j++ {
-			fmt.Fprintf(w, "0x%02x, ", m[j+i])
-		}
-		fmt.Fprintf(w, "\n")
-	}
-	fmt.Fprintf(w, "};\n")
-}
-func main() {
-	flag.Parse()
-	a := flag.Args()
-	w := &bytes.Buffer{}
-	for _, n := range a[1:] {
-		f, err := elf.Open(n)
-		if err != nil {
-			fmt.Printf("%v %v\n", n, err)
-			continue
-		}
-		var dataend, codeend, end uint64
-		var datastart, codestart, start uint64
-		datastart, codestart, start = math.MaxUint64, math.MaxUint64, math.MaxUint64
-		mem := []byte{}
-		for _, v := range f.Progs {
-			if v.Type != elf.PT_LOAD {
-				continue
-			}
-			fmt.Fprintf(os.Stderr, "processing %v\n", v)
-			// MUST alignt to 2M page boundary.
-			// then MUST allocate a []byte that
-			// is the right size. And MUST
-			// see if by some off chance it
-			// joins to a pre-existing segment.
-			// It's easier than it seems. We produce ONE text
-			// array and ONE data array. So it's a matter of creating
-			// a virtual memory space with an assumed starting point of
-			// 0x200000, and filling it. We just grow that as needed.
-
-			curstart := v.Vaddr & ^uint64(0xfff) // 0x1fffff)
-			curend := v.Vaddr + v.Memsz
-			fmt.Fprintf(os.Stderr, "s %x e %x\n", curstart, curend)
-			if curend > end {
-				nmem := make([]byte, curend)
-				copy(nmem, mem)
-				mem = nmem
-			}
-			if curstart < start {
-				start = curstart
-			}
-
-			if v.Flags&elf.PF_X == elf.PF_X {
-				if curstart < codestart {
-					codestart = curstart
-				}
-				if curend > codeend {
-					codeend = curend
-				}
-				fmt.Fprintf(os.Stderr, "code s %v e %v\n", codestart, codeend)
-			} else {
-				if curstart < datastart {
-					datastart = curstart
-				}
-				if curend > dataend {
-					dataend = curend
-				}
-				fmt.Fprintf(os.Stderr, "data s %v e %v\n", datastart, dataend)
-			}
-			for i := uint64(0); i < v.Filesz; i++ {
-				if amt, err := v.ReadAt(mem[v.Vaddr+i:], int64(i)); err != nil && err != io.EOF {
-					fmt.Fprintf(os.Stderr, "%v: %v\n", amt, err)
-					os.Exit(1)
-				} else if amt == 0 {
-					if i < v.Filesz {
-						fmt.Fprintf(os.Stderr, "%v: Short read: %v of %v\n", v, i, v.Filesz)
-						os.Exit(1)
-					}
-					break
-				} else {
-					i = i + uint64(amt)
-					fmt.Fprintf(os.Stderr, "i now %v\n", i)
-				}
-			}
-			fmt.Fprintf(os.Stderr, "Processed %v\n", v)
-		}
-		fmt.Fprintf(os.Stderr, "gencode\n")
-		_, file := path.Split(n)
-		fmt.Fprintf(w, "uintptr_t %v_main = %v;\n", n, f.Entry)
-		gencode(w, file, "code", mem, codestart, codeend)
-		gencode(w, file, "data", mem, datastart, dataend)
-	}
-	if err := ioutil.WriteFile(a[0], w.Bytes(), 0444); err != nil {
-		fmt.Fprintf(os.Stderr, "elf2c: write %s failed: %v\n", a[0], err)
-	}
-
-}

+ 0 - 83
util/src/harvey/cmd/jsonpretty/jsonpretty.go

@@ -1,83 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"io/ioutil"
-	"os"
-)
-
-func main() {
-	if len(os.Args) < 2 {
-		fmt.Printf("usage: jsonpretty input.json [output.json]\n")
-		os.Exit(1)
-	}
-
-	buf, err := ioutil.ReadFile(os.Args[1])
-	if err != nil {
-		fmt.Printf("%v\n", err)
-		os.Exit(1)
-	}
-
-	var jsmap map[string]interface{}
-	if err := json.Unmarshal(buf, &jsmap); err != nil {
-		fmt.Printf("%v\n", err)
-		os.Exit(1)
-	}
-
-	for key, val := range jsmap {
-		switch tval := val.(type) {
-		case map[string]interface{}:
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		case []interface{}:
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		}
-	}
-
-	buf, err = json.MarshalIndent(jsmap, "", "\t")
-	if err != nil {
-		fmt.Printf("%v\n", err)
-		os.Exit(1)
-	}
-	buf = append(buf, '\n')
-
-	if len(os.Args) == 3 {
-		ioutil.WriteFile(os.Args[2], buf, 0666)
-	} else {
-		os.Stdout.Write(buf)
-	}
-}

+ 0 - 145
util/src/harvey/cmd/kpdump/kpdump.go

@@ -1,145 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"debug/elf"
-	"encoding/binary"
-	"flag"
-	"fmt"
-	"io"
-	"math"
-	"os"
-)
-
-const LRES = 3
-
-var kernel = flag.String("k", "9k", "kernel name")
-
-func main() {
-	flag.Parse()
-
-	n := flag.Args()[0]
-	d, err := os.Open(n)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v\n", err)
-		os.Exit(1)
-	}
-	f, err := elf.Open(*kernel)
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v\n", err)
-		os.Exit(1)
-	}
-
-	var codeend uint64
-	var codestart uint64 = math.MaxUint64
-
-	for _, v := range f.Progs {
-		if v.Type != elf.PT_LOAD {
-			continue
-		}
-		fmt.Fprintf(os.Stderr, "processing %v\n", v)
-		// MUST alignt to 2M page boundary.
-		// then MUST allocate a []byte that
-		// is the right size. And MUST
-		// see if by some off chance it
-		// joins to a pre-existing segment.
-		// It's easier than it seems. We produce ONE text
-		// array and ONE data array. So it's a matter of creating
-		// a virtual memory space with an assumed starting point of
-		// 0x200000, and filling it. We just grow that as needed.
-
-		curstart := v.Vaddr
-		curend := v.Vaddr + v.Memsz
-		// magic numbers, BAH!
-		if curstart < uint64(0xffffffff00000000) {
-			curstart += 0xfffffffff0000000
-			curend += 0xfffffffff0000000
-		}
-		fmt.Fprintf(os.Stderr, "s %x e %x\n", curstart, curend)
-		if v.Flags&elf.PF_X == elf.PF_X {
-			if curstart < codestart {
-				codestart = curstart
-			}
-			if curend > codeend {
-				codeend = curend
-			}
-			fmt.Fprintf(os.Stderr, "code s %x e %x\n", codestart, codeend)
-		}
-	}
-	fmt.Fprintf(os.Stderr, "code s %x e %x\n", codestart, codeend)
-	s, err := f.Symbols()
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "%v\n", err)
-		os.Exit(1)
-	}
-	// maybe we should stop doing LRES ...
-	symname := make([]string, codeend-codestart)
-	for i := range symname {
-		symname[i] = fmt.Sprintf("[0x%x]", codestart+uint64(i))
-	}
-	for _, v := range s {
-		vstart := v.Value
-		vend := v.Value + v.Size
-		if v.Value > codeend {
-			continue
-		}
-		if v.Value+v.Size < codestart {
-			continue
-		}
-		if vstart < codestart {
-			v.Value = codestart
-		}
-		if vend > codeend {
-			vend = codeend
-		}
-		for i := vstart; i < vend; i++ {
-			symname[i-codestart] = v.Name
-		}
-	}
-	symname[0] = "Total ms"
-	symname[1<<LRES] = "Unknown"
-	// now dump the info ...
-	count := uint32(0)
-	pc := codestart
-	for {
-		if err := binary.Read(d, binary.BigEndian, &count); err != nil {
-			if err != io.EOF {
-				fmt.Fprintf(os.Stderr, "%v\n", err)
-			}
-			break
-		}
-		if count > 0 {
-			fmt.Printf("%s %d\n", symname[pc-codestart], count)
-		}
-		pc += (1 << LRES)
-	}
-}

+ 0 - 384
util/src/harvey/cmd/mksys/mksys.go

@@ -1,384 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"fmt"
-	"io/ioutil"
-	"log"
-	"os"
-	"path"
-	"strings"
-	"text/template"
-)
-
-type Syscall struct {
-	Ret     []string
-	Args    []string
-	Name    string
-	Id      uint32
-	Define  string
-	Sysname string
-	Libname string
-	Fudge   string   `json:"-"`
-	GoArgs  []string `json:"-"`
-	Ret0    string   `json:"-"`
-}
-
-type Syserror struct {
-	Name   string
-	String string
-	Id     uint32
-}
-
-type Bootmethods struct {
-	Name    string
-	Config  string
-	Connect string
-	Arg     string
-}
-
-type Sysconf struct {
-	SyscallBase uint32
-	Syscalls    []Syscall
-	Syserrors   []Syserror
-	Bootmethods []Bootmethods
-}
-
-var mode = flag.String("mode", "", "must be one of: sys.h, sysdecl.h, syscallfiles, systab.c, error.h, errstr.h, sys_harvey.s, sysnum.go")
-var outpath = flag.String("o", "", "path/to/output.c")
-
-func usage(msg string) {
-	fmt.Fprintf(os.Stderr, "mksys: invoked via %v\n", os.Args)
-	fmt.Fprintln(os.Stderr, msg)
-	fmt.Fprint(os.Stderr, "Usage: mksys [-o outpath] -mode=MODE path/to/sysconf.json\n")
-	flag.PrintDefaults()
-	os.Exit(1)
-}
-
-func main() {
-
-	flag.Parse()
-
-	if flag.NArg() != 1 {
-		usage("no path to sysconf.json")
-	}
-
-	outfile := os.Stdout
-	if *mode != "syscallfiles" && *outpath != "" {
-		of, err := os.Create(*outpath)
-		if err != nil {
-			log.Fatal(err)
-		}
-		outfile = of
-	}
-
-	buf, err := ioutil.ReadFile(flag.Arg(0))
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	var sysconf Sysconf
-	err = json.Unmarshal(buf, &sysconf)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	syscalls := sysconf.Syscalls
-	syserrors := sysconf.Syserrors
-	bootmethods := sysconf.Bootmethods
-	// Adjust the syscall # for Harvey system calls to 1024 + number
-	// The plan is that we can then bring in a plan 9 system call interface
-	// and easily run native Plan 9 binaries, including Plan 9 Go binaries.
-	// This is a bit of a hack but OTOH it makes for a pretty easy change.
-	// Boot tested.
-	for i := range syscalls {
-		if syscalls[i].Define == "" {
-			syscalls[i].Define = strings.ToUpper(syscalls[i].Name)
-		}
-		if syscalls[i].Sysname == "" {
-			syscalls[i].Sysname = "sys" + syscalls[i].Name
-		}
-		if syscalls[i].Libname == "" {
-			syscalls[i].Libname = syscalls[i].Name
-		}
-		syscalls[i].Id += sysconf.SyscallBase
-	}
-
-	switch *mode {
-	case "sys_harvey.s":
-		a := os.Getenv("ARCH")
-		switch a {
-		case "aarch64":
-			usage("aarch64 support is incomplete")
-		case "amd64":
-		case "riscv":
-			usage("riscv support is incomplete")
-		default:
-			usage(a + " is not supported.")
-		}
-		syscallargs := []string{"DI", "SI", "DX", "R10", "R8", "R9"}
-		//funcallregs := []string{ "DI", "SI", "DX", "CX", "R8", "R9" };
-		for i := range syscalls {
-			goargs := []string{}
-			fpoff := 0
-			for k := range syscalls[i].Args {
-				switch syscalls[i].Args[k] {
-				case "int32_t", "uint32_t":
-					goargs = append(goargs, fmt.Sprintf("MOVL	arg%d+%d(FP), %s", k, fpoff, syscallargs[k]))
-					fpoff += 4
-				case "void*", "char*", "char**", "uint8_t*", "int32_t*", "uint64_t*", "int64_t*", "int64_t":
-					fpoff = (fpoff + 7) & ^7
-					goargs = append(goargs, fmt.Sprintf("MOVQ	arg%d+%d(FP), %s", k, fpoff, syscallargs[k]))
-					fpoff += 8
-				default:
-					log.Fatalf("unsupported arg %s in syscall: %v", syscalls[i].Args[k], syscalls[i])
-				}
-			}
-			syscalls[i].GoArgs = goargs
-			switch syscalls[i].Ret[0] {
-			case "int32_t", "uint32_t":
-				syscalls[i].Ret0 = fmt.Sprintf("MOVL	AX, ret+%d(FP)", fpoff)
-				fpoff += 4
-			case "void*", "char*", "char**", "uint8_t*", "int32_t*", "uint64_t*", "int64_t*", "int64_t":
-				fpoff = (fpoff + 7) & ^7
-				syscalls[i].Ret0 = fmt.Sprintf("MOVQ	AX, ret+%d(FP)", fpoff)
-				fpoff += 8
-			default:
-				log.Fatalf("unsupported Ret[0] in syscall: %v", syscalls[i])
-			}
-		}
-		tmpl, err := template.New("sys_harvey.s").Parse(`/* automatically generated by mksys */
-/* System calls for AMD64, Harvey */
-#include "go_asm.h"
-#include "go_tls.h"
-#include "textflag.h"
-{{ range . }}
-TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
-{{ range .GoArgs }}	{{ . }}
-{{ end }}	MOVQ	${{ .Id }}, AX
-	SYSCALL
-	{{ .Ret0 }}
-	RET
-{{ end }}
-`)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-		err = tmpl.Execute(outfile, syscalls)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "syscallfiles":
-		var tmpl *template.Template
-		var err error
-		a := os.Getenv("ARCH")
-		switch a {
-		case "aarch64":
-			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
-.globl	{{ .Libname }}
-{{ .Libname }}:
-	mov	x8, #{{ .Id }}
-	svc	#0
-	ret
-`)
-		case "amd64":
-			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
-.globl	{{ .Libname }}
-{{ .Libname }}:
-	movq %rcx, %r10 /* rcx gets smashed by systenter. Use r10.*/
-	movq ${{ .Id }},%rax  /* Put the system call into rax, just like linux. */
-	syscall
-	ret
-`)
-			if err != nil {
-				log.Fatal(err)
-			}
-		case "riscv":
-			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
-.globl	{{ .Libname }}
-{{ .Libname }}:
-	li a7, {{ .Id }}  /* Put the system call into a7 so we don't have to move a0-a6 around*/
-	scall
-	ret
-`)
-			if err != nil {
-				log.Fatal(err)
-			}
-		default:
-			usage(a + " is not supported for system call generation.")
-		}
-
-		for i := range syscalls {
-
-			path := path.Join(*outpath, syscalls[i].Libname+".s")
-			file, err := os.Create(path)
-			if err != nil {
-				log.Fatal(err)
-			}
-
-			err = tmpl.Execute(file, syscalls[i])
-			if err != nil {
-				log.Fatal(err)
-			}
-
-			err = file.Close()
-			if err != nil {
-				log.Fatal(err)
-			}
-		}
-	case "sysnum.go":
-		tmpl, err := template.New("sysnum.go").Parse(`// automatically generated by mksys
-package syscall
-
-const(
-{{ range . }}	SYS_{{ .Define }} = {{ .Id }}
-{{ end }}
-)
-`)
-		err = tmpl.Execute(outfile, syscalls)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "sys.h":
-		tmpl, err := template.New("sys.h").Parse(`/* automatically generated by mksys */
-{{ range . }}#define {{ .Define }} {{ .Id }}
-{{ end }}
-`)
-		err = tmpl.Execute(outfile, syscalls)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "sysdecl.h":
-		tmpl, err := template.New("sysdecl.h").Parse(`/* automatically generated by mksys */
-{{ range . }}extern {{ .Ret0 }} {{ .Libname }}({{ range $i, $e := .Args }}{{ if $i }}, {{ end }}{{ $e }}{{ end }});
-{{ end }}
-`)
-		err = tmpl.Execute(outfile, syscalls)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "systab.c":
-		for i := range syscalls {
-			var fudge string
-			switch syscalls[i].Ret[0] {
-			case "int32_t":
-				fudge = "{ .i = -1 }"
-			case "int64_t":
-				fudge = "{ .vl = -1ll }"
-			case "void*", "char*":
-				fudge = "{ .v = (void*)-1ll }"
-			default:
-				log.Fatalf("unsupported Ret[0] in syscall: %v", syscalls[i])
-			}
-			if syscalls[i].Fudge == "" {
-				syscalls[i].Fudge = fudge
-			}
-
-			syscalls[i].Ret0 = syscalls[i].Ret[0]
-		}
-		tmpl, err := template.New("systab.c").Parse(`/* automatically generated by mksys */
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-#include "../../libc/9syscall/sys.h"
-
-{{ range . }}extern void {{ .Sysname }}(Ar0*, ...);
-{{ end }}
-Systab systab[] = {
-{{ range . }}[{{ .Define }}] = { "{{ .Name }}", {{ .Sysname }}, {{ .Fudge }} },
-{{ end }}
-};
-int nsyscall = nelem(systab);
-`)
-		err = tmpl.Execute(outfile, syscalls)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "error.h":
-		tmpl, err := template.New("error.h").Parse(`/* automatically generated by mksys */
-{{ range . }}extern char {{ .Name }}[]; /* {{ .String }} */
-{{ end }}
-`)
-		err = tmpl.Execute(outfile, syserrors)
-		if err != nil {
-			log.Fatal(err)
-		}
-
-	case "errstr.h":
-		tmpl, err := template.New("errstr.h").Parse(`/* automatically generated by mksys */
-{{ range . }}char {{ .Name }}[] = "{{ .String }}";
-{{ end }}
-`)
-		err = tmpl.Execute(outfile, syserrors)
-		if err != nil {
-			log.Fatal(err)
-		}
-	case "bootcpu.c":
-		tmpl, err := template.New("bootcpu.c").Parse(`/* automatically generated by mksys */
-#include <u.h>
-#include <libc.h>
-
-#include "../boot/boot.h"
-
-Method method[] = {
-{{ range . }}{ "{{.Name}}", {{.Config}}, {{.Connect}}, "{{.Arg}}", },
-{{ end }}{ nil },
-};
-
-int cpuflag = 1;
-char* rootdir = "/root";
-char* bootdisk = "#S/sdE0/";
-extern void boot(int, char**);
-
-void
-main(int argc, char **argv)
-{
-		boot(argc, argv);
-}
-int (*cfs)(int) = 0;
-`)
-		err = tmpl.Execute(outfile, bootmethods)
-		if err != nil {
-			log.Fatal(err)
-		}
-	}
-}

+ 0 - 137
util/src/harvey/cmd/op2/op2.go

@@ -1,137 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"encoding/binary"
-	"fmt"
-	"io"
-	"os"
-)
-
-/*
-first word
-high 8 bits is ee, which is an invalid address on amd64.
-next 8 bits is protocol version
-next 16 bits is unused, MBZ. Later, we can make it a packet type.
-next 16 bits is core id
-next 8 bits is unused
-next 8 bits is # words following.
-
-second word is time in ns. (soon to be tsc ticks)
-
-Third and following words are PCs, there must be at least one of them.
-*/
-type sample struct {
-	Wordcount, _    uint8
-	Coreid          uint16
-	_               uint16
-	Version, Marker uint8
-	Ns              uint64
-}
-
-type backtrace struct {
-	Pcs []uint64
-}
-
-/* the docs lie. Perl expects Count to be zero. I only wasted a day figuring this out. */
-type hdr struct {
-	Count, Slots, Format, Period, Padding uint64
-}
-
-type record struct {
-	Count, Size uint64
-	Pcs         []uint64
-}
-
-type trailer struct {
-	Zero, One, Zeroh uint64
-}
-
-func main() {
-	var s sample
-
-	r := io.Reader(os.Stdin)
-	w := io.Writer(os.Stdout)
-
-	records := make(map[string]uint64, 16384)
-	backtraces := make(map[string][]uint64, 1024)
-
-	/* ignore the documentation, it's wrong, first word must be zero.
-	 * the perl code that figures word length depends on it.
-	 */
-	hdr := hdr{0, 3, 0, 10000, 0}
-	trailer := trailer{0, 1, 0}
-	start := uint64(0)
-	end := start
-	nsamples := end
-	for binary.Read(r, binary.LittleEndian, &s) == nil {
-		numpcs := int(s.Wordcount)
-		bt := make([]uint64, numpcs)
-		binary.Read(r, binary.LittleEndian, &bt)
-		//fmt.Printf("%v\n", bt)
-		record := ""
-		/* Fix the symbols. pprof was unhappy about the 0xfffffff.
-		 * N.B. The fact that we have to mess with the bt values
-		 * is the reason we did not write a stringer for bt.
-		 */
-		for i := range bt {
-			bt[i] = bt[i] & ((uint64(1) << 32) - 1)
-			record = record + fmt.Sprintf("0x%x ", bt[i])
-		}
-		records[record]++
-		backtraces[record] = bt
-		//fmt.Printf("%v %d %d %x %v record %v\n", s, s.Wordcount, s.Coreid, s.Ns, bt, record)
-		/* how sad, once we go to ticks this gets ugly. */
-		if start == 0 {
-			start = s.Ns
-		}
-		end = s.Ns
-		nsamples++
-	}
-	/* we'll need to fix this once we go to ticks. */
-	hdr.Period = (end - start) / nsamples
-	hdr.Count = uint64(0) // !@$@!#$!@#$len(records))
-	//fmt.Printf("start %v end %v nsamples %d period %d\n", start, end, nsamples, hdr.Period)
-	binary.Write(w, binary.LittleEndian, &hdr)
-	out := make([]uint64, 2)
-	/* note that the backtrace length varies. But we're good with that. */
-	for key, v := range records {
-		bt := backtraces[key]
-		out[0] = v
-		out[1] = uint64(len(bt))
-		dump := append(out, bt...)
-		//fmt.Printf("dump %v\n", dump)
-		binary.Write(w, binary.LittleEndian, &dump)
-	}
-	binary.Write(w, binary.LittleEndian, &trailer)
-
-}

+ 0 - 1
util/src/harvey/cmd/preen/.gitignore

@@ -1 +0,0 @@
-/preen

+ 0 - 187
util/src/harvey/cmd/preen/preen.go

@@ -1,187 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"io/ioutil"
-	"log"
-	"os"
-	"path/filepath"
-)
-
-var config = struct {
-	Harvey   string
-	Args     []string
-	Except   map[string]bool
-	CmdName  string
-	FullPath string
-	Src      string
-	Uroot    string
-	Cwd      string
-	Bbsh     string
-
-	Goroot    string
-	Gosrcroot string
-	Arch      string
-	Goos      string
-	Gopath    string
-	TempDir   string
-	Go        string
-	Debug     bool
-	Fail      bool
-}{
-	Harvey: os.Getenv("HARVEY"),
-	Except: map[string]bool{"cflags.json": true, "9": true, "libauthcmd.json": true, "awk.json": true, "bzip2": true, "klibc.json": true, "kcmds.json": true, "klib.json": true, "kernel.json": true},
-}
-
-type fixup func(string, map[string]interface{})
-
-func cflags(n string, jsmap map[string]interface{}) {
-	if _, ok := jsmap["Cflags"]; ok {
-		log.Printf("Deleting Cflags from %v", n)
-		delete(jsmap, "Cflags")
-		// TODO: once we have another ARCH, use it.
-		a := []string{"/amd64/include/cflags.json"}
-		switch tval := jsmap["Include"].(type) {
-		case []interface{}:
-			for _, v := range tval {
-				a = append(a, v.(string))
-			}
-		}
-		jsmap["Include"] = a
-	}
-}
-
-func removeempty(n string, jsmap map[string]interface{}) {
-	for key, val := range jsmap {
-		switch tval := val.(type) {
-		case map[string]interface{}:
-			log.Printf("%s: tval %s", n, tval)
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		case []interface{}:
-			if len(tval) == 0 {
-				delete(jsmap, key)
-			}
-		}
-	}
-}
-
-func checkname(n string, jsmap map[string]interface{}) {
-	if _, ok := jsmap["Name"]; !ok {
-		log.Printf("File %v has no \"Name\" key", n)
-	}
-}
-
-func one(n string, f ...fixup) error {
-	buf, err := ioutil.ReadFile(n)
-	if err != nil {
-		return err
-	}
-
-	var jsmap map[string]interface{}
-	if err := json.Unmarshal(buf, &jsmap); err != nil {
-		return err
-	}
-	if config.Debug {
-		log.Printf("%v: %v", n, jsmap)
-	}
-
-	for _, d := range f {
-		d(n, jsmap)
-	}
-	buf, err = json.MarshalIndent(jsmap, "", "\t")
-	if err != nil {
-		return err
-	}
-	buf = append(buf, '\n')
-
-	if config.Debug {
-		os.Stdout.Write(buf)
-	} else {
-		ioutil.WriteFile(n, buf, 0666)
-	}
-	return nil
-}
-
-func init() {
-	if config.Harvey == "" {
-		log.Fatalf("Please set $HARVEY")
-	}
-
-	if len(config.Args) == 0 {
-		config.Args = []string{config.Harvey}
-	}
-}
-
-func main() {
-	var err error
-
-	flag.BoolVar(&config.Debug, "d", true, "Enable debug prints")
-	flag.Parse()
-	config.Args = flag.Args()
-	for _, n := range config.Args {
-		err = filepath.Walk(n, func(name string, fi os.FileInfo, err error) error {
-			if err != nil {
-				return err
-			}
-			if fi.IsDir() {
-				if config.Except[fi.Name()] {
-					return filepath.SkipDir
-				}
-				return nil
-			}
-			n := fi.Name()
-			if len(n) < 5 || n[len(n)-5:] != ".json" {
-				return nil
-			}
-			todo := []fixup{cflags, removeempty, checkname}
-			if config.Except[n] {
-				todo = todo[1:]
-			}
-			log.Printf("process %s", name)
-			err = one(name, todo...)
-			if err != nil {
-				log.Printf("%s: %s\n", name, err)
-				return err
-			}
-			return nil
-		})
-
-		if err != nil {
-			log.Fatalf("%v", err)
-
-		}
-	}
-}

+ 0 - 160
util/src/harvey/cmd/profile/profile.go

@@ -1,160 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"debug/elf"
-	"encoding/binary"
-	"flag"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"os"
-	"sort"
-)
-
-type Header struct {
-	Sz   byte
-	_    byte
-	Core uint16
-	_    uint16
-	Ver  byte
-	Sig  byte
-	Time uint64
-}
-
-type pc uint64
-
-type Record struct {
-	Header
-	pcs []pc
-}
-
-type Symbol struct {
-	Addr uint64
-	Name string
-}
-
-type Symbols []*Symbol
-
-func (s Symbols) Len() int      { return len(s) }
-func (s Symbols) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
-
-type ByAddress struct{ Symbols }
-
-func (s ByAddress) Less(i, j int) bool { return s.Symbols[i].Addr < s.Symbols[j].Addr }
-
-var (
-	profile     = flag.String("profile", "", "name of file containing profile data")
-	debug       = flag.Bool("d", false, "Debug printing")
-	kernel      = flag.String("kernel", "", "kernel to profile against")
-	symbolTable []*Symbol
-)
-
-func loadSymbols(kernel *elf.File) {
-	syms, err := kernel.Symbols()
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-
-	for _, sym := range syms {
-		value := sym.Value | 0xffffffff00000000
-		symbolTable = append(symbolTable, &Symbol{value, sym.Name})
-	}
-	sort.Sort(ByAddress{symbolTable})
-}
-
-func findFunction(pc pc) string {
-	addr := uint64(pc)
-	var prevSym *Symbol
-	for _, sym := range symbolTable {
-		if sym.Addr > addr && prevSym != nil {
-			return prevSym.Name
-		}
-		prevSym = sym
-	}
-	return "*** Not Found ***"
-}
-
-func main() {
-	flag.Parse()
-	kernelElf, err := elf.Open(*kernel)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-	loadSymbols(kernelElf)
-
-	backtraces, err := ioutil.ReadFile(*profile)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-
-	b := bytes.NewBuffer(backtraces)
-	var numRecords int
-	var records []Record
-	for {
-		var h Header
-		if err := binary.Read(b, binary.LittleEndian, &h); err != nil {
-			if err == io.EOF {
-				break
-			}
-			fmt.Fprintf(os.Stderr, "header: %v\n", err)
-			os.Exit(1)
-		}
-		if *debug {
-			fmt.Fprintf(os.Stderr, "%d: %v\n", numRecords, h)
-		}
-
-		if h.Sig != 0xee {
-			fmt.Fprintf(os.Stderr, "Record %d: sig is 0x%x, not 0xee", numRecords, h.Sig)
-			os.Exit(1)
-		}
-		pcs := make([]pc, h.Sz)
-		if err := binary.Read(b, binary.LittleEndian, pcs); err != nil {
-			fmt.Fprintf(os.Stderr, "data: %v\n", err)
-			os.Exit(1)
-		}
-		numRecords++
-		records = append(records, Record{Header: h, pcs: pcs})
-	}
-
-	for _, r := range records {
-		fmt.Printf("0x%x: ", r.Time)
-		for _, pc := range r.pcs {
-			fmt.Printf("[0x%x, %s] ", pc, findFunction(pc))
-		}
-		fmt.Printf("\n")
-	}
-}

+ 0 - 29
util/src/harvey/cmd/qtap/main.go

@@ -1,29 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"log"
-	"os"
-	"time"
-
-	"github.com/u-root/u-root/pkg/qemu"
-)
-
-func main() {
-	os.Setenv("UROOT_QEMU", "qemu-system-x86_64 -m 512");
-	opts := &qemu.Options{
-		Kernel:       os.ExpandEnv("$HARVEY/sys/src/9/amd64/harvey.32bit"),
-		SerialOutput: os.Stdout,
-		KernelArgs:   "service=terminal nobootprompt=tcp maxcores=1024 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1",
-	}
-	log.Println(opts.Cmdline())
-	vm, err := opts.Start()
-	if err != nil {
-		log.Fatal()
-	}
-	if err := vm.ExpectTimeout("Hello, I am Harvey :-)", time.Minute); err != nil {
-		log.Fatal(err)
-	}
-	vm.Close()
-	fmt.Println("Harvey booted successfully")
-}

+ 0 - 108
util/src/harvey/cmd/removemach/removemach.go

@@ -1,108 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"debug/elf"
-	"flag"
-	"fmt"
-	"io/ioutil"
-	"os"
-	"path/filepath"
-	"strings"
-)
-
-var dry = flag.Bool("dryrun", true, "don't really do it")
-
-func main() {
-	flag.Parse()
-	a := flag.Args()
-	for _, n := range a {
-		f, err := elf.Open(n)
-		if err != nil {
-			fmt.Printf("%v %v\n", n, err)
-			continue
-		}
-
-		s, err := f.Symbols()
-		if err != nil {
-			fmt.Printf("%v %v\n", n, err)
-			continue
-		}
-		usem := false
-		for _, v := range s {
-			if v.Name == "m" && v.Section == elf.SHN_UNDEF {
-				usem = true
-				cf := strings.Split(n, ".")
-				globs, err := filepath.Glob("../*/" + cf[0] + ".c")
-				if err != nil || len(globs) == 0 {
-					fmt.Fprintf(os.Stderr, "%v has NO source?\n", cf[0])
-					continue
-				}
-				if len(globs) > 1 {
-					fmt.Fprintf(os.Stderr, "Skipping %v has more than one source?\n", cf[0])
-					continue
-				}
-				file := globs[0]
-				fi, err := os.Stat(file)
-				if err != nil {
-					fmt.Fprintf(os.Stderr, "%v\n", err)
-					continue
-				}
-				/* OK, read it in, write it out */
-				b, err := ioutil.ReadFile(file)
-				if err != nil {
-					fmt.Fprintf(os.Stderr, "%v: %v\n", file, err)
-				}
-				header := []byte("extern Mach *m; // REMOVE ME\n")
-				if bytes.Compare(header[:], b[0:len(header)]) == 0 {
-					fmt.Fprintf(os.Stderr, "%v already done; skipping\n", file)
-					continue
-				}
-				out := append([]byte("typedef struct Mach Mach; extern Mach *m; // REMOVE ME\n"), b...)
-				if *dry {
-					fmt.Fprintf(os.Stderr, "Would do %v mode %v\n", file, fi.Mode())
-					continue
-				}
-				if err := ioutil.WriteFile(file, out, fi.Mode()); err != nil {
-					fmt.Fprintf(os.Stderr, "Write %v failed: %v; git checkout %v\n", file, err, file)
-				}
-			}
-		}
-		if !usem {
-			fmt.Fprintf(os.Stderr, "Ignored %v as it did not reference Mach *m\n", n)
-		} else {
-			fmt.Fprintf(os.Stderr, "Procssed %v as it did reference Mach *m\n", n)
-		}
-	}
-
-}

+ 0 - 139
util/src/harvey/cmd/syslinux/syslinux.go

@@ -1,139 +0,0 @@
-package main
-
-import (
-	"bytes"
-	"flag"
-	"io"
-	"io/ioutil"
-	"log"
-	"os"
-	"os/exec"
-	"path/filepath"
-)
-
-var (
-	part = `label: dos
-label-id: 0xadc9f7b1
-device: /dev/nbd0
-unit: sectors
-
-/dev/nbd0p1 : start=        2048, size=      102400, type=83, bootable
-/dev/nbd0p2 : start=      104448, size=     6187008, type=39
-`
-	syslinuxconfig = []byte(`
-TIMEOUT 50
-DEFAULT vesamenu.c32
-#DEFAULT 0
-MENU TITLE Harvey OS
-PROMPT 0
-ONTIMEOUT 0
-
-LABEL 0
-TEXT HELP
-Boot Harvey kernel with local filesystem
-ENDTEXT
-MENU LABEL Harvey OS (Local FS)
-KERNEL mboot.c32
-APPEND ../harvey service=cpu nobootprompt=local!#S/sdE0/ maxcores=1024 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1 mouseport=ps2 vgasize=1024x768x24 monitor=vesa
-
-LABEL 1
-TEXT HELP
-Boot Harvey kernel with remote filesystem (10.0.2.2)
-ENDTEXT
-MENU LABEL Harvey OS (Remote FS)
-KERNEL mboot.c32
-APPEND ../harvey service=cpu nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1 mouseport=ps2 vgasize=1024x768x24 monitor=vesa
-
-LABEL 2
-TEXT HELP
-Install harvey on image
-ENDTEXT
-MENU LABEL Harvey OS (Install)
-KERNEL mboot.c32
-APPEND ../harvey service=cpu nobootprompt=tcp maxcores=1024 fs=10.0.2.2 auth=10.0.2.2 nvram=/boot/nvram nvrlen=512 nvroff=0 acpiirq=1 mouseport=ps2 vgasize=1024x768x24 monitor=vesa onstartup=/util/img/prepfs
-`)
-)
-
-type command struct {
-	*exec.Cmd
-	in io.Reader
-}
-
-func gencmds(imgType string) []command {
-	imgFilename := "harvey." + imgType
-	return []command{
-		{Cmd: exec.Command("qemu-img", "create", "-f", imgType, imgFilename, "3G")},
-		{Cmd: exec.Command("chown", os.ExpandEnv("$SUDO_USER"), imgFilename)},
-		{Cmd: exec.Command("chgrp", os.ExpandEnv("$SUDO_USER"), imgFilename)},
-		{Cmd: exec.Command("modprobe", "nbd", "max_part=63")},
-		{Cmd: exec.Command("qemu-nbd", "-c", "/dev/nbd0", "-f", imgType, imgFilename)},
-		{Cmd: exec.Command("dd", "conv=notrunc", "bs=440", "count=1", "if=img/syslinux-bios/mbr.bin", "of=/dev/nbd0")},
-		{Cmd: exec.Command("sfdisk", "/dev/nbd0"), in: bytes.NewBufferString(part)},
-		{Cmd: exec.Command("mkfs.ext4", "/dev/nbd0p1")},
-		{Cmd: exec.Command("mkdir", "-p", "disk/")},
-		{Cmd: exec.Command("mount", "/dev/nbd0p1", "disk/")},
-		{Cmd: exec.Command("extlinux", "-i", "disk/")},
-		{Cmd: exec.Command("cp", "../sys/src/9/amd64/harvey.32bit", "disk/harvey")},
-		{Cmd: exec.Command("ls", "-l", "disk")},
-	}
-}
-
-func detach() {
-	log.Println("Detaching")
-	if err := exec.Command("umount", "disk").Run(); err != nil {
-		log.Print(err)
-	}
-	if err := exec.Command("qemu-nbd", "-d", "/dev/nbd0").Run(); err != nil {
-		log.Print(err)
-	}
-}
-
-func main() {
-	imgType := flag.String("imgtype", "raw", "Type of image to create (raw, qcow2)")
-	flag.Parse()
-	if *imgType != "qcow2" && *imgType != "raw" {
-		log.Println("Invalid imgtype")
-		return
-	}
-
-	if os.Getuid() != 0 {
-		log.Println("You have to run me as root")
-		return
-	}
-
-	defer detach()
-
-	setupcmds := gencmds(*imgType)
-	for _, c := range setupcmds {
-		c.Stdin, c.Stdout, c.Stderr = c.in, os.Stdout, os.Stderr
-		if err := c.Run(); err != nil {
-			log.Printf("%v: %v", c.Cmd, err)
-			return
-		}
-	}
-
-	fi, err := ioutil.ReadDir("img/syslinux-bios/syslinux")
-	if err != nil {
-		log.Print(err)
-		return
-	}
-	if err := os.Mkdir("disk/syslinux", 0777); err != nil {
-		log.Print(err)
-	}
-	for _, f := range fi {
-		log.Printf("Process %v", f)
-		b, err := ioutil.ReadFile(filepath.Join("img/syslinux-bios/syslinux", f.Name()))
-		if err != nil {
-			log.Print(err)
-			return
-		}
-		if err := ioutil.WriteFile(filepath.Join("disk/syslinux/", f.Name()), b, 0666); err != nil {
-			log.Print(err)
-			return
-		}
-	}
-	if err := ioutil.WriteFile(filepath.Join("disk/syslinux/", "syslinux.cfg"), syslinuxconfig, 0666); err != nil {
-		log.Print(err)
-		return
-	}
-}

+ 0 - 271
util/src/harvey/cmd/telnet/telnet.go

@@ -1,271 +0,0 @@
-/*
-Copyright 2018 Harvey OS Team
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package main
-
-import (
-	"bytes"
-	"fmt"
-	"golang.org/x/crypto/ssh/terminal"
-	"io"
-	"net"
-	"os"
-	"os/signal"
-	"strings"
-	"syscall"
-)
-
-// Copyright 2012 the u-root Authors. All rights reserved
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-type (
-	chunk struct {
-		id  int
-		buf []byte
-	}
-)
-
-const (
-	echo = false
-)
-
-func comprefix(lines [][]byte) (int, int) {
-	var line0 []byte
-	len0 := 0
-	for _, ln := range lines {
-		if len(ln) > len0 {
-			line0 = ln
-			len0 = len(ln)
-		}
-	}
-	ndiff := 0
-	for i := range line0 {
-		nshort := 0
-		for _, ln := range lines {
-			if i >= len(ln) {
-				nshort++
-			} else if ln[i] != line0[i] {
-				ndiff++
-			}
-		}
-		if ndiff > 0 {
-			return i, ndiff
-		}
-		if nshort > 0 {
-			return i, ndiff
-		}
-	}
-	return len(line0), ndiff
-}
-
-func main() {
-
-	if len(os.Args) < 2 {
-		os.Exit(1)
-	}
-
-	var conns []*net.TCPConn
-	for _, a := range os.Args[1:] {
-		port := "1522"
-		if !strings.Contains(a, ":") {
-			a = a + ":" + port
-		}
-
-		tcpdst, err := net.ResolveTCPAddr("tcp", a)
-		if err != nil {
-			fmt.Printf("%v\n", err)
-			os.Exit(1)
-		}
-
-		c, err := net.DialTCP("tcp", nil, tcpdst)
-		if err != nil {
-			fmt.Printf("%v\n", err)
-			os.Exit(1)
-		}
-		conns = append(conns, c)
-	}
-	unraw, err := terminal.MakeRaw(0)
-	if err != nil {
-		fmt.Printf("%v\n", err)
-		os.Exit(1)
-	}
-	defer terminal.Restore(0, unraw)
-
-	sigc := make(chan os.Signal, 1)
-	signal.Notify(sigc, os.Interrupt, os.Kill, syscall.SIGTERM)
-	go func() {
-		for _ = range sigc {
-			terminal.Restore(0, unraw)
-			os.Exit(1)
-		}
-	}()
-
-	go func() {
-		buf := make([]byte, 256)
-		for {
-			n, err := os.Stdin.Read(buf)
-			if err != nil {
-				if err != io.EOF {
-					fmt.Printf("%v\n", err)
-				}
-				for _, c := range conns {
-					c.CloseWrite() // I know, I know.. but it is handy sometimes.
-				}
-				break
-			}
-			buf = buf[0:n]
-			for i := range buf {
-				if echo {
-					fmt.Printf("%s", string(buf[i]))
-				}
-				if buf[i] == '\r' {
-					buf[i] = '\n'
-					if echo {
-						fmt.Printf("\n")
-					}
-				}
-			}
-
-			for _, c := range conns {
-				if _, err := c.Write(buf); err != nil {
-					fmt.Printf("%v\n", err)
-					break
-				}
-			}
-
-		}
-	}()
-
-	waitc := make(chan int)
-	chunkc := make(chan chunk)
-	for id, c := range conns {
-		go func(id int, c *net.TCPConn) {
-			for {
-				buf := make([]byte, 256)
-				n, err := c.Read(buf)
-				if err != nil {
-					if err != io.EOF {
-						fmt.Printf("%v\n", err)
-					}
-					c.Close()
-					waitc <- 1
-					break
-				}
-				if n == 0 {
-					continue
-				}
-				chunkc <- chunk{id, buf[0:n]}
-			}
-		}(id, c)
-	}
-
-	act := make([][]byte, len(conns))
-
-	go func() {
-		oldpfix := 0
-		insync := true
-		for {
-			chunk, more := <-chunkc
-			if !more {
-				break
-			}
-			id := chunk.id
-			for _, b := range chunk.buf {
-				act[id] = append(act[id], b)
-				if false && b == '\b' {
-					act[id] = append(act[id], ' ')
-					act[id] = append(act[id], '\b')
-				}
-			}
-
-			/* streams agree, so spit out all they agree on */
-			if insync {
-				newpfix, ndiff := comprefix(act)
-				if ndiff == 0 && newpfix > oldpfix {
-					os.Stdout.Write(act[id][oldpfix:newpfix])
-					for {
-						i := bytes.IndexByte(act[id][:newpfix], '\n')
-						if i == -1 {
-							break
-						}
-						for id := range act {
-							clen := copy(act[id], act[id][i+1:])
-							act[id] = act[id][0:clen]
-						}
-						newpfix = newpfix - (i + 1)
-					}
-					oldpfix = newpfix
-				}
-
-				if ndiff > 0 {
-					insync = false
-				}
-			}
-
-			/*
-			 *	streams disagree, first to newline completes from oldpfix on.
-			 *	the outer loop is just for transitioning from insync, where
-			 *	a leader may be several lines ahead
-			 */
-			if !insync {
-				for id := range act {
-					for {
-						i := bytes.IndexByte(act[id], '\n')
-						if i != -1 {
-							if oldpfix == 0 {
-								fmt.Fprintf(os.Stdout, "[%d]", id)
-							}
-							os.Stdout.Write(act[id][oldpfix : i+1])
-							clen := copy(act[id], act[id][i+1:])
-							act[id] = act[id][0:clen]
-							oldpfix = 0
-						} else {
-							break
-						}
-					}
-				}
-
-				/* try for prompt (or sheer luck) */
-				if _, ndiff := comprefix(act); ndiff == 0 {
-					insync = true
-					oldpfix = 0
-				}
-			}
-		}
-		waitc <- 1
-	}()
-
-	for _ = range conns {
-		<-waitc
-	}
-	close(chunkc)
-	<-waitc
-}