首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代做program、c/c++程序设计代写
项目预算:
开发周期:
发布时间:
要求地区:
MiniOS
In this project, you will extend a small operating system to set up a simple system call and
initialize a simple page table. You are provided with the code of a tiny operating system, which is
not based on any other OS (e.g., Linux). This OS does not include any interrupt or trap handlers,
except minimal system call support.
The system consists of three pieces:
1. The boot loader (boot.efi), which loads the OS kernel and a user application into
memory; you are already given a binary for the boot loader to simplify the build process
2. The OS kernel (kernel_x86_64), a piece of software that runs in the privileged mode
(ring 0)
3. A simple user application (user_x86_64), a piece of software that runs in the unprivileged
mode (ring 3).
The OS kernel supports a video frame buffer which uses 800x600 (RGB32) video mode. On top
of the video frame buffer console, the system implements text output functions such as printf,
which is analogous to the user-space equivalents for the most part but used inside the OS kernel.
Environment:
OS: Ubuntu 22.04 Desktop x86-64
CPU Architecture: x86_64
run:
sudo apt update
sudo apt install make gcc binutils
sudo apt install git
sudo apt install ovmf qemu-system-x86
You can also install additional packages that can be useful for you (e.g., vim, emacs, or any other
editor).
Provided Code:
The provided code consists of the “kernel” and “user” parts. The “user” part makes system calls
to print some messages. You will only need to modify the “kernel” part. You are ONLY allowed
to change kernel_code.c and kernel_extra.c inside “kernel”. Everything else will be discarded for
grading.
The boot loader allocates some memory (around 32 MB), which will be used inside our kernel.
Part of this memory is used for the heap (see the extra credit assignment). But the remaining part
can be used to initialize the page table. You can assume that the memory base address is already
page-aligned.
2
Your Coding Part:
In kernel_code.c, there are two functions that you need implement:
1. kernel_init. It passes addresses to the user space stack, user program (code and data), and
memory that can be used to initialize the page table. Initially, user stack and program will
reside in kernel space. Our system makes sure that it will still work even if you do not
relocate those into user space. However, your eventual goal (Q4) is to move those
addresses in a dedicated user space portion of the address space. To load the page table,
you need to use load_page_table. This is a special function, which checks your page
table (and returns a string with an error message if it fails) and then loads it to the CR3
register which is used to specify the top level (root) page table address in x86-64.
2. syscall_entry. This is the entry point for all system calls. You need to implement one
specific system call (n = 1) and return an error status (-1) in all other cases. Note that the
mechanism to route system calls from user space is already implemented, you only need
to wire it to the corresponding handler inside this function.
In kernel_extra.c, you need to write your memory allocator code.
To compile and test the OS code, you need to run:
make clean
make
make test
Output:
3
Q2: System calls [40 Points]
You need to modify syscall_entry and implement one specific system call (n = 1) to print a
message on the screen using ‘printf’. The return status of this call should be 0. You will return an
error status (-1) in all other cases. Note that the mechanism to route system calls from user space
is already implemented in kernel_asm.S, you only need to wire it to the corresponding handler
inside syscall_entry in kernel_code.c.
Remember that you are allowed to change kernel_code.c ONLY.
Q3: Page table [60 Points]
The boot loader already sets up the default page table, but you need to create your own x86-64
page table (this can be done fully in C). This page table will provide identical virtual-to-physical
mappings for the first 4 GB of physical memory, and you have to use 4 KB pages. All pages are
assumed to be used for the privileged (ring 0) kernel mode. Although your memory size does not
exceed 1 GB, we are asking you to map 4 GB because the frame buffer’s video memory (used by
‘printf’) is typically located somewhere in the region of 3-4 GB. You can ignore the fact that
some mappings will point to non-existent physical pages in this 4 GB region.
The code provided in kernel_init will already call a special load_page_table function,
which will verify your page table and load it into the CR3 hardware register. You need to
initialize the page table before this function is called.
Remember that all entries of bitfields for page tables must be initialized, including those that are
not currently used. (You should specify 0 for any reserved bits.) It may be more convenient (and
less error prone), if you simply use 64-bit integers (uint64_t) and set corresponding bits yourself
(i.e., avoiding bitfields completely).
For simplicity, we will only allow two bits: the ‘present’ bit and the ‘writable’ bit, both of which
must be set to 1 in the page table. Please do not attempt to use any other bits (except the ‘user’
bit in the next question)! Note that load_page_table will fail if you set any other bits. You only
need to consider the “long” (64-bit) mode and 4 KB pages. Our page table will only use
traditional 4 levels!
Note that even though user applications are only allowed to be executed in user space, the
provided load_page_table function will take care of that problem as long as you do not modify
user_stack and user_program. For now, you are only asked to create kernel-space mappings.
You will modify user_stack and user_program in the next question.
You are allowed to change kernel_code.c ONLY. Do not attempt to “trick” the operating system
to get points without actually implementing the page table.
4
Q4: User space support for the page table [30 pts]
You should extend the page table for the application so that you can also properly execute
application code from user space. The page table should still point to the kernel portion (i.e., the
first entry of PML4). However, this page table will also refer to the pages that are assigned to the
user application itself (the user program and the user stack). Note that the kernel portion should
only be accessible in kernel space, whereas the application portion is accessible in both user and
kernel space. Also note that both user_program and user_stack must point to user-space (rather
than kernel-space) virtual addresses. Initially, they point to the kernel-space virtual addresses
(somewhere in the first 4 GB).
You are allowed to assign any virtual addresses from the bottom 2 MB for the application
(i.e., 0xFFFFFFFFFFE00000 to 0xFFFFFFFFFFFFFFFF). x86-64 sign extends 48-bit virtual
addresses (from the page table) to 64-bit virtual addresses. You can assume that the program
occupies just 1 page, and the user stack is also just 1 page. The stack grows downwards, thus the
initial user_stack address points to the next page (i.e., stack_memory_base + 4096).
Consequently, you need to get the physical page address correctly and map that physical page to
the new virtual address. Finally, the new virtual address that you will write into user_stack
should also point to the next virtual page (i.e., stack_memory_base + 4096) since the stack
grows downwards. Note that user_program will still point to a “normal” base address, but you
also need to map the corresponding page and write the user-space virtual address.
As shown in Figure below, the user-space mappings correspond to the last entry of PML4 (Level
4), last entry of PDP (Level 3), and the last entry of PD (Level 2). You can use any entries in PT
(Level 1). Please make sure to set up correct permissions for these new mappings. The userspace portion can be accessed in both modes, and the kernel-space portion can only be accessed
in kernel/privileged mode.
5
You are allowed to change kernel_code.c ONLY. Do not attempt to “trick” the operating system
to get points without actually implementing the user-space portion of the page table.
Extra Credit:
Integrate the memory allocator implementation into kernel_extra.c. Remember that you are NOT
allowed to use any standard header files. The template in kernel_extra.c already includes some
headers that you will likely need. You need to provide mm_init, malloc, and free. The MiniOS
kernel will do some tests on your memory allocator.
You are allowed to change kernel_extra.c ONLY. Do not attempt to “trick” the operating system
to get points without actually implementing the extra-credit part.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!