4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <fcode/private.h>
33 #include <fcode/log.h>
35 #include <fcdriver/fcdriver.h>
39 do_dma_alloc(fcode_env_t
*env
)
44 CHECK_DEPTH(env
, 1, "dma-alloc");
45 size
= (size_t) POP(DS
);
47 debug_msg(DEBUG_REG_ACCESS
, "dma-alloc ( %x ) -> %p\n", (int)size
, p
);
48 throw_from_fclib(env
, (p
== 0), "dma-alloc failed");
49 PUSH(DS
, (fstack_t
) p
);
53 do_dma_free(fcode_env_t
*env
)
58 CHECK_DEPTH(env
, 2, "dma-free");
61 debug_msg(DEBUG_REG_ACCESS
, "dma-free ( %p %x )\n", p
, (int)size
);
67 do_dma_map_in(fcode_env_t
*env
)
70 fstack_t va
, len
, cacheable
;
71 private_data_t
*pd
= DEVICE_PRIVATE(env
);
74 CHECK_DEPTH(env
, 3, "dma-map-in");
79 error
= fc_run_priv(pd
->common
, "dma-map-in", 3, 1,
80 fc_int2cell(cacheable
), fc_size2cell(len
), fc_ptr2cell(va
),
83 throw_from_fclib(env
, error
, "dma-map-in failed");
85 PUSH(DS
, (fstack_t
)data
);
89 do_dma_map_out(fcode_env_t
*env
)
91 fstack_t va
, dva
, len
;
92 private_data_t
*pd
= DEVICE_PRIVATE(env
);
95 CHECK_DEPTH(env
, 3, "dma-map-out");
100 error
= fc_run_priv(pd
->common
, "dma-map-out", 3, 0, fc_size2cell(len
),
101 fc_ptr2cell(dva
), fc_ptr2cell(va
));
103 throw_from_fclib(env
, error
, "dma-map-out failed");
107 do_dma_sync(fcode_env_t
*env
)
109 CHECK_DEPTH(env
, 3, "dma-sync");
115 install_dma_methods(fcode_env_t
*env
)
117 FORTH(0, "dma-alloc", do_dma_alloc
);
118 FORTH(0, "dma-free", do_dma_free
);
119 FORTH(0, "dma-map-in", do_dma_map_in
);
120 FORTH(0, "dma-map-out", do_dma_map_out
);
121 FORTH(0, "dma-sync", do_dma_sync
);