Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
io.c
Go to the documentation of this file.
1 /*
2  * io.c
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * IO manager interface: Manages IO between CHNL and msg_ctrl.
7  *
8  * Copyright (C) 2005-2006 Texas Instruments, Inc.
9  *
10  * This package is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  */
18 #include <linux/types.h>
19 
20 /* ----------------------------------- Host OS */
21 #include <dspbridge/host_os.h>
22 
23 /* ----------------------------------- DSP/BIOS Bridge */
24 #include <dspbridge/dbdefs.h>
25 
26 /* ----------------------------------- Platform Manager */
27 #include <dspbridge/dev.h>
28 
29 /* ----------------------------------- This */
30 #include <ioobj.h>
31 #include <dspbridge/io.h>
32 
33 /*
34  * ======== io_create ========
35  * Purpose:
36  * Create an IO manager object, responsible for managing IO between
37  * CHNL and msg_ctrl
38  */
39 int io_create(struct io_mgr **io_man, struct dev_object *hdev_obj,
40  const struct io_attrs *mgr_attrts)
41 {
42  struct bridge_drv_interface *intf_fxns;
43  struct io_mgr *hio_mgr = NULL;
44  struct io_mgr_ *pio_mgr = NULL;
45  int status = 0;
46 
47  *io_man = NULL;
48 
49  /* A memory base of 0 implies no memory base: */
50  if ((mgr_attrts->shm_base != 0) && (mgr_attrts->sm_length == 0))
51  status = -EINVAL;
52 
53  if (mgr_attrts->word_size == 0)
54  status = -EINVAL;
55 
56  if (!status) {
57  dev_get_intf_fxns(hdev_obj, &intf_fxns);
58 
59  /* Let Bridge channel module finish the create: */
60  status = (*intf_fxns->io_create) (&hio_mgr, hdev_obj,
61  mgr_attrts);
62 
63  if (!status) {
64  pio_mgr = (struct io_mgr_ *)hio_mgr;
65  pio_mgr->intf_fxns = intf_fxns;
66  pio_mgr->dev_obj = hdev_obj;
67 
68  /* Return the new channel manager handle: */
69  *io_man = hio_mgr;
70  }
71  }
72 
73  return status;
74 }
75 
76 /*
77  * ======== io_destroy ========
78  * Purpose:
79  * Delete IO manager.
80  */
81 int io_destroy(struct io_mgr *hio_mgr)
82 {
83  struct bridge_drv_interface *intf_fxns;
84  struct io_mgr_ *pio_mgr = (struct io_mgr_ *)hio_mgr;
85  int status;
86 
87  intf_fxns = pio_mgr->intf_fxns;
88 
89  /* Let Bridge channel module destroy the io_mgr: */
90  status = (*intf_fxns->io_destroy) (hio_mgr);
91 
92  return status;
93 }