1. long host2netl_asm (long param)
Convert the parameter param from host byte order
to network byte order (always Big Endian). The code for this function should be entirely written
in x86 assembly. You should not use in-line assembly (i.e.,
do not use asm("...")). You can assume that the size of long
is 4 bytes and the byte order of the host machine is Little Endian.
To investigate the assembly code generated by the compiler, you can use the tool objdump
-d <___.o> to disassemble an object file. The object
files reside in the /compile directory within the main Xinu directory (xinu-fall2009). You can also see some of
the *.S files in the /sys directory for reference.
2. void printsegaddress()
Print the address of
the end of the text, data, and bss segments of the Xinu OS.
Also print the 4 bytes (in hexadecimal) preceding the end of the
three segment boundaries, and similarly for the 4 bytes following
the segment boundaries. This function can be written
in C.
3. void printtos()
Print the address
of the top of the run-time stack for whichever process you are currently
in. In addition, print the contents of up to five stack locations at
and below the top of the stack (the five or fewer items that have been the
most recently pushed, if any). Remember that stack elements are 32 bits wide,
and be careful to perform pointer arithmetic correctly. Also note that
there are local variables and arguments on the stack, among other things.
See the hints given for #4 below, especially on stacktrace.c and proc.h.
Your function can be written entirely in C, or you can use in-line assembly
if you prefer.
4. void printprocstks()
For each
existing process, print the stack base, stack size, stack
limit, and stack pointer. Also, for each process, include the
process name and the process id. An example output might look
something like:
Proc [prnull]. Pid = 0.
Stack:
Base = 4095996
Len = 0
Limit = 4091904
StkPtr = 4095820
Proc [main]. Pid = 49.
Stack:
Base = 4091896
Len = 4096
Limit = 4087804
StkPtr = 4091872
To help you do this, please
look into proc.h in the h/ directory. Note the proctab[]
array that holds all processes. Also, note that the pesp member of
the pentry structure holds the saved stack pointer. Therefore,
the currently executing process has a stack pointer that is different
from the value of this variable. In order to help you get the stack
pointer of the currently executing process, carefully study the stacktrace.c
file in the sys/directory. The register %esp holds the
current stack pointer. You can use in-line assembly (i.e., asm("..."))
to do this part.
Implement this lab as a set of functions that can be called from main(). Each function should reside in a separate file in the sys directory, and should be incorporated into the Makefile. The files should be named after the functions they are implementing with C files having the .c extension and the assembly files having the .S extension. So, for example, the file that will hold void printsegaddress() should be named printsegaddress.c; and the file that will hold long host2netl_asm(long param) should be named host2netl_asm.S. If you require a header file, please name it lab0.h. Note: As you create new files, you may need to update the Makefile (located in the compile/ directory) to configure it to compile your files correctly. Just look at what is done for the existing files (e.g., main.c) to determine what you have to do.
Electronic turn-in instructions:
i) go to the xinu-fall2009/compile directory and do "make clean".
ii) go to the directory of which your xinu-fall2009 directory is a subdirectory (NOTE: please do not rename xinu-fall2009, or any of its subdirectories.)
e.g., if /homes/jsr/xinu-fall2009 is your directory structure, goto /homes/jsr
iii) type in the following command
turnin -c cs503 -p lab0 xinu-fall2009
You can write code in main.c to test your procedures,
but please note that when we test your programs we will replace the main.c
file! Therefore, do not put any functionality in the main.c file.
Also, ALL debugging output should be turned off before you submit your code.