#include "unix.h"
#include "extern.h"

kmem_read(minor, rawflag)
int minor;
int rawflag;
{
    unsigned addr;

    addr = 512*udata.u_offset.o_blkno+udata.u_offset.o_offset;

    /* This test should be based on a check of the page tables */
    if (addr < 0x1000)
	return (1);

    if (udata.u_sysio)
	bcopy((char *)addr, udata.u_base, udata.u_count);
    else
	uput((char *)addr, udata.u_base, udata.u_count);

    return(udata.u_count);
}

kmem_write(minor, rawflag)
int minor;
int rawflag;
{
    unsigned addr;

    addr = 512*udata.u_offset.o_blkno+udata.u_offset.o_offset;

    if (addr < 0x1000)
	return (1);

    if (udata.u_sysio)
	bcopy(udata.u_base, (char *)addr, udata.u_count);
    else
	uget(udata.u_base, (char *)addr, udata.u_count);

    return(udata.u_count);
}



null_write(minor, rawflag)
int minor;
int rawflag;
{
    return(udata.u_count);
}



static char lop = 0;

lpr_open()
{
    lop = 1;
    return(0);
}

lpr_close()
{
    if (lop)
    {
	lop  = 0;
        lpout('\f');
        lpout('\f');
    }
    return(0);
}



lpr_write(minor, rawflag)
int minor;
int rawflag;
{
    unsigned n;

    n = udata.u_count;
    while (n--)
	lpout(*udata.u_base++);
    return(udata.u_count);
}


lpout(c)
char c;
{
    while(in(0x84)&02)
	;

    out(c,0x85);
    out(0xfe,0x86);
    out(0xff,0x86);
    out(0xff,0x85);
}


#include "devmt.c"

