Ignore:
Timestamp:
Dec 5, 2017, 4:20:07 PM (7 years ago)
Author:
alain
Message:

Fix several bugs in the fork() syscall.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/printk.c

    r407 r408  
    453453}
    454454
     455//////////////////////////
     456void puts( char * string )
     457{
     458    uint32_t   save_sr;
     459    uint32_t   n = 0;
     460
     461    // compute string length
     462    while ( string[n] > 0 ) n++;
     463
     464    // get pointers on TXT0 chdev
     465    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     466    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     467    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     468
     469    // get extended pointer on remote TXT0 chdev lock
     470    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     471
     472    // get TXT0 lock in busy waiting mode
     473    remote_spinlock_lock_busy( lock_xp , &save_sr );
     474
     475    // display string on TTY0
     476    dev_txt_sync_write( string , n );
     477
     478    // release TXT0 lock in busy waiting mode
     479    remote_spinlock_unlock_busy( lock_xp , save_sr );
     480}
     481
     482
     483/////////////////////////
     484void putx( uint32_t val )
     485{
     486    static const char HexaTab[] = "0123456789ABCDEF";
     487
     488    char      buf[10];
     489    uint32_t  c;
     490    uint32_t  save_sr;
     491
     492    buf[0] = '0';
     493    buf[1] = 'x';
     494
     495    // build buffer
     496    for (c = 0; c < 8; c++)
     497    {
     498        buf[9 - c] = HexaTab[val & 0xF];
     499        val = val >> 4;
     500    }
     501
     502    // get pointers on TXT0 chdev
     503    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     504    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     505    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     506
     507    // get extended pointer on remote TXT0 chdev lock
     508    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     509
     510    // get TXT0 lock in busy waiting mode
     511    remote_spinlock_lock_busy( lock_xp , &save_sr );
     512
     513    // display string on TTY0
     514    dev_txt_sync_write( buf , 10 );
     515
     516    // release TXT0 lock in busy waiting mode
     517    remote_spinlock_unlock_busy( lock_xp , save_sr );
     518}
     519
     520/////////////////////////
     521void putl( uint64_t val )
     522{
     523    static const char HexaTab[] = "0123456789ABCDEF";
     524
     525    char      buf[18];
     526    uint32_t  c;
     527    uint32_t  save_sr;
     528
     529    buf[0] = '0';
     530    buf[1] = 'x';
     531
     532    // build buffer
     533    for (c = 0; c < 16; c++)
     534    {
     535        buf[17 - c] = HexaTab[(unsigned int)val & 0xF];
     536        val = val >> 4;
     537    }
     538
     539    // get pointers on TXT0 chdev
     540    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
     541    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     542    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     543
     544    // get extended pointer on remote TXT0 chdev lock
     545    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     546
     547    // get TXT0 lock in busy waiting mode
     548    remote_spinlock_lock_busy( lock_xp , &save_sr );
     549
     550    // display string on TTY0
     551    dev_txt_sync_write( buf , 18 );
     552
     553    // release TXT0 lock in busy waiting mode
     554    remote_spinlock_unlock_busy( lock_xp , save_sr );
     555}
     556
    455557
    456558// Local Variables:
Note: See TracChangeset for help on using the changeset viewer.