Changeset b2d06fa in mainline for uspace/drv/test1/char.c
- Timestamp:
- 2010-12-25T17:14:36Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 092e4f1
- Parents:
- 59e9398b (diff), 3ac66f69 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/test1/char.c
r59e9398b rb2d06fa 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2010 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <stdio.h> 30 #include <unistd.h> 31 #include <atomic.h> 32 #include "../tester.h" 29 /** @file 30 */ 33 31 34 static atomic_t finish; 32 #include <assert.h> 33 #include <errno.h> 34 #include <mem.h> 35 #include <char.h> 35 36 36 static void callback(void *priv, int retval, ipc_call_t *data) 37 { 38 atomic_set(&finish, 1); 37 #include "test1.h" 38 39 static int impl_char_read(device_t *dev, char *buf, size_t count) { 40 memset(buf, 0, count); 41 return count; 39 42 } 40 43 41 const char *test_connect(void) 42 { 43 TPRINTF("Connecting to %u...", IPC_TEST_SERVICE); 44 int phone = ipc_connect_me_to(PHONE_NS, IPC_TEST_SERVICE, 0, 0); 45 if (phone > 0) { 46 TPRINTF("phoneid %d\n", phone); 47 } else { 48 TPRINTF("\n"); 49 return "ipc_connect_me_to() failed"; 50 } 51 52 printf("Sending synchronous message...\n"); 53 int retval = ipc_call_sync_0_0(phone, IPC_TEST_METHOD); 54 TPRINTF("Received response to synchronous message\n"); 55 56 TPRINTF("Sending asynchronous message...\n"); 57 atomic_set(&finish, 0); 58 ipc_call_async_0(phone, IPC_TEST_METHOD, NULL, callback, 1); 59 while (atomic_get(&finish) != 1) 60 TPRINTF("."); 61 TPRINTF("Received response to asynchronous message\n"); 62 63 TPRINTF("Hanging up..."); 64 retval = ipc_hangup(phone); 65 if (retval == 0) { 66 TPRINTF("OK\n"); 67 } else { 68 TPRINTF("\n"); 69 return "ipc_hangup() failed"; 70 } 71 72 return NULL; 44 static int imp_char_write(device_t *dev, char *buf, size_t count) { 45 return count; 73 46 } 47 48 static char_iface_t char_interface = { 49 .read = &impl_char_read, 50 .write = &imp_char_write 51 }; 52 53 device_ops_t char_device_ops = { 54 .interfaces[CHAR_DEV_IFACE] = &char_interface 55 }; 56
Note:
See TracChangeset
for help on using the changeset viewer.