mirror of
https://github.com/CoderSherlock/CoderSherlock.github.io.git
synced 2026-06-13 08:08:10 -07:00
Update xv6
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Xv6 introduction"
|
||||
date: 2017-07-28 14:56:55 -0400
|
||||
categories: xv6
|
||||
---
|
||||
|
||||
I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.
|
||||
|
||||
-------
|
||||
|
||||
## Xv6 Systemcall
|
||||
To invoke a system call, we have to first define a user mode function to be the interface of the kernel instruction in file *user.h*.
|
||||
|
||||
~~~~c
|
||||
void function (void);
|
||||
~~~~
|
||||
|
||||
This interface-like function will then pass the function name, in this case function, to *usys.S*. When using user mode function in programs, *usys.S* will generate a reference to SYS_function and push system call number of this function into %eax. After that, system can know from *syscall.c* and determining whether this system call is available. We must define same name system function and add it into *syscall.h* and *syscall.c*.
|
||||
|
||||
~~~~c
|
||||
#define SYS_function ## // ## is the system call number
|
||||
|
||||
[SYS_function] sys_function // real system function name
|
||||
|
||||
extern int sys_function(void); // real system function declaration
|
||||
~~~~
|
||||
|
||||
After adding these sentences to syscall files, we can implement real function in specific place where you want to make the function works well.
|
||||
|
||||
Sometimes, we need to pass variables among system calls. In this case, variables’ values are not necessary and even can’t be pass directly into system_function. When invoke a system call function, all variables of this system call will be pushed into current process’ stack. In file *syscall.c*, multiple functions are provided to get these variables from the process. I won’t waste time on explaining how to use these functions especially when elegant and detailed comments were written in source codes. However, I will explain concepts and how process organized and works in xv6 in future articles.
|
||||
+3
-1
@@ -102,7 +102,9 @@
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
@@ -186,7 +186,9 @@ Niagara Falls, NY, USA, 2017.</li>
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
@@ -133,7 +133,9 @@ You also need to save charles Root Certificate, it also contains in the same men
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
@@ -104,7 +104,9 @@
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta name="description" content="What is Unikernel?Unikernels are specialised, single-address-space images contructed by using library operating systems.">
|
||||
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
<link rel="canonical" href="https://codersherlock.github.com//archivers/term-comp">
|
||||
<link rel="canonical" href="https://codersherlock.github.com//archivers/intro-unikernel">
|
||||
<link rel="alternate" type="application/rss+xml" title="Stop Talking, Start Doing - 停止空想,开始行动" href="https://codersherlock.github.com//feed.xml" />
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
@@ -121,7 +121,9 @@
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Xv6 introduction « Stop Talking, Start Doing - 停止空想,开始行动</title>
|
||||
<meta name="description" content="I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.">
|
||||
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
<link rel="canonical" href="https://codersherlock.github.com//archivers/intro-xv6">
|
||||
<link rel="alternate" type="application/rss+xml" title="Stop Talking, Start Doing - 停止空想,开始行动" href="https://codersherlock.github.com//feed.xml" />
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-82637164-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
|
||||
<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({
|
||||
google_ad_client: "ca-pub-6651321038908478",
|
||||
enable_page_level_ads: true
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<header class="header">
|
||||
<div class="wrapper">
|
||||
<a class="site-title" href="/">Stop Talking, Start Doing - 停止空想,开始行动</a>
|
||||
<nav class="site-nav">
|
||||
|
||||
|
||||
|
||||
|
||||
<a class="page-link" href="/about/">About</a>
|
||||
|
||||
|
||||
|
||||
<a class="page-link" href="/category/">Category</a>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="wrapper">
|
||||
<div class="col-main">
|
||||
<div class="post">
|
||||
|
||||
<header class="post-header">
|
||||
<h1 class="post-title">Xv6 introduction</h1>
|
||||
<p class="post-meta">Jul 28, 2017</p>
|
||||
</header>
|
||||
|
||||
<article class="post-content">
|
||||
<p>I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 id="xv6-systemcall">Xv6 Systemcall</h2>
|
||||
<p>To invoke a system call, we have to first define a user mode function to be the interface of the kernel instruction in file <em>user.h</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="kt">void</span> <span class="n">function</span> <span class="p">(</span><span class="kt">void</span><span class="p">);</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This interface-like function will then pass the function name, in this case function, to <em>usys.S</em>. When using user mode function in programs, <em>usys.S</em> will generate a reference to SYS_function and push system call number of this function into %eax. After that, system can know from <em>syscall.c</em> and determining whether this system call is available. We must define same name system function and add it into <em>syscall.h</em> and <em>syscall.c</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define SYS_function ## // ## is the system call number
|
||||
</span>
|
||||
<span class="p">[</span><span class="n">SYS_function</span><span class="p">]</span> <span class="n">sys_function</span> <span class="c1">// real system function name
|
||||
</span>
|
||||
<span class="k">extern</span> <span class="kt">int</span> <span class="n">sys_function</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// real system function declaration
|
||||
</span></code></pre>
|
||||
</div>
|
||||
|
||||
<p>After adding these sentences to syscall files, we can implement real function in specific place where you want to make the function works well.</p>
|
||||
|
||||
<p>Sometimes, we need to pass variables among system calls. In this case, variables’ values are not necessary and even can’t be pass directly into system_function. When invoke a system call function, all variables of this system call will be pushed into current process’ stack. In file <em>syscall.c</em>, multiple functions are provided to get these variables from the process. I won’t waste time on explaining how to use these functions especially when elegant and detailed comments were written in source codes. However, I will explain concepts and how process organized and works in xv6 in future articles.</p>
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-second">
|
||||
<div class="col-box col-box-author">
|
||||
<img class="avatar" src="/static/avatar.jpg" alt="Pengzhan Hao - 碾子">
|
||||
<div class="col-box-title name">Pengzhan Hao - 碾子</div>
|
||||
<p></p>
|
||||
<p class="contact">
|
||||
|
||||
<a href="https://github.com/codersherlock">GitHub</a>
|
||||
|
||||
|
||||
<a href="https://twitter.com/haopengzhan">Twitter</a>
|
||||
|
||||
|
||||
<a href="mailto:haopengzhan@gmail.com">Email</a>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="col-box">
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/charles-is-not-a-good-tool">Using charles proxy to monitor mobile SSL traffics</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/hello">Stop Talking is the worst title of one blog</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-box post-toc hide">
|
||||
<div class="col-box-title">TOC</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="wrapper">
|
||||
© 2016 Pengzhan Hao - 碾子
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="/js/easybook.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -217,7 +217,9 @@ dd <span class="k">if</span><span class="o">=</span>/dev/block/mmcblk0p37 <span
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
@@ -99,7 +99,15 @@
|
||||
<h2 class="category" id="unikernel">UNIKERNEL</h2>
|
||||
<ul>
|
||||
|
||||
<li><span>Jul 26</span> » <a href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><span>Jul 26</span> » <a href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<h2 class="category" id="xv6">XV6</h2>
|
||||
<ul>
|
||||
|
||||
<li><span>Jul 28</span> » <a href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -131,7 +139,9 @@
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
+40
-4
@@ -6,10 +6,46 @@
|
||||
</description>
|
||||
<link>https://codersherlock.github.com//</link>
|
||||
<atom:link href="https://codersherlock.github.com//feed.xml" rel="self" type="application/rss+xml"/>
|
||||
<pubDate>Wed, 26 Jul 2017 12:52:19 -0400</pubDate>
|
||||
<lastBuildDate>Wed, 26 Jul 2017 12:52:19 -0400</lastBuildDate>
|
||||
<pubDate>Fri, 28 Jul 2017 15:25:24 -0400</pubDate>
|
||||
<lastBuildDate>Fri, 28 Jul 2017 15:25:24 -0400</lastBuildDate>
|
||||
<generator>Jekyll v3.5.1</generator>
|
||||
|
||||
<item>
|
||||
<title>Xv6 introduction</title>
|
||||
<description><p>I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2 id="xv6-systemcall">Xv6 Systemcall</h2>
|
||||
<p>To invoke a system call, we have to first define a user mode function to be the interface of the kernel instruction in file <em>user.h</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="kt">void</span> <span class="n">function</span> <span class="p">(</span><span class="kt">void</span><span class="p">);</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This interface-like function will then pass the function name, in this case function, to <em>usys.S</em>. When using user mode function in programs, <em>usys.S</em> will generate a reference to SYS_function and push system call number of this function into %eax. After that, system can know from <em>syscall.c</em> and determining whether this system call is available. We must define same name system function and add it into <em>syscall.h</em> and <em>syscall.c</em>.</p>
|
||||
|
||||
<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define SYS_function ## // ## is the system call number
|
||||
</span>
|
||||
<span class="p">[</span><span class="n">SYS_function</span><span class="p">]</span> <span class="n">sys_function</span> <span class="c1">// real system function name
|
||||
</span>
|
||||
<span class="k">extern</span> <span class="kt">int</span> <span class="n">sys_function</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// real system function declaration
|
||||
</span></code></pre>
|
||||
</div>
|
||||
|
||||
<p>After adding these sentences to syscall files, we can implement real function in specific place where you want to make the function works well.</p>
|
||||
|
||||
<p>Sometimes, we need to pass variables among system calls. In this case, variables’ values are not necessary and even can’t be pass directly into system_function. When invoke a system call function, all variables of this system call will be pushed into current process’ stack. In file <em>syscall.c</em>, multiple functions are provided to get these variables from the process. I won’t waste time on explaining how to use these functions especially when elegant and detailed comments were written in source codes. However, I will explain concepts and how process organized and works in xv6 in future articles.</p>
|
||||
</description>
|
||||
<pubDate>Fri, 28 Jul 2017 14:56:55 -0400</pubDate>
|
||||
<link>https://codersherlock.github.com//archivers/intro-xv6</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/intro-xv6</guid>
|
||||
|
||||
|
||||
<category>xv6</category>
|
||||
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Short talk about Unikernels</title>
|
||||
<description><h2 id="what-is-unikernel">What is Unikernel?</h2>
|
||||
@@ -32,8 +68,8 @@
|
||||
|
||||
</description>
|
||||
<pubDate>Wed, 26 Jul 2017 12:42:33 -0400</pubDate>
|
||||
<link>https://codersherlock.github.com//archivers/term-comp</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/term-comp</guid>
|
||||
<link>https://codersherlock.github.com//archivers/intro-unikernel</link>
|
||||
<guid isPermaLink="true">https://codersherlock.github.com//archivers/intro-unikernel</guid>
|
||||
|
||||
|
||||
<category>unikernel</category>
|
||||
|
||||
+22
-3
@@ -71,7 +71,24 @@
|
||||
|
||||
<li>
|
||||
<h2>
|
||||
<a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a>
|
||||
<a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a>
|
||||
</h2>
|
||||
|
||||
<div class="post-meta">Jul 28, 2017</div>
|
||||
|
||||
<div class="post-excerpt">
|
||||
<p>I hate xv6, a stupid, useless education-oriented system. In this article, I will generally talk about how to implement system call to this operating system.</p>
|
||||
|
||||
|
||||
<p>
|
||||
<a class="post-link" href="/archivers/intro-xv6">Read More »</a>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<h2>
|
||||
<a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a>
|
||||
</h2>
|
||||
|
||||
<div class="post-meta">Jul 26, 2017</div>
|
||||
@@ -82,7 +99,7 @@
|
||||
|
||||
|
||||
<p>
|
||||
<a class="post-link" href="/archivers/term-comp">Read More »</a>
|
||||
<a class="post-link" href="/archivers/intro-unikernel">Read More »</a>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
@@ -176,7 +193,9 @@ My current solution is using AP to forward all SSL traffic to a proxy, <a href="
|
||||
<div class="col-box-title">Newest Posts</div>
|
||||
<ul class="post-list">
|
||||
|
||||
<li><a class="post-link" href="/archivers/term-comp">Short talk about Unikernels</a></li>
|
||||
<li><a class="post-link" href="/archivers/intro-xv6">Xv6 introduction</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/intro-unikernel">Short talk about Unikernels</a></li>
|
||||
|
||||
<li><a class="post-link" href="/archivers/some-of-my-previews-exper-work">Some of my previews experiment works: 2016</a></li>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user