Commit | Line | Data |
---|---|---|
c4ca3d5a ORL |
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 | */ | |
2094f12d | 18 | #include <linux/types.h> |
c4ca3d5a ORL |
19 | |
20 | /* ----------------------------------- Host OS */ | |
21 | #include <dspbridge/host_os.h> | |
22 | ||
23 | /* ----------------------------------- DSP/BIOS Bridge */ | |
c4ca3d5a ORL |
24 | #include <dspbridge/dbdefs.h> |
25 | ||
c4ca3d5a ORL |
26 | /* ----------------------------------- Platform Manager */ |
27 | #include <dspbridge/dev.h> | |
28 | ||
29 | /* ----------------------------------- This */ | |
30 | #include <ioobj.h> | |
c4ca3d5a ORL |
31 | #include <dspbridge/io.h> |
32 | ||
c4ca3d5a ORL |
33 | /* |
34 | * ======== io_create ======== | |
35 | * Purpose: | |
36 | * Create an IO manager object, responsible for managing IO between | |
37 | * CHNL and msg_ctrl | |
38 | */ | |
e6bf74f0 | 39 | int io_create(struct io_mgr **io_man, struct dev_object *hdev_obj, |
9d7d0a52 | 40 | const struct io_attrs *mgr_attrts) |
c4ca3d5a ORL |
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 | ||
e436d07d | 47 | *io_man = NULL; |
c4ca3d5a ORL |
48 | |
49 | /* A memory base of 0 implies no memory base: */ | |
a534f17b | 50 | if ((mgr_attrts->shm_base != 0) && (mgr_attrts->sm_length == 0)) |
c4ca3d5a ORL |
51 | status = -EINVAL; |
52 | ||
fb6aabb7 | 53 | if (mgr_attrts->word_size == 0) |
c4ca3d5a ORL |
54 | status = -EINVAL; |
55 | ||
157990f0 | 56 | if (!status) { |
c4ca3d5a ORL |
57 | dev_get_intf_fxns(hdev_obj, &intf_fxns); |
58 | ||
59 | /* Let Bridge channel module finish the create: */ | |
09f13304 | 60 | status = (*intf_fxns->io_create) (&hio_mgr, hdev_obj, |
fb6aabb7 | 61 | mgr_attrts); |
c4ca3d5a | 62 | |
157990f0 | 63 | if (!status) { |
c4ca3d5a ORL |
64 | pio_mgr = (struct io_mgr_ *)hio_mgr; |
65 | pio_mgr->intf_fxns = intf_fxns; | |
085467b8 | 66 | pio_mgr->dev_obj = hdev_obj; |
c4ca3d5a ORL |
67 | |
68 | /* Return the new channel manager handle: */ | |
e436d07d | 69 | *io_man = hio_mgr; |
c4ca3d5a ORL |
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 | ||
c4ca3d5a ORL |
87 | intf_fxns = pio_mgr->intf_fxns; |
88 | ||
89 | /* Let Bridge channel module destroy the io_mgr: */ | |
09f13304 | 90 | status = (*intf_fxns->io_destroy) (hio_mgr); |
c4ca3d5a ORL |
91 | |
92 | return status; | |
93 | } |