Operating System Lab report-familiar with the experimental environment

Source: Internet
Author: User

Preparation of experimental materials

Download the experiment Package hit-oslab-linux-20110823.tar.gz (including linux-0.11 source, bochs virtual machine, etc.):

HTTPS://cms.hit.edu.cn/pluginfile.php/3329/mod_folder/content/6/hit-oslab/ Hit-oslab-linux-20110823.tar.gz?forcedownload=1

Download gcc-3.4-ubuntu.tar.gz (the lower version of GCC needed to compile the linux-0.11):

HTTPS://cms.hit.edu.cn/pluginfile.php/3329/mod_folder/content/6/hit-oslab/gcc-3.4-ubuntu.tar.gz? Forcedownload=1
Experimental environment setting (UBUNTU-16.04.1-DESKTOP-AMD64) experimental material

Create the workspace folder under ~ (User home folder) and extract the hit-oslab-linux-20110823.tar.gz to workspace:

mkdir WORKSPACECD Workspace tar xzf hit-oslab-linux-20110823. tar. gz
gcc-3.4 Installation

Unzip gcc-3.4-ubuntu.tar.gz to/OPT:

CD/tar xzf ~/downloads/gcc-3.4-ubuntu. tar. gz

Install gcc-3.4 (because I am a 64-bit system, so the installation parameter is AMD64; if it is a 32-bit system, the parameter should be i386):

gcc-3.4sudo /instsh amd64
AS86, LD86 installation (for compiling and linking Bootsect.s and SETUP.S under Linux-0.11/boot, they use AS86 assembler syntax, while other assembly language files under linux-0.11 use gas syntax at/t)

Search for packages that contain as86, ld86:

Apt-cache Search As86 ld86

Execution Result:

-bit x86 assembler and Loader

Install Bin86:

sudo Install Bin86
64-bit systems need to install a 32-bit compatibility library:
sudo Install
C Language Compilation environment
sudo Install build-essential
Installing the IDE
sudo Install vim cscope exuberant-ctags
Compiling the kernel
1 cd ~/workspace/oslab/linux-0.112 make

Compile interrupt, output error message:

InchfileIncluded From/usr/include/linux/fs.h:Ten, from Tools/BUILD.C: -:/usr/include/linux/ioctl.h:4: at: Asm/ioctl.h:no Suchfileor DirectoryinfileIncluded From/usr/include/linux/fs.h: One, from Tools/BUILD.C: -:/usr/include/linux/types.h:4: at: Asm/types.h:no Suchfileor DirectoryinfileIncluded From/usr/include/linux/types.h:8, from/usr/include/linux/fs.h: One, from Tools/BUILD.C: -:/usr/include/linux/posix_types.h: *: in: Asm/posix_types.h:no Suchfileor DirectoryinfileIncluded From/usr/include/linux/fs.h: One, from Tools/BUILD.C: -:/usr/include/linux/types.h: -: Error:syntax Error before"__le16"/usr/include/linux/types.h: -: Error:syntax Error before"__be16"/usr/include/linux/types.h: in: Error:syntax Error before"__le32"/usr/include/linux/types.h: -: Error:syntax Error before"__be32"/usr/include/linux/types.h: to: Error:syntax Error before"__le64"/usr/include/linux/types.h: +: Error:syntax Error before"__be64"/usr/include/linux/types.h: the: Error:syntax Error before"__SUM16"/usr/include/linux/types.h: *: Error:syntax Error before"__wsum"inchfileIncluded from TOOLS/BUILD.C: -:/usr/include/linux/fs.h: +: Error:syntax Error before"__u64"/usr/include/linux/fs.h: $: Error:syntax Error before"Minlen" Make: * * * [tools/build] Error1

Google search has learned that the ASM directory for 64-bit Linux is:

/usr/include/x86_64-linux-gnu/asm

Make cannot find a file resulting in a compile break

Workaround (Establish link):

sudo LN -s/usr/include/x86_64-linux-gnu/asm/usr/include/asm
Run and Debug run

Run the compiled kernel, under the Oslab directory:

./run

Error occurred:

 while loading shared libraries:libSM.so. 6 Object file file or directory

To print a dynamic link configuration:

grep libsm.so. 6

Libsm.so.6 's link information:

Libsm.so. 6 (libc6,x86-) =/usr/lib/x86_64-linux-gnu/libsm.so. 6

What we need is a 32-bit. Search for the package name for the library:

apt-file search libsm.so. 6

Printing results:

LIBSM6:/usr/lib/x86_64-linux-gnu/libsm.so. 6  /usr/lib/x86_64-linux-gnu/libsm.so. 6.0. 1

To get its corresponding package named LIBSM6, install the corresponding 32-bit library:

sudo Install libsm6:i386

Try again and an error occurs:

 while loading shared libraries:libXpm.so. 4 Object file file or directory

can also be resolved as above, but here is another tool:

Dpkg-query-s libxpm.so. 4

In the same vein, try again:

./run

Run successfully!

Debug assembly-Level debugging
./dbg-asm

Operating Reference Bochs User manual

C Language-level debugging
./dbg-c

Ctrl+alt+t open another terminal window and go to ~/workspace/oslab to execute:

./rungdb

Occurs two times the library does not have an error, follow the above method to install the corresponding 32-bit library resolved after the run succeeded:

Operation refer to GdB's Manuel:

 man GdB
File exchange between Ubuntu and Linux-0.11 Mount Linux-0.11
./Mount-HDC

MOUNT-HDC is a shell script:

1 #!/bin/sh2 export oslab_path=$ (dirname 'which $0') 3 Mount -t minix-o loop,offset=1024x768 $OSLAB _path/hdc-0.11

Line 1th indicates the shell used by the script

The 2nd line will call this script directory set to Oslab directory

Line 3rd according to the manual manual of Mount,

-T Minix indicates the file system type to mount is Minix

-o[ption] can have 3 parameters (refer to Losetup's manual):

Loop can specify the loopback device to which the file is mapped, and if not specified, the mount automatically searches for

OFFSET specifies the shift in the file or device from where the data starts in the file or device

SizeLimit the maximum size of a file or device starting with offset

Therefore, the $oslab_path/hdc-0.11.img map to the Mount search device, the file system is Minix, the data start offset is 1024byte, and then mounted to the $OSLAB_PATH/HDC directory.

In this way, Ubuntu can access Linux-0.11 files under $OSLAB_PATH/HDC.

Uninstalling Linux-0.11

Under the Oslab directory:

Umount HDC

Attention

1: Do not mount the image file while the 0.11 kernel is running, or it may corrupt the file system. Likewise, do not run the 0.11 kernel while it is already in Mount;

2: Before you close Bochs, you need to run "sync" on the Linux-0.11 command line to ensure that all cached data is saved and then shut down Bochs.

Reference

AS86, LD86 installation

Kernel compilation ASM does not exist error

Loop device loopback Devices

Operating System Lab report-familiar with the experimental environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.