- Timestamp:
- 2009-08-22T10:48:00Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04803bf
- Parents:
- 1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 1 added
- 37 edited
- 2 moved
-
app/trace/syscalls.c (modified) (1 diff)
-
lib/libc/generic/async.c (modified) (3 diffs)
-
lib/libc/generic/fibril_sync.c (modified) (5 diffs)
-
lib/libc/generic/io/printf_core.c (modified) (1 diff)
-
lib/libc/generic/io/vsnprintf.c (modified) (1 diff)
-
lib/libc/generic/ipc.c (modified) (1 diff)
-
lib/libc/generic/malloc.c (modified) (1 diff)
-
lib/libc/generic/vfs/vfs.c (modified) (14 diffs)
-
lib/libc/include/async.h (modified) (1 diff)
-
lib/libc/include/ipc/ipc.h (modified) (1 diff)
-
lib/libc/include/ipc/kbd.h (added)
-
srv/bd/ata_bd/ata_bd.c (modified) (11 diffs)
-
srv/bd/ata_bd/ata_bd.h (modified) (1 diff)
-
srv/console/Makefile (modified) (2 diffs)
-
srv/console/console.c (modified) (1 diff)
-
srv/console/keybuffer.c (moved) (moved from uspace/srv/kbd/generic/keybuffer.c )
-
srv/console/keybuffer.h (moved) (moved from uspace/srv/kbd/include/keybuffer.h )
-
srv/fs/fat/fat_fat.c (modified) (1 diff)
-
srv/fs/fat/fat_fat.h (modified) (1 diff)
-
srv/fs/fat/fat_ops.c (modified) (3 diffs)
-
srv/kbd/Makefile (modified) (1 diff)
-
srv/kbd/ctl/gxe_fb.c (modified) (1 diff)
-
srv/kbd/ctl/pc.c (modified) (4 diffs)
-
srv/kbd/ctl/pl050.c (modified) (1 diff)
-
srv/kbd/ctl/stty.c (modified) (1 diff)
-
srv/kbd/ctl/sun.c (modified) (1 diff)
-
srv/kbd/generic/kbd.c (modified) (5 diffs)
-
srv/kbd/include/kbd.h (modified) (1 diff)
-
srv/kbd/include/kbd_ctl.h (modified) (1 diff)
-
srv/kbd/include/kbd_port.h (modified) (1 diff)
-
srv/kbd/port/dummy.c (modified) (1 diff)
-
srv/kbd/port/gxemul.c (modified) (1 diff)
-
srv/kbd/port/i8042.c (modified) (1 diff)
-
srv/kbd/port/msim.c (modified) (1 diff)
-
srv/kbd/port/pl050.c (modified) (1 diff)
-
srv/kbd/port/sgcn.c (modified) (1 diff)
-
srv/kbd/port/ski.c (modified) (1 diff)
-
srv/kbd/port/sun.c (modified) (1 diff)
-
srv/ns/task.h (modified) (1 diff)
-
srv/vfs/vfs_node.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/syscalls.c
r1ea99cc rb50b5af2 62 62 [SYS_IPC_FORWARD_SLOW] = { "ipc_forward_slow", 3, V_ERRNO }, 63 63 [SYS_IPC_WAIT] = { "ipc_wait_for_call", 3, V_HASH }, 64 [SYS_IPC_POKE] = { "ipc_poke", 0, V_ERRNO }, 64 65 [SYS_IPC_HANGUP] = { "ipc_hangup", 1, V_ERRNO }, 65 66 [SYS_IPC_REGISTER_IRQ] = { "ipc_register_irq", 4, V_ERRNO }, -
uspace/lib/libc/generic/async.c
r1ea99cc rb50b5af2 106 106 107 107 atomic_t async_futex = FUTEX_INITIALIZER; 108 109 /** Number of threads waiting for IPC in the kernel. */ 110 atomic_t threads_in_ipc_wait = { 0 }; 108 111 109 112 /** Structures of this type represent a waiting fibril. */ … … 683 686 684 687 futex_up(&async_futex); 688 689 atomic_inc(&threads_in_ipc_wait); 685 690 686 691 ipc_call_t call; … … 688 693 SYNCH_FLAGS_NONE); 689 694 695 atomic_dec(&threads_in_ipc_wait); 696 690 697 if (!callid) { 691 698 handle_expired_timeouts(); -
uspace/lib/libc/generic/fibril_sync.c
r1ea99cc rb50b5af2 40 40 #include <assert.h> 41 41 42 static void optimize_execution_power(void) 43 { 44 /* 45 * When waking up a worker fibril previously blocked in fibril 46 * synchronization, chances are that there is an idle manager fibril 47 * waiting for IPC, that could start executing the awakened worker 48 * fibril right away. We try to detect this and bring the manager 49 * fibril back to fruitful work. 50 */ 51 if (atomic_get(&threads_in_ipc_wait) > 0) 52 ipc_poke(); 53 } 54 42 55 void fibril_mutex_initialize(fibril_mutex_t *fm) 43 56 { … … 84 97 list_remove(&f->link); 85 98 fibril_add_ready((fid_t) f); 99 optimize_execution_power(); 86 100 } 87 101 } … … 152 166 fibril_add_ready((fid_t) f); 153 167 frw->writers++; 168 optimize_execution_power(); 154 169 break; 155 170 } else { … … 157 172 fibril_add_ready((fid_t) f); 158 173 frw->readers++; 174 optimize_execution_power(); 159 175 } 160 176 } … … 200 216 list_remove(&f->link); 201 217 fibril_add_ready((fid_t) f); 218 optimize_execution_power(); 202 219 if (once) 203 220 break; -
uspace/lib/libc/generic/io/printf_core.c
r1ea99cc rb50b5af2 490 490 counter += retval; 491 491 492 /* Print t ailing spaces */492 /* Print trailing spaces */ 493 493 494 494 while (width-- > 0) { -
uspace/lib/libc/generic/io/vsnprintf.c
r1ea99cc rb50b5af2 100 100 } 101 101 102 /* Buffer is big enough tto print the whole string */102 /* Buffer is big enough to print the whole string */ 103 103 memcpy((void *)(data->dst + data->len), (void *) str, size); 104 104 data->len += size; -
uspace/lib/libc/generic/ipc.c
r1ea99cc rb50b5af2 565 565 } 566 566 567 /** Interrupt one thread of this task from waiting for IPC. */ 568 void ipc_poke(void) 569 { 570 __SYSCALL0(SYS_IPC_POKE); 571 } 572 567 573 /** Ask destination to do a callback connection. 568 574 * -
uspace/lib/libc/generic/malloc.c
r1ea99cc rb50b5af2 392 392 if (orig_size - real_size >= STRUCT_OVERHEAD) { 393 393 /* Split the original block to a full block 394 and a t ailing free block */394 and a trailing free block */ 395 395 block_init((void *) head, real_size, false); 396 396 block_init((void *) head + real_size, -
uspace/lib/libc/generic/vfs/vfs.c
r1ea99cc rb50b5af2 122 122 int res; 123 123 ipcarg_t rc; 124 ipcarg_t rc_orig; 124 125 aid_t req; 125 126 dev_handle_t dev_handle; … … 141 142 rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_size); 142 143 if (rc != EOK) { 143 async_wait_for(req, NULL);144 async_wait_for(req, &rc_orig); 144 145 async_serialize_end(); 145 146 futex_up(&vfs_phone_futex); 146 147 free(mpa); 147 return (int) rc; 148 if (rc_orig == EOK) 149 return (int) rc; 150 else 151 return (int) rc_orig; 148 152 } 149 153 150 154 rc = ipc_data_write_start(vfs_phone, (void *) opts, str_size(opts)); 151 155 if (rc != EOK) { 152 async_wait_for(req, NULL);156 async_wait_for(req, &rc_orig); 153 157 async_serialize_end(); 154 158 futex_up(&vfs_phone_futex); 155 159 free(mpa); 156 return (int) rc; 160 if (rc_orig == EOK) 161 return (int) rc; 162 else 163 return (int) rc_orig; 157 164 } 158 165 159 166 rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name)); 160 167 if (rc != EOK) { 161 async_wait_for(req, NULL);168 async_wait_for(req, &rc_orig); 162 169 async_serialize_end(); 163 170 futex_up(&vfs_phone_futex); 164 171 free(mpa); 165 return (int) rc; 172 if (rc_orig == EOK) 173 return (int) rc; 174 else 175 return (int) rc_orig; 166 176 } 167 177 … … 169 179 rc = async_req_0_0(vfs_phone, IPC_M_PING); 170 180 if (rc != EOK) { 171 async_wait_for(req, NULL);181 async_wait_for(req, &rc_orig); 172 182 async_serialize_end(); 173 183 futex_up(&vfs_phone_futex); 174 184 free(mpa); 175 return (int) rc; 185 if (rc_orig == EOK) 186 return (int) rc; 187 else 188 return (int) rc_orig; 176 189 } 177 190 … … 202 215 rc = ipc_data_write_start(vfs_phone, pa, pa_size); 203 216 if (rc != EOK) { 204 async_wait_for(req, NULL); 217 ipcarg_t rc_orig; 218 219 async_wait_for(req, &rc_orig); 205 220 async_serialize_end(); 206 221 futex_up(&vfs_phone_futex); 207 222 free(pa); 208 return (int) rc; 223 if (rc_orig == EOK) 224 return (int) rc; 225 else 226 return (int) rc_orig; 209 227 } 210 228 async_wait_for(req, &rc); … … 240 258 241 259 if (rc != EOK) 242 return (int) rc;260 return (int) rc; 243 261 244 262 return (int) IPC_GET_ARG1(answer); … … 274 292 rc = ipc_data_read_start(vfs_phone, (void *)buf, nbyte); 275 293 if (rc != EOK) { 276 async_wait_for(req, NULL); 277 async_serialize_end(); 278 futex_up(&vfs_phone_futex); 279 return (ssize_t) rc; 294 ipcarg_t rc_orig; 295 296 async_wait_for(req, &rc_orig); 297 async_serialize_end(); 298 futex_up(&vfs_phone_futex); 299 if (rc_orig == EOK) 300 return (ssize_t) rc; 301 else 302 return (ssize_t) rc_orig; 280 303 } 281 304 async_wait_for(req, &rc); … … 301 324 rc = ipc_data_write_start(vfs_phone, (void *)buf, nbyte); 302 325 if (rc != EOK) { 303 async_wait_for(req, NULL); 304 async_serialize_end(); 305 futex_up(&vfs_phone_futex); 306 return (ssize_t) rc; 326 ipcarg_t rc_orig; 327 328 async_wait_for(req, &rc_orig); 329 async_serialize_end(); 330 futex_up(&vfs_phone_futex); 331 if (rc_orig == EOK) 332 return (ssize_t) rc; 333 else 334 return (ssize_t) rc_orig; 307 335 } 308 336 async_wait_for(req, &rc); … … 376 404 rc = ipc_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat)); 377 405 if (rc != EOK) { 378 async_wait_for(req, NULL); 379 async_serialize_end(); 380 futex_up(&vfs_phone_futex); 381 return (ssize_t) rc; 406 ipcarg_t rc_orig; 407 408 async_wait_for(req, &rc_orig); 409 async_serialize_end(); 410 futex_up(&vfs_phone_futex); 411 if (rc_orig == EOK) 412 return (ssize_t) rc; 413 else 414 return (ssize_t) rc_orig; 382 415 } 383 416 async_wait_for(req, &rc); … … 391 424 { 392 425 ipcarg_t rc; 426 ipcarg_t rc_orig; 393 427 aid_t req; 394 428 … … 405 439 rc = ipc_data_write_start(vfs_phone, pa, pa_size); 406 440 if (rc != EOK) { 407 async_wait_for(req, NULL);441 async_wait_for(req, &rc_orig); 408 442 async_serialize_end(); 409 443 futex_up(&vfs_phone_futex); 410 444 free(pa); 411 return (int) rc; 445 if (rc_orig == EOK) 446 return (int) rc; 447 else 448 return (int) rc_orig; 412 449 } 413 450 rc = ipc_data_read_start(vfs_phone, stat, sizeof(struct stat)); 414 451 if (rc != EOK) { 415 async_wait_for(req, NULL);452 async_wait_for(req, &rc_orig); 416 453 async_serialize_end(); 417 454 futex_up(&vfs_phone_futex); 418 455 free(pa); 419 return (int) rc; 456 if (rc_orig == EOK) 457 return (int) rc; 458 else 459 return (int) rc_orig; 420 460 } 421 461 async_wait_for(req, &rc); … … 476 516 rc = ipc_data_write_start(vfs_phone, pa, pa_size); 477 517 if (rc != EOK) { 478 async_wait_for(req, NULL); 518 ipcarg_t rc_orig; 519 520 async_wait_for(req, &rc_orig); 479 521 async_serialize_end(); 480 522 futex_up(&vfs_phone_futex); 481 523 free(pa); 482 return (int) rc; 524 if (rc_orig == EOK) 525 return (int) rc; 526 else 527 return (int) rc_orig; 483 528 } 484 529 async_wait_for(req, &rc); … … 506 551 rc = ipc_data_write_start(vfs_phone, pa, pa_size); 507 552 if (rc != EOK) { 508 async_wait_for(req, NULL); 553 ipcarg_t rc_orig; 554 555 async_wait_for(req, &rc_orig); 509 556 async_serialize_end(); 510 557 futex_up(&vfs_phone_futex); 511 558 free(pa); 512 return (int) rc; 559 if (rc_orig == EOK) 560 return (int) rc; 561 else 562 return (int) rc_orig; 513 563 } 514 564 async_wait_for(req, &rc); … … 532 582 { 533 583 ipcarg_t rc; 584 ipcarg_t rc_orig; 534 585 aid_t req; 535 586 … … 553 604 rc = ipc_data_write_start(vfs_phone, olda, olda_size); 554 605 if (rc != EOK) { 555 async_wait_for(req, NULL);606 async_wait_for(req, &rc_orig); 556 607 async_serialize_end(); 557 608 futex_up(&vfs_phone_futex); 558 609 free(olda); 559 610 free(newa); 560 return (int) rc; 611 if (rc_orig == EOK) 612 return (int) rc; 613 else 614 return (int) rc_orig; 561 615 } 562 616 rc = ipc_data_write_start(vfs_phone, newa, newa_size); 563 617 if (rc != EOK) { 564 async_wait_for(req, NULL);618 async_wait_for(req, &rc_orig); 565 619 async_serialize_end(); 566 620 futex_up(&vfs_phone_futex); 567 621 free(olda); 568 622 free(newa); 569 return (int) rc; 623 if (rc_orig == EOK) 624 return (int) rc; 625 else 626 return (int) rc_orig; 570 627 } 571 628 async_wait_for(req, &rc); -
uspace/lib/libc/include/async.h
r1ea99cc rb50b5af2 47 47 extern atomic_t async_futex; 48 48 49 extern atomic_t threads_in_ipc_wait; 50 49 51 extern int __async_init(void); 50 52 extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs); -
uspace/lib/libc/include/ipc/ipc.h
r1ea99cc rb50b5af2 192 192 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int); 193 193 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t); 194 extern void ipc_poke(void); 194 195 195 196 static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data) -
uspace/srv/bd/ata_bd/ata_bd.c
r1ea99cc rb50b5af2 36 36 * 37 37 * This driver currently works only with CHS addressing and uses PIO. 38 * Currently based on the (now obsolete) ANSI X3.221-1994 (ATA-1) standard. 39 * At this point only reading is possible, not writing. 38 * Currently based on the (now obsolete) ATA-1, ATA-2 standards. 40 39 * 41 40 * The driver services a single controller which can have up to two disks … … 61 60 #define NAME "ata_bd" 62 61 62 /** Physical block size. Should be always 512. */ 63 63 static const size_t block_size = 512; 64 65 /** Size of the communication area. */ 64 66 static size_t comm_size; 65 67 68 /** I/O base address of the command registers. */ 66 69 static uintptr_t cmd_physical = 0x1f0; 70 /** I/O base address of the control registers. */ 67 71 static uintptr_t ctl_physical = 0x170; 72 68 73 static ata_cmd_t *cmd; 69 74 static ata_ctl_t *ctl; … … 81 86 const void *buf); 82 87 static int drive_identify(int drive_id, disk_t *d); 88 static int wait_status(unsigned set, unsigned n_reset, uint8_t *pstatus, 89 unsigned timeout); 83 90 84 91 int main(int argc, char **argv) 85 92 { 86 uint8_t status;87 93 char name[16]; 88 94 int i, rc; … … 96 102 return -1; 97 103 98 /* Put drives to reset, disable interrupts. */ 99 printf("Reset drives... "); 100 fflush(stdout); 101 102 pio_write_8(&ctl->device_control, DCR_SRST); 103 /* FIXME: Find out how to do this properly. */ 104 async_usleep(100); 105 pio_write_8(&ctl->device_control, 0); 106 107 do { 108 status = pio_read_8(&cmd->status); 109 } while ((status & SR_BSY) != 0); 110 printf("Done\n"); 111 112 (void) drive_identify(0, &disk[0]); 113 (void) drive_identify(1, &disk[1]); 104 for (i = 0; i < MAX_DISKS; i++) { 105 printf("Identify drive %d... ", i); 106 fflush(stdout); 107 108 rc = drive_identify(i, &disk[i]); 109 110 if (rc == EOK) { 111 printf("%u cylinders, %u heads, %u sectors\n", 112 disk[i].cylinders, disk[i].heads, disk[i].sectors); 113 } else { 114 printf("Not found.\n"); 115 } 116 } 114 117 115 118 n_disks = 0; … … 144 147 } 145 148 146 static int drive_identify(int disk_id, disk_t *d) 147 { 148 uint16_t data; 149 uint8_t status; 150 size_t i; 151 152 printf("Identify drive %d... ", disk_id); 153 fflush(stdout); 154 155 pio_write_8(&cmd->drive_head, ((disk_id != 0) ? DHR_DRV : 0)); 156 async_usleep(100); 157 pio_write_8(&cmd->command, CMD_IDENTIFY_DRIVE); 158 159 status = pio_read_8(&cmd->status); 160 161 d->present = false; 162 163 /* 164 * Detect if drive is present. This is Qemu only! Need to 165 * do the right thing to work with real drives. 166 */ 167 if ((status & SR_DRDY) == 0) { 168 printf("None attached.\n"); 169 return ENOENT; 170 } 171 172 for (i = 0; i < block_size / 2; i++) { 173 do { 174 status = pio_read_8(&cmd->status); 175 } while ((status & SR_DRDY) == 0); 176 177 data = pio_read_16(&cmd->data_port); 178 179 switch (i) { 180 case 1: d->cylinders = data; break; 181 case 3: d->heads = data; break; 182 case 6: d->sectors = data; break; 183 } 184 } 185 186 d->blocks = d->cylinders * d->heads * d->sectors; 187 188 printf("Geometry: %u cylinders, %u heads, %u sectors\n", 189 d->cylinders, d->heads, d->sectors); 190 191 d->present = true; 192 fibril_mutex_initialize(&d->lock); 193 194 return EOK; 195 } 196 149 150 /** Register driver and enable device I/O. */ 197 151 static int ata_bd_init(void) 198 152 { … … 226 180 } 227 181 182 /** Block device connection handler */ 228 183 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall) 229 184 { … … 296 251 } 297 252 253 /** Transfer a logical block from/to the device. 254 * 255 * @param disk_id Device index (0 or 1) 256 * @param method @c BD_READ_BLOCK or @c BD_WRITE_BLOCK 257 * @param blk_idx Index of the first block. 258 * @param size Size of the logical block. 259 * @param buf Data buffer. 260 * 261 * @return EOK on success, EIO on error. 262 */ 298 263 static int ata_bd_rdwr(int disk_id, ipcarg_t method, off_t blk_idx, size_t size, 299 264 void *buf) … … 327 292 } 328 293 329 294 /** Issue IDENTIFY command. 295 * 296 * This is used to detect whether an ATA device is present and if so, 297 * to determine its parameters. The parameters are written to @a d. 298 * 299 * @param disk_id Device ID, 0 or 1. 300 * @param d Device structure to store parameters in. 301 */ 302 static int drive_identify(int disk_id, disk_t *d) 303 { 304 uint16_t data; 305 uint8_t status; 306 uint8_t drv_head; 307 size_t i; 308 309 drv_head = ((disk_id != 0) ? DHR_DRV : 0); 310 d->present = false; 311 312 if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK) 313 return EIO; 314 315 pio_write_8(&cmd->drive_head, drv_head); 316 317 /* 318 * This is where we would most likely expect a non-existing device to 319 * show up by not setting SR_DRDY. 320 */ 321 if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK) 322 return EIO; 323 324 pio_write_8(&cmd->command, CMD_IDENTIFY_DRIVE); 325 326 if (wait_status(0, ~SR_BSY, &status, TIMEOUT_PROBE) != EOK) 327 return EIO; 328 329 /* Read data from the disk buffer. */ 330 331 if ((status & SR_DRQ) != 0) { 332 // for (i = 0; i < block_size / 2; i++) { 333 // data = pio_read_16(&cmd->data_port); 334 // ((uint16_t *) buf)[i] = data; 335 // } 336 337 for (i = 0; i < block_size / 2; i++) { 338 data = pio_read_16(&cmd->data_port); 339 340 switch (i) { 341 case 1: d->cylinders = data; break; 342 case 3: d->heads = data; break; 343 case 6: d->sectors = data; break; 344 } 345 } 346 } 347 348 if ((status & SR_ERR) != 0) 349 return EIO; 350 351 d->blocks = d->cylinders * d->heads * d->sectors; 352 353 d->present = true; 354 fibril_mutex_initialize(&d->lock); 355 356 return EOK; 357 } 358 359 /** Read a physical from the device. 360 * 361 * @param disk_id Device index (0 or 1) 362 * @param blk_idx Index of the first block. 363 * @param blk_cnt Number of blocks to transfer. 364 * @param buf Buffer for holding the data. 365 * 366 * @return EOK on success, EIO on error. 367 */ 330 368 static int ata_bd_read_block(int disk_id, uint64_t blk_idx, size_t blk_cnt, 331 369 void *buf) … … 361 399 /* Program a Read Sectors operation. */ 362 400 401 if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_BSY) != EOK) { 402 fibril_mutex_unlock(&d->lock); 403 return EIO; 404 } 405 363 406 pio_write_8(&cmd->drive_head, drv_head); 407 408 if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_DRDY) != EOK) { 409 fibril_mutex_unlock(&d->lock); 410 return EIO; 411 } 412 364 413 pio_write_8(&cmd->sector_count, 1); 365 414 pio_write_8(&cmd->sector_number, s); 366 415 pio_write_8(&cmd->cylinder_low, c & 0xff); 367 416 pio_write_8(&cmd->cylinder_high, c >> 16); 417 368 418 pio_write_8(&cmd->command, CMD_READ_SECTORS); 369 419 370 /* Read data from the disk buffer. */ 371 372 for (i = 0; i < block_size / 2; i++) { 373 do { 374 status = pio_read_8(&cmd->status); 375 } while ((status & SR_DRDY) == 0); 376 377 data = pio_read_16(&cmd->data_port); 378 ((uint16_t *) buf)[i] = data; 379 } 420 if (wait_status(0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK) { 421 fibril_mutex_unlock(&d->lock); 422 return EIO; 423 } 424 425 if ((status & SR_DRQ) != 0) { 426 /* Read data from the device buffer. */ 427 428 for (i = 0; i < block_size / 2; i++) { 429 data = pio_read_16(&cmd->data_port); 430 ((uint16_t *) buf)[i] = data; 431 } 432 } 433 434 if ((status & SR_ERR) != 0) 435 return EIO; 380 436 381 437 fibril_mutex_unlock(&d->lock); … … 383 439 } 384 440 441 /** Write a physical block to the device. 442 * 443 * @param disk_id Device index (0 or 1) 444 * @param blk_idx Index of the first block. 445 * @param blk_cnt Number of blocks to transfer. 446 * @param buf Buffer holding the data to write. 447 * 448 * @return EOK on success, EIO on error. 449 */ 385 450 static int ata_bd_write_block(int disk_id, uint64_t blk_idx, size_t blk_cnt, 386 451 const void *buf) … … 413 478 fibril_mutex_lock(&d->lock); 414 479 415 /* Program a Read Sectors operation. */ 480 /* Program a Write Sectors operation. */ 481 482 if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_BSY) != EOK) { 483 fibril_mutex_unlock(&d->lock); 484 return EIO; 485 } 416 486 417 487 pio_write_8(&cmd->drive_head, drv_head); 488 489 if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_DRDY) != EOK) { 490 fibril_mutex_unlock(&d->lock); 491 return EIO; 492 } 493 418 494 pio_write_8(&cmd->sector_count, 1); 419 495 pio_write_8(&cmd->sector_number, s); 420 496 pio_write_8(&cmd->cylinder_low, c & 0xff); 421 497 pio_write_8(&cmd->cylinder_high, c >> 16); 498 422 499 pio_write_8(&cmd->command, CMD_WRITE_SECTORS); 423 500 424 /* Write data to the disk buffer. */ 425 426 for (i = 0; i < block_size / 2; i++) { 427 do { 428 status = pio_read_8(&cmd->status); 429 } while ((status & SR_DRDY) == 0); 430 431 pio_write_16(&cmd->data_port, ((uint16_t *) buf)[i]); 501 if (wait_status(0, ~SR_BSY, &status, TIMEOUT_BSY) != EOK) { 502 fibril_mutex_unlock(&d->lock); 503 return EIO; 504 } 505 506 if ((status & SR_DRQ) != 0) { 507 /* Write data to the device buffer. */ 508 509 for (i = 0; i < block_size / 2; i++) { 510 pio_write_16(&cmd->data_port, ((uint16_t *) buf)[i]); 511 } 432 512 } 433 513 434 514 fibril_mutex_unlock(&d->lock); 515 516 if (status & SR_ERR) 517 return EIO; 518 435 519 return EOK; 436 520 } 437 521 522 /** Wait until some status bits are set and some are reset. 523 * 524 * Example: wait_status(SR_DRDY, ~SR_BSY) waits for SR_DRDY to become 525 * set and SR_BSY to become reset. 526 * 527 * @param set Combination if bits which must be all set. 528 * @param n_reset Negated combination of bits which must be all reset. 529 * @param pstatus Pointer where to store last read status or NULL. 530 * @param timeout Timeout in 10ms units. 531 * 532 * @return EOK on success, EIO on timeout. 533 */ 534 static int wait_status(unsigned set, unsigned n_reset, uint8_t *pstatus, 535 unsigned timeout) 536 { 537 uint8_t status; 538 int cnt; 539 540 status = pio_read_8(&cmd->status); 541 542 /* 543 * This is crude, yet simple. First try with 1us delays 544 * (most likely the device will respond very fast). If not, 545 * start trying every 10 ms. 546 */ 547 548 cnt = 100; 549 while ((status & ~n_reset) != 0 || (status & set) != set) { 550 async_usleep(1); 551 --cnt; 552 if (cnt <= 0) break; 553 554 status = pio_read_8(&cmd->status); 555 } 556 557 cnt = timeout; 558 while ((status & ~n_reset) != 0 || (status & set) != set) { 559 async_usleep(10000); 560 --cnt; 561 if (cnt <= 0) break; 562 563 status = pio_read_8(&cmd->status); 564 } 565 566 if (pstatus) 567 *pstatus = status; 568 569 if (cnt == 0) 570 return EIO; 571 572 return EOK; 573 } 438 574 439 575 /** -
uspace/srv/bd/ata_bd/ata_bd.h
r1ea99cc rb50b5af2 135 135 }; 136 136 137 /** Timeout definitions. Unit is 10 ms. */ 138 enum ata_timeout { 139 TIMEOUT_PROBE = 100, /* 1 s */ 140 TIMEOUT_BSY = 100, /* 1 s */ 141 TIMEOUT_DRDY = 1000 /* 10 s */ 142 }; 143 137 144 typedef struct { 138 145 bool present; -
uspace/srv/console/Makefile
r1ea99cc rb50b5af2 35 35 include $(LIBC_PREFIX)/Makefile.toolchain 36 36 37 CFLAGS += -I. -I../kbd/include -I../fb37 CFLAGS += -I. 38 38 39 39 LIBS = $(LIBC_PREFIX)/libc.a … … 47 47 console.c \ 48 48 screenbuffer.c \ 49 ../kbd/generic/keybuffer.c \49 keybuffer.c \ 50 50 gcons.c 51 51 -
uspace/srv/console/console.c
r1ea99cc rb50b5af2 34 34 35 35 #include <libc.h> 36 #include <fb.h>37 36 #include <ipc/ipc.h> 38 #include < kbd.h>37 #include <ipc/kbd.h> 39 38 #include <io/keycode.h> 40 39 #include <ipc/fb.h> -
uspace/srv/fs/fat/fat_fat.c
r1ea99cc rb50b5af2 451 451 } 452 452 453 void 454 fat_zero_cluster(struct fat_bs *bs, dev_handle_t dev_handle, fat_cluster_t c) 455 { 456 int i; 457 block_t *b; 458 unsigned bps; 459 460 bps = uint16_t_le2host(bs->bps); 461 462 for (i = 0; i < bs->spc; i++) { 463 b = _fat_block_get(bs, dev_handle, c, i, BLOCK_FLAGS_NOREAD); 464 memset(b->data, 0, bps); 465 b->dirty = true; 466 block_put(b); 467 } 468 } 469 453 470 /** 454 471 * @} -
uspace/srv/fs/fat/fat_fat.h
r1ea99cc rb50b5af2 84 84 extern void fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t, 85 85 off_t); 86 extern void fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t); 86 87 87 88 #endif -
uspace/srv/fs/fat/fat_ops.c
r1ea99cc rb50b5af2 332 332 /* idxp->lock held */ 333 333 if (flags & L_DIRECTORY) { 334 int i; 335 block_t *b; 336 337 /* 338 * Populate the new cluster with unused dentries. 339 */ 340 for (i = 0; i < bs->spc; i++) { 341 b = _fat_block_get(bs, dev_handle, mcl, i, 342 BLOCK_FLAGS_NOREAD); 343 /* mark all dentries as never-used */ 344 memset(b->data, 0, bps); 345 b->dirty = false; 346 block_put(b); 347 } 334 /* Populate the new cluster with unused dentries. */ 335 fat_zero_cluster(bs, dev_handle, mcl); 348 336 nodep->type = FAT_DIRECTORY; 349 337 nodep->firstc = mcl; … … 462 450 * We need to grow the parent in order to create a new unused dentry. 463 451 */ 464 if (parentp-> idx->pfc == FAT_CLST_ROOT) {452 if (parentp->firstc == FAT_CLST_ROOT) { 465 453 /* Can't grow the root directory. */ 466 454 fibril_mutex_unlock(&parentp->idx->lock); … … 472 460 return rc; 473 461 } 462 fat_zero_cluster(bs, parentp->idx->dev_handle, mcl); 474 463 fat_append_clusters(bs, parentp, mcl); 475 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NOREAD); 464 parentp->size += bps * bs->spc; 465 parentp->dirty = true; /* need to sync node */ 466 b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE); 476 467 d = (fat_dentry_t *)b->data; 477 /*478 * Clear all dentries in the block except for the first one (the first479 * dentry will be cleared in the next step).480 */481 memset(d + 1, 0, bps - sizeof(fat_dentry_t));482 468 483 469 hit: -
uspace/srv/kbd/Makefile
r1ea99cc rb50b5af2 45 45 generic/kbd.c \ 46 46 genarch/gsp.c \ 47 genarch/stroke.c \ 48 generic/keybuffer.c 47 genarch/stroke.c 49 48 50 49 ARCH_SOURCES = -
uspace/srv/kbd/ctl/gxe_fb.c
r1ea99cc rb50b5af2 225 225 } 226 226 227 void kbd_ctl_set_ind(unsigned mods) 228 { 229 (void) mods; 230 } 231 227 232 /** 228 233 * @} -
uspace/srv/kbd/ctl/pc.c
r1ea99cc rb50b5af2 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 #include <gsp.h> 43 44 … … 45 46 ds_s, 46 47 ds_e 48 }; 49 50 enum special_code { 51 SC_ACK = 0xfa, 52 SC_NAK = 0xfe 53 }; 54 55 enum lock_ind_bits { 56 LI_SCROLL = 0x01, 57 LI_NUM = 0x02, 58 LI_CAPS = 0x04 59 }; 60 61 enum kbd_command { 62 KBD_CMD_SET_LEDS = 0xed 47 63 }; 48 64 … … 194 210 size_t map_length; 195 211 212 /* 213 * ACK/NAK are returned as response to us sending a command. 214 * We are not interested in them. 215 */ 216 if (scancode == SC_ACK || scancode == SC_NAK) 217 return; 218 196 219 if (scancode == 0xe0) { 197 220 ds = ds_e; … … 230 253 } 231 254 255 void kbd_ctl_set_ind(unsigned mods) 256 { 257 uint8_t b; 258 259 b = 0; 260 if ((mods & KM_CAPS_LOCK) != 0) 261 b = b | LI_CAPS; 262 if ((mods & KM_NUM_LOCK) != 0) 263 b = b | LI_NUM; 264 if ((mods & KM_SCROLL_LOCK) != 0) 265 b = b | LI_SCROLL; 266 267 kbd_port_write(KBD_CMD_SET_LEDS); 268 kbd_port_write(b); 269 } 270 232 271 /** 233 272 * @} -
uspace/srv/kbd/ctl/pl050.c
r1ea99cc rb50b5af2 258 258 } 259 259 260 void kbd_ctl_set_ind(unsigned mods) 261 { 262 (void) mods; 263 } 264 260 265 /** 261 266 * @} -
uspace/srv/kbd/ctl/stty.c
r1ea99cc rb50b5af2 224 224 } 225 225 226 void kbd_ctl_set_ind(unsigned mods) 227 { 228 (void) mods; 229 } 230 226 231 /** 227 232 * @} -
uspace/srv/kbd/ctl/sun.c
r1ea99cc rb50b5af2 72 72 if (key != 0) 73 73 kbd_push_ev(type, key); 74 } 75 76 void kbd_ctl_set_ind(unsigned mods) 77 { 78 (void) mods; 74 79 } 75 80 -
uspace/srv/kbd/generic/kbd.c
r1ea99cc rb50b5af2 38 38 #include <ipc/ipc.h> 39 39 #include <ipc/services.h> 40 #include <ipc/kbd.h> 40 41 #include <sysinfo.h> 41 42 #include <stdio.h> … … 51 52 52 53 #include <kbd.h> 53 #include <keybuffer.h>54 54 #include <kbd_port.h> 55 55 #include <kbd_ctl.h> … … 60 60 int cons_connected = 0; 61 61 int phone2cons = -1; 62 keybuffer_t keybuffer;63 62 64 63 /** Currently active modifiers. */ … … 125 124 mods = mods ^ (mod_mask & ~lock_keys); 126 125 lock_keys = lock_keys | mod_mask; 126 127 /* Update keyboard lock indicator lights. */ 128 kbd_ctl_set_ind(mods); 127 129 } else { 128 130 lock_keys = lock_keys & ~mod_mask; … … 239 241 layout[active_layout]->reset(); 240 242 241 /* Initialize key buffer */242 keybuffer_init(&keybuffer);243 244 243 async_set_client_connection(console_connection); 245 244 -
uspace/srv/kbd/include/kbd.h
r1ea99cc rb50b5af2 38 38 #define KBD_KBD_H_ 39 39 40 #include <keybuffer.h>41 #include <ipc/ipc.h>42 43 #define KBD_EVENT 102444 #define KBD_MS_LEFT 102545 #define KBD_MS_RIGHT 102646 #define KBD_MS_MIDDLE 102747 #define KBD_MS_MOVE 102848 49 typedef enum {50 KBD_YIELD = IPC_FIRST_USER_METHOD,51 KBD_RECLAIM52 } kbd_request_t;53 54 40 extern int cir_service; 55 41 extern int cir_phone; -
uspace/srv/kbd/include/kbd_ctl.h
r1ea99cc rb50b5af2 40 40 extern void kbd_ctl_parse_scancode(int); 41 41 extern int kbd_ctl_init(void); 42 42 extern void kbd_ctl_set_ind(unsigned); 43 43 44 44 #endif -
uspace/srv/kbd/include/kbd_port.h
r1ea99cc rb50b5af2 38 38 #define KBD_PORT_H_ 39 39 40 #include <sys/types.h> 41 40 42 extern int kbd_port_init(void); 41 43 extern void kbd_port_yield(void); 42 44 extern void kbd_port_reclaim(void); 45 extern void kbd_port_write(uint8_t); 43 46 44 47 #endif -
uspace/srv/kbd/port/dummy.c
r1ea99cc rb50b5af2 51 51 } 52 52 53 void kbd_port_write(uint8_t data) 54 { 55 (void) data; 56 } 57 53 58 /** @} 54 59 */ -
uspace/srv/kbd/port/gxemul.c
r1ea99cc rb50b5af2 78 78 } 79 79 80 void kbd_port_write(uint8_t data) 81 { 82 (void) data; 83 } 84 80 85 /** Process data sent when a key is pressed. 81 86 * -
uspace/srv/kbd/port/i8042.c
r1ea99cc rb50b5af2 160 160 } 161 161 162 void kbd_port_write(uint8_t data) 163 { 164 pio_write_8(&i8042->data, data); 165 wait_ready(); 166 } 167 162 168 static void i8042_irq_handler(ipc_callid_t iid, ipc_call_t *call) 163 169 { -
uspace/srv/kbd/port/msim.c
r1ea99cc rb50b5af2 78 78 } 79 79 80 void kbd_port_write(uint8_t data) 81 { 82 (void) data; 83 } 84 80 85 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call) 81 86 { -
uspace/srv/kbd/port/pl050.c
r1ea99cc rb50b5af2 102 102 } 103 103 104 void kbd_port_write(uint8_t data) 105 { 106 (void) data; 107 } 108 104 109 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call) 105 110 { -
uspace/srv/kbd/port/sgcn.c
r1ea99cc rb50b5af2 133 133 } 134 134 135 void kbd_port_write(uint8_t data) 136 { 137 (void) data; 138 } 139 135 140 /** 136 141 * Handler of the "key pressed" event. Reads codes of all the pressed keys from -
uspace/srv/kbd/port/ski.c
r1ea99cc rb50b5af2 78 78 } 79 79 80 void kbd_port_write(uint8_t data) 81 { 82 (void) data; 83 } 84 80 85 /** Thread to poll Ski for keypresses. */ 81 86 static void *ski_thread_impl(void *arg) -
uspace/srv/kbd/port/sun.c
r1ea99cc rb50b5af2 71 71 } 72 72 73 void kbd_port_write(uint8_t data) 74 { 75 (void) data; 76 } 77 73 78 /** @} 74 79 */ -
uspace/srv/ns/task.h
r1ea99cc rb50b5af2 35 35 36 36 #include <ipc/ipc.h> 37 #include <event.h>38 37 39 38 extern int task_init(void); 40 39 extern void process_pending_wait(void); 41 40 42 extern void wait_notification(wait_type_t et, task_id_t id);43 41 extern void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid); 44 42 -
uspace/srv/vfs/vfs_node.c
r1ea99cc rb50b5af2 188 188 } 189 189 190 assert(node->size == result->size );190 assert(node->size == result->size || node->type != VFS_NODE_FILE); 191 191 assert(node->lnkcnt == result->lnkcnt); 192 192 assert(node->type == result->type || result->type == VFS_NODE_UNKNOWN);
Note:
See TracChangeset
for help on using the changeset viewer.
