| Last change
                  on this file since 595 was
                  444,
                  checked in by satin@…, 7 years ago | 
        
          | 
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
 | 
        | File size:
            1.4 KB | 
      
      
        
  | Rev | Line |  | 
|---|
| [444] | 1 | /* | 
|---|
|  | 2 | * mbx-inbyte.c -- inbyte function for targets using the eppcbug monitor | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * Copyright (c) 1998 Cygnus Support | 
|---|
|  | 5 | * | 
|---|
|  | 6 | * The authors hereby grant permission to use, copy, modify, distribute, | 
|---|
|  | 7 | * and license this software and its documentation for any purpose, provided | 
|---|
|  | 8 | * that existing copyright notices are retained in all copies and that this | 
|---|
|  | 9 | * notice is included verbatim in any distributions. No written agreement, | 
|---|
|  | 10 | * license, or royalty fee is required for any of the authorized uses. | 
|---|
|  | 11 | * Modifications to this software may be copyrighted by their authors | 
|---|
|  | 12 | * and need not follow the licensing terms described here, provided that | 
|---|
|  | 13 | * the new terms are clearly indicated on the first page of each file where | 
|---|
|  | 14 | * they apply. | 
|---|
|  | 15 | */ | 
|---|
|  | 16 |  | 
|---|
|  | 17 | #include "ppc-asm.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 | int inbyte(void) | 
|---|
|  | 20 | { | 
|---|
|  | 21 | struct { | 
|---|
|  | 22 | unsigned clun; | 
|---|
|  | 23 | unsigned dlun; | 
|---|
|  | 24 | char     *data; | 
|---|
|  | 25 | unsigned len; | 
|---|
|  | 26 | unsigned rsrvd; | 
|---|
|  | 27 | char     buf[4]; | 
|---|
|  | 28 | } ipb, *inpb; | 
|---|
|  | 29 |  | 
|---|
|  | 30 | struct { | 
|---|
|  | 31 | int status; | 
|---|
|  | 32 | int cnt; | 
|---|
|  | 33 | } opb, *outpb; | 
|---|
|  | 34 |  | 
|---|
|  | 35 | inpb = &ipb; | 
|---|
|  | 36 | outpb = &opb; | 
|---|
|  | 37 |  | 
|---|
|  | 38 | do { | 
|---|
|  | 39 | inpb->clun = 0; | 
|---|
|  | 40 | inpb->dlun = 0; | 
|---|
|  | 41 | inpb->data = ipb.buf; | 
|---|
|  | 42 | inpb->len  = 1; | 
|---|
|  | 43 | inpb->rsrvd = 0; | 
|---|
|  | 44 |  | 
|---|
|  | 45 | asm volatile ( | 
|---|
|  | 46 | "mr  3,%0\n" | 
|---|
|  | 47 | "mr  4,%1\n" | 
|---|
|  | 48 | "li  10,0x200\n" | 
|---|
|  | 49 | "sc" | 
|---|
|  | 50 | : /* no outputs */ | 
|---|
|  | 51 | : "r" (inpb), "r" (outpb) | 
|---|
|  | 52 | : "3", "4", "10" | 
|---|
|  | 53 | ); | 
|---|
|  | 54 | } while (outpb->status == 0 && outpb->cnt == 0); | 
|---|
|  | 55 |  | 
|---|
|  | 56 | if (outpb->status == 0) | 
|---|
|  | 57 | return ipb.buf[0] & 0xff; | 
|---|
|  | 58 |  | 
|---|
|  | 59 | return -1; | 
|---|
|  | 60 | } | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.