summaryrefslogtreecommitdiff
path: root/sys/src/9/boot/paq.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/9/boot/paq.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/9/boot/paq.c')
-rwxr-xr-xsys/src/9/boot/paq.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/sys/src/9/boot/paq.c b/sys/src/9/boot/paq.c
new file mode 100755
index 000000000..9536d78aa
--- /dev/null
+++ b/sys/src/9/boot/paq.c
@@ -0,0 +1,67 @@
+#include <u.h>
+#include <libc.h>
+#include <../boot/boot.h>
+
+char *fparts[] =
+{
+ "add bootldr 0x0000000 0x0040000",
+ "add params 0x0040000 0x0080000",
+ "add kernel 0x0080000 0x0140000",
+ "add user 0x0140000 0x0200000",
+ "add ramdisk 0x0200000 0x0600000",
+};
+
+void
+configpaq(Method*)
+{
+ int fd;
+ int i;
+
+ if(bind("#F", "/dev", MAFTER) < 0)
+ fatal("bind #c");
+ if(bind("#p", "/proc", MREPL) < 0)
+ fatal("bind #p");
+ fd = open("/dev/flash/flashctl", OWRITE);
+ if(fd < 0)
+ fatal("opening flashctl");
+ for(i = 0; i < nelem(fparts); i++)
+ if(fprint(fd, fparts[i]) < 0)
+ fatal(fparts[i]);
+ close(fd);
+}
+
+int
+connectpaq(void)
+{
+ int p[2];
+ char **arg, **argp;
+
+ print("paq...");
+ if(pipe(p)<0)
+ fatal("pipe");
+ switch(fork()){
+ case -1:
+ fatal("fork");
+ case 0:
+ arg = malloc(10*sizeof(char*));
+ argp = arg;
+ *argp++ = "paqfs";
+ *argp++ = "-v";
+ *argp++ = "-i";
+ *argp++ = "/dev/flash/ramdisk";
+ *argp = 0;
+
+ dup(p[0], 0);
+ dup(p[1], 1);
+ close(p[0]);
+ close(p[1]);
+ exec("/boot/paqfs", arg);
+ fatal("can't exec paqfs");
+ default:
+ break;
+ }
+ waitpid();
+
+ close(p[1]);
+ return p[0];
+}