Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7f620e8 in mainline


Ignore:
Timestamp:
2013-12-31T19:33:59Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
26c03dbd
Parents:
99e8fb7b
Message:

libdrv, libc: Move AHCI to libdrv.

Location:
uspace
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/ahci/ahci.c

    r99e8fb7b r7f620e8  
    111111        }
    112112
    113 static int ahci_get_sata_device_name(ddf_fun_t *, size_t, char *);
    114 static int ahci_get_num_blocks(ddf_fun_t *, uint64_t *);
    115 static int ahci_get_block_size(ddf_fun_t *, size_t *);
    116 static int ahci_read_blocks(ddf_fun_t *, uint64_t, size_t, void *);
    117 static int ahci_write_blocks(ddf_fun_t *, uint64_t, size_t, void *);
     113static int get_sata_device_name(ddf_fun_t *, size_t, char *);
     114static int get_num_blocks(ddf_fun_t *, uint64_t *);
     115static int get_block_size(ddf_fun_t *, size_t *);
     116static int read_blocks(ddf_fun_t *, uint64_t, size_t, void *);
     117static int write_blocks(ddf_fun_t *, uint64_t, size_t, void *);
    118118
    119119static int ahci_identify_device(sata_dev_t *);
     
    139139
    140140static ahci_iface_t ahci_interface = {
    141         .get_sata_device_name = &ahci_get_sata_device_name,
    142         .get_num_blocks = &ahci_get_num_blocks,
    143         .get_block_size = &ahci_get_block_size,
    144         .read_blocks = &ahci_read_blocks,
    145         .write_blocks = &ahci_write_blocks
     141        .get_sata_device_name = &get_sata_device_name,
     142        .get_num_blocks = &get_num_blocks,
     143        .get_block_size = &get_block_size,
     144        .read_blocks = &read_blocks,
     145        .write_blocks = &write_blocks
    146146};
    147147
     
    180180 *
    181181 */
    182 static int ahci_get_sata_device_name(ddf_fun_t *fun,
     182static int get_sata_device_name(ddf_fun_t *fun,
    183183    size_t sata_dev_name_length, char *sata_dev_name)
    184184{
     
    196196 *
    197197 */
    198 static int ahci_get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks)
     198static int get_num_blocks(ddf_fun_t *fun, uint64_t *num_blocks)
    199199{
    200200        sata_dev_t *sata = fun_sata_dev(fun);
     
    211211 *
    212212 */
    213 static int ahci_get_block_size(ddf_fun_t *fun, size_t *block_size)
     213static int get_block_size(ddf_fun_t *fun, size_t *block_size)
    214214{
    215215        sata_dev_t *sata = fun_sata_dev(fun);
     
    228228 *
    229229 */
    230 static int ahci_read_blocks(ddf_fun_t *fun, uint64_t blocknum,
     230static int read_blocks(ddf_fun_t *fun, uint64_t blocknum,
    231231    size_t count, void *buf)
    232232{
     
    271271 *
    272272 */
    273 static int ahci_write_blocks(ddf_fun_t *fun, uint64_t blocknum,
     273static int write_blocks(ddf_fun_t *fun, uint64_t blocknum,
    274274    size_t count, void *buf)
    275275{
  • uspace/lib/c/Makefile

    r99e8fb7b r7f620e8  
    7474        generic/device/graph_dev.c \
    7575        generic/device/nic.c \
    76         generic/device/ahci.c \
    7776        generic/dhcp.c \
    7877        generic/dnsr.c \
  • uspace/lib/drv/generic/remote_ahci.c

    r99e8fb7b r7f620e8  
    3333 */
    3434
     35#include <as.h>
    3536#include <async.h>
     37#include <devman.h>
    3638#include <errno.h>
    3739#include <stdio.h>
     
    4850} ahci_iface_funcs_t;
    4951
     52#define MAX_NAME_LENGTH  1024
     53
    5054#define LO(ptr) \
    5155        ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) & 0xffffffff))
     
    5357#define HI(ptr) \
    5458        ((uint32_t) (((uint64_t) ((uintptr_t) (ptr))) >> 32))
     59
     60async_sess_t* ahci_get_sess(devman_handle_t funh, char **name)
     61{
     62        // FIXME: Use a better way than substring match
     63       
     64        *name = NULL;
     65       
     66        char devn[MAX_NAME_LENGTH];
     67        int rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH);
     68        if (rc != EOK)
     69                return NULL;
     70       
     71        size_t devn_size = str_size(devn);
     72       
     73        if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) {
     74                async_sess_t *sess = devman_device_connect(EXCHANGE_PARALLEL,
     75                    funh, IPC_FLAG_BLOCKING);
     76               
     77                if (sess) {
     78                        *name = str_dup(devn);
     79                        return sess;
     80                }
     81        }
     82       
     83        return NULL;
     84}
     85
     86int ahci_get_sata_device_name(async_sess_t *sess, size_t sata_dev_name_length,
     87    char *sata_dev_name)
     88{
     89        async_exch_t *exch = async_exchange_begin(sess);
     90        if (!exch)
     91                return EINVAL;
     92       
     93        aid_t req = async_send_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
     94            IPC_M_AHCI_GET_SATA_DEVICE_NAME, sata_dev_name_length, NULL);
     95       
     96        async_data_read_start(exch, sata_dev_name, sata_dev_name_length);
     97       
     98        sysarg_t rc;
     99        async_wait_for(req, &rc);
     100       
     101        return rc;
     102}
     103
     104int ahci_get_num_blocks(async_sess_t *sess, uint64_t *blocks)
     105{
     106        async_exch_t *exch = async_exchange_begin(sess);
     107        if (!exch)
     108                return EINVAL;
     109       
     110        sysarg_t blocks_hi;
     111        sysarg_t blocks_lo;
     112        int rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
     113            IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo);
     114       
     115        async_exchange_end(exch);
     116       
     117        if (rc == EOK) {
     118                *blocks = (((uint64_t) blocks_hi) << 32)
     119                    | (((uint64_t) blocks_lo) & 0xffffffff);
     120        }
     121       
     122        return rc;
     123}
     124
     125int ahci_get_block_size(async_sess_t *sess, size_t *blocks_size)
     126{
     127        async_exch_t *exch = async_exchange_begin(sess);
     128        if (!exch)
     129                return EINVAL;
     130       
     131        sysarg_t bs;
     132        int rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
     133            IPC_M_AHCI_GET_BLOCK_SIZE, &bs);
     134       
     135        async_exchange_end(exch);
     136       
     137        if (rc == EOK)
     138                *blocks_size = (size_t) bs;
     139       
     140        return rc;
     141}
     142
     143int ahci_read_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
     144    void *buf)
     145{
     146        async_exch_t *exch = async_exchange_begin(sess);
     147        if (!exch)
     148                return EINVAL;
     149       
     150        aid_t req;
     151        req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
     152            IPC_M_AHCI_READ_BLOCKS, HI(blocknum),  LO(blocknum), count, NULL);
     153       
     154        async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);
     155       
     156        async_exchange_end(exch);
     157       
     158        sysarg_t rc;
     159        async_wait_for(req, &rc);
     160       
     161        return rc;
     162}
     163
     164int ahci_write_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
     165    void* buf)
     166{
     167        async_exch_t *exch = async_exchange_begin(sess);
     168        if (!exch)
     169                return EINVAL;
     170       
     171        aid_t req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
     172            IPC_M_AHCI_WRITE_BLOCKS, HI(blocknum),  LO(blocknum), count, NULL);
     173       
     174        async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);
     175       
     176        async_exchange_end(exch);
     177       
     178        sysarg_t rc;
     179        async_wait_for(req, &rc);
     180       
     181        return rc;
     182}
    55183
    56184static void remote_ahci_get_sata_device_name(ddf_fun_t *, void *, ipc_callid_t,
  • uspace/lib/drv/include/ahci_iface.h

    r99e8fb7b r7f620e8  
    4141#include <async.h>
    4242
     43extern async_sess_t* ahci_get_sess(devman_handle_t, char **);
     44
     45extern int ahci_get_sata_device_name(async_sess_t *, size_t, char *);
     46extern int ahci_get_num_blocks(async_sess_t *, uint64_t *);
     47extern int ahci_get_block_size(async_sess_t *, size_t *);
     48extern int ahci_read_blocks(async_sess_t *, uint64_t, size_t, void *);
     49extern int ahci_write_blocks(async_sess_t *, uint64_t, size_t, void *);
     50
    4351/** AHCI device communication interface. */
    4452typedef struct {
  • uspace/srv/bd/sata_bd/Makefile

    r99e8fb7b r7f620e8  
    2929USPACE_PREFIX = ../../..
    3030BINARY = sata_bd
     31EXTRA_CFLAGS = -I$(LIBDRV_PREFIX)/include
     32LIBS = $(LIBDRV_PREFIX)/libdrv.a
    3133
    3234SOURCES = \
  • uspace/srv/bd/sata_bd/sata_bd.c

    r99e8fb7b r7f620e8  
    3939#include <sys/types.h>
    4040#include <bd_srv.h>
     41#include <devman.h>
    4142#include <errno.h>
    4243#include <stdio.h>
     
    4546#include <macros.h>
    4647
    47 #include <device/ahci.h>
     48#include <ahci_iface.h>
    4849#include "sata_bd.h"
    4950
Note: See TracChangeset for help on using the changeset viewer.