RTEMS-6
Annotated Report
libpipe
Sun Feb 28 12:27:30 2021

40004650 <fifo_open>:                                                                     
                                                                                          
int fifo_open(                                                                            
  pipe_control_t **pipep,                                                                 
  rtems_libio_t *iop                                                                      
)                                                                                         
{                                                                                         
40004650:   fe010113            addi    sp,sp,-32                                         
40004654:   01212823            sw  s2,16(sp)                                             
  _Mutex_Acquire( mutex );                                                                
40004658:   40018937            lui s2,0x40018                                            
4000465c:   00912a23            sw  s1,20(sp)                                             
40004660:   00050493            mv  s1,a0                                                 
40004664:   5f490513            addi    a0,s2,1524 # 400185f4 <pipe_mutex>                
40004668:   00812c23            sw  s0,24(sp)                                             
4000466c:   01312623            sw  s3,12(sp)                                             
40004670:   00112e23            sw  ra,28(sp)                                             
40004674:   00058993            mv  s3,a1                                                 
40004678:   220010ef            jal ra,40005898 <_Mutex_Acquire>                          
  pipe = *pipep;                                                                          
4000467c:   0004a403            lw  s0,0(s1)                                              
  if (pipe == NULL) {                                                                     
40004680:   06040463            beqz    s0,400046e8 <fifo_open+0x98>                      
40004684:   02840513            addi    a0,s0,40                                          
40004688:   210010ef            jal ra,40005898 <_Mutex_Acquire>                          
  _Mutex_Release( mutex );                                                                
4000468c:   5f490513            addi    a0,s2,1524                                        
  *pipep = pipe;                                                                          
40004690:   0084a023            sw  s0,0(s1)                                              
40004694:   274010ef            jal ra,40005908 <_Mutex_Release>                          
40004698:   0009a783            lw  a5,0(s3)                                              
  int err;                                                                                
                                                                                          
  err = pipe_new(pipep);                                                                  
  if (err)                                                                                
    return err;                                                                           
  pipe = *pipep;                                                                          
4000469c:   0004a403            lw  s0,0(s1)                                              
                                                                                          
  switch (LIBIO_ACCMODE(iop)) {                                                           
400046a0:   00400713            li  a4,4                                                  
400046a4:   0067f793            andi    a5,a5,6                                           
                                                                                          
        prevCounter = pipe->writerCounter;                                                
        err = -EINTR;                                                                     
        /* Wait until a writer opens the pipe */                                          
        do {                                                                              
          PIPE_READWAIT(pipe);                                                            
400046a8:   02840913            addi    s2,s0,40                                          
  switch (LIBIO_ACCMODE(iop)) {                                                           
400046ac:   14e78a63            beq a5,a4,40004800 <fifo_open+0x1b0>                      
400046b0:   00600713            li  a4,6                                                  
400046b4:   0ee78e63            beq a5,a4,400047b0 <fifo_open+0x160>                      
400046b8:   00200713            li  a4,2                                                  
400046bc:   0ae78263            beq a5,a4,40004760 <fifo_open+0x110>                      
400046c0:   00090513            mv  a0,s2                                                 
400046c4:   244010ef            jal ra,40005908 <_Mutex_Release>                          
        PIPE_WAKEUPREADERS(pipe);                                                         
      break;                                                                              
  }                                                                                       
                                                                                          
  PIPE_UNLOCK(pipe);                                                                      
  return 0;                                                                               
400046c8:   00000513            li  a0,0                                                  
                                                                                          
out_error:                                                                                
  pipe_release(pipep, iop);                                                               
  return err;                                                                             
}                                                                                         
400046cc:   01c12083            lw  ra,28(sp)                                             
400046d0:   01812403            lw  s0,24(sp)                                             
400046d4:   01412483            lw  s1,20(sp)                                             
400046d8:   01012903            lw  s2,16(sp)                                             
400046dc:   00c12983            lw  s3,12(sp)                                             
400046e0:   02010113            addi    sp,sp,32                                          
400046e4:   00008067            ret                                                       
  pipe = malloc(sizeof(pipe_control_t));                                                  
400046e8:   06400513            li  a0,100                                                
400046ec:   485040ef            jal ra,40009370 <malloc>                                  
400046f0:   00050413            mv  s0,a0                                                 
  if (pipe == NULL)                                                                       
400046f4:   1a050663            beqz    a0,400048a0 <fifo_open+0x250>                     
  memset(pipe, 0, sizeof(pipe_control_t));                                                
400046f8:   05c00613            li  a2,92                                                 
400046fc:   00000593            li  a1,0                                                  
40004700:   00850513            addi    a0,a0,8                                           
40004704:   2550b0ef            jal ra,40010158 <memset>                                  
  pipe->Size = PIPE_BUF;                                                                  
40004708:   20000793            li  a5,512                                                
  pipe->Buffer = malloc(pipe->Size);                                                      
4000470c:   20000513            li  a0,512                                                
  pipe->Size = PIPE_BUF;                                                                  
40004710:   00f42223            sw  a5,4(s0)                                              
  pipe->Buffer = malloc(pipe->Size);                                                      
40004714:   45d040ef            jal ra,40009370 <malloc>                                  
40004718:   00a42023            sw  a0,0(s0)                                              
  if (pipe->Buffer == NULL) {                                                             
4000471c:   16050e63            beqz    a0,40004898 <fifo_open+0x248>                     <== NEVER TAKEN
_Condition_Initialize_named(struct _Condition_Control *_cond,                             
    const char *_name)                                                                    
{                                                                                         
    struct _Condition_Control _init = _CONDITION_NAMED_INITIALIZER(_name);                
                                                                                          
    *_cond = _init;                                                                       
40004720:   40017737            lui a4,0x40017                                            
40004724:   a5870713            addi    a4,a4,-1448 # 40016a58 <IMFS_node_control_sym_link+0x10>
40004728:   04e42623            sw  a4,76(s0)                                             
4000472c:   40017737            lui a4,0x40017                                            
40004730:   a6470713            addi    a4,a4,-1436 # 40016a64 <IMFS_node_control_sym_link+0x1c>
  if (c ++ == 'z')                                                                        
40004734:   8ec18793            addi    a5,gp,-1812 # 40018b14 <c.0>                      
40004738:   06e42023            sw  a4,96(s0)                                             
4000473c:   0007c683            lbu a3,0(a5)                                              
    *_mutex = _init;                                                                      
40004740:   40017737            lui a4,0x40017                                            
40004744:   a7070713            addi    a4,a4,-1424 # 40016a70 <IMFS_node_control_sym_link+0x28>
40004748:   02e42c23            sw  a4,56(s0)                                             
4000474c:   07a00713            li  a4,122                                                
40004750:   0ae68263            beq a3,a4,400047f4 <fifo_open+0x1a4>                      
40004754:   00168693            addi    a3,a3,1 # 4001 <bsp_section_rodata_size+0x1bed>   
40004758:   00d78023            sb  a3,0(a5)                                              
4000475c:   f29ff06f            j   40004684 <fifo_open+0x34>                             
      pipe->readerCounter ++;                                                             
40004760:   02042783            lw  a5,32(s0)                                             
      if (pipe->Readers ++ == 0)                                                          
40004764:   01042703            lw  a4,16(s0)                                             
      pipe->readerCounter ++;                                                             
40004768:   00178793            addi    a5,a5,1                                           
      if (pipe->Readers ++ == 0)                                                          
4000476c:   00170693            addi    a3,a4,1                                           
      pipe->readerCounter ++;                                                             
40004770:   02f42023            sw  a5,32(s0)                                             
      if (pipe->Readers ++ == 0)                                                          
40004774:   00d42823            sw  a3,16(s0)                                             
40004778:   0e070663            beqz    a4,40004864 <fifo_open+0x214>                     <== ALWAYS TAKEN
      if (pipe->Writers == 0) {                                                           
4000477c:   01442783            lw  a5,20(s0)                                             
40004780:   f40790e3            bnez    a5,400046c0 <fifo_open+0x70>                      
40004784:   0009a783            lw  a5,0(s3)                                              
        if (LIBIO_NODELAY(iop))                                                           
40004788:   0017f793            andi    a5,a5,1                                           
4000478c:   f2079ae3            bnez    a5,400046c0 <fifo_open+0x70>                      
        prevCounter = pipe->writerCounter;                                                
40004790:   02442983            lw  s3,36(s0)                                             
          PIPE_READWAIT(pipe);                                                            
40004794:   03c40493            addi    s1,s0,60                                          
  _Condition_Wait( condition_variable, mutex );                                           
40004798:   00090593            mv  a1,s2                                                 
4000479c:   00048513            mv  a0,s1                                                 
400047a0:   029000ef            jal ra,40004fc8 <_Condition_Wait>                         
        } while (prevCounter == pipe->writerCounter);                                     
400047a4:   02442783            lw  a5,36(s0)                                             
400047a8:   ff3788e3            beq a5,s3,40004798 <fifo_open+0x148>                      
400047ac:   f15ff06f            j   400046c0 <fifo_open+0x70>                             
      pipe->readerCounter ++;                                                             
400047b0:   02042783            lw  a5,32(s0)                                             
      if (pipe->Readers ++ == 0)                                                          
400047b4:   01042703            lw  a4,16(s0)                                             
      pipe->readerCounter ++;                                                             
400047b8:   00178793            addi    a5,a5,1                                           
      if (pipe->Readers ++ == 0)                                                          
400047bc:   00170693            addi    a3,a4,1                                           
      pipe->readerCounter ++;                                                             
400047c0:   02f42023            sw  a5,32(s0)                                             
      if (pipe->Readers ++ == 0)                                                          
400047c4:   00d42823            sw  a3,16(s0)                                             
400047c8:   08070863            beqz    a4,40004858 <fifo_open+0x208>                     <== ALWAYS TAKEN
      pipe->writerCounter ++;                                                             
400047cc:   02442783            lw  a5,36(s0)                                             
      if (pipe->Writers ++ == 0)                                                          
400047d0:   01442703            lw  a4,20(s0)                                             
      pipe->writerCounter ++;                                                             
400047d4:   00178793            addi    a5,a5,1                                           
      if (pipe->Writers ++ == 0)                                                          
400047d8:   00170693            addi    a3,a4,1                                           
      pipe->writerCounter ++;                                                             
400047dc:   02f42223            sw  a5,36(s0)                                             
      if (pipe->Writers ++ == 0)                                                          
400047e0:   00d42a23            sw  a3,20(s0)                                             
400047e4:   ec071ee3            bnez    a4,400046c0 <fifo_open+0x70>                      <== NEVER TAKEN
  _Condition_Broadcast( condition_variable );                                             
400047e8:   03c40513            addi    a0,s0,60                                          
400047ec:   045000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
400047f0:   ed1ff06f            j   400046c0 <fifo_open+0x70>                             
    c = 'a';                                                                              
400047f4:   06100713            li  a4,97                                                 
400047f8:   00e78023            sb  a4,0(a5)                                              
    if (err) {                                                                            
400047fc:   e89ff06f            j   40004684 <fifo_open+0x34>                             
      pipe->writerCounter ++;                                                             
40004800:   02442783            lw  a5,36(s0)                                             
      if (pipe->Writers ++ == 0)                                                          
40004804:   01442703            lw  a4,20(s0)                                             
      pipe->writerCounter ++;                                                             
40004808:   00178793            addi    a5,a5,1                                           
      if (pipe->Writers ++ == 0)                                                          
4000480c:   00170693            addi    a3,a4,1                                           
      pipe->writerCounter ++;                                                             
40004810:   02f42223            sw  a5,36(s0)                                             
      if (pipe->Writers ++ == 0)                                                          
40004814:   00d42a23            sw  a3,20(s0)                                             
40004818:   04070c63            beqz    a4,40004870 <fifo_open+0x220>                     <== ALWAYS TAKEN
      if (pipe->Readers == 0 && LIBIO_NODELAY(iop)) {                                     
4000481c:   01042783            lw  a5,16(s0)                                             
40004820:   ea0790e3            bnez    a5,400046c0 <fifo_open+0x70>                      
40004824:   0009a783            lw  a5,0(s3)                                              
40004828:   0017f793            andi    a5,a5,1                                           
4000482c:   04079863            bnez    a5,4000487c <fifo_open+0x22c>                     
      if (pipe->Readers == 0) {                                                           
40004830:   01042783            lw  a5,16(s0)                                             
40004834:   e80796e3            bnez    a5,400046c0 <fifo_open+0x70>                      <== NEVER TAKEN
        prevCounter = pipe->readerCounter;                                                
40004838:   02042983            lw  s3,32(s0)                                             
        PIPE_WAKEUPWRITERS(pipe);                                                         
4000483c:   05040493            addi    s1,s0,80                                          
  _Condition_Wait( condition_variable, mutex );                                           
40004840:   00090593            mv  a1,s2                                                 
40004844:   00048513            mv  a0,s1                                                 
40004848:   780000ef            jal ra,40004fc8 <_Condition_Wait>                         
        } while (prevCounter == pipe->readerCounter);                                     
4000484c:   02042783            lw  a5,32(s0)                                             
40004850:   ff3788e3            beq a5,s3,40004840 <fifo_open+0x1f0>                      
40004854:   e6dff06f            j   400046c0 <fifo_open+0x70>                             
  _Condition_Broadcast( condition_variable );                                             
40004858:   05040513            addi    a0,s0,80                                          
4000485c:   7d4000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004860:   f6dff06f            j   400047cc <fifo_open+0x17c>                            
  _Condition_Broadcast( condition_variable );                                             
40004864:   05040513            addi    a0,s0,80                                          
40004868:   7c8000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
4000486c:   f11ff06f            j   4000477c <fifo_open+0x12c>                            
  _Condition_Broadcast( condition_variable );                                             
40004870:   03c40513            addi    a0,s0,60                                          
40004874:   7bc000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004878:   fa5ff06f            j   4000481c <fifo_open+0x1cc>                            
  _Mutex_Release( mutex );                                                                
4000487c:   00090513            mv  a0,s2                                                 
40004880:   088010ef            jal ra,40005908 <_Mutex_Release>                          
  pipe_release(pipep, iop);                                                               
40004884:   00048513            mv  a0,s1                                                 
40004888:   00098593            mv  a1,s3                                                 
4000488c:   cd1ff0ef            jal ra,4000455c <pipe_release>                            
  return err;                                                                             
40004890:   ffa00513            li  a0,-6                                                 
40004894:   e39ff06f            j   400046cc <fifo_open+0x7c>                             
    free(pipe);                                                                           
40004898:   00040513            mv  a0,s0                                                 <== NOT EXECUTED
4000489c:   6e0040ef            jal ra,40008f7c <free>                                    <== NOT EXECUTED
400048a0:   5f490513            addi    a0,s2,1524                                        
400048a4:   064010ef            jal ra,40005908 <_Mutex_Release>                          
    return -ENOMEM;                                                                       
400048a8:   ff400513            li  a0,-12                                                
400048ac:   e21ff06f            j   400046cc <fifo_open+0x7c>                             
                                                                                          

400047dc <pipe>: static uint16_t rtems_pipe_no = 0; int pipe( int filsdes[2] ) {
400047dc:   fe010113            addi    sp,sp,-32                                         
400047e0:   00112e23            sw  ra,28(sp)                                             
400047e4:   00812c23            sw  s0,24(sp)                                             
400047e8:   00912a23            sw  s1,20(sp)                                             
  rtems_libio_t *iop;                                                                     
  int err = 0;                                                                            
                                                                                          
  if (filsdes == NULL)                                                                    
400047ec:   16050063            beqz    a0,4000494c <pipe+0x170>                          
    rtems_set_errno_and_return_minus_one( EFAULT );                                       
                                                                                          
  if (rtems_mkdir("/tmp", S_IRWXU | S_IRWXG | S_IRWXO) != 0)                              
400047f0:   00050493            mv  s1,a0                                                 
400047f4:   40016537            lui a0,0x40016                                            
400047f8:   1ff00593            li  a1,511                                                
400047fc:   2f050513            addi    a0,a0,752 # 400162f0 <IMFS_node_control_sym_link+0x38>
40004800:   235040ef            jal ra,40009234 <rtems_mkdir>                             
40004804:   14051063            bnez    a0,40004944 <pipe+0x168>                          
    return -1;                                                                            
                                                                                          
  /* /tmp/.fifoXXXX */                                                                    
  char fifopath[15];                                                                      
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
40004808:   706d7737            lui a4,0x706d7                                            
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
4000480c:   91c18793            addi    a5,gp,-1764 # 40018324 <rtems_pipe_no>            
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
40004810:   42f70713            addi    a4,a4,1071 # 706d742f <RamEnd+0x2f6d742f>         
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
40004814:   0007d603            lhu a2,0(a5)                                              
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
40004818:   00e12023            sw  a4,0(sp)                                              
4000481c:   69663737            lui a4,0x69663                                            
40004820:   e2f70713            addi    a4,a4,-465 # 69662e2f <RamEnd+0x28662e2f>         
40004824:   00e12223            sw  a4,4(sp)                                              
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
40004828:   400165b7            lui a1,0x40016                                            
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
4000482c:   00007737            lui a4,0x7                                                
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
40004830:   00160693            addi    a3,a2,1                                           
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
40004834:   f6670713            addi    a4,a4,-154 # 6f66 <bsp_section_bss_size+0x4b86>   
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
40004838:   2f858593            addi    a1,a1,760 # 400162f8 <IMFS_node_control_sym_link+0x40>
4000483c:   00a10513            addi    a0,sp,10                                          
  memcpy(fifopath, "/tmp/.fifo", 10);                                                     
40004840:   00e11423            sh  a4,8(sp)                                              
  sprintf(fifopath + 10, "%04x", rtems_pipe_no ++);                                       
40004844:   00d79023            sh  a3,0(a5)                                              
40004848:   6b80b0ef            jal ra,4000ff00 <sprintf>                                 
                                                                                          
  /* Try creating FIFO file until find an available file name */                          
  while (mkfifo(fifopath, S_IRUSR|S_IWUSR) != 0) {                                        
4000484c:   18000593            li  a1,384                                                
40004850:   00010513            mv  a0,sp                                                 
40004854:   1c5040ef            jal ra,40009218 <mkfifo>                                  
40004858:   00050413            mv  s0,a0                                                 
4000485c:   06051e63            bnez    a0,400048d8 <pipe+0xfc>                           <== NEVER TAKEN
    return -1;                                                                            
    /* sprintf(fifopath + 10, "%04x", rtems_pipe_no ++); */                               
  }                                                                                       
                                                                                          
  /* Non-blocking open to avoid waiting for writers */                                    
  filsdes[0] = open(fifopath, O_RDONLY | O_NONBLOCK);                                     
40004860:   000045b7            lui a1,0x4                                                
40004864:   00010513            mv  a0,sp                                                 
40004868:   e30fc0ef            jal ra,40000e98 <open>                                    
4000486c:   00a4a023            sw  a0,0(s1)                                              
  if (filsdes[0] < 0) {                                                                   
40004870:   08054463            bltz    a0,400048f8 <pipe+0x11c>                          
  return &rtems_libio_iops[ fd ];                                                         
40004874:   00151793            slli    a5,a0,0x1                                         
40004878:   00a78533            add a0,a5,a0                                              
4000487c:   4001a7b7            lui a5,0x4001a                                            
40004880:   98878793            addi    a5,a5,-1656 # 40019988 <rtems_libio_iops>         
40004884:   00451513            slli    a0,a0,0x4                                         
40004888:   00f50533            add a0,a0,a5                                              
  __asm__ volatile (                                                                      
4000488c:   300477f3            csrrci  a5,mstatus,8                                      
  *obj = val & arg;                                                                       
40004890:   00052703            lw  a4,0(a0)                                              
40004894:   ffe77713            andi    a4,a4,-2                                          
40004898:   00e52023            sw  a4,0(a0)                                              
  return mstatus & RISCV_MSTATUS_MIE;                                                     
4000489c:   0087f793            andi    a5,a5,8                                           
  __asm__ volatile ( "csrrs zero, mstatus, %0" : : "r" ( level ) );                       
400048a0:   3007a073            csrs    mstatus,a5                                        
  else {                                                                                  
  /* Reset open file to blocking mode */                                                  
    iop = rtems_libio_iop(filsdes[0]);                                                    
    rtems_libio_iop_flags_clear( iop, LIBIO_FLAGS_NO_DELAY );                             
                                                                                          
    filsdes[1] = open(fifopath, O_WRONLY);                                                
400048a4:   00100593            li  a1,1                                                  
400048a8:   00010513            mv  a0,sp                                                 
400048ac:   decfc0ef            jal ra,40000e98 <open>                                    
400048b0:   00a4a223            sw  a0,4(s1)                                              
                                                                                          
    if (filsdes[1] < 0) {                                                                 
400048b4:   06054663            bltz    a0,40004920 <pipe+0x144>                          
    err = errno;                                                                          
    close(filsdes[0]);                                                                    
    }                                                                                     
  unlink(fifopath);                                                                       
400048b8:   00010513            mv  a0,sp                                                 
400048bc:   f48fd0ef            jal ra,40002004 <unlink>                                  
  }                                                                                       
  if(err != 0)                                                                            
    rtems_set_errno_and_return_minus_one(err);                                            
  return 0;                                                                               
}                                                                                         
400048c0:   01c12083            lw  ra,28(sp)                                             
400048c4:   00040513            mv  a0,s0                                                 
400048c8:   01812403            lw  s0,24(sp)                                             
400048cc:   01412483            lw  s1,20(sp)                                             
400048d0:   02010113            addi    sp,sp,32                                          
400048d4:   00008067            ret                                                       
    if (errno != EEXIST){                                                                 
400048d8:   16c0b0ef            jal ra,4000fa44 <__errno>                                 <== NOT EXECUTED
    return -1;                                                                            
400048dc:   fff00413            li  s0,-1                                                 <== NOT EXECUTED
}                                                                                         
400048e0:   01c12083            lw  ra,28(sp)                                             <== NOT EXECUTED
400048e4:   00040513            mv  a0,s0                                                 <== NOT EXECUTED
400048e8:   01812403            lw  s0,24(sp)                                             <== NOT EXECUTED
400048ec:   01412483            lw  s1,20(sp)                                             <== NOT EXECUTED
400048f0:   02010113            addi    sp,sp,32                                          <== NOT EXECUTED
400048f4:   00008067            ret                                                       <== NOT EXECUTED
    err = errno;                                                                          
400048f8:   14c0b0ef            jal ra,4000fa44 <__errno>                                 
400048fc:   00050793            mv  a5,a0                                                 
40004900:   0007a403            lw  s0,0(a5)                                              
    unlink(fifopath);                                                                     
40004904:   00010513            mv  a0,sp                                                 
40004908:   efcfd0ef            jal ra,40002004 <unlink>                                  
  if(err != 0)                                                                            
4000490c:   fa040ae3            beqz    s0,400048c0 <pipe+0xe4>                           <== NEVER TAKEN
    rtems_set_errno_and_return_minus_one(err);                                            
40004910:   1340b0ef            jal ra,4000fa44 <__errno>                                 
40004914:   00852023            sw  s0,0(a0)                                              
40004918:   fff00413            li  s0,-1                                                 
4000491c:   fa5ff06f            j   400048c0 <pipe+0xe4>                                  
    err = errno;                                                                          
40004920:   1240b0ef            jal ra,4000fa44 <__errno>                                 
40004924:   00050793            mv  a5,a0                                                 
    close(filsdes[0]);                                                                    
40004928:   0004a503            lw  a0,0(s1)                                              
    err = errno;                                                                          
4000492c:   0007a403            lw  s0,0(a5)                                              
    close(filsdes[0]);                                                                    
40004930:   b99fb0ef            jal ra,400004c8 <close>                                   
  unlink(fifopath);                                                                       
40004934:   00010513            mv  a0,sp                                                 
40004938:   eccfd0ef            jal ra,40002004 <unlink>                                  
  if(err != 0)                                                                            
4000493c:   f80402e3            beqz    s0,400048c0 <pipe+0xe4>                           <== NEVER TAKEN
40004940:   fd1ff06f            j   40004910 <pipe+0x134>                                 
    return -1;                                                                            
40004944:   fff00413            li  s0,-1                                                 
40004948:   f79ff06f            j   400048c0 <pipe+0xe4>                                  
    rtems_set_errno_and_return_minus_one( EFAULT );                                       
4000494c:   0f80b0ef            jal ra,4000fa44 <__errno>                                 
40004950:   00e00793            li  a5,14                                                 
40004954:   00f52023            sw  a5,0(a0)                                              
40004958:   fff00413            li  s0,-1                                                 
4000495c:   f65ff06f            j   400048c0 <pipe+0xe4>                                  
                                                                                          

400048b0 <pipe_read>: pipe_control_t *pipe, void *buffer, size_t count, rtems_libio_t *iop ) {
400048b0:   fe010113            addi    sp,sp,-32                                         
400048b4:   00912a23            sw  s1,20(sp)                                             
  int chunk, chunk1, read = 0, ret = 0;                                                   
                                                                                          
  PIPE_LOCK(pipe);                                                                        
400048b8:   02850493            addi    s1,a0,40                                          
{                                                                                         
400048bc:   00812c23            sw  s0,24(sp)                                             
400048c0:   00050413            mv  s0,a0                                                 
  _Mutex_Acquire( mutex );                                                                
400048c4:   00048513            mv  a0,s1                                                 
400048c8:   01212823            sw  s2,16(sp)                                             
400048cc:   01412423            sw  s4,8(sp)                                              
400048d0:   01512223            sw  s5,4(sp)                                              
400048d4:   00112e23            sw  ra,28(sp)                                             
400048d8:   00060a93            mv  s5,a2                                                 
400048dc:   01312623            sw  s3,12(sp)                                             
400048e0:   00058a13            mv  s4,a1                                                 
400048e4:   00068913            mv  s2,a3                                                 
400048e8:   7b1000ef            jal ra,40005898 <_Mutex_Acquire>                          
                                                                                          
  while (PIPE_EMPTY(pipe)) {                                                              
400048ec:   00c42603            lw  a2,12(s0)                                             
400048f0:   08061063            bnez    a2,40004970 <pipe_read+0xc0>                      
      goto out_locked;                                                                    
    }                                                                                     
                                                                                          
    /* Wait until pipe is no more empty or no writer exists */                            
    pipe->waitingReaders ++;                                                              
    PIPE_READWAIT(pipe);                                                                  
400048f4:   03c40993            addi    s3,s0,60                                          
400048f8:   03c0006f            j   40004934 <pipe_read+0x84>                             
400048fc:   00092783            lw  a5,0(s2)                                              
    if (LIBIO_NODELAY(iop)) {                                                             
40004900:   0017f793            andi    a5,a5,1                                           
  _Condition_Wait( condition_variable, mutex );                                           
40004904:   00048593            mv  a1,s1                                                 
40004908:   00098513            mv  a0,s3                                                 
4000490c:   0c079c63            bnez    a5,400049e4 <pipe_read+0x134>                     
    pipe->waitingReaders ++;                                                              
40004910:   01842783            lw  a5,24(s0)                                             
40004914:   00178793            addi    a5,a5,1                                           
40004918:   00f42c23            sw  a5,24(s0)                                             
4000491c:   6ac000ef            jal ra,40004fc8 <_Condition_Wait>                         
    pipe->waitingReaders --;                                                              
40004920:   01842783            lw  a5,24(s0)                                             
  while (PIPE_EMPTY(pipe)) {                                                              
40004924:   00c42603            lw  a2,12(s0)                                             
    pipe->waitingReaders --;                                                              
40004928:   fff78793            addi    a5,a5,-1                                          
4000492c:   00f42c23            sw  a5,24(s0)                                             
  while (PIPE_EMPTY(pipe)) {                                                              
40004930:   04061063            bnez    a2,40004970 <pipe_read+0xc0>                      <== ALWAYS TAKEN
    if (pipe->Writers == 0)                                                               
40004934:   01442783            lw  a5,20(s0)                                             
40004938:   fc0792e3            bnez    a5,400048fc <pipe_read+0x4c>                      
  int chunk, chunk1, read = 0, ret = 0;                                                   
4000493c:   00000913            li  s2,0                                                  
  _Mutex_Release( mutex );                                                                
40004940:   00048513            mv  a0,s1                                                 
40004944:   7c5000ef            jal ra,40005908 <_Mutex_Release>                          
  PIPE_UNLOCK(pipe);                                                                      
                                                                                          
  if (read > 0)                                                                           
    return read;                                                                          
  return ret;                                                                             
}                                                                                         
40004948:   01c12083            lw  ra,28(sp)                                             
4000494c:   01812403            lw  s0,24(sp)                                             
40004950:   01412483            lw  s1,20(sp)                                             
40004954:   00c12983            lw  s3,12(sp)                                             
40004958:   00812a03            lw  s4,8(sp)                                              
4000495c:   00412a83            lw  s5,4(sp)                                              
40004960:   00090513            mv  a0,s2                                                 
40004964:   01012903            lw  s2,16(sp)                                             
40004968:   02010113            addi    sp,sp,32                                          
4000496c:   00008067            ret                                                       
  chunk = MIN(count - read,  pipe->Length);                                               
40004970:   00060913            mv  s2,a2                                                 
40004974:   08caec63            bltu    s5,a2,40004a0c <pipe_read+0x15c>                  
  chunk1 = pipe->Size - pipe->Start;                                                      
40004978:   00842783            lw  a5,8(s0)                                              
4000497c:   00442983            lw  s3,4(s0)                                              
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1);                            
40004980:   00042583            lw  a1,0(s0)                                              
  chunk1 = pipe->Size - pipe->Start;                                                      
40004984:   40f989b3            sub s3,s3,a5                                              
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1);                            
40004988:   00f585b3            add a1,a1,a5                                              
  if (chunk > chunk1) {                                                                   
4000498c:   0729c063            blt s3,s2,400049ec <pipe_read+0x13c>                      
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk);                             
40004990:   00090613            mv  a2,s2                                                 
40004994:   000a0513            mv  a0,s4                                                 
40004998:   6980b0ef            jal ra,40010030 <memcpy>                                  
  pipe->Start += chunk;                                                                   
4000499c:   00842783            lw  a5,8(s0)                                              
  pipe->Start %= pipe->Size;                                                              
400049a0:   00442683            lw  a3,4(s0)                                              
  pipe->Length -= chunk;                                                                  
400049a4:   00c42703            lw  a4,12(s0)                                             
  pipe->Start += chunk;                                                                   
400049a8:   00f907b3            add a5,s2,a5                                              
  pipe->Start %= pipe->Size;                                                              
400049ac:   02d7f7b3            remu    a5,a5,a3                                          
  pipe->Length -= chunk;                                                                  
400049b0:   41270733            sub a4,a4,s2                                              
400049b4:   00e42623            sw  a4,12(s0)                                             
  pipe->Start %= pipe->Size;                                                              
400049b8:   00f42423            sw  a5,8(s0)                                              
  if (PIPE_EMPTY(pipe))                                                                   
400049bc:   00071463            bnez    a4,400049c4 <pipe_read+0x114>                     
    pipe->Start = 0;                                                                      
400049c0:   00042423            sw  zero,8(s0)                                            
  if (pipe->waitingWriters > 0)                                                           
400049c4:   01c42783            lw  a5,28(s0)                                             
400049c8:   06079263            bnez    a5,40004a2c <pipe_read+0x17c>                     
400049cc:   00048513            mv  a0,s1                                                 
400049d0:   739000ef            jal ra,40005908 <_Mutex_Release>                          
  if (read > 0)                                                                           
400049d4:   fff94613            not a2,s2                                                 
400049d8:   41f65613            srai    a2,a2,0x1f                                        
400049dc:   00c97933            and s2,s2,a2                                              
400049e0:   f69ff06f            j   40004948 <pipe_read+0x98>                             
      ret = -EAGAIN;                                                                      
400049e4:   ff500913            li  s2,-11                                                
400049e8:   f59ff06f            j   40004940 <pipe_read+0x90>                             
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1);                            
400049ec:   00098613            mv  a2,s3                                                 
400049f0:   000a0513            mv  a0,s4                                                 
400049f4:   63c0b0ef            jal ra,40010030 <memcpy>                                  
    memcpy(buffer + read + chunk1, pipe->Buffer, chunk - chunk1);                         
400049f8:   00042583            lw  a1,0(s0)                                              
400049fc:   41390633            sub a2,s2,s3                                              
40004a00:   013a0533            add a0,s4,s3                                              
40004a04:   62c0b0ef            jal ra,40010030 <memcpy>                                  
40004a08:   f95ff06f            j   4000499c <pipe_read+0xec>                             
  chunk1 = pipe->Size - pipe->Start;                                                      
40004a0c:   00842783            lw  a5,8(s0)                                              
40004a10:   00442983            lw  s3,4(s0)                                              
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1);                            
40004a14:   00042583            lw  a1,0(s0)                                              
  chunk = MIN(count - read,  pipe->Length);                                               
40004a18:   000a8913            mv  s2,s5                                                 
  chunk1 = pipe->Size - pipe->Start;                                                      
40004a1c:   40f989b3            sub s3,s3,a5                                              
    memcpy(buffer + read, pipe->Buffer + pipe->Start, chunk1);                            
40004a20:   00f585b3            add a1,a1,a5                                              
  if (chunk > chunk1) {                                                                   
40004a24:   f729d6e3            bge s3,s2,40004990 <pipe_read+0xe0>                       
40004a28:   fc5ff06f            j   400049ec <pipe_read+0x13c>                            <== NOT EXECUTED
  _Condition_Broadcast( condition_variable );                                             
40004a2c:   05040513            addi    a0,s0,80                                          
40004a30:   600000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004a34:   f99ff06f            j   400049cc <pipe_read+0x11c>                            
                                                                                          

4000455c <pipe_release>: void pipe_release( pipe_control_t **pipep, rtems_libio_t *iop ) {
4000455c:   fe010113            addi    sp,sp,-32                                         
40004560:   00812c23            sw  s0,24(sp)                                             
  pipe_control_t *pipe = *pipep;                                                          
40004564:   00052403            lw  s0,0(a0)                                              
{                                                                                         
40004568:   01312623            sw  s3,12(sp)                                             
  mutex->_Queue._name = name;                                                             
}                                                                                         
                                                                                          
static __inline void rtems_mutex_lock( rtems_mutex *mutex )                               
{                                                                                         
  _Mutex_Acquire( mutex );                                                                
4000456c:   400189b7            lui s3,0x40018                                            
40004570:   00912a23            sw  s1,20(sp)                                             
40004574:   00050493            mv  s1,a0                                                 
40004578:   5f498513            addi    a0,s3,1524 # 400185f4 <pipe_mutex>                
4000457c:   00112e23            sw  ra,28(sp)                                             
40004580:   01212823            sw  s2,16(sp)                                             
40004584:   01412423            sw  s4,8(sp)                                              
40004588:   00058913            mv  s2,a1                                                 
  uint32_t mode;                                                                          
                                                                                          
  pipe_lock();                                                                            
  PIPE_LOCK(pipe);                                                                        
4000458c:   02840a13            addi    s4,s0,40                                          
40004590:   308010ef            jal ra,40005898 <_Mutex_Acquire>                          
40004594:   000a0513            mv  a0,s4                                                 
40004598:   300010ef            jal ra,40005898 <_Mutex_Acquire>                          
4000459c:   00092783            lw  a5,0(s2)                                              
                                                                                          
  mode = LIBIO_ACCMODE(iop);                                                              
  if (mode & LIBIO_FLAGS_READ)                                                            
400045a0:   0027f713            andi    a4,a5,2                                           
  mode = LIBIO_ACCMODE(iop);                                                              
400045a4:   0067f913            andi    s2,a5,6                                           
  if (mode & LIBIO_FLAGS_READ)                                                            
400045a8:   00070863            beqz    a4,400045b8 <pipe_release+0x5c>                   
     pipe->Readers --;                                                                    
400045ac:   01042703            lw  a4,16(s0)                                             
400045b0:   fff70713            addi    a4,a4,-1                                          
400045b4:   00e42823            sw  a4,16(s0)                                             
  if (mode & LIBIO_FLAGS_WRITE)                                                           
400045b8:   0047f793            andi    a5,a5,4                                           
400045bc:   00078863            beqz    a5,400045cc <pipe_release+0x70>                   
     pipe->Writers --;                                                                    
400045c0:   01442783            lw  a5,20(s0)                                             
400045c4:   fff78793            addi    a5,a5,-1 # efff <bsp_section_rodata_size+0xcbeb>  
400045c8:   00f42a23            sw  a5,20(s0)                                             
}                                                                                         
                                                                                          
static __inline void rtems_mutex_unlock( rtems_mutex *mutex )                             
{                                                                                         
  _Mutex_Release( mutex );                                                                
400045cc:   000a0513            mv  a0,s4                                                 
400045d0:   338010ef            jal ra,40005908 <_Mutex_Release>                          
                                                                                          
  PIPE_UNLOCK(pipe);                                                                      
                                                                                          
  if (pipe->Readers == 0 && pipe->Writers == 0) {                                         
400045d4:   01042783            lw  a5,16(s0)                                             
400045d8:   02078c63            beqz    a5,40004610 <pipe_release+0xb4>                   
    *pipep = NULL;                                                                        
  }                                                                                       
  else if (pipe->Readers == 0 && mode != LIBIO_FLAGS_WRITE)                               
    /* Notify waiting Writers that all their partners left */                             
    PIPE_WAKEUPWRITERS(pipe);                                                             
  else if (pipe->Writers == 0 && mode != LIBIO_FLAGS_READ)                                
400045dc:   01442783            lw  a5,20(s0)                                             
400045e0:   00079663            bnez    a5,400045ec <pipe_release+0x90>                   <== NEVER TAKEN
400045e4:   00200793            li  a5,2                                                  
400045e8:   04f91263            bne s2,a5,4000462c <pipe_release+0xd0>                    
  rtems_libio_iop_flags_clear( iop, LIBIO_FLAGS_OPEN );                                   
  if(iop->pathinfo.ops->unlink_h(&iop->pathinfo))                                         
    return;                                                                               
#endif                                                                                    
                                                                                          
}                                                                                         
400045ec:   01812403            lw  s0,24(sp)                                             
400045f0:   01c12083            lw  ra,28(sp)                                             
400045f4:   01412483            lw  s1,20(sp)                                             
400045f8:   01012903            lw  s2,16(sp)                                             
400045fc:   00812a03            lw  s4,8(sp)                                              
40004600:   5f498513            addi    a0,s3,1524                                        
40004604:   00c12983            lw  s3,12(sp)                                             
40004608:   02010113            addi    sp,sp,32                                          
4000460c:   2fc0106f            j   40005908 <_Mutex_Release>                             
  if (pipe->Readers == 0 && pipe->Writers == 0) {                                         
40004610:   01442783            lw  a5,20(s0)                                             
40004614:   02078263            beqz    a5,40004638 <pipe_release+0xdc>                   
  else if (pipe->Readers == 0 && mode != LIBIO_FLAGS_WRITE)                               
40004618:   00400793            li  a5,4                                                  
4000461c:   fcf908e3            beq s2,a5,400045ec <pipe_release+0x90>                    
                                                                                          
static __inline void rtems_condition_variable_broadcast(                                  
  rtems_condition_variable *condition_variable                                            
)                                                                                         
{                                                                                         
  _Condition_Broadcast( condition_variable );                                             
40004620:   05040513            addi    a0,s0,80                                          
40004624:   20d000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004628:   fc5ff06f            j   400045ec <pipe_release+0x90>                          
  _Condition_Broadcast( condition_variable );                                             
4000462c:   03c40513            addi    a0,s0,60                                          
40004630:   201000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004634:   fb9ff06f            j   400045ec <pipe_release+0x90>                          
  free(pipe->Buffer);                                                                     
40004638:   00042503            lw  a0,0(s0)                                              
4000463c:   141040ef            jal ra,40008f7c <free>                                    
  free(pipe);                                                                             
40004640:   00040513            mv  a0,s0                                                 
40004644:   139040ef            jal ra,40008f7c <free>                                    
    *pipep = NULL;                                                                        
40004648:   0004a023            sw  zero,0(s1)                                            
4000464c:   fa1ff06f            j   400045ec <pipe_release+0x90>                          
                                                                                          

40004a38 <pipe_write>: pipe_control_t *pipe, const void *buffer, size_t count, rtems_libio_t *iop ) {
40004a38:   fd010113            addi    sp,sp,-48                                         
40004a3c:   01712623            sw  s7,12(sp)                                             
40004a40:   02112623            sw  ra,44(sp)                                             
40004a44:   02812423            sw  s0,40(sp)                                             
40004a48:   02912223            sw  s1,36(sp)                                             
40004a4c:   03212023            sw  s2,32(sp)                                             
40004a50:   01312e23            sw  s3,28(sp)                                             
40004a54:   01412c23            sw  s4,24(sp)                                             
40004a58:   01512a23            sw  s5,20(sp)                                             
40004a5c:   01612823            sw  s6,16(sp)                                             
40004a60:   01812423            sw  s8,8(sp)                                              
40004a64:   01912223            sw  s9,4(sp)                                              
40004a68:   01a12023            sw  s10,0(sp)                                             
  int chunk, chunk1, written = 0, ret = 0;                                                
                                                                                          
  /* Write nothing */                                                                     
  if (count == 0)                                                                         
    return 0;                                                                             
40004a6c:   00000b93            li  s7,0                                                  
  if (count == 0)                                                                         
40004a70:   04061063            bnez    a2,40004ab0 <pipe_write+0x78>                     <== ALWAYS TAKEN
#endif                                                                                    
                                                                                          
  if (written > 0)                                                                        
    return written;                                                                       
  return ret;                                                                             
}                                                                                         
40004a74:   02c12083            lw  ra,44(sp)                                             
40004a78:   02812403            lw  s0,40(sp)                                             
40004a7c:   02412483            lw  s1,36(sp)                                             
40004a80:   02012903            lw  s2,32(sp)                                             
40004a84:   01c12983            lw  s3,28(sp)                                             
40004a88:   01812a03            lw  s4,24(sp)                                             
40004a8c:   01412a83            lw  s5,20(sp)                                             
40004a90:   01012b03            lw  s6,16(sp)                                             
40004a94:   00812c03            lw  s8,8(sp)                                              
40004a98:   00412c83            lw  s9,4(sp)                                              
40004a9c:   00012d03            lw  s10,0(sp)                                             
40004aa0:   000b8513            mv  a0,s7                                                 
40004aa4:   00c12b83            lw  s7,12(sp)                                             
40004aa8:   03010113            addi    sp,sp,48                                          
40004aac:   00008067            ret                                                       
  PIPE_LOCK(pipe);                                                                        
40004ab0:   02850993            addi    s3,a0,40                                          
40004ab4:   00050413            mv  s0,a0                                                 
  _Mutex_Acquire( mutex );                                                                
40004ab8:   00098513            mv  a0,s3                                                 
40004abc:   00060a13            mv  s4,a2                                                 
40004ac0:   00058b13            mv  s6,a1                                                 
40004ac4:   00068493            mv  s1,a3                                                 
40004ac8:   5d1000ef            jal ra,40005898 <_Mutex_Acquire>                          
  if (pipe->Readers == 0) {                                                               
40004acc:   01042783            lw  a5,16(s0)                                             
40004ad0:   0e078463            beqz    a5,40004bb8 <pipe_write+0x180>                    
  chunk = count <= pipe->Size ? count : 1;                                                
40004ad4:   00442603            lw  a2,4(s0)                                              
40004ad8:   000a0913            mv  s2,s4                                                 
40004adc:   0d466a63            bltu    a2,s4,40004bb0 <pipe_write+0x178>                 
40004ae0:   00000b93            li  s7,0                                                  
  while (written < count) {                                                               
40004ae4:   00000c13            li  s8,0                                                  
      PIPE_WRITEWAIT(pipe);                                                               
40004ae8:   05040a93            addi    s5,s0,80                                          
      PIPE_WAKEUPREADERS(pipe);                                                           
40004aec:   03c40c93            addi    s9,s0,60                                          
40004af0:   0400006f            j   40004b30 <pipe_write+0xf8>                            
40004af4:   0004a783            lw  a5,0(s1)                                              
      if (LIBIO_NODELAY(iop)) {                                                           
40004af8:   0017f793            andi    a5,a5,1                                           
40004afc:   0c079e63            bnez    a5,40004bd8 <pipe_write+0x1a0>                    
      pipe->waitingWriters ++;                                                            
40004b00:   01c42783            lw  a5,28(s0)                                             
  _Condition_Wait( condition_variable, mutex );                                           
40004b04:   00098593            mv  a1,s3                                                 
40004b08:   000a8513            mv  a0,s5                                                 
40004b0c:   00178793            addi    a5,a5,1                                           
40004b10:   00f42e23            sw  a5,28(s0)                                             
40004b14:   4b4000ef            jal ra,40004fc8 <_Condition_Wait>                         
      pipe->waitingWriters --;                                                            
40004b18:   01c42783            lw  a5,28(s0)                                             
      if (pipe->Readers == 0) {                                                           
40004b1c:   01042703            lw  a4,16(s0)                                             
      pipe->waitingWriters --;                                                            
40004b20:   fff78793            addi    a5,a5,-1                                          
40004b24:   00f42e23            sw  a5,28(s0)                                             
      if (pipe->Readers == 0) {                                                           
40004b28:   0c070263            beqz    a4,40004bec <pipe_write+0x1b4>                    <== NEVER TAKEN
    while (PIPE_SPACE(pipe) < chunk) {                                                    
40004b2c:   00442603            lw  a2,4(s0)                                              
40004b30:   00c42783            lw  a5,12(s0)                                             
40004b34:   40f60733            sub a4,a2,a5                                              
40004b38:   fb276ee3            bltu    a4,s2,40004af4 <pipe_write+0xbc>                  
    chunk = MIN(count - written, PIPE_SPACE(pipe));                                       
40004b3c:   418a0d33            sub s10,s4,s8                                             
40004b40:   01a77463            bgeu    a4,s10,40004b48 <pipe_write+0x110>                
40004b44:   00070d13            mv  s10,a4                                                <== NOT EXECUTED
    chunk1 = pipe->Size - PIPE_WSTART(pipe);                                              
40004b48:   00842703            lw  a4,8(s0)                                              
      memcpy(pipe->Buffer + PIPE_WSTART(pipe), buffer + written, chunk1);                 
40004b4c:   00042503            lw  a0,0(s0)                                              
40004b50:   018b05b3            add a1,s6,s8                                              
    chunk1 = pipe->Size - PIPE_WSTART(pipe);                                              
40004b54:   00e787b3            add a5,a5,a4                                              
40004b58:   02c7f7b3            remu    a5,a5,a2                                          
40004b5c:   40f60933            sub s2,a2,a5                                              
      memcpy(pipe->Buffer + PIPE_WSTART(pipe), buffer + written, chunk1);                 
40004b60:   00f50533            add a0,a0,a5                                              
    if (chunk > chunk1) {                                                                 
40004b64:   0ba95463            bge s2,s10,40004c0c <pipe_write+0x1d4>                    
      memcpy(pipe->Buffer + PIPE_WSTART(pipe), buffer + written, chunk1);                 
40004b68:   00090613            mv  a2,s2                                                 
40004b6c:   4c40b0ef            jal ra,40010030 <memcpy>                                  
      memcpy(pipe->Buffer, buffer + written + chunk1, chunk - chunk1);                    
40004b70:   00042503            lw  a0,0(s0)                                              
40004b74:   012c05b3            add a1,s8,s2                                              
40004b78:   412d0633            sub a2,s10,s2                                             
40004b7c:   00bb05b3            add a1,s6,a1                                              
40004b80:   4b00b0ef            jal ra,40010030 <memcpy>                                  
    pipe->Length += chunk;                                                                
40004b84:   00c42783            lw  a5,12(s0)                                             
    if (pipe->waitingReaders > 0)                                                         
40004b88:   01842703            lw  a4,24(s0)                                             
    pipe->Length += chunk;                                                                
40004b8c:   01a787b3            add a5,a5,s10                                             
40004b90:   00f42623            sw  a5,12(s0)                                             
    if (pipe->waitingReaders > 0)                                                         
40004b94:   08071263            bnez    a4,40004c18 <pipe_write+0x1e0>                    
    written += chunk;                                                                     
40004b98:   01ab8bb3            add s7,s7,s10                                             
  while (written < count) {                                                               
40004b9c:   000b8c13            mv  s8,s7                                                 
40004ba0:   094bf263            bgeu    s7,s4,40004c24 <pipe_write+0x1ec>                 
    while (PIPE_SPACE(pipe) < chunk) {                                                    
40004ba4:   00442603            lw  a2,4(s0)                                              <== NOT EXECUTED
    chunk = 1;                                                                            
40004ba8:   00100913            li  s2,1                                                  <== NOT EXECUTED
40004bac:   f85ff06f            j   40004b30 <pipe_write+0xf8>                            <== NOT EXECUTED
  chunk = count <= pipe->Size ? count : 1;                                                
40004bb0:   00100913            li  s2,1                                                  <== NOT EXECUTED
40004bb4:   f2dff06f            j   40004ae0 <pipe_write+0xa8>                            <== NOT EXECUTED
  _Mutex_Release( mutex );                                                                
40004bb8:   00098513            mv  a0,s3                                                 
40004bbc:   54d000ef            jal ra,40005908 <_Mutex_Release>                          
    kill(getpid(), SIGPIPE);                                                              
40004bc0:   61c040ef            jal ra,400091dc <getpid>                                  
40004bc4:   00d00593            li  a1,13                                                 
40004bc8:   291030ef            jal ra,40008658 <kill>                                    
40004bcc:   fe000793            li  a5,-32                                                
40004bd0:   00078b93            mv  s7,a5                                                 
40004bd4:   ea1ff06f            j   40004a74 <pipe_write+0x3c>                            
40004bd8:   00098513            mv  a0,s3                                                 
40004bdc:   52d000ef            jal ra,40005908 <_Mutex_Release>                          
        ret = -EAGAIN;                                                                    
40004be0:   ff500793            li  a5,-11                                                
  if (written > 0)                                                                        
40004be4:   e97048e3            bgtz    s7,40004a74 <pipe_write+0x3c>                     <== NEVER TAKEN
40004be8:   fe9ff06f            j   40004bd0 <pipe_write+0x198>                           
40004bec:   00098513            mv  a0,s3                                                 <== NOT EXECUTED
40004bf0:   519000ef            jal ra,40005908 <_Mutex_Release>                          <== NOT EXECUTED
    kill(getpid(), SIGPIPE);                                                              
40004bf4:   5e8040ef            jal ra,400091dc <getpid>                                  <== NOT EXECUTED
40004bf8:   00d00593            li  a1,13                                                 <== NOT EXECUTED
40004bfc:   25d030ef            jal ra,40008658 <kill>                                    <== NOT EXECUTED
40004c00:   fe000793            li  a5,-32                                                <== NOT EXECUTED
  if (written > 0)                                                                        
40004c04:   e77048e3            bgtz    s7,40004a74 <pipe_write+0x3c>                     <== NOT EXECUTED
40004c08:   fc9ff06f            j   40004bd0 <pipe_write+0x198>                           <== NOT EXECUTED
      memcpy(pipe->Buffer + PIPE_WSTART(pipe), buffer + written, chunk);                  
40004c0c:   000d0613            mv  a2,s10                                                
40004c10:   4200b0ef            jal ra,40010030 <memcpy>                                  
40004c14:   f71ff06f            j   40004b84 <pipe_write+0x14c>                           
  _Condition_Broadcast( condition_variable );                                             
40004c18:   000c8513            mv  a0,s9                                                 
40004c1c:   414000ef            jal ra,40005030 <_Condition_Broadcast>                    
}                                                                                         
40004c20:   f79ff06f            j   40004b98 <pipe_write+0x160>                           
  _Mutex_Release( mutex );                                                                
40004c24:   00098513            mv  a0,s3                                                 
40004c28:   4e1000ef            jal ra,40005908 <_Mutex_Release>                          
40004c2c:   00000793            li  a5,0                                                  
  if (written > 0)                                                                        
40004c30:   e57042e3            bgtz    s7,40004a74 <pipe_write+0x3c>                     <== ALWAYS TAKEN
40004c34:   f9dff06f            j   40004bd0 <pipe_write+0x198>                           <== NOT EXECUTED