1 /* 2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 #include <kernel.h> 6 #include <stage2.h> 7 #include <memheap.h> 8 #include <devfs.h> 9 #include <vm.h> 10 #include <zero.h> 11 #include <string.h> 12 #include <Errors.h> 13 14 #define DEVICE_NAME "zero" 15 16 static status_t 17 zero_open(const char *name, uint32 flags, void **cookie) 18 { 19 *cookie = NULL; 20 return 0; 21 } 22 23 static status_t 24 zero_close(void * cookie) 25 { 26 return 0; 27 } 28 29 static status_t 30 zero_freecookie(void * cookie) 31 { 32 return 0; 33 } 34 35 static status_t 36 zero_ioctl(void * cookie, uint32 op, void *buf, size_t len) 37 { 38 return EPERM; 39 } 40 41 static ssize_t 42 zero_read(void * cookie, off_t pos, void *buf, size_t *len) 43 { 44 int rc; 45 46 rc = user_memset(buf, 0, *len); 47 if(rc < 0) 48 return rc; 49 50 return 0; 51 } 52 53 static ssize_t 54 zero_write(void * cookie, off_t pos, const void *buf, size_t *len) 55 { 56 return 0; 57 } 58 59 status_t 60 init_hardware() 61 { 62 return 0; 63 } 64 65 const char ** 66 publish_devices(void) 67 { 68 static const char *devices[] = { 69 DEVICE_NAME, 70 NULL 71 }; 72 73 return devices; 74 } 75 76 device_hooks * 77 find_device(const char *name) 78 { 79 static device_hooks hooks = { 80 &zero_open, 81 &zero_close, 82 &zero_freecookie, 83 &zero_ioctl, 84 &zero_read, 85 &zero_write, 86 /* Leave select/deselect/readv/writev undefined. The kernel will 87 * use its own default implementation. The basic hooks above this 88 * line MUST be defined, however. */ 89 NULL, 90 NULL, 91 NULL, 92 NULL 93 }; 94 95 if (!strcmp(name, DEVICE_NAME)) 96 return &hooks; 97 98 return NULL; 99 } 100 101 status_t 102 init_driver() 103 { 104 return 0; 105 } 106 107 void 108 uninit_driver() 109 { 110 } 111 112