source: mainline/uspace/drv/audio/sb16/dma_controller.c@ f451dae

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f451dae was f451dae, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

sb16: Add 8237 DMA Controller registers.

Ugly as hell…

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/** @addtogroup drvaudiosb16
29 * @{
30 */
31/** @file
32 * @brief DMA memory management
33 */
34#include <assert.h>
35#include <errno.h>
36
37#include "dma_controller.h"
38
39#define DMA_CONTROLLER_FIRST_BASE 0x0
40typedef struct dma_controller_regs_first {
41 uint8_t channel_start0;
42 uint8_t channel_count0;
43 uint8_t channel_start1;
44 uint8_t channel_count1;
45 uint8_t channel_start2;
46 uint8_t channel_count2;
47 uint8_t channel_start3;
48 uint8_t channel_count3;
49
50 uint8_t command_status;
51 uint8_t request;
52 uint8_t single_mask;
53 uint8_t mode;
54 uint8_t flip_flop;
55 uint8_t master_reset_intermediate;
56 uint8_t multi_mask;
57} dma_controller_regs_first_t;
58
59#define DMA_CONTROLLER_SECOND_BASE 0xc0
60typedef struct dma_controller_regs_second {
61 uint8_t channel_start4;
62 uint8_t reserved0;
63 uint8_t channel_count4;
64 uint8_t reserved1;
65 uint8_t channel_start5;
66 uint8_t reserved2;
67 uint8_t channel_count5;
68 uint8_t reserved3;
69 uint8_t channel_start6;
70 uint8_t reserved4;
71 uint8_t channel_count6;
72 uint8_t reserved5;
73 uint8_t channel_start7;
74 uint8_t reserved6;
75 uint8_t channel_count7;
76
77 uint8_t command_status;
78 uint8_t reserved8;
79 uint8_t request;
80 uint8_t reserved9;
81 uint8_t single_mask;
82 uint8_t reserveda;
83 uint8_t mode;
84 uint8_t reservedb;
85 uint8_t flip_flop;
86 uint8_t reservedc;
87 uint8_t master_reset_intermediate;
88 uint8_t reservedd;
89 uint8_t multi_mask;
90} dma_controller_regs_second_t;
91
92#define DMA_CONTROLLER_PAGE_BASE 0x81
93typedef struct dma_page_regs {
94 uint8_t channel2;
95 uint8_t channel3;
96 uint8_t channel1;
97 uint8_t reserved0;
98 uint8_t reserved1;
99 uint8_t reserved2;
100 uint8_t channel0;
101 uint8_t reserved3;
102 uint8_t channel6;
103 uint8_t channel7;
104 uint8_t channel5;
105 uint8_t reserved4;
106 uint8_t reserved5;
107 uint8_t reserved6;
108 uint8_t channel4;
109} dma_page_regs_t;
110
111typedef struct dma_channel {
112 uint8_t offset_reg_address;
113 uint8_t size_reg_address;
114 uint8_t page_reg_address;
115} dma_channel_t;
116
117typedef struct dma_controller {
118 dma_channel_t channel[8];
119 dma_page_regs_t *page_table;
120 dma_controller_regs_first_t *first;
121 dma_controller_regs_second_t *second;
122} dma_controller_t;
123
124dma_controller_t controller_8237 = {
125 .channel = {
126 { 0x00, 0x01, 0x87 }, { 0x02, 0x03, 0x83 },
127 { 0x04, 0x05, 0x81 }, { 0x06, 0x07, 0x82 },
128 { 0xc0, 0xc2, 0x8f }, { 0xc4, 0xc6, 0x8b },
129 { 0xc8, 0xca, 0x89 }, { 0xcc, 0xce, 0x8a } },
130 .page_table = NULL,
131 .first = NULL,
132 .second = NULL,
133};
134
135static inline dma_controller_t *dma_controller_init()
136{
137 return NULL;
138}
139/*----------------------------------------------------------------------------*/
140int dma_setup_channel(unsigned channel, uintptr_t pa, size_t size)
141{
142 static dma_controller_t *controller = NULL;
143 if (!controller)
144 return EIO;
145 return ENOTSUP;
146}
147/**
148 * @}
149 */
Note: See TracBrowser for help on using the repository browser.