Changeset 9be30cdf in mainline


Ignore:
Timestamp:
2013-12-31T02:50:45Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1ee46f
Parents:
208b5f5
Message:

libdrv: Make driver ops structures constant

These are statically initialized and we don't modify them.
Moves cca 1KB (30%) of data from .data (rw) section to ro. (driver binaries, amd64)

Location:
uspace/lib/drv
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/dev_iface.c

    r208b5f5 r9be30cdf  
    6969                [CLOCK_DEV_IFACE] = &remote_clock_dev_iface,
    7070                [BATTERY_DEV_IFACE] = &remote_battery_dev_iface,
    71                 [AHCI_DEV_IFACE] = &remote_ahci_iface
     71                [AHCI_DEV_IFACE] = &remote_ahci_iface,
    7272        }
    7373};
  • uspace/lib/drv/generic/remote_ahci.c

    r208b5f5 r9be30cdf  
    3636#include <errno.h>
    3737#include <stdio.h>
     38#include <macros.h>
    3839#include "ahci_iface.h"
    3940#include "ddf/driver.h"
     
    6566
    6667/** Remote AHCI interface operations. */
    67 static remote_iface_func_ptr_t remote_ahci_iface_ops [] = {
     68static const remote_iface_func_ptr_t remote_ahci_iface_ops [] = {
    6869        [IPC_M_AHCI_GET_SATA_DEVICE_NAME] = remote_ahci_get_sata_device_name,
    6970        [IPC_M_AHCI_GET_NUM_BLOCKS] = remote_ahci_get_num_blocks,
     
    7677 */
    7778remote_iface_t remote_ahci_iface = {
    78         .method_count = sizeof(remote_ahci_iface_ops) /
    79             sizeof(remote_ahci_iface_ops[0]),
     79        .method_count = ARRAY_SIZE(remote_ahci_iface_ops),
    8080        .methods = remote_ahci_iface_ops
    8181};
  • uspace/lib/drv/generic/remote_audio_mixer.c

    r208b5f5 r9be30cdf  
    3737#include <assert.h>
    3838#include <str.h>
     39#include <macros.h>
    3940
    4041#include "audio_mixer_iface.h"
     
    204205
    205206/** Remote audio mixer interface operations. */
    206 static remote_iface_func_ptr_t remote_audio_mixer_iface_ops[] = {
     207static const remote_iface_func_ptr_t remote_audio_mixer_iface_ops[] = {
    207208        [IPC_M_AUDIO_MIXER_GET_INFO] = remote_audio_mixer_get_info,
    208209        [IPC_M_AUDIO_MIXER_GET_ITEM_INFO] = remote_audio_mixer_get_item_info,
     
    213214/** Remote audio mixer interface structure. */
    214215remote_iface_t remote_audio_mixer_iface = {
    215         .method_count = sizeof(remote_audio_mixer_iface_ops) /
    216             sizeof(remote_audio_mixer_iface_ops[0]),
     216        .method_count = ARRAY_SIZE(remote_audio_mixer_iface_ops),
    217217        .methods = remote_audio_mixer_iface_ops
    218218};
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r208b5f5 r9be30cdf  
    3838#include <macros.h>
    3939#include <str.h>
    40 #include <as.h>
    4140#include <sys/mman.h>
    4241
     
    611610
    612611/** Remote audio pcm buffer interface operations. */
    613 static remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {
     612static const remote_iface_func_ptr_t remote_audio_pcm_iface_ops[] = {
    614613        [IPC_M_AUDIO_PCM_GET_INFO_STR] = remote_audio_pcm_get_info_str,
    615614        [IPC_M_AUDIO_PCM_QUERY_CAPS] = remote_audio_pcm_query_caps,
     
    628627/** Remote audio mixer interface structure. */
    629628remote_iface_t remote_audio_pcm_iface = {
    630         .method_count = sizeof(remote_audio_pcm_iface_ops) /
    631             sizeof(remote_audio_pcm_iface_ops[0]),
     629        .method_count = ARRAY_SIZE(remote_audio_pcm_iface_ops),
    632630        .methods = remote_audio_pcm_iface_ops
    633631};
  • uspace/lib/drv/generic/remote_battery_dev.c

    r208b5f5 r9be30cdf  
    3838#include <device/battery_dev.h>
    3939#include <ddf/driver.h>
     40#include <macros.h>
    4041
    4142static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t,
     
    4546
    4647/** Remote battery interface operations */
    47 static remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = {
     48static const remote_iface_func_ptr_t remote_battery_dev_iface_ops[] = {
    4849        &remote_battery_status_get,
    4950        &remote_battery_charge_level_get,
     
    5758 */
    5859remote_iface_t remote_battery_dev_iface = {
    59         .method_count = sizeof(remote_battery_dev_iface_ops) /
    60             sizeof(remote_iface_func_ptr_t),
     60        .method_count = ARRAY_SIZE(remote_battery_dev_iface_ops),
    6161        .methods = remote_battery_dev_iface_ops,
    6262};
  • uspace/lib/drv/generic/remote_char_dev.c

    r208b5f5 r9be30cdf  
    3535#include <async.h>
    3636#include <errno.h>
     37#include <macros.h>
    3738
    3839#include "ops/char_dev.h"
     
    4546
    4647/** Remote character interface operations. */
    47 static remote_iface_func_ptr_t remote_char_dev_iface_ops[] = {
     48static const remote_iface_func_ptr_t remote_char_dev_iface_ops[] = {
    4849        &remote_char_read,
    4950        &remote_char_write
     
    5657 */
    5758remote_iface_t remote_char_dev_iface = {
    58         .method_count = sizeof(remote_char_dev_iface_ops) /
    59             sizeof(remote_iface_func_ptr_t),
     59        .method_count = ARRAY_SIZE(remote_char_dev_iface_ops),
    6060        .methods = remote_char_dev_iface_ops
    6161};
  • uspace/lib/drv/generic/remote_clock_dev.c

    r208b5f5 r9be30cdf  
    3636#include <errno.h>
    3737#include <time.h>
     38#include <macros.h>
    3839
    3940#include <ops/clock_dev.h>
     
    4647
    4748/** Remote clock interface operations */
    48 static remote_iface_func_ptr_t remote_clock_dev_iface_ops[] = {
     49static const remote_iface_func_ptr_t remote_clock_dev_iface_ops[] = {
    4950        &remote_clock_time_get,
    5051        &remote_clock_time_set,
     
    5758 */
    5859remote_iface_t remote_clock_dev_iface = {
    59         .method_count = sizeof(remote_clock_dev_iface_ops) /
    60             sizeof(remote_iface_func_ptr_t),
     60        .method_count = ARRAY_SIZE(remote_clock_dev_iface_ops),
    6161        .methods = remote_clock_dev_iface_ops,
    6262};
  • uspace/lib/drv/generic/remote_graph_dev.c

    r208b5f5 r9be30cdf  
    3535#include <errno.h>
    3636#include <async.h>
     37#include <macros.h>
    3738
    3839#include "ops/graph_dev.h"
     
    4142static void remote_graph_connect(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    4243
    43 static remote_iface_func_ptr_t remote_graph_dev_iface_ops[] = {
     44static const remote_iface_func_ptr_t remote_graph_dev_iface_ops[] = {
    4445        &remote_graph_connect
    4546};
    4647
    4748remote_iface_t remote_graph_dev_iface = {
    48         .method_count = sizeof(remote_graph_dev_iface_ops) /
    49             sizeof(remote_iface_func_ptr_t),
     49        .method_count = ARRAY_SIZE(remote_graph_dev_iface_ops),
    5050        .methods = remote_graph_dev_iface_ops
    5151};
  • uspace/lib/drv/generic/remote_hw_res.c

    r208b5f5 r9be30cdf  
    3636#include <async.h>
    3737#include <errno.h>
     38#include <macros.h>
    3839
    3940#include "ops/hw_res.h"
     
    4950    ipc_call_t *);
    5051
    51 static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
     52static const remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
    5253        [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list,
    5354        [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt,
     
    5758
    5859remote_iface_t remote_hw_res_iface = {
    59         .method_count = sizeof(remote_hw_res_iface_ops) /
    60             sizeof(remote_iface_func_ptr_t),
     60        .method_count = ARRAY_SIZE(remote_hw_res_iface_ops),
    6161        .methods = remote_hw_res_iface_ops
    6262};
  • uspace/lib/drv/generic/remote_nic.c

    r208b5f5 r9be30cdf  
    4040#include <ipc/services.h>
    4141#include <sys/time.h>
     42#include <macros.h>
     43
    4244#include "ops/nic.h"
    4345
     
    11981200 *
    11991201 */
    1200 static remote_iface_func_ptr_t remote_nic_iface_ops[] = {
     1202static const remote_iface_func_ptr_t remote_nic_iface_ops[] = {
    12011203        &remote_nic_send_frame,
    12021204        &remote_nic_callback_create,
     
    12491251 */
    12501252remote_iface_t remote_nic_iface = {
    1251         .method_count = sizeof(remote_nic_iface_ops) /
    1252             sizeof(remote_iface_func_ptr_t),
     1253        .method_count = ARRAY_SIZE(remote_nic_iface_ops),
    12531254        .methods = remote_nic_iface_ops
    12541255};
  • uspace/lib/drv/generic/remote_pci.c

    r208b5f5 r9be30cdf  
    3636#include <async.h>
    3737#include <errno.h>
     38#include <macros.h>
    3839
    3940#include "pci_dev_iface.h"
     
    4950
    5051/** Remote USB interface operations. */
    51 static remote_iface_func_ptr_t remote_pci_iface_ops [] = {
     52static const remote_iface_func_ptr_t remote_pci_iface_ops [] = {
    5253        remote_config_space_read_8,
    5354        remote_config_space_read_16,
     
    6263 */
    6364remote_iface_t remote_pci_iface = {
    64         .method_count = sizeof(remote_pci_iface_ops) /
    65             sizeof(remote_pci_iface_ops[0]),
     65        .method_count = ARRAY_SIZE(remote_pci_iface_ops),
    6666        .methods = remote_pci_iface_ops
    6767};
  • uspace/lib/drv/generic/remote_pio_window.c

    r208b5f5 r9be30cdf  
    3535#include <async.h>
    3636#include <errno.h>
     37#include <macros.h>
    3738
    3839#include "ops/pio_window.h"
     
    4243    ipc_call_t *);
    4344
    44 static remote_iface_func_ptr_t remote_pio_window_iface_ops [] = {
     45static const remote_iface_func_ptr_t remote_pio_window_iface_ops [] = {
    4546        [PIO_WINDOW_GET] = &remote_pio_window_get
    4647};
    4748
    4849remote_iface_t remote_pio_window_iface = {
    49         .method_count = sizeof(remote_pio_window_iface_ops) /
    50             sizeof(remote_iface_func_ptr_t),
     50        .method_count = ARRAY_SIZE(remote_pio_window_iface_ops),
    5151        .methods = remote_pio_window_iface_ops
    5252};
  • uspace/lib/drv/generic/remote_usb.c

    r208b5f5 r9be30cdf  
    3636#include <async.h>
    3737#include <errno.h>
     38#include <macros.h>
    3839
    3940#include "usb_iface.h"
     
    107108
    108109/** Remote USB interface operations. */
    109 static remote_iface_func_ptr_t remote_usb_iface_ops [] = {
     110static const remote_iface_func_ptr_t remote_usb_iface_ops [] = {
    110111        [IPC_M_USB_GET_MY_ADDRESS] = remote_usb_get_my_address,
    111112        [IPC_M_USB_GET_MY_INTERFACE] = remote_usb_get_my_interface,
     
    116117 */
    117118remote_iface_t remote_usb_iface = {
    118         .method_count = sizeof(remote_usb_iface_ops) /
    119             sizeof(remote_usb_iface_ops[0]),
     119        .method_count = ARRAY_SIZE(remote_usb_iface_ops),
    120120        .methods = remote_usb_iface_ops
    121121};
  • uspace/lib/drv/generic/remote_usbhc.c

    r208b5f5 r9be30cdf  
    3737#include <errno.h>
    3838#include <assert.h>
     39#include <macros.h>
    3940
    4041#include "usbhc_iface.h"
     
    334335
    335336/** Remote USB host controller interface operations. */
    336 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
     337static const remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
    337338        [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address,
    338339        [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address,
     
    350351 */
    351352remote_iface_t remote_usbhc_iface = {
    352         .method_count = sizeof(remote_usbhc_iface_ops) /
    353             sizeof(remote_usbhc_iface_ops[0]),
     353        .method_count = ARRAY_SIZE(remote_usbhc_iface_ops),
    354354        .methods = remote_usbhc_iface_ops
    355355};
  • uspace/lib/drv/generic/remote_usbhid.c

    r208b5f5 r9be30cdf  
    3737#include <assert.h>
    3838#include <stdio.h>
     39#include <macros.h>
    3940
    4041#include "usbhid_iface.h"
     
    4849
    4950/** Remote USB HID interface operations. */
    50 static remote_iface_func_ptr_t remote_usbhid_iface_ops [] = {
     51static const remote_iface_func_ptr_t remote_usbhid_iface_ops [] = {
    5152        remote_usbhid_get_event_length,
    5253        remote_usbhid_get_event,
     
    5859 */
    5960remote_iface_t remote_usbhid_iface = {
    60         .method_count = sizeof(remote_usbhid_iface_ops) /
    61             sizeof(remote_usbhid_iface_ops[0]),
     61        .method_count = ARRAY_SIZE(remote_usbhid_iface_ops),
    6262        .methods = remote_usbhid_iface_ops
    6363};
  • uspace/lib/drv/include/dev_iface.h

    r208b5f5 r9be30cdf  
    5555
    5656typedef struct {
    57         size_t method_count;
    58         remote_iface_func_ptr_t *methods;
     57        const size_t method_count;
     58        const remote_iface_func_ptr_t *methods;
    5959} remote_iface_t;
    6060
Note: See TracChangeset for help on using the changeset viewer.