1 |
/* |
---|
2 |
* Copyright (C) 2005-2007 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This library is free software; you can redistribute it and/or |
---|
10 |
* modify it under the terms of the GNU Lesser General Public |
---|
11 |
* License version 2.1, as published by the Free Software Foundation; |
---|
12 |
* |
---|
13 |
* This library is distributed in the hope that it will be useful, |
---|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 |
* Lesser General Public License for more details. |
---|
17 |
* |
---|
18 |
* You should have received a copy of the GNU Lesser General Public |
---|
19 |
* License along with this library; if not, write to the Free Software |
---|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
---|
21 |
* MA 02110-1301 USA |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#include "ARMHandler.h" |
---|
25 |
|
---|
26 |
IMPL_DEBUG_MODULE( ARMHandler, ARMHandler, DEBUG_LEVEL_VERBOSE); |
---|
27 |
/** |
---|
28 |
* @param start identifies addressrange |
---|
29 |
* @param length identifies addressrange length (in bytes) |
---|
30 |
* @param initial_value pointer to buffer containing (if necessary) initial value |
---|
31 |
* NULL means undefined |
---|
32 |
* @param access_rights access-rights for registered addressrange handled |
---|
33 |
* by kernel-part. Value is one or more binary or of the |
---|
34 |
* following flags - ARM_READ, ARM_WRITE, ARM_LOCK |
---|
35 |
* @param notification_options identifies for which type of request you want |
---|
36 |
* to be notified. Value is one or more binary or of the |
---|
37 |
* following flags - ARM_READ, ARM_WRITE, ARM_LOCK |
---|
38 |
* @param client_transactions identifies for which type of request you want |
---|
39 |
* to handle the request by the client application. |
---|
40 |
* for those requests no response will be generated, but |
---|
41 |
* has to be generated by the application. |
---|
42 |
* Value is one or more binary or of the |
---|
43 |
* following flags - ARM_READ, ARM_WRITE, ARM_LOCK |
---|
44 |
* For each bit set here, notification_options and |
---|
45 |
* access_rights will be ignored. |
---|
46 |
* |
---|
47 |
*/ |
---|
48 |
ARMHandler::ARMHandler(nodeaddr_t start, size_t length, |
---|
49 |
unsigned int access_rights, |
---|
50 |
unsigned int notification_options, |
---|
51 |
unsigned int client_transactions |
---|
52 |
) |
---|
53 |
: m_start(start), |
---|
54 |
m_length(length), |
---|
55 |
m_access_rights(access_rights), |
---|
56 |
m_notification_options(notification_options), |
---|
57 |
m_client_transactions(client_transactions), |
---|
58 |
m_buffer(0) |
---|
59 |
{ |
---|
60 |
m_buffer=(byte_t*)calloc(length, sizeof(byte_t)); |
---|
61 |
memset(&m_response,0,sizeof(m_response)); |
---|
62 |
} |
---|
63 |
|
---|
64 |
ARMHandler::~ARMHandler() { |
---|
65 |
if(m_buffer) |
---|
66 |
delete m_buffer; |
---|
67 |
} |
---|
68 |
|
---|
69 |
bool ARMHandler::handleRead(struct raw1394_arm_request *req) { |
---|
70 |
debugOutput(DEBUG_LEVEL_VERBOSE,"Read\n"); |
---|
71 |
printRequest(req); |
---|
72 |
return true; |
---|
73 |
} |
---|
74 |
|
---|
75 |
bool ARMHandler::handleWrite(struct raw1394_arm_request *req) { |
---|
76 |
debugOutput(DEBUG_LEVEL_VERBOSE,"Write\n"); |
---|
77 |
printRequest(req); |
---|
78 |
return true; |
---|
79 |
} |
---|
80 |
|
---|
81 |
bool ARMHandler::handleLock(struct raw1394_arm_request *req) { |
---|
82 |
debugOutput(DEBUG_LEVEL_VERBOSE,"Lock\n"); |
---|
83 |
printRequest(req); |
---|
84 |
return true; |
---|
85 |
} |
---|
86 |
|
---|
87 |
// typedef struct raw1394_arm_request { |
---|
88 |
// nodeid_t destination_nodeid; |
---|
89 |
// nodeid_t source_nodeid; |
---|
90 |
// nodeaddr_t destination_offset; |
---|
91 |
// u_int8_t tlabel; |
---|
92 |
// u_int8_t tcode; |
---|
93 |
// u_int8_t extended_transaction_code; |
---|
94 |
// u_int32_t generation; |
---|
95 |
// arm_length_t buffer_length; |
---|
96 |
// byte_t *buffer; |
---|
97 |
// } *raw1394_arm_request_t; |
---|
98 |
// |
---|
99 |
// typedef struct raw1394_arm_response { |
---|
100 |
// int response_code; |
---|
101 |
// arm_length_t buffer_length; |
---|
102 |
// byte_t *buffer; |
---|
103 |
// } *raw1394_arm_response_t; |
---|
104 |
// |
---|
105 |
// typedef struct raw1394_arm_request_response { |
---|
106 |
// struct raw1394_arm_request *request; |
---|
107 |
// struct raw1394_arm_response *response; |
---|
108 |
// } *raw1394_arm_request_response_t; |
---|
109 |
|
---|
110 |
void ARMHandler::printRequest(struct raw1394_arm_request *arm_req) { |
---|
111 |
debugOutput(DEBUG_LEVEL_VERBOSE," request info: \n"); |
---|
112 |
debugOutput(DEBUG_LEVEL_VERBOSE," from node 0x%04X to node 0x%04X\n", |
---|
113 |
arm_req->source_nodeid, arm_req->destination_nodeid); |
---|
114 |
debugOutput(DEBUG_LEVEL_VERBOSE," tlabel: 0x%02X, tcode: 0x%02X, extended tcode: 0x%02X\n", |
---|
115 |
arm_req->tlabel, arm_req->tcode, arm_req->extended_transaction_code); |
---|
116 |
debugOutput(DEBUG_LEVEL_VERBOSE," generation: %lu\n", |
---|
117 |
arm_req->generation); |
---|
118 |
debugOutput(DEBUG_LEVEL_VERBOSE," buffer length: %lu\n", |
---|
119 |
arm_req->buffer_length); |
---|
120 |
printBufferBytes(DEBUG_LEVEL_VERBOSE, arm_req->buffer_length, arm_req->buffer); |
---|
121 |
} |
---|
122 |
|
---|
123 |
void |
---|
124 |
ARMHandler::printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const |
---|
125 |
{ |
---|
126 |
|
---|
127 |
for ( unsigned int i=0; i < length; ++i ) { |
---|
128 |
if ( ( i % 16 ) == 0 ) { |
---|
129 |
if ( i > 0 ) { |
---|
130 |
debugOutputShort(level,"\n"); |
---|
131 |
} |
---|
132 |
debugOutputShort(level," %4d: ",i*16); |
---|
133 |
} |
---|
134 |
debugOutputShort(level,"%02X ",buffer[i]); |
---|
135 |
} |
---|
136 |
debugOutputShort(level,"\n"); |
---|
137 |
} |
---|