nusb: change usbevent format, put nusbrc in bootfs

This commit is contained in:
cinap_lenrek 2011-07-30 07:23:26 +02:00
parent 9d49fcdb37
commit f9846213d1
4 changed files with 29 additions and 9 deletions

View file

@ -152,10 +152,7 @@ if(test -e '#b' && test -x /bin/aux/kbdfs){
aux/kbdfs -s cons $a aux/kbdfs -s cons $a
} }
if(test -e '#u' && test -x /bin/usb/usbd){ nusbrc
bind -a '#u' /dev
usb/usbd
}
# bind in an ip interface # bind in an ip interface
for(i in I l^(0 1 2 3)) for(i in I l^(0 1 2 3))

18
sys/src/9/boot/nusbrc Normal file
View file

@ -0,0 +1,18 @@
#!/bin/rc
if(! bind -a '#u' /dev)
exit
if(! nusb/usbd)
exit
fn dev {
switch($4){
case *03
nusb/kb $1
case *08
nusb/disk $1
}
}
rc </dev/usbevent &
bind -a '#σ/usb' /dev

View file

@ -30,8 +30,10 @@ $cputype
srv srv
test test
unmount unmount
usb nusb
usbd usbd
disk
kb
xd xd
rc rc
lib lib
@ -41,5 +43,6 @@ rc
bin bin
fstype fstype
diskparts diskparts
nusbrc 555 sys sys ../boot/nusbrc
bootrc 555 sys sys ../boot/bootrc bootrc 555 sys sys ../boot/bootrc
tmp tmp

View file

@ -208,8 +208,7 @@ formatdev(Dev *d)
Usbdev *u; Usbdev *u;
u = d->usb; u = d->usb;
return smprint("in id %d vid 0x%.4x did 0x%.4x csp 0x%.8lx\n", return smprint("dev %d %.4x %.4x %.8lx\n", d->id, u->vid, u->did, u->csp);
d->id, u->vid, u->did, u->csp);
} }
static void static void
@ -333,8 +332,10 @@ main(int argc, char **argv)
{ {
int fd, i, nd; int fd, i, nd;
Dir *d; Dir *d;
argc--; argv++; ARGBEGIN {
} ARGEND;
initevent(); initevent();
rfork(RFNOTEG); rfork(RFNOTEG);
switch(rfork(RFPROC|RFMEM)){ switch(rfork(RFPROC|RFMEM)){
@ -358,4 +359,5 @@ main(int argc, char **argv)
rendezvous(work, strdup(argv[i])); rendezvous(work, strdup(argv[i]));
rendezvous(work, nil); rendezvous(work, nil);
postsharesrv(&usbdsrv, nil, "usb", "usbd", "b"); postsharesrv(&usbdsrv, nil, "usb", "usbd", "b");
exits(nil);
} }