Basic VM and other minor improvements.

Not complete, probably not fully debugged or optimized.
This commit is contained in:
Ben Gras
2008-11-19 12:26:10 +00:00
parent c888305e21
commit c078ec0331
273 changed files with 10814 additions and 4305 deletions

View File

@@ -5,8 +5,7 @@ DRIVER = amddev
CC = exec cc
CFLAGS = $(CPROFILE)
LDFLAGS = -i
#LIBS = -lsysutil -lsys -ltimers
LIBS = -lsysutil -lsys
LIBS = -lsys
OBJ = amddev.o

View File

@@ -15,7 +15,7 @@ Driver for the AMD Device Exclusion Vector (DEV)
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/vm.h>
#include <sys/vm_i386.h>
#include <minix/com.h>
#include <minix/const.h>
#include <minix/ipc.h>
@@ -213,17 +213,13 @@ static void write_reg(int function, int index, u32_t value)
static void init_domain(int index)
{
int r;
size_t o, size, memsize;
phys_bytes busaddr;
size= 0x100000 / 8;
table= malloc(size + PAGE_SIZE);
table= alloc_contig(size, AC_ALIGN4K, &busaddr);
if (table == NULL)
panic("AMDDEV","malloc failed", NO_NUM);
o= (unsigned)table & (PAGE_SIZE-1);
if (o)
table += PAGE_SIZE-o;
if (index == 0)
{
memset(table, 0, size);
@@ -237,9 +233,6 @@ static void init_domain(int index)
memset(table, 0x00, size);
}
r= sys_umap(SELF, D, (vir_bytes)table, size, &busaddr);
if (r != OK)
panic("AMDDEV","sys_umap failed", r);
printf("init_domain: busaddr = %p\n", busaddr);
write_reg(DEVF_BASE_HI, index, 0);
@@ -265,6 +258,7 @@ static void init_map(int index)
printf("after write: DEVF_MAP: 0x%x\n", read_reg(DEVF_MAP, index));
}
#if 0
static int do_add(message *m)
{
int r;
@@ -282,19 +276,19 @@ static int do_add(message *m)
size, start, proc);
#endif
if (start % PAGE_SIZE)
if (start % I386_PAGE_SIZE)
{
printf("amddev`do_add: bad start 0x%x from proc %d\n",
start, proc);
return EINVAL;
}
if (size % PAGE_SIZE)
if (size % I386_PAGE_SIZE)
{
printf("amddev`do_add: bad size 0x%x from proc %d\n",
size, proc);
return EINVAL;
}
r= sys_umap(proc, D, (vir_bytes)start, size, &busaddr);
r= sys_umap(proc, VM_D, (vir_bytes)start, size, &busaddr);
if (r != OK)
{
printf("amddev`do_add: umap failed for 0x%x@0x%x, proc %d\n",
@@ -304,6 +298,7 @@ static int do_add(message *m)
add_range(busaddr, size);
}
#endif
static int do_add_phys(message *m)
{
@@ -319,12 +314,12 @@ static int do_add_phys(message *m)
size, start);
#endif
if (start % PAGE_SIZE)
if (start % I386_PAGE_SIZE)
{
printf("amddev`do_add_phys: bad start 0x%x\n", start);
return EINVAL;
}
if (size % PAGE_SIZE)
if (size % I386_PAGE_SIZE)
{
printf("amddev`do_add_phys: bad size 0x%x\n", size);
return EINVAL;
@@ -355,12 +350,12 @@ static int do_del_phys(message *m)
size, start);
#endif
if (start % PAGE_SIZE)
if (start % I386_PAGE_SIZE)
{
printf("amddev`do_del_phys: bad start 0x%x\n", start);
return EINVAL;
}
if (size % PAGE_SIZE)
if (size % I386_PAGE_SIZE)
{
printf("amddev`do_del_phys: bad size 0x%x\n", size);
return EINVAL;
@@ -391,13 +386,13 @@ static int do_add4pci(message *m)
"amddev`do_add4pci: got request for 0x%x@0x%x from %d for pci dev %u.%u.%u\n",
size, start, proc, pci_bus, pci_dev, pci_func);
if (start % PAGE_SIZE)
if (start % I386_PAGE_SIZE)
{
printf("amddev`do_add4pci: bad start 0x%x from proc %d\n",
start, proc);
return EINVAL;
}
if (size % PAGE_SIZE)
if (size % I386_PAGE_SIZE)
{
printf("amddev`do_add4pci: bad size 0x%x from proc %d\n",
size, proc);
@@ -406,7 +401,7 @@ static int do_add4pci(message *m)
printf("amddev`do_add4pci: should check with PCI\n");
r= sys_umap(proc, D, (vir_bytes)start, size, &busaddr);
r= sys_umap(proc, VM_D, (vir_bytes)start, size, &busaddr);
if (r != OK)
{
printf(
@@ -415,7 +410,7 @@ static int do_add4pci(message *m)
return r;
}
r= adddma(proc, busaddr, size);
r= adddma(proc, start, size);
if (r != 0)
{
r= -errno;
@@ -439,9 +434,9 @@ static void add_range(u32_t busaddr, u32_t size)
printf("add_range: mapping 0x%x@0x%x\n", size, busaddr);
#endif
for (o= 0; o<size; o += PAGE_SIZE)
for (o= 0; o<size; o += I386_PAGE_SIZE)
{
bit= (busaddr+o)/PAGE_SIZE;
bit= (busaddr+o)/I386_PAGE_SIZE;
table[bit/8] &= ~(1 << (bit % 8));
}
}
@@ -454,9 +449,9 @@ static void del_range(u32_t busaddr, u32_t size)
printf("del_range: mapping 0x%x@0x%x\n", size, busaddr);
#endif
for (o= 0; o<size; o += PAGE_SIZE)
for (o= 0; o<size; o += I386_PAGE_SIZE)
{
bit= (busaddr+o)/PAGE_SIZE;
bit= (busaddr+o)/I386_PAGE_SIZE;
table[bit/8] |= (1 << (bit % 8));
}
}

View File

@@ -15,7 +15,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i -L../libdriver
LIBS = -lsysutil -lsys -ltimers -ldriver
LIBS = -ldriver -lsys -ltimers
OBJ = at_wini.o

View File

@@ -18,8 +18,10 @@
#include <minix/sysutil.h>
#include <minix/keymap.h>
#include <minix/type.h>
#include <sys/ioc_disk.h>
#include <ibm/pci.h>
#include <sys/mman.h>
#define ATAPI_DEBUG 0 /* To debug ATAPI code. */
@@ -294,7 +296,6 @@ PRIVATE struct wini { /* main drive struct, one entry per drive */
PRIVATE int w_device = -1;
PRIVATE int w_controller = -1;
PRIVATE int w_major = -1;
PRIVATE char w_id_string[40];
PRIVATE int win_tasknr; /* my task number */
PRIVATE int w_command; /* current command in execution */
@@ -309,7 +310,7 @@ PRIVATE struct device *w_dv; /* device's base and size */
#define ATA_DMA_SECTORS 64
#define ATA_DMA_BUF_SIZE (ATA_DMA_SECTORS*SECTOR_SIZE)
PRIVATE char dma_buf[ATA_DMA_BUF_SIZE];
PRIVATE char *dma_buf;
PRIVATE phys_bytes dma_buf_phys;
#define N_PRDTE 1024 /* Should be enough for large requests */
@@ -320,7 +321,10 @@ PRIVATE struct prdte
u16_t prdte_count;
u8_t prdte_reserved;
u8_t prdte_flags;
} prdt[N_PRDTE];
};
#define PRDT_BYTES (sizeof(struct prdte) * N_PRDTE)
PRIVATE struct prdte *prdt;
PRIVATE phys_bytes prdt_phys;
#define PRDTE_FL_EOT 0x80 /* End of table */
@@ -428,6 +432,8 @@ PUBLIC int main(int argc, char *argv[])
/* Install signal handlers. Ask PM to transform signal into message. */
struct sigaction sa;
init_buffer();
sa.sa_handler = SIG_MESS;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
@@ -475,16 +481,34 @@ PRIVATE void init_params()
w_identify_wakeup_ticks = WAKEUP_TICKS;
}
if (disable_dma)
printf("DMA for ATA devices is disabled.\n");
if (disable_dma) {
printf("at_wini%d: DMA for ATA devices is disabled.\n", w_instance);
} else {
/* Ask for anonymous memory for DMA, that is physically contiguous. */
dma_buf = mmap(0, ATA_DMA_BUF_SIZE, PROT_READ|PROT_WRITE,
MAP_PREALLOC | MAP_CONTIG | MAP_ANON, -1, 0);
prdt = mmap(0, PRDT_BYTES,
PROT_READ|PROT_WRITE, MAP_CONTIG | MAP_ANON, -1, 0);
if(dma_buf == MAP_FAILED || prdt == MAP_FAILED) {
disable_dma = 1;
printf("at_wini%d: no dma\n", w_instance);
} else {
s= sys_umap(SELF, VM_D, (vir_bytes)dma_buf,
ATA_DMA_BUF_SIZE, &dma_buf_phys);
if (s != 0)
panic("at_wini", "can't map dma buffer", s);
s= sys_umap(SELF, D, (vir_bytes)dma_buf, sizeof(dma_buf), &dma_buf_phys);
if (s != 0)
panic("at_wini", "can't map dma buffer", s);
s= sys_umap(SELF, D, (vir_bytes)prdt, sizeof(prdt), &prdt_phys);
if (s != 0)
panic("at_wini", "can't map prd table", s);
s= sys_umap(SELF, VM_D, (vir_bytes)prdt,
PRDT_BYTES, &prdt_phys);
if (s != 0)
panic("at_wini", "can't map prd table", s);
#if 0
printf("at_wini%d: physical dma_buf: 0x%lx, "
"prdt tab: 0x%lx\n",
w_instance, dma_buf_phys, prdt_phys);
#endif
}
}
if (w_instance == 0) {
/* Get the number of drives from the BIOS data area */
@@ -524,7 +548,7 @@ PRIVATE void init_params()
0 /* no DMA */, NO_IRQ, 0, 0, drive);
w_next_drive++;
}
}
}
/* Look for controllers on the pci bus. Skip none the first instance,
* skip one and then 2 for every instance, for every next instance.
@@ -779,15 +803,6 @@ message *m_ptr;
wn->state |= IGNORING;
return(ENXIO);
}
#if VERBOSE
printf("%s: AT driver detected ", w_name());
if (wn->state & (SMART|ATAPI)) {
printf("%.40s\n", w_id_string);
} else {
printf("%ux%ux%u\n", wn->pcylinders, wn->pheads, wn->psectors);
}
#endif
}
#if ENABLE_ATAPI
@@ -898,9 +913,6 @@ PRIVATE int w_identify()
/* This is an ATA device. */
wn->state |= SMART;
/* Why are the strings byte swapped??? */
for (i = 0; i < 40; i++) w_id_string[i] = id_byte(27)[i^1];
/* Preferred CHS translation mode. */
wn->pcylinders = id_word(1);
wn->pheads = id_word(3);
@@ -958,7 +970,8 @@ PRIVATE int w_identify()
else if (id_dma && dma_base)
{
w= id_word(ID_MULTIWORD_DMA);
if (w & (ID_MWDMA_2_SUP|ID_MWDMA_1_SUP|ID_MWDMA_0_SUP))
if (w_pci_debug &&
(w & (ID_MWDMA_2_SUP|ID_MWDMA_1_SUP|ID_MWDMA_0_SUP)))
{
printf(
"%s: multiword DMA modes supported:%s%s%s\n",
@@ -967,7 +980,8 @@ PRIVATE int w_identify()
(w & ID_MWDMA_1_SUP) ? " 1" : "",
(w & ID_MWDMA_2_SUP) ? " 2" : "");
}
if (w & (ID_MWDMA_0_SEL|ID_MWDMA_1_SEL|ID_MWDMA_2_SEL))
if (w_pci_debug &&
(w & (ID_MWDMA_0_SEL|ID_MWDMA_1_SEL|ID_MWDMA_2_SEL)))
{
printf(
"%s: multiword DMA mode selected:%s%s%s\n",
@@ -976,7 +990,7 @@ PRIVATE int w_identify()
(w & ID_MWDMA_1_SEL) ? " 1" : "",
(w & ID_MWDMA_2_SEL) ? " 2" : "");
}
if (ultra_dma)
if (w_pci_debug && ultra_dma)
{
w= id_word(ID_ULTRA_DMA);
if (w & (ID_UDMA_0_SUP|ID_UDMA_1_SUP|
@@ -1048,9 +1062,6 @@ PRIVATE int w_identify()
if ((s=sys_insw(wn->base_cmd + REG_DATA, SELF, tmp_buf, 512)) != OK)
panic(w_name(),"Call to sys_insw() failed", s);
/* Why are the strings byte swapped??? */
for (i = 0; i < 40; i++) w_id_string[i] = id_byte(27)[i^1];
size = 0; /* Size set later. */
#endif
} else {
@@ -1114,14 +1125,17 @@ PRIVATE int w_io_test(void)
int r, save_dev;
int save_timeout, save_errors, save_wakeup;
iovec_t iov;
static char *buf;
#ifdef CD_SECTOR_SIZE
static char buf[CD_SECTOR_SIZE];
#define BUFSIZE CD_SECTOR_SIZE
#else
static char buf[SECTOR_SIZE];
#define BUFSIZE SECTOR_SIZE
#endif
STATICINIT(buf, BUFSIZE);
iov.iov_addr = (vir_bytes) buf;
iov.iov_size = sizeof(buf);
iov.iov_size = BUFSIZE;
save_dev = w_device;
/* Reduce timeout values for this test transaction. */
@@ -1321,8 +1335,8 @@ int safe; /* iov contains addresses (0) or grants? */
nbytes = diff64(dv_size, position);
block = div64u(add64(w_dv->dv_base, position), SECTOR_SIZE);
do_dma= wn->dma;
do_write= (opcode == DEV_SCATTER_S);
do_dma= wn->dma;
if (nbytes >= wn->max_count) {
/* The drive can't do more then max_count at once. */
@@ -1475,14 +1489,17 @@ int safe; /* iov contains addresses (0) or grants? */
s=sys_safe_insw(wn->base_cmd + REG_DATA, proc_nr,
(void *) (iov->iov_addr), addr_offset,
SECTOR_SIZE);
if(s != OK) {
panic(w_name(),"Call to sys_safe_insw() failed", s);
}
} else {
s=sys_insw(wn->base_cmd + REG_DATA, proc_nr,
(void *) (iov->iov_addr + addr_offset),
SECTOR_SIZE);
}
if(s != OK) {
panic(w_name(),"Call to sys_insw() failed", s);
}
}
} else {
if(safe) {
s=sys_safe_outsw(wn->base_cmd + REG_DATA, proc_nr,
@@ -1662,14 +1679,14 @@ int safe;
offset= 0; /* Offset in current iov */
#if 0
printf("setup_dma: proc_nr %d\n", proc_nr);
printf("at_wini: setup_dma: proc_nr %d\n", proc_nr);
#endif
while (size > 0)
{
#if 0
printf(
"setup_dma: iov[%d]: addr 0x%x, size %d offset %d, size %d\n",
"at_wini: setup_dma: iov[%d]: addr 0x%x, size %d offset %d, size %d\n",
i, iov[i].iov_addr, iov[i].iov_size, offset, size);
#endif
@@ -1679,13 +1696,15 @@ int safe;
if (n == 0 || (n & 1))
panic("at_wini", "bad size in iov", iov[i].iov_size);
if(safe) {
r= sys_umap(proc_nr, GRANT_SEG, iov[i].iov_addr, n,&user_phys);
r= sys_umap(proc_nr, VM_GRANT, iov[i].iov_addr, n,&user_phys);
if (r != 0)
panic("at_wini", "can't map user buffer (VM_GRANT)", r);
user_phys += offset;
} else {
r= sys_umap(proc_nr, D, iov[i].iov_addr+offset, n, &user_phys);
}
r= sys_umap(proc_nr, VM_D, iov[i].iov_addr+offset, n, &user_phys);
if (r != 0)
panic("at_wini", "can't map user buffer", r);
panic("at_wini", "can't map user buffer (VM_D)", r);
}
if (user_phys & 1)
{
/* Buffer is not aligned */
@@ -2709,7 +2728,7 @@ PRIVATE int at_in(int line, u32_t port, u32_t *value,
return OK;
printf("at_wini%d: line %d: %s failed: %d; port %x\n",
w_instance, line, typename, s, value, port);
panic(w_name(), "sys_out failed", NO_NUM);
panic(w_name(), "sys_in failed", NO_NUM);
}
#undef panic

View File

@@ -12,7 +12,7 @@ gen_drv_dir = ../../gen_drivers/cyclic_dma
CC = exec cc
CFLAGS = -I$i
LDFLAGS = -i
LIBS = -lsys -lsysutil
LIBS = -lsys
# build local binary
all: es1370

View File

@@ -11,7 +11,7 @@ b = $i/ibm
CC = exec cc
CFLAGS = -I$i
LDFLAGS = -i
LIBS = -lsys -lsysutil
LIBS = -lsys
PROGRAM_NAME = es1371
INSTALL_BIN = /usr/sbin/$(PROGRAM_NAME)

View File

@@ -45,6 +45,7 @@
#include "audio_fw.h"
#include <sys/vm.h>
#include <minix/ds.h>
#include <sys/vm_i386.h>
FORWARD _PROTOTYPE( int msg_open, (int minor_dev_nr) );
@@ -85,7 +86,6 @@ PUBLIC void main(void)
/* Here is the main loop of the dma driver. It waits for a message,
carries it out, and sends a reply. */
printf("%s up and running\n", drv.DriverName);
while(1) {
receive(ANY, &mess);
@@ -886,19 +886,16 @@ PRIVATE int init_buffers(sub_dev_t *sub_dev_ptr)
size_t size, off;
unsigned left;
u32_t i;
phys_bytes ph;
/* allocate dma buffer space */
size= sub_dev_ptr->DmaSize + 64 * 1024;
base= malloc(size + PAGE_SIZE);
off = base= alloc_contig(size, AC_ALIGN4K, &ph);
if (!base) {
error("%s: failed to allocate dma buffer for channel %d\n",
drv.DriverName,i);
return EIO;
}
/* Align base */
off= ((size_t)base % PAGE_SIZE);
if (off)
base += PAGE_SIZE-off;
sub_dev_ptr->DmaBuf= base;
tell_dev((vir_bytes)base, size, 0, 0, 0);

View File

@@ -12,7 +12,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i
LDFLAGS = -i
LIBS = -lsys -lsysutil
LIBS = -lsys
# build local binary

View File

@@ -14,7 +14,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i -L../libdriver
LIBS = -lsysutil -lsys -ltimers -ldriver
LIBS = -ldriver -lsys -lsys -ltimers
OBJ = bios_wini.o

View File

@@ -166,7 +166,7 @@ vir_bytes from_vir;
endpoint_t to_proc;
int to_seg;
vir_bytes to_vir;
vir_bytes grant_offset;
size_t grant_offset;
size_t size;
{
phys_bytes addr;

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = 3c503.o dp8390.o ne2000.o rtl8029.o wdeth.o

View File

@@ -59,6 +59,7 @@
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
#include <sys/vm_i386.h>
#include <sys/vm.h>
#include "assert.h"
@@ -2540,18 +2541,22 @@ dpeth_t *dep;
return;
}
size = dep->de_ramsize + PAGE_SIZE; /* Add PAGE_SIZE for
size = dep->de_ramsize + I386_PAGE_SIZE; /* Add I386_PAGE_SIZE for
* alignment
*/
buf= malloc(size);
if (buf == NULL)
panic(__FILE__, "map_hw_buffer: cannot malloc size", size);
o= PAGE_SIZE - ((vir_bytes)buf % PAGE_SIZE);
o= I386_PAGE_SIZE - ((vir_bytes)buf % I386_PAGE_SIZE);
abuf= buf + o;
printf("buf at 0x%x, abuf at 0x%x\n", buf, abuf);
#if 0
r= sys_vm_map(SELF, 1 /* map */, (vir_bytes)abuf,
dep->de_ramsize, (phys_bytes)dep->de_linmem);
#else
r = ENOSYS;
#endif
if (r != OK)
panic(__FILE__, "map_hw_buffer: sys_vm_map failed", r);
dep->de_locmem = abuf;

View File

@@ -15,7 +15,7 @@ LDFLAGS = -i -o $@
SRCS = 3c501.c 3c509.c 3c503.c ne.c wd.c 8390.c devio.c netbuff.c dp.c
OBJS = 3c501.o 3c509.o 3c503.o ne.o wd.o 8390.o devio.o netbuff.o dp.o
LIBS = -lsysutil -lsys # -ltimers
LIBS = -lsys
## Build rules
all build: $(DRIVER)

View File

@@ -14,7 +14,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i -L../libdriver
LIBS = -lsysutil -ldriver -lsys -ltimers
LIBS = -ldriver -lsys -ltimers
OBJ = floppy.o

View File

@@ -294,6 +294,8 @@ PUBLIC void main()
struct floppy *fp;
int s;
init_buffer();
f_next_timeout = TMR_NEVER;
tmr_inittimer(&f_tmr_timeout);

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = fxp.o mii.o
@@ -21,7 +21,7 @@ OBJ = fxp.o mii.o
all build: $(DRIVER)
$(DRIVER): $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 96k $(DRIVER)
install -S 128k $(DRIVER)
# install with other drivers
install: /usr/sbin/$(DRIVER)

View File

@@ -211,7 +211,8 @@ fxp_t;
#define FT_82558A 0x2
#define FT_82559 0x4
static fxp_t fxp_table[FXP_PORT_NR];
static fxp_t *fxp_table;
phys_bytes fxp_table_phys;
static u16_t eth_ign_proto;
static tmra_ut fxp_watchdog;
@@ -281,6 +282,7 @@ int main(int argc, char *argv[])
u32_t tasknr;
fxp_t *fp;
long v;
vir_bytes ft = sizeof(*fxp_table)*FXP_PORT_NR;
if (argc < 1)
panic("FXP", "A head which at this time has no name", NO_NUM);
@@ -292,6 +294,11 @@ int main(int argc, char *argv[])
#endif
eth_ign_proto= htons((u16_t) v);
if(!(fxp_table = alloc_contig(ft, 0, &fxp_table_phys)))
panic("FXP","couldn't allocate table", r);
memset(fxp_table, 0, ft);
if((r=micro_delay_calibrate()) != OK)
panic("FXP","rmicro_delay_calibrate failed", r);
@@ -795,7 +802,7 @@ fxp_t *fp;
fxp_do_conf(fp);
/* Set pointer to statistical counters */
r= sys_umap(SELF, D, (vir_bytes)&fp->fxp_stat, sizeof(fp->fxp_stat),
r= sys_umap(SELF, VM_D, (vir_bytes)&fp->fxp_stat, sizeof(fp->fxp_stat),
&bus_addr);
if (r != OK)
panic("FXP","sys_umap failed", r);
@@ -835,6 +842,7 @@ fxp_t *fp;
int i, r;
struct rfd *rfdp;
struct tx *txp;
phys_bytes ph;
fp->fxp_rx_nbuf= N_RX_BUF;
rx_totbufsize= fp->fxp_rx_nbuf * sizeof(struct rfd);
@@ -844,33 +852,33 @@ fxp_t *fp;
tx_totbufsize= fp->fxp_tx_nbuf * sizeof(struct tx);
fp->fxp_tx_bufsize= tx_totbufsize;
#define BUFALIGN 4096
tot_bufsize= sizeof(*tmpbufp) + tx_totbufsize + rx_totbufsize;
if (tot_bufsize % 4096)
tot_bufsize += 4096 - (tot_bufsize % 4096);
alloc_bufsize= tot_bufsize+BUFALIGN;
alloc_buf= malloc(alloc_bufsize);
alloc_bufsize= tot_bufsize;
alloc_buf= alloc_contig(alloc_bufsize, AC_ALIGN4K, &ph);
if (alloc_buf == NULL)
{
panic(__FILE__, "fxp_init_buf: unable to malloc size",
panic(__FILE__, "fxp_init_buf: unable to alloc_contig size",
alloc_bufsize);
}
buf= (phys_bytes)alloc_buf;
buf += BUFALIGN - (buf % BUFALIGN);
tell_dev((vir_bytes)buf, tot_bufsize, 0, 0, 0);
tmpbufp= (union tmpbuf *)buf;
fp->fxp_rx_buf= (struct rfd *)&tmpbufp[1];
r= sys_umap(SELF, D, (vir_bytes)fp->fxp_rx_buf, rx_totbufsize,
r= sys_umap(SELF, VM_D, (vir_bytes)fp->fxp_rx_buf, rx_totbufsize,
&fp->fxp_rx_busaddr);
if (r != OK)
panic("FXP","sys_umap failed", r);
#if 0
printf("fxp_init_buf: got phys 0x%x for vir 0x%x\n",
fp->fxp_rx_busaddr, fp->fxp_rx_buf);
#endif
for (i= 0, rfdp= fp->fxp_rx_buf; i<fp->fxp_rx_nbuf; i++, rfdp++)
{
@@ -878,7 +886,7 @@ fxp_t *fp;
rfdp->rfd_command= 0;
if (i != fp->fxp_rx_nbuf-1)
{
r= sys_umap(SELF, D, (vir_bytes)&rfdp[1],
r= sys_umap(SELF, VM_D, (vir_bytes)&rfdp[1],
sizeof(rfdp[1]), &rfdp->rfd_linkaddr);
if (r != OK)
panic("FXP","sys_umap failed", r);
@@ -896,7 +904,7 @@ fxp_t *fp;
fp->fxp_rx_head= 0;
fp->fxp_tx_buf= (struct tx *)((char *)fp->fxp_rx_buf+rx_totbufsize);
r= sys_umap(SELF, D, (vir_bytes)fp->fxp_tx_buf,
r= sys_umap(SELF, VM_D, (vir_bytes)fp->fxp_tx_buf,
(phys_bytes)tx_totbufsize, &fp->fxp_tx_busaddr);
if (r != OK)
panic("FXP","sys_umap failed", r);
@@ -907,7 +915,7 @@ fxp_t *fp;
txp->tx_command= TXC_EL | CBL_NOP; /* Just in case */
if (i != fp->fxp_tx_nbuf-1)
{
r= sys_umap(SELF, D, (vir_bytes)&txp[1],
r= sys_umap(SELF, VM_D, (vir_bytes)&txp[1],
(phys_bytes)sizeof(txp[1]),
&txp->tx_linkaddr);
if (r != OK)
@@ -938,7 +946,7 @@ fxp_t *fp;
/* Reset device */
fxp_outl(port, CSR_PORT, CP_CMD_SOFT_RESET);
tickdelay(MICROS_TO_TICKS(CSR_PORT_RESET_DELAY));
tickdelay(micros_to_ticks(CSR_PORT_RESET_DELAY));
/* Disable interrupts */
fxp_outb(port, SCB_INT_MASK, SIM_M);
@@ -995,7 +1003,7 @@ fxp_t *fp;
tmpbufp->ias.ias_linkaddr= 0;
memcpy(tmpbufp->ias.ias_ethaddr, fp->fxp_address.ea_addr,
sizeof(tmpbufp->ias.ias_ethaddr));
r= sys_umap(SELF, D, (vir_bytes)&tmpbufp->ias,
r= sys_umap(SELF, VM_D, (vir_bytes)&tmpbufp->ias,
(phys_bytes)sizeof(tmpbufp->ias), &bus_addr);
if (r != OK)
panic("FXP","sys_umap failed", r);
@@ -1007,7 +1015,7 @@ fxp_t *fp;
/* Wait for CU command to complete */
if (tmpbufp->ias.ias_status & CBL_F_C)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(1000));
if (!(tmpbufp->ias.ias_status & CBL_F_C))
panic("FXP","fxp_confaddr: CU command failed to complete", NO_NUM);
@@ -1731,7 +1739,7 @@ fxp_t *fp;
memcpy(tmpbufp->cc.cc_bytes, fp->fxp_conf_bytes,
sizeof(tmpbufp->cc.cc_bytes));
r= sys_umap(SELF, D, (vir_bytes)&tmpbufp->cc,
r= sys_umap(SELF, VM_D, (vir_bytes)&tmpbufp->cc,
(phys_bytes)sizeof(tmpbufp->cc), &bus_addr);
if (r != OK)
panic("FXP","sys_umap failed", r);
@@ -1743,7 +1751,7 @@ fxp_t *fp;
/* Wait for CU command to complete */
if (tmpbufp->cc.cc_status & CBL_F_C)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(100000));
if (!(tmpbufp->cc.cc_status & CBL_F_C))
panic("FXP","fxp_do_conf: CU command failed to complete", NO_NUM);
@@ -1786,7 +1794,7 @@ int check_idle;
scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_CUC_MASK) == SC_CU_NOP)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(100000));
if ((scb_cmd & SC_CUC_MASK) != SC_CU_NOP)
panic("FXP","fxp_cu_ptr_cmd: CU does not accept command", NO_NUM);
@@ -1823,7 +1831,7 @@ int check_idle;
scb_cmd= fxp_inb(port, SCB_CMD);
if ((scb_cmd & SC_RUC_MASK) == SC_RU_NOP)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(1000));
if ((scb_cmd & SC_RUC_MASK) != SC_RU_NOP)
panic("FXP","fxp_ru_ptr_cmd: RU does not accept command", NO_NUM);
@@ -1899,7 +1907,7 @@ message *mp;
/* Wait for CU command to complete */
if (*p != 0)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(1000));
if (*p == 0)
panic("FXP","fxp_getstat: CU command failed to complete", NO_NUM);
@@ -1983,7 +1991,7 @@ message *mp;
/* Wait for CU command to complete */
if (*p != 0)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(1000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(1000));
if (*p == 0)
panic("FXP","fxp_getstat: CU command failed to complete", NO_NUM);
@@ -2798,7 +2806,7 @@ int reg;
v= fxp_inl(port, CSR_MDI_CTL);
if (v & CM_READY)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(100000));
if (!(v & CM_READY))
panic("FXP","mii_read: MDI not ready after command", NO_NUM);
@@ -2932,9 +2940,11 @@ int pci_func;
r= ds_retrieve_u32("amddev", &u32);
if (r != OK)
{
#if 0
printf(
"fxp`tell_dev: ds_retrieve_u32 failed for 'amddev': %d\n",
r);
#endif
return;
}

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys
#-lutils -ltimers
OBJ = lance.o
@@ -22,7 +22,7 @@ OBJ = lance.o
all build: $(DRIVER)
$(DRIVER): $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 16k $(DRIVER)
install -S 128k $(DRIVER)
# install with other drivers
install: /usr/sbin/$(DRIVER)

View File

@@ -193,7 +193,7 @@ unsigned long vir2phys( unsigned long x )
int r;
unsigned long value;
if ( (r=sys_umap( SELF, D, x, 4, &value )) != OK )
if ( (r=sys_umap( SELF, VM_D, x, 4, &value )) != OK )
panic( "lance", "sys_umap failed", r );
return value;
@@ -202,7 +202,7 @@ unsigned long vir2phys( unsigned long x )
/* DMA limitations */
#define DMA_ADDR_MASK 0xFFFFFF /* mask to verify DMA address is 24-bit */
#define CORRECT_DMA_MEM() ( (virt_to_bus(lance + sizeof(lance)) & ~DMA_ADDR_MASK) == 0 )
#define CORRECT_DMA_MEM() ( (virt_to_bus(lance_buf + sizeof(struct lance_interface)) & ~DMA_ADDR_MASK) == 0 )
#define ETH_FRAME_LEN 1518
@@ -297,7 +297,8 @@ struct lance_interface
/* =============== global variables =============== */
static struct lance_interface *lp;
static char lance[sizeof(struct lance_interface)+8];
#define LANCE_BUF_SIZE (sizeof(struct lance_interface))
static char *lance_buf = NULL;
static int rx_slot_nr = 0; /* Rx-slot number */
static int tx_slot_nr = 0; /* Tx-slot number */
static int cur_tx_slot_nr = 0; /* Tx-slot number */
@@ -1682,8 +1683,11 @@ ether_card_t *ec;
unsigned short ioaddr = ec->ec_port;
/* ============= setup init_block(cf. lance_probe1) ================ */
/* make sure data structure is 8-byte aligned */
l = ((Address)lance + 7) & ~7;
/* make sure data structure is 8-byte aligned and below 16MB (for DMA) */
assert(!lance_buf);
if(!(lance_buf = alloc_contig(LANCE_BUF_SIZE, AC_ALIGN4K|AC_LOWER16M, &l))) {
panic( "lance", "alloc_contig failed", LANCE_BUF_SIZE);
}
lp = (struct lance_interface *)l;
lp->init_block.mode = 0x3; /* disable Rx and Tx */
lp->init_block.filter[0] = lp->init_block.filter[1] = 0x0;

View File

@@ -11,7 +11,7 @@ m = $i/minix
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys
LIB = libdriver.a
OBJECTS = driver.o drvlib.o mq.o

View File

@@ -43,29 +43,13 @@
#include <minix/mq.h>
#include "driver.h"
#if (CHIP == INTEL)
#if USE_EXTRA_DMA_BUF && DMA_BUF_SIZE < 2048
/* A bit extra scratch for the Adaptec driver. */
#define BUF_EXTRA (2048 - DMA_BUF_SIZE)
#else
#define BUF_EXTRA 0
#endif
/* Claim space for variables. */
PRIVATE u8_t buffer[(unsigned) 2 * DMA_BUF_SIZE + BUF_EXTRA];
#if 0
PRIVATE u8_t buffer[(unsigned) 2 * DMA_BUF_SIZE];
#endif
u8_t *tmp_buf; /* the DMA buffer eventually */
phys_bytes tmp_phys; /* phys address of DMA buffer */
#else /* CHIP != INTEL */
/* Claim space for variables. */
u8_t tmp_buf[DMA_BUF_SIZE]; /* the DMA buffer */
phys_bytes tmp_phys; /* phys address of DMA buffer */
#endif /* CHIP != INTEL */
FORWARD _PROTOTYPE( void init_buffer, (void) );
FORWARD _PROTOTYPE( int do_rdwt, (struct driver *dr, message *mp, int safe) );
FORWARD _PROTOTYPE( int do_vrdwt, (struct driver *dr, message *mp, int safe) );
@@ -86,9 +70,6 @@ struct driver *dp; /* Device dependent entry points. */
/* Init MQ library. */
mq_init();
/* Get a DMA buffer. */
init_buffer();
/* Here is the main loop of the disk task. It waits for a message, carries
* it out, and sends a reply.
*/
@@ -176,25 +157,17 @@ struct driver *dp; /* Device dependent entry points. */
/*===========================================================================*
* init_buffer *
*===========================================================================*/
PRIVATE void init_buffer()
PUBLIC void init_buffer(void)
{
/* Select a buffer that can safely be used for DMA transfers. It may also
* be used to read partition tables and such. Its absolute address is
* 'tmp_phys', the normal address is 'tmp_buf'.
*/
#if (CHIP == INTEL)
unsigned left;
tmp_buf = buffer;
sys_umap(SELF, D, (vir_bytes)buffer, (phys_bytes)sizeof(buffer), &tmp_phys);
if ((left = dma_bytes_left(tmp_phys)) < DMA_BUF_SIZE) {
/* First half of buffer crosses a 64K boundary, can't DMA into that */
tmp_buf += left;
tmp_phys += left;
}
#endif /* CHIP == INTEL */
if(!(tmp_buf = alloc_contig(2*DMA_BUF_SIZE, AC_ALIGN4K, &tmp_phys)))
panic(__FILE__, "can't allocate tmp_buf", DMA_BUF_SIZE);
}
/*===========================================================================*
@@ -216,8 +189,8 @@ int safe; /* use safecopies? */
/* Check the user buffer (not relevant for safe copies). */
if(!safe) {
sys_umap(mp->IO_ENDPT, D, (vir_bytes) mp->ADDRESS, mp->COUNT, &phys_addr);
if (phys_addr == 0) return(EFAULT);
printf("libdriver_asyn: do_rdwt: no support for non-safe command.\n");
return EINVAL;
}
/* Prepare for I/O. */

View File

@@ -45,14 +45,6 @@ struct driver {
_PROTOTYPE( int (*dr_hw_int), (struct driver *dp, message *m_ptr) );
};
#if (CHIP == INTEL)
/* Number of bytes you can DMA before hitting a 64K boundary: */
#define dma_bytes_left(phys) \
((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
#endif /* CHIP == INTEL */
/* Base and size of a partition in bytes. */
struct device {
u64_t dv_base;
@@ -75,6 +67,7 @@ _PROTOTYPE( int nop_select, (struct driver *dp, message *m_ptr) );
_PROTOTYPE( int do_diocntl, (struct driver *dp, message *m_ptr, int safe) );
_PROTOTYPE( int nop_ioctl, (struct driver *dp, message *m_ptr, int safe) );
_PROTOTYPE( int mq_queue, (message *m_ptr) );
_PROTOTYPE( void init_buffer, (void) );
/* Parameters for the disk drive. */
#define SECTOR_SIZE 512 /* physical sector size in bytes */

View File

@@ -11,7 +11,7 @@ m = $i/minix
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys
LIB = libdriver.a
OBJECTS = driver.o drvlib.o mq.o

View File

@@ -43,28 +43,10 @@
#include <minix/mq.h>
#include "driver.h"
#if (CHIP == INTEL)
#if USE_EXTRA_DMA_BUF && DMA_BUF_SIZE < 2048
/* A bit extra scratch for the Adaptec driver. */
#define BUF_EXTRA (2048 - DMA_BUF_SIZE)
#else
#define BUF_EXTRA 0
#endif
/* Claim space for variables. */
PRIVATE u8_t buffer[(unsigned) 2 * DMA_BUF_SIZE + BUF_EXTRA];
u8_t *tmp_buf; /* the DMA buffer eventually */
u8_t *tmp_buf = NULL; /* the DMA buffer eventually */
phys_bytes tmp_phys; /* phys address of DMA buffer */
#else /* CHIP != INTEL */
/* Claim space for variables. */
u8_t tmp_buf[DMA_BUF_SIZE]; /* the DMA buffer */
phys_bytes tmp_phys; /* phys address of DMA buffer */
#endif /* CHIP != INTEL */
FORWARD _PROTOTYPE( void init_buffer, (void) );
FORWARD _PROTOTYPE( int do_rdwt, (struct driver *dr, message *mp, int safe) );
FORWARD _PROTOTYPE( int do_vrdwt, (struct driver *dr, message *mp, int safe) );
@@ -88,9 +70,6 @@ struct driver *dp; /* Device dependent entry points. */
/* Init MQ library. */
mq_init();
/* Get a DMA buffer. */
init_buffer();
/* Here is the main loop of the disk task. It waits for a message, carries
* it out, and sends a reply.
*/
@@ -112,6 +91,7 @@ struct driver *dp; /* Device dependent entry points. */
device_caller = mess.m_source;
proc_nr = mess.IO_ENDPT;
#if 0
if (mess.m_type != SYN_ALARM && mess.m_type != DEV_PING &&
mess.m_type != 4105 /* notify from TTY */ &&
mess.m_type != DEV_SELECT &&
@@ -119,9 +99,10 @@ struct driver *dp; /* Device dependent entry points. */
mess.m_type != DIAGNOSTICS_S &&
mess.m_type != CANCEL)
{
printf("libdriver_asyn`driver_task: message %d\n",
mess.m_type);
printf("libdriver_asyn`driver_task: msg %d / 0x%x from %d\n",
mess.m_type, mess.m_type, mess.m_source);
}
#endif
if (mess.m_type == DEV_SELECT)
{
@@ -129,9 +110,11 @@ struct driver *dp; /* Device dependent entry points. */
if (first)
{
first= 0;
#if 0
printf(
"libdriver_asyn`driver_task: first DEV_SELECT: minor 0x%x, ops 0x%x\n",
mess.DEVICE, mess.IO_ENDPT);
#endif
}
}
@@ -223,15 +206,19 @@ struct driver *dp; /* Device dependent entry points. */
}
else if (mess.m_type == DIAGNOSTICS_S)
{
#if 0
if (device_caller == FS_PROC_NR)
printf("driver_task: sending DIAG_REPL to FS\n");
#endif
reply_mess.m_type = DIAG_REPL;
reply_mess.REP_STATUS = r;
}
else
{
#if 0
printf("driver_task: TASK_REPLY to req %d\n",
mess.m_type);
#endif
reply_mess.m_type = TASK_REPLY;
reply_mess.REP_ENDPT = proc_nr;
/* Status is # of bytes transferred or error code. */
@@ -258,18 +245,11 @@ PRIVATE void init_buffer()
* 'tmp_phys', the normal address is 'tmp_buf'.
*/
#if (CHIP == INTEL)
unsigned left;
tmp_buf = buffer;
sys_umap(SELF, D, (vir_bytes)buffer, (phys_bytes)sizeof(buffer), &tmp_phys);
if ((left = dma_bytes_left(tmp_phys)) < DMA_BUF_SIZE) {
/* First half of buffer crosses a 64K boundary, can't DMA into that */
tmp_buf += left;
tmp_phys += left;
if(!(tmp_buf = alloc_contig(2*DMA_BUF_SIZE, 0, &tmp_phys))) {
panic(__FILE__, "can't allocate tmp_buf", NO_NUM);
}
#endif /* CHIP == INTEL */
}
/*===========================================================================*
@@ -557,6 +537,8 @@ PUBLIC int mq_queue(message *m)
return OK;
}
#if 0
#define ASYN_NR 100
PRIVATE asynmsg_t msgtable[ASYN_NR];
PRIVATE int first_slot= 0, next_slot= 0;
@@ -644,3 +626,4 @@ message *mp;
return senda(msgtable+first_slot, next_slot-first_slot);
}
#endif

View File

@@ -45,14 +45,6 @@ struct driver {
_PROTOTYPE( int (*dr_hw_int), (struct driver *dp, message *m_ptr) );
};
#if (CHIP == INTEL)
/* Number of bytes you can DMA before hitting a 64K boundary: */
#define dma_bytes_left(phys) \
((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
#endif /* CHIP == INTEL */
/* Base and size of a partition in bytes. */
struct device {
u64_t dv_base;

View File

@@ -13,7 +13,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i -L../libdriver_asyn
LIBS = -lsysutil -ldriver -lsys
LIBS = -ldriver -lsys
LIB_DEP = ../libdriver_asyn/libdriver.a
OBJ = log.o diag.o kputc.o
@@ -22,11 +22,11 @@ OBJ = log.o diag.o kputc.o
all build: $(DRIVER)
$(DRIVER): $(OBJ) $(LIB_DEP)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 16kb $(DRIVER)
install -S 32kb $(DRIVER)
# install with other drivers
install: $(DRIVER)
install -o root -cs $? /sbin/$(DRIVER)
install -o root -cs $< /sbin/$(DRIVER)
# clean up local files
clean:

View File

@@ -11,11 +11,9 @@
#include <fcntl.h>
#include <minix/type.h>
#include <minix/safecopies.h>
#include <minix/sys_config.h>
#include "log.h"
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
/*==========================================================================*
* do_new_kmess *
@@ -24,8 +22,8 @@ PUBLIC int do_new_kmess(m)
message *m; /* notification message */
{
/* Notification for a new kernel message. */
struct kmessages kmess; /* entire kmess structure */
char print_buf[KMESS_BUF_SIZE]; /* copy new message here */
static struct kmessages kmess; /* entire kmess structure */
static char print_buf[_KMESS_BUF_SIZE]; /* copy new message here */
int bytes;
int i, r;
int *prev_nextp;
@@ -79,12 +77,12 @@ message *m; /* notification message */
* Check for size being positive, the buffer might as well be emptied!
*/
if (kmess.km_size > 0) {
bytes = ((kmess.km_next + KMESS_BUF_SIZE) - (*prev_nextp)) %
KMESS_BUF_SIZE;
bytes = ((kmess.km_next + _KMESS_BUF_SIZE) - (*prev_nextp)) %
_KMESS_BUF_SIZE;
r= *prev_nextp; /* start at previous old */
i=0;
while (bytes > 0) {
print_buf[i] = kmess.km_buf[(r%KMESS_BUF_SIZE)];
print_buf[i] = kmess.km_buf[(r%_KMESS_BUF_SIZE)];
bytes --;
r ++;
i ++;
@@ -136,5 +134,7 @@ PUBLIC int do_diagnostics(message *m, int safe)
}
log_append(diagbuf, i);
if(m->m_type == ASYN_DIAGNOSTICS) return EDONTREPLY;
return OK;
}

View File

@@ -9,8 +9,6 @@
#include "log.h"
#include <sys/time.h>
#include <sys/select.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#define LOG_DEBUG 0 /* enable/ disable debugging */
@@ -403,10 +401,10 @@ int safe;
r = do_diagnostics(m_ptr, 0);
break;
}
case DIAGNOSTICS_S: {
case ASYN_DIAGNOSTICS:
case DIAGNOSTICS_S:
r = do_diagnostics(m_ptr, 1);
break;
}
case DEV_STATUS: {
printf("log_other: unexpected DEV_STATUS request\n");
r = EDONTREPLY;

View File

@@ -14,7 +14,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i
LDFLAGS = -i -L../libdriver
LIBS = -lsysutil -ldriver -lsys
LIBS = -ldriver -lsys
# imgrd_s.s is the ACK assembler version of the ramdisk. For more portability,
# use the C version imgrd.c. However, the C compiler takes too much memory

View File

@@ -27,6 +27,7 @@
#define MY_DS_NAME_SIZE "dev:memory:ramdisk_size"
#include <sys/vm.h>
#include <sys/vm_i386.h>
#include "assert.h"
@@ -71,7 +72,7 @@ PRIVATE struct driver m_dtab = {
/* One page of temporary mapping area - enough to be able to page-align
* one page.
*/
static char pagedata_buf[2*PAGE_SIZE];
static char pagedata_buf[2*I386_PAGE_SIZE];
vir_bytes pagedata_aligned;
/* Buffer for the /dev/zero null byte feed. */
@@ -171,8 +172,10 @@ int safe; /* safe copies */
break;
/* Virtual copying. For RAM disk, kernel memory and boot device. */
case RAM_DEV:
case KMEM_DEV:
return EIO;
break;
case RAM_DEV:
case BOOT_DEV:
if (position >= dv_size) return(OK); /* check for EOF */
if (position + count > dv_size) count = dv_size - position;
@@ -207,15 +210,19 @@ int safe; /* safe copies */
count = dv_size - position;
mem_phys = cv64ul(dv->dv_base) + position;
page_off = mem_phys % PAGE_SIZE;
page_off = mem_phys % I386_PAGE_SIZE;
pagestart = mem_phys - page_off;
/* All memory to the map call has to be page-aligned.
* Don't have to map same page over and over.
*/
if(!any_mapped || pagestart_mapped != pagestart) {
#if 0
if((r=sys_vm_map(SELF, 1, pagedata_aligned,
PAGE_SIZE, pagestart)) != OK) {
I386_PAGE_SIZE, pagestart)) != OK) {
#else
if(1) {
#endif
printf("memory: sys_vm_map failed: %d\n", r);
return r;
}
@@ -224,7 +231,7 @@ int safe; /* safe copies */
}
/* how much to be done within this page. */
subcount = PAGE_SIZE-page_off;
subcount = I386_PAGE_SIZE-page_off;
if(subcount > count)
subcount = count;
@@ -324,12 +331,14 @@ PRIVATE void m_init()
}
/* Install remote segment for /dev/kmem memory. */
#if 0
m_geom[KMEM_DEV].dv_base = cvul64(kinfo.kmem_base);
m_geom[KMEM_DEV].dv_size = cvul64(kinfo.kmem_size);
if (OK != (s=sys_segctl(&m_seg[KMEM_DEV], (u16_t *) &s, (vir_bytes *) &s,
kinfo.kmem_base, kinfo.kmem_size))) {
panic("MEM","Couldn't install remote segment.",s);
}
#endif
/* Install remote segment for /dev/boot memory, if enabled. */
m_geom[BOOT_DEV].dv_base = cvul64(kinfo.bootdev_base);
@@ -365,8 +374,8 @@ PRIVATE void m_init()
}
/* Page-align page pointer. */
pagedata_aligned = (u32_t) pagedata_buf + PAGE_SIZE;
pagedata_aligned -= pagedata_aligned % PAGE_SIZE;
pagedata_aligned = (u32_t) pagedata_buf + I386_PAGE_SIZE;
pagedata_aligned -= pagedata_aligned % I386_PAGE_SIZE;
/* Set up memory range for /dev/mem. */
m_geom[MEM_DEV].dv_size = cvul64(0xffffffff);
@@ -404,15 +413,11 @@ int safe;
if (m_ptr->DEVICE != RAM_DEV) return(EINVAL);
if ((dv = m_prepare(m_ptr->DEVICE)) == NIL_DEV) return(ENXIO);
#if 0
ramdev_size= m_ptr->POSITION;
#else
/* Get request structure */
s= sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->IO_GRANT,
0, (vir_bytes)&ramdev_size, sizeof(ramdev_size), D);
if (s != OK)
return s;
#endif
#if DEBUG
printf("allocating ramdisk of size 0x%x\n", ramdev_size);
@@ -447,27 +452,6 @@ int safe;
first_time= 0;
break;
}
case MIOCMAP:
case MIOCUNMAP: {
int r, do_map;
struct mapreq mapreq;
if ((*dp->dr_prepare)(m_ptr->DEVICE) == NIL_DEV) return(ENXIO);
if (m_device != MEM_DEV)
return ENOTTY;
do_map= (m_ptr->REQUEST == MIOCMAP); /* else unmap */
/* Get request structure */
r= sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->IO_GRANT,
0, (vir_bytes)&mapreq, sizeof(mapreq), D);
if (r != OK)
return r;
r= sys_vm_map(m_ptr->IO_ENDPT, do_map,
(phys_bytes)mapreq.base, mapreq.size, mapreq.offset);
return r;
}
default:
return(do_diocntl(&m_dtab, m_ptr, safe));

View File

@@ -9,7 +9,6 @@ then
else
/bin/service -c up /bin/at_wini -dev /dev/c0d0 -config /etc/drivers.conf -label at_wini_0
/bin/service -c up /bin/at_wini -dev /dev/c1d0 -config /etc/drivers.conf -label at_wini_1 -args ata_instance=1
#/bin/service -c up /bin/at_wini -dev /dev/c0d0 -script /etc/rs.single -config /etc/drivers.conf
fi
rootdev=`sysenv rootdev` || echo 'No rootdev?'

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = orinoco.o hermes.o

View File

@@ -44,8 +44,6 @@
#include "string.h"
int this_proc;
#define MICROS_TO_TICKS(m) (((m)*HZ/1000000)+1)
/*****************************************************************************
* milli_delay *
* *

View File

@@ -93,7 +93,7 @@ static tmra_ut or_watchdog;
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
#include <sys/vm.h>
#include <sys/vm_i386.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
@@ -738,24 +738,29 @@ static void map_hw_buffer(t_or *orp) {
char *buf, *abuf;
hermes_t *hw = &(orp->hw);
/* This way, the buffer will be at least PAGE_SIZE big: see
/* This way, the buffer will be at least I386_PAGE_SIZE big: see
* calculation with the offset */
size = 2 * PAGE_SIZE;
size = 2 * I386_PAGE_SIZE;
buf = (char *)malloc(size);
if(buf == NULL)
panic(__FILE__, "map_hw_buffer: cannot malloc size:", size);
/* Let the mapped memory by PAGE_SIZE aligned */
o = PAGE_SIZE - ((vir_bytes)buf % PAGE_SIZE);
/* Let the mapped memory by I386_PAGE_SIZE aligned */
o = I386_PAGE_SIZE - ((vir_bytes)buf % I386_PAGE_SIZE);
abuf = buf + o;
#if 0
r = sys_vm_map(SELF, 1, (vir_bytes)abuf,
1 * PAGE_SIZE, (phys_bytes)orp->or_base_port);
1 * I386_PAGE_SIZE, (phys_bytes)orp->or_base_port);
#else
r = ENOSYS;
#endif
if(r!=OK)
panic(__FILE__, "map_hw_buffer: sys_vm_map failed:", r);
hw->locmem = abuf;
}

View File

@@ -13,7 +13,7 @@ d = ..
CC = cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = main.o pci.o pci_table.o

View File

@@ -388,8 +388,10 @@ message *mp;
}
acl[i].inuse= 0;
#if 0
printf("do_acl: deleting ACL for %d ('%s') at entry %d\n",
acl[i].acl.rsp_endpoint, acl[i].acl.rsp_label, i);
#endif
/* Also release all devices held by this process */
pci_release(proc_nr);

View File

@@ -10,7 +10,7 @@ Created: Jan 2000 by Philip Homburg <philip@cs.vu.nl>
#include "../drivers.h"
#include <assert.h>
#include <ibm/pci.h>
#include <sys/vm.h>
#include <sys/vm_i386.h>
#include <minix/com.h>
#include <minix/rs.h>
#include <minix/syslib.h>
@@ -118,7 +118,9 @@ FORWARD _PROTOTYPE( int do_piix, (int devind) );
FORWARD _PROTOTYPE( int do_amd_isabr, (int devind) );
FORWARD _PROTOTYPE( int do_sis_isabr, (int devind) );
FORWARD _PROTOTYPE( int do_via_isabr, (int devind) );
#if 0
FORWARD _PROTOTYPE( void report_vga, (int devind) );
#endif
FORWARD _PROTOTYPE( char *pci_vid_name, (U16_t vid) );
FORWARD _PROTOTYPE( char *pci_baseclass_name, (U8_t baseclass) );
FORWARD _PROTOTYPE( char *pci_subclass_name, (U8_t baseclass,
@@ -872,8 +874,10 @@ printf("probe_bus(%d)\n", busind);
print_capabilities(devind);
t3= ((baseclass << 16) | (subclass << 8) | infclass);
#if 0
if (t3 == PCI_T3_VGA || t3 == PCI_T3_VGA_OLD)
report_vga(devind);
#endif
if (nr_pcidev >= NR_PCIDEV)
panic("PCI","too many PCI devices", nr_pcidev);
@@ -1406,8 +1410,8 @@ PRIVATE void complete_bars()
if (!(pcidev[i].pd_bar[j].pb_flags & PBF_INCOMPLETE))
continue;
size= pcidev[i].pd_bar[j].pb_size;
if (size < PAGE_SIZE)
size= PAGE_SIZE;
if (size < I386_PAGE_SIZE)
size= I386_PAGE_SIZE;
base= memgap_high-size;
base &= ~(u32_t)(size-1);
if (base < memgap_low)
@@ -2010,6 +2014,7 @@ int devind;
}
#if 0
/*===========================================================================*
* report_vga *
*===========================================================================*/
@@ -2042,6 +2047,7 @@ int devind;
amount);
}
}
#endif
/*===========================================================================*

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys -lsys
OBJ = printer.o

View File

@@ -14,7 +14,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i -L../libdriver_asyn
LIBS = -lsysutil -ldriver -lsys
LIBS = -ldriver -lsys
LIB_DEPS=../libdriver_asyn/libdriver.a
OBJ = main.o random.o sha2.o aes/rijndael_api.o aes/rijndael_alg.o

View File

@@ -6,7 +6,7 @@ MAKE = exec make
CC = exec cc
CFLAGS=-D_MINIX=1 -D_POSIX_SOURCE=1 -D_SYSTEM=1
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys
OBJ = readclock.o

View File

@@ -14,7 +14,7 @@ MAKE = exec make
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = rtl8139.o

View File

@@ -12,7 +12,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys
LIBS = -lsys
# build local binary

View File

@@ -13,7 +13,7 @@ d = ..
CC = exec cc
CFLAGS = -I$i $(CPROFILE)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = ti1225.o

View File

@@ -7,6 +7,7 @@ Created: Dec 2005 by Philip Homburg
#include "../drivers.h"
#include <ibm/pci.h>
#include <sys/vm.h>
#include <sys/vm_i386.h>
#include "ti1225.h"
#include "i82365.h"
@@ -29,7 +30,7 @@ PRIVATE struct port
char *base_ptr;
volatile struct csr *csr_ptr;
char buffer[2*PAGE_SIZE];
char buffer[2*I386_PAGE_SIZE];
} ports[NR_PORTS];
#define PF_PRESENT 1
@@ -257,8 +258,8 @@ u32_t base;
vir_bytes buf_base;
buf_base= (vir_bytes)pp->buffer;
if (buf_base % PAGE_SIZE)
buf_base += PAGE_SIZE-(buf_base % PAGE_SIZE);
if (buf_base % I386_PAGE_SIZE)
buf_base += I386_PAGE_SIZE-(buf_base % I386_PAGE_SIZE);
pp->base_ptr= (char *)buf_base;
if (debug)
{
@@ -269,8 +270,12 @@ u32_t base;
/* Clear low order bits in base */
base &= ~(u32_t)0xF;
#if 0
r= sys_vm_map(SELF, 1 /* map */, (vir_bytes)pp->base_ptr,
PAGE_SIZE, (phys_bytes)base);
I386_PAGE_SIZE, (phys_bytes)base);
#else
r = ENOSYS;
#endif
if (r != OK)
panic("ti1225", "map_regs: sys_vm_map failed", r);
}
@@ -422,7 +427,7 @@ struct port *pp;
csr_present= pp->csr_ptr->csr_present;
if (csr_present & CP_PWRCYCLE)
break;
} while (getuptime(&t1)==OK && (t1-t0) < MICROS_TO_TICKS(100000));
} while (getuptime(&t1)==OK && (t1-t0) < micros_to_ticks(100000));
if (!(csr_present & CP_PWRCYCLE))
{

View File

@@ -14,10 +14,10 @@ d = ..
# programs, flags, etc.
MAKE = exec make
CC = exec cc
CPPFLAGS = -I$i -I../../kernel/arch/$(ARCH)/include
CPPFLAGS = -I$i
CFLAGS = $(CPPFLAGS)
LDFLAGS = -i
LIBS = -lsysutil -lsys -ltimers
LIBS = -lsys -ltimers
OBJ = tty.o console.o vidcopy.o keyboard.o pty.o rs232.o
@@ -25,7 +25,7 @@ OBJ = tty.o console.o vidcopy.o keyboard.o pty.o rs232.o
all build: $(DRIVER)
$(DRIVER): $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
install -S 8k $(DRIVER)
install -S 16k $(DRIVER)
# install with other drivers
install:

View File

@@ -20,61 +20,27 @@
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/vm.h>
#include <sys/video.h>
#include <minix/tty.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/sys_config.h>
#include "tty.h"
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
/* Set this to 1 if you want console output duplicated on the first
* serial line.
*/
#define DUP_CONS_TO_SER 0
/* Definitions used by the console driver. */
#define MONO_BASE 0xB0000L /* base of mono video memory */
#define COLOR_BASE 0xB8000L /* base of color video memory */
#define MONO_SIZE 0x1000 /* 4K mono video memory */
#define COLOR_SIZE 0x4000 /* 16K color video memory */
#define EGA_SIZE 0x8000 /* EGA & VGA have at least 32K */
#define BLANK_COLOR 0x0700 /* determines cursor color on blank screen */
#define SCROLL_UP 0 /* scroll forward */
#define SCROLL_DOWN 1 /* scroll backward */
#define BLANK_MEM ((u16_t *) 0) /* tells mem_vid_copy() to blank the screen */
#define CONS_RAM_WORDS 80 /* video ram buffer size */
#define MAX_ESC_PARMS 4 /* number of escape sequence params allowed */
/* Constants relating to the controller chips. */
#define M_6845 0x3B4 /* port for 6845 mono */
#define C_6845 0x3D4 /* port for 6845 color */
#define INDEX 0 /* 6845's index register */
#define DATA 1 /* 6845's data register */
#define STATUS 6 /* 6845's status register */
#define VID_ORG 12 /* 6845's origin register */
#define CURSOR 14 /* 6845's cursor register */
/* The clock task should provide an interface for this */
#define TIMER_FREQ 1193182L /* clock frequency for timer in PC and AT */
/* Beeper. */
#define BEEP_FREQ 0x0533 /* value to put into timer to set beep freq */
#define B_TIME 3 /* length of CTRL-G beep is ticks */
/* definitions used for font management */
#define GA_SEQUENCER_INDEX 0x3C4
#define GA_SEQUENCER_DATA 0x3C5
#define GA_GRAPHICS_INDEX 0x3CE
#define GA_GRAPHICS_DATA 0x3CF
#define GA_VIDEO_ADDRESS 0xA0000L
#define GA_FONT_SIZE 8192
/* Global variables used by the console driver and assembly support. */
PUBLIC int vid_index; /* index of video segment in remote mem map */
PUBLIC u16_t vid_seg;
PUBLIC vir_bytes vid_off; /* video ram is found at vid_seg:vid_off */
PUBLIC unsigned vid_size; /* 0x2000 for color or 0x0800 for mono */
PUBLIC phys_bytes vid_size; /* 0x2000 for color or 0x0800 for mono */
PUBLIC phys_bytes vid_base;
PUBLIC unsigned vid_mask; /* 0x1FFF for color or 0x07FF for mono */
PUBLIC unsigned blank_color = BLANK_COLOR; /* display code for blank */
@@ -87,6 +53,7 @@ PRIVATE unsigned font_lines; /* font lines per character */
PRIVATE unsigned scr_width; /* # characters on a line */
PRIVATE unsigned scr_lines; /* # lines on the screen */
PRIVATE unsigned scr_size; /* # characters on the screen */
PUBLIC unsigned info_location; /* location in video memory of struct */
PRIVATE int disabled_vc = -1; /* Virtual console that was active when
* disable_console was called.
@@ -95,6 +62,9 @@ PRIVATE int disabled_sm; /* Scroll mode to be restored when re-enabling
* console
*/
/* boot_tty_info we use to communicate with the boot code. */
struct boot_tty_info boot_tty_info;
/* Per console data. */
typedef struct console {
tty_t *c_tty; /* associated TTY struct */
@@ -113,11 +83,34 @@ typedef struct console {
int *c_esc_parmp; /* pointer to current escape parameter */
int c_esc_parmv[MAX_ESC_PARMS]; /* list of escape parameters */
u16_t c_ramqueue[CONS_RAM_WORDS]; /* buffer for video RAM */
int c_line; /* line no */
} console_t;
#define UPDATEBOOTINFO(ccons, infofield, value) { \
if(ccons->c_line == 0) { \
boot_tty_info.infofield = value; \
mem_vid_copy((u16_t *) &boot_tty_info, \
info_location/2, sizeof(boot_tty_info)/2); \
} \
}
#define UPDATE_CURSOR(ccons, cursor) { \
ccons->c_cur = cursor; \
UPDATEBOOTINFO(ccons, conscursor, ccons->c_cur); \
if(curcons && ccons == curcons) \
set_6845(CURSOR, ccons->c_cur); \
}
#define UPDATE_ORIGIN(ccons, origin) { \
ccons->c_org = origin; \
UPDATEBOOTINFO(ccons, consorigin, ccons->c_org); \
if (curcons && ccons == curcons) \
set_6845(VID_ORG, ccons->c_org); \
}
PRIVATE int nr_cons= 1; /* actual number of consoles */
PRIVATE console_t cons_table[NR_CONS];
PRIVATE console_t *curcons; /* currently visible */
PRIVATE console_t *curcons = NULL; /* currently visible */
/* Color if using a color controller. */
#define color (vid_port == C_6845)
@@ -142,14 +135,20 @@ FORWARD _PROTOTYPE( void flush, (console_t *cons) );
FORWARD _PROTOTYPE( void parse_escape, (console_t *cons, int c) );
FORWARD _PROTOTYPE( void scroll_screen, (console_t *cons, int dir) );
FORWARD _PROTOTYPE( void set_6845, (int reg, unsigned val) );
FORWARD _PROTOTYPE( void get_6845, (int reg, unsigned *val) );
FORWARD _PROTOTYPE( void stop_beep, (timer_t *tmrp) );
FORWARD _PROTOTYPE( void cons_org0, (void) );
FORWARD _PROTOTYPE( void disable_console, (void) );
FORWARD _PROTOTYPE( void reenable_console, (void) );
FORWARD _PROTOTYPE( int ga_program, (struct sequence *seq) );
FORWARD _PROTOTYPE( int cons_ioctl, (tty_t *tp, int) );
#if DUP_CONS_TO_SER
FORWARD _PROTOTYPE( void ser_putc, (char c) );
#endif
#if 0
FORWARD _PROTOTYPE( void get_6845, (int reg, unsigned *val) );
#endif
/*===========================================================================*
* cons_write *
@@ -174,7 +173,7 @@ int try;
/* Check quickly for nothing to do, so this can be called often without
* unmodular tests elsewhere.
*/
if ((count = tp->tty_outleft) == 0 || tp->tty_inhibited) return;
if ((count = tp->tty_outleft) == 0 || tp->tty_inhibited) return 0;
/* Copy the user bytes to buf[] for decent addressing. Loop over the
* copies, since the user buffer may be much larger than buf[].
@@ -228,6 +227,8 @@ int try;
tp->tty_outcum);
tp->tty_outcum = 0;
}
return 0;
}
/*===========================================================================*
@@ -365,9 +366,9 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
} else
if (!wrap && cons->c_org + scr_size + scr_width >= cons->c_limit) {
vid_vid_copy(cons->c_org + scr_width, cons->c_start, chars);
cons->c_org = cons->c_start;
UPDATE_ORIGIN(cons, cons->c_start);
} else {
cons->c_org = (cons->c_org + scr_width) & vid_mask;
UPDATE_ORIGIN(cons, (cons->c_org + scr_width) & vid_mask);
}
new_line = (cons->c_org + chars) & vid_mask;
} else {
@@ -378,9 +379,9 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
if (!wrap && cons->c_org < cons->c_start + scr_width) {
new_org = cons->c_limit - scr_size;
vid_vid_copy(cons->c_org, new_org + scr_width, chars);
cons->c_org = new_org;
UPDATE_ORIGIN(cons, new_org);
} else {
cons->c_org = (cons->c_org - scr_width) & vid_mask;
UPDATE_ORIGIN(cons, (cons->c_org - scr_width) & vid_mask);
}
new_line = cons->c_org;
}
@@ -388,8 +389,6 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
blank_color = cons->c_blank;
mem_vid_copy(BLANK_MEM, new_line, scr_width);
/* Set the new video origin. */
if (cons == curcons) set_6845(VID_ORG, cons->c_org);
flush(cons);
}
@@ -421,10 +420,8 @@ register console_t *cons; /* pointer to console struct */
if (cons->c_row < 0) cons->c_row = 0;
if (cons->c_row >= scr_lines) cons->c_row = scr_lines - 1;
cur = cons->c_org + cons->c_row * scr_width + cons->c_column;
if (cur != cons->c_cur) {
if (cons == curcons) set_6845(CURSOR, cur);
cons->c_cur = cur;
}
if (cur != cons->c_cur)
UPDATE_CURSOR(cons, cur);
}
/*===========================================================================*
@@ -747,6 +744,7 @@ unsigned val; /* 16-bit value to set it to */
sys_voutb(char_out, 4); /* do actual output */
}
#if 0
/*===========================================================================*
* get_6845 *
*===========================================================================*/
@@ -765,6 +763,7 @@ unsigned *val; /* 16-bit value to set it to */
v2 = v;
*val = (v1 << 8) | v2;
}
#endif
/*===========================================================================*
* beep *
@@ -810,8 +809,7 @@ PRIVATE void beep()
*===========================================================================*/
PUBLIC void do_video(message *m)
{
int i, n, r, ops, watch, safe = 0;
unsigned char c;
int r, safe = 0;
/* Execute the requested device driver function. */
r= EINVAL; /* just in case */
@@ -827,8 +825,10 @@ PUBLIC void do_video(message *m)
break;
case DEV_IOCTL_S:
safe=1;
if (m->TTY_REQUEST == MIOCMAP || m->TTY_REQUEST == MIOCUNMAP)
{
switch(m->TTY_REQUEST) {
case MIOCMAP:
case MIOCUNMAP: {
#if 0
int r, do_map;
struct mapreq mapreq;
@@ -859,8 +859,50 @@ PUBLIC void do_video(message *m)
r= sys_vm_map(safe ? m->POSITION : m->IO_ENDPT,
do_map, (phys_bytes)mapreq.base, mapreq.size,
mapreq.offset);
#else
r = ENOSYS;
printf("tty: %ld used old MIOCMAP interface\n",
safe ? m->POSITION : m->IO_ENDPT);
#endif
tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT, r);
return;
}
case TIOCMAPMEM:
case TIOCUNMAPMEM: {
int r, do_map;
struct mapreqvm mapreqvm;
void *result;
do_map= (m->REQUEST == TIOCMAPMEM); /* else unmap */
/* Get request structure */
if(safe) {
r = sys_safecopyfrom(m->IO_ENDPT,
(vir_bytes)m->ADDRESS, 0, (vir_bytes) &mapreqvm,
sizeof(mapreqvm), D);
} else {
r= sys_vircopy(m->IO_ENDPT, D,
(vir_bytes)m->ADDRESS,
SELF, D, (vir_bytes)&mapreqvm,sizeof(mapreqvm));
}
if (r != OK)
{
tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT,
r);
return;
}
/* In safe ioctl mode, the POSITION field contains
* the endpt number of the original requestor.
* IO_ENDPT is always FS.
*/
if(do_map) {
} else {
}
tty_reply(TASK_REPLY, m->m_source, m->IO_ENDPT, r);
return;
}
}
r= ENOTTY;
break;
@@ -940,19 +982,19 @@ tty_t *tp;
{
/* Initialize the screen driver. */
console_t *cons;
phys_bytes vid_base;
u16_t bios_columns, bios_crtbase, bios_fontlines;
u8_t bios_rows;
int line;
int s;
static int vdu_initialized = 0;
unsigned page_size;
static unsigned page_size;
/* Associate console and TTY. */
line = tp - &tty_table[0];
if (line >= nr_cons) return;
cons = &cons_table[line];
cons->c_tty = tp;
cons->c_line = line;
tp->tty_priv = cons;
/* Fill in TTY function hooks. */
@@ -987,6 +1029,7 @@ tty_t *tp;
}
if (machine.vdu_ega) vid_size = EGA_SIZE;
wrap = ! machine.vdu_ega;
info_location = vid_size - sizeof(struct boot_tty_info);
s = sys_segctl(&vid_index, &vid_seg, &vid_off, vid_base, vid_size);
@@ -997,7 +1040,8 @@ tty_t *tp;
scr_size = scr_lines * scr_width;
/* There can be as many consoles as video memory allows. */
nr_cons = vid_size / scr_size;
nr_cons = (vid_size - sizeof(struct boot_tty_info)/2) / scr_size;
if (nr_cons > NR_CONS) nr_cons = NR_CONS;
if (nr_cons > 1) wrap = 0;
page_size = vid_size / nr_cons;
@@ -1013,13 +1057,18 @@ tty_t *tp;
blank_color = BLANK_COLOR;
mem_vid_copy(BLANK_MEM, cons->c_start, scr_size);
} else {
int i, n;
/* Set the cursor of the console vty at the bottom. c_cur
* is updated automatically later.
*/
scroll_screen(cons, SCROLL_UP);
cons->c_row = scr_lines - 1;
cons->c_column = 0;
memset(&boot_tty_info, 0, sizeof(boot_tty_info));
UPDATE_CURSOR(cons, cons->c_cur);
UPDATE_ORIGIN(cons, cons->c_org);
boot_tty_info.flags = BTIF_CONSCURSOR | BTIF_CONSORIGIN;
boot_tty_info.magic = TTYMAGIC;
}
select_console(0);
cons_ioctl(tp, 0);
@@ -1045,9 +1094,9 @@ int c;
cons_putk(c);
if (c != 0) {
kmess.km_buf[kmess.km_next] = c; /* put normal char in buffer */
if (kmess.km_size < KMESS_BUF_SIZE)
if (kmess.km_size < _KMESS_BUF_SIZE)
kmess.km_size += 1;
kmess.km_next = (kmess.km_next + 1) % KMESS_BUF_SIZE;
kmess.km_next = (kmess.km_next + 1) % _KMESS_BUF_SIZE;
} else {
notify(LOG_PROC_NR);
}
@@ -1060,9 +1109,8 @@ PUBLIC void do_new_kmess(m)
message *m;
{
/* Notification for a new kernel message. */
struct kmessages kmess; /* kmessages structure */
static struct kmessages kmess; /* kmessages structure */
static int prev_next = 0; /* previous next seen */
int size, next;
int bytes;
int r;
@@ -1081,15 +1129,15 @@ message *m;
/* Print only the new part. Determine how many new bytes there are with
* help of the current and previous 'next' index. Note that the kernel
* buffer is circular. This works fine if less then KMESS_BUF_SIZE bytes
* is new data; else we miss % KMESS_BUF_SIZE here.
* buffer is circular. This works fine if less then _KMESS_BUF_SIZE bytes
* is new data; else we miss % _KMESS_BUF_SIZE here.
* Check for size being positive, the buffer might as well be emptied!
*/
if (kmess.km_size > 0) {
bytes = ((kmess.km_next + KMESS_BUF_SIZE) - prev_next) % KMESS_BUF_SIZE;
bytes = ((kmess.km_next + _KMESS_BUF_SIZE) - prev_next) % _KMESS_BUF_SIZE;
r=prev_next; /* start at previous old */
while (bytes > 0) {
cons_putk( kmess.km_buf[(r%KMESS_BUF_SIZE)] );
cons_putk( kmess.km_buf[(r%_KMESS_BUF_SIZE)] );
bytes --;
r ++;
}
@@ -1121,6 +1169,8 @@ int safe;
int r;
if(safe) {
r = sys_safecopyfrom(proc_nr, src, offset, (vir_bytes) &c, 1, D);
if(r != OK)
printf("<tty: proc %d, grant %ld>", proc_nr, src);
} else {
r = sys_vircopy(proc_nr, D, src+offset, SELF, D, (vir_bytes) &c, 1);
}
@@ -1132,9 +1182,12 @@ int safe;
cons_putk(c);
}
cons_putk(0); /* always terminate, even with EFAULT */
m_ptr->m_type = DIAG_REPL;
m_ptr->REP_STATUS = result;
send(m_ptr->m_source, m_ptr);
if(m_ptr->m_type != ASYN_DIAGNOSTICS) {
m_ptr->m_type = DIAG_REPL;
m_ptr->REP_STATUS = result;
send(m_ptr->m_source, m_ptr);
}
}
/*===========================================================================*
@@ -1237,7 +1290,7 @@ PRIVATE void cons_org0()
if (n > cons->c_org - cons->c_start)
n = cons->c_org - cons->c_start;
vid_vid_copy(cons->c_org, cons->c_org - n, scr_size);
cons->c_org -= n;
UPDATE_ORIGIN(cons, cons->c_org - n);
}
flush(cons);
}
@@ -1283,10 +1336,12 @@ PUBLIC void select_console(int cons_line)
/* Set the current console to console number 'cons_line'. */
if (cons_line < 0 || cons_line >= nr_cons) return;
ccurrent = cons_line;
curcons = &cons_table[cons_line];
set_6845(VID_ORG, curcons->c_org);
set_6845(CURSOR, curcons->c_cur);
UPDATE_CURSOR(curcons, curcons->c_cur);
UPDATE_ORIGIN(curcons, curcons->c_org);
}
/*===========================================================================*
@@ -1358,8 +1413,11 @@ int try;
tp->tty_winsize.ws_col= scr_width;
tp->tty_winsize.ws_xpixel= scr_width * 8;
tp->tty_winsize.ws_ypixel= scr_lines * font_lines;
return 0;
}
#if DUP_CONS_TO_SER
#define COM1_BASE 0x3F8
#define COM1_THR (COM1_BASE + 0)
#define LSR_THRE 0x20
@@ -1381,3 +1439,4 @@ PRIVATE void ser_putc(char c)
}
sys_outb(thr, c);
}
#endif

View File

@@ -14,16 +14,11 @@
#include <termios.h>
#include <signal.h>
#include <unistd.h>
#include <archtypes.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/keymap.h>
#include "tty.h"
#include "keymaps/us-std.src"
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
#include "../../kernel/proc.h"
int irq_hook_id = -1;
int aux_irq_hook_id = -1;
@@ -132,10 +127,9 @@ PRIVATE struct kbd_outack
PRIVATE int kbd_watchdog_set= 0;
PRIVATE int kbd_alive= 1;
PRIVATE int sticky_alt_mode = 0;
PRIVATE timer_t tmr_kbd_wd;
int sticky_alt_mode = 0;
FORWARD _PROTOTYPE( void handle_req, (struct kbd *kbdp, message *m) );
FORWARD _PROTOTYPE( int handle_status, (struct kbd *kbdp, message *m) );
FORWARD _PROTOTYPE( void kbc_cmd0, (int cmd) );
@@ -153,6 +147,13 @@ FORWARD _PROTOTYPE( int kb_read, (struct tty *tp, int try) );
FORWARD _PROTOTYPE( unsigned map_key, (int scode) );
FORWARD _PROTOTYPE( void kbd_watchdog, (timer_t *tmrp) );
int micro_delay(u32_t usecs)
{
/* TTY can't use the library micro_delay() as that calls PM. */
tickdelay(micros_to_ticks(usecs));
return OK;
}
/*===========================================================================*
* do_kbd *
*===========================================================================*/
@@ -500,7 +501,6 @@ message *m_ptr;
int o, isaux;
unsigned char scode;
struct kbd *kbdp;
static timer_t timer; /* timer must be static! */
/* Fetch the character from the keyboard hardware and acknowledge it. */
if (!scan_keyboard(&scode, &isaux))
@@ -637,7 +637,7 @@ PRIVATE void kbd_send()
}
if (sb & (KB_OUT_FULL|KB_IN_FULL))
{
printf("not sending 1: sb = 0x%x\n", sb);
printf("not sending 1: sb = 0x%lx\n", sb);
return;
}
micro_delay(KBC_IN_DELAY);
@@ -646,7 +646,7 @@ PRIVATE void kbd_send()
}
if (sb & (KB_OUT_FULL|KB_IN_FULL))
{
printf("not sending 2: sb = 0x%x\n", sb);
printf("not sending 2: sb = 0x%lx\n", sb);
return;
}
@@ -864,10 +864,10 @@ PRIVATE int kbc_read()
while (micro_elapsed(&ms) < 1000000);
#endif
panic("TTY", "kbc_read failed to complete", NO_NUM);
return EINVAL;
}
/*===========================================================================*
* kb_wait *
*===========================================================================*/
@@ -876,7 +876,7 @@ PRIVATE int kb_wait()
/* Wait until the controller is ready; return zero if this times out. */
int retries;
unsigned long status, temp;
unsigned long status;
int s, isaux;
unsigned char byte;
@@ -940,6 +940,12 @@ PUBLIC void kb_init_once(void)
{
int i;
u8_t ccb;
char env[100];
if(env_get_param("sticky_alt", env, sizeof(env)-1) == OK
&& atoi(env) == 1) {
sticky_alt_mode = 1;
}
set_leds(); /* turn off numlock led */
scan_keyboard(NULL, NULL); /* discard leftover keystroke */
@@ -1020,7 +1026,7 @@ message *m_ptr; /* pointer to the request message */
* notifications if it is pressed. At most one binding per key can exist.
*/
int i;
int result;
int result = EINVAL;
switch (m_ptr->FKEY_REQUEST) { /* see what we must do */
case FKEY_MAP: /* request for new mapping */
@@ -1104,8 +1110,6 @@ message *m_ptr; /* pointer to the request message */
}
}
break;
default:
result = EINVAL; /* key cannot be observed */
}
/* Almost done, return result to caller. */
@@ -1128,7 +1132,6 @@ int scode; /* scan code for a function key */
message m;
int key;
int proc_nr;
int i,s;
/* Ignore key releases. If this is a key press, get full key code. */
if (scode & KEY_RELEASE) return(FALSE); /* key release */
@@ -1166,31 +1169,17 @@ int scode; /* scan code for a function key */
*===========================================================================*/
PRIVATE void show_key_mappings()
{
int i,s;
struct proc proc;
int i;
printf("\n");
printf("System information. Known function key mappings to request debug dumps:\n");
printf("-------------------------------------------------------------------------\n");
for (i=0; i<12; i++) {
printf(" %sF%d: ", i+1<10? " ":"", i+1);
if (fkey_obs[i].proc_nr != NONE) {
if ((s=sys_getproc(&proc, fkey_obs[i].proc_nr))!=OK)
printf("sys_getproc: %d\n", s);
printf("%-14.14s", proc.p_name);
} else {
printf("%-14.14s", "<none>");
}
printf("%-14.14s", "<none>");
printf(" %sShift-F%d: ", i+1<10? " ":"", i+1);
if (sfkey_obs[i].proc_nr != NONE) {
if ((s=sys_getproc(&proc, sfkey_obs[i].proc_nr))!=OK)
printf("sys_getproc: %d\n", s);
printf("%-14.14s", proc.p_name);
} else {
printf("%-14.14s", "<none>");
}
printf("%-14.14s", "<none>");
printf("\n");
}
printf("\n");
@@ -1260,12 +1249,6 @@ int *isauxp;
#endif
}
int micro_delay(u32_t usecs)
{
tickdelay(MICROS_TO_TICKS(usecs));
return OK;
}
/*===========================================================================*
* kbd_watchdog *
*===========================================================================*/

