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

@@ -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 */