root/trunk/libffado/src/libieee1394/ARMHandler.cpp

Revision 1234, 5.1 kB (checked in by holin, 16 years ago)

fix gcc 4.3 compile errors and some warnings (largely from Adrian Knoth)

Line 
1 /*
2  * Copyright (C) 2005-2008 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 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.
13  *
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.
18  *
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/>.
21  *
22  */
23
24 #include <cstring>
25 #include <cstdlib>
26
27 #include "ARMHandler.h"
28
29 IMPL_DEBUG_MODULE( ARMHandler, ARMHandler, DEBUG_LEVEL_NORMAL);
30 /**
31  * @param start          identifies addressrange
32  * @param length         identifies addressrange length (in bytes)
33  * @param initial_value  pointer to buffer containing (if necessary) initial value
34  *                    NULL means undefined
35  * @param access_rights access-rights for registered addressrange handled
36  *                    by kernel-part. Value is one or more binary or of the
37  *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK
38  * @param notification_options identifies for which type of request you want
39  *                    to be notified. Value is one or more binary or of the
40  *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK
41  * @param client_transactions identifies for which type of request you want
42  *                    to handle the request by the client application.
43  *                    for those requests no response will be generated, but
44  *                    has to be generated by the application.
45  *                    Value is one or more binary or of the
46  *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK
47  *                    For each bit set here, notification_options and
48  *                    access_rights will be ignored.
49  *
50  */
51 ARMHandler::ARMHandler(nodeaddr_t start, size_t length,
52                unsigned int access_rights,
53                unsigned int notification_options,
54                unsigned int client_transactions
55               )
56         : m_start(start),
57         m_length(length),
58         m_access_rights(access_rights),
59         m_notification_options(notification_options),
60         m_client_transactions(client_transactions),
61         m_buffer(0)
62 {
63     m_buffer=(byte_t*)calloc(length, sizeof(byte_t));
64     memset(&m_response,0,sizeof(m_response));
65 }
66
67 ARMHandler::~ARMHandler() {
68     if(m_buffer)
69         delete m_buffer;
70 }
71
72 bool ARMHandler::handleRead(struct raw1394_arm_request *req) {
73     debugOutput(DEBUG_LEVEL_VERBOSE, "Read\n");
74     printRequest(req);
75     return true;
76 }
77
78 bool ARMHandler::handleWrite(struct raw1394_arm_request *req) {
79     debugOutput(DEBUG_LEVEL_VERBOSE, "Write\n");
80     printRequest(req);
81     return true;
82 }
83
84 bool ARMHandler::handleLock(struct raw1394_arm_request *req) {
85     debugOutput(DEBUG_LEVEL_VERBOSE, "Lock\n");
86     printRequest(req);
87     return true;
88 }
89
90 // typedef struct raw1394_arm_request {
91 //         nodeid_t        destination_nodeid;
92 //         nodeid_t        source_nodeid;
93 //         nodeaddr_t      destination_offset;
94 //         u_int8_t        tlabel;
95 //         u_int8_t        tcode;
96 //         u_int8_t        extended_transaction_code;
97 //         u_int32_t       generation;
98 //         arm_length_t    buffer_length;
99 //         byte_t          *buffer;
100 // } *raw1394_arm_request_t;
101 //
102 // typedef struct raw1394_arm_response {
103 //         int             response_code;
104 //         arm_length_t    buffer_length;
105 //         byte_t          *buffer;
106 // } *raw1394_arm_response_t;
107 //
108 // typedef struct raw1394_arm_request_response {
109 //         struct raw1394_arm_request  *request;
110 //         struct raw1394_arm_response *response;
111 // } *raw1394_arm_request_response_t;
112
113 void ARMHandler::printRequest(struct raw1394_arm_request *arm_req) {
114     debugOutput(DEBUG_LEVEL_VERBOSE, " request info: \n");
115     debugOutput(DEBUG_LEVEL_VERBOSE, "  from node 0x%04X to node 0x%04X\n",
116         arm_req->source_nodeid, arm_req->destination_nodeid);
117     debugOutput(DEBUG_LEVEL_VERBOSE, "  tlabel: 0x%02X, tcode: 0x%02X, extended tcode: 0x%02X\n",
118         arm_req->tlabel, arm_req->tcode, arm_req->extended_transaction_code);
119     debugOutput(DEBUG_LEVEL_VERBOSE, "  generation: %lu\n",
120         arm_req->generation);
121     debugOutput(DEBUG_LEVEL_VERBOSE, "  buffer length: %lu\n",
122         arm_req->buffer_length);
123     printBufferBytes(DEBUG_LEVEL_VERBOSE, arm_req->buffer_length, arm_req->buffer);
124 }
125
126 void
127 ARMHandler::printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const
128 {
129
130     for ( unsigned int i=0; i < length; ++i ) {
131         if ( ( i % 16 ) == 0 ) {
132             if ( i > 0 ) {
133                 debugOutputShort(level,"\n");
134             }
135             debugOutputShort(level," %4d: ",i*16);
136         }
137         debugOutputShort(level,"%02X ",buffer[i]);
138     }
139     debugOutputShort(level,"\n");
140 }
Note: See TracBrowser for help on using the browser.