123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- /*
- * Stub.
- */
- #include "u.h"
- #include "../port/lib.h"
- #include "mem.h"
- #include "dat.h"
- #include "fns.h"
- #include "../port/error.h"
- extern Dev* devtab[];
- void
- devtabreset(void)
- {
- int i;
- for(i = 0; devtab[i] != nil; i++) {
- devtab[i]->reset();
- }
- }
- void
- devtabinit(void)
- {
- int i;
- for(i = 0; devtab[i] != nil; i++) {
- devtab[i]->init();
- }
- }
- void
- devtabshutdown(void)
- {
- int i;
- /*
- * Shutdown in reverse order.
- */
- for(i = 0; devtab[i] != nil; i++)
- ;
- for(i--; i >= 0; i--)
- devtab[i]->shutdown();
- }
- Dev*
- devtabget(int dc, int user)
- {
- int i;
- for(i = 0; devtab[i] != nil; i++){
- if(devtab[i]->dc == dc)
- return devtab[i];
- }
- if(user == 0)
- panic("devtabget %C\n", dc);
- return nil;
- }
- int32_t
- devtabread(Chan* c, void* buf, int32_t n, int64_t off)
- {
- Proc *up = externup();
- int i;
- Dev *dev;
- char *alloc, *e, *p;
- alloc = malloc(READSTR);
- if(alloc == nil)
- error(Enomem);
- p = alloc;
- e = p + READSTR;
- for(i = 0; devtab[i] != nil; i++){
- dev = devtab[i];
- p = seprint(p, e, "#%C %s\n", dev->dc, dev->name);
- }
- if(waserror()){
- free(alloc);
- nexterror();
- }
- n = readstr(off, buf, n, alloc);
- free(alloc);
- poperror();
- return n;
- }
|