Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fallen/NetBSD
base: 637ee13c7aba
...
head fork: fallen/NetBSD
compare: 75703dc61834
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 20, 2013
Yann Sionneau Add implementation of copyin.9 7d4c915
Yann Sionneau Fix typo in copyout.9
Add needed "const" qualifier as well
75703dc
Showing with 37 additions and 2 deletions.
  1. +37 −2 sys/arch/lm32/lm32/copy.c
View
39 sys/arch/lm32/lm32/copy.c
@@ -10,6 +10,7 @@
void do_pmap_load(void);
int copyout(const void *kaddr, void *uaddr, size_t len);
+int copyin(const void *uaddr, void *kaddr, size_t len);
void do_pmap_load(void)
{
@@ -30,12 +31,46 @@ void do_pmap_load(void)
}
+int copyin(const void *uaddr, void *kaddr, size_t len)
+{
+ const uint32_t *uaddr_32 = uaddr;
+ const uint8_t *uaddr_8 = uaddr;
+ uint32_t *kaddr_32 = kaddr;
+ uint8_t *kaddr_8 = kaddr;
+ int count;
+
+ if ( curcpu()->ci_want_pmapload )
+ do_pmap_load();
+
+ kaddr_8 += len;
+ if ((size_t)kaddr_8 < len)
+ return EFAULT;
+ if ((size_t)uaddr_8 > VM_MAXUSER_ADDRESS)
+ return EFAULT;
+
+ count = len;
+ count >>= 2; /* count = count / 4 */
+ while ( count-- > 0)
+ *kaddr_32++ = *uaddr_32++;
+
+ count = len & 0x3; /* test if it is a multiple of 4 */
+ if (count == 0)
+ return 0;
+
+ kaddr_8 = (uint8_t *)kaddr + len - count;
+
+ while (count-- > 0)
+ *kaddr_8++ = *uaddr_8++;
+
+ return 0;
+}
+
int copyout(const void *kaddr, void *uaddr, size_t len)
{
uint32_t *uaddr_32 = uaddr;
uint8_t *uaddr_8 = uaddr;
- uint32_t *kaddr_32 = uaddr;
- uint8_t *kaddr_8 = uaddr;
+ const uint32_t *kaddr_32 = kaddr;
+ const uint8_t *kaddr_8 = kaddr;
int count;
if ( curcpu()->ci_want_pmapload )

No commit comments for this range

Something went wrong with that request. Please try again.