X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=doc%2Fuserprog.texi;h=da9fe3d1774cc40d887f101149283f4d56fd6947;hb=a0820d9aaf9e966d5801c6259db9b560fd9b4547;hp=72ab25615a4f05dad6f9d7eb0f93b72886372635;hpb=01679e7fec5244d137cc9b2cfc2d72e946c4d9d2;p=pintos-anon diff --git a/doc/userprog.texi b/doc/userprog.texi index 72ab256..da9fe3d 100644 --- a/doc/userprog.texi +++ b/doc/userprog.texi @@ -478,25 +478,25 @@ because there's no way to return an error code from a memory access. Therefore, for those who want to try the latter technique, we'll provide a little bit of helpful code: -@example +@verbatim /* Tries to copy a byte from user address USRC to kernel address DST. Returns true if successful, false if USRC is invalid. */ -static inline bool get_user (uint8_t *dst, const uint8_t *usrc) @{ +static inline bool get_user (uint8_t *dst, const uint8_t *usrc) { int eax; asm ("movl $1f, %%eax; movb %2, %%al; movb %%al, %0; 1:" : "=m" (*dst), "=&a" (eax) : "m" (*usrc)); return eax != 0; -@} +} /* Tries write BYTE to user address UDST. Returns true if successful, false if UDST is invalid. */ -static inline bool put_user (uint8_t *udst, uint8_t byte) @{ +static inline bool put_user (uint8_t *udst, uint8_t byte) { int eax; asm ("movl $1f, %%eax; movb %b2, %0; 1:" : "=m" (*udst), "=&a" (eax) : "r" (byte)); return eax != 0; -@} -@end example +} +@end verbatim Each of these functions assumes that the user address has already been verified to be below @code{PHYS_BASE}. They also assume that you've @@ -592,7 +592,7 @@ This value, the exit status of the process, must be returned to the thread's parent when @func{join} is called. @item -@b{Can I just cast a pointer to a @code{struct file} object to get a +@b{Can I just cast a pointer to a @struct{file} object to get a unique file descriptor? Can I just cast a @code{struct thread *} to a @code{pid_t}? It's so much simpler that way!} @@ -688,7 +688,7 @@ some of your caches. This is why inlining code can be much faster. @end menu @node Argument Passing to main -@subsection Argument Passing to @func{main} +@subsection Argument Passing to @code{main()} In @func{main}'s case, there is no caller to prepare the stack before it runs. Therefore, the kernel needs to do it. Fortunately, @@ -807,12 +807,12 @@ You may find the non-standard @func{hex_dump} function, declared in Here's what it would show in the above example, given that @code{PHYS_BASE} is @t{0xc0000000}: -@example +@verbatim bfffffc0 00 00 00 00 | ....| bfffffd0 04 00 00 00 d8 ff ff bf-ed ff ff bf f5 ff ff bf |................| bfffffe0 f8 ff ff bf fc ff ff bf-00 00 00 00 00 2f 62 69 |............./bi| bffffff0 6e 2f 6c 73 00 2d 6c 00-2a 2e 68 00 2a 2e 63 00 |n/ls.-l.*.h.*.c.| -@end example +@end verbatim @node System Calls @section System Calls @@ -868,4 +868,4 @@ In this example, the caller's stack pointer would be at The 80@var{x}86 convention for function return values is to place them in the @samp{EAX} register. System calls that return a value can do -so by modifying the @samp{eax} member of @code{struct intr_frame}. +so by modifying the @samp{eax} member of @struct{intr_frame}.