MCPcopy Create free account
hub / github.com/F-Stack/f-stack / memrw

Function memrw

freebsd/arm/arm/mem.c:85–155  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

83
84/* ARGSUSED */
85int
86memrw(struct cdev *dev, struct uio *uio, int flags)
87{
88 int o;
89 u_int c = 0, v;
90 struct iovec *iov;
91 int error = 0;
92 vm_offset_t addr, eaddr;
93
94 while (uio->uio_resid > 0 && error == 0) {
95 iov = uio->uio_iov;
96 if (iov->iov_len == 0) {
97 uio->uio_iov++;
98 uio->uio_iovcnt--;
99 if (uio->uio_iovcnt < 0)
100 panic("memrw");
101 continue;
102 }
103 if (dev2unit(dev) == CDEV_MINOR_MEM) {
104 int i;
105 int address_valid = 0;
106
107 v = uio->uio_offset;
108 v &= ~PAGE_MASK;
109 for (i = 0; dump_avail[i] || dump_avail[i + 1];
110 i += 2) {
111 if (v >= dump_avail[i] &&
112 v < dump_avail[i + 1]) {
113 address_valid = 1;
114 break;
115 }
116 }
117 if (!address_valid)
118 return (EINVAL);
119 sx_xlock(&tmppt_lock);
120 pmap_kenter((vm_offset_t)_tmppt, v);
121 pmap_tlb_flush(kernel_pmap, (vm_offset_t)_tmppt);
122 o = (int)uio->uio_offset & PAGE_MASK;
123 c = (u_int)(PAGE_SIZE - ((int)iov->iov_base & PAGE_MASK));
124 c = min(c, (u_int)(PAGE_SIZE - o));
125 c = min(c, (u_int)iov->iov_len);
126 error = uiomove((caddr_t)&_tmppt[o], (int)c, uio);
127 pmap_qremove((vm_offset_t)_tmppt, 1);
128 sx_xunlock(&tmppt_lock);
129 continue;
130 }
131 else if (dev2unit(dev) == CDEV_MINOR_KMEM) {
132 c = iov->iov_len;
133
134 /*
135 * Make sure that all of the pages are currently
136 * resident so that we don't create any zero-fill
137 * pages.
138 */
139 addr = trunc_page(uio->uio_offset);
140 eaddr = round_page(uio->uio_offset + c);
141
142 for (; addr < eaddr; addr += PAGE_SIZE)

Callers

nothing calls this directly

Calls 8

pmap_tlb_flushFunction · 0.85
minFunction · 0.85
kernaccFunction · 0.85
pmap_kenterFunction · 0.70
pmap_qremoveFunction · 0.70
pmap_extractFunction · 0.70
panicFunction · 0.50
uiomoveFunction · 0.50

Tested by

no test coverage detected