17
|
1 <!DOCTYPE html>
|
|
2
|
|
3 <html lang="en">
|
|
4
|
|
5 <head>
|
|
6 <meta charset="utf-8">
|
|
7 <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
8 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
|
9 <meta name="apple-mobile-web-app-capable" content="yes">
|
|
10 <meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
11 <meta name="mobile-web-app-capable" content="yes">
|
|
12 <title>
|
|
13 CbCインターフェースによる CbCXv6 の書き換え - HackMD
|
|
14 </title>
|
|
15 <link rel="icon" type="image/png" href="https://hackmd.io/favicon.png">
|
|
16 <link rel="apple-touch-icon" href="https://hackmd.io/apple-touch-icon.png">
|
|
17
|
|
18 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
|
|
19 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
|
20 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css" integrity="sha256-3iu9jgsy9TpTwXKb7bNQzqWekRX7pPK+2OLj3R922fo=" crossorigin="anonymous" />
|
|
21 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css" integrity="sha256-QiWfLIsCT02Sdwkogf6YMiQlj4NE84MKkzEMkZnMGdg=" crossorigin="anonymous" />
|
|
22 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/themes/prism.min.css" integrity="sha256-vtR0hSWRc3Tb26iuN2oZHt3KRUomwTufNIf5/4oeCyg=" crossorigin="anonymous" />
|
|
23 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/emojify.js/1.1.0/css/basic/emojify.min.css" integrity="sha256-UOrvMOsSDSrW6szVLe8ZDZezBxh5IoIfgTwdNDgTjiU=" crossorigin="anonymous" />
|
|
24 <style>
|
|
25 @charset "UTF-8";@import url(https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i|Source+Code+Pro:300,400,500|Source+Sans+Pro:300,300i,400,400i,600,600i|Source+Serif+Pro&subset=latin-ext);.hljs{display:block;background:#fff;padding:.5em;color:#333;overflow-x:auto}.hljs-comment,.hljs-meta{color:#969896}.hljs-emphasis,.hljs-quote,.hljs-string,.hljs-strong,.hljs-template-variable,.hljs-variable{color:#df5000}.hljs-keyword,.hljs-selector-tag,.hljs-type{color:#a71d5d}.hljs-attribute,.hljs-bullet,.hljs-literal,.hljs-number,.hljs-symbol{color:#0086b3}.hljs-built_in,.hljs-builtin-name{color:#005cc5}.hljs-name,.hljs-section{color:#63a35c}.hljs-tag{color:#333}.hljs-attr,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-selector-pseudo,.hljs-title{color:#795da3}.hljs-addition{color:#55a532;background-color:#eaffea}.hljs-deletion{color:#bd2c00;background-color:#ffecec}.hljs-link{text-decoration:underline}.markdown-body{font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body:after,.markdown-body:before{display:table;content:""}.markdown-body:after{clear:both}.markdown-body>:first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:#c00}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-top:0;margin-bottom:16px}.markdown-body hr{height:.25em;padding:0;margin:24px 0;background-color:#e7e7e7;border:0}.markdown-body blockquote{font-size:16px;padding:0 1em;color:#777;border-left:.25em solid #ddd}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body kbd,.popover kbd{display:inline-block;padding:3px 5px;font-size:11px;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:1px solid #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.markdown-body .loweralpha{list-style-type:lower-alpha}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:#000;vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 code,.markdown-body h1 tt,.markdown-body h2 code,.markdown-body h2 tt,.markdown-body h3 code,.markdown-body h3 tt,.markdown-body h4 code,.markdown-body h4 tt,.markdown-body h5 code,.markdown-body h5 tt,.markdown-body h6 code,.markdown-body h6 tt{font-size:inherit}.markdown-body h1{font-size:2em}.markdown-body h1,.markdown-body h2{padding-bottom:.3em;border-bottom:1px solid #eee}.markdown-body h2{font-size:1.5em}.markdown-body h3{font-size:1.25em}.markdown-body h4{font-size:1em}.markdown-body h5{font-size:.875em}.markdown-body h6{font-size:.85em;color:#777}.markdown-body ol,.markdown-body ul{padding-left:2em}.markdown-body ol.no-list,.markdown-body ul.no-list{padding:0;list-style-type:none}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{padding-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:700}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}.markdown-body table th{font-weight:700}.markdown-body table td,.markdown-body table th{padding:6px 13px;border:1px solid #ddd}.markdown-body table tr{background-color:#fff;border-top:1px solid #ccc}.markdown-body table tr:nth-child(2n){background-color:#f8f8f8}.markdown-body img{max-width:100%;box-sizing:content-box;background-color:#fff}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid #ddd}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:#333}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:0;padding-top:.2em;padding-bottom:.2em;margin:0;font-size:85%;background-color:rgba(0,0,0,.04);border-radius:3px}.markdown-body code:after,.markdown-body code:before,.markdown-body tt:after,.markdown-body tt:before{letter-spacing:-.2em;content:"\00a0"}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body pre{word-wrap:normal}.markdown-body pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border-radius:3px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body pre code:after,.markdown-body pre code:before,.markdown-body pre tt:after,.markdown-body pre tt:before{content:normal}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-line-num{padding:10px 8px 9px;text-align:right;background:#fff;border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:700;background:#f8f8f8;border-top:0}.news .alert .markdown-body blockquote{padding:0 0 0 40px;border:0 none}.activity-tab .news .alert .commits,.activity-tab .news .markdown-body blockquote{padding-left:0}.task-list-item{list-style-type:none}.task-list-item label{font-weight:400}.task-list-item.enabled label{cursor:pointer}.task-list-item+.task-list-item{margin-top:3px}.task-list-item-checkbox{float:left;margin:.31em 0 .2em -1.3em!important;vertical-align:middle;cursor:default!important}.markdown-body{padding-top:40px;padding-bottom:40px;max-width:758px;overflow:visible!important}.markdown-body .emoji{vertical-align:top}.markdown-body pre{border:inherit!important}.markdown-body code{color:inherit!important}.markdown-body pre code .wrapper{display:-moz-inline-flex;display:-ms-inline-flex;display:-o-inline-flex;display:inline-flex}.markdown-body pre code .gutter{float:left;overflow:hidden;-webkit-user-select:none;user-select:none}.markdown-body pre code .gutter.linenumber{text-align:right;position:relative;display:inline-block;cursor:default;z-index:4;padding:0 8px 0 0;min-width:20px;box-sizing:content-box;color:#afafaf!important;border-right:3px solid #6ce26c!important}.markdown-body pre code .gutter.linenumber>span:before{content:attr(data-linenumber)}.markdown-body pre code .code{float:left;margin:0 0 0 16px}.markdown-body .gist .line-numbers{border-left:none;border-top:none;border-bottom:none}.markdown-body .gist .line-data{border:none}.markdown-body .gist table{border-spacing:0;border-collapse:inherit!important}.markdown-body code[data-gist-id]{background:none;padding:0}.markdown-body code[data-gist-id]:after,.markdown-body code[data-gist-id]:before{content:""}.markdown-body code[data-gist-id] .blob-num{border:unset}.markdown-body code[data-gist-id] table{overflow:unset;margin-bottom:unset}.markdown-body code[data-gist-id] table tr{background:unset}.markdown-body[dir=rtl] pre{direction:ltr}.markdown-body[dir=rtl] code{direction:ltr;unicode-bidi:embed}.markdown-body .alert>p{margin-bottom:0}.markdown-body pre.abc,.markdown-body pre.flow-chart,.markdown-body pre.graphviz,.markdown-body pre.mermaid,.markdown-body pre.sequence-diagram{text-align:center;background-color:inherit;border-radius:0;white-space:inherit}.markdown-body pre.abc>code,.markdown-body pre.flow-chart>code,.markdown-body pre.graphviz>code,.markdown-body pre.mermaid>code,.markdown-body pre.sequence-diagram>code{text-align:left}.markdown-body pre.abc>svg,.markdown-body pre.flow-chart>svg,.markdown-body pre.graphviz>svg,.markdown-body pre.mermaid>svg,.markdown-body pre.sequence-diagram>svg{max-width:100%;height:100%}.markdown-body pre>code.wrap{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}.markdown-body .alert>p,.markdown-body .alert>ul{margin-bottom:0}.markdown-body summary{display:list-item}.markdown-body summary:focus{outline:none}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>:not(summary){display:none}.markdown-body figure{margin:1em 40px}.markdown-body .mark,.markdown-body mark{background-color:#fff1a7}.vimeo,.youtube{cursor:pointer;display:table;text-align:center;background-position:50%;background-repeat:no-repeat;background-size:contain;background-color:#000;overflow:hidden}.vimeo,.youtube{position:relative;width:100%}.youtube{padding-bottom:56.25%}.vimeo img{width:100%;object-fit:contain;z-index:0}.youtube img{object-fit:cover;z-index:0}.vimeo iframe,.youtube iframe,.youtube img{width:100%;height:100%;position:absolute;top:0;left:0}.vimeo iframe,.youtube iframe{vertical-align:middle;z-index:1}.vimeo .icon,.youtube .icon{position:absolute;height:auto;width:auto;top:50%;left:50%;transform:translate(-50%,-50%);color:#fff;opacity:.3;transition:opacity .2s;z-index:0}.vimeo:hover .icon,.youtube:hover .icon{opacity:.6;transition:opacity .2s}.slideshare .inner,.speakerdeck .inner{position:relative;width:100%}.slideshare .inner iframe,.speakerdeck .inner iframe{position:absolute;top:0;bottom:0;left:0;right:0;width:100%;height:100%}.MJX_Assistive_MathML{display:none}.ui-infobar{position:relative;z-index:2;max-width:760px;margin:25px auto -25px;padding:0 15px;color:#777}.toc .invisable-node{list-style-type:none}.ui-toc{position:fixed;bottom:20px;z-index:998}.ui-toc-label{opacity:.3;background-color:#ccc;border:none;transition:opacity .2s}.ui-toc .open .ui-toc-label{opacity:1;color:#fff;transition:opacity .2s}.ui-toc-label:focus{opacity:.3;background-color:#ccc;color:#000}.ui-toc-label:hover{opacity:1;background-color:#ccc;transition:opacity .2s}.ui-toc-dropdown{margin-top:23px;margin-bottom:20px;padding-left:10px;padding-right:10px;max-width:45vw;width:25vw;max-height:70vh;overflow:auto;text-align:inherit}.ui-toc-dropdown>.toc{max-height:calc(70vh - 100px);overflow:auto}.ui-toc-dropdown[dir=rtl] .nav{padding-right:0;letter-spacing:.0029em}.ui-toc-dropdown a{overflow:hidden;text-overflow:ellipsis;white-space:pre}.ui-toc-dropdown .nav>li>a{display:block;padding:4px 20px;font-size:13px;font-weight:500;color:#767676}.ui-toc-dropdown .nav>li:first-child:last-child > ul,.ui-toc-dropdown .toc.expand ul{display:block}.ui-toc-dropdown .nav>li>a:focus,.ui-toc-dropdown .nav>li>a:hover{padding-left:19px;color:#000;text-decoration:none;background-color:transparent;border-left:1px solid #000}.ui-toc-dropdown[dir=rtl] .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav>li>a:hover{padding-right:19px;border-left:none;border-right:1px solid #000}.ui-toc-dropdown .nav>.active:focus>a,.ui-toc-dropdown .nav>.active:hover>a,.ui-toc-dropdown .nav>.active>a{padding-left:18px;font-weight:700;color:#000;background-color:transparent;border-left:2px solid #000}.ui-toc-dropdown[dir=rtl] .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav>.active>a{padding-right:18px;border-left:none;border-right:2px solid #000}.ui-toc-dropdown .nav .nav{display:none;padding-bottom:10px}.ui-toc-dropdown .nav>.active>ul{display:block}.ui-toc-dropdown .nav .nav>li>a{padding-top:1px;padding-bottom:1px;padding-left:30px;font-size:12px;font-weight:400}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a{padding-right:30px}.ui-toc-dropdown .nav .nav>li>ul>li>a{padding-top:1px;padding-bottom:1px;padding-left:40px;font-size:12px;font-weight:400}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a{padding-right:40px}.ui-toc-dropdown .nav .nav>li>a:focus,.ui-toc-dropdown .nav .nav>li>a:hover{padding-left:29px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>a:hover{padding-right:29px}.ui-toc-dropdown .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown .nav .nav>li>ul>li>a:hover{padding-left:39px}.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:focus,.ui-toc-dropdown[dir=rtl] .nav .nav>li>ul>li>a:hover{padding-right:39px}.ui-toc-dropdown .nav .nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>a{padding-left:28px;font-weight:500}.ui-toc-dropdown[dir=rtl] .nav .nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>a{padding-right:28px}.ui-toc-dropdown .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown .nav .nav>.active>.nav>.active>a{padding-left:38px;font-weight:500}.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:focus>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active:hover>a,.ui-toc-dropdown[dir=rtl] .nav .nav>.active>.nav>.active>a{padding-right:38px}.markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,sans-serif}html[lang^=ja] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,MS\ ゴシック,sans-serif}html[lang=zh-tw] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}html[lang=zh-cn] .markdown-body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}html .markdown-body[lang^=ja]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,MS\ ゴシック,sans-serif}html .markdown-body[lang=zh-tw]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}html .markdown-body[lang=zh-cn]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica Neue,Helvetica,Roboto,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}html[lang^=ja] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Meiryo UI,MS PGothic,MS\ Pゴシック,sans-serif}html[lang=zh-tw] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Microsoft JhengHei UI,微軟正黑UI,sans-serif}html[lang=zh-cn] .ui-toc-dropdown{font-family:Source Sans Pro,Helvetica,Arial,Microsoft YaHei UI,微软雅黑UI,sans-serif}html .ui-toc-dropdown[lang^=ja]{font-family:Source Sans Pro,Helvetica,Arial,Meiryo UI,MS PGothic,MS\ Pゴシック,sans-serif}html .ui-toc-dropdown[lang=zh-tw]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft JhengHei UI,微軟正黑UI,sans-serif}html .ui-toc-dropdown[lang=zh-cn]{font-family:Source Sans Pro,Helvetica,Arial,Microsoft YaHei UI,微软雅黑UI,sans-serif}.ui-affix-toc{position:fixed;top:0;max-width:15vw;max-height:70vh;overflow:auto}.back-to-top,.expand-toggle,.go-to-bottom{display:block;padding:4px 10px;margin-top:10px;margin-left:10px;font-size:12px;font-weight:500;color:#999}.back-to-top:focus,.back-to-top:hover,.expand-toggle:focus,.expand-toggle:hover,.go-to-bottom:focus,.go-to-bottom:hover{color:#563d7c;text-decoration:none}.back-to-top,.go-to-bottom{margin-top:0}.ui-user-icon{width:20px;height:20px;display:block;border-radius:3px;margin-top:2px;margin-bottom:2px;margin-right:5px;background-position:50%;background-repeat:no-repeat;background-size:cover}.ui-user-icon.small{width:18px;height:18px;display:inline-block;vertical-align:middle;margin:0 0 .2em}.ui-infobar>small>span{line-height:22px}.ui-infobar>small .dropdown{display:inline-block}.ui-infobar>small .dropdown a:focus,.ui-infobar>small .dropdown a:hover{text-decoration:none}.ui-published-note{color:#337ab7}.ui-published-note .fa{font-size:20px;vertical-align:top}.unselectable{-webkit-user-select:none;-o-user-select:none;user-select:none}@media print{blockquote,div,img,pre,table{page-break-inside:avoid!important}a[href]:after{font-size:12px!important}}.markdown-body.slides{position:relative;z-index:1;color:#222}.markdown-body.slides:before{content:"";display:block;position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1;background-color:currentColor;box-shadow:0 0 0 50vw}.markdown-body.slides section[data-markdown]{position:relative;margin-bottom:1.5em;background-color:#fff;text-align:center}.markdown-body.slides section[data-markdown] code{text-align:left}.markdown-body.slides section[data-markdown]:before{content:"";display:block;padding-bottom:56.23%}.markdown-body.slides section[data-markdown]>div:first-child{position:absolute;top:50%;left:1em;right:1em;transform:translateY(-50%);max-height:100%;overflow:hidden}.markdown-body.slides section[data-markdown]>ul{display:inline-block}.markdown-body.slides>section>section+section:after{content:"";position:absolute;top:-1.5em;right:1em;height:1.5em;border:3px solid #777}body{font-smoothing:subpixel-antialiased!important;-webkit-font-smoothing:subpixel-antialiased!important;-moz-osx-font-smoothing:auto!important;text-shadow:0 0 1em transparent,1px 1px 1.2px rgba(0,0,0,.004);-webkit-overflow-scrolling:touch;letter-spacing:.025em}.focus,:focus{outline:none!important}::-moz-focus-inner{border:0!important}body{font-family:Source Sans Pro,Helvetica,Arial,sans-serif}html[lang^=ja] body{font-family:Source Sans Pro,Helvetica,Arial,Hiragino Kaku Gothic Pro,ヒラギノ角ゴ Pro W3,Osaka,Meiryo,メイリオ,MS Gothic,MS\ ゴシック,sans-serif}html[lang=zh-tw] body{font-family:Source Sans Pro,Helvetica,Arial,PingFang TC,Microsoft JhengHei,微軟正黑,sans-serif}html[lang=zh-cn] body{font-family:Source Sans Pro,Helvetica,Arial,PingFang SC,Microsoft YaHei,微软雅黑,sans-serif}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}abbr[data-original-title],abbr[title]{cursor:help}body.modal-open{overflow-y:auto;padding-right:0!important}
|
|
26 </style>
|
|
27 <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
|
28 <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
|
29 <!--[if lt IE 9]>
|
|
30 <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" integrity="sha256-3Jy/GbSLrg0o9y5Z5n1uw0qxZECH7C6OQpVBgNFYa0g=" crossorigin="anonymous"></script>
|
|
31 <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js" integrity="sha256-g6iAfvZp+nDQ2TdTR/VVKJf3bGro4ub5fvWSWVRi2NE=" crossorigin="anonymous"></script>
|
|
32 <script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-shim.min.js" integrity="sha256-8E4Is26QH0bD52WoQpcB+R/tcWQtpzlCojrybUd7Mxo=" crossorigin="anonymous"></script>
|
|
33 <![endif]-->
|
|
34 </head>
|
|
35
|
|
36 <body>
|
32
|
37 <div id="doc" class="markdown-body container-fluid comment-enabled" data-hard-breaks="true" style="position: relative;"><h1 class="highlight" id="CbCインターフェースによる-CbCXv6-の書き換え" style=""><a class="anchor hidden-xs" href="#CbCインターフェースによる-CbCXv6-の書き換え" title="CbCインターフェースによる-CbCXv6-の書き換え"><span class="octicon octicon-link"></span></a>CbCインターフェースによる CbCXv6 の書き換え</h1><ul>
|
17
|
38 <li>並列信頼研</li>
|
|
39 <li>桃原 優</li>
|
32
|
40 </ul><hr><h1 class="highlight" id="概要" style=""><a class="anchor hidden-xs" href="#概要" title="概要"><span class="octicon octicon-link"></span></a>概要</h1><ul>
|
|
41 <li>OS の信頼性を上げたい</li>
|
|
42 <li>CbCを使って xv6 という OS を書き換える</li>
|
|
43 <li>Paging の書き換えを行った</li>
|
|
44 <li>まだ実装中</li>
|
|
45 <li>将来はコンテナやVMをメタ計算として実装できるはず</li>
|
|
46 </ul><hr><h1 id="OS-の信頼性を上げたい" style=""><a class="anchor hidden-xs" href="#OS-の信頼性を上げたい" title="OS-の信頼性を上げたい"><span class="octicon octicon-link"></span></a>OS の信頼性を上げたい</h1><ul class="highlight">
|
|
47 <li>仕様を満たすことを証明する</li>
|
|
48 <li>証明しやすい形の記述を作る</li>
|
|
49 <li>CbCの goto で書く
|
17
|
50 <ul>
|
32
|
51 <li>状態遷移系に近い形で記述できる(証明しやすい)</li>
|
|
52 <li>関数型の記述</li>
|
17
|
53 </ul>
|
|
54 </li>
|
32
|
55 <li>CbCのinterface で書く</li>
|
|
56 <li>記述のモジュール化</li>
|
|
57 </ul><hr><h1 id="メタレベルとノーマルレベル" style=""><a class="anchor hidden-xs" href="#メタレベルとノーマルレベル" title="メタレベルとノーマルレベル"><span class="octicon octicon-link"></span></a>メタレベルとノーマルレベル</h1><ul class="highlight">
|
17
|
58 <li>ノーマルレベル
|
|
59 <ul>
|
32
|
60 <li>CbCで記述される普通のアルゴリズム</li>
|
17
|
61 </ul>
|
|
62 </li>
|
|
63 <li>メタレベル
|
|
64 <ul>
|
32
|
65 <li>Paging などのメモリやCPU自体の操作</li>
|
|
66 <li>プログラムの正しさの証明</li>
|
17
|
67 </ul>
|
|
68 </li>
|
32
|
69 <li>Context
|
|
70 <ul>
|
|
71 <li>メタレベルで使用される Meta Data を置く場所</li>
|
17
|
72 </ul>
|
|
73 </li>
|
32
|
74 </ul><hr><h1 id="Continuation-based-C" style=""><a class="anchor hidden-xs" href="#Continuation-based-C" title="Continuation-based-C"><span class="octicon octicon-link"></span></a>Continuation based C</h1><ul class="highlight">
|
18
|
75 <li>ノーマルレベルとメタレベルの処理を同じ言語で行えるようにした言語(以下CbC)</li>
|
|
76 <li>Code Gear
|
17
|
77 <ul>
|
|
78 <li>基本的な処理の単位</li>
|
32
|
79 <li>goto 文で遷移する</li>
|
17
|
80 </ul>
|
|
81 </li>
|
18
|
82 <li>Data Gear
|
17
|
83 <ul>
|
|
84 <li>データの単位</li>
|
|
85 </ul>
|
|
86 </li>
|
32
|
87 <li>Meta Code Gear
|
|
88 <ul>
|
|
89 <li>goto meta</li>
|
|
90 <li>Code Gear の間に挟める計算</li>
|
|
91 </ul>
|
|
92 </li>
|
|
93 <li>Meta Data Gear
|
|
94 <ul>
|
|
95 <li>Context</li>
|
|
96 <li>Code Gearの間の接続など</li>
|
|
97 </ul>
|
|
98 </li>
|
17
|
99 </ul><hr><h1 id="goto-による継続" style=""><a class="anchor hidden-xs" href="#goto-による継続" title="goto-による継続"><span class="octicon octicon-link"></span></a>goto による継続</h1><ul>
|
|
100 <li>Code Gear の処理の間を goto によって遷移していく</li>
|
|
101 </ul><p><img src="https://i.imgur.com/etfQund.png" alt=""></p><hr><h1 id="Data-Gear-の継続" style=""><a class="anchor hidden-xs" href="#Data-Gear-の継続" title="Data-Gear-の継続"><span class="octicon octicon-link"></span></a>Data Gear の継続</h1><ul>
|
32
|
102 <li>Code Gear で定義されたデータ</li>
|
17
|
103 <li>goto の際に Data Gear も継続される</li>
|
|
104 </ul><p><img src="https://i.imgur.com/3E0DGWA.png" alt=""></p><hr><h1 id="Meta-Code-Gear" style=""><a class="anchor hidden-xs" href="#Meta-Code-Gear" title="Meta-Code-Gear"><span class="octicon octicon-link"></span></a>Meta Code Gear</h1><ul>
|
|
105 <li>実際にはノーマルレベルの間にメタレベルの処理がある</li>
|
32
|
106 </ul><p><img src="https://i.imgur.com/vy0NxrG.png" alt=""></p><hr><h1 id="Meta-Data-Gear" style=""><a class="anchor hidden-xs" href="#Meta-Data-Gear" title="Meta-Data-Gear"><span class="octicon octicon-link"></span></a>Meta Data Gear</h1><ul>
|
|
107 <li>CbC では接続可能な Code Gear, Data Gear のリスト</li>
|
|
108 <li>Data Gear を確保するメモリ空間</li>
|
|
109 <li>ノーマルレベルでの書き換えやアクセスを防ぐために存在</li>
|
|
110 </ul><hr><h1 id="Xv6" style=""><a class="anchor hidden-xs" href="#Xv6" title="Xv6"><span class="octicon octicon-link"></span></a>Xv6</h1><ul>
|
18
|
111 <li>MIT の講義用教材として作られたOS
|
|
112 <ul>
|
32
|
113 <li>規格化される前のCで書かれたUNIX V6 を書き換えた</li>
|
18
|
114 <li>1万行程の軽量なOS</li>
|
|
115 <li>Linuxだと数千万行</li>
|
|
116 </ul>
|
|
117 </li>
|
32
|
118 <li>Xv6 をCbCで書き換える</li>
|
|
119 </ul><hr><h1 id="Xv6の構成" style=""><a class="anchor hidden-xs" href="#Xv6の構成" title="Xv6の構成"><span class="octicon octicon-link"></span></a>Xv6の構成</h1><ul class="highlight">
|
|
120 <li>systemcall</li>
|
|
121 <li>Scheduler</li>
|
|
122 <li>Virtual Memory</li>
|
|
123 <li>file system</li>
|
|
124 <li>tty</li>
|
18
|
125 </ul><hr><h1 id="カーネル空間" style=""><a class="anchor hidden-xs" href="#カーネル空間" title="カーネル空間"><span class="octicon octicon-link"></span></a>カーネル空間</h1><ul>
|
|
126 <li>OS の中核となるプログラムで Meta Level に相当する</li>
|
|
127 <li>Xv6 ではカーネルとユーザープログラムは分離されている</li>
|
|
128 <li>ユーザープログラムはカーネルに直接アクセスできない。
|
|
129 <ul>
|
32
|
130 <li>ユーザープログラムによる書き換えやアクセスを防ぐため</li>
|
18
|
131 <li>呼び出す場合は system call</li>
|
|
132 </ul>
|
|
133 </li>
|
19
|
134 </ul><hr><h1 id="system-call" style=""><a class="anchor hidden-xs" href="#system-call" title="system-call"><span class="octicon octicon-link"></span></a>system call</h1><ul>
|
18
|
135 <li>system call 呼び出し</li>
|
|
136 <li>トラップ の発生</li>
|
|
137 <li>ユーザープログラムの中断</li>
|
|
138 <li>処理がカーネルに切り替わる</li>
|
19
|
139 </ul><hr><h1 id="Paging" style=""><a class="anchor hidden-xs" href="#Paging" title="Paging"><span class="octicon octicon-link"></span></a>Paging</h1><ul>
|
18
|
140 <li>Page と呼ばれる固定長のブロックに分割して、メモリとスワップ領域で Page を入れ替えて管理</li>
|
|
141 <li>仮想メモリとして扱うことでフラグメンテーションの解消と空き番地を探す必要がなくなる</li>
|
32
|
142 </ul><hr><h1 id="Xv6の書き換え方針" style=""><a class="anchor hidden-xs" href="#Xv6の書き換え方針" title="Xv6の書き換え方針"><span class="octicon octicon-link"></span></a>Xv6の書き換え方針</h1><ul>
|
|
143 <li>
|
|
144 <p>メタレベルとノーマルレベルを記述できるOSを実装したい</p>
|
|
145 </li>
|
|
146 <li>
|
|
147 <p>段階的に書き換えていきたい</p>
|
|
148 </li>
|
|
149 <li>
|
|
150 <p>Paging を書き換える理由</p>
|
18
|
151 <ul>
|
32
|
152 <li>OS の信頼性を保証する上で重要なメモリ管理部分</li>
|
|
153 </ul>
|
|
154 </li>
|
|
155 <li>
|
|
156 <p>__code で書き直していく</p>
|
|
157 </li>
|
|
158 </ul><hr><h1 id="CbCインターフェース0" style=""><a class="anchor hidden-xs" href="#CbCインターフェース0" title="CbCインターフェース0"><span class="octicon octicon-link"></span></a>CbCインターフェース</h1><ul>
|
|
159 <li>
|
|
160 <p>ノーマルレベルからメタレベルの記述が記述が煩雑になるためインターフェースを導入</p>
|
|
161 </li>
|
|
162 <li>
|
|
163 <p>インターフェースによる他のメリット</p>
|
|
164 <ul>
|
|
165 <li>煩雑な記述の解消</li>
|
|
166 <li>実装の入れ替え</li>
|
18
|
167 </ul>
|
|
168 </li>
|
32
|
169 <li>
|
|
170 <p>実装は別で定義し、呼び出す</p>
|
|
171 </li>
|
|
172 <li>
|
|
173 <p>インターフェースによって実装を置き換えることができる</p>
|
|
174 </li>
|
|
175 </ul><hr><h1 id="CbCインターフェース" style=""><a class="anchor hidden-xs" href="#CbCインターフェース" title="CbCインターフェース"><span class="octicon octicon-link"></span></a>CbCインターフェース</h1><ul>
|
|
176 <li>
|
|
177 <p>Data Gear と Data Gear に対して操作を行う Code Gear の集合を表現する <strong>Meta Data Gear</strong></p>
|
|
178 </li>
|
|
179 <li>
|
|
180 <p>インターフェース実装と定義の図入れる</p>
|
|
181 </li>
|
|
182 </ul><hr><h1 id="インターフェースの定義0" style=""><a class="anchor hidden-xs" href="#インターフェースの定義0" title="インターフェースの定義0"><span class="octicon octicon-link"></span></a>インターフェースの定義</h1><ul>
|
|
183 <li>Xv6 の Virtual Memory の API 部分のインターフェース</li>
|
|
184 </ul><pre><code class="c hljs"><span class="token keyword">typedef</span> <span class="token keyword">struct</span> vm<span class="token operator"><</span>Type<span class="token punctuation">,</span>Impl<span class="token operator">></span> <span class="token punctuation">{</span>
|
|
185 __code <span class="token function">init_vmm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
186 __code <span class="token function">kpt_freerange</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> uint low<span class="token punctuation">,</span> uint hi<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
187 __code <span class="token function">kpt_alloc</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm <span class="token punctuation">,</span>__code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
188 __code <span class="token function">switchuvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm <span class="token punctuation">,</span><span class="token keyword">struct</span> proc<span class="token operator">*</span> p<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
189 __code <span class="token function">init_inituvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> init<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
190 __code <span class="token function">loaduvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span>pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode<span class="token operator">*</span> ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
191 __code <span class="token function">allocuvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> uint oldsz<span class="token punctuation">,</span> uint newsz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
192
|
|
193 </code></pre><hr><h1 id="インターフェースの命名" style=""><a class="anchor hidden-xs" href="#インターフェースの命名" title="インターフェースの命名"><span class="octicon octicon-link"></span></a>インターフェースの命名</h1><ul>
|
|
194 <li>typedef struct の直後にインターフェース名(vm)を書く</li>
|
|
195 <li>Data Gear にマッピングされる</li>
|
|
196 </ul><pre><code class="c hljs"><span class="token keyword">typedef</span> <span class="token keyword">struct</span> vm<span class="token operator"><</span>Type<span class="token punctuation">,</span>Impl<span class="token operator">></span> <span class="token punctuation">{</span>
|
|
197 </code></pre><hr><h1 id="インターフェースの-Code-Gear" style=""><a class="anchor hidden-xs" href="#インターフェースの-Code-Gear" title="インターフェースの-Code-Gear"><span class="octicon octicon-link"></span></a>インターフェースの Code Gear</h1><ul>
|
|
198 <li>Code Gear は __code CodeGear名(引数); で記述する
|
19
|
199 <ul>
|
32
|
200 <li>引数が Data Gear に相当する</li>
|
19
|
201 </ul>
|
|
202 </li>
|
32
|
203 <li>第1引数の Impl* vm がインターフェースの実装の型になる</li>
|
19
|
204 </ul><pre><code class="c hljs"><span class="token keyword">typedef</span> <span class="token keyword">struct</span> vm<span class="token operator"><</span>Type<span class="token punctuation">,</span>Impl<span class="token operator">></span> <span class="token punctuation">{</span>
|
32
|
205 __code <span class="token function">init_vmm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
19
|
206 __code <span class="token function">kpt_freerange</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> uint low<span class="token punctuation">,</span> uint hi<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
207 __code <span class="token function">kpt_alloc</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm <span class="token punctuation">,</span>__code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
208 __code <span class="token function">switchuvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm <span class="token punctuation">,</span><span class="token keyword">struct</span> proc<span class="token operator">*</span> p<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
209 __code <span class="token function">init_inituvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> init<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
210 __code <span class="token function">loaduvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span>pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode<span class="token operator">*</span> ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
211 __code <span class="token function">allocuvm</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> uint oldsz<span class="token punctuation">,</span> uint newsz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
212
|
|
213 </code></pre><hr><h1 id="next…" style=""><a class="anchor hidden-xs" href="#next…" title="next…"><span class="octicon octicon-link"></span></a>next(…)</h1><ul>
|
32
|
214 <li>__code next(…) は次の Code Gear の継続先</li>
|
19
|
215 <li>それぞれの Code Gear の引数の1つに設定する</li>
|
|
216 </ul><pre><code class="c hljs"> __code <span class="token function">kpt_freerange</span><span class="token punctuation">(</span>Impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> uint low<span class="token punctuation">,</span> uint hi<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
32
|
217 <span class="token comment">//....</span>
|
19
|
218 __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
219 <span class="token punctuation">}</span> vm<span class="token punctuation">;</span>
|
32
|
220 </code></pre><pre><code class="c hljs">__code <span class="token function">exit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
|
|
221 <span class="token comment">//....</span>
|
|
222 <span class="token punctuation">}</span>
|
19
|
223
|
32
|
224 <span class="token keyword">goto</span> vm<span class="token operator">-></span><span class="token function">kpt_freerange</span><span class="token punctuation">(</span>vm<span class="token punctuation">,</span> low<span class="token punctuation">,</span> hi<span class="token punctuation">,</span> exit<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
225 </code></pre><hr><h1 id="Interface-の実装の型" style=""><a class="anchor hidden-xs" href="#Interface-の実装の型" title="Interface-の実装の型"><span class="octicon octicon-link"></span></a>Interface の実装の型</h1><ul>
|
|
226 <li>実装側のヘッダーファイルも vm_impl と同じように用意する</li>
|
|
227 </ul><pre><code class="c hljs"><span class="token keyword">typedef</span> <span class="token keyword">struct</span> vm_impl<span class="token operator"><</span>Impl<span class="token punctuation">,</span> Isa<span class="token operator">></span> impl vm<span class="token punctuation">{</span>
|
|
228 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
229 __code <span class="token function">loaduvm_ptesize_check</span><span class="token punctuation">(</span>Type<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> uint i<span class="token punctuation">,</span> pte_t<span class="token operator">*</span> pte<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span>
|
|
230 __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
231 </code></pre><hr><h1 id="インターフェースの実装" style=""><a class="anchor hidden-xs" href="#インターフェースの実装" title="インターフェースの実装"><span class="octicon octicon-link"></span></a>インターフェースの実装</h1><ul>
|
|
232 <li>実装は型と実装をそれぞれ別ファイルで定義する(vm_impl.h と vm_impl.cbc)</li>
|
|
233 <li>実装するインターフェースは #interface で宣言する</li>
|
|
234 </ul><pre><code class="c hljs"><span class="token macro property">#interface "vm.h"</span>
|
|
235 </code></pre><hr><h1 class="highlight" id="vm_impl-のコンストラクタ" style=""><a class="anchor hidden-xs" href="#vm_impl-のコンストラクタ" title="vm_impl-のコンストラクタ"><span class="octicon octicon-link"></span></a>vm_impl のコンストラクタ</h1><ul>
|
|
236 <li>
|
|
237 <p>create_imple の関数内で vm の型を定義し、vm->CodeGear名 で対応させていく</p>
|
|
238 </li>
|
|
239 <li>
|
|
240 <p>実装を Code Gear で記述していく。</p>
|
|
241 </li>
|
|
242 <li>
|
|
243 <p>struct vm* vm = new vm();</p>
|
|
244 <ul>
|
|
245 <li>インターフェースのメモリ空間を確保</li>
|
|
246 </ul>
|
|
247 </li>
|
|
248 <li>
|
|
249 <p>vm->void_ret = C_vm_void_ret;</p>
|
|
250 <ul>
|
|
251 <li>Code Gear の enum の設定</li>
|
|
252 <li>インターフェースのAPIと enum の番号を紐付けている</li>
|
|
253 </ul>
|
|
254 </li>
|
|
255 </ul><pre><code class="c hljs">vm<span class="token operator">*</span> <span class="token function">createvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> Context<span class="token operator">*</span> cbc_context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
256 <span class="token keyword">struct</span> vm<span class="token operator">*</span> vm <span class="token operator">=</span> new <span class="token function">vm</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
257 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
258 vm<span class="token operator">-></span>void_ret <span class="token operator">=</span> C_vm_void_ret<span class="token punctuation">;</span>
|
|
259 vm<span class="token operator">-></span>init_vmm <span class="token operator">=</span> C_init_vmmvm_impl<span class="token punctuation">;</span>
|
|
260 vm<span class="token operator">-></span>kpt_freerange <span class="token operator">=</span> C_kpt_freerangevm_impl<span class="token punctuation">;</span>
|
|
261 vm<span class="token operator">-></span>kpt_alloc <span class="token operator">=</span> C_kpt_allocvm_impl<span class="token punctuation">;</span>
|
32
|
262 </code></pre><ul>
|
|
263 <li>APIの実装の例(init_vmm)
|
|
264 <ul>
|
|
265 <li>C_init_vmmvm_impl が メタレベルでinit_vmmvm_impl と対応する</li>
|
|
266 </ul>
|
|
267 </li>
|
|
268 </ul><pre><code class="c hljs">__code <span class="token function">init_vmmvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm<span class="token punctuation">,</span>__code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
269 <span class="token function">initlock</span><span class="token punctuation">(</span><span class="token operator">&</span>kpt_mem<span class="token punctuation">.</span>lock<span class="token punctuation">,</span> <span class="token string">"vm"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
270 kpt_mem<span class="token punctuation">.</span>freelist <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
|
|
271
|
|
272 <span class="token keyword">goto</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
273 <span class="token punctuation">}</span>
|
32
|
274 </code></pre><hr><h1 id="インターフェース実装内の-CbC" style=""><a class="anchor hidden-xs" href="#インターフェース実装内の-CbC" title="インターフェース実装内の-CbC"><span class="octicon octicon-link"></span></a>インターフェース実装内の CbC</h1><ul>
|
|
275 <li>for文やif文がある場合はさらに実装を分ける
|
|
276 <ul>
|
|
277 <li>状態遷移ベースで記述したい</li>
|
|
278 </ul>
|
|
279 </li>
|
|
280 <li>インターフェースは外から呼び出されるAPI</li>
|
|
281 <li>それに対してインターフェースの実装の Code Gearから明示的に呼び出される Code Gearは、Java の private メソッドのように扱われる。</li>
|
19
|
282 <li>実際に vm.c の loaduvm の実装を分けた記述を説明する</li>
|
32
|
283 </ul><hr><h1 id="実装内の明示的な遷移の処理" style=""><a class="anchor hidden-xs" href="#実装内の明示的な遷移の処理" title="実装内の明示的な遷移の処理"><span class="octicon octicon-link"></span></a>実装内の明示的な遷移の処理</h1><ul>
|
|
284 <li>vm と同じ create_impl 内で vm_impl を定義し、private で実装する Code Gear を定義する</li>
|
|
285 <li>loaduvmvm_impl で goto によって private に遷移する</li>
|
|
286 </ul><pre class="highlight"><code class="c hljs">__code <span class="token function">loaduvmvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode<span class="token operator">*</span> ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
287 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>pgdir <span class="token operator">=</span> pgdir<span class="token punctuation">;</span>
|
|
288 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>addr <span class="token operator">=</span> addr<span class="token punctuation">;</span>
|
|
289 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>ip <span class="token operator">=</span> ip<span class="token punctuation">;</span>
|
|
290 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>offset <span class="token operator">=</span> offset<span class="token punctuation">;</span>
|
|
291 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>sz <span class="token operator">=</span> sz<span class="token punctuation">;</span>
|
|
292 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>next <span class="token operator">=</span> next<span class="token punctuation">;</span>
|
|
293
|
|
294 <span class="token keyword">goto</span> <span class="token function">loaduvm_ptesize_checkvm_impl</span><span class="token punctuation">(</span>vm<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
295 <span class="token punctuation">}</span>
|
|
296 </code></pre><pre class="highlight"><code class="c hljs">vm<span class="token operator">*</span> <span class="token function">createvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> Context<span class="token operator">*</span> cbc_context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
297 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
298 <span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl <span class="token operator">=</span> new <span class="token function">vm_impl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
299 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
300 vm_impl<span class="token operator">-></span>loaduvm_ptesize_check <span class="token operator">=</span> C_loaduvm_ptesize_checkvm_impl<span class="token punctuation">;</span>
|
|
301 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
302 vm<span class="token operator">-></span>loaduvm <span class="token operator">=</span> C_loaduvmvm_impl<span class="token punctuation">;</span>
|
|
303 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
|
|
304 <span class="token punctuation">}</span>
|
|
305 </code></pre><hr><h1 id="loaduvmの-CbCによる書き換え" style=""><a class="anchor hidden-xs" href="#loaduvmの-CbCによる書き換え" title="loaduvmの-CbCによる書き換え"><span class="octicon octicon-link"></span></a>loaduvmの CbCによる書き換え</h1><ul>
|
|
306 <li>loaduvmは何でなぜ書き換えてるのか</li>
|
|
307 <li>vm.cのloaduvmの処理をCbC で書き換える</li>
|
19
|
308 </ul><pre><code class="c hljs"><span class="token keyword">int</span> loaduvm <span class="token punctuation">(</span>pde_t <span class="token operator">*</span>pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span>addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode <span class="token operator">*</span>ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">)</span>
|
|
309 <span class="token punctuation">{</span>
|
|
310 uint i<span class="token punctuation">,</span> pa<span class="token punctuation">,</span> n<span class="token punctuation">;</span>
|
|
311 pte_t <span class="token operator">*</span>pte<span class="token punctuation">;</span>
|
|
312
|
|
313 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>uint<span class="token punctuation">)</span> addr <span class="token operator">%</span> PTE_SZ <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
314 <span class="token function">panic</span><span class="token punctuation">(</span><span class="token string">"loaduvm: addr must be page aligned"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
315 <span class="token punctuation">}</span>
|
|
316
|
|
317 <span class="token keyword">for</span> <span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> sz<span class="token punctuation">;</span> i <span class="token operator">+</span><span class="token operator">=</span> PTE_SZ<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
318 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>pte <span class="token operator">=</span> <span class="token function">walkpgdir</span><span class="token punctuation">(</span>pgdir<span class="token punctuation">,</span> addr <span class="token operator">+</span> i<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
319 <span class="token function">panic</span><span class="token punctuation">(</span><span class="token string">"loaduvm: address should exist"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
320 <span class="token punctuation">}</span>
|
|
321
|
|
322 pa <span class="token operator">=</span> <span class="token function">PTE_ADDR</span><span class="token punctuation">(</span><span class="token operator">*</span>pte<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
323
|
|
324 <span class="token keyword">if</span> <span class="token punctuation">(</span>sz <span class="token operator">-</span> i <span class="token operator"><</span> PTE_SZ<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
325 n <span class="token operator">=</span> sz <span class="token operator">-</span> i<span class="token punctuation">;</span>
|
|
326 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
|
|
327 n <span class="token operator">=</span> PTE_SZ<span class="token punctuation">;</span>
|
|
328 <span class="token punctuation">}</span>
|
|
329
|
|
330 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">readi</span><span class="token punctuation">(</span>ip<span class="token punctuation">,</span> <span class="token function">p2v</span><span class="token punctuation">(</span>pa<span class="token punctuation">)</span><span class="token punctuation">,</span> offset <span class="token operator">+</span> i<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token operator">!=</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
331 <span class="token keyword">return</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
|
|
332 <span class="token punctuation">}</span>
|
|
333 <span class="token punctuation">}</span>
|
|
334
|
|
335 <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
|
|
336 <span class="token punctuation">}</span>
|
32
|
337 </code></pre><ul>
|
|
338 <li>loaduvm_impl がインターフェースから呼ばれる実装</li>
|
|
339 </ul><pre><code class="c hljs">__code <span class="token function">loaduvmvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode<span class="token operator">*</span> ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
340 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>pgdir <span class="token operator">=</span> pgdir<span class="token punctuation">;</span>
|
|
341 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>addr <span class="token operator">=</span> addr<span class="token punctuation">;</span>
|
|
342 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>ip <span class="token operator">=</span> ip<span class="token punctuation">;</span>
|
|
343 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>offset <span class="token operator">=</span> offset<span class="token punctuation">;</span>
|
|
344 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>sz <span class="token operator">=</span> sz<span class="token punctuation">;</span>
|
|
345 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm_impl<span class="token punctuation">)</span><span class="token operator">-></span>next <span class="token operator">=</span> next<span class="token punctuation">;</span>
|
|
346
|
|
347 <span class="token keyword">goto</span> <span class="token function">loaduvm_ptesize_checkvm_impl</span><span class="token punctuation">(</span>vm<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
348 <span class="token punctuation">}</span>
|
32
|
349 </code></pre><ul>
|
|
350 <li>loaduvm_impl から private な Code Gear が呼ばれる</li>
|
|
351 </ul><pre><code class="c hljs"><span class="token macro property">#interface "vm_impl.h"</span>
|
19
|
352
|
32
|
353 __code <span class="token function">loaduvm_ptesize_checkvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
354 <span class="token keyword">char</span><span class="token operator">*</span> addr <span class="token operator">=</span> vm_impl<span class="token operator">-></span>addr<span class="token punctuation">;</span>
|
|
355
|
|
356 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>uint<span class="token punctuation">)</span> addr <span class="token operator">%</span>PTE_SZ <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
357 <span class="token comment">// goto panic</span>
|
|
358 <span class="token punctuation">}</span>
|
|
359
|
32
|
360 <span class="token keyword">goto</span> <span class="token function">loaduvm_loopvm_impl</span><span class="token punctuation">(</span>vm_impl<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
19
|
361 <span class="token punctuation">}</span>
|
|
362 </code></pre><ul>
|
|
363 <li>vm.cではここから for だが CbC は if文の中と外にgoto を用意して実装する</li>
|
32
|
364 </ul><p><img src="https://i.imgur.com/ByA7GVJ.png" alt=""></p><pre><code class="c hljs">__code <span class="token function">loaduvm_loopvm_impl</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
365 uint i <span class="token operator">=</span> vm_impl<span class="token operator">-></span>i<span class="token punctuation">;</span>
|
|
366 uint sz <span class="token operator">=</span> vm_impl<span class="token operator">-></span>sz<span class="token punctuation">;</span>
|
|
367
|
|
368 <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator"><</span> sz<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
369 <span class="token keyword">goto</span> <span class="token function">loaduvm_check_pgdir</span><span class="token punctuation">(</span>vm_impl<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span>ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
370 <span class="token punctuation">}</span>
|
|
371
|
32
|
372 <span class="token keyword">goto</span> <span class="token function">loaduvm_exit</span><span class="token punctuation">(</span>vm_impl<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
19
|
373 <span class="token punctuation">}</span>
|
|
374
|
|
375
|
32
|
376 __code <span class="token function">loaduvm_check_pgdir</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
19
|
377 pte_t<span class="token operator">*</span> pte <span class="token operator">=</span> vm_impl<span class="token operator">-></span>pte<span class="token punctuation">;</span>
|
|
378 pde_t<span class="token operator">*</span> pgdir <span class="token operator">=</span> vm_impl<span class="token operator">-></span>pgdir<span class="token punctuation">;</span>
|
|
379 uint i <span class="token operator">=</span> vm_impl<span class="token operator">-></span>i<span class="token punctuation">;</span>
|
|
380 <span class="token keyword">char</span><span class="token operator">*</span> addr <span class="token operator">=</span> vm_impl<span class="token operator">-></span>addr<span class="token punctuation">;</span>
|
|
381 uint pa <span class="token operator">=</span> vm_impl<span class="token operator">-></span>pa<span class="token punctuation">;</span>
|
|
382
|
|
383 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>pte <span class="token operator">=</span> <span class="token function">walkpgdir</span><span class="token punctuation">(</span>pgdir<span class="token punctuation">,</span> addr <span class="token operator">+</span> i<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
384 <span class="token comment">// goto panic</span>
|
|
385 <span class="token punctuation">}</span>
|
|
386 pa <span class="token operator">=</span> <span class="token function">PTE_ADDR</span><span class="token punctuation">(</span><span class="token operator">*</span>pte<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
387
|
|
388 vm_impl<span class="token operator">-></span>pte <span class="token operator">=</span> pte<span class="token punctuation">;</span>
|
|
389 vm_impl<span class="token operator">-></span>pgdir <span class="token operator">=</span> pgdir<span class="token punctuation">;</span>
|
|
390 vm_impl<span class="token operator">-></span>addr <span class="token operator">=</span> addr<span class="token punctuation">;</span>
|
|
391 vm_impl<span class="token operator">-></span>pa <span class="token operator">=</span> pa<span class="token punctuation">;</span>
|
|
392
|
32
|
393 <span class="token keyword">goto</span> <span class="token function">loaduvm_check_PTE_SZ</span><span class="token punctuation">(</span>vm_impl<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
19
|
394 <span class="token punctuation">}</span>
|
|
395
|
|
396 __code <span class="token function">loaduvm_check_PTE_SZ</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token keyword">int</span> ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
397 <span class="token keyword">if</span> <span class="token punctuation">(</span>sz <span class="token operator">-</span> i <span class="token operator"><</span> PTE_SZ<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
398 n <span class="token operator">=</span> sz <span class="token operator">-</span> i<span class="token punctuation">;</span>
|
|
399 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
|
|
400 n <span class="token operator">=</span> PTE_SZ<span class="token punctuation">;</span>
|
|
401 <span class="token punctuation">}</span>
|
|
402
|
|
403 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">readi</span><span class="token punctuation">(</span>ip<span class="token punctuation">,</span> <span class="token function">p2v</span><span class="token punctuation">(</span>pa<span class="token punctuation">)</span><span class="token punctuation">,</span> offset <span class="token operator">+</span> i<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token operator">!=</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
404 ret <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
|
|
405 <span class="token keyword">goto</span> <span class="token function">next</span><span class="token punctuation">(</span>ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
406 <span class="token punctuation">}</span>
|
|
407
|
|
408 vm_impl<span class="token operator">-></span>n <span class="token operator">=</span> n<span class="token punctuation">;</span>
|
|
409
|
|
410 <span class="token keyword">goto</span> <span class="token function">loaduvm_loopvm_impl</span><span class="token punctuation">(</span>vm_impl<span class="token punctuation">,</span> <span class="token function">next</span><span class="token punctuation">(</span>ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
411 <span class="token punctuation">}</span>
|
|
412
|
|
413 __code <span class="token function">loaduvm_exit</span><span class="token punctuation">(</span><span class="token keyword">struct</span> vm_impl<span class="token operator">*</span> vm_impl<span class="token punctuation">,</span> __code <span class="token function">next</span><span class="token punctuation">(</span><span class="token keyword">int</span> ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
414 ret <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
|
|
415 <span class="token keyword">goto</span> <span class="token function">next</span><span class="token punctuation">(</span>ret<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
416 <span class="token punctuation">}</span>
|
32
|
417 </code></pre><hr><pre><code class="c hljs">
|
19
|
418 <span class="token keyword">int</span> loaduvm <span class="token punctuation">(</span>pde_t <span class="token operator">*</span>pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span>addr<span class="token punctuation">,</span> <span class="token keyword">struct</span> inode <span class="token operator">*</span>ip<span class="token punctuation">,</span> uint offset<span class="token punctuation">,</span> uint sz<span class="token punctuation">)</span>
|
|
419 <span class="token punctuation">{</span>
|
|
420 uint i<span class="token punctuation">,</span> pa<span class="token punctuation">,</span> n<span class="token punctuation">;</span>
|
|
421 pte_t <span class="token operator">*</span>pte<span class="token punctuation">;</span>
|
|
422
|
|
423 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>uint<span class="token punctuation">)</span> addr <span class="token operator">%</span> PTE_SZ <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
424 <span class="token function">panic</span><span class="token punctuation">(</span><span class="token string">"loaduvm: addr must be page aligned"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
425 <span class="token punctuation">}</span>
|
|
426
|
|
427 <span class="token keyword">for</span> <span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator"><</span> sz<span class="token punctuation">;</span> i <span class="token operator">+</span><span class="token operator">=</span> PTE_SZ<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
428 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>pte <span class="token operator">=</span> <span class="token function">walkpgdir</span><span class="token punctuation">(</span>pgdir<span class="token punctuation">,</span> addr <span class="token operator">+</span> i<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
429 <span class="token function">panic</span><span class="token punctuation">(</span><span class="token string">"loaduvm: address should exist"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
430 <span class="token punctuation">}</span>
|
|
431
|
|
432 pa <span class="token operator">=</span> <span class="token function">PTE_ADDR</span><span class="token punctuation">(</span><span class="token operator">*</span>pte<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
433
|
|
434 <span class="token keyword">if</span> <span class="token punctuation">(</span>sz <span class="token operator">-</span> i <span class="token operator"><</span> PTE_SZ<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
435 n <span class="token operator">=</span> sz <span class="token operator">-</span> i<span class="token punctuation">;</span>
|
|
436 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
|
|
437 n <span class="token operator">=</span> PTE_SZ<span class="token punctuation">;</span>
|
|
438 <span class="token punctuation">}</span>
|
|
439
|
|
440 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">readi</span><span class="token punctuation">(</span>ip<span class="token punctuation">,</span> <span class="token function">p2v</span><span class="token punctuation">(</span>pa<span class="token punctuation">)</span><span class="token punctuation">,</span> offset <span class="token operator">+</span> i<span class="token punctuation">,</span> n<span class="token punctuation">)</span> <span class="token operator">!=</span> n<span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
441 <span class="token keyword">return</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
|
|
442 <span class="token punctuation">}</span>
|
|
443 <span class="token punctuation">}</span>
|
|
444
|
|
445 <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
|
|
446 <span class="token punctuation">}</span>
|
32
|
447 </code></pre><hr><h1 id="stub" style=""><a class="anchor hidden-xs" href="#stub" title="stub"><span class="octicon octicon-link"></span></a>stub</h1><ul>
|
|
448 <li>goto meta はstub を呼び込んでいる</li>
|
|
449 <li>説明</li>
|
|
450 </ul><hr><h1 id="C-を-CbC-に部分的に書き直す手法" style=""><a class="anchor hidden-xs" href="#C-を-CbC-に部分的に書き直す手法" title="C-を-CbC-に部分的に書き直す手法"><span class="octicon octicon-link"></span></a>C を CbC に部分的に書き直す手法</h1><ul>
|
19
|
451 <li>CbC の場合 goto による 遷移を行うので、関数呼び出しのように goto 以降のコードを実行できない</li>
|
|
452 <li>例) goto すると戻ってこれないため それ以降が実行されなくなる。</li>
|
32
|
453 </ul><hr><h1 id="CbC-から-C-への遷移" style=""><a class="anchor hidden-xs" href="#CbC-から-C-への遷移" title="CbC-から-C-への遷移"><span class="octicon octicon-link"></span></a>CbC から C への遷移</h1><ul class="highlight">
|
19
|
454 <li>最初の命令は next で戻ってこれるので、dummy の関数を用意してそこで実行する</li>
|
32
|
455 </ul><pre class="highlight"><code class="c hljs"><span class="token keyword">void</span> <span class="token function">cbc_init_vmm_dummy</span><span class="token punctuation">(</span><span class="token keyword">struct</span> Context<span class="token operator">*</span> cbc_context<span class="token punctuation">,</span> <span class="token keyword">struct</span> proc<span class="token operator">*</span> p<span class="token punctuation">,</span> pde_t<span class="token operator">*</span> pgdir<span class="token punctuation">,</span> <span class="token keyword">char</span><span class="token operator">*</span> init<span class="token punctuation">,</span> uint sz<span class="token punctuation">)</span>
|
|
456 <span class="token punctuation">{</span>
|
19
|
457 <span class="token comment">// inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);</span>
|
|
458
|
|
459 <span class="token keyword">struct</span> vm<span class="token operator">*</span> vm <span class="token operator">=</span> <span class="token function">createvm_impl</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
460 <span class="token comment">// goto vm->init_vmm(vm, pgdir, init, sz , vm->void_ret);</span>
|
|
461 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token punctuation">)</span><span class="token operator">-></span>vm <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">union</span> Data<span class="token operator">*</span><span class="token punctuation">)</span> vm<span class="token punctuation">;</span>
|
|
462 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token punctuation">)</span><span class="token operator">-></span>pgdir <span class="token operator">=</span> pgdir<span class="token punctuation">;</span>
|
|
463 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token punctuation">)</span><span class="token operator">-></span>init <span class="token operator">=</span> init<span class="token punctuation">;</span>
|
|
464 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token punctuation">)</span><span class="token operator">-></span>sz <span class="token operator">=</span> sz <span class="token punctuation">;</span>
|
|
465 <span class="token function">Gearef</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token punctuation">)</span><span class="token operator">-></span>next <span class="token operator">=</span> C_vm_void_ret <span class="token punctuation">;</span>
|
|
466 <span class="token keyword">goto</span> <span class="token function">meta</span><span class="token punctuation">(</span>cbc_context<span class="token punctuation">,</span> vm<span class="token operator">-></span>init_inituvm<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
467 <span class="token punctuation">}</span>
|
|
468
|
|
469 <span class="token keyword">void</span> <span class="token function">userinit</span><span class="token punctuation">(</span><span class="token keyword">void</span><span class="token punctuation">)</span>
|
|
470 <span class="token punctuation">{</span>
|
|
471 <span class="token keyword">struct</span> proc<span class="token operator">*</span> p<span class="token punctuation">;</span>
|
|
472 <span class="token keyword">extern</span> <span class="token keyword">char</span> _binary_initcode_start<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> _binary_initcode_size<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
|
|
473
|
|
474 p <span class="token operator">=</span> <span class="token function">allocproc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
475 <span class="token function">initContext</span><span class="token punctuation">(</span><span class="token operator">&</span>p<span class="token operator">-></span>cbc_context<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
476
|
|
477 initproc <span class="token operator">=</span> p<span class="token punctuation">;</span>
|
|
478
|
|
479 <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>p<span class="token operator">-></span>pgdir <span class="token operator">=</span> <span class="token function">kpt_alloc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token constant">NULL</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
|
|
480 <span class="token function">panic</span><span class="token punctuation">(</span><span class="token string">"userinit: out of memory?"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
|
|
481 <span class="token punctuation">}</span>
|
|
482
|
32
|
483 <span class="token function">cbc_init_vmm_dummy</span><span class="token punctuation">(</span><span class="token operator">&</span>p<span class="token operator">-></span>cbc_context<span class="token punctuation">,</span> p<span class="token punctuation">,</span> p<span class="token operator">-></span>pgdir<span class="token punctuation">,</span> _binary_initcode_start<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span>_binary_initcode_size<span class="token punctuation">)</span><span class="token punctuation">;</span>
|
19
|
484
|
32
|
485 </code></pre><hr><h1 id="まとめ" style=""><a class="anchor hidden-xs" href="#まとめ" title="まとめ"><span class="octicon octicon-link"></span></a>まとめ</h1></div>
|
17
|
486 <div class="ui-toc dropup unselectable hidden-print" style="display:none;">
|
|
487 <div class="pull-right dropdown">
|
|
488 <a id="tocLabel" class="ui-toc-label btn btn-default" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" title="Table of content">
|
|
489 <i class="fa fa-bars"></i>
|
|
490 </a>
|
|
491 <ul id="ui-toc" class="ui-toc-dropdown dropdown-menu" aria-labelledby="tocLabel">
|
|
492 <div class="toc"><ul class="nav">
|
19
|
493 <li class=""><a href="#CbCインターフェースによる-CbCXv6-の書き換え" title="CbCインターフェースによる CbCXv6 の書き換え">CbCインターフェースによる CbCXv6 の書き換え</a></li>
|
32
|
494 <li class=""><a href="#概要" title="概要">概要</a></li>
|
|
495 <li class=""><a href="#OS-の信頼性を上げたい" title="OS の信頼性を上げたい">OS の信頼性を上げたい</a></li>
|
|
496 <li class=""><a href="#メタレベルとノーマルレベル" title="メタレベルとノーマルレベル">メタレベルとノーマルレベル</a></li>
|
|
497 <li class=""><a href="#Continuation-based-C" title="Continuation based C">Continuation based C</a></li>
|
|
498 <li class=""><a href="#goto-による継続" title="goto による継続">goto による継続</a></li>
|
|
499 <li class=""><a href="#Data-Gear-の継続" title="Data Gear の継続">Data Gear の継続</a></li>
|
|
500 <li class=""><a href="#Meta-Code-Gear" title="Meta Code Gear">Meta Code Gear</a></li>
|
|
501 <li class=""><a href="#Meta-Data-Gear" title="Meta Data Gear">Meta Data Gear</a></li>
|
|
502 <li class=""><a href="#Xv6" title="Xv6">Xv6</a></li>
|
|
503 <li class=""><a href="#Xv6の構成" title="Xv6の構成">Xv6の構成</a></li>
|
|
504 <li class=""><a href="#カーネル空間" title="カーネル空間">カーネル空間</a></li>
|
|
505 <li class=""><a href="#system-call" title="system call">system call</a></li>
|
|
506 <li class=""><a href="#Paging" title="Paging">Paging</a></li>
|
|
507 <li class=""><a href="#Xv6の書き換え方針" title="Xv6の書き換え方針">Xv6の書き換え方針</a></li>
|
|
508 <li class=""><a href="#CbCインターフェース0" title="CbCインターフェース">CbCインターフェース</a></li>
|
|
509 <li class=""><a href="#CbCインターフェース" title="CbCインターフェース">CbCインターフェース</a></li>
|
|
510 <li class=""><a href="#インターフェースの定義0" title="インターフェースの定義">インターフェースの定義</a></li>
|
|
511 <li><a href="#インターフェースの命名" title="インターフェースの命名">インターフェースの命名</a></li>
|
|
512 <li><a href="#インターフェースの-Code-Gear" title="インターフェースの Code Gear">インターフェースの Code Gear</a></li>
|
19
|
513 <li><a href="#next…" title="next(…)">next(…)</a></li>
|
32
|
514 <li><a href="#Interface-の実装の型" title="Interface の実装の型">Interface の実装の型</a></li>
|
19
|
515 <li><a href="#インターフェースの実装" title="インターフェースの実装">インターフェースの実装</a></li>
|
32
|
516 <li><a href="#vm_impl-のコンストラクタ" title="vm_impl のコンストラクタ">vm_impl のコンストラクタ</a></li>
|
|
517 <li class=""><a href="#インターフェース実装内の-CbC" title="インターフェース実装内の CbC">インターフェース実装内の CbC</a></li>
|
|
518 <li><a href="#実装内の明示的な遷移の処理" title="実装内の明示的な遷移の処理">実装内の明示的な遷移の処理</a></li>
|
|
519 <li><a href="#loaduvmの-CbCによる書き換え" title="loaduvmの CbCによる書き換え">loaduvmの CbCによる書き換え</a></li>
|
|
520 <li><a href="#stub" title="stub">stub</a></li>
|
|
521 <li><a href="#C-を-CbC-に部分的に書き直す手法" title="C を CbC に部分的に書き直す手法">C を CbC に部分的に書き直す手法</a></li>
|
|
522 <li><a href="#CbC-から-C-への遷移" title="CbC から C への遷移">CbC から C への遷移</a></li>
|
|
523 <li><a href="#まとめ" title="まとめ">まとめ</a></li>
|
17
|
524 </ul>
|
|
525 </div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
|
|
526 </ul>
|
|
527 </div>
|
|
528 </div>
|
|
529 <div id="ui-toc-affix" class="ui-affix-toc ui-toc-dropdown unselectable hidden-print" data-spy="affix" style="top:17px;display:none;" null null>
|
|
530 <div class="toc"><ul class="nav">
|
19
|
531 <li class=""><a href="#CbCインターフェースによる-CbCXv6-の書き換え" title="CbCインターフェースによる CbCXv6 の書き換え">CbCインターフェースによる CbCXv6 の書き換え</a></li>
|
32
|
532 <li class=""><a href="#概要" title="概要">概要</a></li>
|
|
533 <li class=""><a href="#OS-の信頼性を上げたい" title="OS の信頼性を上げたい">OS の信頼性を上げたい</a></li>
|
|
534 <li class=""><a href="#メタレベルとノーマルレベル" title="メタレベルとノーマルレベル">メタレベルとノーマルレベル</a></li>
|
|
535 <li class=""><a href="#Continuation-based-C" title="Continuation based C">Continuation based C</a></li>
|
|
536 <li class=""><a href="#goto-による継続" title="goto による継続">goto による継続</a></li>
|
|
537 <li class=""><a href="#Data-Gear-の継続" title="Data Gear の継続">Data Gear の継続</a></li>
|
|
538 <li class=""><a href="#Meta-Code-Gear" title="Meta Code Gear">Meta Code Gear</a></li>
|
|
539 <li class=""><a href="#Meta-Data-Gear" title="Meta Data Gear">Meta Data Gear</a></li>
|
|
540 <li class=""><a href="#Xv6" title="Xv6">Xv6</a></li>
|
|
541 <li class=""><a href="#Xv6の構成" title="Xv6の構成">Xv6の構成</a></li>
|
|
542 <li class=""><a href="#カーネル空間" title="カーネル空間">カーネル空間</a></li>
|
|
543 <li class=""><a href="#system-call" title="system call">system call</a></li>
|
|
544 <li class=""><a href="#Paging" title="Paging">Paging</a></li>
|
|
545 <li class=""><a href="#Xv6の書き換え方針" title="Xv6の書き換え方針">Xv6の書き換え方針</a></li>
|
|
546 <li class=""><a href="#CbCインターフェース0" title="CbCインターフェース">CbCインターフェース</a></li>
|
|
547 <li class=""><a href="#CbCインターフェース" title="CbCインターフェース">CbCインターフェース</a></li>
|
|
548 <li class=""><a href="#インターフェースの定義0" title="インターフェースの定義">インターフェースの定義</a></li>
|
|
549 <li><a href="#インターフェースの命名" title="インターフェースの命名">インターフェースの命名</a></li>
|
|
550 <li><a href="#インターフェースの-Code-Gear" title="インターフェースの Code Gear">インターフェースの Code Gear</a></li>
|
19
|
551 <li><a href="#next…" title="next(…)">next(…)</a></li>
|
32
|
552 <li><a href="#Interface-の実装の型" title="Interface の実装の型">Interface の実装の型</a></li>
|
19
|
553 <li><a href="#インターフェースの実装" title="インターフェースの実装">インターフェースの実装</a></li>
|
32
|
554 <li><a href="#vm_impl-のコンストラクタ" title="vm_impl のコンストラクタ">vm_impl のコンストラクタ</a></li>
|
|
555 <li class=""><a href="#インターフェース実装内の-CbC" title="インターフェース実装内の CbC">インターフェース実装内の CbC</a></li>
|
|
556 <li><a href="#実装内の明示的な遷移の処理" title="実装内の明示的な遷移の処理">実装内の明示的な遷移の処理</a></li>
|
|
557 <li><a href="#loaduvmの-CbCによる書き換え" title="loaduvmの CbCによる書き換え">loaduvmの CbCによる書き換え</a></li>
|
|
558 <li><a href="#stub" title="stub">stub</a></li>
|
|
559 <li><a href="#C-を-CbC-に部分的に書き直す手法" title="C を CbC に部分的に書き直す手法">C を CbC に部分的に書き直す手法</a></li>
|
|
560 <li><a href="#CbC-から-C-への遷移" title="CbC から C への遷移">CbC から C への遷移</a></li>
|
|
561 <li><a href="#まとめ" title="まとめ">まとめ</a></li>
|
17
|
562 </ul>
|
|
563 </div><div class="toc-menu"><a class="expand-toggle" href="#">Expand all</a><a class="back-to-top" href="#">Back to top</a><a class="go-to-bottom" href="#">Go to bottom</a></div>
|
|
564 </div>
|
|
565 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
|
566 <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous" defer></script>
|
|
567 <script src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.6.0/gist-embed.min.js" integrity="sha256-KyF2D6xPIJUW5sUDSs93vWyZm+1RzIpKCexxElmxl8g=" crossorigin="anonymous" defer></script>
|
|
568 <script>
|
|
569 var markdown = $(".markdown-body");
|
|
570 //smooth all hash trigger scrolling
|
|
571 function smoothHashScroll() {
|
|
572 var hashElements = $("a[href^='#']").toArray();
|
|
573 for (var i = 0; i < hashElements.length; i++) {
|
|
574 var element = hashElements[i];
|
|
575 var $element = $(element);
|
|
576 var hash = element.hash;
|
|
577 if (hash) {
|
|
578 $element.on('click', function (e) {
|
|
579 // store hash
|
|
580 var hash = this.hash;
|
|
581 if ($(hash).length <= 0) return;
|
|
582 // prevent default anchor click behavior
|
|
583 e.preventDefault();
|
|
584 // animate
|
|
585 $('body, html').stop(true, true).animate({
|
|
586 scrollTop: $(hash).offset().top
|
|
587 }, 100, "linear", function () {
|
|
588 // when done, add hash to url
|
|
589 // (default click behaviour)
|
|
590 window.location.hash = hash;
|
|
591 });
|
|
592 });
|
|
593 }
|
|
594 }
|
|
595 }
|
|
596
|
|
597 smoothHashScroll();
|
|
598 var toc = $('.ui-toc');
|
|
599 var tocAffix = $('.ui-affix-toc');
|
|
600 var tocDropdown = $('.ui-toc-dropdown');
|
|
601 //toc
|
|
602 tocDropdown.click(function (e) {
|
|
603 e.stopPropagation();
|
|
604 });
|
|
605
|
|
606 var enoughForAffixToc = true;
|
|
607
|
|
608 function generateScrollspy() {
|
|
609 $(document.body).scrollspy({
|
|
610 target: ''
|
|
611 });
|
|
612 $(document.body).scrollspy('refresh');
|
|
613 if (enoughForAffixToc) {
|
|
614 toc.hide();
|
|
615 tocAffix.show();
|
|
616 } else {
|
|
617 tocAffix.hide();
|
|
618 toc.show();
|
|
619 }
|
|
620 $(document.body).scroll();
|
|
621 }
|
|
622
|
|
623 function windowResize() {
|
|
624 //toc right
|
|
625 var paddingRight = parseFloat(markdown.css('padding-right'));
|
|
626 var right = ($(window).width() - (markdown.offset().left + markdown.outerWidth() - paddingRight));
|
|
627 toc.css('right', right + 'px');
|
|
628 //affix toc left
|
|
629 var newbool;
|
|
630 var rightMargin = (markdown.parent().outerWidth() - markdown.outerWidth()) / 2;
|
|
631 //for ipad or wider device
|
|
632 if (rightMargin >= 133) {
|
|
633 newbool = true;
|
|
634 var affixLeftMargin = (tocAffix.outerWidth() - tocAffix.width()) / 2;
|
|
635 var left = markdown.offset().left + markdown.outerWidth() - affixLeftMargin;
|
|
636 tocAffix.css('left', left + 'px');
|
|
637 } else {
|
|
638 newbool = false;
|
|
639 }
|
|
640 if (newbool != enoughForAffixToc) {
|
|
641 enoughForAffixToc = newbool;
|
|
642 generateScrollspy();
|
|
643 }
|
|
644 }
|
|
645 $(window).resize(function () {
|
|
646 windowResize();
|
|
647 });
|
|
648 $(document).ready(function () {
|
|
649 windowResize();
|
|
650 generateScrollspy();
|
|
651 });
|
|
652
|
|
653 //remove hash
|
|
654 function removeHash() {
|
|
655 window.location.hash = '';
|
|
656 }
|
|
657
|
|
658 var backtotop = $('.back-to-top');
|
|
659 var gotobottom = $('.go-to-bottom');
|
|
660
|
|
661 backtotop.click(function (e) {
|
|
662 e.preventDefault();
|
|
663 e.stopPropagation();
|
|
664 if (scrollToTop)
|
|
665 scrollToTop();
|
|
666 removeHash();
|
|
667 });
|
|
668 gotobottom.click(function (e) {
|
|
669 e.preventDefault();
|
|
670 e.stopPropagation();
|
|
671 if (scrollToBottom)
|
|
672 scrollToBottom();
|
|
673 removeHash();
|
|
674 });
|
|
675
|
|
676 var toggle = $('.expand-toggle');
|
|
677 var tocExpand = false;
|
|
678
|
|
679 checkExpandToggle();
|
|
680 toggle.click(function (e) {
|
|
681 e.preventDefault();
|
|
682 e.stopPropagation();
|
|
683 tocExpand = !tocExpand;
|
|
684 checkExpandToggle();
|
|
685 })
|
|
686
|
|
687 function checkExpandToggle () {
|
|
688 var toc = $('.ui-toc-dropdown .toc');
|
|
689 var toggle = $('.expand-toggle');
|
|
690 if (!tocExpand) {
|
|
691 toc.removeClass('expand');
|
|
692 toggle.text('Expand all');
|
|
693 } else {
|
|
694 toc.addClass('expand');
|
|
695 toggle.text('Collapse all');
|
|
696 }
|
|
697 }
|
|
698
|
|
699 function scrollToTop() {
|
|
700 $('body, html').stop(true, true).animate({
|
|
701 scrollTop: 0
|
|
702 }, 100, "linear");
|
|
703 }
|
|
704
|
|
705 function scrollToBottom() {
|
|
706 $('body, html').stop(true, true).animate({
|
|
707 scrollTop: $(document.body)[0].scrollHeight
|
|
708 }, 100, "linear");
|
|
709 }
|
|
710 </script>
|
|
711 </body>
|
|
712
|
|
713 </html>
|