[BeBoB/MAudio] Add PreSonus::FireboxDevice class to support functionality to switch...
[ffado.git] / libffado / src / dice / dice_firmware_loader.h
blobddb8f5fe3efcce8408a0f42f38e9a1c6c666d93a
1 /*
2 * Copyright (C) 2012 by Peter Hinkel
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) version 3 of the License.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * Implementation of the DICE firmware loader specification based upon
23 * TCAT public available document v3.2.0.0 (2008-06-20)
27 #ifndef __DICE_FIRMWARE_LOADER_H__
28 #define __DICE_FIRMWARE_LOADER_H__
30 #include <stdint.h>
31 #include "dice_defines.h"
33 /* private memory space offset for command interface */
34 #define DICE_FL_INTERFACE_SPACE 0x0000FFFFE0100000ULL
35 #define DICE_FL_OFFSET (DICE_FL_INTERFACE_SPACE ^ DICE_REGISTER_BASE)
37 /* memory space offsets relative to DICE_FL_INTERFACE_SPACE */
38 #define DICE_FL_VERSION 0x0 //unused
39 #define DICE_FL_OPCODE 0x4
40 #define DICE_FL_RETURN_STATUS 0x8
41 #define DICE_FL_PROGRESS 0xC
42 #define DICE_FL_CAPABILITIES 0x10
43 #define DICE_FL_RESERVED 0x14 //unused
44 #define DICE_FL_PARAMETER 0x2C
45 #define DICE_FL_TESTDELAY 0xFD8
46 #define DICE_FL_TESTBUF 0xFDC
48 #define DICE_FL_BUFFER 0x34 //offset for Upload buffer
50 /* Opcode IDs for implemented functions (firmware dependent) */
51 #define DICE_FL_OP_GET_IMAGE_DESC 0x0 // parameters: imageId return: imageDesc
52 #define DICE_FL_OP_DELETE_IMAGE 0x1 // parameters: name return: none
53 #define DICE_FL_OP_CREATE_IMAGE 0x2 // parameters: execAddr, entryAddr, name return: none
54 #define DICE_FL_OP_UPLOAD 0x3 // parameters: index, length, data, return none
55 #define DICE_FL_OP_UPLOAD_STAT 0x4 // parameters: length return checksum
56 #define DICE_FL_OP_RESET_IMAGE 0x5 // parameters: none
57 #define DICE_FL_OP_TEST_ACTION 0x6 // parameters: none
58 #define DICE_FL_OP_GET_FLASH_INFO 0x7 // parameters: none
59 #define DICE_FL_OP_READ_MEMORY 0x8 // parameters: none
60 #define DICE_FL_OP_NOOP 0x9 // parameters: none
61 #define DICE_FL_OP_GET_RUNNING_IMAGE_VINFO 0xA // parameters: none return: vendorInfo
62 #define DICE_FL_OP_CREATE_IMAGE2 0xB // parameters: none return: vendorInfo
63 #define DICE_FL_OP_GET_APP_INFO 0xC // parameters: none return: new info structure
65 /* return status #defines */
66 #define DICE_FL_RETURN_NO_ERROR 0x00000000 //Operation successful
67 #define DICE_FL_E_GEN_NOMATCH 0xFF000000 //for Opcode ID: 0x0
68 #define DICE_FL_E_FIS_ILLEGAL_IMAGE 0xC5000001 //for Opcode ID: 0x1, 0x2
69 //#define DICE_FL_E_FIS_FLASH_OP_FAILED 0x00000000 //for Opcode ID: 0x1, 0x2
70 //#define DICE_FL_E_FIS_NO_SPACE 0x00000000 //for Opcode ID: 0x2
71 #define DICE_FL_E_BAD_INPUT_PARAM 0xC3000003 //for Opcode ID: 0x3
72 //#define DICE_FL_E_FAIL 0x00000000 //for Opcode ID: 0x6
74 /* data structure #defines */
75 #define MAX_IMAGE_NAME 16
77 /* data structures input parameters */
78 typedef struct {
79 uint32_t length;
80 uint32_t execAddr;
81 uint32_t entryAddr;
82 char name[MAX_IMAGE_NAME];
83 } DICE_FL_CREATE_IMAGE_PARAM;
85 typedef struct {
86 char name[MAX_IMAGE_NAME];
87 } DICE_FL_DELETE_IMAGE_PARAM;
89 //decomposition of upload parameter due to limited transfer-bandwidth (max 128 quadlets = 512 bytes)
90 //header part of upload parameter
91 typedef struct {
92 uint32_t index;
93 uint32_t length;
94 } DICE_FL_UPLOAD_HEADER_PARAM;
96 //data part of upload parameter
97 typedef struct {
98 uint32_t buffer[128];
99 } DICE_FL_UPLOAD_DATA_PARAM;
101 typedef struct {
102 uint32_t cmdID;
103 uint32_t lvalue0;
104 uint32_t lvalue1;
105 } DICE_FL_TEST_ACTION_PARAM;
107 typedef struct {
108 uint32_t uiStartAddress;
109 uint32_t uiEndAddress;
110 uint32_t uiNumBlocks;
111 uint32_t uiBlockSize;
112 } DICE_FL_INFO_PARAM;
114 typedef struct {
115 uint32_t uiStartAddress;
116 uint32_t uiLen;
117 char ReadBuffer[500]/*[4000]*/;
118 } DICE_FL_READ_MEMORY;
120 /* data structures output parameters */
121 typedef struct {
122 char name[MAX_IMAGE_NAME];
123 uint32_t flashBase;
124 uint32_t memBase;
125 uint32_t size;
126 uint32_t entryPoint;
127 uint32_t length;
128 uint32_t chkSum;
129 uint32_t uiBoardSerialNumber;
130 uint32_t uiVersionHigh;
131 uint32_t uiVersionLow;
132 uint32_t uiConfigurationFlags;
133 char BuildTime[64];
134 char BuildDate[64];
135 } DICE_FL_GET_IMAGE_DESC_RETURN;
137 typedef struct {
138 uint32_t uiProductID;
139 char uiVendorID[8];
140 uint32_t uiVMajor;
141 uint32_t uiVMinor;
142 uint32_t user1;
143 uint32_t user2;
144 } DICE_FL_GET_VENDOR_IMAGE_DESC_RETURN;
146 typedef struct {
147 uint32_t data[100];
148 } DICE_FL_TEST_ACTION_RETURN;
150 typedef struct
152 uint32_t uiBaseSDKVersion; //The full version/revision of the SDK this build was based on
153 uint32_t uiApplicationVersion; //The full version/revision of the Application
154 uint32_t uiVendorID; //The Vendor ID
155 uint32_t uiProductID; //The product ID
156 char BuildTime[64]; //Build time
157 char BuildDate[64]; //Build date
158 uint32_t uiBoardSerialNumber; //The serial number of the board as obtained from persist. storage
159 } DICE_FL_GET_APP_INFO_RETURN;
161 #endif