static void init_map(unsigned int ix);
static int do_add4pci(const message *m);
static void add_range(phys_bytes busaddr, phys_bytes size);
+#if 0
static void del_range(phys_bytes busaddr, phys_bytes size);
+static void sef_cb_signal_handler(int signo);
+#endif
static void report_exceptions(void);
/* SEF functions and variables. */
static void sef_local_startup(void);
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
-static void sef_cb_signal_handler(int signo);
int main(void)
{
sef_setcb_lu_prepare(sef_cb_lu_prepare_always_ready);
sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid_standard);
+#if 0
/* Register signal callbacks. */
sef_setcb_signal_handler(sef_cb_signal_handler);
+#endif
/* Let SEF perform startup. */
sef_startup();
}
+#if 0
/*===========================================================================*
* sef_cb_signal_handler *
*===========================================================================*/
}
}
}
+#endif
/* Returns 0 if no device found, or 1 if a device is found. */
static int find_dev(devindp, capaddrp)
return r;
}
+#if 0
r= vm_adddma(proc, start, size);
if (r != 0)
{
"proc %d: %d\n", size, start, proc, r);
return r;
}
+#endif
add_range(busaddr, size);
}
}
+#if 0
static void del_range(phys_bytes busaddr, phys_bytes size)
{
phys_bytes o;
table[bit/8] |= (1 << (bit % 8));
}
}
+#endif
static void report_exceptions(void)
{
#endif
}
-#define NR_DMA 16
-
-static struct dmatab
-{
- int dt_flags;
- endpoint_t dt_proc;
- phys_bytes dt_base;
- phys_bytes dt_size;
- phys_clicks dt_seg_base;
- phys_clicks dt_seg_size;
-} dmatab[NR_DMA];
-
-#define DTF_INUSE 1
-#define DTF_RELEASE_DMA 2
-#define DTF_RELEASE_SEG 4
-
-/*===========================================================================*
- * do_adddma *
- *===========================================================================*/
-int do_adddma(message *msg)
-{
- endpoint_t target_proc_e;
- int i, proc_n;
- phys_bytes base, size;
- struct vmproc *vmp;
-
- target_proc_e= msg->VMAD_EP;
- base= msg->VMAD_START;
- size= msg->VMAD_SIZE;
-
- /* Find empty slot */
- for (i= 0; i<NR_DMA; i++)
- {
- if (!(dmatab[i].dt_flags & DTF_INUSE))
- break;
- }
- if (i >= NR_DMA)
- {
- printf("vm:do_adddma: dma table full\n");
- for (i= 0; i<NR_DMA; i++)
- {
- printf("%d: flags 0x%x proc %d base 0x%lx size 0x%lx\n",
- i, dmatab[i].dt_flags,
- dmatab[i].dt_proc,
- dmatab[i].dt_base,
- dmatab[i].dt_size);
- }
- panic("adddma: table full");
- return ENOSPC;
- }
-
- /* Find target process */
- if (vm_isokendpt(target_proc_e, &proc_n) != OK)
- {
- printf("vm:do_adddma: endpoint %d not found\n", target_proc_e);
- return EINVAL;
- }
- vmp= &vmproc[proc_n];
- vmp->vm_flags |= VMF_HAS_DMA;
-
- dmatab[i].dt_flags= DTF_INUSE;
- dmatab[i].dt_proc= target_proc_e;
- dmatab[i].dt_base= base;
- dmatab[i].dt_size= size;
-
- return OK;
-}
-
-/*===========================================================================*
- * do_deldma *
- *===========================================================================*/
-int do_deldma(message *msg)
-{
- endpoint_t target_proc_e;
- int i, j;
- phys_bytes base, size;
-
- target_proc_e= msg->VMDD_EP;
- base= msg->VMDD_START;
- size= msg->VMDD_SIZE;
-
- /* Find slot */
- for (i= 0; i<NR_DMA; i++)
- {
- if (!(dmatab[i].dt_flags & DTF_INUSE))
- continue;
- if (dmatab[i].dt_proc == target_proc_e &&
- dmatab[i].dt_base == base &&
- dmatab[i].dt_size == size)
- {
- break;
- }
- }
- if (i >= NR_DMA)
- {
- printf("vm:do_deldma: slot not found\n");
- return ESRCH;
- }
-
- if (dmatab[i].dt_flags & DTF_RELEASE_SEG)
- {
- /* Check if we have to release the segment */
- for (j= 0; j<NR_DMA; j++)
- {
- if (j == i)
- continue;
- if (!(dmatab[j].dt_flags & DTF_INUSE))
- continue;
- if (!(dmatab[j].dt_flags & DTF_RELEASE_SEG))
- continue;
- if (dmatab[i].dt_proc == target_proc_e)
- break;
- }
- if (j >= NR_DMA)
- {
- /* Last segment */
- free_mem(dmatab[i].dt_seg_base,
- dmatab[i].dt_seg_size);
- }
- }
-
- dmatab[i].dt_flags &= ~DTF_INUSE;
-
- return OK;
-}
-
-/*===========================================================================*
- * do_getdma *
- *===========================================================================*/
-int do_getdma(message *msg)
-{
- int i;
-
- /* Find slot to report */
- for (i= 0; i<NR_DMA; i++)
- {
- if (!(dmatab[i].dt_flags & DTF_INUSE))
- continue;
- if (!(dmatab[i].dt_flags & DTF_RELEASE_DMA))
- continue;
-
- printf("do_getdma: setting reply to 0x%lx@0x%lx proc %d\n",
- dmatab[i].dt_size, dmatab[i].dt_base,
- dmatab[i].dt_proc);
- msg->VMGD_PROCP= dmatab[i].dt_proc;
- msg->VMGD_BASEP= dmatab[i].dt_base;
- msg->VMGD_SIZEP= dmatab[i].dt_size;
-
- return OK;
- }
-
- /* Nothing */
- return EAGAIN;
-}
-
-
-
-/*===========================================================================*
- * release_dma *
- *===========================================================================*/
-void release_dma(struct vmproc *vmp)
-{
-#if 0
- int i, found_one;
-
- found_one= FALSE;
- for (i= 0; i<NR_DMA; i++)
- {
- if (!(dmatab[i].dt_flags & DTF_INUSE))
- continue;
- if (dmatab[i].dt_proc != vmp->vm_endpoint)
- continue;
- dmatab[i].dt_flags |= DTF_RELEASE_DMA | DTF_RELEASE_SEG;
- dmatab[i].dt_seg_base= base;
- dmatab[i].dt_seg_size= size;
- found_one= TRUE;
- }
-
- if (!found_one)
- free_mem(base, size);
-
- msg->VMRD_FOUND = found_one;
-#else
- panic("release_dma not done");
-#endif
-
- return;
-}
-
/*===========================================================================*
* printmemstats *
*===========================================================================*/