Changeset 86018c1 in mainline for kernel/arch/sparc64/src/drivers/niagara.c
- Timestamp:
- 2010-01-24T19:48:56Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e33e1d
- Parents:
- eeb643d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/drivers/niagara.c
reeb643d r86018c1 54 54 #define POLL_INTERVAL 10000 55 55 56 /**57 * The driver is polling based, but in order to notify the userspace58 * of a key being pressed, we need to supply the interface with some59 * interrupt number. The interrupt number can be arbitrary as it it60 * will never be used for identifying HW interrupts, but only in61 * notifying the userspace.62 */63 #define FICTIONAL_INR 164 65 66 56 static niagara_instance_t *instance = NULL; 67 57 … … 95 85 output_buffer; 96 86 97 #if 0 98 /** Niagara character device */ 99 chardev_t niagara_io; 100 101 /** defined in drivers/kbd.c */ 102 extern kbd_type_t kbd_type; 103 104 /** 105 * The character read will be stored here until the (notified) uspace 106 * driver picks it up. 107 */ 108 static char read_char; 109 110 111 #endif 87 /** 88 * Analogous to the output_buffer, see the previous definition. 89 */ 90 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 91 static volatile struct { 92 uint64_t write_ptr; 93 uint64_t read_ptr; 94 char data[INPUT_BUFFER_SIZE]; 95 } 96 __attribute__ ((packed)) 97 __attribute__ ((aligned(PAGE_SIZE))) 98 input_buffer; 99 112 100 113 101 /** Writes a single character to the standard output. */ … … 126 114 } 127 115 128 #if 0129 /**130 * Grabs the input for kernel.131 */132 void niagara_grab(void)133 {134 ipl_t ipl = interrupts_disable();135 spinlock_lock(&niagara_irq.lock);136 niagara_irq.notif_cfg.notify = false;137 spinlock_unlock(&niagara_irq.lock);138 interrupts_restore(ipl);139 }140 141 /**142 * Releases the input so that userspace can use it.143 */144 void niagara_release(void)145 {146 ipl_t ipl = interrupts_disable();147 spinlock_lock(&niagara_irq.lock);148 if (niagara_irq.notif_cfg.answerbox)149 niagara_irq.notif_cfg.notify = true;150 spinlock_unlock(&niagara_irq.lock);151 interrupts_restore(ipl);152 }153 154 /**155 * Default suspend/resume operation for the input device.156 */157 static void niagara_noop(chardev_t *d)158 {159 }160 161 /**162 * Called when actively reading the character.163 */164 static char niagara_read(chardev_t *d)165 {166 uint64_t c;167 168 if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {169 return (char) c;170 }171 172 return '\0';173 }174 175 /**176 * Returns the character last read. This function is called from the177 * pseudocode - the character returned by this function is passed to178 * the userspace keyboard driver.179 */180 char niagara_getc(void) {181 return read_char;182 }183 184 #endif185 186 116 /** 187 117 * Function regularly called by the keyboard polling thread. Asks the 188 118 * hypervisor whether there is any unread character. If so, it picks it up 189 119 * and sends it to the upper layers of HelenOS. 120 * 121 * Apart from that, it also checks whether the userspace output driver has 122 * pushed any characters to the output buffer. If so, it prints them. 190 123 */ 191 124 static void niagara_poll(niagara_instance_t *instance) … … 200 133 201 134 if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) { 202 indev_push_character(instance->srlnin, c); 135 if (!silent) { 136 indev_push_character(instance->srlnin, c); 137 } else { 138 input_buffer.data[input_buffer.write_ptr] = (char) c; 139 input_buffer.write_ptr = 140 ((input_buffer.write_ptr) + 1) % INPUT_BUFFER_SIZE; 141 } 203 142 } 204 143 … … 210 149 static void kniagarapoll(void *instance) { 211 150 while (true) { 212 //MH 213 //if (!silent) 214 niagara_poll(instance); 215 151 niagara_poll(instance); 216 152 thread_usleep(POLL_INTERVAL); 217 153 } … … 245 181 /* 246 182 * Set sysinfos and pareas so that the userspace counterpart of the 247 * niagara fb driver can communicate with kernel using a shared buffer. 183 * niagara fb and kbd driver can communicate with kernel using shared 184 * buffers. 248 185 */ 249 186 output_buffer.read_ptr = 0; 250 187 output_buffer.write_ptr = 0; 188 input_buffer.write_ptr = 0; 189 input_buffer.read_ptr = 0; 251 190 252 191 sysinfo_set_item_val("niagara.outbuf.address", NULL, … … 257 196 OUTPUT_BUFFER_SIZE); 258 197 198 sysinfo_set_item_val("niagara.inbuf.address", NULL, 199 KA2PA(&input_buffer)); 200 sysinfo_set_item_val("niagara.inbuf.size", NULL, 201 PAGE_SIZE); 202 sysinfo_set_item_val("niagara.inbuf.datasize", NULL, 203 INPUT_BUFFER_SIZE); 204 259 205 static parea_t outbuf_parea; 260 206 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); … … 262 208 ddi_parea_register(&outbuf_parea); 263 209 264 #if 0 265 kbd_type = KBD_SUN4V; 266 267 devno_t devno = device_assign_devno(); 268 irq_initialize(&niagara_irq); 269 niagara_irq.devno = devno; 270 niagara_irq.inr = FICTIONAL_INR; 271 niagara_irq.claim = niagara_claim; 272 niagara_irq.handler = niagara_irq_handler; 273 irq_register(&niagara_irq); 274 275 sysinfo_set_item_val("kbd", NULL, true); 276 sysinfo_set_item_val("kbd.type", NULL, KBD_SUN4V); 277 sysinfo_set_item_val("kbd.devno", NULL, devno); 278 sysinfo_set_item_val("kbd.inr", NULL, FICTIONAL_INR); 279 #endif 280 281 /* 282 * Set sysinfos and pareas so that the userspace counterpart of the 283 * niagara fb driver can communicate with kernel using a shared buffer. 284 */ 285 //output_buffer.read_ptr = 0; 286 //output_buffer.write_ptr = 0; 287 288 #if 0 289 sysinfo_set_item_val("niagara.outbuf.address", NULL, 290 KA2PA(&output_buffer)); 291 sysinfo_set_item_val("niagara.outbuf.size", NULL, 292 PAGE_SIZE); 293 sysinfo_set_item_val("niagara.outbuf.datasize", NULL, 294 OUTPUT_BUFFER_SIZE); 295 static parea_t outbuf_parea; 296 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); 297 outbuf_parea.vbase = (uintptr_t) (&output_buffer); 298 outbuf_parea.frames = 1; 299 outbuf_parea.cacheable = false; 300 ddi_parea_register(&outbuf_parea); 301 302 #endif 210 static parea_t inbuf_parea; 211 inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer)); 212 inbuf_parea.frames = 1; 213 ddi_parea_register(&inbuf_parea); 303 214 304 215 outdev_t *niagara_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
Note:
See TracChangeset
for help on using the changeset viewer.