Clean up compiler warnings when compiling on 64-bit systems. These are mostly fixing...
[ffado.git] / libffado / src / libieee1394 / ARMHandler.cpp
blob0e1576fc7a5022d2eae710ad5f1e173a24a9e2cd
1 /*
2 * Copyright (C) 2005-2008 by Pieter Palmers
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/>.
24 #include <cstring>
25 #include <cstdlib>
27 #include "ieee1394service.h"
29 /**
30 * @param parent the 1394service that created this handler
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.
51 Ieee1394Service::ARMHandler::ARMHandler(Ieee1394Service &parent,
52 nodeaddr_t start, size_t length,
53 unsigned int access_rights,
54 unsigned int notification_options,
55 unsigned int client_transactions)
56 : m_parent(parent)
57 , m_start(start)
58 , m_length(length)
59 , m_access_rights(access_rights)
60 , m_notification_options(notification_options)
61 , m_client_transactions(client_transactions)
62 , m_buffer(0)
63 , m_debugModule(parent.m_debugModule)
65 m_buffer = (byte_t*)calloc(length, sizeof(byte_t));
66 memset(&m_response, 0, sizeof(m_response));
69 Ieee1394Service::ARMHandler::~ARMHandler() {
70 if(m_buffer)
71 delete m_buffer;
74 bool
75 Ieee1394Service::ARMHandler::handleRead(struct raw1394_arm_request *req) {
76 debugOutput(DEBUG_LEVEL_VERBOSE, "Read\n");
77 printRequest(req);
78 return true;
81 bool
82 Ieee1394Service::ARMHandler::handleWrite(struct raw1394_arm_request *req) {
83 debugOutput(DEBUG_LEVEL_VERBOSE, "Write\n");
84 printRequest(req);
85 return true;
88 bool
89 Ieee1394Service::ARMHandler::handleLock(struct raw1394_arm_request *req) {
90 debugOutput(DEBUG_LEVEL_VERBOSE, "Lock\n");
91 printRequest(req);
92 return true;
95 // typedef struct raw1394_arm_request {
96 // nodeid_t destination_nodeid;
97 // nodeid_t source_nodeid;
98 // nodeaddr_t destination_offset;
99 // u_int8_t tlabel;
100 // u_int8_t tcode;
101 // u_int8_t extended_transaction_code;
102 // u_int32_t generation;
103 // arm_length_t buffer_length;
104 // byte_t *buffer;
105 // } *raw1394_arm_request_t;
107 // typedef struct raw1394_arm_response {
108 // int response_code;
109 // arm_length_t buffer_length;
110 // byte_t *buffer;
111 // } *raw1394_arm_response_t;
113 // typedef struct raw1394_arm_request_response {
114 // struct raw1394_arm_request *request;
115 // struct raw1394_arm_response *response;
116 // } *raw1394_arm_request_response_t;
118 void
119 Ieee1394Service::ARMHandler::printRequest(struct raw1394_arm_request *arm_req) {
120 debugOutput(DEBUG_LEVEL_VERBOSE, " request info: \n");
121 debugOutput(DEBUG_LEVEL_VERBOSE, " from node 0x%04X to node 0x%04X\n",
122 arm_req->source_nodeid, arm_req->destination_nodeid);
123 debugOutput(DEBUG_LEVEL_VERBOSE, " tlabel: 0x%02X, tcode: 0x%02X, extended tcode: 0x%02X\n",
124 arm_req->tlabel, arm_req->tcode, arm_req->extended_transaction_code);
125 debugOutput(DEBUG_LEVEL_VERBOSE, " generation: %u\n",
126 arm_req->generation);
127 debugOutput(DEBUG_LEVEL_VERBOSE, " buffer length: %u\n",
128 arm_req->buffer_length);
129 printBufferBytes(DEBUG_LEVEL_VERBOSE, arm_req->buffer_length, arm_req->buffer);
132 void
133 Ieee1394Service::ARMHandler::printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const
136 for ( unsigned int i=0; i < length; ++i ) {
137 if ( ( i % 16 ) == 0 ) {
138 if ( i > 0 ) {
139 debugOutputShort(level,"\n");
141 debugOutputShort(level," %4d: ",i*16);
143 debugOutputShort(level,"%02X ",buffer[i]);
145 debugOutputShort(level,"\n");