View File

@@ -4,8 +4,8 @@ LK = /usr/lib/keymaps
.SUFFIXES: .src .map
.src.map:
$(CC) -DKEYSRC=\"$<\" $(CPROFILE) genmap.c -lsysutil -lsys
.src.map:
$(CC) -DKEYSRC=\"$<\" genmap.c
./a.out > $@
@rm -f a.out

View File

@@ -89,7 +89,6 @@ message *m_ptr;
/* Perform an open/close/read/write call on a /dev/ptypX device. */
pty_t *pp = tp->tty_priv;
int r;
phys_bytes p;
int safe = 0;
switch (m_ptr->m_type) {
@@ -108,15 +107,6 @@ message *m_ptr;
r = EINVAL;
break;
}
#if DEAD_CODE
if (numap_local(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS,
m_ptr->COUNT) == 0) {
#else
if ((r = sys_umap(m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS,
m_ptr->COUNT, &p)) != OK) {
#endif
break;
}
pp->rdsendreply = TRUE;
pp->rdcaller = m_ptr->m_source;
pp->rdproc = m_ptr->IO_ENDPT;
@@ -130,12 +120,6 @@ message *m_ptr;
return; /* already done */
}
#if DEAD_CODE
if (m_ptr->TTY_FLAGS & O_NONBLOCK) {
r = EAGAIN; /* don't suspend */
pp->rdleft = pp->rdcum = 0;
} else
#endif
{
r = SUSPEND; /* do suspend */
pp->rdsendreply = FALSE;
@@ -157,16 +141,6 @@ message *m_ptr;
r = EINVAL;
break;
}
#if DEAD_CODE
if (numap_local(m_ptr->IO_ENDPT, (vir_bytes) m_ptr->ADDRESS,
m_ptr->COUNT) == 0) {
r = EFAULT;
#else
if ((r = sys_umap(m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr->ADDRESS,
m_ptr->COUNT, &p)) != OK) {
#endif
break;
}
pp->wrsendreply = TRUE;
pp->wrcaller = m_ptr->m_source;
pp->wrproc = m_ptr->IO_ENDPT;
@@ -179,12 +153,6 @@ message *m_ptr;
return; /* already done */
}
#if DEAD_CODE
if (m_ptr->TTY_FLAGS & O_NONBLOCK) { /* don't suspend */
r = pp->wrcum > 0 ? pp->wrcum : EAGAIN;
pp->wrleft = pp->wrcum = 0;
} else
#endif
{
pp->wrsendreply = FALSE; /* do suspend */
r = SUSPEND;
@@ -244,7 +212,7 @@ int try;
*/
pty_t *pp = tp->tty_priv;
int count, ocount, s;
phys_bytes user_phys;
/* PTY closed down? */
if (pp->state & PTY_CLOSED) {
@@ -259,7 +227,7 @@ int try;
tp->tty_outleft = tp->tty_outcum = 0;
}
}
return;
return 0;
}
/* While there is something to do. */
@@ -473,6 +441,8 @@ int try;
notify(pp->wrcaller);
}
}
return 0;
}
/*===========================================================================*
@@ -485,7 +455,7 @@ int try;
/* The tty side has closed, so shut down the pty side. */
pty_t *pp = tp->tty_priv;
if (!(pp->state & PTY_ACTIVE)) return;
if (!(pp->state & PTY_ACTIVE)) return 0;
if (pp->rdleft > 0) {
assert(!pp->rdsendreply);
@@ -498,6 +468,8 @@ int try;
}
if (pp->state & PTY_CLOSED) pp->state = 0; else pp->state |= TTY_CLOSED;
return 0;
}
/*===========================================================================*
@@ -515,6 +487,8 @@ int try;
pp->wrleft= 0;
notify(pp->wrcaller);
}
return 0;
}
/*===========================================================================*
@@ -529,6 +503,8 @@ int try;
pp->ocount = 0;
pp->otail = pp->ohead;
return 0;
}
/*===========================================================================*

View File

@@ -11,21 +11,6 @@
#if NR_RS_LINES > 0
#if (MACHINE != IBM_PC) && (MACHINE != ATARI)
#error /* rs232.c only supports PC and Atari ST */
#endif
#if (MACHINE == ATARI)
#include "staddr.h"
#include "stsound.h"
#include "stmfp.h"
#if (NR_RS_LINES > 1)
#error /* Only one physical RS232 line available */
#endif
#endif
#if (MACHINE == IBM_PC) /* PC/AT 8250/16450 chip combination */
/* 8250 constants. */
#define UART_FREQ 115200L /* timer frequency */
@@ -65,46 +50,25 @@
#define MS_RLSD 0x80 /* Received Line Signal Detect */
#define MS_DRLSD 0x08 /* RLSD Delta */
#else /* MACHINE == ATARI */ /* Atari ST 68901 USART */
#define DATA_BITS_SHIFT 8 /* amount data bits shifted in mode */
#define DEF_BAUD 1200 /* default baud rate */
/* Most of the USART constants are already defined in stmfp.h . The local
* definitions made here are for keeping C code changes smaller. --kub
*/
#define UART_FREQ 19200L /* timer frequency */
/* Line status bits. */
#define LS_OVERRUN_ERR R_OE
#define LS_PARITY_ERR R_PE
#define LS_FRAMING_ERR R_FE
#define LS_BREAK_INTERRUPT R_BREAK
/* Modem status bits. */
#define MS_CTS IO_SCTS /* 0x04 */
#endif /* MACHINE == ATARI */
#define DATA_BITS_SHIFT 8 /* amount data bits shifted in mode */
#define DEF_BAUD 1200 /* default baud rate */
#define RS_IBUFSIZE 1024 /* RS232 input buffer size */
#define RS_OBUFSIZE 1024 /* RS232 output buffer size */
#define RS_IBUFSIZE 1024 /* RS232 input buffer size */
#define RS_OBUFSIZE 1024 /* RS232 output buffer size */
/* Input buffer watermarks.
* The external device is asked to stop sending when the buffer
* exactly reaches high water, or when TTY requests it. Sending restarts
* when the input buffer empties below the low watermark.
*/
#define RS_ILOWWATER (1 * RS_IBUFSIZE / 4)
#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4)
#define RS_ILOWWATER (1 * RS_IBUFSIZE / 4)
#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4)
/* Output buffer low watermark.
* TTY is notified when the output buffer empties below the low watermark, so
* it may continue filling the buffer if doing a large write.
*/
#define RS_OLOWWATER (1 * RS_OBUFSIZE / 4)
#if (MACHINE == IBM_PC)
#define RS_OLOWWATER (1 * RS_OBUFSIZE / 4)
/* Macros to handle flow control.
* Interrupts must be off when they are used.
@@ -141,36 +105,6 @@
#define devhup(rs) \
((my_inb(rs->modem_status_port) & (MS_RLSD|MS_DRLSD)) == MS_DRLSD)
#else /* MACHINE == ATARI */
/* Macros to handle flow control.
* Time is critical - already the function call for lock()/restore() is
* annoying.
* istart() tells external device we are ready by raising RTS.
* istop() tells external device we are not ready by dropping RTS.
* DTR is kept high all the time (it probably should be raised by open and
* dropped by close of the device). NOTE: The modem lines are active low.
*/
#define set_porta(msk,val) { register int s = lock(); \
SOUND->sd_selr = YM_IOA; \
SOUND->sd_wdat = \
SOUND->sd_rdat & (msk) | (val); \
restore(s); }
#define istart(rs) { set_porta( ~(PA_SRTS|PA_SDTR),0 ); \
(rs)->idevready = TRUE; }
#define istop(rs) { set_porta( ~PA_SDTR, PA_SRTS ); \
(rs)->idevready = FALSE; }
/* Macro to tell if device is ready. The rs->cts field is set to MS_CTS if
* CLOCAL is in effect for a line without a CTS wire.
*/
#define devready(rs) ((~MFP->mf_gpip | rs->cts) & MS_CTS)
/* Transmitter ready test */
#define txready(rs) (MFP->mf_tsr & (T_EMPTY | T_UE))
#endif /* MACHINE == ATARI */
/* Types. */
typedef unsigned char bool_t; /* boolean */
@@ -234,11 +168,6 @@ typedef struct rs232 {
PUBLIC rs232_t rs_lines[NR_RS_LINES];
/* Table and macro to translate an RS232 line number to its rs_lines entry. */
PRIVATE rs232_t *p_rs_addr[NR_RS_LINES];
#define rs_addr(line) (p_rs_addr[line])
#if (MACHINE == IBM_PC)
/* 8250 base addresses. */
PRIVATE port_t addr_8250[] = {
@@ -472,7 +401,6 @@ rs232_t *rs; /* which line */
}
if (divisor == 0) return; /* B0? */
#if (MACHINE == IBM_PC)
/* Compute line control flag bits. */
line_controls = 0;
if (tp->tty_termios.c_cflag & PARENB) {
@@ -502,27 +430,6 @@ rs232_t *rs; /* which line */
rs->ostate &= ~ORAW;
unlock();
#else /* MACHINE == ATARI */
line_controls = U_Q16;
if (tp->tty_termios.c_cflag & PARENB) {
line_controls |= U_PAR;
if (!(tp->tty_termios.c_cflag & PARODD)) line_controls |= U_EVEN;
}
line_controls |= (divisor >= (UART_FREQ / 110)) ? U_ST2 : U_ST1;
switch (tp->tty_termios.c_cflag & CSIZE) { /* XXX - are U_Dn like CSn? */
case CS5: line_controls |= U_D5; break;
case CS5: line_controls |= U_D6; break;
case CS5: line_controls |= U_D7; break;
case CS5: line_controls |= U_D8; break;
}
lock();
MFP->mf_ucr = line_controls;
MFP->mf_tddr = divisor;
unlock();
#endif /* MACHINE == ATARI */
}
/*===========================================================================*
@@ -536,11 +443,8 @@ tty_t *tp; /* which TTY */
register rs232_t *rs;
int line;
#if (MACHINE == IBM_PC)
port_t this_8250;
int irq;
long v;
#endif
/* Associate RS232 and TTY structures. */
line = tp - &tty_table[NR_CONS];
@@ -550,7 +454,6 @@ tty_t *tp; /* which TTY */
/* Set up input queue. */
rs->ihead = rs->itail = rs->ibuf;
#if (MACHINE == IBM_PC)
/* Precalculate port numbers for speed. Magic numbers in the code (once). */
this_8250 = addr_8250[line];
rs->xmit_port = this_8250 + 0;
@@ -563,7 +466,6 @@ tty_t *tp; /* which TTY */
rs->modem_ctl_port = this_8250 + 4;
rs->line_status_port = this_8250 + 5;
rs->modem_status_port = this_8250 + 6;
#endif
/* Set up the hardware to a base state, in particular
* o turn off DTR (MC_DTR) to try to stop the external device.
@@ -580,22 +482,17 @@ tty_t *tp; /* which TTY */
*/
istop(rs); /* sets modem_ctl_port */
rs_config(rs);
#if (MACHINE == IBM_PC)
sys_outb(rs->int_enab_port, 0);
#endif
/* Clear any harmful leftover interrupts. An output interrupt is harmless
* and will occur when interrupts are enabled anyway. Set up the output
* queue using the status from clearing the modem status interrupt.
*/
#if (MACHINE == IBM_PC)
sys_inb(rs->line_status_port, &dummy);
sys_inb(rs->recv_port, &dummy);
#endif
rs->ostate = devready(rs) | ORAW | OSWREADY; /* reads modem_ctl_port */
rs->ohead = rs->otail = rs->obuf;
#if (MACHINE == IBM_PC)
/* Enable interrupts for both interrupt controller and device. */
irq = (line & 1) == 0 ? RS232_IRQ : SECONDARY_IRQ;
@@ -613,20 +510,6 @@ tty_t *tp; /* which TTY */
sys_outb(rs->int_enab_port, IE_LINE_STATUS_CHANGE | IE_MODEM_STATUS_CHANGE
| IE_RECEIVER_READY | IE_TRANSMITTER_READY);
#else /* MACHINE == ATARI */
/* Initialize the 68901 chip, then enable interrupts. */
MFP->mf_scr = 0x00;
MFP->mf_tcdcr |= T_Q004;
MFP->mf_rsr = R_ENA;
MFP->mf_tsr = T_ENA;
MFP->mf_aer = (MFP->mf_aer | (IO_SCTS|IO_SDCD)) ^
(MFP->mf_gpip & (IO_SCTS|IO_SDCD));
MFP->mf_ddr = (MFP->mf_ddr & ~ (IO_SCTS|IO_SDCD));
MFP->mf_iera |= (IA_RRDY|IA_RERR|IA_TRDY|IA_TERR);
MFP->mf_imra |= (IA_RRDY|IA_RERR|IA_TRDY|IA_TERR);
MFP->mf_ierb |= (IB_SCTS|IB_SDCD);
MFP->mf_imrb |= (IB_SCTS|IB_SDCD);
#endif /* MACHINE == ATARI */
/* Fill in TTY function hooks. */
tp->tty_devread = rs_read;
@@ -721,7 +604,7 @@ int try;
if (ostate & ODEVHUP) {
sigchar(tp, SIGHUP);
tp->tty_termios.c_ospeed = B0; /* Disable further I/O. */
return;
return 0;
}
}
@@ -744,6 +627,8 @@ int try;
unlock();
if ((rs->itail += count) == bufend(rs->ibuf)) rs->itail = rs->ibuf;
}
return 0;
}
/*===========================================================================*
@@ -787,7 +672,6 @@ int dummy;
{
/* The line is closed; optionally hang up. */
rs232_t *rs = tp->tty_priv;
int r;
if (tp->tty_termios.c_cflag & HUPCL) {
sys_outb(rs->modem_ctl_port, MC_OUT2 | MC_RTS);
@@ -797,7 +681,6 @@ int dummy;
/* Low level (interrupt) routines. */
#if (MACHINE == IBM_PC)
/*===========================================================================*
* rs232_handler *
*===========================================================================*/
@@ -831,50 +714,6 @@ struct rs232 *rs;
return;
}
}
#endif /* MACHINE == IBM_PC */
#if (MACHINE == ATARI)
/*===========================================================================*
* siaint *
*===========================================================================*/
PRIVATE void siaint(type)
int type; /* interrupt type */
{
/* siaint is the rs232 interrupt procedure for Atari ST's. For ST there are
* as much as 5 interrupt lines used for rs232. The trap type byte left on the
* stack by the assembler interrupt handler identifies the interrupt cause.
*/
register unsigned char code;
register rs232_t *rs = &rs_lines[0];
int s = lock();
switch (type & 0x00FF)
{
case 0x00: /* receive buffer full */
in_int(rs);
break;
case 0x01: /* receive error */
line_int(rs);
break;
case 0x02: /* transmit buffer empty */
out_int(rs);
break;
case 0x03: /* transmit error */
code = MFP->mf_tsr;
if (code & ~(T_ENA | T_UE | T_EMPTY))
{
printf("sia: transmit error: status=%x\r\n", code);
/* MFP->mf_udr = lastchar; */ /* retry */
}
break;
case 0x04: /* modem lines change */
modem_int(rs);
break;
}
restore(s);
}
#endif /* MACHINE == ATARI */
/*===========================================================================*
* in_int *
@@ -895,11 +734,7 @@ register rs232_t *rs; /* line with input interrupt */
return;
#endif
#if (MACHINE == IBM_PC)
sys_inb(rs->recv_port, &c);
#else /* MACHINE == ATARI */
c = MFP->mf_udr;
#endif
if (!(rs->ostate & ORAW)) {
if (c == rs->oxoff) {
@@ -937,14 +772,8 @@ register rs232_t *rs; /* line with line status interrupt */
/* Check for and record errors. */
unsigned long s;
#if (MACHINE == IBM_PC)
sys_inb(rs->line_status_port, &s);
rs->lstatus = s;
#else /* MACHINE == ATARI */
rs->lstatus = MFP->mf_rsr;
MFP->mf_rsr &= R_ENA;
rs->pad = MFP->mf_udr; /* discard char in case of LS_OVERRUN_ERR */
#endif /* MACHINE == ATARI */
if (rs->lstatus & LS_FRAMING_ERR) ++rs->framing_errors;
if (rs->lstatus & LS_OVERRUN_ERR) ++rs->overrun_errors;
if (rs->lstatus & LS_PARITY_ERR) ++rs->parity_errors;
@@ -961,12 +790,6 @@ register rs232_t *rs; /* line with modem interrupt */
* If the device just became ready, restart output.
*/
#if (MACHINE == ATARI)
/* Set active edge interrupt so that next change causes a new interrupt */
MFP->mf_aer = (MFP->mf_aer | (IO_SCTS|IO_SDCD)) ^
(MFP->mf_gpip & (IO_SCTS|IO_SDCD));
#endif
if (devhup(rs)) {
rs->ostate |= ODEVHUP;
rs->tty->tty_events = 1;
@@ -994,11 +817,7 @@ register rs232_t *rs; /* line with output interrupt */
if (rs->ostate >= (ODEVREADY | OQUEUED | OSWREADY)) {
/* Bit test allows ORAW and requires the others. */
#if (MACHINE == IBM_PC)
sys_outb(rs->xmit_port, *rs->otail);
#else /* MACHINE == ATARI */
MFP->mf_udr = *rs->otail;
#endif
if (++rs->otail == bufend(rs->obuf)) rs->otail = rs->obuf;
if (--rs->ocount == 0) {
rs->ostate ^= (ODONE | OQUEUED); /* ODONE on, OQUEUED off */

View File

@@ -61,9 +61,9 @@
#include <sys/ioc_tty.h>
#include <signal.h>
#include <minix/callnr.h>
#if (CHIP == INTEL)
#include <minix/sys_config.h>
#include <minix/tty.h>
#include <minix/keymap.h>
#endif
#include "tty.h"
#include <sys/time.h>
@@ -92,6 +92,7 @@ unsigned long rs_irq_set = 0;
#if NR_RS_LINES == 0
#define rs_init(tp) ((void) 0)
#endif
#if NR_PTYS == 0
#define pty_init(tp) ((void) 0)
#define do_pty(tp, mp) ((void) 0)
@@ -138,17 +139,21 @@ PUBLIC timer_t *tty_timers; /* queue of TTY timers */
PUBLIC clock_t tty_next_timeout; /* time that the next alarm is due */
PUBLIC struct machine machine; /* kernel environment variables */
extern PUBLIC unsigned info_location;
extern PUBLIC phys_bytes vid_size; /* 0x2000 for color or 0x0800 for mono */
extern PUBLIC phys_bytes vid_base;
/*===========================================================================*
* tty_task *
*===========================================================================*/
PUBLIC void main(void)
PUBLIC int main(void)
{
/* Main routine of the terminal task. */
message tty_mess; /* buffer for all incoming messages */
unsigned line;
int r, s;
register struct proc *rp;
register tty_t *tp;
/* Get kernel environment (protected_mode, pc_at and ega are needed). */
@@ -162,9 +167,8 @@ PUBLIC void main(void)
/* Final one-time keyboard initialization. */
kb_init_once();
printf("\n");
while (TRUE) {
int adflag = 0;
/* Check for and handle any events on any of the ttys. */
for (tp = FIRST_TTY; tp < END_TTY; tp++) {
@@ -212,14 +216,16 @@ PUBLIC void main(void)
continue;
}
case DIAGNOSTICS: /* a server wants to print some */
#if 0
if (tty_mess.m_source != LOG_PROC_NR)
{
printf("WARNING: old DIAGNOSTICS from %d\n",
tty_mess.m_source);
printf("[%d ", tty_mess.m_source);
}
#endif
do_diagnostics(&tty_mess, 0);
continue;
case DIAGNOSTICS_S:
case ASYN_DIAGNOSTICS:
do_diagnostics(&tty_mess, 1);
continue;
case GET_KMESS:
@@ -299,6 +305,8 @@ PUBLIC void main(void)
tty_mess.IO_ENDPT, EINVAL);
}
}
return 0;
}
/*===========================================================================*
@@ -397,7 +405,7 @@ register message *m_ptr; /* pointer to message sent to the task */
int safe; /* use safecopies? */
{
/* A process wants to read from a terminal. */
int r, status;
int r;
/* Check if there is already a process hanging in a read, check if the
* parameters are correct, do I/O.
@@ -775,9 +783,6 @@ message *m_ptr; /* pointer to message sent to task */
if ((mode & W_BIT) && tp->tty_outleft != 0 && proc_nr == tp->tty_outproc &&
(!tp->tty_out_safe || tp->tty_out_vir_g==(vir_bytes)m_ptr->IO_GRANT)) {
/* Process was writing when killed. Clean up output. */
#if DEAD_CODE
(*tp->tty_ocancel)(tp, 0);
#endif
r = tp->tty_outcum > 0 ? tp->tty_outcum : EAGAIN;
tp->tty_outleft = tp->tty_outcum = tp->tty_outrevived = 0;
}
@@ -849,9 +854,6 @@ tty_t *tp; /* TTY to check for events. */
* messages (in proc.c). This is handled by explicitly checking each line
* for fresh input and completed output on each interrupt.
*/
char *buf;
unsigned count;
int status;
do {
tp->tty_events = 0;
@@ -989,7 +991,6 @@ int count; /* number of input characters */
int ch, sig, ct;
int timeset = FALSE;
static unsigned char csize_mask[] = { 0x1F, 0x3F, 0x7F, 0xFF };
for (ct = 0; ct < count; ct++) {
/* Take one character. */
@@ -1373,7 +1374,7 @@ tty_t *tp;
* sure that an attribute change doesn't affect the processing of current
* output. Once output finishes the ioctl is executed as in do_ioctl().
*/
int result;
int result = EINVAL;
if (tp->tty_outleft > 0) return; /* output not finished */
@@ -1535,8 +1536,6 @@ PRIVATE void tty_init()
register tty_t *tp;
int s;
struct sigaction sa;
char env[100];
/* Initialize the terminal lines. */
for (tp = FIRST_TTY,s=0; tp < END_TTY; tp++,s++) {
@@ -1566,25 +1565,6 @@ PRIVATE void tty_init()
tp->tty_minor = s - (NR_CONS+NR_RS_LINES) + TTYPX_MINOR;
}
}
if(env_get_param("sticky_alt", env, sizeof(env)-1) == OK
&& atoi(env) == 1) {
sticky_alt_mode = 1;
}
#if DEAD_CODE
/* Install signal handlers. Ask PM to transform signal into message. */
sa.sa_handler = SIG_MESS;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction(SIGTERM,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
if (sigaction(SIGKMESS,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
if (sigaction(SIGKSTOP,&sa,NULL)<0) panic("TTY","sigaction failed", errno);
#endif
#if DEBUG
printf("end of tty_init\n");
#endif
}
/*===========================================================================*
@@ -1670,6 +1650,7 @@ tty_t *tp;
int try;
{
/* Some functions need not be implemented at the device level. */
return 0;
}
/*===========================================================================*

View File

@@ -1,8 +1,6 @@
/* tty.h - Terminals */
#include <timers.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#undef lock
#undef unlock
@@ -115,8 +113,6 @@ extern unsigned long rs_irq_set;
extern int panicing; /* From panic.c in sysutil */
extern int sticky_alt_mode; /* right-alt sticky to switch codepages */
/* Values for the fields. */
#define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */
#define ESCAPED 1 /* previous character was LNEXT (^V) */