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

Revision 414, 5.2 kB (checked in by pieterpalmers, 14 years ago)

extended ARM handler functionality

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