* at_winchester_task: main entry when system is brought up
*
* Changes:
- * Aug 19, 2005 ata pci support, supports SATA (Ben Gras)
+ * Aug 19, 2005 ATA PCI support, supports SATA (Ben Gras)
* Nov 18, 2004 moved AT disk driver to user-space (Jorrit N. Herder)
* Aug 20, 2004 watchdogs replaced by sync alarms (Jorrit N. Herder)
* Mar 23, 2000 added ATAPI CDROM support (Michael Temari)
/* Variables. */
-/* wini is indexed by controller first, then drive (0-3).
- * controller 0 is always the 'compatability' ide controller, at
+/* The struct wini is indexed by controller first, then drive (0-3).
+ * Controller 0 is always the 'compatability' ide controller, at
* the fixed locations, whether present or not.
*/
PRIVATE struct wini { /* main drive struct, one entry per drive */
PRIVATE struct device *w_dv; /* device's base and size */
FORWARD _PROTOTYPE( void init_params, (void) );
-FORWARD _PROTOTYPE( void init_drive, (struct wini *, int, int, int, int, int, int));
+FORWARD _PROTOTYPE( void init_drive, (struct wini *, int, int, int,
+ int, int, int));
FORWARD _PROTOTYPE( void init_params_pci, (int) );
FORWARD _PROTOTYPE( int w_do_open, (struct driver *dp, message *m_ptr) );
FORWARD _PROTOTYPE( struct device *w_prepare, (int dev) );
while (TRUE) {
/* Wait for a request to read or write a disk block. */
- if(receive(ANY, &mess) != OK) continue;
+ if (receive(ANY, &mess) != OK) continue;
device_caller = mess.m_source;
proc_nr = mess.PROC_NR;
/* Now carry out the work. */
switch(mess.m_type) {
- case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
+ case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
case DEV_IOCTL: r = (*dp->dr_ioctl)(dp, &mess); break;
case CANCEL: r = (*dp->dr_cancel)(dp, &mess);break;
case DEV_SELECT: r = (*dp->dr_select)(dp, &mess);break;
-
case DEV_READ:
- case DEV_WRITE: r = do_rdwt(dp, &mess); break;
+ case DEV_WRITE: r = do_rdwt(dp, &mess); break;
case DEV_GATHER:
- case DEV_SCATTER: r = do_vrdwt(dp, &mess); break;
+ case DEV_SCATTER: r = do_vrdwt(dp, &mess); break;
case HARD_INT: /* leftover interrupt or expired timer. */
if(dp->dr_hw_int) {
}
}
+
/*===========================================================================*
* init_buffer *
*===========================================================================*/
struct driver *dp;
message *m_ptr;
{
-/* Check device number on open. (This used to give I/O privileges to a
- * process opening /dev/mem or /dev/kmem. This may be needed in case of
- * memory mapped I/O. With system calls to do I/O this is no longer needed.)
- */
+/* Check device number on open. */
if (m_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO);
-
return(OK);
}
PRIVATE void m_init()
{
/* Initialize this task. All minor devices are initialized one by one. */
+ phys_bytes ramdev_size;
+ phys_bytes ramdev_base;
+ message m;
int i, s;
if (OK != (s=sys_getkinfo(&kinfo))) {
}
}
+ /* See if there are already RAM disk details at the Data Store server. */
+ m.DS_KEY = MEMORY_MAJOR;
+ if (OK == (s = _taskcall(DS_PROC_NR, DS_RETRIEVE, &m))) {
+ ramdev_size = m.DS_VAL_L1;
+ ramdev_base = m.DS_VAL_L2;
+ printf("MEM retrieved size %u and base %u from DS, status %d\n",
+ ramdev_size, ramdev_base, s);
+ if (OK != (s=sys_segctl(&m_seg[RAM_DEV], (u16_t *) &s,
+ (vir_bytes *) &s, ramdev_base, ramdev_size))) {
+ panic("MEM","Couldn't install remote segment.",s);
+ }
+ m_geom[RAM_DEV].dv_base = cvul64(ramdev_base);
+ m_geom[RAM_DEV].dv_size = cvul64(ramdev_size);
+ printf("MEM stored retrieved details as new RAM disk\n");
+ }
+
/* Initialize /dev/zero. Simply write zeros into the buffer. */
for (i=0; i<ZERO_BUF_SIZE; i++) {
dev_zero[i] = '\0';
* - MIOCRAMSIZE: to set the size of the RAM disk.
*/
struct device *dv;
- if ((dv = m_prepare(m_ptr->DEVICE)) == NIL_DEV) return(ENXIO);
switch (m_ptr->REQUEST) {
case MIOCRAMSIZE: {
/* FS wants to create a new RAM disk with the given size. */
phys_bytes ramdev_size;
phys_bytes ramdev_base;
+ message m;
int s;
- if (m_ptr->PROC_NR != FS_PROC_NR) {
- report("MEM", "warning, MIOCRAMSIZE called by", m_ptr->PROC_NR);
- return(EPERM);
- }
+ /* Only FS can create RAM disk, and only on RAM disk device. */
+ if (m_ptr->PROC_NR != FS_PROC_NR) return(EPERM);
+ if (m_ptr->DEVICE != RAM_DEV) return(EINVAL);
+ if ((dv = m_prepare(m_ptr->DEVICE)) == NIL_DEV) return(ENXIO);
/* Try to allocate a piece of memory for the RAM disk. */
ramdev_size = m_ptr->POSITION;
report("MEM", "warning, allocmem failed", errno);
return(ENOMEM);
}
- dv->dv_base = cvul64(ramdev_base);
- dv->dv_size = cvul64(ramdev_size);
- if (OK != (s=sys_segctl(&m_seg[RAM_DEV], (u16_t *) &s, (vir_bytes *) &s,
- ramdev_base, ramdev_size))) {
+ /* Store the values we got in the data store so we can retrieve
+ * them later on, in the unfortunate event of a crash.
+ */
+ m.DS_KEY = MEMORY_MAJOR;
+ m.DS_VAL_L1 = ramdev_size;
+ m.DS_VAL_L2 = ramdev_base;
+ if (OK != (s = _taskcall(DS_PROC_NR, DS_PUBLISH, &m))) {
+ panic("MEM","Couldn't store RAM disk details at DS.",s);
+ }
+ printf("MEM stored size %u and base %u at DS, status %d\n",
+ ramdev_size, ramdev_base, s);
+
+ if (OK != (s=sys_segctl(&m_seg[RAM_DEV], (u16_t *) &s,
+ (vir_bytes *) &s, ramdev_base, ramdev_size))) {
panic("MEM","Couldn't install remote segment.",s);
}
+
+ dv->dv_base = cvul64(ramdev_base);
+ dv->dv_size = cvul64(ramdev_size);
break;
}
case MIOCMAP:
return r;
r= sys_vm_map(m_ptr->PROC_NR, do_map,
(phys_bytes)mapreq.base, mapreq.size, mapreq.offset);
- printf("m_ioctl MIOC(UN)MAP: result %d\n", r);
return r;
}