X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..04b8595b18b1b41ac7a206e4b3d51a635f8413d7:/bsd/dev/memdev.c diff --git a/bsd/dev/memdev.c b/bsd/dev/memdev.c index c425c7e08..5a659bebd 100644 --- a/bsd/dev/memdev.c +++ b/bsd/dev/memdev.c @@ -113,7 +113,7 @@ static int mdevrw(dev_t dev, struct uio *uio, int ioflag); static char * nonspace(char *pos, char *end); static char * getspace(char *pos, char *end); -static char * cvtnum(char *pos, char *end, unsigned int *num); +static char * cvtnum(char *pos, char *end, uint64_t *num); #endif /* CONFIG_MEMDEV_INSECURE */ @@ -354,6 +354,7 @@ static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, __unused int flag, u_int32_t *f; u_int64_t *o; int devid; + dk_memdev_info_t * memdev_info; devid = minor(dev); /* Get minor device number */ @@ -364,6 +365,7 @@ static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, __unused int flag, f = (u_int32_t*)data; o = (u_int64_t *)data; + memdev_info = (dk_memdev_info_t *) data; switch (cmd) { @@ -408,7 +410,22 @@ static int mdevioctl(dev_t dev, u_long cmd, caddr_t data, __unused int flag, if(!(mdev[devid].mdFlags & mdInited)) return (ENXIO); *o = ((mdev[devid].mdSize << 12) + mdev[devid].mdSecsize - 1) / mdev[devid].mdSecsize; break; - + + /* + * We're interested in the following bits of information: + * Are you a memory-backed device (always yes, in this case)? + * Physical memory (mdPhys)? + * What is your base page? + * What is your size? + */ + case DKIOCGETMEMDEVINFO: + if (!(mdev[devid].mdFlags & mdInited)) return (ENXIO); + memdev_info->mi_mdev = TRUE; + memdev_info->mi_phys = (mdev[devid].mdFlags & mdPhys) ? TRUE : FALSE; + memdev_info->mi_base = mdev[devid].mdBase; + memdev_info->mi_size = mdev[devid].mdSize; + break; + default: error = ENOTTY; break; @@ -436,8 +453,8 @@ void mdevinit(__unused int the_cnt) { #ifdef CONFIG_MEMDEV_INSECURE int devid, phys; - ppnum_t base; - unsigned int size; + uint64_t base; + uint64_t size; char *ba, *lp; dev_t dev; @@ -476,7 +493,7 @@ void mdevinit(__unused int the_cnt) { if((ba[0] != ' ') && (ba[0] != 0)) continue; /* End must be null or space */ } - dev = mdevadd(devid, base >> 12, size >> 12, phys); /* Go add the device */ + dev = mdevadd(devid, base >> 12, (unsigned)size >> 12, phys); /* Go add the device */ } #endif /* CONFIG_MEMDEV_INSECURE */ @@ -509,7 +526,7 @@ char *getspace(char *pos, char *end) { /* Find next non-space in string */ } } -char *cvtnum(char *pos, char *end, unsigned int *num) { /* Convert to a number */ +char *cvtnum(char *pos, char *end, uint64_t *num) { /* Convert to a number */ int rad, dig;