Changeset 79ae36dd in mainline for uspace/app/tester


Ignore:
Timestamp:
2011-06-08T19:01:55Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
Location:
uspace/app/tester
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/console/console1.c

    r764d71e r79ae36dd  
    5050{
    5151        if (!test_quiet) {
     52                console_ctrl_t *console = console_init(stdin, stdout);
     53               
    5254                printf("Style test: ");
    53                 fflush(stdout);
    54                 console_set_style(fphone(stdout), STYLE_NORMAL);
     55                console_flush(console);
     56                console_set_style(console, STYLE_NORMAL);
    5557                printf(" normal ");
    56                 fflush(stdout);
    57                 console_set_style(fphone(stdout), STYLE_EMPHASIS);
     58                console_flush(console);
     59                console_set_style(console, STYLE_EMPHASIS);
    5860                printf(" emphasized ");
    59                 fflush(stdout);
    60                 console_set_style(fphone(stdout), STYLE_INVERTED);
     61                console_flush(console);
     62                console_set_style(console, STYLE_INVERTED);
    6163                printf(" inverted ");
    62                 fflush(stdout);
    63                 console_set_style(fphone(stdout), STYLE_SELECTED);
     64                console_flush(console);
     65                console_set_style(console, STYLE_SELECTED);
    6466                printf(" selected ");
    65                 fflush(stdout);
    66                 console_set_style(fphone(stdout), STYLE_NORMAL);
     67                console_flush(console);
     68                console_set_style(console, STYLE_NORMAL);
    6769                printf("\n");
    6870               
     
    7375                for (j = 0; j < 2; j++) {
    7476                        for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
    75                                 fflush(stdout);
    76                                 console_set_color(fphone(stdout), i, COLOR_WHITE,
     77                                console_flush(console);
     78                                console_set_color(console, i, COLOR_WHITE,
    7779                                    j ? CATTR_BRIGHT : 0);
    7880                                printf(" %s ", color_name[i]);
    7981                        }
    80                         fflush(stdout);
    81                         console_set_style(fphone(stdout), STYLE_NORMAL);
     82                        console_flush(console);
     83                        console_set_style(console, STYLE_NORMAL);
    8284                        putchar('\n');
    8385                }
     
    8688                for (j = 0; j < 2; j++) {
    8789                        for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
    88                                 fflush(stdout);
    89                                 console_set_color(fphone(stdout), COLOR_WHITE, i,
     90                                console_flush(console);
     91                                console_set_color(console, COLOR_WHITE, i,
    9092                                    j ? CATTR_BRIGHT : 0);
    9193                                printf(" %s ", color_name[i]);
    9294                        }
    93                         fflush(stdout);
    94                         console_set_style(fphone(stdout), STYLE_NORMAL);
     95                        console_flush(console);
     96                        console_set_style(console, STYLE_NORMAL);
    9597                        putchar('\n');
    9698                }
     
    99101               
    100102                for (i = 0; i < 255; i += 16) {
    101                         fflush(stdout);
    102                         console_set_rgb_color(fphone(stdout), (255 - i) << 16, i << 16);
     103                        console_flush(console);
     104                        console_set_rgb_color(console, (255 - i) << 16, i << 16);
    103105                        putchar('X');
    104106                }
    105                 fflush(stdout);
    106                 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
     107                console_flush(console);
     108                console_set_color(console, COLOR_BLACK, COLOR_WHITE, 0);
    107109                putchar('\n');
    108110               
    109111                for (i = 0; i < 255; i += 16) {
    110                         fflush(stdout);
    111                         console_set_rgb_color(fphone(stdout), (255 - i) << 8, i << 8);
     112                        console_flush(console);
     113                        console_set_rgb_color(console, (255 - i) << 8, i << 8);
    112114                        putchar('X');
    113115                }
    114                 fflush(stdout);
    115                 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
     116                console_flush(console);
     117                console_set_color(console, COLOR_BLACK, COLOR_WHITE, 0);
    116118                putchar('\n');
    117119               
    118120                for (i = 0; i < 255; i += 16) {
    119                         fflush(stdout);
    120                         console_set_rgb_color(fphone(stdout), 255 - i, i);
     121                        console_flush(console);
     122                        console_set_rgb_color(console, 255 - i, i);
    121123                        putchar('X');
    122124                }
    123                 fflush(stdout);
    124                 console_set_style(fphone(stdout), STYLE_NORMAL);
     125                console_flush(console);
     126                console_set_style(console, STYLE_NORMAL);
    125127                putchar('\n');
    126128        }
  • uspace/app/tester/devs/devman2.c

    r764d71e r79ae36dd  
    4242#include <devman.h>
    4343#include <str.h>
     44#include <async.h>
    4445#include <vfs/vfs.h>
     46#include <vfs/vfs_sess.h>
    4547#include <sys/stat.h>
    4648#include <fcntl.h>
     
    6870                        continue;
    6971                }
    70                 int phone = fd_phone(fd);
     72                async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
    7173                close(fd);
    72                 if (phone < 0) {
    73                         TPRINTF("Failed opening phone: %s.\n", str_error(phone));
    74                         rc = phone;
     74                if (sess == NULL) {
     75                        TPRINTF("Failed opening phone: %s.\n", str_error(errno));
     76                        rc = errno;
    7577                        err_msg = "Failed opening file descriptor phone";
    7678                        continue;
    7779                }
    78                 async_hangup(phone);
     80                async_hangup(sess);
    7981                TPRINTF("Path `%s' okay.\n", path);
    8082                free(path);
     
    8385        }
    8486       
    85         if (path != NULL) {
     87        if (path != NULL)
    8688                free(path);
    87         }
    88 
     89       
    8990        return err_msg;
    9091}
  • uspace/app/tester/hw/misc/virtchar1.c

    r764d71e r79ae36dd  
    4343#include <str.h>
    4444#include <vfs/vfs.h>
     45#include <vfs/vfs_sess.h>
    4546#include <sys/stat.h>
    4647#include <fcntl.h>
     
    6667        TPRINTF("   ...file handle %d\n", fd);
    6768
    68         TPRINTF(" Asking for phone...\n");
    69         int phone = fd_phone(fd);
    70         if (phone < 0) {
     69        TPRINTF(" Asking for session...\n");
     70        async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
     71        if (!sess) {
    7172                close(fd);
    72                 TPRINTF("   ...error: %s\n", str_error(phone));
    73                 return "Failed to get phone to device";
     73                TPRINTF("   ...error: %s\n", str_error(errno));
     74                return "Failed to get session to device";
    7475        }
    75         TPRINTF("   ...phone is %d\n", phone);
     76        TPRINTF("   ...session is %p\n", sess);
    7677       
    7778        TPRINTF(" Will try to read...\n");
    7879        size_t i;
    7980        char buffer[BUFFER_SIZE];
    80         char_dev_read(phone, buffer, BUFFER_SIZE);
     81        char_dev_read(sess, buffer, BUFFER_SIZE);
    8182        TPRINTF(" ...verifying that we read zeroes only...\n");
    8283        for (i = 0; i < BUFFER_SIZE; i++) {
     
    8889       
    8990        /* Clean-up. */
    90         TPRINTF(" Closing phones and file descriptors\n");
    91         async_hangup(phone);
     91        TPRINTF(" Closing session and file descriptor\n");
     92        async_hangup(sess);
    9293        close(fd);
    9394       
  • uspace/app/tester/hw/serial/serial1.c

    r764d71e r79ae36dd  
    7171                }
    7272       
    73         int res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);
    74        
    7573        devman_handle_t handle;
    76         res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
     74        int res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
    7775            IPC_FLAG_BLOCKING);
    7876        if (res != EOK)
    7977                return "Could not get serial device handle";
    8078       
    81         int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);
    82         if (phone < 0) {
    83                 devman_hangup_phone(DEVMAN_CLIENT);
     79        async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,
     80            IPC_FLAG_BLOCKING);
     81        if (!sess)
    8482                return "Unable to connect to serial device";
    85         }
    8683       
    8784        char *buf = (char *) malloc(cnt + 1);
    8885        if (buf == NULL) {
    89                 async_hangup(phone);
    90                 devman_hangup_phone(DEVMAN_CLIENT);
     86                async_hangup(sess);
    9187                return "Failed to allocate input buffer";
    9288        }
     
    9793        sysarg_t old_word_size;
    9894       
    99         res = async_req_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
     95        async_exch_t *exch = async_exchange_begin(sess);
     96        res = async_req_0_4(exch, SERIAL_GET_COM_PROPS, &old_baud,
    10097            &old_par, &old_word_size, &old_stop);
     98        async_exchange_end(exch);
     99       
    101100        if (res != EOK) {
    102101                free(buf);
    103                 async_hangup(phone);
    104                 devman_hangup_phone(DEVMAN_CLIENT);
     102                async_hangup(sess);
    105103                return "Failed to get old serial communication parameters";
    106104        }
    107105       
    108         res = async_req_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
     106        exch = async_exchange_begin(sess);
     107        res = async_req_4_0(exch, SERIAL_SET_COM_PROPS, 1200,
    109108            SERIAL_NO_PARITY, 8, 1);
     109        async_exchange_end(exch);
     110       
    110111        if (EOK != res) {
    111112                free(buf);
    112                 async_hangup(phone);
    113                 devman_hangup_phone(DEVMAN_CLIENT);
     113                async_hangup(sess);
    114114                return "Failed to set serial communication parameters";
    115115        }
     
    120120        size_t total = 0;
    121121        while (total < cnt) {
    122                 ssize_t read = char_dev_read(phone, buf, cnt - total);
     122                ssize_t read = char_dev_read(sess, buf, cnt - total);
    123123               
    124124                if (read < 0) {
    125                         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     125                        exch = async_exchange_begin(sess);
     126                        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    126127                            old_par, old_word_size, old_stop);
     128                        async_exchange_end(exch);
     129                       
    127130                        free(buf);
    128                         async_hangup(phone);
    129                         devman_hangup_phone(DEVMAN_CLIENT);
     131                        async_hangup(sess);
    130132                        return "Failed read from serial device";
    131133                }
    132134               
    133135                if ((size_t) read > cnt - total) {
    134                         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     136                        exch = async_exchange_begin(sess);
     137                        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    135138                            old_par, old_word_size, old_stop);
     139                        async_exchange_end(exch);
     140                       
    136141                        free(buf);
    137                         async_hangup(phone);
    138                         devman_hangup_phone(DEVMAN_CLIENT);
     142                        async_hangup(sess);
    139143                        return "Read more data than expected";
    140144                }
     
    151155                         * direction of data transfer.
    152156                         */
    153                         ssize_t written = char_dev_write(phone, buf, read);
     157                        ssize_t written = char_dev_write(sess, buf, read);
    154158                       
    155159                        if (written < 0) {
    156                                 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     160                                exch = async_exchange_begin(sess);
     161                                async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    157162                                    old_par, old_word_size, old_stop);
     163                                async_exchange_end(exch);
     164                               
    158165                                free(buf);
    159                                 async_hangup(phone);
    160                                 devman_hangup_phone(DEVMAN_CLIENT);
     166                                async_hangup(sess);
    161167                                return "Failed write to serial device";
    162168                        }
    163169                       
    164170                        if (written != read) {
    165                                 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     171                                exch = async_exchange_begin(sess);
     172                                async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    166173                                    old_par, old_word_size, old_stop);
     174                                async_exchange_end(exch);
     175                               
    167176                                free(buf);
    168                                 async_hangup(phone);
    169                                 devman_hangup_phone(DEVMAN_CLIENT);
     177                                async_hangup(sess);
    170178                                return "Written less data than read from serial device";
    171179                        }
     
    180188       
    181189        size_t eot_size = str_size(EOT);
    182         ssize_t written = char_dev_write(phone, (void *) EOT, eot_size);
    183        
    184         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     190        ssize_t written = char_dev_write(sess, (void *) EOT, eot_size);
     191       
     192        exch = async_exchange_begin(sess);
     193        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    185194            old_par, old_word_size, old_stop);
     195        async_exchange_end(exch);
     196       
    186197        free(buf);
    187         async_hangup(phone);
    188         devman_hangup_phone(DEVMAN_CLIENT);
     198        async_hangup(sess);
    189199       
    190200        if (written < 0)
  • uspace/app/tester/ipc/ping_pong.c

    r764d71e r79ae36dd  
    3030#include <stdlib.h>
    3131#include <sys/time.h>
    32 #include <ipc/ns.h>
     32#include <ns.h>
    3333#include <async.h>
    3434#include <errno.h>
     
    6161                size_t i;
    6262                for (i = 0; i < COUNT_GRANULARITY; i++) {
    63                         int retval = async_req_0_0(PHONE_NS, NS_PING);
     63                        int retval = ns_ping();
    6464                       
    6565                        if (retval != EOK) {
Note: See TracChangeset for help on using the changeset viewer.