示例#1
0
/* Utility function to perform ascii to ebcdic translation on a string */
void host_to_guest_str(unsigned char *d,char *s)
{
    int i;

    for(i=0;s[i];i++)
    {
        d[i]=host_to_guest(s[i]);
    }
}
示例#2
0
void set_lparname(char *name)
{
    size_t i;

    for(i = 0; name && i < strlen(name) && i < sizeof(lparname); i++)
        if(isprint(name[i]))
            lparname[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
        else
            lparname[i] = 0x40;
    for(; i < sizeof(lparname); i++)
        lparname[i] = 0x40;
}
示例#3
0
/*-------------------------------------------------------------------*/
static void copy_stringz_to_ebcdic(BYTE* fld, size_t len, char *name)
{
    size_t i;

    for(i = 0; name && i < strlen(name) && i < len; i++)
        if(isprint(name[i]))
            fld[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
        else
            fld[i] = 0x40;
    for(; i < len; i++)
        fld[i] = 0x40;
}
示例#4
0
void set_manufacturer(char *name)
{
    size_t i;

    for(i = 0; name && i < strlen(name) && i < sizeof(manufact); i++)
        if(isprint(name[i]))
            manufact[i] = host_to_guest((int)(islower(name[i]) ? toupper(name[i]) : name[i]));
        else
            manufact[i] = 0x40;
    for(; i < sizeof(manufact); i++)
        manufact[i] = 0x40;
}
示例#5
0
static void*
con1052_panel_command (char *cmd)
{
DEVBLK *dev;
char *input;
int  i;

    void* (*next_panel_command_handler)(char *cmd);

    for(dev = sysblk.firstdev; dev; dev = dev->nextdev)
    {
        if(dev->allocated
          && dev->hnd == &con1052_device_hndinfo
          && !strncasecmp(cmd,dev->filename,strlen(dev->filename)) )
        {
            input = cmd + strlen(dev->filename);
            WRCMSG ("<pnl,color(lightyellow,black)>", HHC00008, "I",
                        dev->filename, cmd+strlen(dev->filename) );
            for(i = 0; i < dev->bufsize && input[i] != '\0'; i++)
                dev->buf[i] = isprint(input[i]) ? host_to_guest(input[i]) : SPACE;
            dev->keybdrem = dev->buflen = i;
            obtain_lock(&dev->lock);
            if(dev->iowaiters)
            {
                signal_condition(&dev->iocond);
                release_lock(&dev->lock);
            }
            else
            {
                release_lock(&dev->lock);
                device_attention (dev, CSW_ATTN);
            }
            return NULL;
        }
    }

    next_panel_command_handler = HDL_FINDNXT(con1052_panel_command);

    if (!next_panel_command_handler)
        return NULL;

    return  next_panel_command_handler(cmd);
}
示例#6
0
/*-------------------------------------------------------------------*/
void ARCH_DEP(diag224_call) (int r1, int r2, REGS *regs)
{
RADR              abs;                 /* abs addr of data area      */
BYTE             *p;                   /* pointer to the data area   */
unsigned int      i;                   /* loop index                 */

//FIXME : this is probably incomplete.
//        see linux/arch/s390/hypfs/hypfs_diag.c
    UNREFERENCED(r1);

    abs = APPLY_PREFIXING (regs->GR_L(r2), regs->PX);

    /* Program check if data area is not on a page boundary */
    if ( (abs & PAGEFRAME_BYTEMASK) != 0x000)
        ARCH_DEP(program_interrupt) (regs, PGM_SPECIFICATION_EXCEPTION);

    /* Program check if data area is outside main storage */
    if ( abs > regs->mainlim )
        ARCH_DEP(program_interrupt) (regs, PGM_ADDRESSING_EXCEPTION);

    /* Point to DIAG 224 data area */
    p = regs->mainstor + abs;

    /* Mark page referenced */
    STORAGE_KEY(abs, regs) |= STORKEY_REF | STORKEY_CHANGE;

    /* First byte contains the number of entries - 1 */
    *p = 5;

    /* Clear the next 15 bytes */
    memset (p + 1, 0, 15);

    /* Set the 6 possible entries */
    p += 16;
    memcpy(p,diag224_cputable,sizeof(diag224_cputable)-1);

    /* Convert to EBCDIC */
    for (i = 0; i < sizeof(diag224_cputable); i++)
        p[i] = host_to_guest(p[i]);

} /* end function diag224_call */
示例#7
0
/*-------------------------------------------------------------------*/
static int copy_stringz_to_ebcdic(BYTE* fld, size_t len, char *name)
{
    size_t  i;
    size_t  copylen;
    int     n;
    BYTE    *temp_fld;

    if ( name == NULL || strlen(name) == 0 )
    {
        memset(fld, 0, len);
        return 0;
    }

    temp_fld = (BYTE *)malloc(len+1);
    memset(temp_fld, 0x40, len);
    copylen = MIN(strlen(name), len);

    for ( i = 0, n = 0; i < copylen; i++ )
        if ( isalnum(name[i]) )
        {
            temp_fld[i] = host_to_guest((int)toupper(name[i]));
            n++;
        }
        else
        {
            n = -1;
            break;
        }

    if ( n > 0 )
        memcpy(fld,temp_fld,len);

    free(temp_fld);

    return n;
}
示例#8
0
/*-------------------------------------------------------------------*/
int read_omatext (DEVBLK *dev, OMATAPE_DESC *omadesc,
                        BYTE *buf, BYTE *unitstat,BYTE code)
{
int             rc;                     /* Return code               */
off_t           rcoff;                  /* Return code from lseek()  */
int             num;                    /* Number of characters read */
int             pos;                    /* Position in I/O buffer    */
long            blkpos;                 /* Offset of block in file   */
BYTE            c;                      /* Character work area       */

    /* Initialize current block position */
    blkpos = dev->nxtblkpos;

    /* Seek to new current block position */
    rcoff = lseek (dev->fd, blkpos, SEEK_SET);
    if (rcoff < 0)
    {
        /* Handle seek error condition */
        logmsg (_("HHCTA260E %4.4X: Error seeking to offset "I32_FMTX" "
                "in file %s: %s\n"),
                dev->devnum, blkpos, omadesc->filename, strerror(errno));

        /* Set unit check with equipment check */
        build_senseX(TAPE_BSENSE_LOCATEERR,dev,unitstat,code);
        return -1;
    }

    /* Read data from tape file until end of line */
    for (num = 0, pos = 0; ; )
    {
        rc = read (dev->fd, &c, 1);
        if (rc < 1) break;

        /* Treat X'1A' as end of file */
        if (c == '\x1A')
        {
            rc = 0;
            break;
        }

        /* Count characters read */
        num++;

        /* Ignore carriage return character */
        if (c == '\r') continue;

        /* Exit if newline character */
        if (c == '\n') break;

        /* Ignore characters in excess of I/O buffer length */
        if (pos >= MAX_BLKLEN) continue;

        /* Translate character to EBCDIC and copy to I/O buffer */
        if (buf != NULL)
            buf[pos] = host_to_guest(c);

        /* Count characters copied or skipped */
        pos++;

    } /* end for(num) */

    /* At end of file return zero to indicate tapemark */
    if (rc == 0 && num == 0)
    {
        close (dev->fd);
        dev->fd = -1;
        dev->curfilen++;
        dev->nxtblkpos = 0;
        dev->prvblkpos = -1;
        return 0;
    }

    /* Handle read error condition */
    if (rc < 0)
    {
        logmsg (_("HHCTA261E %4.4X: Error reading data block "
                "at offset "I32_FMTX" in file %s: %s\n"),
                dev->devnum, blkpos, omadesc->filename,
                strerror(errno));

        build_senseX(TAPE_BSENSE_READFAIL,dev,unitstat,code);
        return -1;
    }

    /* Check for block not terminated by newline */
    if (rc < 1)
    {
        logmsg (_("HHCTA262E %4.4X: Unexpected end of file in data block "
                "at offset "I32_FMTX" in file %s\n"),
                dev->devnum, blkpos, omadesc->filename);

        /* Set unit check with data check and partial record */
        build_senseX(TAPE_BSENSE_BLOCKSHORT,dev,unitstat,code);
        return -1;
    }

    /* Check for invalid zero length block */
    if (pos == 0)
    {
        logmsg (_("HHCTA263E %4.4X: Invalid zero length block "
                "at offset "I32_FMTX" in file %s\n"),
                dev->devnum, blkpos, omadesc->filename);

        /* Set unit check with equipment check */
        build_senseX(TAPE_BSENSE_BLOCKSHORT,dev,unitstat,code);
        return -1;
    }

    /* Calculate the offsets of the next and previous blocks */
    dev->nxtblkpos = blkpos + num;
    dev->prvblkpos = blkpos;

    /* Return block length */
    return pos;

} /* end function read_omatext */
示例#9
0
/*-------------------------------------------------------------------*/
static int read_ascii ( DEVBLK *dev, BYTE *unitstat )
{
int     rc;                             /* Return code               */
int     i;                              /* Array subscript           */
BYTE    c = 0;                          /* Input character           */

    /* Prefill the card image with EBCDIC blanks */
    memset (dev->buf, HEX40, CARD_SIZE);

    /* Read up to 80 bytes into device buffer */
    for (i = 0; ; )
    {
        /* Read next byte of card image */
        if (dev->bs)
        {
            BYTE b; rc = read_socket( dev->fd, &b, 1 );
            if (rc <= 0) rc = EOF; else c = b;
        }
        else
        {
            rc = getc(dev->fh);
            c = (BYTE)rc;
        }

        /* Handle end-of-file condition */
        if (rc == EOF || c == '\x1A')
        {
            /* End of record if there is any data in buffer */
            if (i > 0) break;

            /* Return unit exception or intervention required */
            if (dev->rdreof)
            {
                *unitstat = CSW_CE | CSW_DE | CSW_UX;
            }
            else
            {
                dev->sense[0] = SENSE_IR;
                dev->sense[1] = SENSE1_RDR_RAIC; /* Retry when IntReq Cleared */
                *unitstat = CSW_CE | CSW_DE | CSW_UC;
            }

            /* Close the file and clear the file name and flags */
            if (clear_cardrdr(dev) != 0)
            {
                /* Set unit check with equipment check */
                dev->sense[0] = SENSE_EC;
                *unitstat = CSW_CE | CSW_DE | CSW_UC;
                return -1;
            }

            return -2;
        }

        /* Handle read error condition */
        if (rc < 0)
        {
            WRMSG (HHC01200, "E", SSID_TO_LCSS(dev->ssid), dev->devnum,
                   "read_socket() or getc()", strerror(errno));

            /* Set unit check with equipment check */
            dev->sense[0] = SENSE_EC;
            *unitstat = CSW_CE | CSW_DE | CSW_UC;
            return -1;
        }

        /* Ignore carriage return */
        if (c == '\r') continue;

        /* Line-feed indicates end of variable length record */
        if (c == '\n') break;

        /* Expand tabs to spaces */
        if (c == '\t')
        {
            do {i++;} while ((i & 7) && (i < CARD_SIZE));
            continue;
        }

        /* Test for overlength record */
        if (i >= CARD_SIZE)
        {
            /* Ignore excess characters if trunc option specified */
            if (dev->trunc) continue;

            WRMSG (HHC01207, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, dev->filename, CARD_SIZE);

            /* Set unit check with data check */
            dev->sense[0] = SENSE_DC;
            *unitstat = CSW_CE | CSW_DE | CSW_UC;
            return -1;
        }

        /* Convert character to EBCDIC and store in device buffer */
        dev->buf[i++] = host_to_guest(c);

    } /* end for(i) */

    return 0;
} /* end function read_ascii */