source: trunk/kernel/kern/chdev.c @ 559

Last change on this file since 559 was 545, checked in by nicolas.van.phan@…, 6 years ago

Fix memory access at 0x10 and 0x14

chdev_dir() tried to read chdev_dir.iob to display information
about the IOB, but on TSAR LETI there's no IOB and this pointer
is NULL.

File size: 19.1 KB
RevLine 
[5]1/*
2 * chdev.c - channel device descriptor operations implementation.
3 *
4 * Authors  Alain Greiner   (2016)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH.is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH.is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[14]24#include <kernel_config.h>
[457]25#include <hal_kernel_types.h>
[5]26#include <hal_special.h>
[447]27#include <hal_remote.h>
[407]28#include <hal_irqmask.h>
[16]29#include <printk.h>
[5]30#include <boot_info.h>
31#include <xlist.h>
32#include <kmem.h>
[407]33#include <scheduler.h>
[5]34#include <thread.h>
35#include <rpc.h>
36#include <chdev.h>
[23]37#include <devfs.h>
[5]38
[317]39
40extern chdev_directory_t    chdev_dir;   // allocated in kernel_init.c
41
[438]42#if (DEBUG_SYS_READ & 1)
[435]43extern uint32_t enter_chdev_cmd_read;
44extern uint32_t exit_chdev_cmd_read;
45extern uint32_t enter_chdev_server_read;
46extern uint32_t exit_chdev_server_read;
[407]47#endif
[317]48
[438]49#if (DEBUG_SYS_WRITE & 1)
[435]50extern uint32_t enter_chdev_cmd_write;
51extern uint32_t exit_chdev_cmd_write;
52extern uint32_t enter_chdev_server_write;
53extern uint32_t exit_chdev_server_write;
54#endif
55
[5]56////////////////////////////////////////////
57char * chdev_func_str( uint32_t func_type ) 
58{
[527]59  switch ( func_type ) {
60    case DEV_FUNC_RAM: return "RAM";
61    case DEV_FUNC_ROM: return "ROM";
62    case DEV_FUNC_FBF: return "FBF";
63    case DEV_FUNC_IOB: return "IOB";
64    case DEV_FUNC_IOC: return "IOC";
65    case DEV_FUNC_MMC: return "MMC";
66    case DEV_FUNC_DMA: return "DMA";
67    case DEV_FUNC_NIC: return "NIC";
68    case DEV_FUNC_TIM: return "TIM";
69    case DEV_FUNC_TXT: return "TXT";
70    case DEV_FUNC_ICU: return "ICU";
71    case DEV_FUNC_PIC: return "PIC";
72    default:           return "undefined";
73    }
[5]74}
75
76/////////////////////////////////////////
77chdev_t * chdev_create( uint32_t    func,
78                        uint32_t    impl,
79                        uint32_t    channel,
80                        uint32_t    is_rx,
81                        xptr_t      base )
82{
83    chdev_t    * chdev;
84    kmem_req_t   req;
85
86    // allocate memory for chdev
87    req.type   = KMEM_DEVICE;
88    req.flags  = AF_ZERO;
89    chdev      = (chdev_t *)kmem_alloc( &req );
90
91    if( chdev == NULL ) return NULL;
92
93    // initialize waiting threads queue and associated lock
94    remote_spinlock_init( XPTR( local_cxy , &chdev->wait_lock ) );
95    xlist_root_init( XPTR( local_cxy , &chdev->wait_root ) );
96
97    // initialize attributes
98    chdev->func    =  func;
99    chdev->impl    =  impl;
100    chdev->channel =  channel;
101    chdev->is_rx   =  is_rx;
102    chdev->base    =  base; 
103
104    return chdev;
105
106}  // end chdev_create()
107
108///////////////////////////////////
109void chdev_print( chdev_t * chdev )
110{
111    printk("\n - func      = %s"
112           "\n - channel   = %d"
113           "\n - base      = %l"
114           "\n - cmd       = %x"
115           "\n - isr       = %x"
116           "\n - chdev     = %x\n",
117           chdev_func_str(chdev->func),
118           chdev->channel,
119           chdev->base,
120           chdev->cmd,
121           chdev->isr,
122           chdev );
123}
124
[407]125//////////////////////////////////////////////////
126void chdev_register_command( xptr_t     chdev_xp )
[5]127{
[407]128    thread_t * server_ptr;    // local pointer on server thread associated to chdev
[440]129    xptr_t     server_xp;     // extended pointer on server thread
[407]130    core_t   * core_ptr;      // local pointer on core running the server thread
[457]131    uint32_t   server_lid;    // core running the server thread local index
[407]132    xptr_t     lock_xp;       // extended pointer on lock protecting the chdev queue
133    uint32_t   save_sr;       // for critical section
[5]134
[438]135#if (DEBUG_SYS_READ & 1)
[435]136enter_chdev_cmd_read = (uint32_t)hal_get_cycles();
[418]137#endif
138
[438]139#if (DEBUG_SYS_WRITE & 1)
[435]140enter_chdev_cmd_write = (uint32_t)hal_get_cycles();
141#endif
142
[407]143    thread_t * this = CURRENT_THREAD;
144
[440]145    // get chdev cluster and local pointer
[5]146    cxy_t     chdev_cxy = GET_CXY( chdev_xp );
[440]147    chdev_t * chdev_ptr = GET_PTR( chdev_xp );
[5]148
[440]149    // get local and extended pointers on server thread
150    server_ptr = (thread_t *)hal_remote_lpt( XPTR( chdev_cxy , &chdev_ptr->server) );
151    server_xp  = XPTR( chdev_cxy , server_ptr );
152
153    // get local pointer on core running the server thread
154    core_ptr   = (core_t *)hal_remote_lpt( XPTR( chdev_cxy , &server_ptr->core ) );
155
156    // get server core local index
[457]157    server_lid = hal_remote_lw( XPTR( chdev_cxy , &core_ptr->lid ) );
[440]158
[438]159#if (DEBUG_CHDEV_CMD_RX || DEBUG_CHDEV_CMD_TX)
[437]160bool_t is_rx = hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->is_rx ) );
161#endif
162   
[438]163#if DEBUG_CHDEV_CMD_RX
[437]164uint32_t rx_cycle = (uint32_t)hal_get_cycles();
[438]165if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
[450]166printk("\n[DBG] %s : client_thread %x (%s) enter for RX / server = %x / cycle %d\n",
167__FUNCTION__, this, thread_type_str(this->type) , server_ptr, rx_cycle );
[437]168#endif
169
[438]170#if DEBUG_CHDEV_CMD_TX
[437]171uint32_t tx_cycle = (uint32_t)hal_get_cycles();
[438]172if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
[450]173printk("\n[DBG] %s : client_thread %x (%s) enter for TX / server = %x / cycle %d\n",
174__FUNCTION__, this, thread_type_str(this->type) , server_ptr, tx_cycle );
[437]175#endif
176
[440]177    // build extended pointer on client thread xlist
178    xptr_t  list_xp    = XPTR( local_cxy , &this->wait_list );
[5]179
[440]180    // build extended pointer on chdev waiting queue root
181    xptr_t  root_xp    = XPTR( chdev_cxy , &chdev_ptr->wait_root );
[5]182
[440]183    // build extended pointer on server thread blocked state
184    xptr_t  blocked_xp = XPTR( chdev_cxy , &server_ptr->blocked );
185
186    // build extended pointer on lock protecting chdev waiting queue
[407]187    lock_xp = XPTR( chdev_cxy , &chdev_ptr->wait_lock );
188
[450]189    // critical section for the following sequence:
[440]190    // (1) take the lock protecting waiting queue
191    // (2) block the client thread
192    // (3) unblock the server thread if required
193    // (4) register client thread in server queue
194    // (5) send IPI to force server scheduling
195    // (6) release the lock protecting waiting queue
196    // (7) deschedule
197    // ... in this order
[407]198
[440]199    // enter critical section
200    hal_disable_irq( &save_sr );
[407]201
[446]202    // take the lock protecting chdev waiting queue
[440]203    remote_spinlock_lock( lock_xp );
[408]204
205    // block current thread
[436]206    thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_IO );
[408]207
[450]208#if (DEBUG_CHDEV_CMD_TX & 1)
209if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
210printk("\n[DBG] in %s : client thread %x blocked\n", __FUNCTION__, this );
211#endif
212
[457]213#if (DEBUG_CHDEV_CMD_RX & 1)
214if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
215printk("\n[DBG] in %s : client thread %x blocked\n", __FUNCTION__, this );
216#endif
217
[446]218    // unblock server thread if required
[440]219    if( hal_remote_lw( blocked_xp ) & THREAD_BLOCKED_IDLE )
220    thread_unblock( server_xp , THREAD_BLOCKED_IDLE );
221
[450]222#if (DEBUG_CHDEV_CMD_TX & 1)
223if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
[457]224printk("\n[DBG] in %s : TX server thread %x unblocked\n", __FUNCTION__, server_ptr );
[450]225#endif
226
[457]227#if (DEBUG_CHDEV_CMD_RX & 1)
228if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
229printk("\n[DBG] in %s : RX server thread %x unblocked\n", __FUNCTION__, server_ptr );
230#endif
231
[5]232    // register client thread in waiting queue
[407]233    xlist_add_last( root_xp , list_xp );
[5]234
[450]235#if (DEBUG_CHDEV_CMD_TX & 1)
236if( (is_rx == 0)  && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
237printk("\n[DBG] in %s : thread %x registered write request in chdev\n", __FUNCTION__, this );
238#endif
239 
[457]240#if (DEBUG_CHDEV_CMD_RX & 1)
241if( (is_rx)  && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
242printk("\n[DBG] in %s : thread %x registered read request in chdev\n", __FUNCTION__, this );
243#endif
244 
[440]245    // send IPI to core running the server thread when server != client
[457]246    if( (server_lid != this->core->lid) || (local_cxy != chdev_cxy) )
[450]247    {
[457]248        dev_pic_send_ipi( chdev_cxy , server_lid ); 
249
[450]250#if (DEBUG_CHDEV_CMD_TX & 1)
251if( (is_rx == 0)  && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
[457]252printk("\n[DBG] in %s : client thread %x sent IPI to TX server thread %x\n",
[450]253__FUNCTION__, this, server_ptr );
254#endif
255
[457]256#if (DEBUG_CHDEV_CMD_RX & 1)
257if( (is_rx)  && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
258printk("\n[DBG] in %s : client thread %x sent IPI to RX server thread %x\n",
259__FUNCTION__, this, server_ptr );
260#endif
261
[450]262    }
263 
[440]264    // release lock
265    remote_spinlock_unlock( lock_xp );
266
[408]267    // deschedule
[503]268    assert( thread_can_yield() , "illegal sched_yield\n" );
[408]269    sched_yield("blocked on I/O");
[407]270
271    // exit critical section
272    hal_restore_irq( save_sr );
273
[438]274#if DEBUG_CHDEV_CMD_RX
[437]275rx_cycle = (uint32_t)hal_get_cycles();
[438]276if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
[437]277printk("\n[DBG] %s : client_thread %x (%s) exit for RX / cycle %d\n",
278__FUNCTION__, this, thread_type_str(this->type) , rx_cycle );
[433]279#endif
280
[438]281#if DEBUG_CHDEV_CMD_TX
[437]282tx_cycle = (uint32_t)hal_get_cycles();
[438]283if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
[437]284printk("\n[DBG] %s : client_thread %x (%s) exit for TX / cycle %d\n",
285__FUNCTION__, this, thread_type_str(this->type) , tx_cycle );
286#endif
287
[438]288#if (DEBUG_SYS_READ & 1)
[435]289exit_chdev_cmd_read = (uint32_t)hal_get_cycles();
[418]290#endif
291
[438]292#if (DEBUG_SYS_WRITE & 1)
[435]293exit_chdev_cmd_write = (uint32_t)hal_get_cycles();
294#endif
295
[5]296}  // end chdev_register_command()
297
298///////////////////////////////////////////////
299void chdev_sequencial_server( chdev_t * chdev )
300{
301    xptr_t          client_xp;    // extended pointer on waiting thread
302    cxy_t           client_cxy;   // cluster of client thread
303    thread_t      * client_ptr;   // local pointer on client thread
[407]304    thread_t      * server;       // local pointer on server thread
[5]305    xptr_t          root_xp;      // extended pointer on device waiting queue root
[407]306    xptr_t          lock_xp;      // extended pointer on lock ptotecting chdev queue
[5]307
308    server = CURRENT_THREAD;
309
[437]310    // get root and lock on command queue
[5]311    root_xp = XPTR( local_cxy , &chdev->wait_root );
[407]312    lock_xp = XPTR( local_cxy , &chdev->wait_lock );
[5]313
[407]314        // This infinite loop is executed by the DEV thread
315    // to handle commands registered in the chdev queue.
[5]316    while( 1 )
317    {
[407]318        // get the lock protecting the waiting queue
319        remote_spinlock_lock( lock_xp );
320
[5]321        // check waiting queue state
[407]322        if( xlist_is_empty( root_xp ) ) // waiting queue empty
[5]323        {
324            // release lock
[407]325            remote_spinlock_unlock( lock_xp );
[5]326
[440]327            // block
328            thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_IDLE ); 
329
[408]330            // deschedule
[516]331            assert( thread_can_yield() , "illegal sched_yield\n" );
[408]332            sched_yield("I/O queue empty");
[5]333        } 
[407]334        else                            // waiting queue not empty
[5]335        {
[407]336            // get extended pointer on first client thread
337            client_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list );
[5]338
[440]339            // get client thread cluster and local pointer
[407]340            client_cxy = GET_CXY( client_xp );
[440]341            client_ptr = GET_PTR( client_xp );
[407]342
[440]343            // remove this first client thread from waiting queue
344            xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );
345
346            // release lock
347            remote_spinlock_unlock( lock_xp );
348
[438]349#if DEBUG_CHDEV_SERVER_RX
[437]350uint32_t rx_cycle = (uint32_t)hal_get_cycles();
[438]351if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
[437]352printk("\n[DBG] %s : server_thread %x start RX / client %x / cycle %d\n",
353__FUNCTION__ , server , client_ptr , rx_cycle );
354#endif
355
[438]356#if DEBUG_CHDEV_SERVER_TX
[437]357uint32_t tx_cycle = (uint32_t)hal_get_cycles();
[438]358if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
[437]359printk("\n[DBG] %s : server_thread %x start TX / client %x / cycle %d\n",
360__FUNCTION__ , server , client_ptr , tx_cycle );
361#endif
362
[438]363#if (DEBUG_SYS_READ & 1)
[437]364enter_chdev_server_read = (uint32_t)hal_get_cycles();
365#endif
366
[438]367#if (DEBUG_SYS_WRITE & 1)
[437]368enter_chdev_server_write = (uint32_t)hal_get_cycles();
369#endif
370
[407]371            // call driver command function to execute I/O operation
372            chdev->cmd( client_xp );
[5]373       
[418]374            // unblock client thread
375            thread_unblock( client_xp , THREAD_BLOCKED_IO );
376
[438]377#if DEBUG_CHDEV_SERVER_RX
[437]378rx_cycle = (uint32_t)hal_get_cycles();
[438]379if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
[437]380printk("\n[DBG] %s : server_thread %x completes RX / client %x / cycle %d\n",
381__FUNCTION__ , server , client_ptr , rx_cycle );
[433]382#endif
[5]383
[438]384#if DEBUG_CHDEV_SERVER_TX
[437]385tx_cycle = (uint32_t)hal_get_cycles();
[438]386if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
[437]387printk("\n[DBG] %s : server_thread %x completes TX / client %x / cycle %d\n",
388__FUNCTION__ , server , client_ptr , tx_cycle );
389#endif
390
[438]391#if (DEBUG_SYS_READ & 1)
[435]392exit_chdev_server_read = (uint32_t)hal_get_cycles();
[407]393#endif
394
[438]395#if (DEBUG_SYS_WRITE & 1)
[435]396exit_chdev_server_write = (uint32_t)hal_get_cycles();
397#endif
398
[407]399        }
[5]400    }  // end while
401}  // end chdev_sequencial_server()
402
[428]403////////////////////////////////////////
404xptr_t chdev_from_file( xptr_t file_xp )
405{
406    cxy_t         file_cxy;
407    vfs_file_t  * file_ptr;
408    uint32_t      inode_type;
409    vfs_inode_t * inode_ptr;
410    chdev_t     * chdev_ptr;
411
[492]412    assert( (file_xp != XPTR_NULL) ,
[440]413    "file_xp == XPTR_NULL\n" );
414
[428]415    // get cluster and local pointer on remote file descriptor
416    // associated inode and chdev are stored in same cluster as the file desc.
417    file_cxy  = GET_CXY( file_xp );
418    file_ptr  = (vfs_file_t *)GET_PTR( file_xp );
419
420    // get inode type from file descriptor
421    inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
422    inode_ptr  = (vfs_inode_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
423
[492]424    assert( (inode_type == INODE_TYPE_DEV) ,
[440]425    "inode type %d is not INODE_TYPE_DEV\n", inode_type );
[428]426
427    // get chdev local pointer from inode extension
428    chdev_ptr = (chdev_t *)hal_remote_lpt( XPTR( file_cxy , &inode_ptr->extend ) );
429
430    return XPTR( file_cxy , chdev_ptr );
431
432}  // end chdev_from_file()
433
[317]434////////////////////////
[485]435void chdev_dir_display( void )
[317]436{
[428]437    uint32_t  i;
438    cxy_t     cxy;
439    chdev_t * ptr;
440    uint32_t  base;
441    reg_t     save_sr;
[317]442
[428]443    // get pointers on TXT0 chdev
444    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
445    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
446    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
[317]447
[428]448    // get extended pointer on remote TXT0 chdev lock
449    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
[317]450
[428]451    // get TXT0 lock in busy waiting mode
452    remote_spinlock_lock_busy( lock_xp , &save_sr );
[317]453
[428]454    // header
455    nolock_printk("\n***** external chdevs directory *****\n");
[317]456
[428]457    // IOB
[545]458    if (chdev_dir.iob != NULL )
459    {
460        cxy  = GET_CXY( chdev_dir.iob );
461        ptr  = GET_PTR( chdev_dir.iob );
462        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
463        nolock_printk("  - iob       : cxy = %X / ptr = %X / base = %X\n", cxy, ptr, base);
464    }
[407]465
[428]466    // PIC
467    cxy  = GET_CXY( chdev_dir.pic );
468    ptr  = GET_PTR( chdev_dir.pic );
469    base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
470    nolock_printk("  - pic       : cxy = %X / ptr = %X / base = %X\n", cxy, ptr, base);
[407]471
[428]472    // TXT
473    for( i = 0 ; i < LOCAL_CLUSTER->nb_txt_channels ; i++ )
474    {
475        cxy = GET_CXY( chdev_dir.txt_rx[i] );
476        ptr = GET_PTR( chdev_dir.txt_rx[i] );
477        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
478        nolock_printk("  - txt_rx[%d] : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
[407]479
[428]480        cxy = GET_CXY( chdev_dir.txt_tx[i] );
481        ptr = GET_PTR( chdev_dir.txt_tx[i] );
482        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
483        nolock_printk("  - txt_tx[%d] : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
484    }
[317]485
[428]486    // IOC
487    for( i = 0 ; i < LOCAL_CLUSTER->nb_ioc_channels ; i++ )
488    {
489        cxy = GET_CXY( chdev_dir.ioc[i] );
490        ptr = GET_PTR( chdev_dir.ioc[i] );
491        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
492        nolock_printk("  - ioc[%d]    : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
493    }
[317]494
[428]495    // FBF
496    for( i = 0 ; i < LOCAL_CLUSTER->nb_fbf_channels ; i++ )
497    {
498        cxy  = GET_CXY( chdev_dir.fbf[i] );
499        ptr  = GET_PTR( chdev_dir.fbf[i] );
500        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
501        nolock_printk("  - fbf[%d]    : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
502    }
[317]503
[428]504    // NIC
505    for( i = 0 ; i < LOCAL_CLUSTER->nb_nic_channels ; i++ )
506    {
507        cxy = GET_CXY( chdev_dir.nic_rx[i] );
508        ptr = GET_PTR( chdev_dir.nic_rx[i] );
509        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
510        nolock_printk("  - nic_rx[%d] : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
[317]511
[428]512        cxy = GET_CXY( chdev_dir.nic_tx[i] );
513        ptr = GET_PTR( chdev_dir.nic_tx[i] );
514        base = (uint32_t)hal_remote_lwd( XPTR( cxy , &ptr->base ) );
515        nolock_printk("  - nic_tx[%d] : cxy = %X / ptr = %X / base = %X\n", i, cxy, ptr, base);
516    }
[317]517
[428]518    // release lock
519    remote_spinlock_unlock_busy( lock_xp , save_sr );
520
[317]521}  // end chdev_dir_display()
522
[447]523///////////////////////////////////////////
524void chdev_queue_display( xptr_t chdev_xp )
525{
526    cxy_t       chdev_cxy;          // chdev cluster
527    chdev_t   * chdev_ptr;          // chdev local pointer
528    xptr_t      root_xp;            // extended pointer on waiting queuue root
529    char        name[16];           // local copie of chdev name
530    xptr_t      iter_xp;            // extended pointer on xlist_t field in waiting thread
531    xptr_t      thread_xp;          // extended pointer on thread registered in queue
532    cxy_t       thread_cxy;         // cluster identifier for waiting thread
533    thread_t  * thread_ptr;         // local pointer on waiting thread
534    trdid_t     trdid;              // waiting thread identifier
535    process_t * process;            // waiting thread process descriptor
536    pid_t       pid;                // waiting thread process identifier
537
538    // get cluster and local pointer on chdev
539    chdev_cxy = GET_CXY( chdev_xp );
540    chdev_ptr = GET_PTR( chdev_xp );
541
542    // get extended pointer on root of requests queue
[450]543    root_xp = XPTR( chdev_cxy , &chdev_ptr->wait_root );
[447]544
545    // get chdev name
546    hal_remote_strcpy( XPTR( local_cxy , name ), XPTR( chdev_cxy , chdev_ptr->name ) );
547
548    // check queue empty
549    if( xlist_is_empty( root_xp ) )
550    {
551        printk("\n***** Waiting queue empty for chdev %s\n", name ); 
552    }
553    else
554    {
555        printk("\n***** Waiting queue for chdev %s\n", name ); 
556
557        // scan the waiting queue
558        XLIST_FOREACH( root_xp , iter_xp )
559        {
560            thread_xp  = XLIST_ELEMENT( iter_xp , thread_t , wait_list );
561            thread_cxy = GET_CXY( thread_xp );
562            thread_ptr = GET_PTR( thread_xp );
563            trdid      = hal_remote_lw ( XPTR( thread_cxy , &thread_ptr->trdid   ) );
564            process    = hal_remote_lpt( XPTR( thread_cxy , &thread_ptr->process ) );
565                        pid        = hal_remote_lw ( XPTR( thread_cxy , &process->pid        ) );
566
[450]567            printk("- thread %X / cluster %X / trdid %X / pid %X\n",
568            thread_ptr, thread_cxy, trdid, pid );
[447]569        }
570    }
571}  // end chdev_queue_display()
572
Note: See TracBrowser for help on using the repository browser.