text
stringlengths
1
1.05M
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ #include <iostream> #include <thread> #include <string> #include <mutex> #include <echolib/client.h> #include <echolib/datatypes.h> using namespace std; using namespace echolib; #define DELIMITER "$ " namespace echolib { //template <> inline string get_type_identifier<echolib::Dictionary>() { return string("dictionary"); } template <> inline string get_type_identifier<pair<string, string> >() { return string("string pair"); } template<> inline shared_ptr<Message> Message::pack<pair<string, string> >(const pair<string, string> &data) { MessageWriter writer(data.first.size() + data.second.size() + 8); writer.write_string(data.first); writer.write_string(data.second); return make_shared<BufferedMessage>(writer); } template<> inline shared_ptr<pair<string, string> > Message::unpack<pair<string, string> >(SharedMessage message) { MessageReader reader(message); string user = reader.read_string(); string text = reader.read_string(); return make_shared<pair<string, string> >(user, text); } } int main(int argc, char** argv) { SharedIOLoop loop = make_shared<IOLoop>(); string address; if (argc > 1) { address = string(argv[1]); } //Connect to local socket based daemon SharedClient client = make_shared<echolib::Client>(address); loop->add_handler(client); string name; cout << "Enter your name\n"; std::getline(std::cin, name); std::mutex mutex; function<void(shared_ptr<pair<string, string> >)> chat_callback = [&](shared_ptr<pair<string, string> > m) { const string name = m->first; const string message = m->second; std::cout<< name << ": " << message << std::endl; }; function<void(int)> subscribe_callback = [&](int m) { std::cout << "Total subscribers: " << m << std::endl; }; TypedSubscriber<pair<string, string> > sub(client, "chat", chat_callback); SubscriptionWatcher watch(client, "chat", subscribe_callback); TypedPublisher<pair<string, string> > pub(client, "chat"); std::thread write([&]() { while (client->is_connected()) { string message; std::getline(std::cin, message); pub.send(pair<string, string>(name, message)); } }); while(loop->wait(10)) { // We have to give the write thread some space std::this_thread::sleep_for(std::chrono::milliseconds(10)); } exit(0); }
lc r4, 0x00000000 lc r5, 0x0000101f lc r6, 0x00000000 tlbse r6, r4 lc r8, 0x40000000 lc r9, 0x0000101f lc r10, 0x00000001 tlbse r10, r8 lc r11, 0xdeadbeef lc r12, 0x80000000 lc r13, 0x80000000 st4 r11, r12, 0 ex4 r30, r12, 0 halt #@expected values #r4 = 0x00000000 #r5 = 0x0000101f #r6 = 0x00000000 #tlb 0: # vpn = 0x00000 # os = 0x000 # ppn = 0x00001 # at = 0x01f #r8 = 0x40000000 #r9 = 0x0000101f #r10 = 0x00000001 #tlb 1: # vpn = 0x40000 # os = 0x000 # ppn = 0x00001 # at = 0x01f #r11 = 0xdeadbeef #r12 = 0x80000000 #r13 = 0x80000000 #r30 = 0xdeadbeef #pc = 0x80000048
#include "query_parser.h" #include "http_filemapper.h" namespace simpleServer { #ifdef _WIN32 char HttpFileMapper::pathSeparator = '\\'; #else char HttpFileMapper::pathSeparator = '/'; #endif HttpFileMapper::HttpFileMapper(std::string &&documentRoot, std::string &&index) :documentRoot(std::move(documentRoot)) ,index(std::move(index)) { /* if (this->documentRoot.empty() || this->documentRoot[this->documentRoot.length()-1] != pathSeparator) { this->documentRoot.push_back(pathSeparator); }*/ } bool HttpFileMapper::mapFile(const HTTPRequest& req, StrViewA fullPathname) { StrViewA mime = mapMime(fullPathname); req.sendFile(fullPathname, mime, true); return true; } void HttpFileMapper::operator ()(const HTTPRequest& req) { bool res = operator()(req,req.getPath()); if (res == false) return req.sendErrorPage(404); } static const std::pair<StrViewA, StrViewA> mimeList[]={ {".323", "text/h323"}, {".3g2", "video/3gpp2"}, {".3gp", "video/3gpp"}, {".3gp2", "video/3gpp2"}, {".3gpp", "video/3gpp"}, {".7z", "application/x-7z-compressed"}, {".aa", "audio/audible"}, {".AAC", "audio/aac"}, {".aaf", "application/octet-stream"}, {".aax", "audio/vnd.audible.aax"}, {".ac3", "audio/ac3"}, {".aca", "application/octet-stream"}, {".accda", "application/msaccess.addin"}, {".accdb", "application/msaccess"}, {".accdc", "application/msaccess.cab"}, {".accde", "application/msaccess"}, {".accdr", "application/msaccess.runtime"}, {".accdt", "application/msaccess"}, {".accdw", "application/msaccess.webapplication"}, {".accft", "application/msaccess.ftemplate"}, {".acx", "application/internet-property-stream"}, {".AddIn", "text/xml"}, {".ade", "application/msaccess"}, {".adobebridge", "application/x-bridge-url"}, {".adp", "application/msaccess"}, {".ADT", "audio/vnd.dlna.adts"}, {".ADTS", "audio/aac"}, {".afm", "application/octet-stream"}, {".ai", "application/postscript"}, {".aif", "audio/aiff"}, {".aifc", "audio/aiff"}, {".aiff", "audio/aiff"}, {".air", "application/vnd.adobe.air-application-installer-package+zip"}, {".amc", "application/mpeg"}, {".anx", "application/annodex"}, {".apk", "application/vnd.android.package-archive" }, {".application", "application/x-ms-application"}, {".art", "image/x-jg"}, {".asa", "application/xml"}, {".asax", "application/xml"}, {".ascx", "application/xml"}, {".asd", "application/octet-stream"}, {".asf", "video/x-ms-asf"}, {".ashx", "application/xml"}, {".asi", "application/octet-stream"}, {".asm", "text/plain"}, {".asmx", "application/xml"}, {".aspx", "application/xml"}, {".asr", "video/x-ms-asf"}, {".asx", "video/x-ms-asf"}, {".atom", "application/atom+xml"}, {".au", "audio/basic"}, {".avi", "video/x-msvideo"}, {".axa", "audio/annodex"}, {".axs", "application/olescript"}, {".axv", "video/annodex"}, {".bas", "text/plain"}, {".bcpio", "application/x-bcpio"}, {".bin", "application/octet-stream"}, {".bmp", "image/bmp"}, {".c", "text/plain"}, {".cab", "application/octet-stream"}, {".caf", "audio/x-caf"}, {".calx", "application/vnd.ms-office.calx"}, {".cat", "application/vnd.ms-pki.seccat"}, {".cc", "text/plain"}, {".cd", "text/plain"}, {".cdda", "audio/aiff"}, {".cdf", "application/x-cdf"}, {".cer", "application/x-x509-ca-cert"}, {".cfg", "text/plain"}, {".chm", "application/octet-stream"}, {".class", "application/x-java-applet"}, {".clp", "application/x-msclip"}, {".cmd", "text/plain"}, {".cmx", "image/x-cmx"}, {".cnf", "text/plain"}, {".cod", "image/cis-cod"}, {".config", "application/xml"}, {".contact", "text/x-ms-contact"}, {".coverage", "application/xml"}, {".cpio", "application/x-cpio"}, {".cpp", "text/plain"}, {".crd", "application/x-mscardfile"}, {".crl", "application/pkix-crl"}, {".crt", "application/x-x509-ca-cert"}, {".cs", "text/plain"}, {".csdproj", "text/plain"}, {".csh", "application/x-csh"}, {".csproj", "text/plain"}, {".css", "text/css"}, {".csv", "text/csv"}, {".cur", "application/octet-stream"}, {".cxx", "text/plain"}, {".dat", "application/octet-stream"}, {".datasource", "application/xml"}, {".dbproj", "text/plain"}, {".dcr", "application/x-director"}, {".def", "text/plain"}, {".deploy", "application/octet-stream"}, {".der", "application/x-x509-ca-cert"}, {".dgml", "application/xml"}, {".dib", "image/bmp"}, {".dif", "video/x-dv"}, {".dir", "application/x-director"}, {".disco", "text/xml"}, {".divx", "video/divx"}, {".dll", "application/x-msdownload"}, {".dll.config", "text/xml"}, {".dlm", "text/dlm"}, {".doc", "application/msword"}, {".docm", "application/vnd.ms-word.document.macroEnabled.12"}, {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, {".dot", "application/msword"}, {".dotm", "application/vnd.ms-word.template.macroEnabled.12"}, {".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"}, {".dsp", "application/octet-stream"}, {".dsw", "text/plain"}, {".dtd", "text/xml"}, {".dtsConfig", "text/xml"}, {".dv", "video/x-dv"}, {".dvi", "application/x-dvi"}, {".dwf", "drawing/x-dwf"}, {".dwg", "application/acad"}, {".dwp", "application/octet-stream"}, {".dxf", "application/x-dxf" }, {".dxr", "application/x-director"}, {".eml", "message/rfc822"}, {".emz", "application/octet-stream"}, {".eot", "application/vnd.ms-fontobject"}, {".eps", "application/postscript"}, {".etl", "application/etl"}, {".etx", "text/x-setext"}, {".evy", "application/envoy"}, {".exe", "application/octet-stream"}, {".exe.config", "text/xml"}, {".fdf", "application/vnd.fdf"}, {".fif", "application/fractals"}, {".filters", "application/xml"}, {".fla", "application/octet-stream"}, {".flac", "audio/flac"}, {".flr", "x-world/x-vrml"}, {".flv", "video/x-flv"}, {".fsscript", "application/fsharp-script"}, {".fsx", "application/fsharp-script"}, {".generictest", "application/xml"}, {".gif", "image/gif"}, {".gpx", "application/gpx+xml"}, {".group", "text/x-ms-group"}, {".gsm", "audio/x-gsm"}, {".gtar", "application/x-gtar"}, {".gz", "application/x-gzip"}, {".h", "text/plain"}, {".hdf", "application/x-hdf"}, {".hdml", "text/x-hdml"}, {".hhc", "application/x-oleobject"}, {".hhk", "application/octet-stream"}, {".hhp", "application/octet-stream"}, {".hlp", "application/winhlp"}, {".hpp", "text/plain"}, {".hqx", "application/mac-binhex40"}, {".hta", "application/hta"}, {".htc", "text/x-component"}, {".htm", "text/html"}, {".html", "text/html"}, {".htt", "text/webviewhtml"}, {".hxa", "application/xml"}, {".hxc", "application/xml"}, {".hxd", "application/octet-stream"}, {".hxe", "application/xml"}, {".hxf", "application/xml"}, {".hxh", "application/octet-stream"}, {".hxi", "application/octet-stream"}, {".hxk", "application/xml"}, {".hxq", "application/octet-stream"}, {".hxr", "application/octet-stream"}, {".hxs", "application/octet-stream"}, {".hxt", "text/html"}, {".hxv", "application/xml"}, {".hxw", "application/octet-stream"}, {".hxx", "text/plain"}, {".i", "text/plain"}, {".ico", "image/x-icon"}, {".ics", "application/octet-stream"}, {".idl", "text/plain"}, {".ief", "image/ief"}, {".iii", "application/x-iphone"}, {".inc", "text/plain"}, {".inf", "application/octet-stream"}, {".ini", "text/plain"}, {".inl", "text/plain"}, {".ins", "application/x-internet-signup"}, {".ipa", "application/x-itunes-ipa"}, {".ipg", "application/x-itunes-ipg"}, {".ipproj", "text/plain"}, {".ipsw", "application/x-itunes-ipsw"}, {".iqy", "text/x-ms-iqy"}, {".isp", "application/x-internet-signup"}, {".ite", "application/x-itunes-ite"}, {".itlp", "application/x-itunes-itlp"}, {".itms", "application/x-itunes-itms"}, {".itpc", "application/x-itunes-itpc"}, {".IVF", "video/x-ivf"}, {".jar", "application/java-archive"}, {".java", "application/octet-stream"}, {".jck", "application/liquidmotion"}, {".jcz", "application/liquidmotion"}, {".jfif", "image/pjpeg"}, {".jnlp", "application/x-java-jnlp-file"}, {".jpb", "application/octet-stream"}, {".jpe", "image/jpeg"}, {".jpeg", "image/jpeg"}, {".jpg", "image/jpeg"}, {".js", "application/javascript"}, {".json", "application/json"}, {".jsx", "text/jscript"}, {".jsxbin", "text/plain"}, {".latex", "application/x-latex"}, {".library-ms", "application/windows-library+xml"}, {".lit", "application/x-ms-reader"}, {".loadtest", "application/xml"}, {".lpk", "application/octet-stream"}, {".lsf", "video/x-la-asf"}, {".lst", "text/plain"}, {".lsx", "video/x-la-asf"}, {".lzh", "application/octet-stream"}, {".m13", "application/x-msmediaview"}, {".m14", "application/x-msmediaview"}, {".m1v", "video/mpeg"}, {".m2t", "video/vnd.dlna.mpeg-tts"}, {".m2ts", "video/vnd.dlna.mpeg-tts"}, {".m2v", "video/mpeg"}, {".m3u", "audio/x-mpegurl"}, {".m3u8", "audio/x-mpegurl"}, {".m4a", "audio/m4a"}, {".m4b", "audio/m4b"}, {".m4p", "audio/m4p"}, {".m4r", "audio/x-m4r"}, {".m4v", "video/x-m4v"}, {".mac", "image/x-macpaint"}, {".mak", "text/plain"}, {".man", "application/x-troff-man"}, {".manifest", "application/x-ms-manifest"}, {".map", "text/plain"}, {".master", "application/xml"}, {".mbox", "application/mbox"}, {".mda", "application/msaccess"}, {".mdb", "application/x-msaccess"}, {".mde", "application/msaccess"}, {".mdp", "application/octet-stream"}, {".me", "application/x-troff-me"}, {".mfp", "application/x-shockwave-flash"}, {".mht", "message/rfc822"}, {".mhtml", "message/rfc822"}, {".mid", "audio/mid"}, {".midi", "audio/mid"}, {".mix", "application/octet-stream"}, {".mk", "text/plain"}, {".mmf", "application/x-smaf"}, {".mno", "text/xml"}, {".mny", "application/x-msmoney"}, {".mod", "video/mpeg"}, {".mov", "video/quicktime"}, {".movie", "video/x-sgi-movie"}, {".mp2", "video/mpeg"}, {".mp2v", "video/mpeg"}, {".mp3", "audio/mpeg"}, {".mp4", "video/mp4"}, {".mp4v", "video/mp4"}, {".mpa", "video/mpeg"}, {".mpe", "video/mpeg"}, {".mpeg", "video/mpeg"}, {".mpf", "application/vnd.ms-mediapackage"}, {".mpg", "video/mpeg"}, {".mpp", "application/vnd.ms-project"}, {".mpv2", "video/mpeg"}, {".mqv", "video/quicktime"}, {".ms", "application/x-troff-ms"}, {".msg", "application/vnd.ms-outlook"}, {".msi", "application/octet-stream"}, {".mso", "application/octet-stream"}, {".mts", "video/vnd.dlna.mpeg-tts"}, {".mtx", "application/xml"}, {".mvb", "application/x-msmediaview"}, {".mvc", "application/x-miva-compiled"}, {".mxp", "application/x-mmxp"}, {".nc", "application/x-netcdf"}, {".nsc", "video/x-ms-asf"}, {".nws", "message/rfc822"}, {".ocx", "application/octet-stream"}, {".oda", "application/oda"}, {".odb", "application/vnd.oasis.opendocument.database"}, {".odc", "application/vnd.oasis.opendocument.chart"}, {".odf", "application/vnd.oasis.opendocument.formula"}, {".odg", "application/vnd.oasis.opendocument.graphics"}, {".odh", "text/plain"}, {".odi", "application/vnd.oasis.opendocument.image"}, {".odl", "text/plain"}, {".odm", "application/vnd.oasis.opendocument.text-master"}, {".odp", "application/vnd.oasis.opendocument.presentation"}, {".ods", "application/vnd.oasis.opendocument.spreadsheet"}, {".odt", "application/vnd.oasis.opendocument.text"}, {".oga", "audio/ogg"}, {".ogg", "audio/ogg"}, {".ogv", "video/ogg"}, {".ogx", "application/ogg"}, {".one", "application/onenote"}, {".onea", "application/onenote"}, {".onepkg", "application/onenote"}, {".onetmp", "application/onenote"}, {".onetoc", "application/onenote"}, {".onetoc2", "application/onenote"}, {".opus", "audio/ogg"}, {".orderedtest", "application/xml"}, {".osdx", "application/opensearchdescription+xml"}, {".otf", "application/font-sfnt"}, {".otg", "application/vnd.oasis.opendocument.graphics-template"}, {".oth", "application/vnd.oasis.opendocument.text-web"}, {".otp", "application/vnd.oasis.opendocument.presentation-template"}, {".ots", "application/vnd.oasis.opendocument.spreadsheet-template"}, {".ott", "application/vnd.oasis.opendocument.text-template"}, {".oxt", "application/vnd.openofficeorg.extension"}, {".p10", "application/pkcs10"}, {".p12", "application/x-pkcs12"}, {".p7b", "application/x-pkcs7-certificates"}, {".p7c", "application/pkcs7-mime"}, {".p7m", "application/pkcs7-mime"}, {".p7r", "application/x-pkcs7-certreqresp"}, {".p7s", "application/pkcs7-signature"}, {".pbm", "image/x-portable-bitmap"}, {".pcast", "application/x-podcast"}, {".pct", "image/pict"}, {".pcx", "application/octet-stream"}, {".pcz", "application/octet-stream"}, {".pdf", "application/pdf"}, {".pfb", "application/octet-stream"}, {".pfm", "application/octet-stream"}, {".pfx", "application/x-pkcs12"}, {".pgm", "image/x-portable-graymap"}, {".pic", "image/pict"}, {".pict", "image/pict"}, {".pkgdef", "text/plain"}, {".pkgundef", "text/plain"}, {".pko", "application/vnd.ms-pki.pko"}, {".pls", "audio/scpls"}, {".pma", "application/x-perfmon"}, {".pmc", "application/x-perfmon"}, {".pml", "application/x-perfmon"}, {".pmr", "application/x-perfmon"}, {".pmw", "application/x-perfmon"}, {".png", "image/png"}, {".pnm", "image/x-portable-anymap"}, {".pnt", "image/x-macpaint"}, {".pntg", "image/x-macpaint"}, {".pnz", "image/png"}, {".pot", "application/vnd.ms-powerpoint"}, {".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"}, {".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"}, {".ppa", "application/vnd.ms-powerpoint"}, {".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"}, {".ppm", "image/x-portable-pixmap"}, {".pps", "application/vnd.ms-powerpoint"}, {".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"}, {".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"}, {".ppt", "application/vnd.ms-powerpoint"}, {".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"}, {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, {".prf", "application/pics-rules"}, {".prm", "application/octet-stream"}, {".prx", "application/octet-stream"}, {".ps", "application/postscript"}, {".psc1", "application/PowerShell"}, {".psd", "application/octet-stream"}, {".psess", "application/xml"}, {".psm", "application/octet-stream"}, {".psp", "application/octet-stream"}, {".pst", "application/vnd.ms-outlook"}, {".pub", "application/x-mspublisher"}, {".pwz", "application/vnd.ms-powerpoint"}, {".qht", "text/x-html-insertion"}, {".qhtm", "text/x-html-insertion"}, {".qt", "video/quicktime"}, {".qti", "image/x-quicktime"}, {".qtif", "image/x-quicktime"}, {".qtl", "application/x-quicktimeplayer"}, {".qxd", "application/octet-stream"}, {".ra", "audio/x-pn-realaudio"}, {".ram", "audio/x-pn-realaudio"}, {".rar", "application/x-rar-compressed"}, {".ras", "image/x-cmu-raster"}, {".rat", "application/rat-file"}, {".rc", "text/plain"}, {".rc2", "text/plain"}, {".rct", "text/plain"}, {".rdlc", "application/xml"}, {".reg", "text/plain"}, {".resx", "application/xml"}, {".rf", "image/vnd.rn-realflash"}, {".rgb", "image/x-rgb"}, {".rgs", "text/plain"}, {".rm", "application/vnd.rn-realmedia"}, {".rmi", "audio/mid"}, {".rmp", "application/vnd.rn-rn_music_package"}, {".roff", "application/x-troff"}, {".rpm", "audio/x-pn-realaudio-plugin"}, {".rqy", "text/x-ms-rqy"}, {".rtf", "application/rtf"}, {".rtx", "text/richtext"}, {".rvt", "application/octet-stream" }, {".ruleset", "application/xml"}, {".s", "text/plain"}, {".safariextz", "application/x-safari-safariextz"}, {".scd", "application/x-msschedule"}, {".scr", "text/plain"}, {".sct", "text/scriptlet"}, {".sd2", "audio/x-sd2"}, {".sdp", "application/sdp"}, {".sea", "application/octet-stream"}, {".searchConnector-ms", "application/windows-search-connector+xml"}, {".setpay", "application/set-payment-initiation"}, {".setreg", "application/set-registration-initiation"}, {".settings", "application/xml"}, {".sgimb", "application/x-sgimb"}, {".sgml", "text/sgml"}, {".sh", "application/x-sh"}, {".shar", "application/x-shar"}, {".shtml", "text/html"}, {".sit", "application/x-stuffit"}, {".sitemap", "application/xml"}, {".skin", "application/xml"}, {".skp", "application/x-koan" }, {".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12"}, {".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"}, {".slk", "application/vnd.ms-excel"}, {".sln", "text/plain"}, {".slupkg-ms", "application/x-ms-license"}, {".smd", "audio/x-smd"}, {".smi", "application/octet-stream"}, {".smx", "audio/x-smd"}, {".smz", "audio/x-smd"}, {".snd", "audio/basic"}, {".snippet", "application/xml"}, {".snp", "application/octet-stream"}, {".sol", "text/plain"}, {".sor", "text/plain"}, {".spc", "application/x-pkcs7-certificates"}, {".spl", "application/futuresplash"}, {".spx", "audio/ogg"}, {".src", "application/x-wais-source"}, {".srf", "text/plain"}, {".SSISDeploymentManifest", "text/xml"}, {".ssm", "application/streamingmedia"}, {".sst", "application/vnd.ms-pki.certstore"}, {".step", "application/step"}, {".stl", "application/vnd.ms-pki.stl"}, {".stp", "application/step"}, {".sv4cpio", "application/x-sv4cpio"}, {".sv4crc", "application/x-sv4crc"}, {".svc", "application/xml"}, {".svg", "image/svg+xml"}, {".swf", "application/x-shockwave-flash"}, {".t", "application/x-troff"}, {".tar", "application/x-tar"}, {".tcl", "application/x-tcl"}, {".testrunconfig", "application/xml"}, {".testsettings", "application/xml"}, {".tex", "application/x-tex"}, {".texi", "application/x-texinfo"}, {".texinfo", "application/x-texinfo"}, {".tgz", "application/x-compressed"}, {".thmx", "application/vnd.ms-officetheme"}, {".thn", "application/octet-stream"}, {".tif", "image/tiff"}, {".tiff", "image/tiff"}, {".tlh", "text/plain"}, {".tli", "text/plain"}, {".toc", "application/octet-stream"}, {".tr", "application/x-troff"}, {".trm", "application/x-msterminal"}, {".trx", "application/xml"}, {".ts", "video/vnd.dlna.mpeg-tts"}, {".tsv", "text/tab-separated-values"}, {".ttf", "application/font-sfnt"}, {".tts", "video/vnd.dlna.mpeg-tts"}, {".txt", "text/plain"}, {".u32", "application/octet-stream"}, {".uls", "text/iuls"}, {".user", "text/plain"}, {".ustar", "application/x-ustar"}, {".vb", "text/plain"}, {".vbdproj", "text/plain"}, {".vbk", "video/mpeg"}, {".vbproj", "text/plain"}, {".vbs", "text/vbscript"}, {".vcf", "text/x-vcard"}, {".vcproj", "application/xml"}, {".vcs", "text/plain"}, {".vcxproj", "application/xml"}, {".vddproj", "text/plain"}, {".vdp", "text/plain"}, {".vdproj", "text/plain"}, {".vdx", "application/vnd.ms-visio.viewer"}, {".vml", "text/xml"}, {".vscontent", "application/xml"}, {".vsct", "text/xml"}, {".vsd", "application/vnd.visio"}, {".vsi", "application/ms-vsi"}, {".vsix", "application/vsix"}, {".vsixlangpack", "text/xml"}, {".vsixmanifest", "text/xml"}, {".vsmdi", "application/xml"}, {".vspscc", "text/plain"}, {".vss", "application/vnd.visio"}, {".vsscc", "text/plain"}, {".vssettings", "text/xml"}, {".vssscc", "text/plain"}, {".vst", "application/vnd.visio"}, {".vstemplate", "text/xml"}, {".vsto", "application/x-ms-vsto"}, {".vsw", "application/vnd.visio"}, {".vsx", "application/vnd.visio"}, {".vtx", "application/vnd.visio"}, {".wav", "audio/wav"}, {".wave", "audio/wav"}, {".wax", "audio/x-ms-wax"}, {".wbk", "application/msword"}, {".wbmp", "image/vnd.wap.wbmp"}, {".wcm", "application/vnd.ms-works"}, {".wdb", "application/vnd.ms-works"}, {".wdp", "image/vnd.ms-photo"}, {".webarchive", "application/x-safari-webarchive"}, {".webm", "video/webm"}, {".webp", "image/webp"}, /* https://en.wikipedia.org/wiki/WebP */ {".webtest", "application/xml"}, {".wiq", "application/xml"}, {".wiz", "application/msword"}, {".wks", "application/vnd.ms-works"}, {".WLMP", "application/wlmoviemaker"}, {".wlpginstall", "application/x-wlpg-detect"}, {".wlpginstall3", "application/x-wlpg3-detect"}, {".wm", "video/x-ms-wm"}, {".wma", "audio/x-ms-wma"}, {".wmd", "application/x-ms-wmd"}, {".wmf", "application/x-msmetafile"}, {".wml", "text/vnd.wap.wml"}, {".wmlc", "application/vnd.wap.wmlc"}, {".wmls", "text/vnd.wap.wmlscript"}, {".wmlsc", "application/vnd.wap.wmlscriptc"}, {".wmp", "video/x-ms-wmp"}, {".wmv", "video/x-ms-wmv"}, {".wmx", "video/x-ms-wmx"}, {".wmz", "application/x-ms-wmz"}, {".woff", "application/font-woff"}, {".wpl", "application/vnd.ms-wpl"}, {".wps", "application/vnd.ms-works"}, {".wri", "application/x-mswrite"}, {".wrl", "x-world/x-vrml"}, {".wrz", "x-world/x-vrml"}, {".wsc", "text/scriptlet"}, {".wsdl", "text/xml"}, {".wvx", "video/x-ms-wvx"}, {".x", "application/directx"}, {".xaf", "x-world/x-vrml"}, {".xaml", "application/xaml+xml"}, {".xap", "application/x-silverlight-app"}, {".xbap", "application/x-ms-xbap"}, {".xbm", "image/x-xbitmap"}, {".xdr", "text/plain"}, {".xht", "application/xhtml+xml"}, {".xhtml", "application/xhtml+xml"}, {".xla", "application/vnd.ms-excel"}, {".xlam", "application/vnd.ms-excel.addin.macroEnabled.12"}, {".xlc", "application/vnd.ms-excel"}, {".xld", "application/vnd.ms-excel"}, {".xlk", "application/vnd.ms-excel"}, {".xll", "application/vnd.ms-excel"}, {".xlm", "application/vnd.ms-excel"}, {".xls", "application/vnd.ms-excel"}, {".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"}, {".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"}, {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, {".xlt", "application/vnd.ms-excel"}, {".xltm", "application/vnd.ms-excel.template.macroEnabled.12"}, {".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"}, {".xlw", "application/vnd.ms-excel"}, {".xml", "text/xml"}, {".xmp", "application/octet-stream" }, {".xmta", "application/xml"}, {".xof", "x-world/x-vrml"}, {".XOML", "text/plain"}, {".xpm", "image/x-xpixmap"}, {".xps", "application/vnd.ms-xpsdocument"}, {".xrm-ms", "text/xml"}, {".xsc", "application/xml"}, {".xsd", "text/xml"}, {".xsf", "text/xml"}, {".xsl", "text/xml"}, {".xslt", "text/xml"}, {".xsn", "application/octet-stream"}, {".xss", "application/xml"}, {".xspf", "application/xspf+xml"}, {".xtp", "application/octet-stream"}, {".xwd", "image/x-xwindowdump"}, {".z", "application/x-compress"}, {".zip", "application/zip"}, {"application/fsharp-script", ".fsx"}, {"application/msaccess", ".adp"}, {"application/msword", ".doc"}, {"application/octet-stream", ".bin"}, {"application/onenote", ".one"}, {"application/postscript", ".eps"}, {"application/step", ".step"}, {"application/vnd.ms-excel", ".xls"}, {"application/vnd.ms-powerpoint", ".ppt"}, {"application/vnd.ms-works", ".wks"}, {"application/vnd.visio", ".vsd"}, {"application/x-director", ".dir"}, {"application/x-shockwave-flash", ".swf"}, {"application/x-x509-ca-cert", ".cer"}, {"application/x-zip-compressed", ".zip"}, {"application/xhtml+xml", ".xhtml"}, {"application/xml", ".xml"}, // anomoly, .xml -> text/xml, but application/xml -> many thingss, but all are xml, so safest is .xml {"audio/aac", ".AAC"}, {"audio/aiff", ".aiff"}, {"audio/basic", ".snd"}, {"audio/mid", ".midi"}, {"audio/wav", ".wav"}, {"audio/x-m4a", ".m4a"}, {"audio/x-mpegurl", ".m3u"}, {"audio/x-pn-realaudio", ".ra"}, {"audio/x-smd", ".smd"}, {"image/bmp", ".bmp"}, {"image/jpeg", ".jpg"}, {"image/pict", ".pic"}, {"image/png", ".png"}, {"image/tiff", ".tiff"}, {"image/x-macpaint", ".mac"}, {"image/x-quicktime", ".qti"}, {"message/rfc822", ".eml"}, {"text/html", ".html"}, {"text/plain", ".txt"}, {"text/scriptlet", ".wsc"}, {"text/xml", ".xml"}, {"video/3gpp", ".3gp"}, {"video/3gpp2", ".3gp2"}, {"video/mp4", ".mp4"}, {"video/mpeg", ".mpg"}, {"video/quicktime", ".mov"}, {"video/vnd.dlna.mpeg-tts", ".m2t"}, {"video/x-dv", ".dv"}, {"video/x-la-asf", ".lsf"}, {"video/x-ms-asf", ".asf"}, {"x-world/x-vrml", ".xof"} }; StrViewA HttpFileMapper::mapMime(StrViewA fullPathname) { auto sep = fullPathname.lastIndexOf("."); if (sep == fullPathname.npos) { return "application/octet-stream"; } std::pair<StrViewA, StrViewA> srch; srch.first = fullPathname.substr(sep); auto fnd = std::lower_bound(std::begin(mimeList),std::end(mimeList),srch, std::less<decltype(srch)>()); if (fnd == std::end(mimeList) || fnd->first != srch.first) return "application/octet-stream"; return fnd->second; } bool HttpFileMapper::operator ()(const HTTPRequest& req, const StrViewA& vpath) { if (vpath.empty() || vpath[0] != '/') { req.redirectToFolderRoot(); return true; } std::vector<char> buffer; buffer.reserve(documentRoot.size()+1000); buffer.insert(buffer.end(),documentRoot.begin(),documentRoot.end()); QueryParser qp(vpath); int level = 0; auto splt = qp.getPath().split("/"); bool dir = false; while (splt) { StrViewA x = splt(); if (x.empty()) { dir = true; continue; } dir = false; if (x == ".") continue; if (x == "..") { if (!level) return false; level--; } else { level++; } buffer.push_back(pathSeparator); buffer.insert(buffer.end(),x.begin(),x.end()); } if (dir) { buffer.push_back(pathSeparator); buffer.insert(buffer.end(),index.begin(),index.end()); } return mapFile(req, StrViewA(buffer.data(), buffer.size())); } }
input: INP STA [num] JIZ [end] JSP [loop] loop: LDA [num] STA [numDiv] JSP [divisori] JMP [loop] divisori: LDA [num] LDB [numDiv] DIV STA [divRes] LDA [numDiv] LDB [divRes] MUL STA [mulRes] LDA [num] LDB [mulRes] SUB STA [rem] LDA [numDiv] STA [outputNum] LDB #1 SUB STA [numDiv] JIZ [input] LDA [rem] JIZ [output] LDA [numDiv] JMP [divisori] output: LDA [outputNum] OUT JMP [divisori] end: HLT == VARS == num: LDA #1 STA [num] numDiv: NOP numCount: NOP divRes: NOP mulRes: NOP rem: NOP outputNum:NOP
/* +------------------------------------------------------------------------+ | Phalcon Framework | +------------------------------------------------------------------------+ | Copyright (c) 2011-2014 Phalcon Team (http://www.phalconphp.com) | +------------------------------------------------------------------------+ | This source file is subject to the New BSD License that is bundled | | with this package in the file docs/LICENSE.txt. | | | | If you did not receive a copy of the license and are unable to | | obtain it through the world-wide-web, please send an email | | to license@phalconphp.com so we can send you a copy immediately. | +------------------------------------------------------------------------+ | Authors: Andres Gutierrez <andres@phalconphp.com> | | Eduar Carvajal <eduar@phalconphp.com> | +------------------------------------------------------------------------+ */ #include "db/result/pdo.h" #include "db/resultinterface.h" #include "db/exception.h" #include <ext/pdo/php_pdo_driver.h> #include "kernel/main.h" #include "kernel/memory.h" #include "kernel/exception.h" #include "kernel/object.h" #include "kernel/fcall.h" #include "kernel/operators.h" #include "kernel/string.h" #include "kernel/array.h" #include "kernel/concat.h" /** * Phalcon\Db\Result\Pdo * * Encapsulates the resultset internals * * <code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * $result->setFetchMode(Phalcon\Db::FETCH_NUM); * while ($robot = $result->fetchArray()) { * print_r($robot); * } * </code> */ zend_class_entry *phalcon_db_result_pdo_ce; PHP_METHOD(Phalcon_Db_Result_Pdo, __construct); PHP_METHOD(Phalcon_Db_Result_Pdo, execute); PHP_METHOD(Phalcon_Db_Result_Pdo, fetch); PHP_METHOD(Phalcon_Db_Result_Pdo, fetchArray); PHP_METHOD(Phalcon_Db_Result_Pdo, fetchAll); PHP_METHOD(Phalcon_Db_Result_Pdo, numRows); PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek); PHP_METHOD(Phalcon_Db_Result_Pdo, setFetchMode); PHP_METHOD(Phalcon_Db_Result_Pdo, getInternalResult); PHP_METHOD(Phalcon_Db_Result_Pdo, nextRowset); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_db_result___construct, 0, 0, 2) ZEND_ARG_INFO(0, connection) ZEND_ARG_INFO(0, result) ZEND_ARG_INFO(0, sqlStatement) ZEND_ARG_INFO(0, bindParams) ZEND_ARG_INFO(0, bindTypes) ZEND_END_ARG_INFO() static const zend_function_entry phalcon_db_result_pdo_method_entry[] = { PHP_ME(Phalcon_Db_Result_Pdo, __construct, arginfo_phalcon_db_result___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Db_Result_Pdo, execute, arginfo_phalcon_db_resultinterface_execute, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, fetch, arginfo_phalcon_db_resultinterface_fetch, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, fetchArray, arginfo_phalcon_db_resultinterface_fetcharray, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, fetchAll, arginfo_phalcon_db_resultinterface_fetchall, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, numRows, arginfo_phalcon_db_resultinterface_numrows, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, dataSeek, arginfo_phalcon_db_resultinterface_dataseek, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, setFetchMode, arginfo_phalcon_db_resultinterface_setfetchmode, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, getInternalResult, arginfo_phalcon_db_resultinterface_getinternalresult, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Db_Result_Pdo, nextRowset, NULL, ZEND_ACC_PUBLIC) PHP_FE_END }; /** * Phalcon\Db\Result\Pdo initializer */ PHALCON_INIT_CLASS(Phalcon_Db_Result_Pdo){ PHALCON_REGISTER_CLASS(Phalcon\\Db\\Result, Pdo, db_result_pdo, phalcon_db_result_pdo_method_entry, 0); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_connection"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_result"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(phalcon_db_result_pdo_ce, SL("_fetchMode"), PDO_FETCH_OBJ, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_pdoStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_sqlStatement"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_bindParams"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_db_result_pdo_ce, SL("_bindTypes"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(phalcon_db_result_pdo_ce, SL("_rowCount"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); return SUCCESS; } /** * Phalcon\Db\Result\Pdo constructor * * @param Phalcon\Db\AdapterInterface $connection * @param string $sqlStatement * @param array $bindParams * @param array $bindTypes * @param \PDOStatement $result */ PHP_METHOD(Phalcon_Db_Result_Pdo, __construct){ zval *connection, *result, *sql_statement = NULL, *bind_params = NULL; zval *bind_types = NULL; phalcon_fetch_params(0, 2, 3, &connection, &result, &sql_statement, &bind_params, &bind_types); if (!sql_statement) { sql_statement = PHALCON_GLOBAL(z_null); } if (!bind_params) { bind_params = PHALCON_GLOBAL(z_null); } if (!bind_types) { bind_types = PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(result) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STRW(phalcon_db_exception_ce, "Invalid PDOStatement supplied to Phalcon\\Db\\Result\\Pdo"); return; } phalcon_update_property_this(this_ptr, SL("_connection"), connection TSRMLS_CC); phalcon_update_property_this(this_ptr, SL("_pdoStatement"), result TSRMLS_CC); if (Z_TYPE_P(sql_statement) != IS_NULL) { phalcon_update_property_this(this_ptr, SL("_sqlStatement"), sql_statement TSRMLS_CC); } if (Z_TYPE_P(bind_params) != IS_NULL) { phalcon_update_property_this(this_ptr, SL("_bindParams"), bind_params TSRMLS_CC); } if (Z_TYPE_P(bind_types) != IS_NULL) { phalcon_update_property_this(this_ptr, SL("_bindTypes"), bind_types TSRMLS_CC); } } /** * Allows to executes the statement again. Some database systems don't support scrollable cursors, * So, as cursors are forward only, we need to execute the cursor again to fetch rows from the begining * * @return boolean */ PHP_METHOD(Phalcon_Db_Result_Pdo, execute){ zval *pdo_statement; PHALCON_MM_GROW(); pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_RETURN_CALL_METHOD(pdo_statement, "execute"); PHALCON_MM_RESTORE(); } /** * Fetches an array/object of strings that corresponds to the fetched row, or FALSE if there are no more rows. * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * *<code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * $result->setFetchMode(Phalcon\Db::FETCH_OBJ); * while ($robot = $result->fetch()) { * echo $robot->name; * } *</code> * * @return mixed */ PHP_METHOD(Phalcon_Db_Result_Pdo, fetch){ zval *pdo_statement; PHALCON_MM_GROW(); pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_RETURN_CALL_METHOD(pdo_statement, "fetch"); RETURN_MM(); } /** * Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * *<code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * $result->setFetchMode(Phalcon\Db::FETCH_NUM); * while ($robot = $result->fetchArray()) { * print_r($robot); * } *</code> * * @return mixed */ PHP_METHOD(Phalcon_Db_Result_Pdo, fetchArray){ zval *pdo_statement; PHALCON_MM_GROW(); pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_RETURN_CALL_METHOD(pdo_statement, "fetch"); RETURN_MM(); } /** * Returns an array of arrays containing all the records in the result * This method is affected by the active fetch flag set using Phalcon\Db\Result\Pdo::setFetchMode * *<code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * $robots = $result->fetchAll(); *</code> * * @return array */ PHP_METHOD(Phalcon_Db_Result_Pdo, fetchAll){ zval *pdo_statement; PHALCON_MM_GROW(); pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_RETURN_CALL_METHOD(pdo_statement, "fetchall"); RETURN_MM(); } /** * Gets number of rows returned by a resulset * *<code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * echo 'There are ', $result->numRows(), ' rows in the resulset'; *</code> * * @return int */ PHP_METHOD(Phalcon_Db_Result_Pdo, numRows){ zval *row_count = NULL, *connection, *type = NULL, *pdo_statement = NULL; zval *sql_statement, *bind_params, *bind_types; zval *matches, *pattern, *match, *else_clauses; zval *sql, *result = NULL, *row = NULL; PHALCON_MM_GROW(); PHALCON_OBS_VAR(row_count); phalcon_read_property_this(&row_count, this_ptr, SL("_rowCount"), PH_NOISY TSRMLS_CC); if (PHALCON_IS_FALSE(row_count)) { PHALCON_OBS_VAR(connection); phalcon_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&type, connection, "gettype"); /** * MySQL/PostgreSQL library property returns the number of records */ if (PHALCON_IS_STRING(type, "mysql") || PHALCON_IS_STRING(type, "pgsql")) { PHALCON_OBS_VAR(pdo_statement); phalcon_read_property_this(&pdo_statement, this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&row_count, pdo_statement, "rowcount"); } /** * We should get the count using a new statement :( */ if (PHALCON_IS_FALSE(row_count)) { /** * SQLite/Oracle/SQLServer returns resultsets that to the client eyes (PDO) has an * arbitrary number of rows, so we need to perform an extra count to know that */ PHALCON_OBS_VAR(sql_statement); phalcon_read_property_this(&sql_statement, this_ptr, SL("_sqlStatement"), PH_NOISY TSRMLS_CC); /** * If the sql_statement starts with SELECT COUNT(*) we don't make the count */ if (!phalcon_start_with_str(sql_statement, SL("SELECT COUNT(*) "))) { PHALCON_OBS_VAR(bind_params); phalcon_read_property_this(&bind_params, this_ptr, SL("_bindParams"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(bind_types); phalcon_read_property_this(&bind_types, this_ptr, SL("_bindTypes"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(matches); PHALCON_INIT_VAR(pattern); ZVAL_STRING(pattern, "/^SELECT\\s+(.*)$/i", 1); PHALCON_INIT_VAR(match); RETURN_MM_ON_FAILURE(phalcon_preg_match(match, pattern, sql_statement, matches TSRMLS_CC)); if (zend_is_true(match)) { PHALCON_OBS_VAR(else_clauses); phalcon_array_fetch_long(&else_clauses, matches, 1, PH_NOISY); PHALCON_INIT_VAR(sql); PHALCON_CONCAT_SVS(sql, "SELECT COUNT(*) \"numrows\" FROM (SELECT ", else_clauses, ")"); PHALCON_CALL_METHOD(&result, connection, "query", sql, bind_params, bind_types); PHALCON_CALL_METHOD(&row, result, "fetch"); PHALCON_OBS_NVAR(row_count); phalcon_array_fetch_string(&row_count, row, SL("numrows"), PH_NOISY); } } else { PHALCON_INIT_NVAR(row_count); ZVAL_LONG(row_count, 1); } } /** * Update the value to avoid further calculations */ phalcon_update_property_this(this_ptr, SL("_rowCount"), row_count TSRMLS_CC); } RETURN_CCTOR(row_count); } /** * Moves internal resulset cursor to another position letting us to fetch a certain row * *<code> * $result = $connection->query("SELECT * FROM robots ORDER BY name"); * $result->dataSeek(2); // Move to third row on result * $row = $result->fetch(); // Fetch third row *</code> * * @param int $number */ PHP_METHOD(Phalcon_Db_Result_Pdo, dataSeek){ long number = 0, n; zval *connection, *pdo = NULL, *sql_statement; zval *bind_params, *bind_types, *statement = NULL; zval *temp_statement = NULL; pdo_stmt_t *stmt; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &number) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(connection); phalcon_read_property(&connection, this_ptr, SL("_connection"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&pdo, connection, "getinternalhandler"); PHALCON_OBS_VAR(sql_statement); phalcon_read_property(&sql_statement, this_ptr, SL("_sqlStatement"), PH_NOISY TSRMLS_CC); PHALCON_OBS_VAR(bind_params); phalcon_read_property(&bind_params, this_ptr, SL("_bindParams"), PH_NOISY TSRMLS_CC); /** * PDO doesn't support scrollable cursors, so we need to re-execute the statement again */ if (Z_TYPE_P(bind_params) == IS_ARRAY) { PHALCON_OBS_VAR(bind_types); phalcon_read_property(&bind_types, this_ptr, SL("_bindTypes"), PH_NOISY TSRMLS_CC); PHALCON_CALL_METHOD(&statement, pdo, "prepare", sql_statement); if (Z_TYPE_P(statement) == IS_OBJECT) { PHALCON_CALL_METHOD(&temp_statement, connection, "executeprepared", statement, bind_params, bind_types); PHALCON_CPY_WRT(statement, temp_statement); } } else { PHALCON_CALL_METHOD(&statement, pdo, "query", sql_statement); } phalcon_update_property_zval(this_ptr, SL("_pdoStatement"), statement TSRMLS_CC); /** * This a fetch scroll to reach the desired position, however with a big number of records * maybe it may be very slow */ stmt = (pdo_stmt_t*) zend_object_store_get_object(statement TSRMLS_CC); if (!stmt->dbh) { PHALCON_MM_RESTORE(); RETURN_FALSE; } n = -1; number--; while (n != number) { if(!stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0 TSRMLS_CC)) { PHALCON_MM_RESTORE(); RETURN_NULL(); } n++; } PHALCON_MM_RESTORE(); } /** * Changes the fetching mode affecting Phalcon\Db\Result\Pdo::fetch() * *<code> * //Return array with integer indexes * $result->setFetchMode(Phalcon\Db::FETCH_NUM); * * //Return associative array without integer indexes * $result->setFetchMode(Phalcon\Db::FETCH_ASSOC); * * //Return associative array together with integer indexes * $result->setFetchMode(Phalcon\Db::FETCH_BOTH); * * //Return an object * $result->setFetchMode(Phalcon\Db::FETCH_OBJ); *</code> * * @param int $fetchMode */ PHP_METHOD(Phalcon_Db_Result_Pdo, setFetchMode){ zval *fetch_mode, *fetch_arg1 = NULL, *fetch_arg2 = NULL; zval *pdo_statement; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 2, &fetch_mode, &fetch_arg1, &fetch_arg2); PHALCON_SEPARATE_PARAM(fetch_mode); if (Z_TYPE_P(fetch_mode) != IS_LONG) { convert_to_long(fetch_mode); } PHALCON_OBS_VAR(pdo_statement); phalcon_read_property(&pdo_statement, this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); if (Z_RESVAL_P(fetch_mode) != 0) { if (fetch_arg1 && fetch_arg2) { PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg1, fetch_arg2); } else if (fetch_arg1) { PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg1); } else if (fetch_arg2) { PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode, fetch_arg2); } else { PHALCON_CALL_METHOD(NULL, pdo_statement, "setfetchmode", fetch_mode); } phalcon_update_property_long(this_ptr, SL("_fetchMode"), Z_RESVAL_P(fetch_mode) TSRMLS_CC); } RETURN_MM_NULL(); } /** * Gets the internal PDO result object * * @return \PDOStatement */ PHP_METHOD(Phalcon_Db_Result_Pdo, getInternalResult){ RETURN_MEMBER(this_ptr, "_pdoStatement"); } /** * Advances to the next rowset in a multi-rowset statement handle * * @return boolean */ PHP_METHOD(Phalcon_Db_Result_Pdo, nextRowset){ zval *pdo_statement; PHALCON_MM_GROW(); pdo_statement = phalcon_fetch_nproperty_this(this_ptr, SL("_pdoStatement"), PH_NOISY TSRMLS_CC); PHALCON_RETURN_CALL_METHOD(pdo_statement, "nextrowset"); RETURN_MM(); }
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/sms/model/ReplicationRunType.h> #include <aws/core/utils/HashingUtils.h> #include <aws/core/Globals.h> #include <aws/core/utils/EnumParseOverflowContainer.h> using namespace Aws::Utils; namespace Aws { namespace SMS { namespace Model { namespace ReplicationRunTypeMapper { static const int ON_DEMAND_HASH = HashingUtils::HashString("ON_DEMAND"); static const int AUTOMATIC_HASH = HashingUtils::HashString("AUTOMATIC"); ReplicationRunType GetReplicationRunTypeForName(const Aws::String& name) { int hashCode = HashingUtils::HashString(name.c_str()); if (hashCode == ON_DEMAND_HASH) { return ReplicationRunType::ON_DEMAND; } else if (hashCode == AUTOMATIC_HASH) { return ReplicationRunType::AUTOMATIC; } EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { overflowContainer->StoreOverflow(hashCode, name); return static_cast<ReplicationRunType>(hashCode); } return ReplicationRunType::NOT_SET; } Aws::String GetNameForReplicationRunType(ReplicationRunType enumValue) { switch(enumValue) { case ReplicationRunType::ON_DEMAND: return "ON_DEMAND"; case ReplicationRunType::AUTOMATIC: return "AUTOMATIC"; default: EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); } return {}; } } } // namespace ReplicationRunTypeMapper } // namespace Model } // namespace SMS } // namespace Aws
; Boot sector that prints Hello to the screen using a BIOS routine mov ah, 0x0e ; Scrolling teletype BIOS routine => prints character and moves cursor over, ready to print another character ; Prints "Hello" to the screen character by character mov al, 'H' int 0x10 mov al, 'e' int 0x10 mov al, 'l' int 0x10 mov al, 'l' int 0x10 mov al, 'o' int 0x10 ; Padding for the boot sector times 510-($-$$) db 0 dw 0xaa55
INCLUDE "config_private.inc" SECTION code_driver SECTION code_driver_terminal_output PUBLIC rc_01_output_hbios1_iterm_msg_putc EXTERN rc_01_output_hbios1_oterm_msg_putc_raw rc_01_output_hbios1_iterm_msg_putc: ; enter : c = char to output ; can use: af, bc, de, hl, ix ; char to print is coming from the input terminal ; so it should not be subject to tty emulation ; input terminal must not echo control codes ld a,c cp 32 jp nc, rc_01_output_hbios1_oterm_msg_putc_raw cp CHAR_LF jp z, rc_01_output_hbios1_oterm_msg_putc_raw ld c,'?' jp rc_01_output_hbios1_oterm_msg_putc_raw
_grep: file format elf32-i386 Disassembly of section .text: 00001000 <grep>: char buf[1024]; int match(char*, char*); void grep(char *pattern, int fd) { 1000: 55 push %ebp 1001: 89 e5 mov %esp,%ebp 1003: 83 ec 28 sub $0x28,%esp int n, m; char *p, *q; m = 0; 1006: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){ 100d: e9 bb 00 00 00 jmp 10cd <grep+0xcd> m += n; 1012: 8b 45 ec mov -0x14(%ebp),%eax 1015: 01 45 f4 add %eax,-0xc(%ebp) p = buf; 1018: c7 45 f0 40 20 00 00 movl $0x2040,-0x10(%ebp) while((q = strchr(p, '\n')) != 0){ 101f: eb 51 jmp 1072 <grep+0x72> *q = 0; 1021: 8b 45 e8 mov -0x18(%ebp),%eax 1024: c6 00 00 movb $0x0,(%eax) if(match(pattern, p)){ 1027: 8b 45 f0 mov -0x10(%ebp),%eax 102a: 89 44 24 04 mov %eax,0x4(%esp) 102e: 8b 45 08 mov 0x8(%ebp),%eax 1031: 89 04 24 mov %eax,(%esp) 1034: e8 bc 01 00 00 call 11f5 <match> 1039: 85 c0 test %eax,%eax 103b: 74 2c je 1069 <grep+0x69> *q = '\n'; 103d: 8b 45 e8 mov -0x18(%ebp),%eax 1040: c6 00 0a movb $0xa,(%eax) write(1, p, q+1 - p); 1043: 8b 45 e8 mov -0x18(%ebp),%eax 1046: 83 c0 01 add $0x1,%eax 1049: 89 c2 mov %eax,%edx 104b: 8b 45 f0 mov -0x10(%ebp),%eax 104e: 29 c2 sub %eax,%edx 1050: 89 d0 mov %edx,%eax 1052: 89 44 24 08 mov %eax,0x8(%esp) 1056: 8b 45 f0 mov -0x10(%ebp),%eax 1059: 89 44 24 04 mov %eax,0x4(%esp) 105d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1064: e8 84 05 00 00 call 15ed <write> } p = q+1; 1069: 8b 45 e8 mov -0x18(%ebp),%eax 106c: 83 c0 01 add $0x1,%eax 106f: 89 45 f0 mov %eax,-0x10(%ebp) m = 0; while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){ m += n; p = buf; while((q = strchr(p, '\n')) != 0){ 1072: c7 44 24 04 0a 00 00 movl $0xa,0x4(%esp) 1079: 00 107a: 8b 45 f0 mov -0x10(%ebp),%eax 107d: 89 04 24 mov %eax,(%esp) 1080: e8 af 03 00 00 call 1434 <strchr> 1085: 89 45 e8 mov %eax,-0x18(%ebp) 1088: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 108c: 75 93 jne 1021 <grep+0x21> *q = '\n'; write(1, p, q+1 - p); } p = q+1; } if(p == buf) 108e: 81 7d f0 40 20 00 00 cmpl $0x2040,-0x10(%ebp) 1095: 75 07 jne 109e <grep+0x9e> m = 0; 1097: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) if(m > 0){ 109e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 10a2: 7e 29 jle 10cd <grep+0xcd> m -= p - buf; 10a4: ba 40 20 00 00 mov $0x2040,%edx 10a9: 8b 45 f0 mov -0x10(%ebp),%eax 10ac: 29 c2 sub %eax,%edx 10ae: 89 d0 mov %edx,%eax 10b0: 01 45 f4 add %eax,-0xc(%ebp) memmove(buf, p, m); 10b3: 8b 45 f4 mov -0xc(%ebp),%eax 10b6: 89 44 24 08 mov %eax,0x8(%esp) 10ba: 8b 45 f0 mov -0x10(%ebp),%eax 10bd: 89 44 24 04 mov %eax,0x4(%esp) 10c1: c7 04 24 40 20 00 00 movl $0x2040,(%esp) 10c8: e8 ab 04 00 00 call 1578 <memmove> { int n, m; char *p, *q; m = 0; while((n = read(fd, buf+m, sizeof(buf)-m)) > 0){ 10cd: 8b 45 f4 mov -0xc(%ebp),%eax 10d0: ba 00 04 00 00 mov $0x400,%edx 10d5: 29 c2 sub %eax,%edx 10d7: 89 d0 mov %edx,%eax 10d9: 8b 55 f4 mov -0xc(%ebp),%edx 10dc: 81 c2 40 20 00 00 add $0x2040,%edx 10e2: 89 44 24 08 mov %eax,0x8(%esp) 10e6: 89 54 24 04 mov %edx,0x4(%esp) 10ea: 8b 45 0c mov 0xc(%ebp),%eax 10ed: 89 04 24 mov %eax,(%esp) 10f0: e8 f0 04 00 00 call 15e5 <read> 10f5: 89 45 ec mov %eax,-0x14(%ebp) 10f8: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 10fc: 0f 8f 10 ff ff ff jg 1012 <grep+0x12> if(m > 0){ m -= p - buf; memmove(buf, p, m); } } } 1102: c9 leave 1103: c3 ret 00001104 <main>: int main(int argc, char *argv[]) { 1104: 55 push %ebp 1105: 89 e5 mov %esp,%ebp 1107: 83 e4 f0 and $0xfffffff0,%esp 110a: 83 ec 20 sub $0x20,%esp int fd, i; char *pattern; if(argc <= 1){ 110d: 83 7d 08 01 cmpl $0x1,0x8(%ebp) 1111: 7f 19 jg 112c <main+0x28> printf(2, "usage: grep pattern [file ...]\n"); 1113: c7 44 24 04 1c 1b 00 movl $0x1b1c,0x4(%esp) 111a: 00 111b: c7 04 24 02 00 00 00 movl $0x2,(%esp) 1122: e8 26 06 00 00 call 174d <printf> exit(); 1127: e8 a1 04 00 00 call 15cd <exit> } pattern = argv[1]; 112c: 8b 45 0c mov 0xc(%ebp),%eax 112f: 8b 40 04 mov 0x4(%eax),%eax 1132: 89 44 24 18 mov %eax,0x18(%esp) if(argc <= 2){ 1136: 83 7d 08 02 cmpl $0x2,0x8(%ebp) 113a: 7f 19 jg 1155 <main+0x51> grep(pattern, 0); 113c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1143: 00 1144: 8b 44 24 18 mov 0x18(%esp),%eax 1148: 89 04 24 mov %eax,(%esp) 114b: e8 b0 fe ff ff call 1000 <grep> exit(); 1150: e8 78 04 00 00 call 15cd <exit> } for(i = 2; i < argc; i++){ 1155: c7 44 24 1c 02 00 00 movl $0x2,0x1c(%esp) 115c: 00 115d: e9 81 00 00 00 jmp 11e3 <main+0xdf> if((fd = open(argv[i], 0)) < 0){ 1162: 8b 44 24 1c mov 0x1c(%esp),%eax 1166: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 116d: 8b 45 0c mov 0xc(%ebp),%eax 1170: 01 d0 add %edx,%eax 1172: 8b 00 mov (%eax),%eax 1174: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 117b: 00 117c: 89 04 24 mov %eax,(%esp) 117f: e8 89 04 00 00 call 160d <open> 1184: 89 44 24 14 mov %eax,0x14(%esp) 1188: 83 7c 24 14 00 cmpl $0x0,0x14(%esp) 118d: 79 2f jns 11be <main+0xba> printf(1, "grep: cannot open %s\n", argv[i]); 118f: 8b 44 24 1c mov 0x1c(%esp),%eax 1193: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 119a: 8b 45 0c mov 0xc(%ebp),%eax 119d: 01 d0 add %edx,%eax 119f: 8b 00 mov (%eax),%eax 11a1: 89 44 24 08 mov %eax,0x8(%esp) 11a5: c7 44 24 04 3c 1b 00 movl $0x1b3c,0x4(%esp) 11ac: 00 11ad: c7 04 24 01 00 00 00 movl $0x1,(%esp) 11b4: e8 94 05 00 00 call 174d <printf> exit(); 11b9: e8 0f 04 00 00 call 15cd <exit> } grep(pattern, fd); 11be: 8b 44 24 14 mov 0x14(%esp),%eax 11c2: 89 44 24 04 mov %eax,0x4(%esp) 11c6: 8b 44 24 18 mov 0x18(%esp),%eax 11ca: 89 04 24 mov %eax,(%esp) 11cd: e8 2e fe ff ff call 1000 <grep> close(fd); 11d2: 8b 44 24 14 mov 0x14(%esp),%eax 11d6: 89 04 24 mov %eax,(%esp) 11d9: e8 17 04 00 00 call 15f5 <close> if(argc <= 2){ grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 11de: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 11e3: 8b 44 24 1c mov 0x1c(%esp),%eax 11e7: 3b 45 08 cmp 0x8(%ebp),%eax 11ea: 0f 8c 72 ff ff ff jl 1162 <main+0x5e> exit(); } grep(pattern, fd); close(fd); } exit(); 11f0: e8 d8 03 00 00 call 15cd <exit> 000011f5 <match>: int matchhere(char*, char*); int matchstar(int, char*, char*); int match(char *re, char *text) { 11f5: 55 push %ebp 11f6: 89 e5 mov %esp,%ebp 11f8: 83 ec 18 sub $0x18,%esp if(re[0] == '^') 11fb: 8b 45 08 mov 0x8(%ebp),%eax 11fe: 0f b6 00 movzbl (%eax),%eax 1201: 3c 5e cmp $0x5e,%al 1203: 75 17 jne 121c <match+0x27> return matchhere(re+1, text); 1205: 8b 45 08 mov 0x8(%ebp),%eax 1208: 8d 50 01 lea 0x1(%eax),%edx 120b: 8b 45 0c mov 0xc(%ebp),%eax 120e: 89 44 24 04 mov %eax,0x4(%esp) 1212: 89 14 24 mov %edx,(%esp) 1215: e8 36 00 00 00 call 1250 <matchhere> 121a: eb 32 jmp 124e <match+0x59> do{ // must look at empty string if(matchhere(re, text)) 121c: 8b 45 0c mov 0xc(%ebp),%eax 121f: 89 44 24 04 mov %eax,0x4(%esp) 1223: 8b 45 08 mov 0x8(%ebp),%eax 1226: 89 04 24 mov %eax,(%esp) 1229: e8 22 00 00 00 call 1250 <matchhere> 122e: 85 c0 test %eax,%eax 1230: 74 07 je 1239 <match+0x44> return 1; 1232: b8 01 00 00 00 mov $0x1,%eax 1237: eb 15 jmp 124e <match+0x59> }while(*text++ != '\0'); 1239: 8b 45 0c mov 0xc(%ebp),%eax 123c: 8d 50 01 lea 0x1(%eax),%edx 123f: 89 55 0c mov %edx,0xc(%ebp) 1242: 0f b6 00 movzbl (%eax),%eax 1245: 84 c0 test %al,%al 1247: 75 d3 jne 121c <match+0x27> return 0; 1249: b8 00 00 00 00 mov $0x0,%eax } 124e: c9 leave 124f: c3 ret 00001250 <matchhere>: // matchhere: search for re at beginning of text int matchhere(char *re, char *text) { 1250: 55 push %ebp 1251: 89 e5 mov %esp,%ebp 1253: 83 ec 18 sub $0x18,%esp if(re[0] == '\0') 1256: 8b 45 08 mov 0x8(%ebp),%eax 1259: 0f b6 00 movzbl (%eax),%eax 125c: 84 c0 test %al,%al 125e: 75 0a jne 126a <matchhere+0x1a> return 1; 1260: b8 01 00 00 00 mov $0x1,%eax 1265: e9 9b 00 00 00 jmp 1305 <matchhere+0xb5> if(re[1] == '*') 126a: 8b 45 08 mov 0x8(%ebp),%eax 126d: 83 c0 01 add $0x1,%eax 1270: 0f b6 00 movzbl (%eax),%eax 1273: 3c 2a cmp $0x2a,%al 1275: 75 24 jne 129b <matchhere+0x4b> return matchstar(re[0], re+2, text); 1277: 8b 45 08 mov 0x8(%ebp),%eax 127a: 8d 48 02 lea 0x2(%eax),%ecx 127d: 8b 45 08 mov 0x8(%ebp),%eax 1280: 0f b6 00 movzbl (%eax),%eax 1283: 0f be c0 movsbl %al,%eax 1286: 8b 55 0c mov 0xc(%ebp),%edx 1289: 89 54 24 08 mov %edx,0x8(%esp) 128d: 89 4c 24 04 mov %ecx,0x4(%esp) 1291: 89 04 24 mov %eax,(%esp) 1294: e8 6e 00 00 00 call 1307 <matchstar> 1299: eb 6a jmp 1305 <matchhere+0xb5> if(re[0] == '$' && re[1] == '\0') 129b: 8b 45 08 mov 0x8(%ebp),%eax 129e: 0f b6 00 movzbl (%eax),%eax 12a1: 3c 24 cmp $0x24,%al 12a3: 75 1d jne 12c2 <matchhere+0x72> 12a5: 8b 45 08 mov 0x8(%ebp),%eax 12a8: 83 c0 01 add $0x1,%eax 12ab: 0f b6 00 movzbl (%eax),%eax 12ae: 84 c0 test %al,%al 12b0: 75 10 jne 12c2 <matchhere+0x72> return *text == '\0'; 12b2: 8b 45 0c mov 0xc(%ebp),%eax 12b5: 0f b6 00 movzbl (%eax),%eax 12b8: 84 c0 test %al,%al 12ba: 0f 94 c0 sete %al 12bd: 0f b6 c0 movzbl %al,%eax 12c0: eb 43 jmp 1305 <matchhere+0xb5> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 12c2: 8b 45 0c mov 0xc(%ebp),%eax 12c5: 0f b6 00 movzbl (%eax),%eax 12c8: 84 c0 test %al,%al 12ca: 74 34 je 1300 <matchhere+0xb0> 12cc: 8b 45 08 mov 0x8(%ebp),%eax 12cf: 0f b6 00 movzbl (%eax),%eax 12d2: 3c 2e cmp $0x2e,%al 12d4: 74 10 je 12e6 <matchhere+0x96> 12d6: 8b 45 08 mov 0x8(%ebp),%eax 12d9: 0f b6 10 movzbl (%eax),%edx 12dc: 8b 45 0c mov 0xc(%ebp),%eax 12df: 0f b6 00 movzbl (%eax),%eax 12e2: 38 c2 cmp %al,%dl 12e4: 75 1a jne 1300 <matchhere+0xb0> return matchhere(re+1, text+1); 12e6: 8b 45 0c mov 0xc(%ebp),%eax 12e9: 8d 50 01 lea 0x1(%eax),%edx 12ec: 8b 45 08 mov 0x8(%ebp),%eax 12ef: 83 c0 01 add $0x1,%eax 12f2: 89 54 24 04 mov %edx,0x4(%esp) 12f6: 89 04 24 mov %eax,(%esp) 12f9: e8 52 ff ff ff call 1250 <matchhere> 12fe: eb 05 jmp 1305 <matchhere+0xb5> return 0; 1300: b8 00 00 00 00 mov $0x0,%eax } 1305: c9 leave 1306: c3 ret 00001307 <matchstar>: // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { 1307: 55 push %ebp 1308: 89 e5 mov %esp,%ebp 130a: 83 ec 18 sub $0x18,%esp do{ // a * matches zero or more instances if(matchhere(re, text)) 130d: 8b 45 10 mov 0x10(%ebp),%eax 1310: 89 44 24 04 mov %eax,0x4(%esp) 1314: 8b 45 0c mov 0xc(%ebp),%eax 1317: 89 04 24 mov %eax,(%esp) 131a: e8 31 ff ff ff call 1250 <matchhere> 131f: 85 c0 test %eax,%eax 1321: 74 07 je 132a <matchstar+0x23> return 1; 1323: b8 01 00 00 00 mov $0x1,%eax 1328: eb 29 jmp 1353 <matchstar+0x4c> }while(*text!='\0' && (*text++==c || c=='.')); 132a: 8b 45 10 mov 0x10(%ebp),%eax 132d: 0f b6 00 movzbl (%eax),%eax 1330: 84 c0 test %al,%al 1332: 74 1a je 134e <matchstar+0x47> 1334: 8b 45 10 mov 0x10(%ebp),%eax 1337: 8d 50 01 lea 0x1(%eax),%edx 133a: 89 55 10 mov %edx,0x10(%ebp) 133d: 0f b6 00 movzbl (%eax),%eax 1340: 0f be c0 movsbl %al,%eax 1343: 3b 45 08 cmp 0x8(%ebp),%eax 1346: 74 c5 je 130d <matchstar+0x6> 1348: 83 7d 08 2e cmpl $0x2e,0x8(%ebp) 134c: 74 bf je 130d <matchstar+0x6> return 0; 134e: b8 00 00 00 00 mov $0x0,%eax } 1353: c9 leave 1354: c3 ret 00001355 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1355: 55 push %ebp 1356: 89 e5 mov %esp,%ebp 1358: 57 push %edi 1359: 53 push %ebx asm volatile("cld; rep stosb" : 135a: 8b 4d 08 mov 0x8(%ebp),%ecx 135d: 8b 55 10 mov 0x10(%ebp),%edx 1360: 8b 45 0c mov 0xc(%ebp),%eax 1363: 89 cb mov %ecx,%ebx 1365: 89 df mov %ebx,%edi 1367: 89 d1 mov %edx,%ecx 1369: fc cld 136a: f3 aa rep stos %al,%es:(%edi) 136c: 89 ca mov %ecx,%edx 136e: 89 fb mov %edi,%ebx 1370: 89 5d 08 mov %ebx,0x8(%ebp) 1373: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 1376: 5b pop %ebx 1377: 5f pop %edi 1378: 5d pop %ebp 1379: c3 ret 0000137a <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 137a: 55 push %ebp 137b: 89 e5 mov %esp,%ebp 137d: 83 ec 10 sub $0x10,%esp char *os; os = s; 1380: 8b 45 08 mov 0x8(%ebp),%eax 1383: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 1386: 90 nop 1387: 8b 45 08 mov 0x8(%ebp),%eax 138a: 8d 50 01 lea 0x1(%eax),%edx 138d: 89 55 08 mov %edx,0x8(%ebp) 1390: 8b 55 0c mov 0xc(%ebp),%edx 1393: 8d 4a 01 lea 0x1(%edx),%ecx 1396: 89 4d 0c mov %ecx,0xc(%ebp) 1399: 0f b6 12 movzbl (%edx),%edx 139c: 88 10 mov %dl,(%eax) 139e: 0f b6 00 movzbl (%eax),%eax 13a1: 84 c0 test %al,%al 13a3: 75 e2 jne 1387 <strcpy+0xd> ; return os; 13a5: 8b 45 fc mov -0x4(%ebp),%eax } 13a8: c9 leave 13a9: c3 ret 000013aa <strcmp>: int strcmp(const char *p, const char *q) { 13aa: 55 push %ebp 13ab: 89 e5 mov %esp,%ebp while(*p && *p == *q) 13ad: eb 08 jmp 13b7 <strcmp+0xd> p++, q++; 13af: 83 45 08 01 addl $0x1,0x8(%ebp) 13b3: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 13b7: 8b 45 08 mov 0x8(%ebp),%eax 13ba: 0f b6 00 movzbl (%eax),%eax 13bd: 84 c0 test %al,%al 13bf: 74 10 je 13d1 <strcmp+0x27> 13c1: 8b 45 08 mov 0x8(%ebp),%eax 13c4: 0f b6 10 movzbl (%eax),%edx 13c7: 8b 45 0c mov 0xc(%ebp),%eax 13ca: 0f b6 00 movzbl (%eax),%eax 13cd: 38 c2 cmp %al,%dl 13cf: 74 de je 13af <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 13d1: 8b 45 08 mov 0x8(%ebp),%eax 13d4: 0f b6 00 movzbl (%eax),%eax 13d7: 0f b6 d0 movzbl %al,%edx 13da: 8b 45 0c mov 0xc(%ebp),%eax 13dd: 0f b6 00 movzbl (%eax),%eax 13e0: 0f b6 c0 movzbl %al,%eax 13e3: 29 c2 sub %eax,%edx 13e5: 89 d0 mov %edx,%eax } 13e7: 5d pop %ebp 13e8: c3 ret 000013e9 <strlen>: uint strlen(char *s) { 13e9: 55 push %ebp 13ea: 89 e5 mov %esp,%ebp 13ec: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 13ef: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 13f6: eb 04 jmp 13fc <strlen+0x13> 13f8: 83 45 fc 01 addl $0x1,-0x4(%ebp) 13fc: 8b 55 fc mov -0x4(%ebp),%edx 13ff: 8b 45 08 mov 0x8(%ebp),%eax 1402: 01 d0 add %edx,%eax 1404: 0f b6 00 movzbl (%eax),%eax 1407: 84 c0 test %al,%al 1409: 75 ed jne 13f8 <strlen+0xf> ; return n; 140b: 8b 45 fc mov -0x4(%ebp),%eax } 140e: c9 leave 140f: c3 ret 00001410 <memset>: void* memset(void *dst, int c, uint n) { 1410: 55 push %ebp 1411: 89 e5 mov %esp,%ebp 1413: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 1416: 8b 45 10 mov 0x10(%ebp),%eax 1419: 89 44 24 08 mov %eax,0x8(%esp) 141d: 8b 45 0c mov 0xc(%ebp),%eax 1420: 89 44 24 04 mov %eax,0x4(%esp) 1424: 8b 45 08 mov 0x8(%ebp),%eax 1427: 89 04 24 mov %eax,(%esp) 142a: e8 26 ff ff ff call 1355 <stosb> return dst; 142f: 8b 45 08 mov 0x8(%ebp),%eax } 1432: c9 leave 1433: c3 ret 00001434 <strchr>: char* strchr(const char *s, char c) { 1434: 55 push %ebp 1435: 89 e5 mov %esp,%ebp 1437: 83 ec 04 sub $0x4,%esp 143a: 8b 45 0c mov 0xc(%ebp),%eax 143d: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 1440: eb 14 jmp 1456 <strchr+0x22> if(*s == c) 1442: 8b 45 08 mov 0x8(%ebp),%eax 1445: 0f b6 00 movzbl (%eax),%eax 1448: 3a 45 fc cmp -0x4(%ebp),%al 144b: 75 05 jne 1452 <strchr+0x1e> return (char*)s; 144d: 8b 45 08 mov 0x8(%ebp),%eax 1450: eb 13 jmp 1465 <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 1452: 83 45 08 01 addl $0x1,0x8(%ebp) 1456: 8b 45 08 mov 0x8(%ebp),%eax 1459: 0f b6 00 movzbl (%eax),%eax 145c: 84 c0 test %al,%al 145e: 75 e2 jne 1442 <strchr+0xe> if(*s == c) return (char*)s; return 0; 1460: b8 00 00 00 00 mov $0x0,%eax } 1465: c9 leave 1466: c3 ret 00001467 <gets>: char* gets(char *buf, int max) { 1467: 55 push %ebp 1468: 89 e5 mov %esp,%ebp 146a: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 146d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1474: eb 4c jmp 14c2 <gets+0x5b> cc = read(0, &c, 1); 1476: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 147d: 00 147e: 8d 45 ef lea -0x11(%ebp),%eax 1481: 89 44 24 04 mov %eax,0x4(%esp) 1485: c7 04 24 00 00 00 00 movl $0x0,(%esp) 148c: e8 54 01 00 00 call 15e5 <read> 1491: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 1494: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1498: 7f 02 jg 149c <gets+0x35> break; 149a: eb 31 jmp 14cd <gets+0x66> buf[i++] = c; 149c: 8b 45 f4 mov -0xc(%ebp),%eax 149f: 8d 50 01 lea 0x1(%eax),%edx 14a2: 89 55 f4 mov %edx,-0xc(%ebp) 14a5: 89 c2 mov %eax,%edx 14a7: 8b 45 08 mov 0x8(%ebp),%eax 14aa: 01 c2 add %eax,%edx 14ac: 0f b6 45 ef movzbl -0x11(%ebp),%eax 14b0: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 14b2: 0f b6 45 ef movzbl -0x11(%ebp),%eax 14b6: 3c 0a cmp $0xa,%al 14b8: 74 13 je 14cd <gets+0x66> 14ba: 0f b6 45 ef movzbl -0x11(%ebp),%eax 14be: 3c 0d cmp $0xd,%al 14c0: 74 0b je 14cd <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 14c2: 8b 45 f4 mov -0xc(%ebp),%eax 14c5: 83 c0 01 add $0x1,%eax 14c8: 3b 45 0c cmp 0xc(%ebp),%eax 14cb: 7c a9 jl 1476 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 14cd: 8b 55 f4 mov -0xc(%ebp),%edx 14d0: 8b 45 08 mov 0x8(%ebp),%eax 14d3: 01 d0 add %edx,%eax 14d5: c6 00 00 movb $0x0,(%eax) return buf; 14d8: 8b 45 08 mov 0x8(%ebp),%eax } 14db: c9 leave 14dc: c3 ret 000014dd <stat>: int stat(char *n, struct stat *st) { 14dd: 55 push %ebp 14de: 89 e5 mov %esp,%ebp 14e0: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 14e3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 14ea: 00 14eb: 8b 45 08 mov 0x8(%ebp),%eax 14ee: 89 04 24 mov %eax,(%esp) 14f1: e8 17 01 00 00 call 160d <open> 14f6: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 14f9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 14fd: 79 07 jns 1506 <stat+0x29> return -1; 14ff: b8 ff ff ff ff mov $0xffffffff,%eax 1504: eb 23 jmp 1529 <stat+0x4c> r = fstat(fd, st); 1506: 8b 45 0c mov 0xc(%ebp),%eax 1509: 89 44 24 04 mov %eax,0x4(%esp) 150d: 8b 45 f4 mov -0xc(%ebp),%eax 1510: 89 04 24 mov %eax,(%esp) 1513: e8 0d 01 00 00 call 1625 <fstat> 1518: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 151b: 8b 45 f4 mov -0xc(%ebp),%eax 151e: 89 04 24 mov %eax,(%esp) 1521: e8 cf 00 00 00 call 15f5 <close> return r; 1526: 8b 45 f0 mov -0x10(%ebp),%eax } 1529: c9 leave 152a: c3 ret 0000152b <atoi>: int atoi(const char *s) { 152b: 55 push %ebp 152c: 89 e5 mov %esp,%ebp 152e: 83 ec 10 sub $0x10,%esp int n; n = 0; 1531: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 1538: eb 25 jmp 155f <atoi+0x34> n = n*10 + *s++ - '0'; 153a: 8b 55 fc mov -0x4(%ebp),%edx 153d: 89 d0 mov %edx,%eax 153f: c1 e0 02 shl $0x2,%eax 1542: 01 d0 add %edx,%eax 1544: 01 c0 add %eax,%eax 1546: 89 c1 mov %eax,%ecx 1548: 8b 45 08 mov 0x8(%ebp),%eax 154b: 8d 50 01 lea 0x1(%eax),%edx 154e: 89 55 08 mov %edx,0x8(%ebp) 1551: 0f b6 00 movzbl (%eax),%eax 1554: 0f be c0 movsbl %al,%eax 1557: 01 c8 add %ecx,%eax 1559: 83 e8 30 sub $0x30,%eax 155c: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 155f: 8b 45 08 mov 0x8(%ebp),%eax 1562: 0f b6 00 movzbl (%eax),%eax 1565: 3c 2f cmp $0x2f,%al 1567: 7e 0a jle 1573 <atoi+0x48> 1569: 8b 45 08 mov 0x8(%ebp),%eax 156c: 0f b6 00 movzbl (%eax),%eax 156f: 3c 39 cmp $0x39,%al 1571: 7e c7 jle 153a <atoi+0xf> n = n*10 + *s++ - '0'; return n; 1573: 8b 45 fc mov -0x4(%ebp),%eax } 1576: c9 leave 1577: c3 ret 00001578 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 1578: 55 push %ebp 1579: 89 e5 mov %esp,%ebp 157b: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 157e: 8b 45 08 mov 0x8(%ebp),%eax 1581: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 1584: 8b 45 0c mov 0xc(%ebp),%eax 1587: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 158a: eb 17 jmp 15a3 <memmove+0x2b> *dst++ = *src++; 158c: 8b 45 fc mov -0x4(%ebp),%eax 158f: 8d 50 01 lea 0x1(%eax),%edx 1592: 89 55 fc mov %edx,-0x4(%ebp) 1595: 8b 55 f8 mov -0x8(%ebp),%edx 1598: 8d 4a 01 lea 0x1(%edx),%ecx 159b: 89 4d f8 mov %ecx,-0x8(%ebp) 159e: 0f b6 12 movzbl (%edx),%edx 15a1: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 15a3: 8b 45 10 mov 0x10(%ebp),%eax 15a6: 8d 50 ff lea -0x1(%eax),%edx 15a9: 89 55 10 mov %edx,0x10(%ebp) 15ac: 85 c0 test %eax,%eax 15ae: 7f dc jg 158c <memmove+0x14> *dst++ = *src++; return vdst; 15b0: 8b 45 08 mov 0x8(%ebp),%eax } 15b3: c9 leave 15b4: c3 ret 000015b5 <fork>: 15b5: b8 01 00 00 00 mov $0x1,%eax 15ba: cd 40 int $0x40 15bc: c3 ret 000015bd <cowfork>: 15bd: b8 0f 00 00 00 mov $0xf,%eax 15c2: cd 40 int $0x40 15c4: c3 ret 000015c5 <procdump>: 15c5: b8 10 00 00 00 mov $0x10,%eax 15ca: cd 40 int $0x40 15cc: c3 ret 000015cd <exit>: 15cd: b8 02 00 00 00 mov $0x2,%eax 15d2: cd 40 int $0x40 15d4: c3 ret 000015d5 <wait>: 15d5: b8 03 00 00 00 mov $0x3,%eax 15da: cd 40 int $0x40 15dc: c3 ret 000015dd <pipe>: 15dd: b8 04 00 00 00 mov $0x4,%eax 15e2: cd 40 int $0x40 15e4: c3 ret 000015e5 <read>: 15e5: b8 05 00 00 00 mov $0x5,%eax 15ea: cd 40 int $0x40 15ec: c3 ret 000015ed <write>: 15ed: b8 12 00 00 00 mov $0x12,%eax 15f2: cd 40 int $0x40 15f4: c3 ret 000015f5 <close>: 15f5: b8 17 00 00 00 mov $0x17,%eax 15fa: cd 40 int $0x40 15fc: c3 ret 000015fd <kill>: 15fd: b8 06 00 00 00 mov $0x6,%eax 1602: cd 40 int $0x40 1604: c3 ret 00001605 <exec>: 1605: b8 07 00 00 00 mov $0x7,%eax 160a: cd 40 int $0x40 160c: c3 ret 0000160d <open>: 160d: b8 11 00 00 00 mov $0x11,%eax 1612: cd 40 int $0x40 1614: c3 ret 00001615 <mknod>: 1615: b8 13 00 00 00 mov $0x13,%eax 161a: cd 40 int $0x40 161c: c3 ret 0000161d <unlink>: 161d: b8 14 00 00 00 mov $0x14,%eax 1622: cd 40 int $0x40 1624: c3 ret 00001625 <fstat>: 1625: b8 08 00 00 00 mov $0x8,%eax 162a: cd 40 int $0x40 162c: c3 ret 0000162d <link>: 162d: b8 15 00 00 00 mov $0x15,%eax 1632: cd 40 int $0x40 1634: c3 ret 00001635 <mkdir>: 1635: b8 16 00 00 00 mov $0x16,%eax 163a: cd 40 int $0x40 163c: c3 ret 0000163d <chdir>: 163d: b8 09 00 00 00 mov $0x9,%eax 1642: cd 40 int $0x40 1644: c3 ret 00001645 <dup>: 1645: b8 0a 00 00 00 mov $0xa,%eax 164a: cd 40 int $0x40 164c: c3 ret 0000164d <getpid>: 164d: b8 0b 00 00 00 mov $0xb,%eax 1652: cd 40 int $0x40 1654: c3 ret 00001655 <sbrk>: 1655: b8 0c 00 00 00 mov $0xc,%eax 165a: cd 40 int $0x40 165c: c3 ret 0000165d <sleep>: 165d: b8 0d 00 00 00 mov $0xd,%eax 1662: cd 40 int $0x40 1664: c3 ret 00001665 <uptime>: 1665: b8 0e 00 00 00 mov $0xe,%eax 166a: cd 40 int $0x40 166c: c3 ret 0000166d <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 166d: 55 push %ebp 166e: 89 e5 mov %esp,%ebp 1670: 83 ec 18 sub $0x18,%esp 1673: 8b 45 0c mov 0xc(%ebp),%eax 1676: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 1679: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 1680: 00 1681: 8d 45 f4 lea -0xc(%ebp),%eax 1684: 89 44 24 04 mov %eax,0x4(%esp) 1688: 8b 45 08 mov 0x8(%ebp),%eax 168b: 89 04 24 mov %eax,(%esp) 168e: e8 5a ff ff ff call 15ed <write> } 1693: c9 leave 1694: c3 ret 00001695 <printint>: static void printint(int fd, int xx, int base, int sgn) { 1695: 55 push %ebp 1696: 89 e5 mov %esp,%ebp 1698: 56 push %esi 1699: 53 push %ebx 169a: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 169d: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 16a4: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 16a8: 74 17 je 16c1 <printint+0x2c> 16aa: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 16ae: 79 11 jns 16c1 <printint+0x2c> neg = 1; 16b0: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 16b7: 8b 45 0c mov 0xc(%ebp),%eax 16ba: f7 d8 neg %eax 16bc: 89 45 ec mov %eax,-0x14(%ebp) 16bf: eb 06 jmp 16c7 <printint+0x32> } else { x = xx; 16c1: 8b 45 0c mov 0xc(%ebp),%eax 16c4: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 16c7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 16ce: 8b 4d f4 mov -0xc(%ebp),%ecx 16d1: 8d 41 01 lea 0x1(%ecx),%eax 16d4: 89 45 f4 mov %eax,-0xc(%ebp) 16d7: 8b 5d 10 mov 0x10(%ebp),%ebx 16da: 8b 45 ec mov -0x14(%ebp),%eax 16dd: ba 00 00 00 00 mov $0x0,%edx 16e2: f7 f3 div %ebx 16e4: 89 d0 mov %edx,%eax 16e6: 0f b6 80 00 20 00 00 movzbl 0x2000(%eax),%eax 16ed: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 16f1: 8b 75 10 mov 0x10(%ebp),%esi 16f4: 8b 45 ec mov -0x14(%ebp),%eax 16f7: ba 00 00 00 00 mov $0x0,%edx 16fc: f7 f6 div %esi 16fe: 89 45 ec mov %eax,-0x14(%ebp) 1701: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1705: 75 c7 jne 16ce <printint+0x39> if(neg) 1707: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 170b: 74 10 je 171d <printint+0x88> buf[i++] = '-'; 170d: 8b 45 f4 mov -0xc(%ebp),%eax 1710: 8d 50 01 lea 0x1(%eax),%edx 1713: 89 55 f4 mov %edx,-0xc(%ebp) 1716: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 171b: eb 1f jmp 173c <printint+0xa7> 171d: eb 1d jmp 173c <printint+0xa7> putc(fd, buf[i]); 171f: 8d 55 dc lea -0x24(%ebp),%edx 1722: 8b 45 f4 mov -0xc(%ebp),%eax 1725: 01 d0 add %edx,%eax 1727: 0f b6 00 movzbl (%eax),%eax 172a: 0f be c0 movsbl %al,%eax 172d: 89 44 24 04 mov %eax,0x4(%esp) 1731: 8b 45 08 mov 0x8(%ebp),%eax 1734: 89 04 24 mov %eax,(%esp) 1737: e8 31 ff ff ff call 166d <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 173c: 83 6d f4 01 subl $0x1,-0xc(%ebp) 1740: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1744: 79 d9 jns 171f <printint+0x8a> putc(fd, buf[i]); } 1746: 83 c4 30 add $0x30,%esp 1749: 5b pop %ebx 174a: 5e pop %esi 174b: 5d pop %ebp 174c: c3 ret 0000174d <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 174d: 55 push %ebp 174e: 89 e5 mov %esp,%ebp 1750: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 1753: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 175a: 8d 45 0c lea 0xc(%ebp),%eax 175d: 83 c0 04 add $0x4,%eax 1760: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 1763: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 176a: e9 7c 01 00 00 jmp 18eb <printf+0x19e> c = fmt[i] & 0xff; 176f: 8b 55 0c mov 0xc(%ebp),%edx 1772: 8b 45 f0 mov -0x10(%ebp),%eax 1775: 01 d0 add %edx,%eax 1777: 0f b6 00 movzbl (%eax),%eax 177a: 0f be c0 movsbl %al,%eax 177d: 25 ff 00 00 00 and $0xff,%eax 1782: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 1785: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1789: 75 2c jne 17b7 <printf+0x6a> if(c == '%'){ 178b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 178f: 75 0c jne 179d <printf+0x50> state = '%'; 1791: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 1798: e9 4a 01 00 00 jmp 18e7 <printf+0x19a> } else { putc(fd, c); 179d: 8b 45 e4 mov -0x1c(%ebp),%eax 17a0: 0f be c0 movsbl %al,%eax 17a3: 89 44 24 04 mov %eax,0x4(%esp) 17a7: 8b 45 08 mov 0x8(%ebp),%eax 17aa: 89 04 24 mov %eax,(%esp) 17ad: e8 bb fe ff ff call 166d <putc> 17b2: e9 30 01 00 00 jmp 18e7 <printf+0x19a> } } else if(state == '%'){ 17b7: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 17bb: 0f 85 26 01 00 00 jne 18e7 <printf+0x19a> if(c == 'd'){ 17c1: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 17c5: 75 2d jne 17f4 <printf+0xa7> printint(fd, *ap, 10, 1); 17c7: 8b 45 e8 mov -0x18(%ebp),%eax 17ca: 8b 00 mov (%eax),%eax 17cc: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 17d3: 00 17d4: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 17db: 00 17dc: 89 44 24 04 mov %eax,0x4(%esp) 17e0: 8b 45 08 mov 0x8(%ebp),%eax 17e3: 89 04 24 mov %eax,(%esp) 17e6: e8 aa fe ff ff call 1695 <printint> ap++; 17eb: 83 45 e8 04 addl $0x4,-0x18(%ebp) 17ef: e9 ec 00 00 00 jmp 18e0 <printf+0x193> } else if(c == 'x' || c == 'p'){ 17f4: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 17f8: 74 06 je 1800 <printf+0xb3> 17fa: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 17fe: 75 2d jne 182d <printf+0xe0> printint(fd, *ap, 16, 0); 1800: 8b 45 e8 mov -0x18(%ebp),%eax 1803: 8b 00 mov (%eax),%eax 1805: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 180c: 00 180d: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 1814: 00 1815: 89 44 24 04 mov %eax,0x4(%esp) 1819: 8b 45 08 mov 0x8(%ebp),%eax 181c: 89 04 24 mov %eax,(%esp) 181f: e8 71 fe ff ff call 1695 <printint> ap++; 1824: 83 45 e8 04 addl $0x4,-0x18(%ebp) 1828: e9 b3 00 00 00 jmp 18e0 <printf+0x193> } else if(c == 's'){ 182d: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 1831: 75 45 jne 1878 <printf+0x12b> s = (char*)*ap; 1833: 8b 45 e8 mov -0x18(%ebp),%eax 1836: 8b 00 mov (%eax),%eax 1838: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 183b: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 183f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1843: 75 09 jne 184e <printf+0x101> s = "(null)"; 1845: c7 45 f4 52 1b 00 00 movl $0x1b52,-0xc(%ebp) while(*s != 0){ 184c: eb 1e jmp 186c <printf+0x11f> 184e: eb 1c jmp 186c <printf+0x11f> putc(fd, *s); 1850: 8b 45 f4 mov -0xc(%ebp),%eax 1853: 0f b6 00 movzbl (%eax),%eax 1856: 0f be c0 movsbl %al,%eax 1859: 89 44 24 04 mov %eax,0x4(%esp) 185d: 8b 45 08 mov 0x8(%ebp),%eax 1860: 89 04 24 mov %eax,(%esp) 1863: e8 05 fe ff ff call 166d <putc> s++; 1868: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 186c: 8b 45 f4 mov -0xc(%ebp),%eax 186f: 0f b6 00 movzbl (%eax),%eax 1872: 84 c0 test %al,%al 1874: 75 da jne 1850 <printf+0x103> 1876: eb 68 jmp 18e0 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 1878: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 187c: 75 1d jne 189b <printf+0x14e> putc(fd, *ap); 187e: 8b 45 e8 mov -0x18(%ebp),%eax 1881: 8b 00 mov (%eax),%eax 1883: 0f be c0 movsbl %al,%eax 1886: 89 44 24 04 mov %eax,0x4(%esp) 188a: 8b 45 08 mov 0x8(%ebp),%eax 188d: 89 04 24 mov %eax,(%esp) 1890: e8 d8 fd ff ff call 166d <putc> ap++; 1895: 83 45 e8 04 addl $0x4,-0x18(%ebp) 1899: eb 45 jmp 18e0 <printf+0x193> } else if(c == '%'){ 189b: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 189f: 75 17 jne 18b8 <printf+0x16b> putc(fd, c); 18a1: 8b 45 e4 mov -0x1c(%ebp),%eax 18a4: 0f be c0 movsbl %al,%eax 18a7: 89 44 24 04 mov %eax,0x4(%esp) 18ab: 8b 45 08 mov 0x8(%ebp),%eax 18ae: 89 04 24 mov %eax,(%esp) 18b1: e8 b7 fd ff ff call 166d <putc> 18b6: eb 28 jmp 18e0 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 18b8: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 18bf: 00 18c0: 8b 45 08 mov 0x8(%ebp),%eax 18c3: 89 04 24 mov %eax,(%esp) 18c6: e8 a2 fd ff ff call 166d <putc> putc(fd, c); 18cb: 8b 45 e4 mov -0x1c(%ebp),%eax 18ce: 0f be c0 movsbl %al,%eax 18d1: 89 44 24 04 mov %eax,0x4(%esp) 18d5: 8b 45 08 mov 0x8(%ebp),%eax 18d8: 89 04 24 mov %eax,(%esp) 18db: e8 8d fd ff ff call 166d <putc> } state = 0; 18e0: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 18e7: 83 45 f0 01 addl $0x1,-0x10(%ebp) 18eb: 8b 55 0c mov 0xc(%ebp),%edx 18ee: 8b 45 f0 mov -0x10(%ebp),%eax 18f1: 01 d0 add %edx,%eax 18f3: 0f b6 00 movzbl (%eax),%eax 18f6: 84 c0 test %al,%al 18f8: 0f 85 71 fe ff ff jne 176f <printf+0x22> putc(fd, c); } state = 0; } } } 18fe: c9 leave 18ff: c3 ret 00001900 <free>: 1900: 55 push %ebp 1901: 89 e5 mov %esp,%ebp 1903: 83 ec 10 sub $0x10,%esp 1906: 8b 45 08 mov 0x8(%ebp),%eax 1909: 83 e8 08 sub $0x8,%eax 190c: 89 45 f8 mov %eax,-0x8(%ebp) 190f: a1 28 20 00 00 mov 0x2028,%eax 1914: 89 45 fc mov %eax,-0x4(%ebp) 1917: eb 24 jmp 193d <free+0x3d> 1919: 8b 45 fc mov -0x4(%ebp),%eax 191c: 8b 00 mov (%eax),%eax 191e: 3b 45 fc cmp -0x4(%ebp),%eax 1921: 77 12 ja 1935 <free+0x35> 1923: 8b 45 f8 mov -0x8(%ebp),%eax 1926: 3b 45 fc cmp -0x4(%ebp),%eax 1929: 77 24 ja 194f <free+0x4f> 192b: 8b 45 fc mov -0x4(%ebp),%eax 192e: 8b 00 mov (%eax),%eax 1930: 3b 45 f8 cmp -0x8(%ebp),%eax 1933: 77 1a ja 194f <free+0x4f> 1935: 8b 45 fc mov -0x4(%ebp),%eax 1938: 8b 00 mov (%eax),%eax 193a: 89 45 fc mov %eax,-0x4(%ebp) 193d: 8b 45 f8 mov -0x8(%ebp),%eax 1940: 3b 45 fc cmp -0x4(%ebp),%eax 1943: 76 d4 jbe 1919 <free+0x19> 1945: 8b 45 fc mov -0x4(%ebp),%eax 1948: 8b 00 mov (%eax),%eax 194a: 3b 45 f8 cmp -0x8(%ebp),%eax 194d: 76 ca jbe 1919 <free+0x19> 194f: 8b 45 f8 mov -0x8(%ebp),%eax 1952: 8b 40 04 mov 0x4(%eax),%eax 1955: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 195c: 8b 45 f8 mov -0x8(%ebp),%eax 195f: 01 c2 add %eax,%edx 1961: 8b 45 fc mov -0x4(%ebp),%eax 1964: 8b 00 mov (%eax),%eax 1966: 39 c2 cmp %eax,%edx 1968: 75 24 jne 198e <free+0x8e> 196a: 8b 45 f8 mov -0x8(%ebp),%eax 196d: 8b 50 04 mov 0x4(%eax),%edx 1970: 8b 45 fc mov -0x4(%ebp),%eax 1973: 8b 00 mov (%eax),%eax 1975: 8b 40 04 mov 0x4(%eax),%eax 1978: 01 c2 add %eax,%edx 197a: 8b 45 f8 mov -0x8(%ebp),%eax 197d: 89 50 04 mov %edx,0x4(%eax) 1980: 8b 45 fc mov -0x4(%ebp),%eax 1983: 8b 00 mov (%eax),%eax 1985: 8b 10 mov (%eax),%edx 1987: 8b 45 f8 mov -0x8(%ebp),%eax 198a: 89 10 mov %edx,(%eax) 198c: eb 0a jmp 1998 <free+0x98> 198e: 8b 45 fc mov -0x4(%ebp),%eax 1991: 8b 10 mov (%eax),%edx 1993: 8b 45 f8 mov -0x8(%ebp),%eax 1996: 89 10 mov %edx,(%eax) 1998: 8b 45 fc mov -0x4(%ebp),%eax 199b: 8b 40 04 mov 0x4(%eax),%eax 199e: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 19a5: 8b 45 fc mov -0x4(%ebp),%eax 19a8: 01 d0 add %edx,%eax 19aa: 3b 45 f8 cmp -0x8(%ebp),%eax 19ad: 75 20 jne 19cf <free+0xcf> 19af: 8b 45 fc mov -0x4(%ebp),%eax 19b2: 8b 50 04 mov 0x4(%eax),%edx 19b5: 8b 45 f8 mov -0x8(%ebp),%eax 19b8: 8b 40 04 mov 0x4(%eax),%eax 19bb: 01 c2 add %eax,%edx 19bd: 8b 45 fc mov -0x4(%ebp),%eax 19c0: 89 50 04 mov %edx,0x4(%eax) 19c3: 8b 45 f8 mov -0x8(%ebp),%eax 19c6: 8b 10 mov (%eax),%edx 19c8: 8b 45 fc mov -0x4(%ebp),%eax 19cb: 89 10 mov %edx,(%eax) 19cd: eb 08 jmp 19d7 <free+0xd7> 19cf: 8b 45 fc mov -0x4(%ebp),%eax 19d2: 8b 55 f8 mov -0x8(%ebp),%edx 19d5: 89 10 mov %edx,(%eax) 19d7: 8b 45 fc mov -0x4(%ebp),%eax 19da: a3 28 20 00 00 mov %eax,0x2028 19df: c9 leave 19e0: c3 ret 000019e1 <morecore>: 19e1: 55 push %ebp 19e2: 89 e5 mov %esp,%ebp 19e4: 83 ec 28 sub $0x28,%esp 19e7: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 19ee: 77 07 ja 19f7 <morecore+0x16> 19f0: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) 19f7: 8b 45 08 mov 0x8(%ebp),%eax 19fa: c1 e0 03 shl $0x3,%eax 19fd: 89 04 24 mov %eax,(%esp) 1a00: e8 50 fc ff ff call 1655 <sbrk> 1a05: 89 45 f4 mov %eax,-0xc(%ebp) 1a08: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 1a0c: 75 07 jne 1a15 <morecore+0x34> 1a0e: b8 00 00 00 00 mov $0x0,%eax 1a13: eb 22 jmp 1a37 <morecore+0x56> 1a15: 8b 45 f4 mov -0xc(%ebp),%eax 1a18: 89 45 f0 mov %eax,-0x10(%ebp) 1a1b: 8b 45 f0 mov -0x10(%ebp),%eax 1a1e: 8b 55 08 mov 0x8(%ebp),%edx 1a21: 89 50 04 mov %edx,0x4(%eax) 1a24: 8b 45 f0 mov -0x10(%ebp),%eax 1a27: 83 c0 08 add $0x8,%eax 1a2a: 89 04 24 mov %eax,(%esp) 1a2d: e8 ce fe ff ff call 1900 <free> 1a32: a1 28 20 00 00 mov 0x2028,%eax 1a37: c9 leave 1a38: c3 ret 00001a39 <malloc>: 1a39: 55 push %ebp 1a3a: 89 e5 mov %esp,%ebp 1a3c: 83 ec 28 sub $0x28,%esp 1a3f: 8b 45 08 mov 0x8(%ebp),%eax 1a42: 83 c0 07 add $0x7,%eax 1a45: c1 e8 03 shr $0x3,%eax 1a48: 83 c0 01 add $0x1,%eax 1a4b: 89 45 ec mov %eax,-0x14(%ebp) 1a4e: a1 28 20 00 00 mov 0x2028,%eax 1a53: 89 45 f0 mov %eax,-0x10(%ebp) 1a56: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1a5a: 75 23 jne 1a7f <malloc+0x46> 1a5c: c7 45 f0 20 20 00 00 movl $0x2020,-0x10(%ebp) 1a63: 8b 45 f0 mov -0x10(%ebp),%eax 1a66: a3 28 20 00 00 mov %eax,0x2028 1a6b: a1 28 20 00 00 mov 0x2028,%eax 1a70: a3 20 20 00 00 mov %eax,0x2020 1a75: c7 05 24 20 00 00 00 movl $0x0,0x2024 1a7c: 00 00 00 1a7f: 8b 45 f0 mov -0x10(%ebp),%eax 1a82: 8b 00 mov (%eax),%eax 1a84: 89 45 f4 mov %eax,-0xc(%ebp) 1a87: 8b 45 f4 mov -0xc(%ebp),%eax 1a8a: 8b 40 04 mov 0x4(%eax),%eax 1a8d: 3b 45 ec cmp -0x14(%ebp),%eax 1a90: 72 4d jb 1adf <malloc+0xa6> 1a92: 8b 45 f4 mov -0xc(%ebp),%eax 1a95: 8b 40 04 mov 0x4(%eax),%eax 1a98: 3b 45 ec cmp -0x14(%ebp),%eax 1a9b: 75 0c jne 1aa9 <malloc+0x70> 1a9d: 8b 45 f4 mov -0xc(%ebp),%eax 1aa0: 8b 10 mov (%eax),%edx 1aa2: 8b 45 f0 mov -0x10(%ebp),%eax 1aa5: 89 10 mov %edx,(%eax) 1aa7: eb 26 jmp 1acf <malloc+0x96> 1aa9: 8b 45 f4 mov -0xc(%ebp),%eax 1aac: 8b 40 04 mov 0x4(%eax),%eax 1aaf: 2b 45 ec sub -0x14(%ebp),%eax 1ab2: 89 c2 mov %eax,%edx 1ab4: 8b 45 f4 mov -0xc(%ebp),%eax 1ab7: 89 50 04 mov %edx,0x4(%eax) 1aba: 8b 45 f4 mov -0xc(%ebp),%eax 1abd: 8b 40 04 mov 0x4(%eax),%eax 1ac0: c1 e0 03 shl $0x3,%eax 1ac3: 01 45 f4 add %eax,-0xc(%ebp) 1ac6: 8b 45 f4 mov -0xc(%ebp),%eax 1ac9: 8b 55 ec mov -0x14(%ebp),%edx 1acc: 89 50 04 mov %edx,0x4(%eax) 1acf: 8b 45 f0 mov -0x10(%ebp),%eax 1ad2: a3 28 20 00 00 mov %eax,0x2028 1ad7: 8b 45 f4 mov -0xc(%ebp),%eax 1ada: 83 c0 08 add $0x8,%eax 1add: eb 38 jmp 1b17 <malloc+0xde> 1adf: a1 28 20 00 00 mov 0x2028,%eax 1ae4: 39 45 f4 cmp %eax,-0xc(%ebp) 1ae7: 75 1b jne 1b04 <malloc+0xcb> 1ae9: 8b 45 ec mov -0x14(%ebp),%eax 1aec: 89 04 24 mov %eax,(%esp) 1aef: e8 ed fe ff ff call 19e1 <morecore> 1af4: 89 45 f4 mov %eax,-0xc(%ebp) 1af7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1afb: 75 07 jne 1b04 <malloc+0xcb> 1afd: b8 00 00 00 00 mov $0x0,%eax 1b02: eb 13 jmp 1b17 <malloc+0xde> 1b04: 8b 45 f4 mov -0xc(%ebp),%eax 1b07: 89 45 f0 mov %eax,-0x10(%ebp) 1b0a: 8b 45 f4 mov -0xc(%ebp),%eax 1b0d: 8b 00 mov (%eax),%eax 1b0f: 89 45 f4 mov %eax,-0xc(%ebp) 1b12: e9 70 ff ff ff jmp 1a87 <malloc+0x4e> 1b17: c9 leave 1b18: c3 ret
_rm: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: bf 01 00 00 00 mov $0x1,%edi 16: 83 ec 08 sub $0x8,%esp 19: 8b 31 mov (%ecx),%esi 1b: 8b 59 04 mov 0x4(%ecx),%ebx 1e: 83 c3 04 add $0x4,%ebx int i; if(argc < 2){ 21: 83 fe 01 cmp $0x1,%esi 24: 7e 3e jle 64 <main+0x64> 26: 8d 76 00 lea 0x0(%esi),%esi 29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi printf(2, "Usage: rm files...\n"); exit(); } for(i = 1; i < argc; i++){ if(unlink(argv[i]) < 0){ 30: 83 ec 0c sub $0xc,%esp 33: ff 33 pushl (%ebx) 35: e8 e8 02 00 00 call 322 <unlink> 3a: 83 c4 10 add $0x10,%esp 3d: 85 c0 test %eax,%eax 3f: 78 0f js 50 <main+0x50> for(i = 1; i < argc; i++){ 41: 83 c7 01 add $0x1,%edi 44: 83 c3 04 add $0x4,%ebx 47: 39 fe cmp %edi,%esi 49: 75 e5 jne 30 <main+0x30> printf(2, "rm: %s failed to delete\n", argv[i]); break; } } exit(); 4b: e8 82 02 00 00 call 2d2 <exit> printf(2, "rm: %s failed to delete\n", argv[i]); 50: 50 push %eax 51: ff 33 pushl (%ebx) 53: 68 9c 07 00 00 push $0x79c 58: 6a 02 push $0x2 5a: e8 d1 03 00 00 call 430 <printf> break; 5f: 83 c4 10 add $0x10,%esp 62: eb e7 jmp 4b <main+0x4b> printf(2, "Usage: rm files...\n"); 64: 52 push %edx 65: 52 push %edx 66: 68 88 07 00 00 push $0x788 6b: 6a 02 push $0x2 6d: e8 be 03 00 00 call 430 <printf> exit(); 72: e8 5b 02 00 00 call 2d2 <exit> 77: 66 90 xchg %ax,%ax 79: 66 90 xchg %ax,%ax 7b: 66 90 xchg %ax,%ax 7d: 66 90 xchg %ax,%ax 7f: 90 nop 00000080 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 80: 55 push %ebp 81: 89 e5 mov %esp,%ebp 83: 53 push %ebx 84: 8b 45 08 mov 0x8(%ebp),%eax 87: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 8a: 89 c2 mov %eax,%edx 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 90: 83 c1 01 add $0x1,%ecx 93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 97: 83 c2 01 add $0x1,%edx 9a: 84 db test %bl,%bl 9c: 88 5a ff mov %bl,-0x1(%edx) 9f: 75 ef jne 90 <strcpy+0x10> ; return os; } a1: 5b pop %ebx a2: 5d pop %ebp a3: c3 ret a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000b0 <strcmp>: int strcmp(const char *p, const char *q) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 53 push %ebx b4: 8b 55 08 mov 0x8(%ebp),%edx b7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) ba: 0f b6 02 movzbl (%edx),%eax bd: 0f b6 19 movzbl (%ecx),%ebx c0: 84 c0 test %al,%al c2: 75 1c jne e0 <strcmp+0x30> c4: eb 2a jmp f0 <strcmp+0x40> c6: 8d 76 00 lea 0x0(%esi),%esi c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; d0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) d3: 0f b6 02 movzbl (%edx),%eax p++, q++; d6: 83 c1 01 add $0x1,%ecx d9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) dc: 84 c0 test %al,%al de: 74 10 je f0 <strcmp+0x40> e0: 38 d8 cmp %bl,%al e2: 74 ec je d0 <strcmp+0x20> return (uchar)*p - (uchar)*q; e4: 29 d8 sub %ebx,%eax } e6: 5b pop %ebx e7: 5d pop %ebp e8: c3 ret e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; f2: 29 d8 sub %ebx,%eax } f4: 5b pop %ebx f5: 5d pop %ebp f6: c3 ret f7: 89 f6 mov %esi,%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <strlen>: uint strlen(const char *s) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 106: 80 39 00 cmpb $0x0,(%ecx) 109: 74 15 je 120 <strlen+0x20> 10b: 31 d2 xor %edx,%edx 10d: 8d 76 00 lea 0x0(%esi),%esi 110: 83 c2 01 add $0x1,%edx 113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 117: 89 d0 mov %edx,%eax 119: 75 f5 jne 110 <strlen+0x10> ; return n; } 11b: 5d pop %ebp 11c: c3 ret 11d: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 120: 31 c0 xor %eax,%eax } 122: 5d pop %ebp 123: c3 ret 124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000130 <memset>: void* memset(void *dst, int c, uint n) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 57 push %edi 134: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 137: 8b 4d 10 mov 0x10(%ebp),%ecx 13a: 8b 45 0c mov 0xc(%ebp),%eax 13d: 89 d7 mov %edx,%edi 13f: fc cld 140: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 142: 89 d0 mov %edx,%eax 144: 5f pop %edi 145: 5d pop %ebp 146: c3 ret 147: 89 f6 mov %esi,%esi 149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000150 <strchr>: char* strchr(const char *s, char c) { 150: 55 push %ebp 151: 89 e5 mov %esp,%ebp 153: 53 push %ebx 154: 8b 45 08 mov 0x8(%ebp),%eax 157: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 15a: 0f b6 10 movzbl (%eax),%edx 15d: 84 d2 test %dl,%dl 15f: 74 1d je 17e <strchr+0x2e> if(*s == c) 161: 38 d3 cmp %dl,%bl 163: 89 d9 mov %ebx,%ecx 165: 75 0d jne 174 <strchr+0x24> 167: eb 17 jmp 180 <strchr+0x30> 169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 170: 38 ca cmp %cl,%dl 172: 74 0c je 180 <strchr+0x30> for(; *s; s++) 174: 83 c0 01 add $0x1,%eax 177: 0f b6 10 movzbl (%eax),%edx 17a: 84 d2 test %dl,%dl 17c: 75 f2 jne 170 <strchr+0x20> return (char*)s; return 0; 17e: 31 c0 xor %eax,%eax } 180: 5b pop %ebx 181: 5d pop %ebp 182: c3 ret 183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000190 <gets>: char* gets(char *buf, int max) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 57 push %edi 194: 56 push %esi 195: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 196: 31 f6 xor %esi,%esi 198: 89 f3 mov %esi,%ebx { 19a: 83 ec 1c sub $0x1c,%esp 19d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 1a0: eb 2f jmp 1d1 <gets+0x41> 1a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 1a8: 8d 45 e7 lea -0x19(%ebp),%eax 1ab: 83 ec 04 sub $0x4,%esp 1ae: 6a 01 push $0x1 1b0: 50 push %eax 1b1: 6a 00 push $0x0 1b3: e8 32 01 00 00 call 2ea <read> if(cc < 1) 1b8: 83 c4 10 add $0x10,%esp 1bb: 85 c0 test %eax,%eax 1bd: 7e 1c jle 1db <gets+0x4b> break; buf[i++] = c; 1bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1c3: 83 c7 01 add $0x1,%edi 1c6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1c9: 3c 0a cmp $0xa,%al 1cb: 74 23 je 1f0 <gets+0x60> 1cd: 3c 0d cmp $0xd,%al 1cf: 74 1f je 1f0 <gets+0x60> for(i=0; i+1 < max; ){ 1d1: 83 c3 01 add $0x1,%ebx 1d4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1d7: 89 fe mov %edi,%esi 1d9: 7c cd jl 1a8 <gets+0x18> 1db: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1dd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1e0: c6 03 00 movb $0x0,(%ebx) } 1e3: 8d 65 f4 lea -0xc(%ebp),%esp 1e6: 5b pop %ebx 1e7: 5e pop %esi 1e8: 5f pop %edi 1e9: 5d pop %ebp 1ea: c3 ret 1eb: 90 nop 1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1f0: 8b 75 08 mov 0x8(%ebp),%esi 1f3: 8b 45 08 mov 0x8(%ebp),%eax 1f6: 01 de add %ebx,%esi 1f8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1fa: c6 03 00 movb $0x0,(%ebx) } 1fd: 8d 65 f4 lea -0xc(%ebp),%esp 200: 5b pop %ebx 201: 5e pop %esi 202: 5f pop %edi 203: 5d pop %ebp 204: c3 ret 205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <stat>: int stat(const char *n, struct stat *st) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 56 push %esi 214: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 215: 83 ec 08 sub $0x8,%esp 218: 6a 00 push $0x0 21a: ff 75 08 pushl 0x8(%ebp) 21d: e8 f0 00 00 00 call 312 <open> if(fd < 0) 222: 83 c4 10 add $0x10,%esp 225: 85 c0 test %eax,%eax 227: 78 27 js 250 <stat+0x40> return -1; r = fstat(fd, st); 229: 83 ec 08 sub $0x8,%esp 22c: ff 75 0c pushl 0xc(%ebp) 22f: 89 c3 mov %eax,%ebx 231: 50 push %eax 232: e8 f3 00 00 00 call 32a <fstat> close(fd); 237: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 23a: 89 c6 mov %eax,%esi close(fd); 23c: e8 b9 00 00 00 call 2fa <close> return r; 241: 83 c4 10 add $0x10,%esp } 244: 8d 65 f8 lea -0x8(%ebp),%esp 247: 89 f0 mov %esi,%eax 249: 5b pop %ebx 24a: 5e pop %esi 24b: 5d pop %ebp 24c: c3 ret 24d: 8d 76 00 lea 0x0(%esi),%esi return -1; 250: be ff ff ff ff mov $0xffffffff,%esi 255: eb ed jmp 244 <stat+0x34> 257: 89 f6 mov %esi,%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000260 <atoi>: int atoi(const char *s) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 53 push %ebx 264: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 267: 0f be 11 movsbl (%ecx),%edx 26a: 8d 42 d0 lea -0x30(%edx),%eax 26d: 3c 09 cmp $0x9,%al n = 0; 26f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 274: 77 1f ja 295 <atoi+0x35> 276: 8d 76 00 lea 0x0(%esi),%esi 279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 280: 8d 04 80 lea (%eax,%eax,4),%eax 283: 83 c1 01 add $0x1,%ecx 286: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 28a: 0f be 11 movsbl (%ecx),%edx 28d: 8d 5a d0 lea -0x30(%edx),%ebx 290: 80 fb 09 cmp $0x9,%bl 293: 76 eb jbe 280 <atoi+0x20> return n; } 295: 5b pop %ebx 296: 5d pop %ebp 297: c3 ret 298: 90 nop 299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000002a0 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 2a0: 55 push %ebp 2a1: 89 e5 mov %esp,%ebp 2a3: 56 push %esi 2a4: 53 push %ebx 2a5: 8b 5d 10 mov 0x10(%ebp),%ebx 2a8: 8b 45 08 mov 0x8(%ebp),%eax 2ab: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 2ae: 85 db test %ebx,%ebx 2b0: 7e 14 jle 2c6 <memmove+0x26> 2b2: 31 d2 xor %edx,%edx 2b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 2b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 2bc: 88 0c 10 mov %cl,(%eax,%edx,1) 2bf: 83 c2 01 add $0x1,%edx while(n-- > 0) 2c2: 39 d3 cmp %edx,%ebx 2c4: 75 f2 jne 2b8 <memmove+0x18> return vdst; } 2c6: 5b pop %ebx 2c7: 5e pop %esi 2c8: 5d pop %ebp 2c9: c3 ret 000002ca <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2ca: b8 01 00 00 00 mov $0x1,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <exit>: SYSCALL(exit) 2d2: b8 02 00 00 00 mov $0x2,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <wait>: SYSCALL(wait) 2da: b8 03 00 00 00 mov $0x3,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <pipe>: SYSCALL(pipe) 2e2: b8 04 00 00 00 mov $0x4,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <read>: SYSCALL(read) 2ea: b8 05 00 00 00 mov $0x5,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <write>: SYSCALL(write) 2f2: b8 10 00 00 00 mov $0x10,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <close>: SYSCALL(close) 2fa: b8 15 00 00 00 mov $0x15,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <kill>: SYSCALL(kill) 302: b8 06 00 00 00 mov $0x6,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <exec>: SYSCALL(exec) 30a: b8 07 00 00 00 mov $0x7,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <open>: SYSCALL(open) 312: b8 0f 00 00 00 mov $0xf,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <mknod>: SYSCALL(mknod) 31a: b8 11 00 00 00 mov $0x11,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <unlink>: SYSCALL(unlink) 322: b8 12 00 00 00 mov $0x12,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <fstat>: SYSCALL(fstat) 32a: b8 08 00 00 00 mov $0x8,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <link>: SYSCALL(link) 332: b8 13 00 00 00 mov $0x13,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <mkdir>: SYSCALL(mkdir) 33a: b8 14 00 00 00 mov $0x14,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <chdir>: SYSCALL(chdir) 342: b8 09 00 00 00 mov $0x9,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <dup>: SYSCALL(dup) 34a: b8 0a 00 00 00 mov $0xa,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <getpid>: SYSCALL(getpid) 352: b8 0b 00 00 00 mov $0xb,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <sbrk>: SYSCALL(sbrk) 35a: b8 0c 00 00 00 mov $0xc,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <sleep>: SYSCALL(sleep) 362: b8 0d 00 00 00 mov $0xd,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <uptime>: SYSCALL(uptime) 36a: b8 0e 00 00 00 mov $0xe,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <set_priority>: SYSCALL(set_priority) 372: b8 16 00 00 00 mov $0x16,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <waitx>: SYSCALL(waitx) 37a: b8 17 00 00 00 mov $0x17,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <getpinfo>: 382: b8 18 00 00 00 mov $0x18,%eax 387: cd 40 int $0x40 389: c3 ret 38a: 66 90 xchg %ax,%ax 38c: 66 90 xchg %ax,%ax 38e: 66 90 xchg %ax,%ax 00000390 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 57 push %edi 394: 56 push %esi 395: 53 push %ebx 396: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 399: 85 d2 test %edx,%edx { 39b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 39e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 3a0: 79 76 jns 418 <printint+0x88> 3a2: f6 45 08 01 testb $0x1,0x8(%ebp) 3a6: 74 70 je 418 <printint+0x88> x = -xx; 3a8: f7 d8 neg %eax neg = 1; 3aa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3b1: 31 f6 xor %esi,%esi 3b3: 8d 5d d7 lea -0x29(%ebp),%ebx 3b6: eb 0a jmp 3c2 <printint+0x32> 3b8: 90 nop 3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3c0: 89 fe mov %edi,%esi 3c2: 31 d2 xor %edx,%edx 3c4: 8d 7e 01 lea 0x1(%esi),%edi 3c7: f7 f1 div %ecx 3c9: 0f b6 92 bc 07 00 00 movzbl 0x7bc(%edx),%edx }while((x /= base) != 0); 3d0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3d2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3d5: 75 e9 jne 3c0 <printint+0x30> if(neg) 3d7: 8b 45 c4 mov -0x3c(%ebp),%eax 3da: 85 c0 test %eax,%eax 3dc: 74 08 je 3e6 <printint+0x56> buf[i++] = '-'; 3de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 3e3: 8d 7e 02 lea 0x2(%esi),%edi 3e6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 3ea: 8b 7d c0 mov -0x40(%ebp),%edi 3ed: 8d 76 00 lea 0x0(%esi),%esi 3f0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 3f3: 83 ec 04 sub $0x4,%esp 3f6: 83 ee 01 sub $0x1,%esi 3f9: 6a 01 push $0x1 3fb: 53 push %ebx 3fc: 57 push %edi 3fd: 88 45 d7 mov %al,-0x29(%ebp) 400: e8 ed fe ff ff call 2f2 <write> while(--i >= 0) 405: 83 c4 10 add $0x10,%esp 408: 39 de cmp %ebx,%esi 40a: 75 e4 jne 3f0 <printint+0x60> putc(fd, buf[i]); } 40c: 8d 65 f4 lea -0xc(%ebp),%esp 40f: 5b pop %ebx 410: 5e pop %esi 411: 5f pop %edi 412: 5d pop %ebp 413: c3 ret 414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 418: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 41f: eb 90 jmp 3b1 <printint+0x21> 421: eb 0d jmp 430 <printf> 423: 90 nop 424: 90 nop 425: 90 nop 426: 90 nop 427: 90 nop 428: 90 nop 429: 90 nop 42a: 90 nop 42b: 90 nop 42c: 90 nop 42d: 90 nop 42e: 90 nop 42f: 90 nop 00000430 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 430: 55 push %ebp 431: 89 e5 mov %esp,%ebp 433: 57 push %edi 434: 56 push %esi 435: 53 push %ebx 436: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 439: 8b 75 0c mov 0xc(%ebp),%esi 43c: 0f b6 1e movzbl (%esi),%ebx 43f: 84 db test %bl,%bl 441: 0f 84 b3 00 00 00 je 4fa <printf+0xca> ap = (uint*)(void*)&fmt + 1; 447: 8d 45 10 lea 0x10(%ebp),%eax 44a: 83 c6 01 add $0x1,%esi state = 0; 44d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 44f: 89 45 d4 mov %eax,-0x2c(%ebp) 452: eb 2f jmp 483 <printf+0x53> 454: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 458: 83 f8 25 cmp $0x25,%eax 45b: 0f 84 a7 00 00 00 je 508 <printf+0xd8> write(fd, &c, 1); 461: 8d 45 e2 lea -0x1e(%ebp),%eax 464: 83 ec 04 sub $0x4,%esp 467: 88 5d e2 mov %bl,-0x1e(%ebp) 46a: 6a 01 push $0x1 46c: 50 push %eax 46d: ff 75 08 pushl 0x8(%ebp) 470: e8 7d fe ff ff call 2f2 <write> 475: 83 c4 10 add $0x10,%esp 478: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 47b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 47f: 84 db test %bl,%bl 481: 74 77 je 4fa <printf+0xca> if(state == 0){ 483: 85 ff test %edi,%edi c = fmt[i] & 0xff; 485: 0f be cb movsbl %bl,%ecx 488: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 48b: 74 cb je 458 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 48d: 83 ff 25 cmp $0x25,%edi 490: 75 e6 jne 478 <printf+0x48> if(c == 'd'){ 492: 83 f8 64 cmp $0x64,%eax 495: 0f 84 05 01 00 00 je 5a0 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 49b: 81 e1 f7 00 00 00 and $0xf7,%ecx 4a1: 83 f9 70 cmp $0x70,%ecx 4a4: 74 72 je 518 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 4a6: 83 f8 73 cmp $0x73,%eax 4a9: 0f 84 99 00 00 00 je 548 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4af: 83 f8 63 cmp $0x63,%eax 4b2: 0f 84 08 01 00 00 je 5c0 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 4b8: 83 f8 25 cmp $0x25,%eax 4bb: 0f 84 ef 00 00 00 je 5b0 <printf+0x180> write(fd, &c, 1); 4c1: 8d 45 e7 lea -0x19(%ebp),%eax 4c4: 83 ec 04 sub $0x4,%esp 4c7: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4cb: 6a 01 push $0x1 4cd: 50 push %eax 4ce: ff 75 08 pushl 0x8(%ebp) 4d1: e8 1c fe ff ff call 2f2 <write> 4d6: 83 c4 0c add $0xc,%esp 4d9: 8d 45 e6 lea -0x1a(%ebp),%eax 4dc: 88 5d e6 mov %bl,-0x1a(%ebp) 4df: 6a 01 push $0x1 4e1: 50 push %eax 4e2: ff 75 08 pushl 0x8(%ebp) 4e5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4e8: 31 ff xor %edi,%edi write(fd, &c, 1); 4ea: e8 03 fe ff ff call 2f2 <write> for(i = 0; fmt[i]; i++){ 4ef: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 4f3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 4f6: 84 db test %bl,%bl 4f8: 75 89 jne 483 <printf+0x53> } } } 4fa: 8d 65 f4 lea -0xc(%ebp),%esp 4fd: 5b pop %ebx 4fe: 5e pop %esi 4ff: 5f pop %edi 500: 5d pop %ebp 501: c3 ret 502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 508: bf 25 00 00 00 mov $0x25,%edi 50d: e9 66 ff ff ff jmp 478 <printf+0x48> 512: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 518: 83 ec 0c sub $0xc,%esp 51b: b9 10 00 00 00 mov $0x10,%ecx 520: 6a 00 push $0x0 522: 8b 7d d4 mov -0x2c(%ebp),%edi 525: 8b 45 08 mov 0x8(%ebp),%eax 528: 8b 17 mov (%edi),%edx 52a: e8 61 fe ff ff call 390 <printint> ap++; 52f: 89 f8 mov %edi,%eax 531: 83 c4 10 add $0x10,%esp state = 0; 534: 31 ff xor %edi,%edi ap++; 536: 83 c0 04 add $0x4,%eax 539: 89 45 d4 mov %eax,-0x2c(%ebp) 53c: e9 37 ff ff ff jmp 478 <printf+0x48> 541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 548: 8b 45 d4 mov -0x2c(%ebp),%eax 54b: 8b 08 mov (%eax),%ecx ap++; 54d: 83 c0 04 add $0x4,%eax 550: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 553: 85 c9 test %ecx,%ecx 555: 0f 84 8e 00 00 00 je 5e9 <printf+0x1b9> while(*s != 0){ 55b: 0f b6 01 movzbl (%ecx),%eax state = 0; 55e: 31 ff xor %edi,%edi s = (char*)*ap; 560: 89 cb mov %ecx,%ebx while(*s != 0){ 562: 84 c0 test %al,%al 564: 0f 84 0e ff ff ff je 478 <printf+0x48> 56a: 89 75 d0 mov %esi,-0x30(%ebp) 56d: 89 de mov %ebx,%esi 56f: 8b 5d 08 mov 0x8(%ebp),%ebx 572: 8d 7d e3 lea -0x1d(%ebp),%edi 575: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 578: 83 ec 04 sub $0x4,%esp s++; 57b: 83 c6 01 add $0x1,%esi 57e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 581: 6a 01 push $0x1 583: 57 push %edi 584: 53 push %ebx 585: e8 68 fd ff ff call 2f2 <write> while(*s != 0){ 58a: 0f b6 06 movzbl (%esi),%eax 58d: 83 c4 10 add $0x10,%esp 590: 84 c0 test %al,%al 592: 75 e4 jne 578 <printf+0x148> 594: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 597: 31 ff xor %edi,%edi 599: e9 da fe ff ff jmp 478 <printf+0x48> 59e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 5a0: 83 ec 0c sub $0xc,%esp 5a3: b9 0a 00 00 00 mov $0xa,%ecx 5a8: 6a 01 push $0x1 5aa: e9 73 ff ff ff jmp 522 <printf+0xf2> 5af: 90 nop write(fd, &c, 1); 5b0: 83 ec 04 sub $0x4,%esp 5b3: 88 5d e5 mov %bl,-0x1b(%ebp) 5b6: 8d 45 e5 lea -0x1b(%ebp),%eax 5b9: 6a 01 push $0x1 5bb: e9 21 ff ff ff jmp 4e1 <printf+0xb1> putc(fd, *ap); 5c0: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 5c3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 5c6: 8b 07 mov (%edi),%eax write(fd, &c, 1); 5c8: 6a 01 push $0x1 ap++; 5ca: 83 c7 04 add $0x4,%edi putc(fd, *ap); 5cd: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5d0: 8d 45 e4 lea -0x1c(%ebp),%eax 5d3: 50 push %eax 5d4: ff 75 08 pushl 0x8(%ebp) 5d7: e8 16 fd ff ff call 2f2 <write> ap++; 5dc: 89 7d d4 mov %edi,-0x2c(%ebp) 5df: 83 c4 10 add $0x10,%esp state = 0; 5e2: 31 ff xor %edi,%edi 5e4: e9 8f fe ff ff jmp 478 <printf+0x48> s = "(null)"; 5e9: bb b5 07 00 00 mov $0x7b5,%ebx while(*s != 0){ 5ee: b8 28 00 00 00 mov $0x28,%eax 5f3: e9 72 ff ff ff jmp 56a <printf+0x13a> 5f8: 66 90 xchg %ax,%ax 5fa: 66 90 xchg %ax,%ax 5fc: 66 90 xchg %ax,%ax 5fe: 66 90 xchg %ax,%ax 00000600 <free>: static Header base; static Header *freep; void free(void *ap) { 600: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 601: a1 6c 0a 00 00 mov 0xa6c,%eax { 606: 89 e5 mov %esp,%ebp 608: 57 push %edi 609: 56 push %esi 60a: 53 push %ebx 60b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 60e: 8d 4b f8 lea -0x8(%ebx),%ecx 611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 618: 39 c8 cmp %ecx,%eax 61a: 8b 10 mov (%eax),%edx 61c: 73 32 jae 650 <free+0x50> 61e: 39 d1 cmp %edx,%ecx 620: 72 04 jb 626 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 622: 39 d0 cmp %edx,%eax 624: 72 32 jb 658 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 626: 8b 73 fc mov -0x4(%ebx),%esi 629: 8d 3c f1 lea (%ecx,%esi,8),%edi 62c: 39 fa cmp %edi,%edx 62e: 74 30 je 660 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 630: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 633: 8b 50 04 mov 0x4(%eax),%edx 636: 8d 34 d0 lea (%eax,%edx,8),%esi 639: 39 f1 cmp %esi,%ecx 63b: 74 3a je 677 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 63d: 89 08 mov %ecx,(%eax) freep = p; 63f: a3 6c 0a 00 00 mov %eax,0xa6c } 644: 5b pop %ebx 645: 5e pop %esi 646: 5f pop %edi 647: 5d pop %ebp 648: c3 ret 649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 650: 39 d0 cmp %edx,%eax 652: 72 04 jb 658 <free+0x58> 654: 39 d1 cmp %edx,%ecx 656: 72 ce jb 626 <free+0x26> { 658: 89 d0 mov %edx,%eax 65a: eb bc jmp 618 <free+0x18> 65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 660: 03 72 04 add 0x4(%edx),%esi 663: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 666: 8b 10 mov (%eax),%edx 668: 8b 12 mov (%edx),%edx 66a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 66d: 8b 50 04 mov 0x4(%eax),%edx 670: 8d 34 d0 lea (%eax,%edx,8),%esi 673: 39 f1 cmp %esi,%ecx 675: 75 c6 jne 63d <free+0x3d> p->s.size += bp->s.size; 677: 03 53 fc add -0x4(%ebx),%edx freep = p; 67a: a3 6c 0a 00 00 mov %eax,0xa6c p->s.size += bp->s.size; 67f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 682: 8b 53 f8 mov -0x8(%ebx),%edx 685: 89 10 mov %edx,(%eax) } 687: 5b pop %ebx 688: 5e pop %esi 689: 5f pop %edi 68a: 5d pop %ebp 68b: c3 ret 68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000690 <malloc>: return freep; } void* malloc(uint nbytes) { 690: 55 push %ebp 691: 89 e5 mov %esp,%ebp 693: 57 push %edi 694: 56 push %esi 695: 53 push %ebx 696: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 699: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 69c: 8b 15 6c 0a 00 00 mov 0xa6c,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6a2: 8d 78 07 lea 0x7(%eax),%edi 6a5: c1 ef 03 shr $0x3,%edi 6a8: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 6ab: 85 d2 test %edx,%edx 6ad: 0f 84 9d 00 00 00 je 750 <malloc+0xc0> 6b3: 8b 02 mov (%edx),%eax 6b5: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 6b8: 39 cf cmp %ecx,%edi 6ba: 76 6c jbe 728 <malloc+0x98> 6bc: 81 ff 00 10 00 00 cmp $0x1000,%edi 6c2: bb 00 10 00 00 mov $0x1000,%ebx 6c7: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6ca: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6d1: eb 0e jmp 6e1 <malloc+0x51> 6d3: 90 nop 6d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6d8: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6da: 8b 48 04 mov 0x4(%eax),%ecx 6dd: 39 f9 cmp %edi,%ecx 6df: 73 47 jae 728 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6e1: 39 05 6c 0a 00 00 cmp %eax,0xa6c 6e7: 89 c2 mov %eax,%edx 6e9: 75 ed jne 6d8 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 6eb: 83 ec 0c sub $0xc,%esp 6ee: 56 push %esi 6ef: e8 66 fc ff ff call 35a <sbrk> if(p == (char*)-1) 6f4: 83 c4 10 add $0x10,%esp 6f7: 83 f8 ff cmp $0xffffffff,%eax 6fa: 74 1c je 718 <malloc+0x88> hp->s.size = nu; 6fc: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6ff: 83 ec 0c sub $0xc,%esp 702: 83 c0 08 add $0x8,%eax 705: 50 push %eax 706: e8 f5 fe ff ff call 600 <free> return freep; 70b: 8b 15 6c 0a 00 00 mov 0xa6c,%edx if((p = morecore(nunits)) == 0) 711: 83 c4 10 add $0x10,%esp 714: 85 d2 test %edx,%edx 716: 75 c0 jne 6d8 <malloc+0x48> return 0; } } 718: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 71b: 31 c0 xor %eax,%eax } 71d: 5b pop %ebx 71e: 5e pop %esi 71f: 5f pop %edi 720: 5d pop %ebp 721: c3 ret 722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 728: 39 cf cmp %ecx,%edi 72a: 74 54 je 780 <malloc+0xf0> p->s.size -= nunits; 72c: 29 f9 sub %edi,%ecx 72e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 731: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 734: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 737: 89 15 6c 0a 00 00 mov %edx,0xa6c } 73d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 740: 83 c0 08 add $0x8,%eax } 743: 5b pop %ebx 744: 5e pop %esi 745: 5f pop %edi 746: 5d pop %ebp 747: c3 ret 748: 90 nop 749: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 750: c7 05 6c 0a 00 00 70 movl $0xa70,0xa6c 757: 0a 00 00 75a: c7 05 70 0a 00 00 70 movl $0xa70,0xa70 761: 0a 00 00 base.s.size = 0; 764: b8 70 0a 00 00 mov $0xa70,%eax 769: c7 05 74 0a 00 00 00 movl $0x0,0xa74 770: 00 00 00 773: e9 44 ff ff ff jmp 6bc <malloc+0x2c> 778: 90 nop 779: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 780: 8b 08 mov (%eax),%ecx 782: 89 0a mov %ecx,(%edx) 784: eb b1 jmp 737 <malloc+0xa7>
MULTIPLY: MOV R4, #'x' MOV R0, #2h MOV A, #50h ADD A, R0 MOV R0, A MOV A, @R0 ACALL CONTINUECODE
dnl S/390-32 logops. dnl Copyright 2011 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb variant 1 variant 2 variant 3 C rp!=up rp=up C z900 ? ? ? ? C z990 2.5 1 2.75 2.75 C z9 ? ? ? C z10 ? ? ? C z196 ? ? ? C INPUT PARAMETERS define(`rp', `%r2') define(`up', `%r3') define(`vp', `%r4') define(`nn', `%r5') ifdef(`OPERATION_and_n',` define(`func',`mpn_and_n') define(`VARIANT_1') define(`LOGOPC',`nc') define(`LOGOP',`n')') ifdef(`OPERATION_andn_n',` define(`func',`mpn_andn_n') define(`VARIANT_2') define(`LOGOP',`n')') ifdef(`OPERATION_nand_n',` define(`func',`mpn_nand_n') define(`VARIANT_3') define(`LOGOP',`n')') ifdef(`OPERATION_ior_n',` define(`func',`mpn_ior_n') define(`VARIANT_1') define(`LOGOPC',`oc') define(`LOGOP',`o')') ifdef(`OPERATION_iorn_n',` define(`func',`mpn_iorn_n') define(`VARIANT_2') define(`LOGOP',`o')') ifdef(`OPERATION_nior_n',` define(`func',`mpn_nior_n') define(`VARIANT_3') define(`LOGOP',`o')') ifdef(`OPERATION_xor_n',` define(`func',`mpn_xor_n') define(`VARIANT_1') define(`LOGOPC',`xc') define(`LOGOP',`x')') ifdef(`OPERATION_xnor_n',` define(`func',`mpn_xnor_n') define(`VARIANT_2') define(`LOGOP',`x')') MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n) ASM_START() PROLOGUE(func) ifdef(`VARIANT_1',` cr rp, up jne L(normal) sll nn, 2 ahi nn, -1 lr %r1, nn srl %r1, 8 ltr %r1, %r1 C < 256 bytes to copy? je L(1) L(tp): LOGOPC 0(256, rp), 0(vp) la rp, 256(rp) la vp, 256(vp) brct %r1, L(tp) L(1): bras %r1, L(2) C make r1 point to mvc insn LOGOPC 0(1, rp), 0(vp) L(2): ex nn, 0(%r1) C execute mvc with length ((nn-1) mod 256)+1 L(rtn): br %r14 L(normal): stm %r6, %r8, 12(%r15) ahi nn, 3 lhi %r7, 3 lr %r0, nn srl %r0, 2 nr %r7, nn C nn mod 4 je L(b1) chi %r7, 2 jl L(b2) jne L(top) L(b3): lm %r5, %r7, 0(up) la up, 12(up) LOGOP %r5, 0(vp) LOGOP %r6, 4(vp) LOGOP %r7, 8(vp) stm %r5, %r7, 0(rp) la rp, 12(rp) la vp, 12(vp) j L(mid) L(b1): l %r5, 0(up) la up, 4(up) LOGOP %r5, 0(vp) st %r5, 0(rp) la rp, 4(rp) la vp, 4(vp) j L(mid) L(b2): lm %r5, %r6, 0(up) la up, 8(up) LOGOP %r5, 0(vp) LOGOP %r6, 4(vp) stm %r5, %r6, 0(rp) la rp, 8(rp) la vp, 8(vp) j L(mid) L(top): lm %r5, %r8, 0(up) la up, 16(up) LOGOP %r5, 0(vp) LOGOP %r6, 4(vp) LOGOP %r7, 8(vp) LOGOP %r8, 12(vp) stm %r5, %r8, 0(rp) la rp, 16(rp) la vp, 16(vp) L(mid): brct %r0, L(top) lm %r6, %r8, 12(%r15) br %r14 ') ifdef(`VARIANT_2',` stm %r6, %r8, 12(%r15) lhi %r1, -1 ahi nn, 3 lhi %r7, 3 lr %r0, nn srl %r0, 2 nr %r7, nn C nn mod 4 je L(b1) chi %r7, 2 jl L(b2) jne L(top) L(b3): lm %r5, %r7, 0(vp) la vp, 12(vp) xr %r5, %r1 xr %r6, %r1 xr %r7, %r1 LOGOP %r5, 0(up) LOGOP %r6, 4(up) LOGOP %r7, 8(up) stm %r5, %r7, 0(rp) la rp, 12(rp) la up, 12(up) j L(mid) L(b1): l %r5, 0(vp) la vp, 4(vp) xr %r5, %r1 LOGOP %r5, 0(up) st %r5, 0(rp) la rp, 4(rp) la up, 4(up) j L(mid) L(b2): lm %r5, %r6, 0(vp) la vp, 8(vp) xr %r5, %r1 xr %r6, %r1 LOGOP %r5, 0(up) LOGOP %r6, 4(up) stm %r5, %r6, 0(rp) la rp, 8(rp) la up, 8(up) j L(mid) L(top): lm %r5, %r8, 0(vp) la vp, 16(vp) xr %r5, %r1 xr %r6, %r1 xr %r7, %r1 xr %r8, %r1 LOGOP %r5, 0(up) LOGOP %r6, 4(up) LOGOP %r7, 8(up) LOGOP %r8, 12(up) la up, 16(up) stm %r5, %r8, 0(rp) la rp, 16(rp) L(mid): brct %r0, L(top) lm %r6, %r8, 12(%r15) br %r14 ') ifdef(`VARIANT_3',` stm %r6, %r8, 12(%r15) lhi %r1, -1 ahi nn, 3 lhi %r7, 3 lr %r0, nn srl %r0, 2 nr %r7, nn C nn mod 4 je L(b1) chi %r7, 2 jl L(b2) jne L(top) L(b3): lm %r5, %r7, 0(vp) la vp, 12(vp) LOGOP %r5, 0(up) LOGOP %r6, 4(up) xr %r5, %r1 xr %r6, %r1 LOGOP %r7, 8(up) xr %r7, %r1 stm %r5, %r7, 0(rp) la rp, 12(rp) la up, 12(up) j L(mid) L(b1): l %r5, 0(vp) la vp, 4(vp) LOGOP %r5, 0(up) xr %r5, %r1 st %r5, 0(rp) la rp, 4(rp) la up, 4(up) j L(mid) L(b2): lm %r5, %r6, 0(vp) la vp, 8(vp) LOGOP %r5, 0(up) LOGOP %r6, 4(up) xr %r5, %r1 xr %r6, %r1 stm %r5, %r6, 0(rp) la rp, 8(rp) la up, 8(up) j L(mid) L(top): lm %r5, %r8, 0(vp) la vp, 16(vp) LOGOP %r5, 0(up) LOGOP %r6, 4(up) xr %r5, %r1 xr %r6, %r1 LOGOP %r7, 8(up) LOGOP %r8, 12(up) xr %r7, %r1 xr %r8, %r1 stm %r5, %r8, 0(rp) la up, 16(up) la rp, 16(rp) L(mid): brct %r0, L(top) lm %r6, %r8, 12(%r15) br %r14 ') EPILOGUE()
LCClubT label byte word C_BLACK Bitmap <71,100,BMC_PACKBITS,BMF_MONO> db 0xf8, 0x00 db 0xf8, 0x00 db 0xf8, 0x00 db 0xf8, 0x00 db 0x01, 0x18, 0x78, 0xfa, 0x00 db 0x01, 0x18, 0xfc, 0xfa, 0x00 db 0x01, 0x19, 0xce, 0xfa, 0x00 db 0x01, 0x19, 0x86, 0xfa, 0x00 db 0x01, 0x19, 0x86, 0xfa, 0x00 db 0x01, 0x19, 0x86, 0xfa, 0x00 db 0x01, 0x19, 0x86, 0xfa, 0x00 db 0x05, 0x19, 0x86, 0x01, 0xc0, 0x00, 0x07, 0xfe, 0x00 db 0x08, 0x19, 0x86, 0x02, 0xe0, 0x00, 0x0b, 0x80, 0x00, 0x00 db 0x08, 0x19, 0x86, 0x05, 0xf0, 0x00, 0x17, 0xc0, 0x00, 0x00 db 0x08, 0x19, 0x86, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x19, 0x86, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x19, 0xce, 0x03, 0xe0, 0x00, 0x0f, 0x80, 0x00, 0x00 db 0x08, 0x18, 0xfc, 0x1d, 0xdc, 0x00, 0x77, 0x70, 0x00, 0x00 db 0x08, 0x18, 0x78, 0x2e, 0xae, 0x00, 0xba, 0xb8, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x5f, 0xdf, 0x01, 0x7f, 0x7c, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x01, 0xc0, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x02, 0xe0, 0x3e, 0xbe, 0x00, 0xfa, 0xf8, 0x00, 0x00 db 0x08, 0x03, 0xe0, 0x1c, 0x9c, 0x38, 0x72, 0x70, 0x00, 0x00 db 0x05, 0x03, 0xe0, 0x01, 0xc0, 0x5c, 0x07, 0xfe, 0x00 db 0x08, 0x0d, 0xd8, 0x03, 0xe0, 0xbe, 0x0f, 0x80, 0x00, 0x00 db 0x04, 0x17, 0xec, 0x00, 0x00, 0xfe, 0xfd, 0x00 db 0x04, 0x1f, 0xfc, 0x00, 0x00, 0xfe, 0xfd, 0x00 db 0x04, 0x1f, 0xfc, 0x00, 0x00, 0x7c, 0xfd, 0x00 db 0x05, 0x0e, 0xb8, 0x00, 0x03, 0xbb, 0x80, 0xfe, 0x00 db 0x05, 0x01, 0xc0, 0x00, 0x05, 0xd5, 0xc0, 0xfe, 0x00 db 0x05, 0x03, 0xe0, 0x00, 0x0b, 0xfb, 0xe0, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x0f, 0xff, 0xe0, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x0f, 0xff, 0xe0, 0xfe, 0x00 db 0x05, 0x00, 0x00, 0x01, 0xc7, 0xd7, 0xc7, 0xfe, 0x00 db 0x08, 0x00, 0x00, 0x02, 0xe3, 0x93, 0x8b, 0x80, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x05, 0xf0, 0x38, 0x17, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x7c, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x0f, 0x80, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x1d, 0xdc, 0x00, 0x77, 0x70, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x2e, 0xae, 0x00, 0xba, 0xb8, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x5f, 0xdf, 0x01, 0x7f, 0x7c, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x3e, 0xbe, 0x00, 0xfa, 0xf8, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x1c, 0x9c, 0x00, 0x72, 0x70, 0x00, 0x00 db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe, 0x00 db 0x08, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x0f, 0x80, 0x00, 0x00 db 0xf8, 0x00 db 0xf8, 0x00 db 0x08, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x0f, 0x80, 0x00, 0x00 db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe, 0x00 db 0x08, 0x00, 0x00, 0x1c, 0x9c, 0x00, 0x72, 0x70, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x2e, 0xae, 0x00, 0xba, 0xb8, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x5f, 0xdf, 0x01, 0x7f, 0x7c, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x3e, 0xbe, 0x00, 0xfa, 0xf8, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x1d, 0xdc, 0x00, 0x77, 0x70, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x02, 0xe0, 0x00, 0x0b, 0x80, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x05, 0xf0, 0x00, 0x17, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x7c, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x38, 0x1f, 0xc0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x03, 0xe3, 0x93, 0x8f, 0x80, 0x00, 0x00 db 0x05, 0x00, 0x00, 0x01, 0xc5, 0xd5, 0xc7, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x0b, 0xfb, 0xe0, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x0f, 0xff, 0xe0, 0xfe, 0x00 db 0xfe, 0x00, 0x05, 0x0f, 0xff, 0xe0, 0x00, 0x0f, 0x80 db 0xfe, 0x00, 0x05, 0x07, 0xd7, 0xc0, 0x00, 0x07, 0x00 db 0xfe, 0x00, 0x05, 0x03, 0xbb, 0x80, 0x00, 0x3a, 0xe0 db 0xfd, 0x00, 0x04, 0x5c, 0x00, 0x00, 0x5f, 0x70 db 0xfd, 0x00, 0x04, 0xbe, 0x00, 0x00, 0x7f, 0xf0 db 0xfd, 0x00, 0x04, 0xfe, 0x00, 0x00, 0x7f, 0xf0 db 0x08, 0x00, 0x00, 0x03, 0xe0, 0xfe, 0x0f, 0x80, 0x37, 0x60 db 0x08, 0x00, 0x00, 0x01, 0xc0, 0x7c, 0x07, 0x00, 0x0b, 0x80 db 0x08, 0x00, 0x00, 0x1c, 0x9c, 0x38, 0x72, 0x70, 0x0f, 0x80 db 0x08, 0x00, 0x00, 0x2e, 0xae, 0x00, 0xba, 0xb8, 0x0f, 0x80 db 0x08, 0x00, 0x00, 0x5f, 0xdf, 0x01, 0x7f, 0x7c, 0x07, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xff, 0xfc, 0x00, 0x00 db 0x08, 0x00, 0x00, 0x3e, 0xbe, 0x00, 0xfa, 0xf8, 0x3c, 0x30 db 0x08, 0x00, 0x00, 0x1d, 0xdc, 0x00, 0x77, 0x70, 0x7e, 0x30 db 0x08, 0x00, 0x00, 0x02, 0xe0, 0x00, 0x0b, 0x80, 0xe7, 0x30 db 0x08, 0x00, 0x00, 0x05, 0xf0, 0x00, 0x17, 0xc0, 0xc3, 0x30 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0xc3, 0x30 db 0x08, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x1f, 0xc0, 0xc3, 0x30 db 0x08, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x0f, 0x80, 0xc3, 0x30 db 0x08, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0x00, 0xc3, 0x30 db 0xfa, 0x00, 0x01, 0xc3, 0x30 db 0xfa, 0x00, 0x01, 0xc3, 0x30 db 0xfa, 0x00, 0x01, 0xc3, 0x30 db 0xfa, 0x00, 0x01, 0xc3, 0x30 db 0xfa, 0x00, 0x01, 0xe7, 0x30 db 0xfa, 0x00, 0x01, 0x7e, 0x30 db 0xfa, 0x00, 0x01, 0x3c, 0x30 db 0xf8, 0x00 db 0xf8, 0x00 db 0xf8, 0x00 db 0x00, 0x1f, 0xfa, 0xff, 0x00, 0xf0
.file "example.cpp" .intel_syntax noprefix .text .Ltext0: .globl _Z3foov .type _Z3foov, @function _Z3foov: .LFB17: .file 1 "/tmp/compiler-explorer-compiler119330-63-1ccesdf.nzyy/example.cpp" .loc 1 3 11 .cfi_startproc .loc 1 3 13 .loc 1 3 24 is_stmt 0 mov eax, 42 ret .cfi_endproc .LFE17: .size _Z3foov, .-_Z3foov .globl _Z3barv .type _Z3barv, @function _Z3barv: .LFB18: .loc 1 4 11 is_stmt 1 .cfi_startproc .loc 1 4 13 .LVL0: .LBB6: .LBB7: .file 2 "/opt/compiler-explorer/gcc-8.3.0/include/c++/8.3.0/typeinfo" .loc 2 100 7 .loc 2 100 14 is_stmt 0 mov rax, QWORD PTR _ZTIi[rip+8] .loc 2 100 31 cmp BYTE PTR [rax], 42 sete dl movzx edx, dl .LVL1: .LBE7: .LBE6: .loc 1 4 40 movsx eax, BYTE PTR [rax+rdx] .loc 1 4 43 ret .cfi_endproc .LFE18: .size _Z3barv, .-_Z3barv .globl _Z3bazv .type _Z3bazv, @function _Z3bazv: .LFB19: .loc 1 6 11 is_stmt 1 .cfi_startproc .loc 1 6 13 .LVL2: .loc 2 100 7 .loc 1 6 45 is_stmt 0 mov eax, 53 ret .cfi_endproc .LFE19: .size _Z3bazv, .-_Z3bazv .Letext0: .file 3 "/opt/compiler-explorer/gcc-8.3.0/include/c++/8.3.0/x86_64-linux-gnu/bits/c++config.h" .file 4 "<built-in>" .section .debug_info,"",@progbits .Ldebug_info0: .long 0x153 .value 0x4 .long .Ldebug_abbrev0 .byte 0x8 .uleb128 0x1 .long .LASF4 .byte 0x4 .long .LASF5 .long .LASF6 .quad .Ltext0 .quad .Letext0-.Ltext0 .long .Ldebug_line0 .uleb128 0x2 .string "std" .byte 0x4 .byte 0 .long 0x75 .uleb128 0x3 .long .LASF0 .byte 0x3 .value 0x104 .byte 0x41 .uleb128 0x4 .byte 0x3 .value 0x104 .byte 0x41 .long 0x38 .uleb128 0x5 .long .LASF7 .long 0x6f .uleb128 0x6 .long .LASF8 .byte 0x2 .byte 0x63 .byte 0x11 .long .LASF9 .long 0x125 .byte 0x1 .long 0x68 .uleb128 0x7 .long 0x137 .byte 0 .byte 0 .uleb128 0x8 .long 0x4a .byte 0 .uleb128 0x9 .long .LASF10 .byte 0x3 .value 0x106 .byte 0xb .long 0x95 .uleb128 0x3 .long .LASF0 .byte 0x3 .value 0x108 .byte 0x41 .uleb128 0x4 .byte 0x3 .value 0x108 .byte 0x41 .long 0x82 .byte 0 .uleb128 0xa .string "baz" .byte 0x1 .byte 0x6 .byte 0x5 .long .LASF1 .long 0xb7 .quad .LFB19 .quad .LFE19-.LFB19 .uleb128 0x1 .byte 0x9c .uleb128 0xb .byte 0x4 .byte 0x5 .string "int" .uleb128 0xc .string "bar" .byte 0x1 .byte 0x4 .byte 0x5 .long .LASF11 .long 0xb7 .quad .LFB18 .quad .LFE18-.LFB18 .uleb128 0x1 .byte 0x9c .long 0x103 .uleb128 0xd .long 0x142 .quad .LBB6 .quad .LBE6-.LBB6 .byte 0x1 .byte 0x4 .byte 0x24 .uleb128 0xe .long 0x14c .byte 0 .byte 0 .uleb128 0xa .string "foo" .byte 0x1 .byte 0x3 .byte 0x5 .long .LASF2 .long 0xb7 .quad .LFB17 .quad .LFE17-.LFB17 .uleb128 0x1 .byte 0x9c .uleb128 0xf .byte 0x8 .long 0x132 .uleb128 0x10 .byte 0x1 .byte 0x6 .long .LASF3 .uleb128 0x8 .long 0x12b .uleb128 0xf .byte 0x8 .long 0x6f .uleb128 0x8 .long 0x137 .uleb128 0x11 .long 0x53 .long 0x14c .byte 0x3 .uleb128 0x12 .long .LASF12 .long 0x13d .byte 0 .byte 0 .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .uleb128 0x1 .uleb128 0x11 .byte 0x1 .uleb128 0x25 .uleb128 0xe .uleb128 0x13 .uleb128 0xb .uleb128 0x3 .uleb128 0xe .uleb128 0x1b .uleb128 0xe .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x7 .uleb128 0x10 .uleb128 0x17 .byte 0 .byte 0 .uleb128 0x2 .uleb128 0x39 .byte 0x1 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x3 .uleb128 0x39 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0x5 .uleb128 0x39 .uleb128 0xb .uleb128 0x89 .uleb128 0x19 .byte 0 .byte 0 .uleb128 0x4 .uleb128 0x3a .byte 0 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0x5 .uleb128 0x39 .uleb128 0xb .uleb128 0x18 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x5 .uleb128 0x2 .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0x3c .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x6 .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x39 .uleb128 0xb .uleb128 0x6e .uleb128 0xe .uleb128 0x49 .uleb128 0x13 .uleb128 0x32 .uleb128 0xb .uleb128 0x3c .uleb128 0x19 .uleb128 0x64 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x7 .uleb128 0x5 .byte 0 .uleb128 0x49 .uleb128 0x13 .uleb128 0x34 .uleb128 0x19 .byte 0 .byte 0 .uleb128 0x8 .uleb128 0x26 .byte 0 .uleb128 0x49 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x9 .uleb128 0x39 .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0x5 .uleb128 0x39 .uleb128 0xb .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0xa .uleb128 0x2e .byte 0 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x39 .uleb128 0xb .uleb128 0x6e .uleb128 0xe .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x7 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .byte 0 .byte 0 .uleb128 0xb .uleb128 0x24 .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0x8 .byte 0 .byte 0 .uleb128 0xc .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x39 .uleb128 0xb .uleb128 0x6e .uleb128 0xe .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x7 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0xd .uleb128 0x1d .byte 0x1 .uleb128 0x31 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x7 .uleb128 0x58 .uleb128 0xb .uleb128 0x59 .uleb128 0xb .uleb128 0x57 .uleb128 0xb .byte 0 .byte 0 .uleb128 0xe .uleb128 0x5 .byte 0 .uleb128 0x31 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0xf .uleb128 0xf .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x10 .uleb128 0x24 .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0xe .byte 0 .byte 0 .uleb128 0x11 .uleb128 0x2e .byte 0x1 .uleb128 0x47 .uleb128 0x13 .uleb128 0x64 .uleb128 0x13 .uleb128 0x20 .uleb128 0xb .byte 0 .byte 0 .uleb128 0x12 .uleb128 0x5 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x49 .uleb128 0x13 .uleb128 0x34 .uleb128 0x19 .byte 0 .byte 0 .byte 0 .section .debug_aranges,"",@progbits .long 0x2c .value 0x2 .long .Ldebug_info0 .byte 0x8 .byte 0 .value 0 .value 0 .quad .Ltext0 .quad .Letext0-.Ltext0 .quad 0 .quad 0 .section .debug_line,"",@progbits .Ldebug_line0: .section .debug_str,"MS",@progbits,1 .LASF1: .string "_Z3bazv" .LASF2: .string "_Z3foov" .LASF7: .string "type_info" .LASF10: .string "__gnu_cxx" .LASF3: .string "char" .LASF5: .string "/tmp/compiler-explorer-compiler119330-63-1ccesdf.nzyy/example.cpp" .LASF11: .string "_Z3barv" .LASF9: .string "_ZNKSt9type_info4nameEv" .LASF12: .string "this" .LASF0: .string "__cxx11" .LASF4: .string "GNU C++14 8.3.0 -masm=intel -mtune=generic -march=x86-64 -g -O1" .LASF8: .string "name" .LASF6: .string "/tmp/compiler-explorer-compiler119330-63-1ccesdf.nzyy" .ident "GCC: (Compiler-Explorer-Build) 8.3.0" .section .note.GNU-stack,"",@progbits
; A292046: The list of distinct values of A072464. ; 1,3,6,7,11,12,13,14,16,17,18,19,20,21,22,23,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264 mov $2,$0 mov $3,$0 lpb $3 mul $3,2 add $3,1 log $3,2 add $1,$3 sub $3,1 lpe add $1,1 add $1,$2
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 0f in $0xf,%al 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 90 10 00 mov $0x109000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc d0 b5 10 80 mov $0x8010b5d0,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 00 2f 10 80 mov $0x80102f00,%eax jmp *%eax 80100032: ff e0 jmp *%eax ... 80100040 <brelse>: // Release a locked buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 80100040: 55 push %ebp 80100041: 89 e5 mov %esp,%ebp 80100043: 56 push %esi 80100044: 53 push %ebx 80100045: 83 ec 10 sub $0x10,%esp 80100048: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 8010004b: 8d 73 0c lea 0xc(%ebx),%esi 8010004e: 89 34 24 mov %esi,(%esp) 80100051: e8 da 44 00 00 call 80104530 <holdingsleep> 80100056: 85 c0 test %eax,%eax 80100058: 74 62 je 801000bc <brelse+0x7c> panic("brelse"); releasesleep(&b->lock); 8010005a: 89 34 24 mov %esi,(%esp) 8010005d: e8 fe 44 00 00 call 80104560 <releasesleep> acquire(&bcache.lock); 80100062: c7 04 24 e0 b5 10 80 movl $0x8010b5e0,(%esp) 80100069: e8 62 47 00 00 call 801047d0 <acquire> b->refcnt--; 8010006e: 8b 43 4c mov 0x4c(%ebx),%eax 80100071: 83 e8 01 sub $0x1,%eax if (b->refcnt == 0) { 80100074: 85 c0 test %eax,%eax panic("brelse"); releasesleep(&b->lock); acquire(&bcache.lock); b->refcnt--; 80100076: 89 43 4c mov %eax,0x4c(%ebx) if (b->refcnt == 0) { 80100079: 75 2f jne 801000aa <brelse+0x6a> // no one is waiting for it. b->next->prev = b->prev; 8010007b: 8b 43 54 mov 0x54(%ebx),%eax 8010007e: 8b 53 50 mov 0x50(%ebx),%edx 80100081: 89 50 50 mov %edx,0x50(%eax) b->prev->next = b->next; 80100084: 8b 43 50 mov 0x50(%ebx),%eax 80100087: 8b 53 54 mov 0x54(%ebx),%edx 8010008a: 89 50 54 mov %edx,0x54(%eax) b->next = bcache.head.next; 8010008d: a1 30 fd 10 80 mov 0x8010fd30,%eax b->prev = &bcache.head; 80100092: c7 43 50 dc fc 10 80 movl $0x8010fcdc,0x50(%ebx) b->refcnt--; if (b->refcnt == 0) { // no one is waiting for it. b->next->prev = b->prev; b->prev->next = b->next; b->next = bcache.head.next; 80100099: 89 43 54 mov %eax,0x54(%ebx) b->prev = &bcache.head; bcache.head.next->prev = b; 8010009c: a1 30 fd 10 80 mov 0x8010fd30,%eax 801000a1: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 801000a4: 89 1d 30 fd 10 80 mov %ebx,0x8010fd30 } release(&bcache.lock); 801000aa: c7 45 08 e0 b5 10 80 movl $0x8010b5e0,0x8(%ebp) } 801000b1: 83 c4 10 add $0x10,%esp 801000b4: 5b pop %ebx 801000b5: 5e pop %esi 801000b6: 5d pop %ebp b->prev = &bcache.head; bcache.head.next->prev = b; bcache.head.next = b; } release(&bcache.lock); 801000b7: e9 c4 46 00 00 jmp 80104780 <release> // Move to the head of the MRU list. void brelse(struct buf *b) { if(!holdingsleep(&b->lock)) panic("brelse"); 801000bc: c7 04 24 00 73 10 80 movl $0x80107300,(%esp) 801000c3: e8 08 03 00 00 call 801003d0 <panic> 801000c8: 90 nop 801000c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801000d0 <bwrite>: } // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { 801000d0: 55 push %ebp 801000d1: 89 e5 mov %esp,%ebp 801000d3: 53 push %ebx 801000d4: 83 ec 14 sub $0x14,%esp 801000d7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801000da: 8d 43 0c lea 0xc(%ebx),%eax 801000dd: 89 04 24 mov %eax,(%esp) 801000e0: e8 4b 44 00 00 call 80104530 <holdingsleep> 801000e5: 85 c0 test %eax,%eax 801000e7: 74 10 je 801000f9 <bwrite+0x29> panic("bwrite"); b->flags |= B_DIRTY; 801000e9: 83 0b 04 orl $0x4,(%ebx) iderw(b); 801000ec: 89 5d 08 mov %ebx,0x8(%ebp) } 801000ef: 83 c4 14 add $0x14,%esp 801000f2: 5b pop %ebx 801000f3: 5d pop %ebp bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); b->flags |= B_DIRTY; iderw(b); 801000f4: e9 57 1f 00 00 jmp 80102050 <iderw> // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { if(!holdingsleep(&b->lock)) panic("bwrite"); 801000f9: c7 04 24 07 73 10 80 movl $0x80107307,(%esp) 80100100: e8 cb 02 00 00 call 801003d0 <panic> 80100105: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100110 <bread>: } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 80100110: 55 push %ebp 80100111: 89 e5 mov %esp,%ebp 80100113: 57 push %edi 80100114: 56 push %esi 80100115: 53 push %ebx 80100116: 83 ec 1c sub $0x1c,%esp 80100119: 8b 75 08 mov 0x8(%ebp),%esi 8010011c: 8b 7d 0c mov 0xc(%ebp),%edi static struct buf* bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); 8010011f: c7 04 24 e0 b5 10 80 movl $0x8010b5e0,(%esp) 80100126: e8 a5 46 00 00 call 801047d0 <acquire> // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ 8010012b: 8b 1d 30 fd 10 80 mov 0x8010fd30,%ebx 80100131: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100137: 75 12 jne 8010014b <bread+0x3b> 80100139: eb 25 jmp 80100160 <bread+0x50> 8010013b: 90 nop 8010013c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100140: 8b 5b 54 mov 0x54(%ebx),%ebx 80100143: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100149: 74 15 je 80100160 <bread+0x50> if(b->dev == dev && b->blockno == blockno){ 8010014b: 3b 73 04 cmp 0x4(%ebx),%esi 8010014e: 75 f0 jne 80100140 <bread+0x30> 80100150: 3b 7b 08 cmp 0x8(%ebx),%edi 80100153: 75 eb jne 80100140 <bread+0x30> b->refcnt++; 80100155: 83 43 4c 01 addl $0x1,0x4c(%ebx) 80100159: eb 3f jmp 8010019a <bread+0x8a> 8010015b: 90 nop 8010015c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } // Not cached; recycle some unused buffer and clean buffer // "clean" because B_DIRTY and not locked means log.c // hasn't yet committed the changes to the buffer. for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100160: 8b 1d 2c fd 10 80 mov 0x8010fd2c,%ebx 80100166: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 8010016c: 75 0d jne 8010017b <bread+0x6b> 8010016e: eb 58 jmp 801001c8 <bread+0xb8> 80100170: 8b 5b 50 mov 0x50(%ebx),%ebx 80100173: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100179: 74 4d je 801001c8 <bread+0xb8> if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { 8010017b: 8b 43 4c mov 0x4c(%ebx),%eax 8010017e: 85 c0 test %eax,%eax 80100180: 75 ee jne 80100170 <bread+0x60> 80100182: f6 03 04 testb $0x4,(%ebx) 80100185: 75 e9 jne 80100170 <bread+0x60> b->dev = dev; 80100187: 89 73 04 mov %esi,0x4(%ebx) b->blockno = blockno; 8010018a: 89 7b 08 mov %edi,0x8(%ebx) b->flags = 0; 8010018d: c7 03 00 00 00 00 movl $0x0,(%ebx) b->refcnt = 1; 80100193: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) release(&bcache.lock); 8010019a: c7 04 24 e0 b5 10 80 movl $0x8010b5e0,(%esp) 801001a1: e8 da 45 00 00 call 80104780 <release> acquiresleep(&b->lock); 801001a6: 8d 43 0c lea 0xc(%ebx),%eax 801001a9: 89 04 24 mov %eax,(%esp) 801001ac: e8 ef 43 00 00 call 801045a0 <acquiresleep> bread(uint dev, uint blockno) { struct buf *b; b = bget(dev, blockno); if(!(b->flags & B_VALID)) { 801001b1: f6 03 02 testb $0x2,(%ebx) 801001b4: 75 08 jne 801001be <bread+0xae> iderw(b); 801001b6: 89 1c 24 mov %ebx,(%esp) 801001b9: e8 92 1e 00 00 call 80102050 <iderw> } return b; } 801001be: 83 c4 1c add $0x1c,%esp 801001c1: 89 d8 mov %ebx,%eax 801001c3: 5b pop %ebx 801001c4: 5e pop %esi 801001c5: 5f pop %edi 801001c6: 5d pop %ebp 801001c7: c3 ret release(&bcache.lock); acquiresleep(&b->lock); return b; } } panic("bget: no buffers"); 801001c8: c7 04 24 0e 73 10 80 movl $0x8010730e,(%esp) 801001cf: e8 fc 01 00 00 call 801003d0 <panic> 801001d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801001da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801001e0 <binit>: struct buf head; } bcache; void binit(void) { 801001e0: 55 push %ebp 801001e1: 89 e5 mov %esp,%ebp 801001e3: 53 push %ebx // head.next is most recently used. struct buf head; } bcache; void binit(void) 801001e4: bb 14 b6 10 80 mov $0x8010b614,%ebx { 801001e9: 83 ec 14 sub $0x14,%esp struct buf *b; initlock(&bcache.lock, "bcache"); 801001ec: c7 44 24 04 1f 73 10 movl $0x8010731f,0x4(%esp) 801001f3: 80 801001f4: c7 04 24 e0 b5 10 80 movl $0x8010b5e0,(%esp) 801001fb: e8 40 44 00 00 call 80104640 <initlock> // head.next is most recently used. struct buf head; } bcache; void binit(void) 80100200: b8 dc fc 10 80 mov $0x8010fcdc,%eax initlock(&bcache.lock, "bcache"); //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; 80100205: c7 05 2c fd 10 80 dc movl $0x8010fcdc,0x8010fd2c 8010020c: fc 10 80 bcache.head.next = &bcache.head; 8010020f: c7 05 30 fd 10 80 dc movl $0x8010fcdc,0x8010fd30 80100216: fc 10 80 80100219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(b = bcache.buf; b < bcache.buf+NBUF; b++){ b->next = bcache.head.next; 80100220: 89 43 54 mov %eax,0x54(%ebx) b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); 80100223: 8d 43 0c lea 0xc(%ebx),%eax // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ b->next = bcache.head.next; b->prev = &bcache.head; 80100226: c7 43 50 dc fc 10 80 movl $0x8010fcdc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 8010022d: 89 04 24 mov %eax,(%esp) 80100230: c7 44 24 04 26 73 10 movl $0x80107326,0x4(%esp) 80100237: 80 80100238: e8 c3 43 00 00 call 80104600 <initsleeplock> bcache.head.next->prev = b; 8010023d: a1 30 fd 10 80 mov 0x8010fd30,%eax 80100242: 89 58 50 mov %ebx,0x50(%eax) //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100245: 89 d8 mov %ebx,%eax b->next = bcache.head.next; b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; 80100247: 89 1d 30 fd 10 80 mov %ebx,0x8010fd30 //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 8010024d: 81 c3 5c 02 00 00 add $0x25c,%ebx 80100253: 81 fb dc fc 10 80 cmp $0x8010fcdc,%ebx 80100259: 75 c5 jne 80100220 <binit+0x40> b->prev = &bcache.head; initsleeplock(&b->lock, "buffer"); bcache.head.next->prev = b; bcache.head.next = b; } } 8010025b: 83 c4 14 add $0x14,%esp 8010025e: 5b pop %ebx 8010025f: 5d pop %ebp 80100260: c3 ret ... 80100270 <consoleinit>: return n; } void consoleinit(void) { 80100270: 55 push %ebp 80100271: 89 e5 mov %esp,%ebp 80100273: 83 ec 18 sub $0x18,%esp initlock(&cons.lock, "console"); 80100276: c7 44 24 04 2d 73 10 movl $0x8010732d,0x4(%esp) 8010027d: 80 8010027e: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 80100285: e8 b6 43 00 00 call 80104640 <initlock> devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; picenable(IRQ_KBD); 8010028a: c7 04 24 01 00 00 00 movl $0x1,(%esp) void consoleinit(void) { initlock(&cons.lock, "console"); devsw[CONSOLE].write = consolewrite; 80100291: c7 05 8c 09 11 80 d0 movl $0x801005d0,0x8011098c 80100298: 05 10 80 devsw[CONSOLE].read = consoleread; 8010029b: c7 05 88 09 11 80 d0 movl $0x801002d0,0x80110988 801002a2: 02 10 80 cons.locking = 1; 801002a5: c7 05 74 a5 10 80 01 movl $0x1,0x8010a574 801002ac: 00 00 00 picenable(IRQ_KBD); 801002af: e8 0c 30 00 00 call 801032c0 <picenable> ioapicenable(IRQ_KBD, 0); 801002b4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801002bb: 00 801002bc: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801002c3: e8 88 1f 00 00 call 80102250 <ioapicenable> } 801002c8: c9 leave 801002c9: c3 ret 801002ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801002d0 <consoleread>: } } int consoleread(struct inode *ip, char *dst, int n) { 801002d0: 55 push %ebp 801002d1: 89 e5 mov %esp,%ebp 801002d3: 57 push %edi 801002d4: 56 push %esi 801002d5: 53 push %ebx 801002d6: 83 ec 3c sub $0x3c,%esp 801002d9: 8b 5d 10 mov 0x10(%ebp),%ebx 801002dc: 8b 7d 08 mov 0x8(%ebp),%edi 801002df: 8b 75 0c mov 0xc(%ebp),%esi uint target; int c; iunlock(ip); 801002e2: 89 3c 24 mov %edi,(%esp) 801002e5: e8 06 19 00 00 call 80101bf0 <iunlock> target = n; 801002ea: 89 5d e4 mov %ebx,-0x1c(%ebp) acquire(&cons.lock); 801002ed: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 801002f4: e8 d7 44 00 00 call 801047d0 <acquire> while(n > 0){ 801002f9: 85 db test %ebx,%ebx 801002fb: 7f 2c jg 80100329 <consoleread+0x59> 801002fd: e9 c0 00 00 00 jmp 801003c2 <consoleread+0xf2> 80100302: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while(input.r == input.w){ if(proc->killed){ 80100308: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010030e: 8b 40 24 mov 0x24(%eax),%eax 80100311: 85 c0 test %eax,%eax 80100313: 75 5b jne 80100370 <consoleread+0xa0> release(&cons.lock); ilock(ip); return -1; } sleep(&input.r, &cons.lock); 80100315: c7 44 24 04 40 a5 10 movl $0x8010a540,0x4(%esp) 8010031c: 80 8010031d: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100324: e8 57 37 00 00 call 80103a80 <sleep> iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ 80100329: a1 c0 ff 10 80 mov 0x8010ffc0,%eax 8010032e: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 80100334: 74 d2 je 80100308 <consoleread+0x38> ilock(ip); return -1; } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; 80100336: 89 c2 mov %eax,%edx 80100338: 83 e2 7f and $0x7f,%edx 8010033b: 0f b6 8a 40 ff 10 80 movzbl -0x7fef00c0(%edx),%ecx 80100342: 0f be d1 movsbl %cl,%edx 80100345: 89 55 d4 mov %edx,-0x2c(%ebp) 80100348: 8d 50 01 lea 0x1(%eax),%edx if(c == C('D')){ // EOF 8010034b: 83 7d d4 04 cmpl $0x4,-0x2c(%ebp) ilock(ip); return -1; } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; 8010034f: 89 15 c0 ff 10 80 mov %edx,0x8010ffc0 if(c == C('D')){ // EOF 80100355: 74 3a je 80100391 <consoleread+0xc1> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 80100357: 88 0e mov %cl,(%esi) --n; 80100359: 83 eb 01 sub $0x1,%ebx if(c == '\n') 8010035c: 83 7d d4 0a cmpl $0xa,-0x2c(%ebp) 80100360: 74 39 je 8010039b <consoleread+0xcb> int c; iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ 80100362: 85 db test %ebx,%ebx 80100364: 7e 35 jle 8010039b <consoleread+0xcb> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 80100366: 83 c6 01 add $0x1,%esi 80100369: eb be jmp 80100329 <consoleread+0x59> 8010036b: 90 nop 8010036c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ if(proc->killed){ release(&cons.lock); 80100370: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 80100377: e8 04 44 00 00 call 80104780 <release> ilock(ip); 8010037c: 89 3c 24 mov %edi,(%esp) 8010037f: e8 dc 18 00 00 call 80101c60 <ilock> } release(&cons.lock); ilock(ip); return target - n; } 80100384: 83 c4 3c add $0x3c,%esp acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ if(proc->killed){ release(&cons.lock); ilock(ip); 80100387: b8 ff ff ff ff mov $0xffffffff,%eax } release(&cons.lock); ilock(ip); return target - n; } 8010038c: 5b pop %ebx 8010038d: 5e pop %esi 8010038e: 5f pop %edi 8010038f: 5d pop %ebp 80100390: c3 ret } sleep(&input.r, &cons.lock); } c = input.buf[input.r++ % INPUT_BUF]; if(c == C('D')){ // EOF if(n < target){ 80100391: 39 5d e4 cmp %ebx,-0x1c(%ebp) 80100394: 76 05 jbe 8010039b <consoleread+0xcb> // Save ^D for next time, to make sure // caller gets a 0-byte result. input.r--; 80100396: a3 c0 ff 10 80 mov %eax,0x8010ffc0 8010039b: 8b 45 e4 mov -0x1c(%ebp),%eax 8010039e: 29 d8 sub %ebx,%eax *dst++ = c; --n; if(c == '\n') break; } release(&cons.lock); 801003a0: 89 45 e0 mov %eax,-0x20(%ebp) 801003a3: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 801003aa: e8 d1 43 00 00 call 80104780 <release> ilock(ip); 801003af: 89 3c 24 mov %edi,(%esp) 801003b2: e8 a9 18 00 00 call 80101c60 <ilock> 801003b7: 8b 45 e0 mov -0x20(%ebp),%eax return target - n; } 801003ba: 83 c4 3c add $0x3c,%esp 801003bd: 5b pop %ebx 801003be: 5e pop %esi 801003bf: 5f pop %edi 801003c0: 5d pop %ebp 801003c1: c3 ret iunlock(ip); target = n; acquire(&cons.lock); while(n > 0){ while(input.r == input.w){ if(proc->killed){ 801003c2: 31 c0 xor %eax,%eax 801003c4: eb da jmp 801003a0 <consoleread+0xd0> 801003c6: 8d 76 00 lea 0x0(%esi),%esi 801003c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801003d0 <panic>: release(&cons.lock); } void panic(char *s) { 801003d0: 55 push %ebp 801003d1: 89 e5 mov %esp,%ebp 801003d3: 56 push %esi 801003d4: 53 push %ebx 801003d5: 83 ec 40 sub $0x40,%esp } static inline void cli(void) { asm volatile("cli"); 801003d8: fa cli int i; uint pcs[10]; cli(); cons.locking = 0; cprintf("cpu with apicid %d: panic: ", cpu->apicid); 801003d9: 65 a1 00 00 00 00 mov %gs:0x0,%eax cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); 801003df: 8d 75 d0 lea -0x30(%ebp),%esi 801003e2: 31 db xor %ebx,%ebx { int i; uint pcs[10]; cli(); cons.locking = 0; 801003e4: c7 05 74 a5 10 80 00 movl $0x0,0x8010a574 801003eb: 00 00 00 cprintf("cpu with apicid %d: panic: ", cpu->apicid); 801003ee: 0f b6 00 movzbl (%eax),%eax 801003f1: c7 04 24 35 73 10 80 movl $0x80107335,(%esp) 801003f8: 89 44 24 04 mov %eax,0x4(%esp) 801003fc: e8 6f 04 00 00 call 80100870 <cprintf> cprintf(s); 80100401: 8b 45 08 mov 0x8(%ebp),%eax 80100404: 89 04 24 mov %eax,(%esp) 80100407: e8 64 04 00 00 call 80100870 <cprintf> cprintf("\n"); 8010040c: c7 04 24 16 78 10 80 movl $0x80107816,(%esp) 80100413: e8 58 04 00 00 call 80100870 <cprintf> getcallerpcs(&s, pcs); 80100418: 8d 45 08 lea 0x8(%ebp),%eax 8010041b: 89 74 24 04 mov %esi,0x4(%esp) 8010041f: 89 04 24 mov %eax,(%esp) 80100422: e8 39 42 00 00 call 80104660 <getcallerpcs> 80100427: 90 nop for(i=0; i<10; i++) cprintf(" %p", pcs[i]); 80100428: 8b 04 9e mov (%esi,%ebx,4),%eax cons.locking = 0; cprintf("cpu with apicid %d: panic: ", cpu->apicid); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); for(i=0; i<10; i++) 8010042b: 83 c3 01 add $0x1,%ebx cprintf(" %p", pcs[i]); 8010042e: c7 04 24 51 73 10 80 movl $0x80107351,(%esp) 80100435: 89 44 24 04 mov %eax,0x4(%esp) 80100439: e8 32 04 00 00 call 80100870 <cprintf> cons.locking = 0; cprintf("cpu with apicid %d: panic: ", cpu->apicid); cprintf(s); cprintf("\n"); getcallerpcs(&s, pcs); for(i=0; i<10; i++) 8010043e: 83 fb 0a cmp $0xa,%ebx 80100441: 75 e5 jne 80100428 <panic+0x58> cprintf(" %p", pcs[i]); panicked = 1; // freeze other CPU 80100443: c7 05 20 a5 10 80 01 movl $0x1,0x8010a520 8010044a: 00 00 00 8010044d: eb fe jmp 8010044d <panic+0x7d> 8010044f: 90 nop 80100450 <consputc>: crt[pos] = ' ' | 0x0700; } void consputc(int c) { 80100450: 55 push %ebp 80100451: 89 e5 mov %esp,%ebp 80100453: 57 push %edi 80100454: 56 push %esi 80100455: 89 c6 mov %eax,%esi 80100457: 53 push %ebx 80100458: 83 ec 1c sub $0x1c,%esp if(panicked){ 8010045b: 83 3d 20 a5 10 80 00 cmpl $0x0,0x8010a520 80100462: 74 03 je 80100467 <consputc+0x17> 80100464: fa cli 80100465: eb fe jmp 80100465 <consputc+0x15> cli(); for(;;) ; } if(c == BACKSPACE){ 80100467: 3d 00 01 00 00 cmp $0x100,%eax 8010046c: 0f 84 ac 00 00 00 je 8010051e <consputc+0xce> uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); 80100472: 89 04 24 mov %eax,(%esp) 80100475: e8 c6 59 00 00 call 80105e40 <uartputc> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010047a: b9 d4 03 00 00 mov $0x3d4,%ecx 8010047f: b8 0e 00 00 00 mov $0xe,%eax 80100484: 89 ca mov %ecx,%edx 80100486: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80100487: bf d5 03 00 00 mov $0x3d5,%edi 8010048c: 89 fa mov %edi,%edx 8010048e: ec in (%dx),%al { int pos; // Cursor position: col + 80*row. outb(CRTPORT, 14); pos = inb(CRTPORT+1) << 8; 8010048f: 0f b6 d8 movzbl %al,%ebx } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100492: 89 ca mov %ecx,%edx 80100494: c1 e3 08 shl $0x8,%ebx 80100497: b8 0f 00 00 00 mov $0xf,%eax 8010049c: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010049d: 89 fa mov %edi,%edx 8010049f: ec in (%dx),%al outb(CRTPORT, 15); pos |= inb(CRTPORT+1); 801004a0: 0f b6 c0 movzbl %al,%eax 801004a3: 09 c3 or %eax,%ebx if(c == '\n') 801004a5: 83 fe 0a cmp $0xa,%esi 801004a8: 0f 84 fb 00 00 00 je 801005a9 <consputc+0x159> pos += 80 - pos%80; else if(c == BACKSPACE){ 801004ae: 81 fe 00 01 00 00 cmp $0x100,%esi 801004b4: 0f 84 e1 00 00 00 je 8010059b <consputc+0x14b> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white 801004ba: 66 81 e6 ff 00 and $0xff,%si 801004bf: 66 81 ce 00 07 or $0x700,%si 801004c4: 66 89 b4 1b 00 80 0b mov %si,-0x7ff48000(%ebx,%ebx,1) 801004cb: 80 801004cc: 83 c3 01 add $0x1,%ebx if(pos < 0 || pos > 25*80) 801004cf: 81 fb d0 07 00 00 cmp $0x7d0,%ebx 801004d5: 0f 87 b4 00 00 00 ja 8010058f <consputc+0x13f> panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. 801004db: 81 fb 7f 07 00 00 cmp $0x77f,%ebx 801004e1: 8d bc 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%edi 801004e8: 7f 5d jg 80100547 <consputc+0xf7> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801004ea: b9 d4 03 00 00 mov $0x3d4,%ecx 801004ef: b8 0e 00 00 00 mov $0xe,%eax 801004f4: 89 ca mov %ecx,%edx 801004f6: ee out %al,(%dx) 801004f7: be d5 03 00 00 mov $0x3d5,%esi 801004fc: 89 d8 mov %ebx,%eax 801004fe: c1 f8 08 sar $0x8,%eax 80100501: 89 f2 mov %esi,%edx 80100503: ee out %al,(%dx) 80100504: b8 0f 00 00 00 mov $0xf,%eax 80100509: 89 ca mov %ecx,%edx 8010050b: ee out %al,(%dx) 8010050c: 89 d8 mov %ebx,%eax 8010050e: 89 f2 mov %esi,%edx 80100510: ee out %al,(%dx) outb(CRTPORT, 14); outb(CRTPORT+1, pos>>8); outb(CRTPORT, 15); outb(CRTPORT+1, pos); crt[pos] = ' ' | 0x0700; 80100511: 66 c7 07 20 07 movw $0x720,(%edi) if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); cgaputc(c); } 80100516: 83 c4 1c add $0x1c,%esp 80100519: 5b pop %ebx 8010051a: 5e pop %esi 8010051b: 5f pop %edi 8010051c: 5d pop %ebp 8010051d: c3 ret for(;;) ; } if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); 8010051e: c7 04 24 08 00 00 00 movl $0x8,(%esp) 80100525: e8 16 59 00 00 call 80105e40 <uartputc> 8010052a: c7 04 24 20 00 00 00 movl $0x20,(%esp) 80100531: e8 0a 59 00 00 call 80105e40 <uartputc> 80100536: c7 04 24 08 00 00 00 movl $0x8,(%esp) 8010053d: e8 fe 58 00 00 call 80105e40 <uartputc> 80100542: e9 33 ff ff ff jmp 8010047a <consputc+0x2a> if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); pos -= 80; 80100547: 83 eb 50 sub $0x50,%ebx if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 8010054a: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) 80100551: 00 pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 80100552: 8d bc 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%edi if(pos < 0 || pos > 25*80) panic("pos under/overflow"); if((pos/80) >= 24){ // Scroll up. memmove(crt, crt+80, sizeof(crt[0])*23*80); 80100559: c7 44 24 04 a0 80 0b movl $0x800b80a0,0x4(%esp) 80100560: 80 80100561: c7 04 24 00 80 0b 80 movl $0x800b8000,(%esp) 80100568: e8 d3 43 00 00 call 80104940 <memmove> pos -= 80; memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 8010056d: b8 80 07 00 00 mov $0x780,%eax 80100572: 29 d8 sub %ebx,%eax 80100574: 01 c0 add %eax,%eax 80100576: 89 44 24 08 mov %eax,0x8(%esp) 8010057a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100581: 00 80100582: 89 3c 24 mov %edi,(%esp) 80100585: e8 e6 42 00 00 call 80104870 <memset> 8010058a: e9 5b ff ff ff jmp 801004ea <consputc+0x9a> if(pos > 0) --pos; } else crt[pos++] = (c&0xff) | 0x0700; // black on white if(pos < 0 || pos > 25*80) panic("pos under/overflow"); 8010058f: c7 04 24 55 73 10 80 movl $0x80107355,(%esp) 80100596: e8 35 fe ff ff call 801003d0 <panic> pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; else if(c == BACKSPACE){ if(pos > 0) --pos; 8010059b: 31 c0 xor %eax,%eax 8010059d: 85 db test %ebx,%ebx 8010059f: 0f 9f c0 setg %al 801005a2: 29 c3 sub %eax,%ebx 801005a4: e9 26 ff ff ff jmp 801004cf <consputc+0x7f> pos = inb(CRTPORT+1) << 8; outb(CRTPORT, 15); pos |= inb(CRTPORT+1); if(c == '\n') pos += 80 - pos%80; 801005a9: 89 da mov %ebx,%edx 801005ab: 89 d8 mov %ebx,%eax 801005ad: b9 50 00 00 00 mov $0x50,%ecx 801005b2: 83 c3 50 add $0x50,%ebx 801005b5: c1 fa 1f sar $0x1f,%edx 801005b8: f7 f9 idiv %ecx 801005ba: 29 d3 sub %edx,%ebx 801005bc: e9 0e ff ff ff jmp 801004cf <consputc+0x7f> 801005c1: eb 0d jmp 801005d0 <consolewrite> 801005c3: 90 nop 801005c4: 90 nop 801005c5: 90 nop 801005c6: 90 nop 801005c7: 90 nop 801005c8: 90 nop 801005c9: 90 nop 801005ca: 90 nop 801005cb: 90 nop 801005cc: 90 nop 801005cd: 90 nop 801005ce: 90 nop 801005cf: 90 nop 801005d0 <consolewrite>: return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 801005d0: 55 push %ebp 801005d1: 89 e5 mov %esp,%ebp 801005d3: 57 push %edi 801005d4: 56 push %esi 801005d5: 53 push %ebx 801005d6: 83 ec 1c sub $0x1c,%esp int i; iunlock(ip); 801005d9: 8b 45 08 mov 0x8(%ebp),%eax return target - n; } int consolewrite(struct inode *ip, char *buf, int n) { 801005dc: 8b 75 10 mov 0x10(%ebp),%esi 801005df: 8b 7d 0c mov 0xc(%ebp),%edi int i; iunlock(ip); 801005e2: 89 04 24 mov %eax,(%esp) 801005e5: e8 06 16 00 00 call 80101bf0 <iunlock> acquire(&cons.lock); 801005ea: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 801005f1: e8 da 41 00 00 call 801047d0 <acquire> for(i = 0; i < n; i++) 801005f6: 85 f6 test %esi,%esi 801005f8: 7e 16 jle 80100610 <consolewrite+0x40> 801005fa: 31 db xor %ebx,%ebx 801005fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi consputc(buf[i] & 0xff); 80100600: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax { int i; iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++) 80100604: 83 c3 01 add $0x1,%ebx consputc(buf[i] & 0xff); 80100607: e8 44 fe ff ff call 80100450 <consputc> { int i; iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++) 8010060c: 39 de cmp %ebx,%esi 8010060e: 7f f0 jg 80100600 <consolewrite+0x30> consputc(buf[i] & 0xff); release(&cons.lock); 80100610: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 80100617: e8 64 41 00 00 call 80104780 <release> ilock(ip); 8010061c: 8b 45 08 mov 0x8(%ebp),%eax 8010061f: 89 04 24 mov %eax,(%esp) 80100622: e8 39 16 00 00 call 80101c60 <ilock> return n; } 80100627: 83 c4 1c add $0x1c,%esp 8010062a: 89 f0 mov %esi,%eax 8010062c: 5b pop %ebx 8010062d: 5e pop %esi 8010062e: 5f pop %edi 8010062f: 5d pop %ebp 80100630: c3 ret 80100631: eb 0d jmp 80100640 <consoleintr> 80100633: 90 nop 80100634: 90 nop 80100635: 90 nop 80100636: 90 nop 80100637: 90 nop 80100638: 90 nop 80100639: 90 nop 8010063a: 90 nop 8010063b: 90 nop 8010063c: 90 nop 8010063d: 90 nop 8010063e: 90 nop 8010063f: 90 nop 80100640 <consoleintr>: #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 80100640: 55 push %ebp 80100641: 89 e5 mov %esp,%ebp 80100643: 57 push %edi int c, doprocdump = 0; acquire(&cons.lock); 80100644: 31 ff xor %edi,%edi #define C(x) ((x)-'@') // Control-x void consoleintr(int (*getc)(void)) { 80100646: 56 push %esi 80100647: 53 push %ebx 80100648: 83 ec 1c sub $0x1c,%esp 8010064b: 8b 75 08 mov 0x8(%ebp),%esi int c, doprocdump = 0; acquire(&cons.lock); 8010064e: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 80100655: e8 76 41 00 00 call 801047d0 <acquire> 8010065a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while((c = getc()) >= 0){ 80100660: ff d6 call *%esi 80100662: 85 c0 test %eax,%eax 80100664: 89 c3 mov %eax,%ebx 80100666: 0f 88 98 00 00 00 js 80100704 <consoleintr+0xc4> switch(c){ 8010066c: 83 fb 10 cmp $0x10,%ebx 8010066f: 90 nop 80100670: 0f 84 32 01 00 00 je 801007a8 <consoleintr+0x168> 80100676: 0f 8f a4 00 00 00 jg 80100720 <consoleintr+0xe0> 8010067c: 83 fb 08 cmp $0x8,%ebx 8010067f: 90 nop 80100680: 0f 84 a8 00 00 00 je 8010072e <consoleintr+0xee> input.e--; consputc(BACKSPACE); } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ 80100686: 85 db test %ebx,%ebx 80100688: 74 d6 je 80100660 <consoleintr+0x20> 8010068a: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 8010068f: 89 c2 mov %eax,%edx 80100691: 2b 15 c0 ff 10 80 sub 0x8010ffc0,%edx 80100697: 83 fa 7f cmp $0x7f,%edx 8010069a: 77 c4 ja 80100660 <consoleintr+0x20> c = (c == '\r') ? '\n' : c; 8010069c: 83 fb 0d cmp $0xd,%ebx 8010069f: 0f 84 0d 01 00 00 je 801007b2 <consoleintr+0x172> input.buf[input.e++ % INPUT_BUF] = c; 801006a5: 89 c2 mov %eax,%edx 801006a7: 83 c0 01 add $0x1,%eax 801006aa: 83 e2 7f and $0x7f,%edx 801006ad: 88 9a 40 ff 10 80 mov %bl,-0x7fef00c0(%edx) 801006b3: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(c); 801006b8: 89 d8 mov %ebx,%eax 801006ba: e8 91 fd ff ff call 80100450 <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 801006bf: 83 fb 04 cmp $0x4,%ebx 801006c2: 0f 84 08 01 00 00 je 801007d0 <consoleintr+0x190> 801006c8: 83 fb 0a cmp $0xa,%ebx 801006cb: 0f 84 ff 00 00 00 je 801007d0 <consoleintr+0x190> 801006d1: 8b 15 c0 ff 10 80 mov 0x8010ffc0,%edx 801006d7: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 801006dc: 83 ea 80 sub $0xffffff80,%edx 801006df: 39 d0 cmp %edx,%eax 801006e1: 0f 85 79 ff ff ff jne 80100660 <consoleintr+0x20> input.w = input.e; 801006e7: a3 c4 ff 10 80 mov %eax,0x8010ffc4 wakeup(&input.r); 801006ec: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 801006f3: e8 28 32 00 00 call 80103920 <wakeup> consoleintr(int (*getc)(void)) { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ 801006f8: ff d6 call *%esi 801006fa: 85 c0 test %eax,%eax 801006fc: 89 c3 mov %eax,%ebx 801006fe: 0f 89 68 ff ff ff jns 8010066c <consoleintr+0x2c> } } break; } } release(&cons.lock); 80100704: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 8010070b: e8 70 40 00 00 call 80104780 <release> if(doprocdump) { 80100710: 85 ff test %edi,%edi 80100712: 0f 85 c2 00 00 00 jne 801007da <consoleintr+0x19a> procdump(); // now call procdump() wo. cons.lock held } } 80100718: 83 c4 1c add $0x1c,%esp 8010071b: 5b pop %ebx 8010071c: 5e pop %esi 8010071d: 5f pop %edi 8010071e: 5d pop %ebp 8010071f: c3 ret { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ 80100720: 83 fb 15 cmp $0x15,%ebx 80100723: 74 33 je 80100758 <consoleintr+0x118> 80100725: 83 fb 7f cmp $0x7f,%ebx 80100728: 0f 85 58 ff ff ff jne 80100686 <consoleintr+0x46> input.e--; consputc(BACKSPACE); } break; case C('H'): case '\x7f': // Backspace if(input.e != input.w){ 8010072e: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 80100733: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 80100739: 0f 84 21 ff ff ff je 80100660 <consoleintr+0x20> input.e--; 8010073f: 83 e8 01 sub $0x1,%eax 80100742: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(BACKSPACE); 80100747: b8 00 01 00 00 mov $0x100,%eax 8010074c: e8 ff fc ff ff call 80100450 <consputc> 80100751: e9 0a ff ff ff jmp 80100660 <consoleintr+0x20> 80100756: 66 90 xchg %ax,%ax case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 80100758: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 8010075d: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 80100763: 75 2b jne 80100790 <consoleintr+0x150> 80100765: e9 f6 fe ff ff jmp 80100660 <consoleintr+0x20> 8010076a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.e--; 80100770: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(BACKSPACE); 80100775: b8 00 01 00 00 mov $0x100,%eax 8010077a: e8 d1 fc ff ff call 80100450 <consputc> case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 8010077f: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 80100784: 3b 05 c4 ff 10 80 cmp 0x8010ffc4,%eax 8010078a: 0f 84 d0 fe ff ff je 80100660 <consoleintr+0x20> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 80100790: 83 e8 01 sub $0x1,%eax 80100793: 89 c2 mov %eax,%edx 80100795: 83 e2 7f and $0x7f,%edx case C('P'): // Process listing. // procdump() locks cons.lock indirectly; invoke later doprocdump = 1; break; case C('U'): // Kill line. while(input.e != input.w && 80100798: 80 ba 40 ff 10 80 0a cmpb $0xa,-0x7fef00c0(%edx) 8010079f: 75 cf jne 80100770 <consoleintr+0x130> 801007a1: e9 ba fe ff ff jmp 80100660 <consoleintr+0x20> 801007a6: 66 90 xchg %ax,%ax { int c, doprocdump = 0; acquire(&cons.lock); while((c = getc()) >= 0){ switch(c){ 801007a8: bf 01 00 00 00 mov $0x1,%edi 801007ad: e9 ae fe ff ff jmp 80100660 <consoleintr+0x20> } break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ c = (c == '\r') ? '\n' : c; input.buf[input.e++ % INPUT_BUF] = c; 801007b2: 89 c2 mov %eax,%edx 801007b4: 83 c0 01 add $0x1,%eax 801007b7: 83 e2 7f and $0x7f,%edx 801007ba: c6 82 40 ff 10 80 0a movb $0xa,-0x7fef00c0(%edx) 801007c1: a3 c8 ff 10 80 mov %eax,0x8010ffc8 consputc(c); 801007c6: b8 0a 00 00 00 mov $0xa,%eax 801007cb: e8 80 fc ff ff call 80100450 <consputc> 801007d0: a1 c8 ff 10 80 mov 0x8010ffc8,%eax 801007d5: e9 0d ff ff ff jmp 801006e7 <consoleintr+0xa7> } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held } } 801007da: 83 c4 1c add $0x1c,%esp 801007dd: 5b pop %ebx 801007de: 5e pop %esi 801007df: 5f pop %edi 801007e0: 5d pop %ebp break; } } release(&cons.lock); if(doprocdump) { procdump(); // now call procdump() wo. cons.lock held 801007e1: e9 da 2f 00 00 jmp 801037c0 <procdump> 801007e6: 8d 76 00 lea 0x0(%esi),%esi 801007e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801007f0 <printint>: int locking; } cons; static void printint(int xx, int base, int sign) { 801007f0: 55 push %ebp 801007f1: 89 e5 mov %esp,%ebp 801007f3: 57 push %edi 801007f4: 56 push %esi 801007f5: 89 d6 mov %edx,%esi 801007f7: 53 push %ebx 801007f8: 83 ec 1c sub $0x1c,%esp static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 801007fb: 85 c9 test %ecx,%ecx 801007fd: 74 04 je 80100803 <printint+0x13> 801007ff: 85 c0 test %eax,%eax 80100801: 78 55 js 80100858 <printint+0x68> x = -xx; else x = xx; 80100803: 31 ff xor %edi,%edi 80100805: 31 c9 xor %ecx,%ecx 80100807: 8d 5d d8 lea -0x28(%ebp),%ebx 8010080a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi i = 0; do{ buf[i++] = digits[x % base]; 80100810: 31 d2 xor %edx,%edx 80100812: f7 f6 div %esi 80100814: 0f b6 92 78 73 10 80 movzbl -0x7fef8c88(%edx),%edx 8010081b: 88 14 0b mov %dl,(%ebx,%ecx,1) 8010081e: 83 c1 01 add $0x1,%ecx }while((x /= base) != 0); 80100821: 85 c0 test %eax,%eax 80100823: 75 eb jne 80100810 <printint+0x20> if(sign) 80100825: 85 ff test %edi,%edi 80100827: 74 08 je 80100831 <printint+0x41> buf[i++] = '-'; 80100829: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 8010082e: 83 c1 01 add $0x1,%ecx while(--i >= 0) 80100831: 8d 71 ff lea -0x1(%ecx),%esi 80100834: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi consputc(buf[i]); 80100838: 0f be 04 33 movsbl (%ebx,%esi,1),%eax }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 8010083c: 83 ee 01 sub $0x1,%esi consputc(buf[i]); 8010083f: e8 0c fc ff ff call 80100450 <consputc> }while((x /= base) != 0); if(sign) buf[i++] = '-'; while(--i >= 0) 80100844: 83 fe ff cmp $0xffffffff,%esi 80100847: 75 ef jne 80100838 <printint+0x48> consputc(buf[i]); } 80100849: 83 c4 1c add $0x1c,%esp 8010084c: 5b pop %ebx 8010084d: 5e pop %esi 8010084e: 5f pop %edi 8010084f: 5d pop %ebp 80100850: c3 ret 80100851: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) x = -xx; 80100858: f7 d8 neg %eax 8010085a: bf 01 00 00 00 mov $0x1,%edi static char digits[] = "0123456789abcdef"; char buf[16]; int i; uint x; if(sign && (sign = xx < 0)) 8010085f: eb a4 jmp 80100805 <printint+0x15> 80100861: eb 0d jmp 80100870 <cprintf> 80100863: 90 nop 80100864: 90 nop 80100865: 90 nop 80100866: 90 nop 80100867: 90 nop 80100868: 90 nop 80100869: 90 nop 8010086a: 90 nop 8010086b: 90 nop 8010086c: 90 nop 8010086d: 90 nop 8010086e: 90 nop 8010086f: 90 nop 80100870 <cprintf>: //PAGEBREAK: 50 // Print to the console. only understands %d, %x, %p, %s. void cprintf(char *fmt, ...) { 80100870: 55 push %ebp 80100871: 89 e5 mov %esp,%ebp 80100873: 57 push %edi 80100874: 56 push %esi 80100875: 53 push %ebx 80100876: 83 ec 2c sub $0x2c,%esp int i, c, locking; uint *argp; char *s; locking = cons.locking; 80100879: 8b 3d 74 a5 10 80 mov 0x8010a574,%edi if(locking) 8010087f: 85 ff test %edi,%edi 80100881: 0f 85 31 01 00 00 jne 801009b8 <cprintf+0x148> acquire(&cons.lock); if (fmt == 0) 80100887: 8b 4d 08 mov 0x8(%ebp),%ecx 8010088a: 85 c9 test %ecx,%ecx 8010088c: 0f 84 37 01 00 00 je 801009c9 <cprintf+0x159> panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100892: 0f b6 01 movzbl (%ecx),%eax 80100895: 85 c0 test %eax,%eax 80100897: 0f 84 8b 00 00 00 je 80100928 <cprintf+0xb8> acquire(&cons.lock); if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); 8010089d: 8d 75 0c lea 0xc(%ebp),%esi 801008a0: 31 db xor %ebx,%ebx 801008a2: eb 3f jmp 801008e3 <cprintf+0x73> 801008a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi continue; } c = fmt[++i] & 0xff; if(c == 0) break; switch(c){ 801008a8: 83 fa 25 cmp $0x25,%edx 801008ab: 0f 84 af 00 00 00 je 80100960 <cprintf+0xf0> 801008b1: 83 fa 64 cmp $0x64,%edx 801008b4: 0f 84 86 00 00 00 je 80100940 <cprintf+0xd0> case '%': consputc('%'); break; default: // Print unknown % sequence to draw attention. consputc('%'); 801008ba: b8 25 00 00 00 mov $0x25,%eax 801008bf: 89 55 e0 mov %edx,-0x20(%ebp) 801008c2: e8 89 fb ff ff call 80100450 <consputc> consputc(c); 801008c7: 8b 55 e0 mov -0x20(%ebp),%edx 801008ca: 89 d0 mov %edx,%eax 801008cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801008d0: e8 7b fb ff ff call 80100450 <consputc> 801008d5: 8b 4d 08 mov 0x8(%ebp),%ecx if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801008d8: 83 c3 01 add $0x1,%ebx 801008db: 0f b6 04 19 movzbl (%ecx,%ebx,1),%eax 801008df: 85 c0 test %eax,%eax 801008e1: 74 45 je 80100928 <cprintf+0xb8> if(c != '%'){ 801008e3: 83 f8 25 cmp $0x25,%eax 801008e6: 75 e8 jne 801008d0 <cprintf+0x60> consputc(c); continue; } c = fmt[++i] & 0xff; 801008e8: 83 c3 01 add $0x1,%ebx 801008eb: 0f b6 14 19 movzbl (%ecx,%ebx,1),%edx if(c == 0) 801008ef: 85 d2 test %edx,%edx 801008f1: 74 35 je 80100928 <cprintf+0xb8> break; switch(c){ 801008f3: 83 fa 70 cmp $0x70,%edx 801008f6: 74 0f je 80100907 <cprintf+0x97> 801008f8: 7e ae jle 801008a8 <cprintf+0x38> 801008fa: 83 fa 73 cmp $0x73,%edx 801008fd: 8d 76 00 lea 0x0(%esi),%esi 80100900: 74 76 je 80100978 <cprintf+0x108> 80100902: 83 fa 78 cmp $0x78,%edx 80100905: 75 b3 jne 801008ba <cprintf+0x4a> case 'd': printint(*argp++, 10, 1); break; case 'x': case 'p': printint(*argp++, 16, 0); 80100907: 8b 06 mov (%esi),%eax 80100909: 31 c9 xor %ecx,%ecx 8010090b: ba 10 00 00 00 mov $0x10,%edx if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100910: 83 c3 01 add $0x1,%ebx case 'd': printint(*argp++, 10, 1); break; case 'x': case 'p': printint(*argp++, 16, 0); 80100913: 83 c6 04 add $0x4,%esi 80100916: e8 d5 fe ff ff call 801007f0 <printint> 8010091b: 8b 4d 08 mov 0x8(%ebp),%ecx if (fmt == 0) panic("null fmt"); argp = (uint*)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 8010091e: 0f b6 04 19 movzbl (%ecx,%ebx,1),%eax 80100922: 85 c0 test %eax,%eax 80100924: 75 bd jne 801008e3 <cprintf+0x73> 80100926: 66 90 xchg %ax,%ax consputc(c); break; } } if(locking) 80100928: 85 ff test %edi,%edi 8010092a: 74 0c je 80100938 <cprintf+0xc8> release(&cons.lock); 8010092c: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 80100933: e8 48 3e 00 00 call 80104780 <release> } 80100938: 83 c4 2c add $0x2c,%esp 8010093b: 5b pop %ebx 8010093c: 5e pop %esi 8010093d: 5f pop %edi 8010093e: 5d pop %ebp 8010093f: c3 ret c = fmt[++i] & 0xff; if(c == 0) break; switch(c){ case 'd': printint(*argp++, 10, 1); 80100940: 8b 06 mov (%esi),%eax 80100942: b9 01 00 00 00 mov $0x1,%ecx 80100947: ba 0a 00 00 00 mov $0xa,%edx 8010094c: 83 c6 04 add $0x4,%esi 8010094f: e8 9c fe ff ff call 801007f0 <printint> 80100954: 8b 4d 08 mov 0x8(%ebp),%ecx break; 80100957: e9 7c ff ff ff jmp 801008d8 <cprintf+0x68> 8010095c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = "(null)"; for(; *s; s++) consputc(*s); break; case '%': consputc('%'); 80100960: b8 25 00 00 00 mov $0x25,%eax 80100965: e8 e6 fa ff ff call 80100450 <consputc> 8010096a: 8b 4d 08 mov 0x8(%ebp),%ecx break; 8010096d: e9 66 ff ff ff jmp 801008d8 <cprintf+0x68> 80100972: 8d b6 00 00 00 00 lea 0x0(%esi),%esi case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) 80100978: 8b 16 mov (%esi),%edx 8010097a: b8 71 73 10 80 mov $0x80107371,%eax 8010097f: 83 c6 04 add $0x4,%esi 80100982: 85 d2 test %edx,%edx 80100984: 0f 44 d0 cmove %eax,%edx s = "(null)"; for(; *s; s++) 80100987: 0f b6 02 movzbl (%edx),%eax 8010098a: 84 c0 test %al,%al 8010098c: 0f 84 46 ff ff ff je 801008d8 <cprintf+0x68> 80100992: 89 5d e4 mov %ebx,-0x1c(%ebp) 80100995: 89 d3 mov %edx,%ebx 80100997: 90 nop consputc(*s); 80100998: 0f be c0 movsbl %al,%eax printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++) 8010099b: 83 c3 01 add $0x1,%ebx consputc(*s); 8010099e: e8 ad fa ff ff call 80100450 <consputc> printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++) 801009a3: 0f b6 03 movzbl (%ebx),%eax 801009a6: 84 c0 test %al,%al 801009a8: 75 ee jne 80100998 <cprintf+0x128> 801009aa: 8b 5d e4 mov -0x1c(%ebp),%ebx 801009ad: 8b 4d 08 mov 0x8(%ebp),%ecx 801009b0: e9 23 ff ff ff jmp 801008d8 <cprintf+0x68> 801009b5: 8d 76 00 lea 0x0(%esi),%esi uint *argp; char *s; locking = cons.locking; if(locking) acquire(&cons.lock); 801009b8: c7 04 24 40 a5 10 80 movl $0x8010a540,(%esp) 801009bf: e8 0c 3e 00 00 call 801047d0 <acquire> 801009c4: e9 be fe ff ff jmp 80100887 <cprintf+0x17> if (fmt == 0) panic("null fmt"); 801009c9: c7 04 24 68 73 10 80 movl $0x80107368,(%esp) 801009d0: e8 fb f9 ff ff call 801003d0 <panic> ... 801009e0 <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 801009e0: 55 push %ebp 801009e1: 89 e5 mov %esp,%ebp 801009e3: 57 push %edi 801009e4: 56 push %esi 801009e5: 53 push %ebx 801009e6: 81 ec 2c 01 00 00 sub $0x12c,%esp struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; begin_op(); 801009ec: e8 bf 23 00 00 call 80102db0 <begin_op> if((ip = namei(path)) == 0){ 801009f1: 8b 45 08 mov 0x8(%ebp),%eax 801009f4: 89 04 24 mov %eax,(%esp) 801009f7: e8 c4 14 00 00 call 80101ec0 <namei> 801009fc: 85 c0 test %eax,%eax 801009fe: 89 c7 mov %eax,%edi 80100a00: 0f 84 32 02 00 00 je 80100c38 <exec+0x258> end_op(); return -1; } ilock(ip); 80100a06: 89 04 24 mov %eax,(%esp) 80100a09: e8 52 12 00 00 call 80101c60 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 80100a0e: 8d 45 94 lea -0x6c(%ebp),%eax 80100a11: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) 80100a18: 00 80100a19: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80100a20: 00 80100a21: 89 44 24 04 mov %eax,0x4(%esp) 80100a25: 89 3c 24 mov %edi,(%esp) 80100a28: e8 43 0e 00 00 call 80101870 <readi> 80100a2d: 83 f8 34 cmp $0x34,%eax 80100a30: 0f 85 fa 01 00 00 jne 80100c30 <exec+0x250> goto bad; if(elf.magic != ELF_MAGIC) 80100a36: 81 7d 94 7f 45 4c 46 cmpl $0x464c457f,-0x6c(%ebp) 80100a3d: 0f 85 ed 01 00 00 jne 80100c30 <exec+0x250> goto bad; if((pgdir = setupkvm()) == 0) 80100a43: e8 68 61 00 00 call 80106bb0 <setupkvm> 80100a48: 85 c0 test %eax,%eax 80100a4a: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) 80100a50: 0f 84 da 01 00 00 je 80100c30 <exec+0x250> goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a56: 66 83 7d c0 00 cmpw $0x0,-0x40(%ebp) 80100a5b: 8b 5d b0 mov -0x50(%ebp),%ebx 80100a5e: 0f 84 d1 02 00 00 je 80100d35 <exec+0x355> 80100a64: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp) 80100a6b: 00 00 00 80100a6e: 31 f6 xor %esi,%esi 80100a70: eb 18 jmp 80100a8a <exec+0xaa> 80100a72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100a78: 0f b7 45 c0 movzwl -0x40(%ebp),%eax 80100a7c: 83 c6 01 add $0x1,%esi 80100a7f: 39 f0 cmp %esi,%eax 80100a81: 0f 8e c1 00 00 00 jle 80100b48 <exec+0x168> 80100a87: 83 c3 20 add $0x20,%ebx if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100a8a: 8d 55 c8 lea -0x38(%ebp),%edx 80100a8d: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) 80100a94: 00 80100a95: 89 5c 24 08 mov %ebx,0x8(%esp) 80100a99: 89 54 24 04 mov %edx,0x4(%esp) 80100a9d: 89 3c 24 mov %edi,(%esp) 80100aa0: e8 cb 0d 00 00 call 80101870 <readi> 80100aa5: 83 f8 20 cmp $0x20,%eax 80100aa8: 75 76 jne 80100b20 <exec+0x140> goto bad; if(ph.type != ELF_PROG_LOAD) 80100aaa: 83 7d c8 01 cmpl $0x1,-0x38(%ebp) 80100aae: 75 c8 jne 80100a78 <exec+0x98> continue; if(ph.memsz < ph.filesz) 80100ab0: 8b 45 dc mov -0x24(%ebp),%eax 80100ab3: 3b 45 d8 cmp -0x28(%ebp),%eax 80100ab6: 72 68 jb 80100b20 <exec+0x140> goto bad; if(ph.vaddr + ph.memsz < ph.vaddr) 80100ab8: 03 45 d0 add -0x30(%ebp),%eax 80100abb: 72 63 jb 80100b20 <exec+0x140> goto bad; if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100abd: 89 44 24 08 mov %eax,0x8(%esp) 80100ac1: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx 80100ac7: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax 80100acd: 89 4c 24 04 mov %ecx,0x4(%esp) 80100ad1: 89 04 24 mov %eax,(%esp) 80100ad4: e8 27 64 00 00 call 80106f00 <allocuvm> 80100ad9: 85 c0 test %eax,%eax 80100adb: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100ae1: 74 3d je 80100b20 <exec+0x140> goto bad; if(ph.vaddr % PGSIZE != 0) 80100ae3: 8b 45 d0 mov -0x30(%ebp),%eax 80100ae6: a9 ff 0f 00 00 test $0xfff,%eax 80100aeb: 75 33 jne 80100b20 <exec+0x140> goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100aed: 8b 55 d8 mov -0x28(%ebp),%edx 80100af0: 89 7c 24 08 mov %edi,0x8(%esp) 80100af4: 89 44 24 04 mov %eax,0x4(%esp) 80100af8: 89 54 24 10 mov %edx,0x10(%esp) 80100afc: 8b 55 cc mov -0x34(%ebp),%edx 80100aff: 89 54 24 0c mov %edx,0xc(%esp) 80100b03: 8b 95 f4 fe ff ff mov -0x10c(%ebp),%edx 80100b09: 89 14 24 mov %edx,(%esp) 80100b0c: e8 0f 65 00 00 call 80107020 <loaduvm> 80100b11: 85 c0 test %eax,%eax 80100b13: 0f 89 5f ff ff ff jns 80100a78 <exec+0x98> 80100b19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi freevm(oldpgdir); return 0; bad: if(pgdir) freevm(pgdir); 80100b20: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax 80100b26: 89 04 24 mov %eax,(%esp) 80100b29: e8 82 62 00 00 call 80106db0 <freevm> if(ip){ 80100b2e: 85 ff test %edi,%edi 80100b30: b8 ff ff ff ff mov $0xffffffff,%eax 80100b35: 0f 85 f5 00 00 00 jne 80100c30 <exec+0x250> iunlockput(ip); end_op(); } return -1; } 80100b3b: 81 c4 2c 01 00 00 add $0x12c,%esp 80100b41: 5b pop %ebx 80100b42: 5e pop %esi 80100b43: 5f pop %edi 80100b44: 5d pop %ebp 80100b45: c3 ret 80100b46: 66 90 xchg %ax,%ax if((pgdir = setupkvm()) == 0) goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100b48: 8b 9d f0 fe ff ff mov -0x110(%ebp),%ebx 80100b4e: 81 c3 ff 0f 00 00 add $0xfff,%ebx 80100b54: 81 e3 00 f0 ff ff and $0xfffff000,%ebx 80100b5a: 8d b3 00 20 00 00 lea 0x2000(%ebx),%esi if(ph.vaddr % PGSIZE != 0) goto bad; if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) goto bad; } iunlockput(ip); 80100b60: 89 3c 24 mov %edi,(%esp) 80100b63: e8 d8 10 00 00 call 80101c40 <iunlockput> end_op(); 80100b68: e8 13 21 00 00 call 80102c80 <end_op> ip = 0; // Allocate two pages at the next page boundary. // Make the first inaccessible. Use the second as the user stack. sz = PGROUNDUP(sz); if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b6d: 8b 8d f4 fe ff ff mov -0x10c(%ebp),%ecx 80100b73: 89 74 24 08 mov %esi,0x8(%esp) 80100b77: 89 5c 24 04 mov %ebx,0x4(%esp) 80100b7b: 89 0c 24 mov %ecx,(%esp) 80100b7e: e8 7d 63 00 00 call 80106f00 <allocuvm> 80100b83: 85 c0 test %eax,%eax 80100b85: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100b8b: 0f 84 96 00 00 00 je 80100c27 <exec+0x247> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100b91: 2d 00 20 00 00 sub $0x2000,%eax 80100b96: 89 44 24 04 mov %eax,0x4(%esp) 80100b9a: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax 80100ba0: 89 04 24 mov %eax,(%esp) 80100ba3: e8 a8 60 00 00 call 80106c50 <clearpteu> sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100ba8: 8b 55 0c mov 0xc(%ebp),%edx 80100bab: 8b 02 mov (%edx),%eax 80100bad: 85 c0 test %eax,%eax 80100baf: 0f 84 8c 01 00 00 je 80100d41 <exec+0x361> 80100bb5: 8b 7d 0c mov 0xc(%ebp),%edi 80100bb8: 31 f6 xor %esi,%esi 80100bba: 8b 9d f0 fe ff ff mov -0x110(%ebp),%ebx 80100bc0: eb 28 jmp 80100bea <exec+0x20a> 80100bc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; 80100bc8: 89 9c b5 10 ff ff ff mov %ebx,-0xf0(%ebp,%esi,4) #include "defs.h" #include "x86.h" #include "elf.h" int exec(char *path, char **argv) 80100bcf: 8b 45 0c mov 0xc(%ebp),%eax goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100bd2: 83 c6 01 add $0x1,%esi if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; 80100bd5: 8d 95 04 ff ff ff lea -0xfc(%ebp),%edx #include "defs.h" #include "x86.h" #include "elf.h" int exec(char *path, char **argv) 80100bdb: 8d 3c b0 lea (%eax,%esi,4),%edi goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100bde: 8b 04 b0 mov (%eax,%esi,4),%eax 80100be1: 85 c0 test %eax,%eax 80100be3: 74 62 je 80100c47 <exec+0x267> if(argc >= MAXARG) 80100be5: 83 fe 20 cmp $0x20,%esi 80100be8: 74 3d je 80100c27 <exec+0x247> goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100bea: 89 04 24 mov %eax,(%esp) 80100bed: e8 ae 3e 00 00 call 80104aa0 <strlen> 80100bf2: f7 d0 not %eax 80100bf4: 8d 1c 18 lea (%eax,%ebx,1),%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100bf7: 8b 07 mov (%edi),%eax // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { if(argc >= MAXARG) goto bad; sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100bf9: 83 e3 fc and $0xfffffffc,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100bfc: 89 04 24 mov %eax,(%esp) 80100bff: e8 9c 3e 00 00 call 80104aa0 <strlen> 80100c04: 8b 8d f4 fe ff ff mov -0x10c(%ebp),%ecx 80100c0a: 83 c0 01 add $0x1,%eax 80100c0d: 89 44 24 0c mov %eax,0xc(%esp) 80100c11: 8b 07 mov (%edi),%eax 80100c13: 89 5c 24 04 mov %ebx,0x4(%esp) 80100c17: 89 0c 24 mov %ecx,(%esp) 80100c1a: 89 44 24 08 mov %eax,0x8(%esp) 80100c1e: e8 6d 5e 00 00 call 80106a90 <copyout> 80100c23: 85 c0 test %eax,%eax 80100c25: 79 a1 jns 80100bc8 <exec+0x1e8> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); end_op(); 80100c27: 31 ff xor %edi,%edi 80100c29: e9 f2 fe ff ff jmp 80100b20 <exec+0x140> 80100c2e: 66 90 xchg %ax,%ax bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100c30: 89 3c 24 mov %edi,(%esp) 80100c33: e8 08 10 00 00 call 80101c40 <iunlockput> end_op(); 80100c38: e8 43 20 00 00 call 80102c80 <end_op> 80100c3d: b8 ff ff ff ff mov $0xffffffff,%eax 80100c42: e9 f4 fe ff ff jmp 80100b3b <exec+0x15b> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100c47: 8d 4e 03 lea 0x3(%esi),%ecx 80100c4a: 8d 3c b5 04 00 00 00 lea 0x4(,%esi,4),%edi 80100c51: 8d 04 b5 10 00 00 00 lea 0x10(,%esi,4),%eax sp = (sp - (strlen(argv[argc]) + 1)) & ~3; if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; 80100c58: c7 84 8d 04 ff ff ff movl $0x0,-0xfc(%ebp,%ecx,4) 80100c5f: 00 00 00 00 ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100c63: 89 d9 mov %ebx,%ecx sp -= (3+argc+1) * 4; 80100c65: 29 c3 sub %eax,%ebx if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c67: 89 44 24 0c mov %eax,0xc(%esp) 80100c6b: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC ustack[1] = argc; ustack[2] = sp - (argc+1)*4; // argv pointer 80100c71: 29 f9 sub %edi,%ecx goto bad; ustack[3+argc] = sp; } ustack[3+argc] = 0; ustack[0] = 0xffffffff; // fake return PC 80100c73: c7 85 04 ff ff ff ff movl $0xffffffff,-0xfc(%ebp) 80100c7a: ff ff ff ustack[1] = argc; 80100c7d: 89 b5 08 ff ff ff mov %esi,-0xf8(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c83: 89 8d 0c ff ff ff mov %ecx,-0xf4(%ebp) sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c89: 89 54 24 08 mov %edx,0x8(%esp) 80100c8d: 89 5c 24 04 mov %ebx,0x4(%esp) 80100c91: 89 04 24 mov %eax,(%esp) 80100c94: e8 f7 5d 00 00 call 80106a90 <copyout> 80100c99: 85 c0 test %eax,%eax 80100c9b: 78 8a js 80100c27 <exec+0x247> goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100c9d: 8b 4d 08 mov 0x8(%ebp),%ecx 80100ca0: 0f b6 11 movzbl (%ecx),%edx 80100ca3: 84 d2 test %dl,%dl 80100ca5: 74 19 je 80100cc0 <exec+0x2e0> 80100ca7: 89 c8 mov %ecx,%eax 80100ca9: 83 c0 01 add $0x1,%eax 80100cac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(*s == '/') 80100cb0: 80 fa 2f cmp $0x2f,%dl sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100cb3: 0f b6 10 movzbl (%eax),%edx if(*s == '/') 80100cb6: 0f 44 c8 cmove %eax,%ecx sp -= (3+argc+1) * 4; if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) goto bad; // Save program name for debugging. for(last=s=path; *s; s++) 80100cb9: 83 c0 01 add $0x1,%eax 80100cbc: 84 d2 test %dl,%dl 80100cbe: 75 f0 jne 80100cb0 <exec+0x2d0> if(*s == '/') last = s+1; safestrcpy(proc->name, last, sizeof(proc->name)); 80100cc0: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100cc6: 89 4c 24 04 mov %ecx,0x4(%esp) 80100cca: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80100cd1: 00 80100cd2: 83 c0 6c add $0x6c,%eax 80100cd5: 89 04 24 mov %eax,(%esp) 80100cd8: e8 83 3d 00 00 call 80104a60 <safestrcpy> // Commit to the user image. oldpgdir = proc->pgdir; 80100cdd: 65 a1 04 00 00 00 mov %gs:0x4,%eax proc->pgdir = pgdir; 80100ce3: 8b 95 f4 fe ff ff mov -0x10c(%ebp),%edx if(*s == '/') last = s+1; safestrcpy(proc->name, last, sizeof(proc->name)); // Commit to the user image. oldpgdir = proc->pgdir; 80100ce9: 8b 70 04 mov 0x4(%eax),%esi proc->pgdir = pgdir; 80100cec: 89 50 04 mov %edx,0x4(%eax) proc->sz = sz; 80100cef: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100cf5: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx 80100cfb: 89 08 mov %ecx,(%eax) proc->tf->eip = elf.entry; // main 80100cfd: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100d03: 8b 55 ac mov -0x54(%ebp),%edx 80100d06: 8b 40 18 mov 0x18(%eax),%eax 80100d09: 89 50 38 mov %edx,0x38(%eax) proc->tf->esp = sp; 80100d0c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100d12: 8b 40 18 mov 0x18(%eax),%eax 80100d15: 89 58 44 mov %ebx,0x44(%eax) switchuvm(proc); 80100d18: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80100d1e: 89 04 24 mov %eax,(%esp) 80100d21: e8 ba 63 00 00 call 801070e0 <switchuvm> freevm(oldpgdir); 80100d26: 89 34 24 mov %esi,(%esp) 80100d29: e8 82 60 00 00 call 80106db0 <freevm> 80100d2e: 31 c0 xor %eax,%eax return 0; 80100d30: e9 06 fe ff ff jmp 80100b3b <exec+0x15b> if((pgdir = setupkvm()) == 0) goto bad; // Load program into memory. sz = 0; for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100d35: be 00 20 00 00 mov $0x2000,%esi 80100d3a: 31 db xor %ebx,%ebx 80100d3c: e9 1f fe ff ff jmp 80100b60 <exec+0x180> goto bad; clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); sp = sz; // Push argument strings, prepare rest of stack in ustack. for(argc = 0; argv[argc]; argc++) { 80100d41: 8b 9d f0 fe ff ff mov -0x110(%ebp),%ebx 80100d47: b0 10 mov $0x10,%al 80100d49: bf 04 00 00 00 mov $0x4,%edi 80100d4e: b9 03 00 00 00 mov $0x3,%ecx 80100d53: 31 f6 xor %esi,%esi 80100d55: 8d 95 04 ff ff ff lea -0xfc(%ebp),%edx 80100d5b: e9 f8 fe ff ff jmp 80100c58 <exec+0x278> 80100d60 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100d60: 55 push %ebp 80100d61: 89 e5 mov %esp,%ebp 80100d63: 57 push %edi 80100d64: 56 push %esi 80100d65: 53 push %ebx 80100d66: 83 ec 2c sub $0x2c,%esp 80100d69: 8b 45 0c mov 0xc(%ebp),%eax 80100d6c: 8b 5d 08 mov 0x8(%ebp),%ebx 80100d6f: 89 45 e0 mov %eax,-0x20(%ebp) 80100d72: 8b 45 10 mov 0x10(%ebp),%eax 80100d75: 89 45 e4 mov %eax,-0x1c(%ebp) int r; if(f->writable == 0) 80100d78: 80 7b 09 00 cmpb $0x0,0x9(%ebx) 80100d7c: 0f 84 ae 00 00 00 je 80100e30 <filewrite+0xd0> return -1; if(f->type == FD_PIPE) 80100d82: 8b 03 mov (%ebx),%eax 80100d84: 83 f8 01 cmp $0x1,%eax 80100d87: 0f 84 c2 00 00 00 je 80100e4f <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 80100d8d: 83 f8 02 cmp $0x2,%eax 80100d90: 0f 85 d7 00 00 00 jne 80100e6d <filewrite+0x10d> // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((LOGSIZE-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80100d96: 8b 45 e4 mov -0x1c(%ebp),%eax 80100d99: 31 f6 xor %esi,%esi 80100d9b: 85 c0 test %eax,%eax 80100d9d: 7f 31 jg 80100dd0 <filewrite+0x70> 80100d9f: e9 9c 00 00 00 jmp 80100e40 <filewrite+0xe0> 80100da4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n1 = max; begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; 80100da8: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100dab: 8b 53 10 mov 0x10(%ebx),%edx 80100dae: 89 45 dc mov %eax,-0x24(%ebp) 80100db1: 89 14 24 mov %edx,(%esp) 80100db4: e8 37 0e 00 00 call 80101bf0 <iunlock> end_op(); 80100db9: e8 c2 1e 00 00 call 80102c80 <end_op> 80100dbe: 8b 45 dc mov -0x24(%ebp),%eax if(r < 0) break; if(r != n1) 80100dc1: 39 f8 cmp %edi,%eax 80100dc3: 0f 85 98 00 00 00 jne 80100e61 <filewrite+0x101> panic("short filewrite"); i += r; 80100dc9: 01 c6 add %eax,%esi // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((LOGSIZE-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80100dcb: 39 75 e4 cmp %esi,-0x1c(%ebp) 80100dce: 7e 70 jle 80100e40 <filewrite+0xe0> int n1 = n - i; 80100dd0: 8b 7d e4 mov -0x1c(%ebp),%edi 80100dd3: b8 00 1a 00 00 mov $0x1a00,%eax 80100dd8: 29 f7 sub %esi,%edi 80100dda: 81 ff 00 1a 00 00 cmp $0x1a00,%edi 80100de0: 0f 4f f8 cmovg %eax,%edi if(n1 > max) n1 = max; begin_op(); 80100de3: e8 c8 1f 00 00 call 80102db0 <begin_op> ilock(f->ip); 80100de8: 8b 43 10 mov 0x10(%ebx),%eax 80100deb: 89 04 24 mov %eax,(%esp) 80100dee: e8 6d 0e 00 00 call 80101c60 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80100df3: 89 7c 24 0c mov %edi,0xc(%esp) 80100df7: 8b 43 14 mov 0x14(%ebx),%eax 80100dfa: 89 44 24 08 mov %eax,0x8(%esp) 80100dfe: 8b 45 e0 mov -0x20(%ebp),%eax 80100e01: 01 f0 add %esi,%eax 80100e03: 89 44 24 04 mov %eax,0x4(%esp) 80100e07: 8b 43 10 mov 0x10(%ebx),%eax 80100e0a: 89 04 24 mov %eax,(%esp) 80100e0d: e8 3e 09 00 00 call 80101750 <writei> 80100e12: 85 c0 test %eax,%eax 80100e14: 7f 92 jg 80100da8 <filewrite+0x48> f->off += r; iunlock(f->ip); 80100e16: 8b 53 10 mov 0x10(%ebx),%edx 80100e19: 89 45 dc mov %eax,-0x24(%ebp) 80100e1c: 89 14 24 mov %edx,(%esp) 80100e1f: e8 cc 0d 00 00 call 80101bf0 <iunlock> end_op(); 80100e24: e8 57 1e 00 00 call 80102c80 <end_op> if(r < 0) 80100e29: 8b 45 dc mov -0x24(%ebp),%eax 80100e2c: 85 c0 test %eax,%eax 80100e2e: 74 91 je 80100dc1 <filewrite+0x61> i += r; } return i == n ? n : -1; } panic("filewrite"); } 80100e30: 83 c4 2c add $0x2c,%esp panic("short filewrite"); i += r; } return i == n ? n : -1; } panic("filewrite"); 80100e33: b8 ff ff ff ff mov $0xffffffff,%eax } 80100e38: 5b pop %ebx 80100e39: 5e pop %esi 80100e3a: 5f pop %edi 80100e3b: 5d pop %ebp 80100e3c: c3 ret 80100e3d: 8d 76 00 lea 0x0(%esi),%esi break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 80100e40: 3b 75 e4 cmp -0x1c(%ebp),%esi } panic("filewrite"); 80100e43: 89 f0 mov %esi,%eax break; if(r != n1) panic("short filewrite"); i += r; } return i == n ? n : -1; 80100e45: 75 e9 jne 80100e30 <filewrite+0xd0> } panic("filewrite"); } 80100e47: 83 c4 2c add $0x2c,%esp 80100e4a: 5b pop %ebx 80100e4b: 5e pop %esi 80100e4c: 5f pop %edi 80100e4d: 5d pop %ebp 80100e4e: c3 ret int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 80100e4f: 8b 43 0c mov 0xc(%ebx),%eax 80100e52: 89 45 08 mov %eax,0x8(%ebp) i += r; } return i == n ? n : -1; } panic("filewrite"); } 80100e55: 83 c4 2c add $0x2c,%esp 80100e58: 5b pop %ebx 80100e59: 5e pop %esi 80100e5a: 5f pop %edi 80100e5b: 5d pop %ebp int r; if(f->writable == 0) return -1; if(f->type == FD_PIPE) return pipewrite(f->pipe, addr, n); 80100e5c: e9 2f 26 00 00 jmp 80103490 <pipewrite> end_op(); if(r < 0) break; if(r != n1) panic("short filewrite"); 80100e61: c7 04 24 89 73 10 80 movl $0x80107389,(%esp) 80100e68: e8 63 f5 ff ff call 801003d0 <panic> i += r; } return i == n ? n : -1; } panic("filewrite"); 80100e6d: c7 04 24 8f 73 10 80 movl $0x8010738f,(%esp) 80100e74: e8 57 f5 ff ff call 801003d0 <panic> 80100e79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100e80 <fileread>: } // Read from file f. int fileread(struct file *f, char *addr, int n) { 80100e80: 55 push %ebp 80100e81: 89 e5 mov %esp,%ebp 80100e83: 83 ec 38 sub $0x38,%esp 80100e86: 89 5d f4 mov %ebx,-0xc(%ebp) 80100e89: 8b 5d 08 mov 0x8(%ebp),%ebx 80100e8c: 89 75 f8 mov %esi,-0x8(%ebp) 80100e8f: 8b 75 0c mov 0xc(%ebp),%esi 80100e92: 89 7d fc mov %edi,-0x4(%ebp) 80100e95: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 80100e98: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 80100e9c: 74 5a je 80100ef8 <fileread+0x78> return -1; if(f->type == FD_PIPE) 80100e9e: 8b 03 mov (%ebx),%eax 80100ea0: 83 f8 01 cmp $0x1,%eax 80100ea3: 74 6b je 80100f10 <fileread+0x90> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 80100ea5: 83 f8 02 cmp $0x2,%eax 80100ea8: 75 7d jne 80100f27 <fileread+0xa7> ilock(f->ip); 80100eaa: 8b 43 10 mov 0x10(%ebx),%eax 80100ead: 89 04 24 mov %eax,(%esp) 80100eb0: e8 ab 0d 00 00 call 80101c60 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100eb5: 89 7c 24 0c mov %edi,0xc(%esp) 80100eb9: 8b 43 14 mov 0x14(%ebx),%eax 80100ebc: 89 74 24 04 mov %esi,0x4(%esp) 80100ec0: 89 44 24 08 mov %eax,0x8(%esp) 80100ec4: 8b 43 10 mov 0x10(%ebx),%eax 80100ec7: 89 04 24 mov %eax,(%esp) 80100eca: e8 a1 09 00 00 call 80101870 <readi> 80100ecf: 85 c0 test %eax,%eax 80100ed1: 7e 03 jle 80100ed6 <fileread+0x56> f->off += r; 80100ed3: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100ed6: 8b 53 10 mov 0x10(%ebx),%edx 80100ed9: 89 45 e4 mov %eax,-0x1c(%ebp) 80100edc: 89 14 24 mov %edx,(%esp) 80100edf: e8 0c 0d 00 00 call 80101bf0 <iunlock> return r; 80100ee4: 8b 45 e4 mov -0x1c(%ebp),%eax } panic("fileread"); } 80100ee7: 8b 5d f4 mov -0xc(%ebp),%ebx 80100eea: 8b 75 f8 mov -0x8(%ebp),%esi 80100eed: 8b 7d fc mov -0x4(%ebp),%edi 80100ef0: 89 ec mov %ebp,%esp 80100ef2: 5d pop %ebp 80100ef3: c3 ret 80100ef4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100ef8: 8b 5d f4 mov -0xc(%ebp),%ebx if((r = readi(f->ip, addr, f->off, n)) > 0) f->off += r; iunlock(f->ip); return r; } panic("fileread"); 80100efb: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f00: 8b 75 f8 mov -0x8(%ebp),%esi 80100f03: 8b 7d fc mov -0x4(%ebp),%edi 80100f06: 89 ec mov %ebp,%esp 80100f08: 5d pop %ebp 80100f09: c3 ret 80100f0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100f10: 8b 43 0c mov 0xc(%ebx),%eax f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100f13: 8b 75 f8 mov -0x8(%ebp),%esi 80100f16: 8b 5d f4 mov -0xc(%ebp),%ebx 80100f19: 8b 7d fc mov -0x4(%ebp),%edi int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100f1c: 89 45 08 mov %eax,0x8(%ebp) f->off += r; iunlock(f->ip); return r; } panic("fileread"); } 80100f1f: 89 ec mov %ebp,%esp 80100f21: 5d pop %ebp int r; if(f->readable == 0) return -1; if(f->type == FD_PIPE) return piperead(f->pipe, addr, n); 80100f22: e9 69 24 00 00 jmp 80103390 <piperead> if((r = readi(f->ip, addr, f->off, n)) > 0) f->off += r; iunlock(f->ip); return r; } panic("fileread"); 80100f27: c7 04 24 99 73 10 80 movl $0x80107399,(%esp) 80100f2e: e8 9d f4 ff ff call 801003d0 <panic> 80100f33: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100f39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100f40 <filestat>: } // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100f40: 55 push %ebp if(f->type == FD_INODE){ 80100f41: b8 ff ff ff ff mov $0xffffffff,%eax } // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100f46: 89 e5 mov %esp,%ebp 80100f48: 53 push %ebx 80100f49: 83 ec 14 sub $0x14,%esp 80100f4c: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 80100f4f: 83 3b 02 cmpl $0x2,(%ebx) 80100f52: 74 0c je 80100f60 <filestat+0x20> stati(f->ip, st); iunlock(f->ip); return 0; } return -1; } 80100f54: 83 c4 14 add $0x14,%esp 80100f57: 5b pop %ebx 80100f58: 5d pop %ebp 80100f59: c3 ret 80100f5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi // Get metadata about file f. int filestat(struct file *f, struct stat *st) { if(f->type == FD_INODE){ ilock(f->ip); 80100f60: 8b 43 10 mov 0x10(%ebx),%eax 80100f63: 89 04 24 mov %eax,(%esp) 80100f66: e8 f5 0c 00 00 call 80101c60 <ilock> stati(f->ip, st); 80100f6b: 8b 45 0c mov 0xc(%ebp),%eax 80100f6e: 89 44 24 04 mov %eax,0x4(%esp) 80100f72: 8b 43 10 mov 0x10(%ebx),%eax 80100f75: 89 04 24 mov %eax,(%esp) 80100f78: e8 e3 01 00 00 call 80101160 <stati> iunlock(f->ip); 80100f7d: 8b 43 10 mov 0x10(%ebx),%eax 80100f80: 89 04 24 mov %eax,(%esp) 80100f83: e8 68 0c 00 00 call 80101bf0 <iunlock> return 0; } return -1; } 80100f88: 83 c4 14 add $0x14,%esp filestat(struct file *f, struct stat *st) { if(f->type == FD_INODE){ ilock(f->ip); stati(f->ip, st); iunlock(f->ip); 80100f8b: 31 c0 xor %eax,%eax return 0; } return -1; } 80100f8d: 5b pop %ebx 80100f8e: 5d pop %ebp 80100f8f: c3 ret 80100f90 <filedup>: } // Increment ref count for file f. struct file* filedup(struct file *f) { 80100f90: 55 push %ebp 80100f91: 89 e5 mov %esp,%ebp 80100f93: 53 push %ebx 80100f94: 83 ec 14 sub $0x14,%esp 80100f97: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 80100f9a: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80100fa1: e8 2a 38 00 00 call 801047d0 <acquire> if(f->ref < 1) 80100fa6: 8b 43 04 mov 0x4(%ebx),%eax 80100fa9: 85 c0 test %eax,%eax 80100fab: 7e 1a jle 80100fc7 <filedup+0x37> panic("filedup"); f->ref++; 80100fad: 83 c0 01 add $0x1,%eax 80100fb0: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80100fb3: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80100fba: e8 c1 37 00 00 call 80104780 <release> return f; } 80100fbf: 89 d8 mov %ebx,%eax 80100fc1: 83 c4 14 add $0x14,%esp 80100fc4: 5b pop %ebx 80100fc5: 5d pop %ebp 80100fc6: c3 ret struct file* filedup(struct file *f) { acquire(&ftable.lock); if(f->ref < 1) panic("filedup"); 80100fc7: c7 04 24 a2 73 10 80 movl $0x801073a2,(%esp) 80100fce: e8 fd f3 ff ff call 801003d0 <panic> 80100fd3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100fe0 <filealloc>: } // Allocate a file structure. struct file* filealloc(void) { 80100fe0: 55 push %ebp 80100fe1: 89 e5 mov %esp,%ebp 80100fe3: 53 push %ebx initlock(&ftable.lock, "ftable"); } // Allocate a file structure. struct file* filealloc(void) 80100fe4: bb 2c 00 11 80 mov $0x8011002c,%ebx { 80100fe9: 83 ec 14 sub $0x14,%esp struct file *f; acquire(&ftable.lock); 80100fec: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80100ff3: e8 d8 37 00 00 call 801047d0 <acquire> for(f = ftable.file; f < ftable.file + NFILE; f++){ if(f->ref == 0){ 80100ff8: 8b 0d 18 00 11 80 mov 0x80110018,%ecx 80100ffe: 85 c9 test %ecx,%ecx 80101000: 75 11 jne 80101013 <filealloc+0x33> 80101002: eb 4a jmp 8010104e <filealloc+0x6e> 80101004: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi filealloc(void) { struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80101008: 83 c3 18 add $0x18,%ebx 8010100b: 81 fb 74 09 11 80 cmp $0x80110974,%ebx 80101011: 74 25 je 80101038 <filealloc+0x58> if(f->ref == 0){ 80101013: 8b 53 04 mov 0x4(%ebx),%edx 80101016: 85 d2 test %edx,%edx 80101018: 75 ee jne 80101008 <filealloc+0x28> f->ref = 1; 8010101a: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 80101021: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80101028: e8 53 37 00 00 call 80104780 <release> return f; } } release(&ftable.lock); return 0; } 8010102d: 89 d8 mov %ebx,%eax 8010102f: 83 c4 14 add $0x14,%esp 80101032: 5b pop %ebx 80101033: 5d pop %ebp 80101034: c3 ret 80101035: 8d 76 00 lea 0x0(%esi),%esi f->ref = 1; release(&ftable.lock); return f; } } release(&ftable.lock); 80101038: 31 db xor %ebx,%ebx 8010103a: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80101041: e8 3a 37 00 00 call 80104780 <release> return 0; } 80101046: 89 d8 mov %ebx,%eax 80101048: 83 c4 14 add $0x14,%esp 8010104b: 5b pop %ebx 8010104c: 5d pop %ebp 8010104d: c3 ret { struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ if(f->ref == 0){ 8010104e: bb 14 00 11 80 mov $0x80110014,%ebx 80101053: eb c5 jmp 8010101a <filealloc+0x3a> 80101055: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101059: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101060 <fileclose>: } // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80101060: 55 push %ebp 80101061: 89 e5 mov %esp,%ebp 80101063: 83 ec 38 sub $0x38,%esp 80101066: 89 5d f4 mov %ebx,-0xc(%ebp) 80101069: 8b 5d 08 mov 0x8(%ebp),%ebx 8010106c: 89 75 f8 mov %esi,-0x8(%ebp) 8010106f: 89 7d fc mov %edi,-0x4(%ebp) struct file ff; acquire(&ftable.lock); 80101072: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80101079: e8 52 37 00 00 call 801047d0 <acquire> if(f->ref < 1) 8010107e: 8b 43 04 mov 0x4(%ebx),%eax 80101081: 85 c0 test %eax,%eax 80101083: 0f 8e a4 00 00 00 jle 8010112d <fileclose+0xcd> panic("fileclose"); if(--f->ref > 0){ 80101089: 83 e8 01 sub $0x1,%eax 8010108c: 85 c0 test %eax,%eax 8010108e: 89 43 04 mov %eax,0x4(%ebx) 80101091: 74 1d je 801010b0 <fileclose+0x50> release(&ftable.lock); 80101093: c7 45 08 e0 ff 10 80 movl $0x8010ffe0,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 8010109a: 8b 5d f4 mov -0xc(%ebp),%ebx 8010109d: 8b 75 f8 mov -0x8(%ebp),%esi 801010a0: 8b 7d fc mov -0x4(%ebp),%edi 801010a3: 89 ec mov %ebp,%esp 801010a5: 5d pop %ebp acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); if(--f->ref > 0){ release(&ftable.lock); 801010a6: e9 d5 36 00 00 jmp 80104780 <release> 801010ab: 90 nop 801010ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return; } ff = *f; 801010b0: 8b 43 0c mov 0xc(%ebx),%eax 801010b3: 8b 7b 10 mov 0x10(%ebx),%edi 801010b6: 89 45 e0 mov %eax,-0x20(%ebp) 801010b9: 0f b6 43 09 movzbl 0x9(%ebx),%eax 801010bd: 88 45 e7 mov %al,-0x19(%ebp) 801010c0: 8b 33 mov (%ebx),%esi f->ref = 0; 801010c2: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx) f->type = FD_NONE; 801010c9: c7 03 00 00 00 00 movl $0x0,(%ebx) release(&ftable.lock); 801010cf: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 801010d6: e8 a5 36 00 00 call 80104780 <release> if(ff.type == FD_PIPE) 801010db: 83 fe 01 cmp $0x1,%esi 801010de: 74 38 je 80101118 <fileclose+0xb8> pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ 801010e0: 83 fe 02 cmp $0x2,%esi 801010e3: 74 13 je 801010f8 <fileclose+0x98> begin_op(); iput(ff.ip); end_op(); } } 801010e5: 8b 5d f4 mov -0xc(%ebp),%ebx 801010e8: 8b 75 f8 mov -0x8(%ebp),%esi 801010eb: 8b 7d fc mov -0x4(%ebp),%edi 801010ee: 89 ec mov %ebp,%esp 801010f0: 5d pop %ebp 801010f1: c3 ret 801010f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi release(&ftable.lock); if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ begin_op(); 801010f8: e8 b3 1c 00 00 call 80102db0 <begin_op> iput(ff.ip); 801010fd: 89 3c 24 mov %edi,(%esp) 80101100: e8 2b 03 00 00 call 80101430 <iput> end_op(); } } 80101105: 8b 5d f4 mov -0xc(%ebp),%ebx 80101108: 8b 75 f8 mov -0x8(%ebp),%esi 8010110b: 8b 7d fc mov -0x4(%ebp),%edi 8010110e: 89 ec mov %ebp,%esp 80101110: 5d pop %ebp if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); 80101111: e9 6a 1b 00 00 jmp 80102c80 <end_op> 80101116: 66 90 xchg %ax,%ax f->ref = 0; f->type = FD_NONE; release(&ftable.lock); if(ff.type == FD_PIPE) pipeclose(ff.pipe, ff.writable); 80101118: 0f be 45 e7 movsbl -0x19(%ebp),%eax 8010111c: 89 44 24 04 mov %eax,0x4(%esp) 80101120: 8b 45 e0 mov -0x20(%ebp),%eax 80101123: 89 04 24 mov %eax,(%esp) 80101126: e8 55 24 00 00 call 80103580 <pipeclose> 8010112b: eb b8 jmp 801010e5 <fileclose+0x85> { struct file ff; acquire(&ftable.lock); if(f->ref < 1) panic("fileclose"); 8010112d: c7 04 24 aa 73 10 80 movl $0x801073aa,(%esp) 80101134: e8 97 f2 ff ff call 801003d0 <panic> 80101139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101140 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80101140: 55 push %ebp 80101141: 89 e5 mov %esp,%ebp 80101143: 83 ec 18 sub $0x18,%esp initlock(&ftable.lock, "ftable"); 80101146: c7 44 24 04 b4 73 10 movl $0x801073b4,0x4(%esp) 8010114d: 80 8010114e: c7 04 24 e0 ff 10 80 movl $0x8010ffe0,(%esp) 80101155: e8 e6 34 00 00 call 80104640 <initlock> } 8010115a: c9 leave 8010115b: c3 ret 8010115c: 00 00 add %al,(%eax) ... 80101160 <stati>: } // Copy stat information from inode. void stati(struct inode *ip, struct stat *st) { 80101160: 55 push %ebp 80101161: 89 e5 mov %esp,%ebp 80101163: 8b 55 08 mov 0x8(%ebp),%edx 80101166: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101169: 8b 0a mov (%edx),%ecx 8010116b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 8010116e: 8b 4a 04 mov 0x4(%edx),%ecx 80101171: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101174: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101178: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 8010117b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 8010117f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101183: 8b 52 58 mov 0x58(%edx),%edx 80101186: 89 50 10 mov %edx,0x10(%eax) } 80101189: 5d pop %ebp 8010118a: c3 ret 8010118b: 90 nop 8010118c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101190 <idup>: // Increment reference count for ip. // Returns ip to enable ip = idup(ip1) idiom. struct inode* idup(struct inode *ip) { 80101190: 55 push %ebp 80101191: 89 e5 mov %esp,%ebp 80101193: 53 push %ebx 80101194: 83 ec 14 sub $0x14,%esp 80101197: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010119a: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 801011a1: e8 2a 36 00 00 call 801047d0 <acquire> ip->ref++; 801011a6: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 801011aa: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 801011b1: e8 ca 35 00 00 call 80104780 <release> return ip; } 801011b6: 89 d8 mov %ebx,%eax 801011b8: 83 c4 14 add $0x14,%esp 801011bb: 5b pop %ebx 801011bc: 5d pop %ebp 801011bd: c3 ret 801011be: 66 90 xchg %ax,%ax 801011c0 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 801011c0: 55 push %ebp 801011c1: 89 e5 mov %esp,%ebp 801011c3: 57 push %edi 801011c4: 89 d7 mov %edx,%edi 801011c6: 56 push %esi // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) 801011c7: 31 f6 xor %esi,%esi { 801011c9: 53 push %ebx 801011ca: 89 c3 mov %eax,%ebx 801011cc: 83 ec 2c sub $0x2c,%esp struct inode *ip, *empty; acquire(&icache.lock); 801011cf: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 801011d6: e8 f5 35 00 00 call 801047d0 <acquire> // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) 801011db: b8 34 0a 11 80 mov $0x80110a34,%eax 801011e0: eb 16 jmp 801011f8 <iget+0x38> 801011e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 801011e8: 85 f6 test %esi,%esi 801011ea: 74 3c je 80101228 <iget+0x68> acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801011ec: 05 90 00 00 00 add $0x90,%eax 801011f1: 3d 54 26 11 80 cmp $0x80112654,%eax 801011f6: 74 48 je 80101240 <iget+0x80> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 801011f8: 8b 48 08 mov 0x8(%eax),%ecx 801011fb: 85 c9 test %ecx,%ecx 801011fd: 7e e9 jle 801011e8 <iget+0x28> 801011ff: 39 18 cmp %ebx,(%eax) 80101201: 75 e5 jne 801011e8 <iget+0x28> 80101203: 39 78 04 cmp %edi,0x4(%eax) 80101206: 75 e0 jne 801011e8 <iget+0x28> ip->ref++; 80101208: 83 c1 01 add $0x1,%ecx 8010120b: 89 48 08 mov %ecx,0x8(%eax) release(&icache.lock); 8010120e: 89 45 e4 mov %eax,-0x1c(%ebp) 80101211: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 80101218: e8 63 35 00 00 call 80104780 <release> return ip; 8010121d: 8b 45 e4 mov -0x1c(%ebp),%eax ip->ref = 1; ip->flags = 0; release(&icache.lock); return ip; } 80101220: 83 c4 2c add $0x2c,%esp 80101223: 5b pop %ebx 80101224: 5e pop %esi 80101225: 5f pop %edi 80101226: 5d pop %ebp 80101227: c3 ret if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101228: 85 c9 test %ecx,%ecx 8010122a: 0f 44 f0 cmove %eax,%esi acquire(&icache.lock); // Is the inode already cached? empty = 0; for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010122d: 05 90 00 00 00 add $0x90,%eax 80101232: 3d 54 26 11 80 cmp $0x80112654,%eax 80101237: 75 bf jne 801011f8 <iget+0x38> 80101239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(empty == 0 && ip->ref == 0) // Remember empty slot. empty = ip; } // Recycle an inode cache entry. if(empty == 0) 80101240: 85 f6 test %esi,%esi 80101242: 74 29 je 8010126d <iget+0xad> panic("iget: no inodes"); ip = empty; ip->dev = dev; 80101244: 89 1e mov %ebx,(%esi) ip->inum = inum; 80101246: 89 7e 04 mov %edi,0x4(%esi) ip->ref = 1; 80101249: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->flags = 0; 80101250: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 80101257: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 8010125e: e8 1d 35 00 00 call 80104780 <release> return ip; } 80101263: 83 c4 2c add $0x2c,%esp ip = empty; ip->dev = dev; ip->inum = inum; ip->ref = 1; ip->flags = 0; release(&icache.lock); 80101266: 89 f0 mov %esi,%eax return ip; } 80101268: 5b pop %ebx 80101269: 5e pop %esi 8010126a: 5f pop %edi 8010126b: 5d pop %ebp 8010126c: c3 ret empty = ip; } // Recycle an inode cache entry. if(empty == 0) panic("iget: no inodes"); 8010126d: c7 04 24 bb 73 10 80 movl $0x801073bb,(%esp) 80101274: e8 57 f1 ff ff call 801003d0 <panic> 80101279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101280 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101280: 55 push %ebp 80101281: 89 e5 mov %esp,%ebp 80101283: 83 ec 18 sub $0x18,%esp return strncmp(s, t, DIRSIZ); 80101286: 8b 45 0c mov 0xc(%ebp),%eax 80101289: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101290: 00 80101291: 89 44 24 04 mov %eax,0x4(%esp) 80101295: 8b 45 08 mov 0x8(%ebp),%eax 80101298: 89 04 24 mov %eax,(%esp) 8010129b: e8 10 37 00 00 call 801049b0 <strncmp> } 801012a0: c9 leave 801012a1: c3 ret 801012a2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801012a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801012b0 <iupdate>: } // Copy a modified in-memory inode to disk. void iupdate(struct inode *ip) { 801012b0: 55 push %ebp 801012b1: 89 e5 mov %esp,%ebp 801012b3: 56 push %esi 801012b4: 53 push %ebx 801012b5: 83 ec 10 sub $0x10,%esp 801012b8: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801012bb: 8b 43 04 mov 0x4(%ebx),%eax 801012be: c1 e8 03 shr $0x3,%eax 801012c1: 03 05 f4 09 11 80 add 0x801109f4,%eax 801012c7: 89 44 24 04 mov %eax,0x4(%esp) 801012cb: 8b 03 mov (%ebx),%eax 801012cd: 89 04 24 mov %eax,(%esp) 801012d0: e8 3b ee ff ff call 80100110 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; dip->type = ip->type; 801012d5: 0f b7 53 50 movzwl 0x50(%ebx),%edx iupdate(struct inode *ip) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801012d9: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 801012db: 8b 43 04 mov 0x4(%ebx),%eax 801012de: 83 e0 07 and $0x7,%eax 801012e1: c1 e0 06 shl $0x6,%eax 801012e4: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax dip->type = ip->type; 801012e8: 66 89 10 mov %dx,(%eax) dip->major = ip->major; 801012eb: 0f b7 53 52 movzwl 0x52(%ebx),%edx 801012ef: 66 89 50 02 mov %dx,0x2(%eax) dip->minor = ip->minor; 801012f3: 0f b7 53 54 movzwl 0x54(%ebx),%edx 801012f7: 66 89 50 04 mov %dx,0x4(%eax) dip->nlink = ip->nlink; 801012fb: 0f b7 53 56 movzwl 0x56(%ebx),%edx 801012ff: 66 89 50 06 mov %dx,0x6(%eax) dip->size = ip->size; 80101303: 8b 53 58 mov 0x58(%ebx),%edx memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 80101306: 83 c3 5c add $0x5c,%ebx dip = (struct dinode*)bp->data + ip->inum%IPB; dip->type = ip->type; dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; 80101309: 89 50 08 mov %edx,0x8(%eax) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010130c: 83 c0 0c add $0xc,%eax 8010130f: 89 5c 24 04 mov %ebx,0x4(%esp) 80101313: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 8010131a: 00 8010131b: 89 04 24 mov %eax,(%esp) 8010131e: e8 1d 36 00 00 call 80104940 <memmove> log_write(bp); 80101323: 89 34 24 mov %esi,(%esp) 80101326: e8 95 17 00 00 call 80102ac0 <log_write> brelse(bp); 8010132b: 89 75 08 mov %esi,0x8(%ebp) } 8010132e: 83 c4 10 add $0x10,%esp 80101331: 5b pop %ebx 80101332: 5e pop %esi 80101333: 5d pop %ebp dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); log_write(bp); brelse(bp); 80101334: e9 07 ed ff ff jmp 80100040 <brelse> 80101339: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101340 <readsb>: struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 80101340: 55 push %ebp 80101341: 89 e5 mov %esp,%ebp 80101343: 83 ec 18 sub $0x18,%esp struct buf *bp; bp = bread(dev, 1); 80101346: 8b 45 08 mov 0x8(%ebp),%eax struct superblock sb; // Read the super block. void readsb(int dev, struct superblock *sb) { 80101349: 89 5d f8 mov %ebx,-0x8(%ebp) 8010134c: 89 75 fc mov %esi,-0x4(%ebp) 8010134f: 8b 75 0c mov 0xc(%ebp),%esi struct buf *bp; bp = bread(dev, 1); 80101352: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80101359: 00 8010135a: 89 04 24 mov %eax,(%esp) 8010135d: e8 ae ed ff ff call 80100110 <bread> memmove(sb, bp->data, sizeof(*sb)); 80101362: 89 34 24 mov %esi,(%esp) 80101365: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) 8010136c: 00 void readsb(int dev, struct superblock *sb) { struct buf *bp; bp = bread(dev, 1); 8010136d: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 8010136f: 8d 40 5c lea 0x5c(%eax),%eax 80101372: 89 44 24 04 mov %eax,0x4(%esp) 80101376: e8 c5 35 00 00 call 80104940 <memmove> brelse(bp); } 8010137b: 8b 75 fc mov -0x4(%ebp),%esi { struct buf *bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); 8010137e: 89 5d 08 mov %ebx,0x8(%ebp) } 80101381: 8b 5d f8 mov -0x8(%ebp),%ebx 80101384: 89 ec mov %ebp,%esp 80101386: 5d pop %ebp { struct buf *bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); 80101387: e9 b4 ec ff ff jmp 80100040 <brelse> 8010138c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101390 <bfree>: } // Free a disk block. static void bfree(int dev, uint b) { 80101390: 55 push %ebp 80101391: 89 e5 mov %esp,%ebp 80101393: 83 ec 28 sub $0x28,%esp 80101396: 89 75 f8 mov %esi,-0x8(%ebp) 80101399: 89 d6 mov %edx,%esi 8010139b: 89 5d f4 mov %ebx,-0xc(%ebp) 8010139e: 89 c3 mov %eax,%ebx 801013a0: 89 7d fc mov %edi,-0x4(%ebp) struct buf *bp; int bi, m; readsb(dev, &sb); 801013a3: 89 04 24 mov %eax,(%esp) 801013a6: c7 44 24 04 e0 09 11 movl $0x801109e0,0x4(%esp) 801013ad: 80 801013ae: e8 8d ff ff ff call 80101340 <readsb> bp = bread(dev, BBLOCK(b, sb)); 801013b3: 89 f0 mov %esi,%eax 801013b5: c1 e8 0c shr $0xc,%eax 801013b8: 03 05 f8 09 11 80 add 0x801109f8,%eax 801013be: 89 1c 24 mov %ebx,(%esp) bi = b % BPB; 801013c1: 89 f3 mov %esi,%ebx 801013c3: 81 e3 ff 0f 00 00 and $0xfff,%ebx { struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); 801013c9: 89 44 24 04 mov %eax,0x4(%esp) bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) 801013cd: c1 fb 03 sar $0x3,%ebx { struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); 801013d0: e8 3b ed ff ff call 80100110 <bread> bi = b % BPB; m = 1 << (bi % 8); 801013d5: 89 f1 mov %esi,%ecx 801013d7: be 01 00 00 00 mov $0x1,%esi 801013dc: 83 e1 07 and $0x7,%ecx 801013df: d3 e6 shl %cl,%esi if((bp->data[bi/8] & m) == 0) 801013e1: 0f b6 54 18 5c movzbl 0x5c(%eax,%ebx,1),%edx { struct buf *bp; int bi, m; readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); 801013e6: 89 c7 mov %eax,%edi bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) 801013e8: 0f b6 c2 movzbl %dl,%eax 801013eb: 85 f0 test %esi,%eax 801013ed: 74 27 je 80101416 <bfree+0x86> panic("freeing free block"); bp->data[bi/8] &= ~m; 801013ef: 89 f0 mov %esi,%eax 801013f1: f7 d0 not %eax 801013f3: 21 d0 and %edx,%eax 801013f5: 88 44 1f 5c mov %al,0x5c(%edi,%ebx,1) log_write(bp); 801013f9: 89 3c 24 mov %edi,(%esp) 801013fc: e8 bf 16 00 00 call 80102ac0 <log_write> brelse(bp); 80101401: 89 3c 24 mov %edi,(%esp) 80101404: e8 37 ec ff ff call 80100040 <brelse> } 80101409: 8b 5d f4 mov -0xc(%ebp),%ebx 8010140c: 8b 75 f8 mov -0x8(%ebp),%esi 8010140f: 8b 7d fc mov -0x4(%ebp),%edi 80101412: 89 ec mov %ebp,%esp 80101414: 5d pop %ebp 80101415: c3 ret readsb(dev, &sb); bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0) panic("freeing free block"); 80101416: c7 04 24 cb 73 10 80 movl $0x801073cb,(%esp) 8010141d: e8 ae ef ff ff call 801003d0 <panic> 80101422: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101430 <iput>: // to it, free the inode (and its content) on disk. // All calls to iput() must be inside a transaction in // case it has to free the inode. void iput(struct inode *ip) { 80101430: 55 push %ebp 80101431: 89 e5 mov %esp,%ebp 80101433: 57 push %edi 80101434: 56 push %esi 80101435: 53 push %ebx 80101436: 83 ec 2c sub $0x2c,%esp 80101439: 8b 75 08 mov 0x8(%ebp),%esi acquire(&icache.lock); 8010143c: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 80101443: e8 88 33 00 00 call 801047d0 <acquire> if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){ 80101448: 8b 46 08 mov 0x8(%esi),%eax 8010144b: 83 f8 01 cmp $0x1,%eax 8010144e: 74 20 je 80101470 <iput+0x40> ip->type = 0; iupdate(ip); acquire(&icache.lock); ip->flags = 0; } ip->ref--; 80101450: 83 e8 01 sub $0x1,%eax 80101453: 89 46 08 mov %eax,0x8(%esi) release(&icache.lock); 80101456: c7 45 08 00 0a 11 80 movl $0x80110a00,0x8(%ebp) } 8010145d: 83 c4 2c add $0x2c,%esp 80101460: 5b pop %ebx 80101461: 5e pop %esi 80101462: 5f pop %edi 80101463: 5d pop %ebp iupdate(ip); acquire(&icache.lock); ip->flags = 0; } ip->ref--; release(&icache.lock); 80101464: e9 17 33 00 00 jmp 80104780 <release> 80101469: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi // case it has to free the inode. void iput(struct inode *ip) { acquire(&icache.lock); if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){ 80101470: f6 46 4c 02 testb $0x2,0x4c(%esi) 80101474: 74 da je 80101450 <iput+0x20> 80101476: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 8010147b: 75 d3 jne 80101450 <iput+0x20> // inode has no links and no other references: truncate and free. release(&icache.lock); 8010147d: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 80101484: 89 f3 mov %esi,%ebx 80101486: e8 f5 32 00 00 call 80104780 <release> // If that was the last reference and the inode has no links // to it, free the inode (and its content) on disk. // All calls to iput() must be inside a transaction in // case it has to free the inode. void iput(struct inode *ip) 8010148b: 8d 7e 30 lea 0x30(%esi),%edi 8010148e: eb 07 jmp 80101497 <iput+0x67> uint *a; for(i = 0; i < NDIRECT; i++){ if(ip->addrs[i]){ bfree(ip->dev, ip->addrs[i]); ip->addrs[i] = 0; 80101490: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101493: 39 fb cmp %edi,%ebx 80101495: 74 19 je 801014b0 <iput+0x80> if(ip->addrs[i]){ 80101497: 8b 53 5c mov 0x5c(%ebx),%edx 8010149a: 85 d2 test %edx,%edx 8010149c: 74 f2 je 80101490 <iput+0x60> bfree(ip->dev, ip->addrs[i]); 8010149e: 8b 06 mov (%esi),%eax 801014a0: e8 eb fe ff ff call 80101390 <bfree> ip->addrs[i] = 0; 801014a5: c7 43 5c 00 00 00 00 movl $0x0,0x5c(%ebx) 801014ac: eb e2 jmp 80101490 <iput+0x60> 801014ae: 66 90 xchg %ax,%ax } } if(ip->addrs[NDIRECT]){ 801014b0: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 801014b6: 85 c0 test %eax,%eax 801014b8: 75 3e jne 801014f8 <iput+0xc8> brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 801014ba: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 801014c1: 89 34 24 mov %esi,(%esp) 801014c4: e8 e7 fd ff ff call 801012b0 <iupdate> acquire(&icache.lock); if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){ // inode has no links and no other references: truncate and free. release(&icache.lock); itrunc(ip); ip->type = 0; 801014c9: 66 c7 46 50 00 00 movw $0x0,0x50(%esi) iupdate(ip); 801014cf: 89 34 24 mov %esi,(%esp) 801014d2: e8 d9 fd ff ff call 801012b0 <iupdate> acquire(&icache.lock); 801014d7: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 801014de: e8 ed 32 00 00 call 801047d0 <acquire> ip->flags = 0; 801014e3: 8b 46 08 mov 0x8(%esi),%eax 801014e6: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 801014ed: e9 5e ff ff ff jmp 80101450 <iput+0x20> 801014f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 801014f8: 89 44 24 04 mov %eax,0x4(%esp) 801014fc: 8b 06 mov (%esi),%eax a = (uint*)bp->data; 801014fe: 31 db xor %ebx,%ebx ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 80101500: 89 04 24 mov %eax,(%esp) 80101503: e8 08 ec ff ff call 80100110 <bread> a = (uint*)bp->data; 80101508: 89 c7 mov %eax,%edi ip->addrs[i] = 0; } } if(ip->addrs[NDIRECT]){ bp = bread(ip->dev, ip->addrs[NDIRECT]); 8010150a: 89 45 e4 mov %eax,-0x1c(%ebp) a = (uint*)bp->data; 8010150d: 83 c7 5c add $0x5c,%edi 80101510: 31 c0 xor %eax,%eax 80101512: eb 11 jmp 80101525 <iput+0xf5> 80101514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(j = 0; j < NINDIRECT; j++){ 80101518: 83 c3 01 add $0x1,%ebx 8010151b: 81 fb 80 00 00 00 cmp $0x80,%ebx 80101521: 89 d8 mov %ebx,%eax 80101523: 74 10 je 80101535 <iput+0x105> if(a[j]) 80101525: 8b 14 87 mov (%edi,%eax,4),%edx 80101528: 85 d2 test %edx,%edx 8010152a: 74 ec je 80101518 <iput+0xe8> bfree(ip->dev, a[j]); 8010152c: 8b 06 mov (%esi),%eax 8010152e: e8 5d fe ff ff call 80101390 <bfree> 80101533: eb e3 jmp 80101518 <iput+0xe8> } brelse(bp); 80101535: 8b 45 e4 mov -0x1c(%ebp),%eax 80101538: 89 04 24 mov %eax,(%esp) 8010153b: e8 00 eb ff ff call 80100040 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 80101540: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 80101546: 8b 06 mov (%esi),%eax 80101548: e8 43 fe ff ff call 80101390 <bfree> ip->addrs[NDIRECT] = 0; 8010154d: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 80101554: 00 00 00 80101557: e9 5e ff ff ff jmp 801014ba <iput+0x8a> 8010155c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101560 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 80101560: 55 push %ebp 80101561: 89 e5 mov %esp,%ebp 80101563: 57 push %edi 80101564: 56 push %esi 80101565: 53 push %ebx 80101566: 83 ec 3c sub $0x3c,%esp 80101569: 89 45 d8 mov %eax,-0x28(%ebp) int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010156c: a1 e0 09 11 80 mov 0x801109e0,%eax 80101571: 85 c0 test %eax,%eax 80101573: 0f 84 90 00 00 00 je 80101609 <balloc+0xa9> 80101579: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 80101580: 8b 45 dc mov -0x24(%ebp),%eax 80101583: c1 f8 0c sar $0xc,%eax 80101586: 03 05 f8 09 11 80 add 0x801109f8,%eax 8010158c: 89 44 24 04 mov %eax,0x4(%esp) 80101590: 8b 45 d8 mov -0x28(%ebp),%eax 80101593: 89 04 24 mov %eax,(%esp) 80101596: e8 75 eb ff ff call 80100110 <bread> 8010159b: 8b 15 e0 09 11 80 mov 0x801109e0,%edx 801015a1: 8b 5d dc mov -0x24(%ebp),%ebx 801015a4: 89 55 e0 mov %edx,-0x20(%ebp) 801015a7: 89 45 e4 mov %eax,-0x1c(%ebp) 801015aa: 31 c0 xor %eax,%eax 801015ac: eb 35 jmp 801015e3 <balloc+0x83> 801015ae: 66 90 xchg %ax,%ax for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 801015b0: 89 c1 mov %eax,%ecx 801015b2: bf 01 00 00 00 mov $0x1,%edi 801015b7: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 801015ba: 89 c2 mov %eax,%edx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 801015bc: d3 e7 shl %cl,%edi if((bp->data[bi/8] & m) == 0){ // Is block free? 801015be: 8b 4d e4 mov -0x1c(%ebp),%ecx 801015c1: c1 fa 03 sar $0x3,%edx bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); 801015c4: 89 7d d4 mov %edi,-0x2c(%ebp) if((bp->data[bi/8] & m) == 0){ // Is block free? 801015c7: 0f b6 74 11 5c movzbl 0x5c(%ecx,%edx,1),%esi 801015cc: 89 f1 mov %esi,%ecx 801015ce: 0f b6 f9 movzbl %cl,%edi 801015d1: 85 7d d4 test %edi,-0x2c(%ebp) 801015d4: 74 42 je 80101618 <balloc+0xb8> struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 801015d6: 83 c0 01 add $0x1,%eax 801015d9: 83 c3 01 add $0x1,%ebx 801015dc: 3d 00 10 00 00 cmp $0x1000,%eax 801015e1: 74 05 je 801015e8 <balloc+0x88> 801015e3: 3b 5d e0 cmp -0x20(%ebp),%ebx 801015e6: 72 c8 jb 801015b0 <balloc+0x50> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 801015e8: 8b 55 e4 mov -0x1c(%ebp),%edx 801015eb: 89 14 24 mov %edx,(%esp) 801015ee: e8 4d ea ff ff call 80100040 <brelse> { int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 801015f3: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 801015fa: 8b 4d dc mov -0x24(%ebp),%ecx 801015fd: 39 0d e0 09 11 80 cmp %ecx,0x801109e0 80101603: 0f 87 77 ff ff ff ja 80101580 <balloc+0x20> return b + bi; } } brelse(bp); } panic("balloc: out of blocks"); 80101609: c7 04 24 de 73 10 80 movl $0x801073de,(%esp) 80101610: e8 bb ed ff ff call 801003d0 <panic> 80101615: 8d 76 00 lea 0x0(%esi),%esi 80101618: 8b 4d d4 mov -0x2c(%ebp),%ecx for(b = 0; b < sb.size; b += BPB){ bp = bread(dev, BBLOCK(b, sb)); for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? bp->data[bi/8] |= m; // Mark block in use. 8010161b: 8b 7d e4 mov -0x1c(%ebp),%edi 8010161e: 09 f1 or %esi,%ecx 80101620: 88 4c 17 5c mov %cl,0x5c(%edi,%edx,1) log_write(bp); 80101624: 89 3c 24 mov %edi,(%esp) 80101627: e8 94 14 00 00 call 80102ac0 <log_write> brelse(bp); 8010162c: 89 3c 24 mov %edi,(%esp) 8010162f: e8 0c ea ff ff call 80100040 <brelse> static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 80101634: 8b 45 d8 mov -0x28(%ebp),%eax 80101637: 89 5c 24 04 mov %ebx,0x4(%esp) 8010163b: 89 04 24 mov %eax,(%esp) 8010163e: e8 cd ea ff ff call 80100110 <bread> memset(bp->data, 0, BSIZE); 80101643: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 8010164a: 00 8010164b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80101652: 00 static void bzero(int dev, int bno) { struct buf *bp; bp = bread(dev, bno); 80101653: 89 c6 mov %eax,%esi memset(bp->data, 0, BSIZE); 80101655: 8d 40 5c lea 0x5c(%eax),%eax 80101658: 89 04 24 mov %eax,(%esp) 8010165b: e8 10 32 00 00 call 80104870 <memset> log_write(bp); 80101660: 89 34 24 mov %esi,(%esp) 80101663: e8 58 14 00 00 call 80102ac0 <log_write> brelse(bp); 80101668: 89 34 24 mov %esi,(%esp) 8010166b: e8 d0 e9 ff ff call 80100040 <brelse> } } brelse(bp); } panic("balloc: out of blocks"); } 80101670: 83 c4 3c add $0x3c,%esp 80101673: 89 d8 mov %ebx,%eax 80101675: 5b pop %ebx 80101676: 5e pop %esi 80101677: 5f pop %edi 80101678: 5d pop %ebp 80101679: c3 ret 8010167a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101680 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 80101680: 55 push %ebp 80101681: 89 e5 mov %esp,%ebp 80101683: 83 ec 38 sub $0x38,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 80101686: 83 fa 0b cmp $0xb,%edx // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 80101689: 89 5d f4 mov %ebx,-0xc(%ebp) 8010168c: 89 c3 mov %eax,%ebx 8010168e: 89 75 f8 mov %esi,-0x8(%ebp) 80101691: 89 7d fc mov %edi,-0x4(%ebp) uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 80101694: 77 1a ja 801016b0 <bmap+0x30> if((addr = ip->addrs[bn]) == 0) 80101696: 8d 7a 14 lea 0x14(%edx),%edi 80101699: 8b 44 b8 0c mov 0xc(%eax,%edi,4),%eax 8010169d: 85 c0 test %eax,%eax 8010169f: 74 6f je 80101710 <bmap+0x90> brelse(bp); return addr; } panic("bmap: out of range"); } 801016a1: 8b 5d f4 mov -0xc(%ebp),%ebx 801016a4: 8b 75 f8 mov -0x8(%ebp),%esi 801016a7: 8b 7d fc mov -0x4(%ebp),%edi 801016aa: 89 ec mov %ebp,%esp 801016ac: 5d pop %ebp 801016ad: c3 ret 801016ae: 66 90 xchg %ax,%ax if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); return addr; } bn -= NDIRECT; 801016b0: 8d 7a f4 lea -0xc(%edx),%edi if(bn < NINDIRECT){ 801016b3: 83 ff 7f cmp $0x7f,%edi 801016b6: 77 7f ja 80101737 <bmap+0xb7> // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) 801016b8: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 801016be: 85 c0 test %eax,%eax 801016c0: 74 66 je 80101728 <bmap+0xa8> ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 801016c2: 89 44 24 04 mov %eax,0x4(%esp) 801016c6: 8b 03 mov (%ebx),%eax 801016c8: 89 04 24 mov %eax,(%esp) 801016cb: e8 40 ea ff ff call 80100110 <bread> a = (uint*)bp->data; if((addr = a[bn]) == 0){ 801016d0: 8d 7c b8 5c lea 0x5c(%eax,%edi,4),%edi if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); bp = bread(ip->dev, addr); 801016d4: 89 c6 mov %eax,%esi a = (uint*)bp->data; if((addr = a[bn]) == 0){ 801016d6: 8b 07 mov (%edi),%eax 801016d8: 85 c0 test %eax,%eax 801016da: 75 17 jne 801016f3 <bmap+0x73> a[bn] = addr = balloc(ip->dev); 801016dc: 8b 03 mov (%ebx),%eax 801016de: e8 7d fe ff ff call 80101560 <balloc> 801016e3: 89 07 mov %eax,(%edi) log_write(bp); 801016e5: 89 45 e4 mov %eax,-0x1c(%ebp) 801016e8: 89 34 24 mov %esi,(%esp) 801016eb: e8 d0 13 00 00 call 80102ac0 <log_write> 801016f0: 8b 45 e4 mov -0x1c(%ebp),%eax } brelse(bp); 801016f3: 89 34 24 mov %esi,(%esp) 801016f6: 89 45 e4 mov %eax,-0x1c(%ebp) 801016f9: e8 42 e9 ff ff call 80100040 <brelse> return addr; 801016fe: 8b 45 e4 mov -0x1c(%ebp),%eax } panic("bmap: out of range"); } 80101701: 8b 5d f4 mov -0xc(%ebp),%ebx 80101704: 8b 75 f8 mov -0x8(%ebp),%esi 80101707: 8b 7d fc mov -0x4(%ebp),%edi 8010170a: 89 ec mov %ebp,%esp 8010170c: 5d pop %ebp 8010170d: c3 ret 8010170e: 66 90 xchg %ax,%ax uint addr, *a; struct buf *bp; if(bn < NDIRECT){ if((addr = ip->addrs[bn]) == 0) ip->addrs[bn] = addr = balloc(ip->dev); 80101710: 8b 03 mov (%ebx),%eax 80101712: e8 49 fe ff ff call 80101560 <balloc> 80101717: 89 44 bb 0c mov %eax,0xc(%ebx,%edi,4) brelse(bp); return addr; } panic("bmap: out of range"); } 8010171b: 8b 5d f4 mov -0xc(%ebp),%ebx 8010171e: 8b 75 f8 mov -0x8(%ebp),%esi 80101721: 8b 7d fc mov -0x4(%ebp),%edi 80101724: 89 ec mov %ebp,%esp 80101726: 5d pop %ebp 80101727: c3 ret bn -= NDIRECT; if(bn < NINDIRECT){ // Load indirect block, allocating if necessary. if((addr = ip->addrs[NDIRECT]) == 0) ip->addrs[NDIRECT] = addr = balloc(ip->dev); 80101728: 8b 03 mov (%ebx),%eax 8010172a: e8 31 fe ff ff call 80101560 <balloc> 8010172f: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) 80101735: eb 8b jmp 801016c2 <bmap+0x42> } brelse(bp); return addr; } panic("bmap: out of range"); 80101737: c7 04 24 f4 73 10 80 movl $0x801073f4,(%esp) 8010173e: e8 8d ec ff ff call 801003d0 <panic> 80101743: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101749: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101750 <writei>: // PAGEBREAK! // Write data to inode. int writei(struct inode *ip, char *src, uint off, uint n) { 80101750: 55 push %ebp 80101751: 89 e5 mov %esp,%ebp 80101753: 83 ec 38 sub $0x38,%esp 80101756: 89 5d f4 mov %ebx,-0xc(%ebp) 80101759: 8b 5d 08 mov 0x8(%ebp),%ebx 8010175c: 89 75 f8 mov %esi,-0x8(%ebp) 8010175f: 8b 4d 0c mov 0xc(%ebp),%ecx 80101762: 89 7d fc mov %edi,-0x4(%ebp) 80101765: 8b 75 10 mov 0x10(%ebp),%esi 80101768: 8b 7d 14 mov 0x14(%ebp),%edi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 8010176b: 66 83 7b 50 03 cmpw $0x3,0x50(%ebx) 80101770: 74 1e je 80101790 <writei+0x40> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); } if(off > ip->size || off + n < off) 80101772: 39 73 58 cmp %esi,0x58(%ebx) 80101775: 73 41 jae 801017b8 <writei+0x68> if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; 80101777: b8 ff ff ff ff mov $0xffffffff,%eax } 8010177c: 8b 5d f4 mov -0xc(%ebp),%ebx 8010177f: 8b 75 f8 mov -0x8(%ebp),%esi 80101782: 8b 7d fc mov -0x4(%ebp),%edi 80101785: 89 ec mov %ebp,%esp 80101787: 5d pop %ebp 80101788: c3 ret 80101789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101790: 0f b7 43 52 movzwl 0x52(%ebx),%eax 80101794: 66 83 f8 09 cmp $0x9,%ax 80101798: 77 dd ja 80101777 <writei+0x27> 8010179a: 98 cwtl 8010179b: 8b 04 c5 84 09 11 80 mov -0x7feef67c(,%eax,8),%eax 801017a2: 85 c0 test %eax,%eax 801017a4: 74 d1 je 80101777 <writei+0x27> return -1; return devsw[ip->major].write(ip, src, n); 801017a6: 89 7d 10 mov %edi,0x10(%ebp) if(n > 0 && off > ip->size){ ip->size = off; iupdate(ip); } return n; } 801017a9: 8b 5d f4 mov -0xc(%ebp),%ebx 801017ac: 8b 75 f8 mov -0x8(%ebp),%esi 801017af: 8b 7d fc mov -0x4(%ebp),%edi 801017b2: 89 ec mov %ebp,%esp 801017b4: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); 801017b5: ff e0 jmp *%eax 801017b7: 90 nop } if(off > ip->size || off + n < off) 801017b8: 89 f8 mov %edi,%eax 801017ba: 01 f0 add %esi,%eax 801017bc: 72 b9 jb 80101777 <writei+0x27> return -1; if(off + n > MAXFILE*BSIZE) 801017be: 3d 00 18 01 00 cmp $0x11800,%eax 801017c3: 77 b2 ja 80101777 <writei+0x27> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 801017c5: 85 ff test %edi,%edi 801017c7: 0f 84 8a 00 00 00 je 80101857 <writei+0x107> 801017cd: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 801017d4: 89 4d e0 mov %ecx,-0x20(%ebp) 801017d7: 89 7d dc mov %edi,-0x24(%ebp) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801017da: 89 f2 mov %esi,%edx 801017dc: 89 d8 mov %ebx,%eax 801017de: c1 ea 09 shr $0x9,%edx m = min(n - tot, BSIZE - off%BSIZE); 801017e1: bf 00 02 00 00 mov $0x200,%edi return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801017e6: e8 95 fe ff ff call 80101680 <bmap> 801017eb: 89 44 24 04 mov %eax,0x4(%esp) 801017ef: 8b 03 mov (%ebx),%eax 801017f1: 89 04 24 mov %eax,(%esp) 801017f4: e8 17 e9 ff ff call 80100110 <bread> m = min(n - tot, BSIZE - off%BSIZE); 801017f9: 8b 4d dc mov -0x24(%ebp),%ecx 801017fc: 2b 4d e4 sub -0x1c(%ebp),%ecx return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801017ff: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101801: 89 f0 mov %esi,%eax 80101803: 25 ff 01 00 00 and $0x1ff,%eax 80101808: 29 c7 sub %eax,%edi 8010180a: 39 cf cmp %ecx,%edi 8010180c: 0f 47 f9 cmova %ecx,%edi memmove(bp->data + off%BSIZE, src, m); 8010180f: 8b 4d e0 mov -0x20(%ebp),%ecx 80101812: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101816: 01 fe add %edi,%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); memmove(bp->data + off%BSIZE, src, m); 80101818: 89 55 d8 mov %edx,-0x28(%ebp) 8010181b: 89 7c 24 08 mov %edi,0x8(%esp) 8010181f: 89 4c 24 04 mov %ecx,0x4(%esp) 80101823: 89 04 24 mov %eax,(%esp) 80101826: e8 15 31 00 00 call 80104940 <memmove> log_write(bp); 8010182b: 8b 55 d8 mov -0x28(%ebp),%edx 8010182e: 89 14 24 mov %edx,(%esp) 80101831: e8 8a 12 00 00 call 80102ac0 <log_write> brelse(bp); 80101836: 8b 55 d8 mov -0x28(%ebp),%edx 80101839: 89 14 24 mov %edx,(%esp) 8010183c: e8 ff e7 ff ff call 80100040 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > MAXFILE*BSIZE) return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101841: 01 7d e4 add %edi,-0x1c(%ebp) 80101844: 8b 45 e4 mov -0x1c(%ebp),%eax 80101847: 01 7d e0 add %edi,-0x20(%ebp) 8010184a: 39 45 dc cmp %eax,-0x24(%ebp) 8010184d: 77 8b ja 801017da <writei+0x8a> memmove(bp->data + off%BSIZE, src, m); log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ 8010184f: 3b 73 58 cmp 0x58(%ebx),%esi 80101852: 8b 7d dc mov -0x24(%ebp),%edi 80101855: 77 07 ja 8010185e <writei+0x10e> ip->size = off; iupdate(ip); } return n; 80101857: 89 f8 mov %edi,%eax 80101859: e9 1e ff ff ff jmp 8010177c <writei+0x2c> log_write(bp); brelse(bp); } if(n > 0 && off > ip->size){ ip->size = off; 8010185e: 89 73 58 mov %esi,0x58(%ebx) iupdate(ip); 80101861: 89 1c 24 mov %ebx,(%esp) 80101864: e8 47 fa ff ff call 801012b0 <iupdate> } return n; 80101869: 89 f8 mov %edi,%eax 8010186b: e9 0c ff ff ff jmp 8010177c <writei+0x2c> 80101870 <readi>: //PAGEBREAK! // Read data from inode. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101870: 55 push %ebp 80101871: 89 e5 mov %esp,%ebp 80101873: 83 ec 38 sub $0x38,%esp 80101876: 89 5d f4 mov %ebx,-0xc(%ebp) 80101879: 8b 5d 08 mov 0x8(%ebp),%ebx 8010187c: 89 75 f8 mov %esi,-0x8(%ebp) 8010187f: 8b 4d 14 mov 0x14(%ebp),%ecx 80101882: 89 7d fc mov %edi,-0x4(%ebp) 80101885: 8b 75 10 mov 0x10(%ebp),%esi 80101888: 8b 7d 0c mov 0xc(%ebp),%edi uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 8010188b: 66 83 7b 50 03 cmpw $0x3,0x50(%ebx) 80101890: 74 1e je 801018b0 <readi+0x40> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); } if(off > ip->size || off + n < off) 80101892: 8b 43 58 mov 0x58(%ebx),%eax 80101895: 39 f0 cmp %esi,%eax 80101897: 73 3f jae 801018d8 <readi+0x68> cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; 80101899: b8 ff ff ff ff mov $0xffffffff,%eax } 8010189e: 8b 5d f4 mov -0xc(%ebp),%ebx 801018a1: 8b 75 f8 mov -0x8(%ebp),%esi 801018a4: 8b 7d fc mov -0x4(%ebp),%edi 801018a7: 89 ec mov %ebp,%esp 801018a9: 5d pop %ebp 801018aa: c3 ret 801018ab: 90 nop 801018ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { uint tot, m; struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 801018b0: 0f b7 43 52 movzwl 0x52(%ebx),%eax 801018b4: 66 83 f8 09 cmp $0x9,%ax 801018b8: 77 df ja 80101899 <readi+0x29> 801018ba: 98 cwtl 801018bb: 8b 04 c5 80 09 11 80 mov -0x7feef680(,%eax,8),%eax 801018c2: 85 c0 test %eax,%eax 801018c4: 74 d3 je 80101899 <readi+0x29> return -1; return devsw[ip->major].read(ip, dst, n); 801018c6: 89 4d 10 mov %ecx,0x10(%ebp) */ memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; } 801018c9: 8b 5d f4 mov -0xc(%ebp),%ebx 801018cc: 8b 75 f8 mov -0x8(%ebp),%esi 801018cf: 8b 7d fc mov -0x4(%ebp),%edi 801018d2: 89 ec mov %ebp,%esp 801018d4: 5d pop %ebp struct buf *bp; if(ip->type == T_DEV){ if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); 801018d5: ff e0 jmp *%eax 801018d7: 90 nop } if(off > ip->size || off + n < off) 801018d8: 89 ca mov %ecx,%edx 801018da: 01 f2 add %esi,%edx 801018dc: 89 55 e0 mov %edx,-0x20(%ebp) 801018df: 72 b8 jb 80101899 <readi+0x29> return -1; if(off + n > ip->size) n = ip->size - off; 801018e1: 89 c2 mov %eax,%edx 801018e3: 29 f2 sub %esi,%edx 801018e5: 3b 45 e0 cmp -0x20(%ebp),%eax 801018e8: 0f 42 ca cmovb %edx,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801018eb: 85 c9 test %ecx,%ecx 801018ed: 74 7e je 8010196d <readi+0xfd> 801018ef: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 801018f6: 89 7d e0 mov %edi,-0x20(%ebp) 801018f9: 89 4d dc mov %ecx,-0x24(%ebp) 801018fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101900: 89 f2 mov %esi,%edx 80101902: 89 d8 mov %ebx,%eax 80101904: c1 ea 09 shr $0x9,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101907: bf 00 02 00 00 mov $0x200,%edi return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 8010190c: e8 6f fd ff ff call 80101680 <bmap> 80101911: 89 44 24 04 mov %eax,0x4(%esp) 80101915: 8b 03 mov (%ebx),%eax 80101917: 89 04 24 mov %eax,(%esp) 8010191a: e8 f1 e7 ff ff call 80100110 <bread> m = min(n - tot, BSIZE - off%BSIZE); 8010191f: 8b 4d dc mov -0x24(%ebp),%ecx 80101922: 2b 4d e4 sub -0x1c(%ebp),%ecx return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101925: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101927: 89 f0 mov %esi,%eax 80101929: 25 ff 01 00 00 and $0x1ff,%eax 8010192e: 29 c7 sub %eax,%edi for (int j = 0; j < min(m, 10); j++) { cprintf("%x ", bp->data[off%BSIZE+j]); } cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); 80101930: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 80101934: 39 cf cmp %ecx,%edi for (int j = 0; j < min(m, 10); j++) { cprintf("%x ", bp->data[off%BSIZE+j]); } cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); 80101936: 89 44 24 04 mov %eax,0x4(%esp) 8010193a: 8b 45 e0 mov -0x20(%ebp),%eax if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ bp = bread(ip->dev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); 8010193d: 0f 47 f9 cmova %ecx,%edi for (int j = 0; j < min(m, 10); j++) { cprintf("%x ", bp->data[off%BSIZE+j]); } cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); 80101940: 89 55 d8 mov %edx,-0x28(%ebp) if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101943: 01 fe add %edi,%esi for (int j = 0; j < min(m, 10); j++) { cprintf("%x ", bp->data[off%BSIZE+j]); } cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); 80101945: 89 7c 24 08 mov %edi,0x8(%esp) 80101949: 89 04 24 mov %eax,(%esp) 8010194c: e8 ef 2f 00 00 call 80104940 <memmove> brelse(bp); 80101951: 8b 55 d8 mov -0x28(%ebp),%edx 80101954: 89 14 24 mov %edx,(%esp) 80101957: e8 e4 e6 ff ff call 80100040 <brelse> if(off > ip->size || off + n < off) return -1; if(off + n > ip->size) n = ip->size - off; for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 8010195c: 01 7d e4 add %edi,-0x1c(%ebp) 8010195f: 8b 55 e4 mov -0x1c(%ebp),%edx 80101962: 01 7d e0 add %edi,-0x20(%ebp) 80101965: 39 55 dc cmp %edx,-0x24(%ebp) 80101968: 77 96 ja 80101900 <readi+0x90> 8010196a: 8b 4d dc mov -0x24(%ebp),%ecx cprintf("\n"); */ memmove(dst, bp->data + off%BSIZE, m); brelse(bp); } return n; 8010196d: 89 c8 mov %ecx,%eax 8010196f: e9 2a ff ff ff jmp 8010189e <readi+0x2e> 80101974: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010197a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80101980 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80101980: 55 push %ebp 80101981: 89 e5 mov %esp,%ebp 80101983: 57 push %edi 80101984: 56 push %esi 80101985: 53 push %ebx 80101986: 83 ec 2c sub $0x2c,%esp 80101989: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 8010198c: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101991: 0f 85 8c 00 00 00 jne 80101a23 <dirlookup+0xa3> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101997: 8b 4b 58 mov 0x58(%ebx),%ecx 8010199a: 85 c9 test %ecx,%ecx 8010199c: 74 4c je 801019ea <dirlookup+0x6a> { uint off, inum; struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); 8010199e: 8d 7d d8 lea -0x28(%ebp),%edi 801019a1: 31 f6 xor %esi,%esi 801019a3: 90 nop 801019a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 801019a8: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 801019af: 00 801019b0: 89 74 24 08 mov %esi,0x8(%esp) 801019b4: 89 7c 24 04 mov %edi,0x4(%esp) 801019b8: 89 1c 24 mov %ebx,(%esp) 801019bb: e8 b0 fe ff ff call 80101870 <readi> 801019c0: 83 f8 10 cmp $0x10,%eax 801019c3: 75 52 jne 80101a17 <dirlookup+0x97> panic("dirlink read"); if(de.inum == 0) 801019c5: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 801019ca: 74 16 je 801019e2 <dirlookup+0x62> continue; if(namecmp(name, de.name) == 0){ 801019cc: 8d 45 da lea -0x26(%ebp),%eax 801019cf: 89 44 24 04 mov %eax,0x4(%esp) 801019d3: 8b 45 0c mov 0xc(%ebp),%eax 801019d6: 89 04 24 mov %eax,(%esp) 801019d9: e8 a2 f8 ff ff call 80101280 <namecmp> 801019de: 85 c0 test %eax,%eax 801019e0: 74 16 je 801019f8 <dirlookup+0x78> struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 801019e2: 83 c6 10 add $0x10,%esi 801019e5: 39 73 58 cmp %esi,0x58(%ebx) 801019e8: 77 be ja 801019a8 <dirlookup+0x28> return iget(dp->dev, inum); } } return 0; } 801019ea: 83 c4 2c add $0x2c,%esp struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 801019ed: 31 c0 xor %eax,%eax return iget(dp->dev, inum); } } return 0; } 801019ef: 5b pop %ebx 801019f0: 5e pop %esi 801019f1: 5f pop %edi 801019f2: 5d pop %ebp 801019f3: c3 ret 801019f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi panic("dirlink read"); if(de.inum == 0) continue; if(namecmp(name, de.name) == 0){ // entry matches path element if(poff) 801019f8: 8b 55 10 mov 0x10(%ebp),%edx 801019fb: 85 d2 test %edx,%edx 801019fd: 74 05 je 80101a04 <dirlookup+0x84> *poff = off; 801019ff: 8b 45 10 mov 0x10(%ebp),%eax 80101a02: 89 30 mov %esi,(%eax) inum = de.inum; return iget(dp->dev, inum); 80101a04: 0f b7 55 d8 movzwl -0x28(%ebp),%edx 80101a08: 8b 03 mov (%ebx),%eax 80101a0a: e8 b1 f7 ff ff call 801011c0 <iget> } } return 0; } 80101a0f: 83 c4 2c add $0x2c,%esp 80101a12: 5b pop %ebx 80101a13: 5e pop %esi 80101a14: 5f pop %edi 80101a15: 5d pop %ebp 80101a16: c3 ret if(dp->type != T_DIR) panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink read"); 80101a17: c7 04 24 19 74 10 80 movl $0x80107419,(%esp) 80101a1e: e8 ad e9 ff ff call 801003d0 <panic> { uint off, inum; struct dirent de; if(dp->type != T_DIR) panic("dirlookup not DIR"); 80101a23: c7 04 24 07 74 10 80 movl $0x80107407,(%esp) 80101a2a: e8 a1 e9 ff ff call 801003d0 <panic> 80101a2f: 90 nop 80101a30 <dirlink>: } // Write a new directory entry (name, inum) into the directory dp. int dirlink(struct inode *dp, char *name, uint inum) { 80101a30: 55 push %ebp 80101a31: 89 e5 mov %esp,%ebp 80101a33: 57 push %edi 80101a34: 56 push %esi 80101a35: 53 push %ebx 80101a36: 83 ec 2c sub $0x2c,%esp 80101a39: 8b 75 08 mov 0x8(%ebp),%esi int off; struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ 80101a3c: 8b 45 0c mov 0xc(%ebp),%eax 80101a3f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101a46: 00 80101a47: 89 34 24 mov %esi,(%esp) 80101a4a: 89 44 24 04 mov %eax,0x4(%esp) 80101a4e: e8 2d ff ff ff call 80101980 <dirlookup> 80101a53: 85 c0 test %eax,%eax 80101a55: 0f 85 89 00 00 00 jne 80101ae4 <dirlink+0xb4> iput(ip); return -1; } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80101a5b: 8b 5e 58 mov 0x58(%esi),%ebx 80101a5e: 85 db test %ebx,%ebx 80101a60: 0f 84 8d 00 00 00 je 80101af3 <dirlink+0xc3> struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ iput(ip); return -1; 80101a66: 8d 7d d8 lea -0x28(%ebp),%edi 80101a69: 31 db xor %ebx,%ebx 80101a6b: eb 0b jmp 80101a78 <dirlink+0x48> 80101a6d: 8d 76 00 lea 0x0(%esi),%esi } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80101a70: 83 c3 10 add $0x10,%ebx 80101a73: 39 5e 58 cmp %ebx,0x58(%esi) 80101a76: 76 24 jbe 80101a9c <dirlink+0x6c> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101a78: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101a7f: 00 80101a80: 89 5c 24 08 mov %ebx,0x8(%esp) 80101a84: 89 7c 24 04 mov %edi,0x4(%esp) 80101a88: 89 34 24 mov %esi,(%esp) 80101a8b: e8 e0 fd ff ff call 80101870 <readi> 80101a90: 83 f8 10 cmp $0x10,%eax 80101a93: 75 65 jne 80101afa <dirlink+0xca> panic("dirlink read"); if(de.inum == 0) 80101a95: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101a9a: 75 d4 jne 80101a70 <dirlink+0x40> break; } strncpy(de.name, name, DIRSIZ); 80101a9c: 8b 45 0c mov 0xc(%ebp),%eax 80101a9f: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101aa6: 00 80101aa7: 89 44 24 04 mov %eax,0x4(%esp) 80101aab: 8d 45 da lea -0x26(%ebp),%eax 80101aae: 89 04 24 mov %eax,(%esp) 80101ab1: e8 5a 2f 00 00 call 80104a10 <strncpy> de.inum = inum; 80101ab6: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ab9: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101ac0: 00 80101ac1: 89 5c 24 08 mov %ebx,0x8(%esp) 80101ac5: 89 7c 24 04 mov %edi,0x4(%esp) if(de.inum == 0) break; } strncpy(de.name, name, DIRSIZ); de.inum = inum; 80101ac9: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101acd: 89 34 24 mov %esi,(%esp) 80101ad0: e8 7b fc ff ff call 80101750 <writei> 80101ad5: 83 f8 10 cmp $0x10,%eax 80101ad8: 75 2c jne 80101b06 <dirlink+0xd6> panic("dirlink"); 80101ada: 31 c0 xor %eax,%eax return 0; } 80101adc: 83 c4 2c add $0x2c,%esp 80101adf: 5b pop %ebx 80101ae0: 5e pop %esi 80101ae1: 5f pop %edi 80101ae2: 5d pop %ebp 80101ae3: c3 ret struct dirent de; struct inode *ip; // Check that name is not present. if((ip = dirlookup(dp, name, 0)) != 0){ iput(ip); 80101ae4: 89 04 24 mov %eax,(%esp) 80101ae7: e8 44 f9 ff ff call 80101430 <iput> 80101aec: b8 ff ff ff ff mov $0xffffffff,%eax return -1; 80101af1: eb e9 jmp 80101adc <dirlink+0xac> } // Look for an empty dirent. for(off = 0; off < dp->size; off += sizeof(de)){ 80101af3: 8d 7d d8 lea -0x28(%ebp),%edi 80101af6: 31 db xor %ebx,%ebx 80101af8: eb a2 jmp 80101a9c <dirlink+0x6c> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink read"); 80101afa: c7 04 24 19 74 10 80 movl $0x80107419,(%esp) 80101b01: e8 ca e8 ff ff call 801003d0 <panic> } strncpy(de.name, name, DIRSIZ); de.inum = inum; if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("dirlink"); 80101b06: c7 04 24 62 7a 10 80 movl $0x80107a62,(%esp) 80101b0d: e8 be e8 ff ff call 801003d0 <panic> 80101b12: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101b19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101b20 <ialloc>: //PAGEBREAK! // Allocate a new inode with the given type on device dev. // A free inode has a type of zero. struct inode* ialloc(uint dev, short type) { 80101b20: 55 push %ebp 80101b21: 89 e5 mov %esp,%ebp 80101b23: 57 push %edi 80101b24: 56 push %esi 80101b25: 53 push %ebx 80101b26: 83 ec 2c sub $0x2c,%esp 80101b29: 8b 45 08 mov 0x8(%ebp),%eax int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101b2c: 83 3d e8 09 11 80 01 cmpl $0x1,0x801109e8 //PAGEBREAK! // Allocate a new inode with the given type on device dev. // A free inode has a type of zero. struct inode* ialloc(uint dev, short type) { 80101b33: 89 45 e4 mov %eax,-0x1c(%ebp) 80101b36: 0f b7 45 0c movzwl 0xc(%ebp),%eax 80101b3a: 66 89 45 e2 mov %ax,-0x1e(%ebp) int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101b3e: 0f 86 95 00 00 00 jbe 80101bd9 <ialloc+0xb9> 80101b44: be 01 00 00 00 mov $0x1,%esi 80101b49: bb 01 00 00 00 mov $0x1,%ebx 80101b4e: eb 15 jmp 80101b65 <ialloc+0x45> 80101b50: 83 c3 01 add $0x1,%ebx dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101b53: 89 3c 24 mov %edi,(%esp) { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101b56: 89 de mov %ebx,%esi dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); } brelse(bp); 80101b58: e8 e3 e4 ff ff call 80100040 <brelse> { int inum; struct buf *bp; struct dinode *dip; for(inum = 1; inum < sb.ninodes; inum++){ 80101b5d: 39 1d e8 09 11 80 cmp %ebx,0x801109e8 80101b63: 76 74 jbe 80101bd9 <ialloc+0xb9> bp = bread(dev, IBLOCK(inum, sb)); 80101b65: 89 f0 mov %esi,%eax 80101b67: c1 e8 03 shr $0x3,%eax 80101b6a: 03 05 f4 09 11 80 add 0x801109f4,%eax 80101b70: 89 44 24 04 mov %eax,0x4(%esp) 80101b74: 8b 45 e4 mov -0x1c(%ebp),%eax 80101b77: 89 04 24 mov %eax,(%esp) 80101b7a: e8 91 e5 ff ff call 80100110 <bread> 80101b7f: 89 c7 mov %eax,%edi dip = (struct dinode*)bp->data + inum%IPB; 80101b81: 89 f0 mov %esi,%eax 80101b83: 83 e0 07 and $0x7,%eax 80101b86: c1 e0 06 shl $0x6,%eax 80101b89: 8d 54 07 5c lea 0x5c(%edi,%eax,1),%edx if(dip->type == 0){ // a free inode 80101b8d: 66 83 3a 00 cmpw $0x0,(%edx) 80101b91: 75 bd jne 80101b50 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 80101b93: 89 14 24 mov %edx,(%esp) 80101b96: 89 55 dc mov %edx,-0x24(%ebp) 80101b99: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) 80101ba0: 00 80101ba1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80101ba8: 00 80101ba9: e8 c2 2c 00 00 call 80104870 <memset> dip->type = type; 80101bae: 8b 55 dc mov -0x24(%ebp),%edx 80101bb1: 0f b7 45 e2 movzwl -0x1e(%ebp),%eax 80101bb5: 66 89 02 mov %ax,(%edx) log_write(bp); // mark it allocated on the disk 80101bb8: 89 3c 24 mov %edi,(%esp) 80101bbb: e8 00 0f 00 00 call 80102ac0 <log_write> brelse(bp); 80101bc0: 89 3c 24 mov %edi,(%esp) 80101bc3: e8 78 e4 ff ff call 80100040 <brelse> return iget(dev, inum); 80101bc8: 8b 45 e4 mov -0x1c(%ebp),%eax 80101bcb: 89 f2 mov %esi,%edx } brelse(bp); } panic("ialloc: no inodes"); } 80101bcd: 83 c4 2c add $0x2c,%esp 80101bd0: 5b pop %ebx 80101bd1: 5e pop %esi 80101bd2: 5f pop %edi 80101bd3: 5d pop %ebp if(dip->type == 0){ // a free inode memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); // mark it allocated on the disk brelse(bp); return iget(dev, inum); 80101bd4: e9 e7 f5 ff ff jmp 801011c0 <iget> } brelse(bp); } panic("ialloc: no inodes"); 80101bd9: c7 04 24 26 74 10 80 movl $0x80107426,(%esp) 80101be0: e8 eb e7 ff ff call 801003d0 <panic> 80101be5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101be9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101bf0 <iunlock>: } // Unlock the given inode. void iunlock(struct inode *ip) { 80101bf0: 55 push %ebp 80101bf1: 89 e5 mov %esp,%ebp 80101bf3: 83 ec 18 sub $0x18,%esp 80101bf6: 89 5d f8 mov %ebx,-0x8(%ebp) 80101bf9: 8b 5d 08 mov 0x8(%ebp),%ebx 80101bfc: 89 75 fc mov %esi,-0x4(%ebp) if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 80101bff: 85 db test %ebx,%ebx 80101c01: 74 27 je 80101c2a <iunlock+0x3a> 80101c03: 8d 73 0c lea 0xc(%ebx),%esi 80101c06: 89 34 24 mov %esi,(%esp) 80101c09: e8 22 29 00 00 call 80104530 <holdingsleep> 80101c0e: 85 c0 test %eax,%eax 80101c10: 74 18 je 80101c2a <iunlock+0x3a> 80101c12: 8b 43 08 mov 0x8(%ebx),%eax 80101c15: 85 c0 test %eax,%eax 80101c17: 7e 11 jle 80101c2a <iunlock+0x3a> panic("iunlock"); releasesleep(&ip->lock); 80101c19: 89 75 08 mov %esi,0x8(%ebp) } 80101c1c: 8b 5d f8 mov -0x8(%ebp),%ebx 80101c1f: 8b 75 fc mov -0x4(%ebp),%esi 80101c22: 89 ec mov %ebp,%esp 80101c24: 5d pop %ebp iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); releasesleep(&ip->lock); 80101c25: e9 36 29 00 00 jmp 80104560 <releasesleep> // Unlock the given inode. void iunlock(struct inode *ip) { if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) panic("iunlock"); 80101c2a: c7 04 24 38 74 10 80 movl $0x80107438,(%esp) 80101c31: e8 9a e7 ff ff call 801003d0 <panic> 80101c36: 8d 76 00 lea 0x0(%esi),%esi 80101c39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101c40 <iunlockput>: } // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { 80101c40: 55 push %ebp 80101c41: 89 e5 mov %esp,%ebp 80101c43: 53 push %ebx 80101c44: 83 ec 14 sub $0x14,%esp 80101c47: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 80101c4a: 89 1c 24 mov %ebx,(%esp) 80101c4d: e8 9e ff ff ff call 80101bf0 <iunlock> iput(ip); 80101c52: 89 5d 08 mov %ebx,0x8(%ebp) } 80101c55: 83 c4 14 add $0x14,%esp 80101c58: 5b pop %ebx 80101c59: 5d pop %ebp // Common idiom: unlock, then put. void iunlockput(struct inode *ip) { iunlock(ip); iput(ip); 80101c5a: e9 d1 f7 ff ff jmp 80101430 <iput> 80101c5f: 90 nop 80101c60 <ilock>: // Lock the given inode. // Reads the inode from disk if necessary. void ilock(struct inode *ip) { 80101c60: 55 push %ebp 80101c61: 89 e5 mov %esp,%ebp 80101c63: 56 push %esi 80101c64: 53 push %ebx 80101c65: 83 ec 10 sub $0x10,%esp 80101c68: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) 80101c6b: 85 db test %ebx,%ebx 80101c6d: 0f 84 b0 00 00 00 je 80101d23 <ilock+0xc3> 80101c73: 8b 53 08 mov 0x8(%ebx),%edx 80101c76: 85 d2 test %edx,%edx 80101c78: 0f 8e a5 00 00 00 jle 80101d23 <ilock+0xc3> panic("ilock"); acquiresleep(&ip->lock); 80101c7e: 8d 43 0c lea 0xc(%ebx),%eax 80101c81: 89 04 24 mov %eax,(%esp) 80101c84: e8 17 29 00 00 call 801045a0 <acquiresleep> if(!(ip->flags & I_VALID)){ 80101c89: f6 43 4c 02 testb $0x2,0x4c(%ebx) 80101c8d: 74 09 je 80101c98 <ilock+0x38> brelse(bp); ip->flags |= I_VALID; if(ip->type == 0) panic("ilock: no type"); } } 80101c8f: 83 c4 10 add $0x10,%esp 80101c92: 5b pop %ebx 80101c93: 5e pop %esi 80101c94: 5d pop %ebp 80101c95: c3 ret 80101c96: 66 90 xchg %ax,%ax panic("ilock"); acquiresleep(&ip->lock); if(!(ip->flags & I_VALID)){ bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101c98: 8b 43 04 mov 0x4(%ebx),%eax 80101c9b: c1 e8 03 shr $0x3,%eax 80101c9e: 03 05 f4 09 11 80 add 0x801109f4,%eax 80101ca4: 89 44 24 04 mov %eax,0x4(%esp) 80101ca8: 8b 03 mov (%ebx),%eax 80101caa: 89 04 24 mov %eax,(%esp) 80101cad: e8 5e e4 ff ff call 80100110 <bread> 80101cb2: 89 c6 mov %eax,%esi dip = (struct dinode*)bp->data + ip->inum%IPB; 80101cb4: 8b 43 04 mov 0x4(%ebx),%eax 80101cb7: 83 e0 07 and $0x7,%eax 80101cba: c1 e0 06 shl $0x6,%eax 80101cbd: 8d 44 06 5c lea 0x5c(%esi,%eax,1),%eax ip->type = dip->type; 80101cc1: 0f b7 10 movzwl (%eax),%edx 80101cc4: 66 89 53 50 mov %dx,0x50(%ebx) ip->major = dip->major; 80101cc8: 0f b7 50 02 movzwl 0x2(%eax),%edx 80101ccc: 66 89 53 52 mov %dx,0x52(%ebx) ip->minor = dip->minor; 80101cd0: 0f b7 50 04 movzwl 0x4(%eax),%edx 80101cd4: 66 89 53 54 mov %dx,0x54(%ebx) ip->nlink = dip->nlink; 80101cd8: 0f b7 50 06 movzwl 0x6(%eax),%edx 80101cdc: 66 89 53 56 mov %dx,0x56(%ebx) ip->size = dip->size; 80101ce0: 8b 50 08 mov 0x8(%eax),%edx memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101ce3: 83 c0 0c add $0xc,%eax dip = (struct dinode*)bp->data + ip->inum%IPB; ip->type = dip->type; ip->major = dip->major; ip->minor = dip->minor; ip->nlink = dip->nlink; ip->size = dip->size; 80101ce6: 89 53 58 mov %edx,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101ce9: 89 44 24 04 mov %eax,0x4(%esp) 80101ced: 8d 43 5c lea 0x5c(%ebx),%eax 80101cf0: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 80101cf7: 00 80101cf8: 89 04 24 mov %eax,(%esp) 80101cfb: e8 40 2c 00 00 call 80104940 <memmove> brelse(bp); 80101d00: 89 34 24 mov %esi,(%esp) 80101d03: e8 38 e3 ff ff call 80100040 <brelse> ip->flags |= I_VALID; 80101d08: 83 4b 4c 02 orl $0x2,0x4c(%ebx) if(ip->type == 0) 80101d0c: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) 80101d11: 0f 85 78 ff ff ff jne 80101c8f <ilock+0x2f> panic("ilock: no type"); 80101d17: c7 04 24 46 74 10 80 movl $0x80107446,(%esp) 80101d1e: e8 ad e6 ff ff call 801003d0 <panic> { struct buf *bp; struct dinode *dip; if(ip == 0 || ip->ref < 1) panic("ilock"); 80101d23: c7 04 24 40 74 10 80 movl $0x80107440,(%esp) 80101d2a: e8 a1 e6 ff ff call 801003d0 <panic> 80101d2f: 90 nop 80101d30 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101d30: 55 push %ebp 80101d31: 89 e5 mov %esp,%ebp 80101d33: 57 push %edi 80101d34: 56 push %esi 80101d35: 53 push %ebx 80101d36: 89 c3 mov %eax,%ebx 80101d38: 83 ec 2c sub $0x2c,%esp 80101d3b: 89 55 e0 mov %edx,-0x20(%ebp) 80101d3e: 89 4d e4 mov %ecx,-0x1c(%ebp) struct inode *ip, *next; if(*path == '/') 80101d41: 80 38 2f cmpb $0x2f,(%eax) 80101d44: 0f 84 14 01 00 00 je 80101e5e <namex+0x12e> ip = iget(ROOTDEV, ROOTINO); else ip = idup(proc->cwd); 80101d4a: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80101d50: 8b 40 68 mov 0x68(%eax),%eax 80101d53: 89 04 24 mov %eax,(%esp) 80101d56: e8 35 f4 ff ff call 80101190 <idup> 80101d5b: 89 c7 mov %eax,%edi 80101d5d: eb 04 jmp 80101d63 <namex+0x33> 80101d5f: 90 nop { char *s; int len; while(*path == '/') path++; 80101d60: 83 c3 01 add $0x1,%ebx skipelem(char *path, char *name) { char *s; int len; while(*path == '/') 80101d63: 0f b6 03 movzbl (%ebx),%eax 80101d66: 3c 2f cmp $0x2f,%al 80101d68: 74 f6 je 80101d60 <namex+0x30> path++; if(*path == 0) 80101d6a: 84 c0 test %al,%al 80101d6c: 75 1a jne 80101d88 <namex+0x58> return 0; } iunlockput(ip); ip = next; } if(nameiparent){ 80101d6e: 8b 4d e0 mov -0x20(%ebp),%ecx 80101d71: 85 c9 test %ecx,%ecx 80101d73: 0f 85 0d 01 00 00 jne 80101e86 <namex+0x156> iput(ip); return 0; } return ip; } 80101d79: 83 c4 2c add $0x2c,%esp 80101d7c: 89 f8 mov %edi,%eax 80101d7e: 5b pop %ebx 80101d7f: 5e pop %esi 80101d80: 5f pop %edi 80101d81: 5d pop %ebp 80101d82: c3 ret 80101d83: 90 nop 80101d84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101d88: 3c 2f cmp $0x2f,%al 80101d8a: 0f 84 91 00 00 00 je 80101e21 <namex+0xf1> 80101d90: 89 de mov %ebx,%esi 80101d92: eb 08 jmp 80101d9c <namex+0x6c> 80101d94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101d98: 3c 2f cmp $0x2f,%al 80101d9a: 74 0a je 80101da6 <namex+0x76> path++; 80101d9c: 83 c6 01 add $0x1,%esi while(*path == '/') path++; if(*path == 0) return 0; s = path; while(*path != '/' && *path != 0) 80101d9f: 0f b6 06 movzbl (%esi),%eax 80101da2: 84 c0 test %al,%al 80101da4: 75 f2 jne 80101d98 <namex+0x68> 80101da6: 89 f2 mov %esi,%edx 80101da8: 29 da sub %ebx,%edx path++; len = path - s; if(len >= DIRSIZ) 80101daa: 83 fa 0d cmp $0xd,%edx 80101dad: 7e 79 jle 80101e28 <namex+0xf8> memmove(name, s, DIRSIZ); 80101daf: 8b 45 e4 mov -0x1c(%ebp),%eax 80101db2: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101db9: 00 80101dba: 89 5c 24 04 mov %ebx,0x4(%esp) 80101dbe: 89 04 24 mov %eax,(%esp) 80101dc1: e8 7a 2b 00 00 call 80104940 <memmove> 80101dc6: eb 03 jmp 80101dcb <namex+0x9b> else { memmove(name, s, len); name[len] = 0; } while(*path == '/') path++; 80101dc8: 83 c6 01 add $0x1,%esi memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101dcb: 80 3e 2f cmpb $0x2f,(%esi) 80101dce: 74 f8 je 80101dc8 <namex+0x98> if(*path == '/') ip = iget(ROOTDEV, ROOTINO); else ip = idup(proc->cwd); while((path = skipelem(path, name)) != 0){ 80101dd0: 85 f6 test %esi,%esi 80101dd2: 74 9a je 80101d6e <namex+0x3e> ilock(ip); 80101dd4: 89 3c 24 mov %edi,(%esp) 80101dd7: e8 84 fe ff ff call 80101c60 <ilock> if(ip->type != T_DIR){ 80101ddc: 66 83 7f 50 01 cmpw $0x1,0x50(%edi) 80101de1: 75 67 jne 80101e4a <namex+0x11a> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101de3: 8b 5d e0 mov -0x20(%ebp),%ebx 80101de6: 85 db test %ebx,%ebx 80101de8: 74 09 je 80101df3 <namex+0xc3> 80101dea: 80 3e 00 cmpb $0x0,(%esi) 80101ded: 0f 84 81 00 00 00 je 80101e74 <namex+0x144> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101df3: 8b 45 e4 mov -0x1c(%ebp),%eax 80101df6: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101dfd: 00 80101dfe: 89 3c 24 mov %edi,(%esp) 80101e01: 89 44 24 04 mov %eax,0x4(%esp) 80101e05: e8 76 fb ff ff call 80101980 <dirlookup> 80101e0a: 85 c0 test %eax,%eax 80101e0c: 89 c3 mov %eax,%ebx 80101e0e: 74 3a je 80101e4a <namex+0x11a> iunlockput(ip); return 0; } iunlockput(ip); 80101e10: 89 3c 24 mov %edi,(%esp) 80101e13: 89 df mov %ebx,%edi 80101e15: 89 f3 mov %esi,%ebx 80101e17: e8 24 fe ff ff call 80101c40 <iunlockput> 80101e1c: e9 42 ff ff ff jmp 80101d63 <namex+0x33> memmove(name, s, DIRSIZ); else { memmove(name, s, len); name[len] = 0; } while(*path == '/') 80101e21: 89 de mov %ebx,%esi 80101e23: 31 d2 xor %edx,%edx 80101e25: 8d 76 00 lea 0x0(%esi),%esi path++; len = path - s; if(len >= DIRSIZ) memmove(name, s, DIRSIZ); else { memmove(name, s, len); 80101e28: 8b 45 e4 mov -0x1c(%ebp),%eax 80101e2b: 89 54 24 08 mov %edx,0x8(%esp) 80101e2f: 89 55 dc mov %edx,-0x24(%ebp) 80101e32: 89 5c 24 04 mov %ebx,0x4(%esp) 80101e36: 89 04 24 mov %eax,(%esp) 80101e39: e8 02 2b 00 00 call 80104940 <memmove> name[len] = 0; 80101e3e: 8b 55 dc mov -0x24(%ebp),%edx 80101e41: 8b 45 e4 mov -0x1c(%ebp),%eax 80101e44: c6 04 10 00 movb $0x0,(%eax,%edx,1) 80101e48: eb 81 jmp 80101dcb <namex+0x9b> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ iunlockput(ip); 80101e4a: 89 3c 24 mov %edi,(%esp) 80101e4d: 31 ff xor %edi,%edi 80101e4f: e8 ec fd ff ff call 80101c40 <iunlockput> if(nameiparent){ iput(ip); return 0; } return ip; } 80101e54: 83 c4 2c add $0x2c,%esp 80101e57: 89 f8 mov %edi,%eax 80101e59: 5b pop %ebx 80101e5a: 5e pop %esi 80101e5b: 5f pop %edi 80101e5c: 5d pop %ebp 80101e5d: c3 ret namex(char *path, int nameiparent, char *name) { struct inode *ip, *next; if(*path == '/') ip = iget(ROOTDEV, ROOTINO); 80101e5e: ba 01 00 00 00 mov $0x1,%edx 80101e63: b8 01 00 00 00 mov $0x1,%eax 80101e68: e8 53 f3 ff ff call 801011c0 <iget> 80101e6d: 89 c7 mov %eax,%edi 80101e6f: e9 ef fe ff ff jmp 80101d63 <namex+0x33> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ // Stop one level early. iunlock(ip); 80101e74: 89 3c 24 mov %edi,(%esp) 80101e77: e8 74 fd ff ff call 80101bf0 <iunlock> if(nameiparent){ iput(ip); return 0; } return ip; } 80101e7c: 83 c4 2c add $0x2c,%esp 80101e7f: 89 f8 mov %edi,%eax 80101e81: 5b pop %ebx 80101e82: 5e pop %esi 80101e83: 5f pop %edi 80101e84: 5d pop %ebp 80101e85: c3 ret } iunlockput(ip); ip = next; } if(nameiparent){ iput(ip); 80101e86: 89 3c 24 mov %edi,(%esp) 80101e89: 31 ff xor %edi,%edi 80101e8b: e8 a0 f5 ff ff call 80101430 <iput> return 0; 80101e90: e9 e4 fe ff ff jmp 80101d79 <namex+0x49> 80101e95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101e99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ea0 <nameiparent>: return namex(path, 0, name); } struct inode* nameiparent(char *path, char *name) { 80101ea0: 55 push %ebp return namex(path, 1, name); 80101ea1: ba 01 00 00 00 mov $0x1,%edx return namex(path, 0, name); } struct inode* nameiparent(char *path, char *name) { 80101ea6: 89 e5 mov %esp,%ebp 80101ea8: 83 ec 08 sub $0x8,%esp return namex(path, 1, name); 80101eab: 8b 4d 0c mov 0xc(%ebp),%ecx 80101eae: 8b 45 08 mov 0x8(%ebp),%eax } 80101eb1: c9 leave } struct inode* nameiparent(char *path, char *name) { return namex(path, 1, name); 80101eb2: e9 79 fe ff ff jmp 80101d30 <namex> 80101eb7: 89 f6 mov %esi,%esi 80101eb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ec0 <namei>: return ip; } struct inode* namei(char *path) { 80101ec0: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80101ec1: 31 d2 xor %edx,%edx return ip; } struct inode* namei(char *path) { 80101ec3: 89 e5 mov %esp,%ebp 80101ec5: 83 ec 18 sub $0x18,%esp char name[DIRSIZ]; return namex(path, 0, name); 80101ec8: 8b 45 08 mov 0x8(%ebp),%eax 80101ecb: 8d 4d ea lea -0x16(%ebp),%ecx 80101ece: e8 5d fe ff ff call 80101d30 <namex> } 80101ed3: c9 leave 80101ed4: c3 ret 80101ed5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101ed9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ee0 <iinit>: struct inode inode[NINODE]; } icache; void iinit(int dev) { 80101ee0: 55 push %ebp 80101ee1: 89 e5 mov %esp,%ebp 80101ee3: 53 push %ebx int i = 0; initlock(&icache.lock, "icache"); 80101ee4: 31 db xor %ebx,%ebx struct inode inode[NINODE]; } icache; void iinit(int dev) { 80101ee6: 83 ec 24 sub $0x24,%esp int i = 0; initlock(&icache.lock, "icache"); 80101ee9: c7 44 24 04 55 74 10 movl $0x80107455,0x4(%esp) 80101ef0: 80 80101ef1: c7 04 24 00 0a 11 80 movl $0x80110a00,(%esp) 80101ef8: e8 43 27 00 00 call 80104640 <initlock> 80101efd: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < NINODE; i++) { initsleeplock(&icache.inode[i].lock, "inode"); 80101f00: 8d 04 db lea (%ebx,%ebx,8),%eax iinit(int dev) { int i = 0; initlock(&icache.lock, "icache"); for(i = 0; i < NINODE; i++) { 80101f03: 83 c3 01 add $0x1,%ebx initsleeplock(&icache.inode[i].lock, "inode"); 80101f06: c1 e0 04 shl $0x4,%eax 80101f09: 05 40 0a 11 80 add $0x80110a40,%eax 80101f0e: c7 44 24 04 5c 74 10 movl $0x8010745c,0x4(%esp) 80101f15: 80 80101f16: 89 04 24 mov %eax,(%esp) 80101f19: e8 e2 26 00 00 call 80104600 <initsleeplock> iinit(int dev) { int i = 0; initlock(&icache.lock, "icache"); for(i = 0; i < NINODE; i++) { 80101f1e: 83 fb 32 cmp $0x32,%ebx 80101f21: 75 dd jne 80101f00 <iinit+0x20> initsleeplock(&icache.inode[i].lock, "inode"); } readsb(dev, &sb); 80101f23: 8b 45 08 mov 0x8(%ebp),%eax 80101f26: c7 44 24 04 e0 09 11 movl $0x801109e0,0x4(%esp) 80101f2d: 80 80101f2e: 89 04 24 mov %eax,(%esp) 80101f31: e8 0a f4 ff ff call 80101340 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 80101f36: a1 f8 09 11 80 mov 0x801109f8,%eax 80101f3b: c7 04 24 64 74 10 80 movl $0x80107464,(%esp) 80101f42: 89 44 24 1c mov %eax,0x1c(%esp) 80101f46: a1 f4 09 11 80 mov 0x801109f4,%eax 80101f4b: 89 44 24 18 mov %eax,0x18(%esp) 80101f4f: a1 f0 09 11 80 mov 0x801109f0,%eax 80101f54: 89 44 24 14 mov %eax,0x14(%esp) 80101f58: a1 ec 09 11 80 mov 0x801109ec,%eax 80101f5d: 89 44 24 10 mov %eax,0x10(%esp) 80101f61: a1 e8 09 11 80 mov 0x801109e8,%eax 80101f66: 89 44 24 0c mov %eax,0xc(%esp) 80101f6a: a1 e4 09 11 80 mov 0x801109e4,%eax 80101f6f: 89 44 24 08 mov %eax,0x8(%esp) 80101f73: a1 e0 09 11 80 mov 0x801109e0,%eax 80101f78: 89 44 24 04 mov %eax,0x4(%esp) 80101f7c: e8 ef e8 ff ff call 80100870 <cprintf> inodestart %d bmap start %d\n", sb.size, sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart); } 80101f81: 83 c4 24 add $0x24,%esp 80101f84: 5b pop %ebx 80101f85: 5d pop %ebp 80101f86: c3 ret ... 80101f90 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f90: 55 push %ebp 80101f91: 89 c1 mov %eax,%ecx 80101f93: 89 e5 mov %esp,%ebp 80101f95: 56 push %esi 80101f96: 53 push %ebx 80101f97: 83 ec 10 sub $0x10,%esp if(b == 0) 80101f9a: 85 c0 test %eax,%eax 80101f9c: 0f 84 99 00 00 00 je 8010203b <idestart+0xab> panic("idestart"); if(b->blockno >= FSSIZE) 80101fa2: 8b 58 08 mov 0x8(%eax),%ebx 80101fa5: 81 fb e7 03 00 00 cmp $0x3e7,%ebx 80101fab: 0f 87 7e 00 00 00 ja 8010202f <idestart+0x9f> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101fb1: ba f7 01 00 00 mov $0x1f7,%edx 80101fb6: 66 90 xchg %ax,%ax 80101fb8: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80101fb9: 25 c0 00 00 00 and $0xc0,%eax 80101fbe: 83 f8 40 cmp $0x40,%eax 80101fc1: 75 f5 jne 80101fb8 <idestart+0x28> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80101fc3: 31 f6 xor %esi,%esi 80101fc5: ba f6 03 00 00 mov $0x3f6,%edx 80101fca: 89 f0 mov %esi,%eax 80101fcc: ee out %al,(%dx) 80101fcd: ba f2 01 00 00 mov $0x1f2,%edx 80101fd2: b8 01 00 00 00 mov $0x1,%eax 80101fd7: ee out %al,(%dx) 80101fd8: b2 f3 mov $0xf3,%dl 80101fda: 89 d8 mov %ebx,%eax 80101fdc: ee out %al,(%dx) 80101fdd: 89 d8 mov %ebx,%eax 80101fdf: b2 f4 mov $0xf4,%dl 80101fe1: c1 f8 08 sar $0x8,%eax 80101fe4: ee out %al,(%dx) 80101fe5: b2 f5 mov $0xf5,%dl 80101fe7: 89 f0 mov %esi,%eax 80101fe9: ee out %al,(%dx) 80101fea: 8b 41 04 mov 0x4(%ecx),%eax 80101fed: b2 f6 mov $0xf6,%dl 80101fef: 83 e0 01 and $0x1,%eax 80101ff2: c1 e0 04 shl $0x4,%eax 80101ff5: 83 c8 e0 or $0xffffffe0,%eax 80101ff8: ee out %al,(%dx) outb(0x1f2, sector_per_block); // number of sectors outb(0x1f3, sector & 0xff); outb(0x1f4, (sector >> 8) & 0xff); outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); if(b->flags & B_DIRTY){ 80101ff9: f6 01 04 testb $0x4,(%ecx) 80101ffc: 75 12 jne 80102010 <idestart+0x80> 80101ffe: ba f7 01 00 00 mov $0x1f7,%edx 80102003: b8 20 00 00 00 mov $0x20,%eax 80102008: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 80102009: 83 c4 10 add $0x10,%esp 8010200c: 5b pop %ebx 8010200d: 5e pop %esi 8010200e: 5d pop %ebp 8010200f: c3 ret 80102010: b2 f7 mov $0xf7,%dl 80102012: b8 30 00 00 00 mov $0x30,%eax 80102017: ee out %al,(%dx) } static inline void outsl(int port, const void *addr, int cnt) { asm volatile("cld; rep outsl" : 80102018: ba f0 01 00 00 mov $0x1f0,%edx 8010201d: 8d 71 5c lea 0x5c(%ecx),%esi 80102020: b9 80 00 00 00 mov $0x80,%ecx 80102025: fc cld 80102026: f3 6f rep outsl %ds:(%esi),(%dx) 80102028: 83 c4 10 add $0x10,%esp 8010202b: 5b pop %ebx 8010202c: 5e pop %esi 8010202d: 5d pop %ebp 8010202e: c3 ret idestart(struct buf *b) { if(b == 0) panic("idestart"); if(b->blockno >= FSSIZE) panic("incorrect blockno"); 8010202f: c7 04 24 c0 74 10 80 movl $0x801074c0,(%esp) 80102036: e8 95 e3 ff ff call 801003d0 <panic> // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { if(b == 0) panic("idestart"); 8010203b: c7 04 24 b7 74 10 80 movl $0x801074b7,(%esp) 80102042: e8 89 e3 ff ff call 801003d0 <panic> 80102047: 89 f6 mov %esi,%esi 80102049: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102050 <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 80102050: 55 push %ebp 80102051: 89 e5 mov %esp,%ebp 80102053: 53 push %ebx 80102054: 83 ec 14 sub $0x14,%esp 80102057: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 8010205a: 8d 43 0c lea 0xc(%ebx),%eax 8010205d: 89 04 24 mov %eax,(%esp) 80102060: e8 cb 24 00 00 call 80104530 <holdingsleep> 80102065: 85 c0 test %eax,%eax 80102067: 0f 84 8f 00 00 00 je 801020fc <iderw+0xac> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010206d: 8b 03 mov (%ebx),%eax 8010206f: 83 e0 06 and $0x6,%eax 80102072: 83 f8 02 cmp $0x2,%eax 80102075: 0f 84 99 00 00 00 je 80102114 <iderw+0xc4> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010207b: 8b 53 04 mov 0x4(%ebx),%edx 8010207e: 85 d2 test %edx,%edx 80102080: 74 09 je 8010208b <iderw+0x3b> 80102082: a1 b8 a5 10 80 mov 0x8010a5b8,%eax 80102087: 85 c0 test %eax,%eax 80102089: 74 7d je 80102108 <iderw+0xb8> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 8010208b: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102092: e8 39 27 00 00 call 801047d0 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 80102097: ba b4 a5 10 80 mov $0x8010a5b4,%edx panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock // Append b to idequeue. b->qnext = 0; 8010209c: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) 801020a3: a1 b4 a5 10 80 mov 0x8010a5b4,%eax for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801020a8: 85 c0 test %eax,%eax 801020aa: 74 0e je 801020ba <iderw+0x6a> 801020ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801020b0: 8d 50 58 lea 0x58(%eax),%edx 801020b3: 8b 40 58 mov 0x58(%eax),%eax 801020b6: 85 c0 test %eax,%eax 801020b8: 75 f6 jne 801020b0 <iderw+0x60> ; *pp = b; 801020ba: 89 1a mov %ebx,(%edx) // Start disk if necessary. if(idequeue == b) 801020bc: 39 1d b4 a5 10 80 cmp %ebx,0x8010a5b4 801020c2: 75 14 jne 801020d8 <iderw+0x88> 801020c4: eb 2d jmp 801020f3 <iderw+0xa3> 801020c6: 66 90 xchg %ax,%ax idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ sleep(b, &idelock); 801020c8: c7 44 24 04 80 a5 10 movl $0x8010a580,0x4(%esp) 801020cf: 80 801020d0: 89 1c 24 mov %ebx,(%esp) 801020d3: e8 a8 19 00 00 call 80103a80 <sleep> // Start disk if necessary. if(idequeue == b) idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801020d8: 8b 03 mov (%ebx),%eax 801020da: 83 e0 06 and $0x6,%eax 801020dd: 83 f8 02 cmp $0x2,%eax 801020e0: 75 e6 jne 801020c8 <iderw+0x78> sleep(b, &idelock); } release(&idelock); 801020e2: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) } 801020e9: 83 c4 14 add $0x14,%esp 801020ec: 5b pop %ebx 801020ed: 5d pop %ebp // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ sleep(b, &idelock); } release(&idelock); 801020ee: e9 8d 26 00 00 jmp 80104780 <release> ; *pp = b; // Start disk if necessary. if(idequeue == b) idestart(b); 801020f3: 89 d8 mov %ebx,%eax 801020f5: e8 96 fe ff ff call 80101f90 <idestart> 801020fa: eb dc jmp 801020d8 <iderw+0x88> iderw(struct buf *b) { struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); 801020fc: c7 04 24 d2 74 10 80 movl $0x801074d2,(%esp) 80102103: e8 c8 e2 ff ff call 801003d0 <panic> if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) panic("iderw: ide disk 1 not present"); 80102108: c7 04 24 fd 74 10 80 movl $0x801074fd,(%esp) 8010210f: e8 bc e2 ff ff call 801003d0 <panic> struct buf **pp; if(!holdingsleep(&b->lock)) panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) panic("iderw: nothing to do"); 80102114: c7 04 24 e8 74 10 80 movl $0x801074e8,(%esp) 8010211b: e8 b0 e2 ff ff call 801003d0 <panic> 80102120 <ideintr>: } // Interrupt handler. void ideintr(void) { 80102120: 55 push %ebp 80102121: 89 e5 mov %esp,%ebp 80102123: 57 push %edi 80102124: 53 push %ebx 80102125: 83 ec 10 sub $0x10,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 80102128: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 8010212f: e8 9c 26 00 00 call 801047d0 <acquire> if((b = idequeue) == 0){ 80102134: 8b 1d b4 a5 10 80 mov 0x8010a5b4,%ebx 8010213a: 85 db test %ebx,%ebx 8010213c: 74 2d je 8010216b <ideintr+0x4b> release(&idelock); // cprintf("spurious IDE interrupt\n"); return; } idequeue = b->qnext; 8010213e: 8b 43 58 mov 0x58(%ebx),%eax 80102141: a3 b4 a5 10 80 mov %eax,0x8010a5b4 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 80102146: 8b 0b mov (%ebx),%ecx 80102148: f6 c1 04 test $0x4,%cl 8010214b: 74 33 je 80102180 <ideintr+0x60> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 8010214d: 83 c9 02 or $0x2,%ecx 80102150: 83 e1 fb and $0xfffffffb,%ecx 80102153: 89 0b mov %ecx,(%ebx) wakeup(b); 80102155: 89 1c 24 mov %ebx,(%esp) 80102158: e8 c3 17 00 00 call 80103920 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 8010215d: a1 b4 a5 10 80 mov 0x8010a5b4,%eax 80102162: 85 c0 test %eax,%eax 80102164: 74 05 je 8010216b <ideintr+0x4b> idestart(idequeue); 80102166: e8 25 fe ff ff call 80101f90 <idestart> release(&idelock); 8010216b: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102172: e8 09 26 00 00 call 80104780 <release> } 80102177: 83 c4 10 add $0x10,%esp 8010217a: 5b pop %ebx 8010217b: 5f pop %edi 8010217c: 5d pop %ebp 8010217d: c3 ret 8010217e: 66 90 xchg %ax,%ax static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102180: ba f7 01 00 00 mov $0x1f7,%edx 80102185: 8d 76 00 lea 0x0(%esi),%esi 80102188: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102189: 0f b6 c0 movzbl %al,%eax 8010218c: 89 c7 mov %eax,%edi 8010218e: 81 e7 c0 00 00 00 and $0xc0,%edi 80102194: 83 ff 40 cmp $0x40,%edi 80102197: 75 ef jne 80102188 <ideintr+0x68> ; if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 80102199: a8 21 test $0x21,%al 8010219b: 75 b0 jne 8010214d <ideintr+0x2d> } static inline void insl(int port, void *addr, int cnt) { asm volatile("cld; rep insl" : 8010219d: 8d 7b 5c lea 0x5c(%ebx),%edi 801021a0: b9 80 00 00 00 mov $0x80,%ecx 801021a5: ba f0 01 00 00 mov $0x1f0,%edx 801021aa: fc cld 801021ab: f3 6d rep insl (%dx),%es:(%edi) 801021ad: 8b 0b mov (%ebx),%ecx 801021af: eb 9c jmp 8010214d <ideintr+0x2d> 801021b1: eb 0d jmp 801021c0 <ideinit> 801021b3: 90 nop 801021b4: 90 nop 801021b5: 90 nop 801021b6: 90 nop 801021b7: 90 nop 801021b8: 90 nop 801021b9: 90 nop 801021ba: 90 nop 801021bb: 90 nop 801021bc: 90 nop 801021bd: 90 nop 801021be: 90 nop 801021bf: 90 nop 801021c0 <ideinit>: return 0; } void ideinit(void) { 801021c0: 55 push %ebp 801021c1: 89 e5 mov %esp,%ebp 801021c3: 83 ec 18 sub $0x18,%esp int i; initlock(&idelock, "ide"); 801021c6: c7 44 24 04 1b 75 10 movl $0x8010751b,0x4(%esp) 801021cd: 80 801021ce: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801021d5: e8 66 24 00 00 call 80104640 <initlock> picenable(IRQ_IDE); 801021da: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 801021e1: e8 da 10 00 00 call 801032c0 <picenable> ioapicenable(IRQ_IDE, ncpu - 1); 801021e6: a1 80 2d 11 80 mov 0x80112d80,%eax 801021eb: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 801021f2: 83 e8 01 sub $0x1,%eax 801021f5: 89 44 24 04 mov %eax,0x4(%esp) 801021f9: e8 52 00 00 00 call 80102250 <ioapicenable> static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801021fe: ba f7 01 00 00 mov $0x1f7,%edx 80102203: 90 nop 80102204: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102208: ec in (%dx),%al static int idewait(int checkerr) { int r; while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102209: 25 c0 00 00 00 and $0xc0,%eax 8010220e: 83 f8 40 cmp $0x40,%eax 80102211: 75 f5 jne 80102208 <ideinit+0x48> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102213: ba f6 01 00 00 mov $0x1f6,%edx 80102218: b8 f0 ff ff ff mov $0xfffffff0,%eax 8010221d: ee out %al,(%dx) 8010221e: 31 c9 xor %ecx,%ecx static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102220: b2 f7 mov $0xf7,%dl 80102222: eb 0f jmp 80102233 <ideinit+0x73> 80102224: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ioapicenable(IRQ_IDE, ncpu - 1); idewait(0); // Check if disk 1 is present outb(0x1f6, 0xe0 | (1<<4)); for(i=0; i<1000; i++){ 80102228: 83 c1 01 add $0x1,%ecx 8010222b: 81 f9 e8 03 00 00 cmp $0x3e8,%ecx 80102231: 74 0f je 80102242 <ideinit+0x82> 80102233: ec in (%dx),%al if(inb(0x1f7) != 0){ 80102234: 84 c0 test %al,%al 80102236: 74 f0 je 80102228 <ideinit+0x68> havedisk1 = 1; 80102238: c7 05 b8 a5 10 80 01 movl $0x1,0x8010a5b8 8010223f: 00 00 00 } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102242: ba f6 01 00 00 mov $0x1f6,%edx 80102247: b8 e0 ff ff ff mov $0xffffffe0,%eax 8010224c: ee out %al,(%dx) } } // Switch back to disk 0. outb(0x1f6, 0xe0 | (0<<4)); } 8010224d: c9 leave 8010224e: c3 ret ... 80102250 <ioapicenable>: } void ioapicenable(int irq, int cpunum) { if(!ismp) 80102250: 8b 15 84 27 11 80 mov 0x80112784,%edx } } void ioapicenable(int irq, int cpunum) { 80102256: 55 push %ebp 80102257: 89 e5 mov %esp,%ebp 80102259: 8b 45 08 mov 0x8(%ebp),%eax if(!ismp) 8010225c: 85 d2 test %edx,%edx 8010225e: 74 31 je 80102291 <ioapicenable+0x41> } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102260: 8b 15 54 26 11 80 mov 0x80112654,%edx return; // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 80102266: 8d 48 20 lea 0x20(%eax),%ecx 80102269: 8d 44 00 10 lea 0x10(%eax,%eax,1),%eax } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010226d: 89 02 mov %eax,(%edx) ioapic->data = data; 8010226f: 8b 15 54 26 11 80 mov 0x80112654,%edx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102275: 83 c0 01 add $0x1,%eax ioapic->data = data; 80102278: 89 4a 10 mov %ecx,0x10(%edx) } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010227b: 8b 0d 54 26 11 80 mov 0x80112654,%ecx // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 80102281: 8b 55 0c mov 0xc(%ebp),%edx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102284: 89 01 mov %eax,(%ecx) ioapic->data = data; 80102286: a1 54 26 11 80 mov 0x80112654,%eax // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 8010228b: c1 e2 18 shl $0x18,%edx static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 8010228e: 89 50 10 mov %edx,0x10(%eax) // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); } 80102291: 5d pop %ebp 80102292: c3 ret 80102293: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801022a0 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 801022a0: 55 push %ebp 801022a1: 89 e5 mov %esp,%ebp 801022a3: 56 push %esi 801022a4: 53 push %ebx 801022a5: 83 ec 10 sub $0x10,%esp int i, id, maxintr; if(!ismp) 801022a8: 8b 0d 84 27 11 80 mov 0x80112784,%ecx 801022ae: 85 c9 test %ecx,%ecx 801022b0: 0f 84 9e 00 00 00 je 80102354 <ioapicinit+0xb4> }; static uint ioapicread(int reg) { ioapic->reg = reg; 801022b6: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 801022bd: 00 00 00 return ioapic->data; 801022c0: 8b 35 10 00 c0 fe mov 0xfec00010,%esi return; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 801022c6: bb 00 00 c0 fe mov $0xfec00000,%ebx }; static uint ioapicread(int reg) { ioapic->reg = reg; 801022cb: c7 05 00 00 c0 fe 00 movl $0x0,0xfec00000 801022d2: 00 00 00 return ioapic->data; 801022d5: a1 10 00 c0 fe mov 0xfec00010,%eax return; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 801022da: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx int i, id, maxintr; if(!ismp) return; ioapic = (volatile struct ioapic*)IOAPIC; 801022e1: c7 05 54 26 11 80 00 movl $0xfec00000,0x80112654 801022e8: 00 c0 fe maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 801022eb: c1 ee 10 shr $0x10,%esi id = ioapicread(REG_ID) >> 24; 801022ee: c1 e8 18 shr $0x18,%eax if(!ismp) return; ioapic = (volatile struct ioapic*)IOAPIC; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 801022f1: 81 e6 ff 00 00 00 and $0xff,%esi id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 801022f7: 39 c2 cmp %eax,%edx 801022f9: 74 12 je 8010230d <ioapicinit+0x6d> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 801022fb: c7 04 24 20 75 10 80 movl $0x80107520,(%esp) 80102302: e8 69 e5 ff ff call 80100870 <cprintf> 80102307: 8b 1d 54 26 11 80 mov 0x80112654,%ebx 8010230d: ba 10 00 00 00 mov $0x10,%edx 80102312: 31 c0 xor %eax,%eax 80102314: eb 08 jmp 8010231e <ioapicinit+0x7e> 80102316: 66 90 xchg %ax,%ax // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 80102318: 8b 1d 54 26 11 80 mov 0x80112654,%ebx } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 8010231e: 89 13 mov %edx,(%ebx) ioapic->data = data; 80102320: 8b 1d 54 26 11 80 mov 0x80112654,%ebx cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 80102326: 8d 48 20 lea 0x20(%eax),%ecx 80102329: 81 c9 00 00 01 00 or $0x10000,%ecx if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010232f: 83 c0 01 add $0x1,%eax static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; ioapic->data = data; 80102332: 89 4b 10 mov %ecx,0x10(%ebx) } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102335: 8b 0d 54 26 11 80 mov 0x80112654,%ecx 8010233b: 8d 5a 01 lea 0x1(%edx),%ebx if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 8010233e: 83 c2 02 add $0x2,%edx 80102341: 39 c6 cmp %eax,%esi } static void ioapicwrite(int reg, uint data) { ioapic->reg = reg; 80102343: 89 19 mov %ebx,(%ecx) ioapic->data = data; 80102345: 8b 0d 54 26 11 80 mov 0x80112654,%ecx 8010234b: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) if(id != ioapicid) cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ 80102352: 7d c4 jge 80102318 <ioapicinit+0x78> ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); ioapicwrite(REG_TABLE+2*i+1, 0); } } 80102354: 83 c4 10 add $0x10,%esp 80102357: 5b pop %ebx 80102358: 5e pop %esi 80102359: 5d pop %ebp 8010235a: c3 ret 8010235b: 00 00 add %al,(%eax) 8010235d: 00 00 add %al,(%eax) ... 80102360 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 80102360: 55 push %ebp 80102361: 89 e5 mov %esp,%ebp 80102363: 53 push %ebx 80102364: 83 ec 14 sub $0x14,%esp struct run *r; if(kmem.use_lock) 80102367: 8b 15 94 26 11 80 mov 0x80112694,%edx 8010236d: 85 d2 test %edx,%edx 8010236f: 75 2f jne 801023a0 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 80102371: 8b 1d 98 26 11 80 mov 0x80112698,%ebx if(r) 80102377: 85 db test %ebx,%ebx 80102379: 74 07 je 80102382 <kalloc+0x22> kmem.freelist = r->next; 8010237b: 8b 03 mov (%ebx),%eax 8010237d: a3 98 26 11 80 mov %eax,0x80112698 if(kmem.use_lock) 80102382: a1 94 26 11 80 mov 0x80112694,%eax 80102387: 85 c0 test %eax,%eax 80102389: 74 0c je 80102397 <kalloc+0x37> release(&kmem.lock); 8010238b: c7 04 24 60 26 11 80 movl $0x80112660,(%esp) 80102392: e8 e9 23 00 00 call 80104780 <release> return (char*)r; } 80102397: 89 d8 mov %ebx,%eax 80102399: 83 c4 14 add $0x14,%esp 8010239c: 5b pop %ebx 8010239d: 5d pop %ebp 8010239e: c3 ret 8010239f: 90 nop kalloc(void) { struct run *r; if(kmem.use_lock) acquire(&kmem.lock); 801023a0: c7 04 24 60 26 11 80 movl $0x80112660,(%esp) 801023a7: e8 24 24 00 00 call 801047d0 <acquire> 801023ac: eb c3 jmp 80102371 <kalloc+0x11> 801023ae: 66 90 xchg %ax,%ax 801023b0 <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 801023b0: 55 push %ebp 801023b1: 89 e5 mov %esp,%ebp 801023b3: 53 push %ebx 801023b4: 83 ec 14 sub $0x14,%esp 801023b7: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 801023ba: f7 c3 ff 0f 00 00 test $0xfff,%ebx 801023c0: 75 7c jne 8010243e <kfree+0x8e> 801023c2: 81 fb 28 58 11 80 cmp $0x80115828,%ebx 801023c8: 72 74 jb 8010243e <kfree+0x8e> 801023ca: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 801023d0: 3d ff ff ff 0d cmp $0xdffffff,%eax 801023d5: 77 67 ja 8010243e <kfree+0x8e> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 801023d7: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801023de: 00 801023df: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801023e6: 00 801023e7: 89 1c 24 mov %ebx,(%esp) 801023ea: e8 81 24 00 00 call 80104870 <memset> if(kmem.use_lock) 801023ef: a1 94 26 11 80 mov 0x80112694,%eax 801023f4: 85 c0 test %eax,%eax 801023f6: 75 38 jne 80102430 <kfree+0x80> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 801023f8: a1 98 26 11 80 mov 0x80112698,%eax 801023fd: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 801023ff: 8b 0d 94 26 11 80 mov 0x80112694,%ecx if(kmem.use_lock) acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; 80102405: 89 1d 98 26 11 80 mov %ebx,0x80112698 if(kmem.use_lock) 8010240b: 85 c9 test %ecx,%ecx 8010240d: 75 09 jne 80102418 <kfree+0x68> release(&kmem.lock); } 8010240f: 83 c4 14 add $0x14,%esp 80102412: 5b pop %ebx 80102413: 5d pop %ebp 80102414: c3 ret 80102415: 8d 76 00 lea 0x0(%esi),%esi acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102418: c7 45 08 60 26 11 80 movl $0x80112660,0x8(%ebp) } 8010241f: 83 c4 14 add $0x14,%esp 80102422: 5b pop %ebx 80102423: 5d pop %ebp acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); 80102424: e9 57 23 00 00 jmp 80104780 <release> 80102429: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); if(kmem.use_lock) acquire(&kmem.lock); 80102430: c7 04 24 60 26 11 80 movl $0x80112660,(%esp) 80102437: e8 94 23 00 00 call 801047d0 <acquire> 8010243c: eb ba jmp 801023f8 <kfree+0x48> kfree(char *v) { struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) panic("kfree"); 8010243e: c7 04 24 52 75 10 80 movl $0x80107552,(%esp) 80102445: e8 86 df ff ff call 801003d0 <panic> 8010244a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102450 <freerange>: kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 80102450: 55 push %ebp 80102451: 89 e5 mov %esp,%ebp 80102453: 56 push %esi 80102454: 53 push %ebx 80102455: 83 ec 10 sub $0x10,%esp char *p; p = (char*)PGROUNDUP((uint)vstart); 80102458: 8b 55 08 mov 0x8(%ebp),%edx kmem.use_lock = 1; } void freerange(void *vstart, void *vend) { 8010245b: 8b 75 0c mov 0xc(%ebp),%esi char *p; p = (char*)PGROUNDUP((uint)vstart); 8010245e: 81 c2 ff 0f 00 00 add $0xfff,%edx 80102464: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010246a: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 80102470: 39 f3 cmp %esi,%ebx 80102472: 76 08 jbe 8010247c <freerange+0x2c> 80102474: eb 18 jmp 8010248e <freerange+0x3e> 80102476: 66 90 xchg %ax,%ax 80102478: 89 da mov %ebx,%edx 8010247a: 89 c3 mov %eax,%ebx kfree(p); 8010247c: 89 14 24 mov %edx,(%esp) 8010247f: e8 2c ff ff ff call 801023b0 <kfree> void freerange(void *vstart, void *vend) { char *p; p = (char*)PGROUNDUP((uint)vstart); for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102484: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010248a: 39 f0 cmp %esi,%eax 8010248c: 76 ea jbe 80102478 <freerange+0x28> kfree(p); } 8010248e: 83 c4 10 add $0x10,%esp 80102491: 5b pop %ebx 80102492: 5e pop %esi 80102493: 5d pop %ebp 80102494: c3 ret 80102495: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102499: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801024a0 <kinit2>: freerange(vstart, vend); } void kinit2(void *vstart, void *vend) { 801024a0: 55 push %ebp 801024a1: 89 e5 mov %esp,%ebp 801024a3: 83 ec 18 sub $0x18,%esp freerange(vstart, vend); 801024a6: 8b 45 0c mov 0xc(%ebp),%eax 801024a9: 89 44 24 04 mov %eax,0x4(%esp) 801024ad: 8b 45 08 mov 0x8(%ebp),%eax 801024b0: 89 04 24 mov %eax,(%esp) 801024b3: e8 98 ff ff ff call 80102450 <freerange> kmem.use_lock = 1; 801024b8: c7 05 94 26 11 80 01 movl $0x1,0x80112694 801024bf: 00 00 00 } 801024c2: c9 leave 801024c3: c3 ret 801024c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801024ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801024d0 <kinit1>: // the pages mapped by entrypgdir on free list. // 2. main() calls kinit2() with the rest of the physical pages // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { 801024d0: 55 push %ebp 801024d1: 89 e5 mov %esp,%ebp 801024d3: 83 ec 18 sub $0x18,%esp 801024d6: 89 5d f8 mov %ebx,-0x8(%ebp) 801024d9: 8b 5d 08 mov 0x8(%ebp),%ebx 801024dc: 89 75 fc mov %esi,-0x4(%ebp) 801024df: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 801024e2: c7 44 24 04 58 75 10 movl $0x80107558,0x4(%esp) 801024e9: 80 801024ea: c7 04 24 60 26 11 80 movl $0x80112660,(%esp) 801024f1: e8 4a 21 00 00 call 80104640 <initlock> kmem.use_lock = 0; freerange(vstart, vend); 801024f6: 89 75 0c mov %esi,0xc(%ebp) } 801024f9: 8b 75 fc mov -0x4(%ebp),%esi void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); 801024fc: 89 5d 08 mov %ebx,0x8(%ebp) } 801024ff: 8b 5d f8 mov -0x8(%ebp),%ebx // after installing a full page table that maps them on all cores. void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; 80102502: c7 05 94 26 11 80 00 movl $0x0,0x80112694 80102509: 00 00 00 freerange(vstart, vend); } 8010250c: 89 ec mov %ebp,%esp 8010250e: 5d pop %ebp void kinit1(void *vstart, void *vend) { initlock(&kmem.lock, "kmem"); kmem.use_lock = 0; freerange(vstart, vend); 8010250f: e9 3c ff ff ff jmp 80102450 <freerange> ... 80102520 <kbdgetc>: #include "defs.h" #include "kbd.h" int kbdgetc(void) { 80102520: 55 push %ebp static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102521: ba 64 00 00 00 mov $0x64,%edx 80102526: 89 e5 mov %esp,%ebp 80102528: ec in (%dx),%al 80102529: 89 c2 mov %eax,%edx normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 8010252b: b8 ff ff ff ff mov $0xffffffff,%eax 80102530: 83 e2 01 and $0x1,%edx 80102533: 74 41 je 80102576 <kbdgetc+0x56> 80102535: ba 60 00 00 00 mov $0x60,%edx 8010253a: ec in (%dx),%al return -1; data = inb(KBDATAP); 8010253b: 0f b6 c0 movzbl %al,%eax if(data == 0xE0){ 8010253e: 3d e0 00 00 00 cmp $0xe0,%eax 80102543: 0f 84 7f 00 00 00 je 801025c8 <kbdgetc+0xa8> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102549: 84 c0 test %al,%al 8010254b: 79 2b jns 80102578 <kbdgetc+0x58> // Key released data = (shift & E0ESC ? data : data & 0x7F); 8010254d: 8b 15 bc a5 10 80 mov 0x8010a5bc,%edx 80102553: 89 c1 mov %eax,%ecx 80102555: 83 e1 7f and $0x7f,%ecx 80102558: f6 c2 40 test $0x40,%dl 8010255b: 0f 44 c1 cmove %ecx,%eax shift &= ~(shiftcode[data] | E0ESC); 8010255e: 0f b6 80 60 75 10 80 movzbl -0x7fef8aa0(%eax),%eax 80102565: 83 c8 40 or $0x40,%eax 80102568: 0f b6 c0 movzbl %al,%eax 8010256b: f7 d0 not %eax 8010256d: 21 d0 and %edx,%eax 8010256f: a3 bc a5 10 80 mov %eax,0x8010a5bc 80102574: 31 c0 xor %eax,%eax c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 80102576: 5d pop %ebp 80102577: c3 ret } else if(data & 0x80){ // Key released data = (shift & E0ESC ? data : data & 0x7F); shift &= ~(shiftcode[data] | E0ESC); return 0; } else if(shift & E0ESC){ 80102578: 8b 0d bc a5 10 80 mov 0x8010a5bc,%ecx 8010257e: f6 c1 40 test $0x40,%cl 80102581: 74 05 je 80102588 <kbdgetc+0x68> // Last character was an E0 escape; or with 0x80 data |= 0x80; 80102583: 0c 80 or $0x80,%al shift &= ~E0ESC; 80102585: 83 e1 bf and $0xffffffbf,%ecx } shift |= shiftcode[data]; shift ^= togglecode[data]; 80102588: 0f b6 90 60 75 10 80 movzbl -0x7fef8aa0(%eax),%edx 8010258f: 09 ca or %ecx,%edx 80102591: 0f b6 88 60 76 10 80 movzbl -0x7fef89a0(%eax),%ecx 80102598: 31 ca xor %ecx,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010259a: 89 d1 mov %edx,%ecx 8010259c: 83 e1 03 and $0x3,%ecx 8010259f: 8b 0c 8d 60 77 10 80 mov -0x7fef88a0(,%ecx,4),%ecx data |= 0x80; shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; 801025a6: 89 15 bc a5 10 80 mov %edx,0x8010a5bc c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ 801025ac: 83 e2 08 and $0x8,%edx shift &= ~E0ESC; } shift |= shiftcode[data]; shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; 801025af: 0f b6 04 01 movzbl (%ecx,%eax,1),%eax if(shift & CAPSLOCK){ 801025b3: 74 c1 je 80102576 <kbdgetc+0x56> if('a' <= c && c <= 'z') 801025b5: 8d 50 9f lea -0x61(%eax),%edx 801025b8: 83 fa 19 cmp $0x19,%edx 801025bb: 77 1b ja 801025d8 <kbdgetc+0xb8> c += 'A' - 'a'; 801025bd: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025c0: 5d pop %ebp 801025c1: c3 ret 801025c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if((st & KBS_DIB) == 0) return -1; data = inb(KBDATAP); if(data == 0xE0){ shift |= E0ESC; 801025c8: 30 c0 xor %al,%al 801025ca: 83 0d bc a5 10 80 40 orl $0x40,0x8010a5bc c += 'A' - 'a'; else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025d1: 5d pop %ebp 801025d2: c3 ret 801025d3: 90 nop 801025d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi shift ^= togglecode[data]; c = charcode[shift & (CTL | SHIFT)][data]; if(shift & CAPSLOCK){ if('a' <= c && c <= 'z') c += 'A' - 'a'; else if('A' <= c && c <= 'Z') 801025d8: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 801025db: 8d 50 20 lea 0x20(%eax),%edx 801025de: 83 f9 19 cmp $0x19,%ecx 801025e1: 0f 46 c2 cmovbe %edx,%eax } return c; } 801025e4: 5d pop %ebp 801025e5: c3 ret 801025e6: 8d 76 00 lea 0x0(%esi),%esi 801025e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801025f0 <kbdintr>: void kbdintr(void) { 801025f0: 55 push %ebp 801025f1: 89 e5 mov %esp,%ebp 801025f3: 83 ec 18 sub $0x18,%esp consoleintr(kbdgetc); 801025f6: c7 04 24 20 25 10 80 movl $0x80102520,(%esp) 801025fd: e8 3e e0 ff ff call 80100640 <consoleintr> } 80102602: c9 leave 80102603: c3 ret ... 80102610 <lapicinit>: //PAGEBREAK! void lapicinit(void) { if(!lapic) 80102610: a1 9c 26 11 80 mov 0x8011269c,%eax } //PAGEBREAK! void lapicinit(void) { 80102615: 55 push %ebp 80102616: 89 e5 mov %esp,%ebp if(!lapic) 80102618: 85 c0 test %eax,%eax 8010261a: 0f 84 09 01 00 00 je 80102729 <lapicinit+0x119> volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102620: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102627: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010262a: a1 9c 26 11 80 mov 0x8011269c,%eax 8010262f: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102632: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 80102639: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010263c: a1 9c 26 11 80 mov 0x8011269c,%eax 80102641: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102644: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 8010264b: 00 02 00 lapic[ID]; // wait for write to finish, by reading 8010264e: a1 9c 26 11 80 mov 0x8011269c,%eax 80102653: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102656: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 8010265d: 96 98 00 lapic[ID]; // wait for write to finish, by reading 80102660: a1 9c 26 11 80 mov 0x8011269c,%eax 80102665: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102668: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 8010266f: 00 01 00 lapic[ID]; // wait for write to finish, by reading 80102672: a1 9c 26 11 80 mov 0x8011269c,%eax 80102677: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 8010267a: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 80102681: 00 01 00 lapic[ID]; // wait for write to finish, by reading 80102684: a1 9c 26 11 80 mov 0x8011269c,%eax 80102689: 8b 50 20 mov 0x20(%eax),%edx lapicw(LINT0, MASKED); lapicw(LINT1, MASKED); // Disable performance counter overflow interrupts // on machines that provide that interrupt entry. if(((lapic[VER]>>16) & 0xFF) >= 4) 8010268c: 8b 50 30 mov 0x30(%eax),%edx 8010268f: c1 ea 10 shr $0x10,%edx 80102692: 80 fa 03 cmp $0x3,%dl 80102695: 0f 87 95 00 00 00 ja 80102730 <lapicinit+0x120> volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 8010269b: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 801026a2: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026a5: a1 9c 26 11 80 mov 0x8011269c,%eax 801026aa: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801026ad: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026b4: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026b7: a1 9c 26 11 80 mov 0x8011269c,%eax 801026bc: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801026bf: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026c6: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026c9: a1 9c 26 11 80 mov 0x8011269c,%eax 801026ce: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801026d1: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 801026d8: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026db: a1 9c 26 11 80 mov 0x8011269c,%eax 801026e0: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801026e3: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 801026ea: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026ed: a1 9c 26 11 80 mov 0x8011269c,%eax 801026f2: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801026f5: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 801026fc: 85 08 00 lapic[ID]; // wait for write to finish, by reading 801026ff: 8b 0d 9c 26 11 80 mov 0x8011269c,%ecx 80102705: 8b 41 20 mov 0x20(%ecx),%eax 80102708: 8d 91 00 03 00 00 lea 0x300(%ecx),%edx 8010270e: 66 90 xchg %ax,%ax lapicw(EOI, 0); // Send an Init Level De-Assert to synchronise arbitration ID's. lapicw(ICRHI, 0); lapicw(ICRLO, BCAST | INIT | LEVEL); while(lapic[ICRLO] & DELIVS) 80102710: 8b 02 mov (%edx),%eax 80102712: f6 c4 10 test $0x10,%ah 80102715: 75 f9 jne 80102710 <lapicinit+0x100> volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102717: c7 81 80 00 00 00 00 movl $0x0,0x80(%ecx) 8010271e: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102721: a1 9c 26 11 80 mov 0x8011269c,%eax 80102726: 8b 40 20 mov 0x20(%eax),%eax while(lapic[ICRLO] & DELIVS) ; // Enable interrupts on the APIC (but not on the processor). lapicw(TPR, 0); } 80102729: 5d pop %ebp 8010272a: c3 ret 8010272b: 90 nop 8010272c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102730: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 80102737: 00 01 00 lapic[ID]; // wait for write to finish, by reading 8010273a: a1 9c 26 11 80 mov 0x8011269c,%eax 8010273f: 8b 50 20 mov 0x20(%eax),%edx 80102742: e9 54 ff ff ff jmp 8010269b <lapicinit+0x8b> 80102747: 89 f6 mov %esi,%esi 80102749: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102750 <lapiceoi>: // Acknowledge interrupt. void lapiceoi(void) { if(lapic) 80102750: a1 9c 26 11 80 mov 0x8011269c,%eax } // Acknowledge interrupt. void lapiceoi(void) { 80102755: 55 push %ebp 80102756: 89 e5 mov %esp,%ebp if(lapic) 80102758: 85 c0 test %eax,%eax 8010275a: 74 12 je 8010276e <lapiceoi+0x1e> volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 8010275c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102763: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102766: a1 9c 26 11 80 mov 0x8011269c,%eax 8010276b: 8b 40 20 mov 0x20(%eax),%eax void lapiceoi(void) { if(lapic) lapicw(EOI, 0); } 8010276e: 5d pop %ebp 8010276f: c3 ret 80102770 <microdelay>: // Spin for a given number of microseconds. // On real hardware would want to tune this dynamically. void microdelay(int us) { 80102770: 55 push %ebp 80102771: 89 e5 mov %esp,%ebp } 80102773: 5d pop %ebp 80102774: c3 ret 80102775: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102779: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102780 <lapicstartap>: // Start additional processor running entry code at addr. // See Appendix B of MultiProcessor Specification. void lapicstartap(uchar apicid, uint addr) { 80102780: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102781: ba 70 00 00 00 mov $0x70,%edx 80102786: 89 e5 mov %esp,%ebp 80102788: b8 0f 00 00 00 mov $0xf,%eax 8010278d: 53 push %ebx 8010278e: 8b 4d 0c mov 0xc(%ebp),%ecx 80102791: 0f b6 5d 08 movzbl 0x8(%ebp),%ebx 80102795: ee out %al,(%dx) 80102796: b8 0a 00 00 00 mov $0xa,%eax 8010279b: b2 71 mov $0x71,%dl 8010279d: ee out %al,(%dx) // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; wrv[1] = addr >> 4; 8010279e: 89 c8 mov %ecx,%eax 801027a0: c1 e8 04 shr $0x4,%eax 801027a3: 66 a3 69 04 00 80 mov %ax,0x80000469 volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801027a9: a1 9c 26 11 80 mov 0x8011269c,%eax 801027ae: c1 e3 18 shl $0x18,%ebx // and the warm reset vector (DWORD based at 40:67) to point at // the AP startup code prior to the [universal startup algorithm]." outb(CMOS_PORT, 0xF); // offset 0xF is shutdown code outb(CMOS_PORT+1, 0x0A); wrv = (ushort*)P2V((0x40<<4 | 0x67)); // Warm reset vector wrv[0] = 0; 801027b1: 66 c7 05 67 04 00 80 movw $0x0,0x80000467 801027b8: 00 00 static void lapicw(int index, int value) { lapic[index] = value; lapic[ID]; // wait for write to finish, by reading 801027ba: c1 e9 0c shr $0xc,%ecx 801027bd: 80 cd 06 or $0x6,%ch volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801027c0: 89 98 10 03 00 00 mov %ebx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801027c6: a1 9c 26 11 80 mov 0x8011269c,%eax 801027cb: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801027ce: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 801027d5: c5 00 00 lapic[ID]; // wait for write to finish, by reading 801027d8: a1 9c 26 11 80 mov 0x8011269c,%eax 801027dd: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801027e0: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 801027e7: 85 00 00 lapic[ID]; // wait for write to finish, by reading 801027ea: a1 9c 26 11 80 mov 0x8011269c,%eax 801027ef: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 801027f2: 89 98 10 03 00 00 mov %ebx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801027f8: a1 9c 26 11 80 mov 0x8011269c,%eax 801027fd: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 80102800: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102806: a1 9c 26 11 80 mov 0x8011269c,%eax 8010280b: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 8010280e: 89 98 10 03 00 00 mov %ebx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102814: a1 9c 26 11 80 mov 0x8011269c,%eax 80102819: 8b 50 20 mov 0x20(%eax),%edx volatile uint *lapic; // Initialized in mp.c static void lapicw(int index, int value) { lapic[index] = value; 8010281c: 89 88 00 03 00 00 mov %ecx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102822: a1 9c 26 11 80 mov 0x8011269c,%eax for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 80102827: 5b pop %ebx 80102828: 5d pop %ebp static void lapicw(int index, int value) { lapic[index] = value; lapic[ID]; // wait for write to finish, by reading 80102829: 8b 40 20 mov 0x20(%eax),%eax for(i = 0; i < 2; i++){ lapicw(ICRHI, apicid<<24); lapicw(ICRLO, STARTUP | (addr>>12)); microdelay(200); } } 8010282c: c3 ret 8010282d: 8d 76 00 lea 0x0(%esi),%esi 80102830 <cmostime>: r->year = cmos_read(YEAR); } // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80102830: 55 push %ebp 80102831: ba 70 00 00 00 mov $0x70,%edx 80102836: 89 e5 mov %esp,%ebp 80102838: b8 0b 00 00 00 mov $0xb,%eax 8010283d: 57 push %edi 8010283e: 56 push %esi 8010283f: 53 push %ebx 80102840: 83 ec 6c sub $0x6c,%esp 80102843: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102844: b2 71 mov $0x71,%dl 80102846: ec in (%dx),%al } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102847: bb 70 00 00 00 mov $0x70,%ebx static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010284c: 88 45 a7 mov %al,-0x59(%ebp) 8010284f: 90 nop } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102850: 31 c0 xor %eax,%eax 80102852: 89 da mov %ebx,%edx 80102854: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102855: b9 71 00 00 00 mov $0x71,%ecx 8010285a: 89 ca mov %ecx,%edx 8010285c: ec in (%dx),%al static uint cmos_read(uint reg) { outb(CMOS_PORT, reg); microdelay(200); return inb(CMOS_RETURN); 8010285d: 0f b6 f0 movzbl %al,%esi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102860: 89 da mov %ebx,%edx 80102862: b8 02 00 00 00 mov $0x2,%eax 80102867: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102868: 89 ca mov %ecx,%edx 8010286a: ec in (%dx),%al 8010286b: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010286e: 89 da mov %ebx,%edx 80102870: 89 45 a8 mov %eax,-0x58(%ebp) 80102873: b8 04 00 00 00 mov $0x4,%eax 80102878: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102879: 89 ca mov %ecx,%edx 8010287b: ec in (%dx),%al 8010287c: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010287f: 89 da mov %ebx,%edx 80102881: 89 45 ac mov %eax,-0x54(%ebp) 80102884: b8 07 00 00 00 mov $0x7,%eax 80102889: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010288a: 89 ca mov %ecx,%edx 8010288c: ec in (%dx),%al 8010288d: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102890: 89 da mov %ebx,%edx 80102892: 89 45 b0 mov %eax,-0x50(%ebp) 80102895: b8 08 00 00 00 mov $0x8,%eax 8010289a: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010289b: 89 ca mov %ecx,%edx 8010289d: ec in (%dx),%al 8010289e: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028a1: 89 da mov %ebx,%edx 801028a3: 89 45 b4 mov %eax,-0x4c(%ebp) 801028a6: b8 09 00 00 00 mov $0x9,%eax 801028ab: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028ac: 89 ca mov %ecx,%edx 801028ae: ec in (%dx),%al 801028af: 0f b6 f8 movzbl %al,%edi } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028b2: 89 da mov %ebx,%edx 801028b4: b8 0a 00 00 00 mov $0xa,%eax 801028b9: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028ba: 89 ca mov %ecx,%edx 801028bc: ec in (%dx),%al bcd = (sb & (1 << 2)) == 0; // make sure CMOS doesn't modify time while we read it for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) 801028bd: 84 c0 test %al,%al 801028bf: 78 8f js 80102850 <cmostime+0x20> 801028c1: 8b 45 a8 mov -0x58(%ebp),%eax 801028c4: 8b 55 ac mov -0x54(%ebp),%edx 801028c7: 89 75 d0 mov %esi,-0x30(%ebp) 801028ca: 89 7d e4 mov %edi,-0x1c(%ebp) 801028cd: 89 45 d4 mov %eax,-0x2c(%ebp) 801028d0: 8b 45 b0 mov -0x50(%ebp),%eax 801028d3: 89 55 d8 mov %edx,-0x28(%ebp) 801028d6: 8b 55 b4 mov -0x4c(%ebp),%edx 801028d9: 89 45 dc mov %eax,-0x24(%ebp) } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028dc: 31 c0 xor %eax,%eax 801028de: 89 55 e0 mov %edx,-0x20(%ebp) 801028e1: 89 da mov %ebx,%edx 801028e3: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028e4: 89 ca mov %ecx,%edx 801028e6: ec in (%dx),%al return inb(CMOS_RETURN); } static void fill_rtcdate(struct rtcdate *r) { r->second = cmos_read(SECS); 801028e7: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028ea: 89 da mov %ebx,%edx 801028ec: 89 45 b8 mov %eax,-0x48(%ebp) 801028ef: b8 02 00 00 00 mov $0x2,%eax 801028f4: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801028f5: 89 ca mov %ecx,%edx 801028f7: ec in (%dx),%al r->minute = cmos_read(MINS); 801028f8: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801028fb: 89 da mov %ebx,%edx 801028fd: 89 45 bc mov %eax,-0x44(%ebp) 80102900: b8 04 00 00 00 mov $0x4,%eax 80102905: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102906: 89 ca mov %ecx,%edx 80102908: ec in (%dx),%al r->hour = cmos_read(HOURS); 80102909: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010290c: 89 da mov %ebx,%edx 8010290e: 89 45 c0 mov %eax,-0x40(%ebp) 80102911: b8 07 00 00 00 mov $0x7,%eax 80102916: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102917: 89 ca mov %ecx,%edx 80102919: ec in (%dx),%al r->day = cmos_read(DAY); 8010291a: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010291d: 89 da mov %ebx,%edx 8010291f: 89 45 c4 mov %eax,-0x3c(%ebp) 80102922: b8 08 00 00 00 mov $0x8,%eax 80102927: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102928: 89 ca mov %ecx,%edx 8010292a: ec in (%dx),%al r->month = cmos_read(MONTH); 8010292b: 0f b6 c0 movzbl %al,%eax } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010292e: 89 da mov %ebx,%edx 80102930: 89 45 c8 mov %eax,-0x38(%ebp) 80102933: b8 09 00 00 00 mov $0x9,%eax 80102938: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102939: 89 ca mov %ecx,%edx 8010293b: ec in (%dx),%al r->year = cmos_read(YEAR); 8010293c: 0f b6 c8 movzbl %al,%ecx for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) continue; fill_rtcdate(&t2); if(memcmp(&t1, &t2, sizeof(t1)) == 0) 8010293f: 8d 55 d0 lea -0x30(%ebp),%edx 80102942: 8d 45 b8 lea -0x48(%ebp),%eax r->second = cmos_read(SECS); r->minute = cmos_read(MINS); r->hour = cmos_read(HOURS); r->day = cmos_read(DAY); r->month = cmos_read(MONTH); r->year = cmos_read(YEAR); 80102945: 89 4d cc mov %ecx,-0x34(%ebp) for(;;) { fill_rtcdate(&t1); if(cmos_read(CMOS_STATA) & CMOS_UIP) continue; fill_rtcdate(&t2); if(memcmp(&t1, &t2, sizeof(t1)) == 0) 80102948: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) 8010294f: 00 80102950: 89 44 24 04 mov %eax,0x4(%esp) 80102954: 89 14 24 mov %edx,(%esp) 80102957: e8 84 1f 00 00 call 801048e0 <memcmp> 8010295c: 85 c0 test %eax,%eax 8010295e: 0f 85 ec fe ff ff jne 80102850 <cmostime+0x20> break; } // convert if(bcd) { 80102964: f6 45 a7 04 testb $0x4,-0x59(%ebp) 80102968: 75 78 jne 801029e2 <cmostime+0x1b2> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 8010296a: 8b 45 d0 mov -0x30(%ebp),%eax 8010296d: 89 c2 mov %eax,%edx 8010296f: 83 e0 0f and $0xf,%eax 80102972: c1 ea 04 shr $0x4,%edx 80102975: 8d 14 92 lea (%edx,%edx,4),%edx 80102978: 8d 04 50 lea (%eax,%edx,2),%eax 8010297b: 89 45 d0 mov %eax,-0x30(%ebp) CONV(minute); 8010297e: 8b 45 d4 mov -0x2c(%ebp),%eax 80102981: 89 c2 mov %eax,%edx 80102983: 83 e0 0f and $0xf,%eax 80102986: c1 ea 04 shr $0x4,%edx 80102989: 8d 14 92 lea (%edx,%edx,4),%edx 8010298c: 8d 04 50 lea (%eax,%edx,2),%eax 8010298f: 89 45 d4 mov %eax,-0x2c(%ebp) CONV(hour ); 80102992: 8b 45 d8 mov -0x28(%ebp),%eax 80102995: 89 c2 mov %eax,%edx 80102997: 83 e0 0f and $0xf,%eax 8010299a: c1 ea 04 shr $0x4,%edx 8010299d: 8d 14 92 lea (%edx,%edx,4),%edx 801029a0: 8d 04 50 lea (%eax,%edx,2),%eax 801029a3: 89 45 d8 mov %eax,-0x28(%ebp) CONV(day ); 801029a6: 8b 45 dc mov -0x24(%ebp),%eax 801029a9: 89 c2 mov %eax,%edx 801029ab: 83 e0 0f and $0xf,%eax 801029ae: c1 ea 04 shr $0x4,%edx 801029b1: 8d 14 92 lea (%edx,%edx,4),%edx 801029b4: 8d 04 50 lea (%eax,%edx,2),%eax 801029b7: 89 45 dc mov %eax,-0x24(%ebp) CONV(month ); 801029ba: 8b 45 e0 mov -0x20(%ebp),%eax 801029bd: 89 c2 mov %eax,%edx 801029bf: 83 e0 0f and $0xf,%eax 801029c2: c1 ea 04 shr $0x4,%edx 801029c5: 8d 14 92 lea (%edx,%edx,4),%edx 801029c8: 8d 04 50 lea (%eax,%edx,2),%eax 801029cb: 89 45 e0 mov %eax,-0x20(%ebp) CONV(year ); 801029ce: 8b 45 e4 mov -0x1c(%ebp),%eax 801029d1: 89 c2 mov %eax,%edx 801029d3: 83 e0 0f and $0xf,%eax 801029d6: c1 ea 04 shr $0x4,%edx 801029d9: 8d 14 92 lea (%edx,%edx,4),%edx 801029dc: 8d 04 50 lea (%eax,%edx,2),%eax 801029df: 89 45 e4 mov %eax,-0x1c(%ebp) #undef CONV } *r = t1; 801029e2: 8b 45 d0 mov -0x30(%ebp),%eax 801029e5: 8b 55 08 mov 0x8(%ebp),%edx 801029e8: 89 02 mov %eax,(%edx) 801029ea: 8b 45 d4 mov -0x2c(%ebp),%eax 801029ed: 89 42 04 mov %eax,0x4(%edx) 801029f0: 8b 45 d8 mov -0x28(%ebp),%eax 801029f3: 89 42 08 mov %eax,0x8(%edx) 801029f6: 8b 45 dc mov -0x24(%ebp),%eax 801029f9: 89 42 0c mov %eax,0xc(%edx) 801029fc: 8b 45 e0 mov -0x20(%ebp),%eax 801029ff: 89 42 10 mov %eax,0x10(%edx) 80102a02: 8b 45 e4 mov -0x1c(%ebp),%eax 80102a05: 89 42 14 mov %eax,0x14(%edx) r->year += 2000; 80102a08: 81 42 14 d0 07 00 00 addl $0x7d0,0x14(%edx) } 80102a0f: 83 c4 6c add $0x6c,%esp 80102a12: 5b pop %ebx 80102a13: 5e pop %esi 80102a14: 5f pop %edi 80102a15: 5d pop %ebp 80102a16: c3 ret 80102a17: 89 f6 mov %esi,%esi 80102a19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102a20 <cpunum>: lapicw(TPR, 0); } int cpunum(void) { 80102a20: 55 push %ebp 80102a21: 89 e5 mov %esp,%ebp 80102a23: 56 push %esi 80102a24: 53 push %ebx 80102a25: 83 ec 10 sub $0x10,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80102a28: 9c pushf 80102a29: 58 pop %eax // Cannot call cpu when interrupts are enabled: // result not guaranteed to last long enough to be used! // Would prefer to panic but even printing is chancy here: // almost everything, including cprintf and panic, calls cpu, // often indirectly through acquire and release. if(readeflags()&FL_IF){ 80102a2a: f6 c4 02 test $0x2,%ah 80102a2d: 74 12 je 80102a41 <cpunum+0x21> static int n; if(n++ == 0) 80102a2f: a1 c0 a5 10 80 mov 0x8010a5c0,%eax 80102a34: 8d 50 01 lea 0x1(%eax),%edx 80102a37: 85 c0 test %eax,%eax 80102a39: 89 15 c0 a5 10 80 mov %edx,0x8010a5c0 80102a3f: 74 4a je 80102a8b <cpunum+0x6b> cprintf("cpu called from %x with interrupts enabled\n", __builtin_return_address(0)); } if (!lapic) 80102a41: a1 9c 26 11 80 mov 0x8011269c,%eax 80102a46: 85 c0 test %eax,%eax 80102a48: 74 5d je 80102aa7 <cpunum+0x87> return 0; apicid = lapic[ID] >> 24; for (i = 0; i < ncpu; ++i) { 80102a4a: 8b 35 80 2d 11 80 mov 0x80112d80,%esi } if (!lapic) return 0; apicid = lapic[ID] >> 24; 80102a50: 8b 58 20 mov 0x20(%eax),%ebx for (i = 0; i < ncpu; ++i) { 80102a53: 85 f6 test %esi,%esi 80102a55: 7e 59 jle 80102ab0 <cpunum+0x90> if (cpus[i].apicid == apicid) 80102a57: 0f b6 0d a0 27 11 80 movzbl 0x801127a0,%ecx } if (!lapic) return 0; apicid = lapic[ID] >> 24; 80102a5e: c1 eb 18 shr $0x18,%ebx for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) 80102a61: 31 c0 xor %eax,%eax 80102a63: ba 5c 28 11 80 mov $0x8011285c,%edx 80102a68: 39 d9 cmp %ebx,%ecx 80102a6a: 74 3b je 80102aa7 <cpunum+0x87> 80102a6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if (!lapic) return 0; apicid = lapic[ID] >> 24; for (i = 0; i < ncpu; ++i) { 80102a70: 83 c0 01 add $0x1,%eax 80102a73: 39 f0 cmp %esi,%eax 80102a75: 7d 39 jge 80102ab0 <cpunum+0x90> if (cpus[i].apicid == apicid) 80102a77: 0f b6 0a movzbl (%edx),%ecx 80102a7a: 81 c2 bc 00 00 00 add $0xbc,%edx 80102a80: 39 d9 cmp %ebx,%ecx 80102a82: 75 ec jne 80102a70 <cpunum+0x50> return i; } panic("unknown apicid\n"); } 80102a84: 83 c4 10 add $0x10,%esp 80102a87: 5b pop %ebx 80102a88: 5e pop %esi 80102a89: 5d pop %ebp 80102a8a: c3 ret // almost everything, including cprintf and panic, calls cpu, // often indirectly through acquire and release. if(readeflags()&FL_IF){ static int n; if(n++ == 0) cprintf("cpu called from %x with interrupts enabled\n", 80102a8b: 8b 45 04 mov 0x4(%ebp),%eax 80102a8e: c7 04 24 70 77 10 80 movl $0x80107770,(%esp) 80102a95: 89 44 24 04 mov %eax,0x4(%esp) 80102a99: e8 d2 dd ff ff call 80100870 <cprintf> __builtin_return_address(0)); } if (!lapic) 80102a9e: a1 9c 26 11 80 mov 0x8011269c,%eax 80102aa3: 85 c0 test %eax,%eax 80102aa5: 75 a3 jne 80102a4a <cpunum+0x2a> for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) return i; } panic("unknown apicid\n"); } 80102aa7: 83 c4 10 add $0x10,%esp apicid = lapic[ID] >> 24; for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) return i; } panic("unknown apicid\n"); 80102aaa: 31 c0 xor %eax,%eax } 80102aac: 5b pop %ebx 80102aad: 5e pop %esi 80102aae: 5d pop %ebp 80102aaf: c3 ret apicid = lapic[ID] >> 24; for (i = 0; i < ncpu; ++i) { if (cpus[i].apicid == apicid) return i; } panic("unknown apicid\n"); 80102ab0: c7 04 24 9c 77 10 80 movl $0x8010779c,(%esp) 80102ab7: e8 14 d9 ff ff call 801003d0 <panic> 80102abc: 00 00 add %al,(%eax) ... 80102ac0 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102ac0: 55 push %ebp 80102ac1: 89 e5 mov %esp,%ebp 80102ac3: 53 push %ebx 80102ac4: 83 ec 14 sub $0x14,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102ac7: a1 e8 26 11 80 mov 0x801126e8,%eax // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102acc: 8b 5d 08 mov 0x8(%ebp),%ebx int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102acf: 83 f8 1d cmp $0x1d,%eax 80102ad2: 7f 7e jg 80102b52 <log_write+0x92> 80102ad4: 8b 15 d8 26 11 80 mov 0x801126d8,%edx 80102ada: 83 ea 01 sub $0x1,%edx 80102add: 39 d0 cmp %edx,%eax 80102adf: 7d 71 jge 80102b52 <log_write+0x92> panic("too big a transaction"); if (log.outstanding < 1) 80102ae1: a1 dc 26 11 80 mov 0x801126dc,%eax 80102ae6: 85 c0 test %eax,%eax 80102ae8: 7e 74 jle 80102b5e <log_write+0x9e> panic("log_write outside of trans"); acquire(&log.lock); 80102aea: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102af1: e8 da 1c 00 00 call 801047d0 <acquire> for (i = 0; i < log.lh.n; i++) { 80102af6: 8b 0d e8 26 11 80 mov 0x801126e8,%ecx 80102afc: 85 c9 test %ecx,%ecx 80102afe: 7e 4b jle 80102b4b <log_write+0x8b> if (log.lh.block[i] == b->blockno) // log absorbtion 80102b00: 8b 53 08 mov 0x8(%ebx),%edx 80102b03: 31 c0 xor %eax,%eax 80102b05: 39 15 ec 26 11 80 cmp %edx,0x801126ec 80102b0b: 75 0c jne 80102b19 <log_write+0x59> 80102b0d: eb 11 jmp 80102b20 <log_write+0x60> 80102b0f: 90 nop 80102b10: 3b 14 85 ec 26 11 80 cmp -0x7feed914(,%eax,4),%edx 80102b17: 74 07 je 80102b20 <log_write+0x60> panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102b19: 83 c0 01 add $0x1,%eax 80102b1c: 39 c8 cmp %ecx,%eax 80102b1e: 7c f0 jl 80102b10 <log_write+0x50> if (log.lh.block[i] == b->blockno) // log absorbtion break; } log.lh.block[i] = b->blockno; 80102b20: 89 14 85 ec 26 11 80 mov %edx,-0x7feed914(,%eax,4) if (i == log.lh.n) 80102b27: 39 05 e8 26 11 80 cmp %eax,0x801126e8 80102b2d: 75 08 jne 80102b37 <log_write+0x77> log.lh.n++; 80102b2f: 83 c0 01 add $0x1,%eax 80102b32: a3 e8 26 11 80 mov %eax,0x801126e8 b->flags |= B_DIRTY; // prevent eviction 80102b37: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80102b3a: c7 45 08 a0 26 11 80 movl $0x801126a0,0x8(%ebp) } 80102b41: 83 c4 14 add $0x14,%esp 80102b44: 5b pop %ebx 80102b45: 5d pop %ebp } log.lh.block[i] = b->blockno; if (i == log.lh.n) log.lh.n++; b->flags |= B_DIRTY; // prevent eviction release(&log.lock); 80102b46: e9 35 1c 00 00 jmp 80104780 <release> panic("too big a transaction"); if (log.outstanding < 1) panic("log_write outside of trans"); acquire(&log.lock); for (i = 0; i < log.lh.n; i++) { 80102b4b: 8b 53 08 mov 0x8(%ebx),%edx 80102b4e: 31 c0 xor %eax,%eax 80102b50: eb ce jmp 80102b20 <log_write+0x60> log_write(struct buf *b) { int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) panic("too big a transaction"); 80102b52: c7 04 24 ac 77 10 80 movl $0x801077ac,(%esp) 80102b59: e8 72 d8 ff ff call 801003d0 <panic> if (log.outstanding < 1) panic("log_write outside of trans"); 80102b5e: c7 04 24 c2 77 10 80 movl $0x801077c2,(%esp) 80102b65: e8 66 d8 ff ff call 801003d0 <panic> 80102b6a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102b70 <install_trans>: } // Copy committed blocks from log to their home location static void install_trans(void) { 80102b70: 55 push %ebp 80102b71: 89 e5 mov %esp,%ebp 80102b73: 57 push %edi 80102b74: 56 push %esi 80102b75: 53 push %ebx 80102b76: 83 ec 1c sub $0x1c,%esp int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102b79: 8b 15 e8 26 11 80 mov 0x801126e8,%edx 80102b7f: 85 d2 test %edx,%edx 80102b81: 7e 78 jle 80102bfb <install_trans+0x8b> 80102b83: 31 db xor %ebx,%ebx 80102b85: 8d 76 00 lea 0x0(%esi),%esi struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 80102b88: a1 d4 26 11 80 mov 0x801126d4,%eax 80102b8d: 8d 44 03 01 lea 0x1(%ebx,%eax,1),%eax 80102b91: 89 44 24 04 mov %eax,0x4(%esp) 80102b95: a1 e4 26 11 80 mov 0x801126e4,%eax 80102b9a: 89 04 24 mov %eax,(%esp) 80102b9d: e8 6e d5 ff ff call 80100110 <bread> 80102ba2: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80102ba4: 8b 04 9d ec 26 11 80 mov -0x7feed914(,%ebx,4),%eax static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102bab: 83 c3 01 add $0x1,%ebx struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80102bae: 89 44 24 04 mov %eax,0x4(%esp) 80102bb2: a1 e4 26 11 80 mov 0x801126e4,%eax 80102bb7: 89 04 24 mov %eax,(%esp) 80102bba: e8 51 d5 ff ff call 80100110 <bread> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 80102bbf: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80102bc6: 00 { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80102bc7: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 80102bc9: 8d 47 5c lea 0x5c(%edi),%eax 80102bcc: 89 44 24 04 mov %eax,0x4(%esp) 80102bd0: 8d 46 5c lea 0x5c(%esi),%eax 80102bd3: 89 04 24 mov %eax,(%esp) 80102bd6: e8 65 1d 00 00 call 80104940 <memmove> bwrite(dbuf); // write dst to disk 80102bdb: 89 34 24 mov %esi,(%esp) 80102bde: e8 ed d4 ff ff call 801000d0 <bwrite> brelse(lbuf); 80102be3: 89 3c 24 mov %edi,(%esp) 80102be6: e8 55 d4 ff ff call 80100040 <brelse> brelse(dbuf); 80102beb: 89 34 24 mov %esi,(%esp) 80102bee: e8 4d d4 ff ff call 80100040 <brelse> static void install_trans(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102bf3: 39 1d e8 26 11 80 cmp %ebx,0x801126e8 80102bf9: 7f 8d jg 80102b88 <install_trans+0x18> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk brelse(lbuf); brelse(dbuf); } } 80102bfb: 83 c4 1c add $0x1c,%esp 80102bfe: 5b pop %ebx 80102bff: 5e pop %esi 80102c00: 5f pop %edi 80102c01: 5d pop %ebp 80102c02: c3 ret 80102c03: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102c09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102c10 <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 80102c10: 55 push %ebp 80102c11: 89 e5 mov %esp,%ebp 80102c13: 56 push %esi 80102c14: 53 push %ebx 80102c15: 83 ec 10 sub $0x10,%esp struct buf *buf = bread(log.dev, log.start); 80102c18: a1 d4 26 11 80 mov 0x801126d4,%eax 80102c1d: 89 44 24 04 mov %eax,0x4(%esp) 80102c21: a1 e4 26 11 80 mov 0x801126e4,%eax 80102c26: 89 04 24 mov %eax,(%esp) 80102c29: e8 e2 d4 ff ff call 80100110 <bread> 80102c2e: 89 c6 mov %eax,%esi struct logheader *hb = (struct logheader *) (buf->data); 80102c30: 8d 58 5c lea 0x5c(%eax),%ebx int i; hb->n = log.lh.n; 80102c33: a1 e8 26 11 80 mov 0x801126e8,%eax 80102c38: 89 46 5c mov %eax,0x5c(%esi) for (i = 0; i < log.lh.n; i++) { 80102c3b: 8b 0d e8 26 11 80 mov 0x801126e8,%ecx 80102c41: 85 c9 test %ecx,%ecx 80102c43: 7e 19 jle 80102c5e <write_head+0x4e> 80102c45: 31 d2 xor %edx,%edx 80102c47: 90 nop hb->block[i] = log.lh.block[i]; 80102c48: 8b 0c 95 ec 26 11 80 mov -0x7feed914(,%edx,4),%ecx 80102c4f: 89 4c 93 04 mov %ecx,0x4(%ebx,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; for (i = 0; i < log.lh.n; i++) { 80102c53: 83 c2 01 add $0x1,%edx 80102c56: 39 15 e8 26 11 80 cmp %edx,0x801126e8 80102c5c: 7f ea jg 80102c48 <write_head+0x38> hb->block[i] = log.lh.block[i]; } bwrite(buf); 80102c5e: 89 34 24 mov %esi,(%esp) 80102c61: e8 6a d4 ff ff call 801000d0 <bwrite> brelse(buf); 80102c66: 89 34 24 mov %esi,(%esp) 80102c69: e8 d2 d3 ff ff call 80100040 <brelse> } 80102c6e: 83 c4 10 add $0x10,%esp 80102c71: 5b pop %ebx 80102c72: 5e pop %esi 80102c73: 5d pop %ebp 80102c74: c3 ret 80102c75: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102c79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102c80 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102c80: 55 push %ebp 80102c81: 89 e5 mov %esp,%ebp 80102c83: 57 push %edi 80102c84: 56 push %esi 80102c85: 53 push %ebx 80102c86: 83 ec 1c sub $0x1c,%esp int do_commit = 0; acquire(&log.lock); 80102c89: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102c90: e8 3b 1b 00 00 call 801047d0 <acquire> log.outstanding -= 1; 80102c95: a1 dc 26 11 80 mov 0x801126dc,%eax if(log.committing) 80102c9a: 8b 3d e0 26 11 80 mov 0x801126e0,%edi end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102ca0: 83 e8 01 sub $0x1,%eax if(log.committing) 80102ca3: 85 ff test %edi,%edi end_op(void) { int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; 80102ca5: a3 dc 26 11 80 mov %eax,0x801126dc if(log.committing) 80102caa: 0f 85 f2 00 00 00 jne 80102da2 <end_op+0x122> panic("log.committing"); if(log.outstanding == 0){ 80102cb0: 85 c0 test %eax,%eax 80102cb2: 0f 85 ca 00 00 00 jne 80102d82 <end_op+0x102> do_commit = 1; log.committing = 1; 80102cb8: c7 05 e0 26 11 80 01 movl $0x1,0x801126e0 80102cbf: 00 00 00 } else { // begin_op() may be waiting for log space. wakeup(&log); } release(&log.lock); 80102cc2: 31 db xor %ebx,%ebx 80102cc4: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102ccb: e8 b0 1a 00 00 call 80104780 <release> } static void commit() { if (log.lh.n > 0) { 80102cd0: 8b 35 e8 26 11 80 mov 0x801126e8,%esi 80102cd6: 85 f6 test %esi,%esi 80102cd8: 0f 8e 8e 00 00 00 jle 80102d6c <end_op+0xec> 80102cde: 66 90 xchg %ax,%ax write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *to = bread(log.dev, log.start+tail+1); // log block 80102ce0: a1 d4 26 11 80 mov 0x801126d4,%eax 80102ce5: 8d 44 03 01 lea 0x1(%ebx,%eax,1),%eax 80102ce9: 89 44 24 04 mov %eax,0x4(%esp) 80102ced: a1 e4 26 11 80 mov 0x801126e4,%eax 80102cf2: 89 04 24 mov %eax,(%esp) 80102cf5: e8 16 d4 ff ff call 80100110 <bread> 80102cfa: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102cfc: 8b 04 9d ec 26 11 80 mov -0x7feed914(,%ebx,4),%eax static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102d03: 83 c3 01 add $0x1,%ebx struct buf *to = bread(log.dev, log.start+tail+1); // log block struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102d06: 89 44 24 04 mov %eax,0x4(%esp) 80102d0a: a1 e4 26 11 80 mov 0x801126e4,%eax 80102d0f: 89 04 24 mov %eax,(%esp) 80102d12: e8 f9 d3 ff ff call 80100110 <bread> memmove(to->data, from->data, BSIZE); 80102d17: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80102d1e: 00 { int tail; for (tail = 0; tail < log.lh.n; tail++) { struct buf *to = bread(log.dev, log.start+tail+1); // log block struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102d1f: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102d21: 8d 40 5c lea 0x5c(%eax),%eax 80102d24: 89 44 24 04 mov %eax,0x4(%esp) 80102d28: 8d 46 5c lea 0x5c(%esi),%eax 80102d2b: 89 04 24 mov %eax,(%esp) 80102d2e: e8 0d 1c 00 00 call 80104940 <memmove> bwrite(to); // write the log 80102d33: 89 34 24 mov %esi,(%esp) 80102d36: e8 95 d3 ff ff call 801000d0 <bwrite> brelse(from); 80102d3b: 89 3c 24 mov %edi,(%esp) 80102d3e: e8 fd d2 ff ff call 80100040 <brelse> brelse(to); 80102d43: 89 34 24 mov %esi,(%esp) 80102d46: e8 f5 d2 ff ff call 80100040 <brelse> static void write_log(void) { int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102d4b: 3b 1d e8 26 11 80 cmp 0x801126e8,%ebx 80102d51: 7c 8d jl 80102ce0 <end_op+0x60> static void commit() { if (log.lh.n > 0) { write_log(); // Write modified blocks from cache to log write_head(); // Write header to disk -- the real commit 80102d53: e8 b8 fe ff ff call 80102c10 <write_head> install_trans(); // Now install writes to home locations 80102d58: e8 13 fe ff ff call 80102b70 <install_trans> log.lh.n = 0; 80102d5d: c7 05 e8 26 11 80 00 movl $0x0,0x801126e8 80102d64: 00 00 00 write_head(); // Erase the transaction from the log 80102d67: e8 a4 fe ff ff call 80102c10 <write_head> if(do_commit){ // call commit w/o holding locks, since not allowed // to sleep with locks. commit(); acquire(&log.lock); 80102d6c: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102d73: e8 58 1a 00 00 call 801047d0 <acquire> log.committing = 0; 80102d78: c7 05 e0 26 11 80 00 movl $0x0,0x801126e0 80102d7f: 00 00 00 wakeup(&log); 80102d82: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102d89: e8 92 0b 00 00 call 80103920 <wakeup> release(&log.lock); 80102d8e: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102d95: e8 e6 19 00 00 call 80104780 <release> } } 80102d9a: 83 c4 1c add $0x1c,%esp 80102d9d: 5b pop %ebx 80102d9e: 5e pop %esi 80102d9f: 5f pop %edi 80102da0: 5d pop %ebp 80102da1: c3 ret int do_commit = 0; acquire(&log.lock); log.outstanding -= 1; if(log.committing) panic("log.committing"); 80102da2: c7 04 24 dd 77 10 80 movl $0x801077dd,(%esp) 80102da9: e8 22 d6 ff ff call 801003d0 <panic> 80102dae: 66 90 xchg %ax,%ax 80102db0 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102db0: 55 push %ebp 80102db1: 89 e5 mov %esp,%ebp 80102db3: 83 ec 18 sub $0x18,%esp acquire(&log.lock); 80102db6: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102dbd: e8 0e 1a 00 00 call 801047d0 <acquire> 80102dc2: eb 18 jmp 80102ddc <begin_op+0x2c> 80102dc4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); 80102dc8: c7 44 24 04 a0 26 11 movl $0x801126a0,0x4(%esp) 80102dcf: 80 80102dd0: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102dd7: e8 a4 0c 00 00 call 80103a80 <sleep> void begin_op(void) { acquire(&log.lock); while(1){ if(log.committing){ 80102ddc: a1 e0 26 11 80 mov 0x801126e0,%eax 80102de1: 85 c0 test %eax,%eax 80102de3: 75 e3 jne 80102dc8 <begin_op+0x18> sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102de5: 8b 15 dc 26 11 80 mov 0x801126dc,%edx 80102deb: 83 c2 01 add $0x1,%edx 80102dee: 8d 04 92 lea (%edx,%edx,4),%eax 80102df1: 01 c0 add %eax,%eax 80102df3: 03 05 e8 26 11 80 add 0x801126e8,%eax 80102df9: 83 f8 1e cmp $0x1e,%eax 80102dfc: 7f ca jg 80102dc8 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102dfe: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) sleep(&log, &log.lock); } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; 80102e05: 89 15 dc 26 11 80 mov %edx,0x801126dc release(&log.lock); 80102e0b: e8 70 19 00 00 call 80104780 <release> break; } } } 80102e10: c9 leave 80102e11: c3 ret 80102e12: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102e19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102e20 <initlog>: static void recover_from_log(void); static void commit(); void initlog(int dev) { 80102e20: 55 push %ebp 80102e21: 89 e5 mov %esp,%ebp 80102e23: 56 push %esi 80102e24: 53 push %ebx 80102e25: 83 ec 30 sub $0x30,%esp 80102e28: 8b 5d 08 mov 0x8(%ebp),%ebx if (sizeof(struct logheader) >= BSIZE) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); 80102e2b: c7 44 24 04 ec 77 10 movl $0x801077ec,0x4(%esp) 80102e32: 80 80102e33: c7 04 24 a0 26 11 80 movl $0x801126a0,(%esp) 80102e3a: e8 01 18 00 00 call 80104640 <initlock> readsb(dev, &sb); 80102e3f: 8d 45 dc lea -0x24(%ebp),%eax 80102e42: 89 44 24 04 mov %eax,0x4(%esp) 80102e46: 89 1c 24 mov %ebx,(%esp) 80102e49: e8 f2 e4 ff ff call 80101340 <readsb> log.start = sb.logstart; 80102e4e: 8b 45 ec mov -0x14(%ebp),%eax log.size = sb.nlog; 80102e51: 8b 55 e8 mov -0x18(%ebp),%edx log.dev = dev; 80102e54: 89 1d e4 26 11 80 mov %ebx,0x801126e4 // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102e5a: 89 1c 24 mov %ebx,(%esp) panic("initlog: too big logheader"); struct superblock sb; initlock(&log.lock, "log"); readsb(dev, &sb); log.start = sb.logstart; 80102e5d: a3 d4 26 11 80 mov %eax,0x801126d4 log.size = sb.nlog; 80102e62: 89 15 d8 26 11 80 mov %edx,0x801126d8 // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); 80102e68: 89 44 24 04 mov %eax,0x4(%esp) 80102e6c: e8 9f d2 ff ff call 80100110 <bread> struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102e71: 8b 58 5c mov 0x5c(%eax),%ebx // Read the log header from disk into the in-memory log header static void read_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); 80102e74: 8d 70 5c lea 0x5c(%eax),%esi int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80102e77: 85 db test %ebx,%ebx read_head(void) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; 80102e79: 89 1d e8 26 11 80 mov %ebx,0x801126e8 for (i = 0; i < log.lh.n; i++) { 80102e7f: 7e 19 jle 80102e9a <initlog+0x7a> 80102e81: 31 d2 xor %edx,%edx 80102e83: 90 nop 80102e84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = lh->block[i]; 80102e88: 8b 4c 96 04 mov 0x4(%esi,%edx,4),%ecx 80102e8c: 89 0c 95 ec 26 11 80 mov %ecx,-0x7feed914(,%edx,4) { struct buf *buf = bread(log.dev, log.start); struct logheader *lh = (struct logheader *) (buf->data); int i; log.lh.n = lh->n; for (i = 0; i < log.lh.n; i++) { 80102e93: 83 c2 01 add $0x1,%edx 80102e96: 39 da cmp %ebx,%edx 80102e98: 75 ee jne 80102e88 <initlog+0x68> log.lh.block[i] = lh->block[i]; } brelse(buf); 80102e9a: 89 04 24 mov %eax,(%esp) 80102e9d: e8 9e d1 ff ff call 80100040 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102ea2: e8 c9 fc ff ff call 80102b70 <install_trans> log.lh.n = 0; 80102ea7: c7 05 e8 26 11 80 00 movl $0x0,0x801126e8 80102eae: 00 00 00 write_head(); // clear the log 80102eb1: e8 5a fd ff ff call 80102c10 <write_head> readsb(dev, &sb); log.start = sb.logstart; log.size = sb.nlog; log.dev = dev; recover_from_log(); } 80102eb6: 83 c4 30 add $0x30,%esp 80102eb9: 5b pop %ebx 80102eba: 5e pop %esi 80102ebb: 5d pop %ebp 80102ebc: c3 ret 80102ebd: 00 00 add %al,(%eax) ... 80102ec0 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80102ec0: 55 push %ebp 80102ec1: 89 e5 mov %esp,%ebp 80102ec3: 83 ec 18 sub $0x18,%esp cprintf("cpu%d: starting\n", cpunum()); 80102ec6: e8 55 fb ff ff call 80102a20 <cpunum> 80102ecb: c7 04 24 f0 77 10 80 movl $0x801077f0,(%esp) 80102ed2: 89 44 24 04 mov %eax,0x4(%esp) 80102ed6: e8 95 d9 ff ff call 80100870 <cprintf> idtinit(); // load idt register 80102edb: e8 f0 2b 00 00 call 80105ad0 <idtinit> xchg(&cpu->started, 1); // tell startothers() we're up 80102ee0: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80102ee7: b8 01 00 00 00 mov $0x1,%eax 80102eec: f0 87 82 a8 00 00 00 lock xchg %eax,0xa8(%edx) scheduler(); // start running processes 80102ef3: e8 08 0f 00 00 call 80103e00 <scheduler> 80102ef8: 90 nop 80102ef9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102f00 <main>: // Bootstrap processor starts running C code here. // Allocate a real stack and switch to it, first // doing some setup required for memory allocator to work. int main(void) { 80102f00: 55 push %ebp 80102f01: 89 e5 mov %esp,%ebp 80102f03: 83 e4 f0 and $0xfffffff0,%esp 80102f06: 53 push %ebx 80102f07: 83 ec 1c sub $0x1c,%esp kinit1(end, P2V(4*1024*1024)); // phys page allocator 80102f0a: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) 80102f11: 80 80102f12: c7 04 24 28 58 11 80 movl $0x80115828,(%esp) 80102f19: e8 b2 f5 ff ff call 801024d0 <kinit1> kvmalloc(); // kernel page table 80102f1e: e8 0d 3d 00 00 call 80106c30 <kvmalloc> mpinit(); // detect other processors 80102f23: e8 c8 01 00 00 call 801030f0 <mpinit> lapicinit(); // interrupt controller 80102f28: e8 e3 f6 ff ff call 80102610 <lapicinit> 80102f2d: 8d 76 00 lea 0x0(%esi),%esi seginit(); // segment descriptors 80102f30: e8 8b 42 00 00 call 801071c0 <seginit> cprintf("\ncpu%d: starting xv6\n\n", cpunum()); 80102f35: e8 e6 fa ff ff call 80102a20 <cpunum> 80102f3a: c7 04 24 01 78 10 80 movl $0x80107801,(%esp) 80102f41: 89 44 24 04 mov %eax,0x4(%esp) 80102f45: e8 26 d9 ff ff call 80100870 <cprintf> picinit(); // another interrupt controller 80102f4a: e8 a1 03 00 00 call 801032f0 <picinit> ioapicinit(); // another interrupt controller 80102f4f: e8 4c f3 ff ff call 801022a0 <ioapicinit> consoleinit(); // console hardware 80102f54: e8 17 d3 ff ff call 80100270 <consoleinit> uartinit(); // serial port 80102f59: e8 32 2f 00 00 call 80105e90 <uartinit> 80102f5e: 66 90 xchg %ax,%ax pinit(); // process table 80102f60: e8 ab 15 00 00 call 80104510 <pinit> tvinit(); // trap vectors 80102f65: e8 f6 2d 00 00 call 80105d60 <tvinit> binit(); // buffer cache 80102f6a: e8 71 d2 ff ff call 801001e0 <binit> 80102f6f: 90 nop fileinit(); // file table 80102f70: e8 cb e1 ff ff call 80101140 <fileinit> ideinit(); // disk 80102f75: e8 46 f2 ff ff call 801021c0 <ideinit> if(!ismp) 80102f7a: a1 84 27 11 80 mov 0x80112784,%eax 80102f7f: 85 c0 test %eax,%eax 80102f81: 0f 84 ca 00 00 00 je 80103051 <main+0x151> // Write entry code to unused memory at 0x7000. // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 80102f87: c7 44 24 08 8a 00 00 movl $0x8a,0x8(%esp) 80102f8e: 00 80102f8f: c7 44 24 04 8c a4 10 movl $0x8010a48c,0x4(%esp) 80102f96: 80 80102f97: c7 04 24 00 70 00 80 movl $0x80007000,(%esp) 80102f9e: e8 9d 19 00 00 call 80104940 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 80102fa3: 69 05 80 2d 11 80 bc imul $0xbc,0x80112d80,%eax 80102faa: 00 00 00 80102fad: 05 a0 27 11 80 add $0x801127a0,%eax 80102fb2: 3d a0 27 11 80 cmp $0x801127a0,%eax 80102fb7: 76 7a jbe 80103033 <main+0x133> 80102fb9: bb a0 27 11 80 mov $0x801127a0,%ebx 80102fbe: 66 90 xchg %ax,%ax if(c == cpus+cpunum()) // We've started already. 80102fc0: e8 5b fa ff ff call 80102a20 <cpunum> 80102fc5: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 80102fcb: 05 a0 27 11 80 add $0x801127a0,%eax 80102fd0: 39 c3 cmp %eax,%ebx 80102fd2: 74 46 je 8010301a <main+0x11a> continue; // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80102fd4: e8 87 f3 ff ff call 80102360 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpenter; 80102fd9: c7 05 f8 6f 00 80 60 movl $0x80103060,0x80006ff8 80102fe0: 30 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80102fe3: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 80102fea: 90 10 00 // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); *(void**)(code-4) = stack + KSTACKSIZE; 80102fed: 05 00 10 00 00 add $0x1000,%eax 80102ff2: a3 fc 6f 00 80 mov %eax,0x80006ffc *(void**)(code-8) = mpenter; *(int**)(code-12) = (void *) V2P(entrypgdir); lapicstartap(c->apicid, V2P(code)); 80102ff7: 0f b6 03 movzbl (%ebx),%eax 80102ffa: c7 44 24 04 00 70 00 movl $0x7000,0x4(%esp) 80103001: 00 80103002: 89 04 24 mov %eax,(%esp) 80103005: e8 76 f7 ff ff call 80102780 <lapicstartap> 8010300a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi // wait for cpu to finish mpmain() while(c->started == 0) 80103010: 8b 83 a8 00 00 00 mov 0xa8(%ebx),%eax 80103016: 85 c0 test %eax,%eax 80103018: 74 f6 je 80103010 <main+0x110> // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 8010301a: 69 05 80 2d 11 80 bc imul $0xbc,0x80112d80,%eax 80103021: 00 00 00 80103024: 81 c3 bc 00 00 00 add $0xbc,%ebx 8010302a: 05 a0 27 11 80 add $0x801127a0,%eax 8010302f: 39 c3 cmp %eax,%ebx 80103031: 72 8d jb 80102fc0 <main+0xc0> fileinit(); // file table ideinit(); // disk if(!ismp) timerinit(); // uniprocessor timer startothers(); // start other processors kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 80103033: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) 8010303a: 8e 8010303b: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) 80103042: e8 59 f4 ff ff call 801024a0 <kinit2> userinit(); // first user process 80103047: e8 c4 13 00 00 call 80104410 <userinit> mpmain(); // finish this processor's setup 8010304c: e8 6f fe ff ff call 80102ec0 <mpmain> tvinit(); // trap vectors binit(); // buffer cache fileinit(); // file table ideinit(); // disk if(!ismp) timerinit(); // uniprocessor timer 80103051: e8 1a 2a 00 00 call 80105a70 <timerinit> 80103056: e9 2c ff ff ff jmp 80102f87 <main+0x87> 8010305b: 90 nop 8010305c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103060 <mpenter>: } // Other CPUs jump here from entryother.S. static void mpenter(void) { 80103060: 55 push %ebp 80103061: 89 e5 mov %esp,%ebp 80103063: 83 ec 08 sub $0x8,%esp switchkvm(); 80103066: e8 55 39 00 00 call 801069c0 <switchkvm> seginit(); 8010306b: e8 50 41 00 00 call 801071c0 <seginit> lapicinit(); 80103070: e8 9b f5 ff ff call 80102610 <lapicinit> mpmain(); 80103075: e8 46 fe ff ff call 80102ec0 <mpmain> 8010307a: 00 00 add %al,(%eax) 8010307c: 00 00 add %al,(%eax) ... 80103080 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80103080: 55 push %ebp 80103081: 89 e5 mov %esp,%ebp 80103083: 56 push %esi 80103084: 53 push %ebx uchar *e, *p, *addr; addr = P2V(a); 80103085: 8d 98 00 00 00 80 lea -0x80000000(%eax),%ebx } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 8010308b: 83 ec 10 sub $0x10,%esp uchar *e, *p, *addr; addr = P2V(a); e = addr+len; 8010308e: 8d 34 13 lea (%ebx,%edx,1),%esi for(p = addr; p < e; p += sizeof(struct mp)) 80103091: 39 f3 cmp %esi,%ebx 80103093: 73 3c jae 801030d1 <mpsearch1+0x51> 80103095: 8d 76 00 lea 0x0(%esi),%esi if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80103098: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 8010309f: 00 801030a0: c7 44 24 04 18 78 10 movl $0x80107818,0x4(%esp) 801030a7: 80 801030a8: 89 1c 24 mov %ebx,(%esp) 801030ab: e8 30 18 00 00 call 801048e0 <memcmp> 801030b0: 85 c0 test %eax,%eax 801030b2: 75 16 jne 801030ca <mpsearch1+0x4a> 801030b4: 31 d2 xor %edx,%edx 801030b6: 66 90 xchg %ax,%ax { int i, sum; sum = 0; for(i=0; i<len; i++) sum += addr[i]; 801030b8: 0f b6 0c 03 movzbl (%ebx,%eax,1),%ecx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 801030bc: 83 c0 01 add $0x1,%eax sum += addr[i]; 801030bf: 01 ca add %ecx,%edx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 801030c1: 83 f8 10 cmp $0x10,%eax 801030c4: 75 f2 jne 801030b8 <mpsearch1+0x38> uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 801030c6: 84 d2 test %dl,%dl 801030c8: 74 10 je 801030da <mpsearch1+0x5a> { uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 801030ca: 83 c3 10 add $0x10,%ebx 801030cd: 39 de cmp %ebx,%esi 801030cf: 77 c7 ja 80103098 <mpsearch1+0x18> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; } 801030d1: 83 c4 10 add $0x10,%esp { uchar *e, *p, *addr; addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) 801030d4: 31 c0 xor %eax,%eax if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; return 0; } 801030d6: 5b pop %ebx 801030d7: 5e pop %esi 801030d8: 5d pop %ebp 801030d9: c3 ret 801030da: 83 c4 10 add $0x10,%esp addr = P2V(a); e = addr+len; for(p = addr; p < e; p += sizeof(struct mp)) if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) return (struct mp*)p; 801030dd: 89 d8 mov %ebx,%eax return 0; } 801030df: 5b pop %ebx 801030e0: 5e pop %esi 801030e1: 5d pop %ebp 801030e2: c3 ret 801030e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801030e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801030f0 <mpinit>: return conf; } void mpinit(void) { 801030f0: 55 push %ebp 801030f1: 89 e5 mov %esp,%ebp 801030f3: 57 push %edi 801030f4: 56 push %esi 801030f5: 53 push %ebx 801030f6: 83 ec 2c sub $0x2c,%esp uchar *bda; uint p; struct mp *mp; bda = (uchar *) P2V(0x400); if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 801030f9: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80103100: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80103107: c1 e0 08 shl $0x8,%eax 8010310a: 09 d0 or %edx,%eax 8010310c: c1 e0 04 shl $0x4,%eax 8010310f: 85 c0 test %eax,%eax 80103111: 75 1b jne 8010312e <mpinit+0x3e> if((mp = mpsearch1(p, 1024))) return mp; } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) 80103113: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 8010311a: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80103121: c1 e0 08 shl $0x8,%eax 80103124: 09 d0 or %edx,%eax 80103126: c1 e0 0a shl $0xa,%eax 80103129: 2d 00 04 00 00 sub $0x400,%eax 8010312e: ba 00 04 00 00 mov $0x400,%edx 80103133: e8 48 ff ff ff call 80103080 <mpsearch1> 80103138: 85 c0 test %eax,%eax 8010313a: 89 c6 mov %eax,%esi 8010313c: 0f 84 a6 00 00 00 je 801031e8 <mpinit+0xf8> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103142: 8b 7e 04 mov 0x4(%esi),%edi 80103145: 85 ff test %edi,%edi 80103147: 75 08 jne 80103151 <mpinit+0x61> // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. } } 80103149: 83 c4 2c add $0x2c,%esp 8010314c: 5b pop %ebx 8010314d: 5e pop %esi 8010314e: 5f pop %edi 8010314f: 5d pop %ebp 80103150: c3 ret struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) return 0; conf = (struct mpconf*) P2V((uint) mp->physaddr); 80103151: 8d 9f 00 00 00 80 lea -0x80000000(%edi),%ebx if(memcmp(conf, "PCMP", 4) != 0) 80103157: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 8010315e: 00 8010315f: c7 44 24 04 1d 78 10 movl $0x8010781d,0x4(%esp) 80103166: 80 80103167: 89 1c 24 mov %ebx,(%esp) 8010316a: e8 71 17 00 00 call 801048e0 <memcmp> 8010316f: 85 c0 test %eax,%eax 80103171: 75 d6 jne 80103149 <mpinit+0x59> return 0; if(conf->version != 1 && conf->version != 4) 80103173: 0f b6 43 06 movzbl 0x6(%ebx),%eax 80103177: 3c 04 cmp $0x4,%al 80103179: 74 04 je 8010317f <mpinit+0x8f> 8010317b: 3c 01 cmp $0x1,%al 8010317d: 75 ca jne 80103149 <mpinit+0x59> *pmp = mp; return conf; } void mpinit(void) 8010317f: 0f b7 53 04 movzwl 0x4(%ebx),%edx conf = (struct mpconf*) P2V((uint) mp->physaddr); if(memcmp(conf, "PCMP", 4) != 0) return 0; if(conf->version != 1 && conf->version != 4) return 0; if(sum((uchar*)conf, conf->length) != 0) 80103183: 89 d8 mov %ebx,%eax *pmp = mp; return conf; } void mpinit(void) 80103185: 8d 8c 17 00 00 00 80 lea -0x80000000(%edi,%edx,1),%ecx 8010318c: 31 d2 xor %edx,%edx 8010318e: eb 08 jmp 80103198 <mpinit+0xa8> { int i, sum; sum = 0; for(i=0; i<len; i++) sum += addr[i]; 80103190: 0f b6 38 movzbl (%eax),%edi 80103193: 83 c0 01 add $0x1,%eax 80103196: 01 fa add %edi,%edx sum(uchar *addr, int len) { int i, sum; sum = 0; for(i=0; i<len; i++) 80103198: 39 c8 cmp %ecx,%eax 8010319a: 75 f4 jne 80103190 <mpinit+0xa0> conf = (struct mpconf*) P2V((uint) mp->physaddr); if(memcmp(conf, "PCMP", 4) != 0) return 0; if(conf->version != 1 && conf->version != 4) return 0; if(sum((uchar*)conf, conf->length) != 0) 8010319c: 84 d2 test %dl,%dl 8010319e: 75 a9 jne 80103149 <mpinit+0x59> struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) return; ismp = 1; 801031a0: c7 05 84 27 11 80 01 movl $0x1,0x80112784 801031a7: 00 00 00 lapic = (uint*)conf->lapicaddr; 801031aa: 8b 43 24 mov 0x24(%ebx),%eax 801031ad: a3 9c 26 11 80 mov %eax,0x8011269c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801031b2: 0f b7 53 04 movzwl 0x4(%ebx),%edx 801031b6: 8d 43 2c lea 0x2c(%ebx),%eax 801031b9: 01 d3 add %edx,%ebx 801031bb: 39 d8 cmp %ebx,%eax 801031bd: 72 17 jb 801031d6 <mpinit+0xe6> 801031bf: eb 5f jmp 80103220 <mpinit+0x130> 801031c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi case MPIOINTR: case MPLINTR: p += 8; continue; default: ismp = 0; 801031c8: c7 05 84 27 11 80 00 movl $0x0,0x80112784 801031cf: 00 00 00 if((conf = mpconfig(&mp)) == 0) return; ismp = 1; lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801031d2: 39 c3 cmp %eax,%ebx 801031d4: 76 41 jbe 80103217 <mpinit+0x127> switch(*p){ 801031d6: 80 38 04 cmpb $0x4,(%eax) 801031d9: 77 ed ja 801031c8 <mpinit+0xd8> 801031db: 0f b6 10 movzbl (%eax),%edx 801031de: ff 24 95 24 78 10 80 jmp *-0x7fef87dc(,%edx,4) 801031e5: 8d 76 00 lea 0x0(%esi),%esi } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 801031e8: ba 00 00 01 00 mov $0x10000,%edx 801031ed: b8 00 00 0f 00 mov $0xf0000,%eax 801031f2: e8 89 fe ff ff call 80103080 <mpsearch1> mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 801031f7: 85 c0 test %eax,%eax } else { p = ((bda[0x14]<<8)|bda[0x13])*1024; if((mp = mpsearch1(p-1024, 1024))) return mp; } return mpsearch1(0xF0000, 0x10000); 801031f9: 89 c6 mov %eax,%esi mpconfig(struct mp **pmp) { struct mpconf *conf; struct mp *mp; if((mp = mpsearch()) == 0 || mp->physaddr == 0) 801031fb: 0f 85 41 ff ff ff jne 80103142 <mpinit+0x52> // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. } } 80103201: 83 c4 2c add $0x2c,%esp 80103204: 5b pop %ebx 80103205: 5e pop %esi 80103206: 5f pop %edi 80103207: 5d pop %ebp 80103208: c3 ret 80103209: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi p += sizeof(struct mpioapic); continue; case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 80103210: 83 c0 08 add $0x8,%eax if((conf = mpconfig(&mp)) == 0) return; ismp = 1; lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 80103213: 39 c3 cmp %eax,%ebx 80103215: 77 bf ja 801031d6 <mpinit+0xe6> default: ismp = 0; break; } } if(!ismp){ 80103217: a1 84 27 11 80 mov 0x80112784,%eax 8010321c: 85 c0 test %eax,%eax 8010321e: 74 70 je 80103290 <mpinit+0x1a0> lapic = 0; ioapicid = 0; return; } if(mp->imcrp){ 80103220: 80 7e 0c 00 cmpb $0x0,0xc(%esi) 80103224: 0f 84 1f ff ff ff je 80103149 <mpinit+0x59> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010322a: ba 22 00 00 00 mov $0x22,%edx 8010322f: b8 70 00 00 00 mov $0x70,%eax 80103234: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80103235: b2 23 mov $0x23,%dl 80103237: ec in (%dx),%al } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80103238: 83 c8 01 or $0x1,%eax 8010323b: ee out %al,(%dx) // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. } } 8010323c: 83 c4 2c add $0x2c,%esp 8010323f: 5b pop %ebx 80103240: 5e pop %esi 80103241: 5f pop %edi 80103242: 5d pop %ebp 80103243: c3 ret 80103244: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi lapic = (uint*)conf->lapicaddr; for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { 80103248: 8b 15 80 2d 11 80 mov 0x80112d80,%edx 8010324e: 83 fa 07 cmp $0x7,%edx 80103251: 7f 1b jg 8010326e <mpinit+0x17e> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 80103253: 69 ca bc 00 00 00 imul $0xbc,%edx,%ecx ncpu++; 80103259: 83 c2 01 add $0x1,%edx for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 8010325c: 89 cf mov %ecx,%edi 8010325e: 0f b6 48 01 movzbl 0x1(%eax),%ecx ncpu++; 80103262: 89 15 80 2d 11 80 mov %edx,0x80112d80 for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ switch(*p){ case MPPROC: proc = (struct mpproc*)p; if(ncpu < NCPU) { cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 80103268: 88 8f a0 27 11 80 mov %cl,-0x7feed860(%edi) ncpu++; } p += sizeof(struct mpproc); 8010326e: 83 c0 14 add $0x14,%eax continue; 80103271: e9 5c ff ff ff jmp 801031d2 <mpinit+0xe2> 80103276: 66 90 xchg %ax,%ax case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 80103278: 0f b6 50 01 movzbl 0x1(%eax),%edx p += sizeof(struct mpioapic); 8010327c: 83 c0 08 add $0x8,%eax } p += sizeof(struct mpproc); continue; case MPIOAPIC: ioapic = (struct mpioapic*)p; ioapicid = ioapic->apicno; 8010327f: 88 15 80 27 11 80 mov %dl,0x80112780 p += sizeof(struct mpioapic); continue; 80103285: e9 48 ff ff ff jmp 801031d2 <mpinit+0xe2> 8010328a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi break; } } if(!ismp){ // Didn't like what we found; fall back to no MP. ncpu = 1; 80103290: c7 05 80 2d 11 80 01 movl $0x1,0x80112d80 80103297: 00 00 00 lapic = 0; 8010329a: c7 05 9c 26 11 80 00 movl $0x0,0x8011269c 801032a1: 00 00 00 ioapicid = 0; 801032a4: c6 05 80 27 11 80 00 movb $0x0,0x80112780 // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. } } 801032ab: 83 c4 2c add $0x2c,%esp 801032ae: 5b pop %ebx 801032af: 5e pop %esi 801032b0: 5f pop %edi 801032b1: 5d pop %ebp 801032b2: c3 ret ... 801032c0 <picenable>: outb(IO_PIC2+1, mask >> 8); } void picenable(int irq) { 801032c0: 55 push %ebp picsetmask(irqmask & ~(1<<irq)); 801032c1: b8 fe ff ff ff mov $0xfffffffe,%eax outb(IO_PIC2+1, mask >> 8); } void picenable(int irq) { 801032c6: 89 e5 mov %esp,%ebp 801032c8: ba 21 00 00 00 mov $0x21,%edx picsetmask(irqmask & ~(1<<irq)); 801032cd: 8b 4d 08 mov 0x8(%ebp),%ecx 801032d0: d3 c0 rol %cl,%eax 801032d2: 66 23 05 00 a0 10 80 and 0x8010a000,%ax static ushort irqmask = 0xFFFF & ~(1<<IRQ_SLAVE); static void picsetmask(ushort mask) { irqmask = mask; 801032d9: 66 a3 00 a0 10 80 mov %ax,0x8010a000 801032df: ee out %al,(%dx) 801032e0: 66 c1 e8 08 shr $0x8,%ax 801032e4: b2 a1 mov $0xa1,%dl 801032e6: ee out %al,(%dx) void picenable(int irq) { picsetmask(irqmask & ~(1<<irq)); } 801032e7: 5d pop %ebp 801032e8: c3 ret 801032e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801032f0 <picinit>: // Initialize the 8259A interrupt controllers. void picinit(void) { 801032f0: 55 push %ebp 801032f1: b9 21 00 00 00 mov $0x21,%ecx 801032f6: 89 e5 mov %esp,%ebp 801032f8: 83 ec 0c sub $0xc,%esp 801032fb: 89 1c 24 mov %ebx,(%esp) 801032fe: b8 ff ff ff ff mov $0xffffffff,%eax 80103303: 89 ca mov %ecx,%edx 80103305: 89 74 24 04 mov %esi,0x4(%esp) 80103309: 89 7c 24 08 mov %edi,0x8(%esp) 8010330d: ee out %al,(%dx) 8010330e: bb a1 00 00 00 mov $0xa1,%ebx 80103313: 89 da mov %ebx,%edx 80103315: ee out %al,(%dx) 80103316: be 11 00 00 00 mov $0x11,%esi 8010331b: b2 20 mov $0x20,%dl 8010331d: 89 f0 mov %esi,%eax 8010331f: ee out %al,(%dx) 80103320: b8 20 00 00 00 mov $0x20,%eax 80103325: 89 ca mov %ecx,%edx 80103327: ee out %al,(%dx) 80103328: b8 04 00 00 00 mov $0x4,%eax 8010332d: ee out %al,(%dx) 8010332e: bf 03 00 00 00 mov $0x3,%edi 80103333: 89 f8 mov %edi,%eax 80103335: ee out %al,(%dx) 80103336: b1 a0 mov $0xa0,%cl 80103338: 89 f0 mov %esi,%eax 8010333a: 89 ca mov %ecx,%edx 8010333c: ee out %al,(%dx) 8010333d: b8 28 00 00 00 mov $0x28,%eax 80103342: 89 da mov %ebx,%edx 80103344: ee out %al,(%dx) 80103345: b8 02 00 00 00 mov $0x2,%eax 8010334a: ee out %al,(%dx) 8010334b: 89 f8 mov %edi,%eax 8010334d: ee out %al,(%dx) 8010334e: be 68 00 00 00 mov $0x68,%esi 80103353: b2 20 mov $0x20,%dl 80103355: 89 f0 mov %esi,%eax 80103357: ee out %al,(%dx) 80103358: bb 0a 00 00 00 mov $0xa,%ebx 8010335d: 89 d8 mov %ebx,%eax 8010335f: ee out %al,(%dx) 80103360: 89 f0 mov %esi,%eax 80103362: 89 ca mov %ecx,%edx 80103364: ee out %al,(%dx) 80103365: 89 d8 mov %ebx,%eax 80103367: ee out %al,(%dx) outb(IO_PIC1, 0x0a); // read IRR by default outb(IO_PIC2, 0x68); // OCW3 outb(IO_PIC2, 0x0a); // OCW3 if(irqmask != 0xFFFF) 80103368: 0f b7 05 00 a0 10 80 movzwl 0x8010a000,%eax 8010336f: 66 83 f8 ff cmp $0xffffffff,%ax 80103373: 74 0a je 8010337f <picinit+0x8f> 80103375: b2 21 mov $0x21,%dl 80103377: ee out %al,(%dx) 80103378: 66 c1 e8 08 shr $0x8,%ax 8010337c: b2 a1 mov $0xa1,%dl 8010337e: ee out %al,(%dx) picsetmask(irqmask); } 8010337f: 8b 1c 24 mov (%esp),%ebx 80103382: 8b 74 24 04 mov 0x4(%esp),%esi 80103386: 8b 7c 24 08 mov 0x8(%esp),%edi 8010338a: 89 ec mov %ebp,%esp 8010338c: 5d pop %ebp 8010338d: c3 ret ... 80103390 <piperead>: return n; } int piperead(struct pipe *p, char *addr, int n) { 80103390: 55 push %ebp 80103391: 89 e5 mov %esp,%ebp 80103393: 57 push %edi 80103394: 56 push %esi 80103395: 53 push %ebx 80103396: 83 ec 1c sub $0x1c,%esp 80103399: 8b 5d 08 mov 0x8(%ebp),%ebx 8010339c: 8b 7d 10 mov 0x10(%ebp),%edi int i; acquire(&p->lock); 8010339f: 89 1c 24 mov %ebx,(%esp) 801033a2: e8 29 14 00 00 call 801047d0 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801033a7: 8b 93 34 02 00 00 mov 0x234(%ebx),%edx 801033ad: 3b 93 38 02 00 00 cmp 0x238(%ebx),%edx 801033b3: 75 58 jne 8010340d <piperead+0x7d> 801033b5: 8b b3 40 02 00 00 mov 0x240(%ebx),%esi 801033bb: 85 f6 test %esi,%esi 801033bd: 74 4e je 8010340d <piperead+0x7d> if(proc->killed){ 801033bf: 65 a1 04 00 00 00 mov %gs:0x4,%eax release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 801033c5: 8d b3 34 02 00 00 lea 0x234(%ebx),%esi { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty if(proc->killed){ 801033cb: 8b 48 24 mov 0x24(%eax),%ecx 801033ce: 85 c9 test %ecx,%ecx 801033d0: 74 21 je 801033f3 <piperead+0x63> 801033d2: e9 99 00 00 00 jmp 80103470 <piperead+0xe0> 801033d7: 90 nop piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801033d8: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 801033de: 85 c0 test %eax,%eax 801033e0: 74 2b je 8010340d <piperead+0x7d> if(proc->killed){ 801033e2: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801033e8: 8b 50 24 mov 0x24(%eax),%edx 801033eb: 85 d2 test %edx,%edx 801033ed: 0f 85 7d 00 00 00 jne 80103470 <piperead+0xe0> release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 801033f3: 89 5c 24 04 mov %ebx,0x4(%esp) 801033f7: 89 34 24 mov %esi,(%esp) 801033fa: e8 81 06 00 00 call 80103a80 <sleep> piperead(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801033ff: 8b 93 34 02 00 00 mov 0x234(%ebx),%edx 80103405: 3b 93 38 02 00 00 cmp 0x238(%ebx),%edx 8010340b: 74 cb je 801033d8 <piperead+0x48> release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 8010340d: 85 ff test %edi,%edi 8010340f: 7e 76 jle 80103487 <piperead+0xf7> if(p->nread == p->nwrite) 80103411: 31 f6 xor %esi,%esi 80103413: 3b 93 38 02 00 00 cmp 0x238(%ebx),%edx 80103419: 75 0d jne 80103428 <piperead+0x98> 8010341b: eb 6a jmp 80103487 <piperead+0xf7> 8010341d: 8d 76 00 lea 0x0(%esi),%esi 80103420: 39 93 38 02 00 00 cmp %edx,0x238(%ebx) 80103426: 74 22 je 8010344a <piperead+0xba> break; addr[i] = p->data[p->nread++ % PIPESIZE]; 80103428: 89 d0 mov %edx,%eax 8010342a: 8b 4d 0c mov 0xc(%ebp),%ecx 8010342d: 83 c2 01 add $0x1,%edx 80103430: 25 ff 01 00 00 and $0x1ff,%eax 80103435: 0f b6 44 03 34 movzbl 0x34(%ebx,%eax,1),%eax 8010343a: 88 04 31 mov %al,(%ecx,%esi,1) release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 8010343d: 83 c6 01 add $0x1,%esi 80103440: 39 f7 cmp %esi,%edi if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; 80103442: 89 93 34 02 00 00 mov %edx,0x234(%ebx) release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103448: 7f d6 jg 80103420 <piperead+0x90> if(p->nread == p->nwrite) break; addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup 8010344a: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 80103450: 89 04 24 mov %eax,(%esp) 80103453: e8 c8 04 00 00 call 80103920 <wakeup> release(&p->lock); 80103458: 89 1c 24 mov %ebx,(%esp) 8010345b: e8 20 13 00 00 call 80104780 <release> return i; } 80103460: 83 c4 1c add $0x1c,%esp 80103463: 89 f0 mov %esi,%eax 80103465: 5b pop %ebx 80103466: 5e pop %esi 80103467: 5f pop %edi 80103468: 5d pop %ebp 80103469: c3 ret 8010346a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi int i; acquire(&p->lock); while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty if(proc->killed){ release(&p->lock); 80103470: be ff ff ff ff mov $0xffffffff,%esi 80103475: 89 1c 24 mov %ebx,(%esp) 80103478: e8 03 13 00 00 call 80104780 <release> addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 8010347d: 83 c4 1c add $0x1c,%esp 80103480: 89 f0 mov %esi,%eax 80103482: 5b pop %ebx 80103483: 5e pop %esi 80103484: 5f pop %edi 80103485: 5d pop %ebp 80103486: c3 ret release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep } for(i = 0; i < n; i++){ //DOC: piperead-copy 80103487: 31 f6 xor %esi,%esi 80103489: eb bf jmp 8010344a <piperead+0xba> 8010348b: 90 nop 8010348c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103490 <pipewrite>: } //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 80103490: 55 push %ebp 80103491: 89 e5 mov %esp,%ebp 80103493: 57 push %edi 80103494: 56 push %esi 80103495: 53 push %ebx 80103496: 83 ec 3c sub $0x3c,%esp 80103499: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 8010349c: 89 1c 24 mov %ebx,(%esp) 8010349f: 8d b3 34 02 00 00 lea 0x234(%ebx),%esi 801034a5: e8 26 13 00 00 call 801047d0 <acquire> for(i = 0; i < n; i++){ 801034aa: 8b 4d 10 mov 0x10(%ebp),%ecx 801034ad: 85 c9 test %ecx,%ecx 801034af: 0f 8e 8d 00 00 00 jle 80103542 <pipewrite+0xb2> 801034b5: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax if(p->readopen == 0 || proc->killed){ release(&p->lock); return -1; } wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 801034bb: 8d bb 38 02 00 00 lea 0x238(%ebx),%edi 801034c1: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 801034c8: eb 37 jmp 80103501 <pipewrite+0x71> 801034ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || proc->killed){ 801034d0: 8b 83 3c 02 00 00 mov 0x23c(%ebx),%eax 801034d6: 85 c0 test %eax,%eax 801034d8: 74 7e je 80103558 <pipewrite+0xc8> 801034da: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801034e0: 8b 50 24 mov 0x24(%eax),%edx 801034e3: 85 d2 test %edx,%edx 801034e5: 75 71 jne 80103558 <pipewrite+0xc8> release(&p->lock); return -1; } wakeup(&p->nread); 801034e7: 89 34 24 mov %esi,(%esp) 801034ea: e8 31 04 00 00 call 80103920 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 801034ef: 89 5c 24 04 mov %ebx,0x4(%esp) 801034f3: 89 3c 24 mov %edi,(%esp) 801034f6: e8 85 05 00 00 call 80103a80 <sleep> { int i; acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801034fb: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax 80103501: 8b 93 34 02 00 00 mov 0x234(%ebx),%edx 80103507: 81 c2 00 02 00 00 add $0x200,%edx 8010350d: 39 d0 cmp %edx,%eax 8010350f: 74 bf je 801034d0 <pipewrite+0x40> return -1; } wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; 80103511: 89 c2 mov %eax,%edx 80103513: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103516: 83 c0 01 add $0x1,%eax 80103519: 81 e2 ff 01 00 00 and $0x1ff,%edx 8010351f: 89 55 d4 mov %edx,-0x2c(%ebp) 80103522: 8b 55 0c mov 0xc(%ebp),%edx 80103525: 0f b6 0c 0a movzbl (%edx,%ecx,1),%ecx 80103529: 8b 55 d4 mov -0x2c(%ebp),%edx 8010352c: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) 80103530: 89 83 38 02 00 00 mov %eax,0x238(%ebx) pipewrite(struct pipe *p, char *addr, int n) { int i; acquire(&p->lock); for(i = 0; i < n; i++){ 80103536: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 8010353a: 8b 4d e4 mov -0x1c(%ebp),%ecx 8010353d: 39 4d 10 cmp %ecx,0x10(%ebp) 80103540: 7f bf jg 80103501 <pipewrite+0x71> wakeup(&p->nread); sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep } p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 80103542: 89 34 24 mov %esi,(%esp) 80103545: e8 d6 03 00 00 call 80103920 <wakeup> release(&p->lock); 8010354a: 89 1c 24 mov %ebx,(%esp) 8010354d: e8 2e 12 00 00 call 80104780 <release> return n; 80103552: eb 13 jmp 80103567 <pipewrite+0xd7> 80103554: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi acquire(&p->lock); for(i = 0; i < n; i++){ while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || proc->killed){ release(&p->lock); 80103558: 89 1c 24 mov %ebx,(%esp) 8010355b: e8 20 12 00 00 call 80104780 <release> 80103560: c7 45 10 ff ff ff ff movl $0xffffffff,0x10(%ebp) p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 release(&p->lock); return n; } 80103567: 8b 45 10 mov 0x10(%ebp),%eax 8010356a: 83 c4 3c add $0x3c,%esp 8010356d: 5b pop %ebx 8010356e: 5e pop %esi 8010356f: 5f pop %edi 80103570: 5d pop %ebp 80103571: c3 ret 80103572: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103579: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103580 <pipeclose>: return -1; } void pipeclose(struct pipe *p, int writable) { 80103580: 55 push %ebp 80103581: 89 e5 mov %esp,%ebp 80103583: 83 ec 18 sub $0x18,%esp 80103586: 89 5d f8 mov %ebx,-0x8(%ebp) 80103589: 8b 5d 08 mov 0x8(%ebp),%ebx 8010358c: 89 75 fc mov %esi,-0x4(%ebp) 8010358f: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 80103592: 89 1c 24 mov %ebx,(%esp) 80103595: e8 36 12 00 00 call 801047d0 <acquire> if(writable){ 8010359a: 85 f6 test %esi,%esi 8010359c: 74 42 je 801035e0 <pipeclose+0x60> p->writeopen = 0; 8010359e: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 801035a5: 00 00 00 wakeup(&p->nread); 801035a8: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 801035ae: 89 04 24 mov %eax,(%esp) 801035b1: e8 6a 03 00 00 call 80103920 <wakeup> } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 801035b6: 8b 83 3c 02 00 00 mov 0x23c(%ebx),%eax 801035bc: 85 c0 test %eax,%eax 801035be: 75 0a jne 801035ca <pipeclose+0x4a> 801035c0: 8b b3 40 02 00 00 mov 0x240(%ebx),%esi 801035c6: 85 f6 test %esi,%esi 801035c8: 74 36 je 80103600 <pipeclose+0x80> release(&p->lock); kfree((char*)p); } else release(&p->lock); 801035ca: 89 5d 08 mov %ebx,0x8(%ebp) } 801035cd: 8b 75 fc mov -0x4(%ebp),%esi 801035d0: 8b 5d f8 mov -0x8(%ebp),%ebx 801035d3: 89 ec mov %ebp,%esp 801035d5: 5d pop %ebp } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); } else release(&p->lock); 801035d6: e9 a5 11 00 00 jmp 80104780 <release> 801035db: 90 nop 801035dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi acquire(&p->lock); if(writable){ p->writeopen = 0; wakeup(&p->nread); } else { p->readopen = 0; 801035e0: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 801035e7: 00 00 00 wakeup(&p->nwrite); 801035ea: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax 801035f0: 89 04 24 mov %eax,(%esp) 801035f3: e8 28 03 00 00 call 80103920 <wakeup> 801035f8: eb bc jmp 801035b6 <pipeclose+0x36> 801035fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); 80103600: 89 1c 24 mov %ebx,(%esp) 80103603: e8 78 11 00 00 call 80104780 <release> kfree((char*)p); } else release(&p->lock); } 80103608: 8b 75 fc mov -0x4(%ebp),%esi p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); 8010360b: 89 5d 08 mov %ebx,0x8(%ebp) } else release(&p->lock); } 8010360e: 8b 5d f8 mov -0x8(%ebp),%ebx 80103611: 89 ec mov %ebp,%esp 80103613: 5d pop %ebp p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ release(&p->lock); kfree((char*)p); 80103614: e9 97 ed ff ff jmp 801023b0 <kfree> 80103619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103620 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103620: 55 push %ebp 80103621: 89 e5 mov %esp,%ebp 80103623: 57 push %edi 80103624: 56 push %esi 80103625: 53 push %ebx 80103626: 83 ec 1c sub $0x1c,%esp 80103629: 8b 75 08 mov 0x8(%ebp),%esi 8010362c: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 8010362f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103635: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010363b: e8 a0 d9 ff ff call 80100fe0 <filealloc> 80103640: 85 c0 test %eax,%eax 80103642: 89 06 mov %eax,(%esi) 80103644: 0f 84 9c 00 00 00 je 801036e6 <pipealloc+0xc6> 8010364a: e8 91 d9 ff ff call 80100fe0 <filealloc> 8010364f: 85 c0 test %eax,%eax 80103651: 89 03 mov %eax,(%ebx) 80103653: 0f 84 7f 00 00 00 je 801036d8 <pipealloc+0xb8> goto bad; if((p = (struct pipe*)kalloc()) == 0) 80103659: e8 02 ed ff ff call 80102360 <kalloc> 8010365e: 85 c0 test %eax,%eax 80103660: 89 c7 mov %eax,%edi 80103662: 74 74 je 801036d8 <pipealloc+0xb8> goto bad; p->readopen = 1; 80103664: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 8010366b: 00 00 00 p->writeopen = 1; 8010366e: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 80103675: 00 00 00 p->nwrite = 0; 80103678: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 8010367f: 00 00 00 p->nread = 0; 80103682: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 80103689: 00 00 00 initlock(&p->lock, "pipe"); 8010368c: 89 04 24 mov %eax,(%esp) 8010368f: c7 44 24 04 38 78 10 movl $0x80107838,0x4(%esp) 80103696: 80 80103697: e8 a4 0f 00 00 call 80104640 <initlock> (*f0)->type = FD_PIPE; 8010369c: 8b 06 mov (%esi),%eax 8010369e: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 801036a4: 8b 06 mov (%esi),%eax 801036a6: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 801036aa: 8b 06 mov (%esi),%eax 801036ac: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 801036b0: 8b 06 mov (%esi),%eax 801036b2: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 801036b5: 8b 03 mov (%ebx),%eax 801036b7: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 801036bd: 8b 03 mov (%ebx),%eax 801036bf: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 801036c3: 8b 03 mov (%ebx),%eax 801036c5: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 801036c9: 8b 03 mov (%ebx),%eax 801036cb: 89 78 0c mov %edi,0xc(%eax) 801036ce: 31 c0 xor %eax,%eax if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 801036d0: 83 c4 1c add $0x1c,%esp 801036d3: 5b pop %ebx 801036d4: 5e pop %esi 801036d5: 5f pop %edi 801036d6: 5d pop %ebp 801036d7: c3 ret //PAGEBREAK: 20 bad: if(p) kfree((char*)p); if(*f0) 801036d8: 8b 06 mov (%esi),%eax 801036da: 85 c0 test %eax,%eax 801036dc: 74 08 je 801036e6 <pipealloc+0xc6> fileclose(*f0); 801036de: 89 04 24 mov %eax,(%esp) 801036e1: e8 7a d9 ff ff call 80101060 <fileclose> if(*f1) 801036e6: 8b 13 mov (%ebx),%edx 801036e8: b8 ff ff ff ff mov $0xffffffff,%eax 801036ed: 85 d2 test %edx,%edx 801036ef: 74 df je 801036d0 <pipealloc+0xb0> fileclose(*f1); 801036f1: 89 14 24 mov %edx,(%esp) 801036f4: e8 67 d9 ff ff call 80101060 <fileclose> 801036f9: b8 ff ff ff ff mov $0xffffffff,%eax 801036fe: eb d0 jmp 801036d0 <pipealloc+0xb0> 80103700 <rndm_gen>: } //code for a random number generator unsigned long rndm_gen(int sd) { 80103700: 55 push %ebp 80103701: 31 c0 xor %eax,%eax 80103703: 89 e5 mov %esp,%ebp 80103705: 69 55 08 c1 60 a8 10 imul $0x10a860c1,0x8(%ebp),%edx return (sd*279470273UL)%4294967291UL; } 8010370c: 5d pop %ebp } //code for a random number generator unsigned long rndm_gen(int sd) { 8010370d: 83 fa fb cmp $0xfffffffb,%edx 80103710: 0f 93 c0 setae %al 80103713: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx 8010371a: 8d 04 01 lea (%ecx,%eax,1),%eax 8010371d: 8d 04 02 lea (%edx,%eax,1),%eax return (sd*279470273UL)%4294967291UL; } 80103720: c3 ret 80103721: eb 0d jmp 80103730 <set_tickets> 80103723: 90 nop 80103724: 90 nop 80103725: 90 nop 80103726: 90 nop 80103727: 90 nop 80103728: 90 nop 80103729: 90 nop 8010372a: 90 nop 8010372b: 90 nop 8010372c: 90 nop 8010372d: 90 nop 8010372e: 90 nop 8010372f: 90 nop 80103730 <set_tickets>: } //our code for set_tickets int set_tickets(int tickets) { 80103730: 55 push %ebp 80103731: 89 e5 mov %esp,%ebp 80103733: 53 push %ebx total_tickets += tickets; proc->tickets = tickets; proc->pass = 10000/proc->tickets; 80103734: bb 10 27 00 00 mov $0x2710,%ebx } //our code for set_tickets int set_tickets(int tickets) { 80103739: 83 ec 14 sub $0x14,%esp 8010373c: 8b 45 08 mov 0x8(%ebp),%eax total_tickets += tickets; proc->tickets = tickets; 8010373f: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx //our code for set_tickets int set_tickets(int tickets) { total_tickets += tickets; 80103746: 01 05 c4 a5 10 80 add %eax,0x8010a5c4 proc->tickets = tickets; 8010374c: 89 42 7c mov %eax,0x7c(%edx) proc->pass = 10000/proc->tickets; 8010374f: 65 8b 0d 04 00 00 00 mov %gs:0x4,%ecx 80103756: 89 da mov %ebx,%edx 80103758: 89 d8 mov %ebx,%eax 8010375a: c1 fa 1f sar $0x1f,%edx 8010375d: f7 79 7c idivl 0x7c(%ecx) 80103760: 89 81 84 00 00 00 mov %eax,0x84(%ecx) cprintf("ticket value for %s set to :%d\n",proc->name,proc->tickets); 80103766: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010376c: 8b 50 7c mov 0x7c(%eax),%edx 8010376f: 83 c0 6c add $0x6c,%eax 80103772: 89 44 24 04 mov %eax,0x4(%esp) 80103776: c7 04 24 40 78 10 80 movl $0x80107840,(%esp) 8010377d: 89 54 24 08 mov %edx,0x8(%esp) 80103781: e8 ea d0 ff ff call 80100870 <cprintf> cprintf("Stride value for %s is : %d\n",proc->name,(10000/proc->tickets)); 80103786: 65 8b 0d 04 00 00 00 mov %gs:0x4,%ecx 8010378d: 89 da mov %ebx,%edx 8010378f: 89 d8 mov %ebx,%eax 80103791: c1 fa 1f sar $0x1f,%edx 80103794: f7 79 7c idivl 0x7c(%ecx) 80103797: 83 c1 6c add $0x6c,%ecx 8010379a: 89 4c 24 04 mov %ecx,0x4(%esp) 8010379e: c7 04 24 60 78 10 80 movl $0x80107860,(%esp) 801037a5: 89 44 24 08 mov %eax,0x8(%esp) 801037a9: e8 c2 d0 ff ff call 80100870 <cprintf> return 0; } 801037ae: 83 c4 14 add $0x14,%esp 801037b1: 31 c0 xor %eax,%eax 801037b3: 5b pop %ebx 801037b4: 5d pop %ebp 801037b5: c3 ret 801037b6: 8d 76 00 lea 0x0(%esi),%esi 801037b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801037c0 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 801037c0: 55 push %ebp 801037c1: 89 e5 mov %esp,%ebp 801037c3: 57 push %edi 801037c4: 56 push %esi 801037c5: 53 push %ebx //PAGEBREAK: 36 // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) 801037c6: bb d4 2d 11 80 mov $0x80112dd4,%ebx { 801037cb: 83 ec 4c sub $0x4c,%esp state = states[p->state]; else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); 801037ce: 8d 7d c0 lea -0x40(%ebp),%edi 801037d1: eb 4e jmp 80103821 <procdump+0x61> 801037d3: 90 nop 801037d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->state == UNUSED) continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 801037d8: 8b 04 85 6c 79 10 80 mov -0x7fef8694(,%eax,4),%eax 801037df: 85 c0 test %eax,%eax 801037e1: 74 4a je 8010382d <procdump+0x6d> state = states[p->state]; else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); 801037e3: 89 44 24 08 mov %eax,0x8(%esp) 801037e7: 8b 43 10 mov 0x10(%ebx),%eax 801037ea: 8d 53 6c lea 0x6c(%ebx),%edx 801037ed: 89 54 24 0c mov %edx,0xc(%esp) 801037f1: c7 04 24 81 78 10 80 movl $0x80107881,(%esp) 801037f8: 89 44 24 04 mov %eax,0x4(%esp) 801037fc: e8 6f d0 ff ff call 80100870 <cprintf> if(p->state == SLEEPING){ 80103801: 83 7b 0c 02 cmpl $0x2,0xc(%ebx) 80103805: 74 31 je 80103838 <procdump+0x78> getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); 80103807: c7 04 24 16 78 10 80 movl $0x80107816,(%esp) 8010380e: e8 5d d0 ff ff call 80100870 <cprintf> int i; struct proc *p; char *state; uint pc[10]; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103813: 81 c3 88 00 00 00 add $0x88,%ebx 80103819: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx 8010381f: 74 57 je 80103878 <procdump+0xb8> if(p->state == UNUSED) 80103821: 8b 43 0c mov 0xc(%ebx),%eax 80103824: 85 c0 test %eax,%eax 80103826: 74 eb je 80103813 <procdump+0x53> continue; if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103828: 83 f8 05 cmp $0x5,%eax 8010382b: 76 ab jbe 801037d8 <procdump+0x18> 8010382d: b8 7d 78 10 80 mov $0x8010787d,%eax 80103832: eb af jmp 801037e3 <procdump+0x23> 80103834: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi state = states[p->state]; else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); 80103838: 8b 43 1c mov 0x1c(%ebx),%eax 8010383b: 31 f6 xor %esi,%esi 8010383d: 89 7c 24 04 mov %edi,0x4(%esp) 80103841: 8b 40 0c mov 0xc(%eax),%eax 80103844: 83 c0 08 add $0x8,%eax 80103847: 89 04 24 mov %eax,(%esp) 8010384a: e8 11 0e 00 00 call 80104660 <getcallerpcs> 8010384f: 90 nop for(i=0; i<10 && pc[i] != 0; i++) 80103850: 8b 04 b7 mov (%edi,%esi,4),%eax 80103853: 85 c0 test %eax,%eax 80103855: 74 b0 je 80103807 <procdump+0x47> 80103857: 83 c6 01 add $0x1,%esi cprintf(" %p", pc[i]); 8010385a: 89 44 24 04 mov %eax,0x4(%esp) 8010385e: c7 04 24 51 73 10 80 movl $0x80107351,(%esp) 80103865: e8 06 d0 ff ff call 80100870 <cprintf> else state = "???"; cprintf("%d %s %s", p->pid, state, p->name); if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) 8010386a: 83 fe 0a cmp $0xa,%esi 8010386d: 75 e1 jne 80103850 <procdump+0x90> 8010386f: eb 96 jmp 80103807 <procdump+0x47> 80103871: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi cprintf(" %p", pc[i]); } cprintf("\n"); } } 80103878: 83 c4 4c add $0x4c,%esp 8010387b: 5b pop %ebx 8010387c: 5e pop %esi 8010387d: 5f pop %edi 8010387e: 5d pop %ebp 8010387f: 90 nop 80103880: c3 ret 80103881: eb 0d jmp 80103890 <kill> 80103883: 90 nop 80103884: 90 nop 80103885: 90 nop 80103886: 90 nop 80103887: 90 nop 80103888: 90 nop 80103889: 90 nop 8010388a: 90 nop 8010388b: 90 nop 8010388c: 90 nop 8010388d: 90 nop 8010388e: 90 nop 8010388f: 90 nop 80103890 <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80103890: 55 push %ebp 80103891: 89 e5 mov %esp,%ebp 80103893: 53 push %ebx 80103894: 83 ec 14 sub $0x14,%esp 80103897: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 8010389a: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801038a1: e8 2a 0f 00 00 call 801047d0 <acquire> // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) 801038a6: b8 5c 2e 11 80 mov $0x80112e5c,%eax { struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ 801038ab: 39 1d e4 2d 11 80 cmp %ebx,0x80112de4 801038b1: 75 11 jne 801038c4 <kill+0x34> 801038b3: eb 62 jmp 80103917 <kill+0x87> 801038b5: 8d 76 00 lea 0x0(%esi),%esi kill(int pid) { struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801038b8: 05 88 00 00 00 add $0x88,%eax 801038bd: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 801038c2: 74 3c je 80103900 <kill+0x70> if(p->pid == pid){ 801038c4: 39 58 10 cmp %ebx,0x10(%eax) 801038c7: 75 ef jne 801038b8 <kill+0x28> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 801038c9: 83 78 0c 02 cmpl $0x2,0xc(%eax) struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; 801038cd: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) // Wake process from sleep if necessary. if(p->state == SLEEPING) 801038d4: 74 1a je 801038f0 <kill+0x60> p->state = RUNNABLE; release(&ptable.lock); 801038d6: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801038dd: e8 9e 0e 00 00 call 80104780 <release> return 0; } } release(&ptable.lock); return -1; } 801038e2: 83 c4 14 add $0x14,%esp if(p->pid == pid){ p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) p->state = RUNNABLE; release(&ptable.lock); 801038e5: 31 c0 xor %eax,%eax return 0; } } release(&ptable.lock); return -1; } 801038e7: 5b pop %ebx 801038e8: 5d pop %ebp 801038e9: c3 ret 801038ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) p->state = RUNNABLE; 801038f0: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 801038f7: eb dd jmp 801038d6 <kill+0x46> 801038f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); return 0; } } release(&ptable.lock); 80103900: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103907: e8 74 0e 00 00 call 80104780 <release> return -1; } 8010390c: 83 c4 14 add $0x14,%esp p->state = RUNNABLE; release(&ptable.lock); return 0; } } release(&ptable.lock); 8010390f: b8 ff ff ff ff mov $0xffffffff,%eax return -1; } 80103914: 5b pop %ebx 80103915: 5d pop %ebp 80103916: c3 ret { struct proc *p; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == pid){ 80103917: b8 d4 2d 11 80 mov $0x80112dd4,%eax 8010391c: eb ab jmp 801038c9 <kill+0x39> 8010391e: 66 90 xchg %ax,%ax 80103920 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80103920: 55 push %ebp 80103921: 89 e5 mov %esp,%ebp 80103923: 53 push %ebx 80103924: 83 ec 14 sub $0x14,%esp 80103927: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 8010392a: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103931: e8 9a 0e 00 00 call 801047d0 <acquire> p->state = RUNNABLE; } // Wake up all processes sleeping on chan. void wakeup(void *chan) 80103936: b8 d4 2d 11 80 mov $0x80112dd4,%eax 8010393b: eb 0f jmp 8010394c <wakeup+0x2c> 8010393d: 8d 76 00 lea 0x0(%esi),%esi static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103940: 05 88 00 00 00 add $0x88,%eax 80103945: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 8010394a: 74 24 je 80103970 <wakeup+0x50> if(p->state == SLEEPING && p->chan == chan) 8010394c: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103950: 75 ee jne 80103940 <wakeup+0x20> 80103952: 3b 58 20 cmp 0x20(%eax),%ebx 80103955: 75 e9 jne 80103940 <wakeup+0x20> p->state = RUNNABLE; 80103957: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 8010395e: 05 88 00 00 00 add $0x88,%eax 80103963: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80103968: 75 e2 jne 8010394c <wakeup+0x2c> 8010396a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 80103970: c7 45 08 a0 2d 11 80 movl $0x80112da0,0x8(%ebp) } 80103977: 83 c4 14 add $0x14,%esp 8010397a: 5b pop %ebx 8010397b: 5d pop %ebp void wakeup(void *chan) { acquire(&ptable.lock); wakeup1(chan); release(&ptable.lock); 8010397c: e9 ff 0d 00 00 jmp 80104780 <release> 80103981: eb 0d jmp 80103990 <forkret> 80103983: 90 nop 80103984: 90 nop 80103985: 90 nop 80103986: 90 nop 80103987: 90 nop 80103988: 90 nop 80103989: 90 nop 8010398a: 90 nop 8010398b: 90 nop 8010398c: 90 nop 8010398d: 90 nop 8010398e: 90 nop 8010398f: 90 nop 80103990 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 80103990: 55 push %ebp 80103991: 89 e5 mov %esp,%ebp 80103993: 83 ec 18 sub $0x18,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 80103996: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 8010399d: e8 de 0d 00 00 call 80104780 <release> if (first) { 801039a2: a1 08 a0 10 80 mov 0x8010a008,%eax 801039a7: 85 c0 test %eax,%eax 801039a9: 75 05 jne 801039b0 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 801039ab: c9 leave 801039ac: c3 ret 801039ad: 8d 76 00 lea 0x0(%esi),%esi if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; iinit(ROOTDEV); 801039b0: c7 04 24 01 00 00 00 movl $0x1,(%esp) if (first) { // Some initialization functions must be run in the context // of a regular process (e.g., they call sleep), and thus cannot // be run from main(). first = 0; 801039b7: c7 05 08 a0 10 80 00 movl $0x0,0x8010a008 801039be: 00 00 00 iinit(ROOTDEV); 801039c1: e8 1a e5 ff ff call 80101ee0 <iinit> initlog(ROOTDEV); 801039c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801039cd: e8 4e f4 ff ff call 80102e20 <initlog> } // Return to "caller", actually trapret (see allocproc). } 801039d2: c9 leave 801039d3: c3 ret 801039d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801039da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801039e0 <sched>: // be proc->intena and proc->ncli, but that would // break in the few places where a lock is held but // there's no process. void sched(void) { 801039e0: 55 push %ebp 801039e1: 89 e5 mov %esp,%ebp 801039e3: 53 push %ebx 801039e4: 83 ec 14 sub $0x14,%esp int intena; if(!holding(&ptable.lock)) 801039e7: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801039ee: e8 cd 0c 00 00 call 801046c0 <holding> 801039f3: 85 c0 test %eax,%eax 801039f5: 74 4d je 80103a44 <sched+0x64> panic("sched ptable.lock"); if(cpu->ncli != 1) 801039f7: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801039fd: 83 b8 ac 00 00 00 01 cmpl $0x1,0xac(%eax) 80103a04: 75 62 jne 80103a68 <sched+0x88> panic("sched locks"); if(proc->state == RUNNING) 80103a06: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80103a0d: 83 7a 0c 04 cmpl $0x4,0xc(%edx) 80103a11: 74 49 je 80103a5c <sched+0x7c> static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103a13: 9c pushf 80103a14: 59 pop %ecx panic("sched running"); if(readeflags()&FL_IF) 80103a15: 80 e5 02 and $0x2,%ch 80103a18: 75 36 jne 80103a50 <sched+0x70> panic("sched interruptible"); intena = cpu->intena; 80103a1a: 8b 98 b0 00 00 00 mov 0xb0(%eax),%ebx swtch(&proc->context, cpu->scheduler); 80103a20: 83 c2 1c add $0x1c,%edx 80103a23: 8b 40 04 mov 0x4(%eax),%eax 80103a26: 89 14 24 mov %edx,(%esp) 80103a29: 89 44 24 04 mov %eax,0x4(%esp) 80103a2d: e8 8a 10 00 00 call 80104abc <swtch> cpu->intena = intena; 80103a32: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80103a38: 89 98 b0 00 00 00 mov %ebx,0xb0(%eax) } 80103a3e: 83 c4 14 add $0x14,%esp 80103a41: 5b pop %ebx 80103a42: 5d pop %ebp 80103a43: c3 ret sched(void) { int intena; if(!holding(&ptable.lock)) panic("sched ptable.lock"); 80103a44: c7 04 24 8a 78 10 80 movl $0x8010788a,(%esp) 80103a4b: e8 80 c9 ff ff call 801003d0 <panic> if(cpu->ncli != 1) panic("sched locks"); if(proc->state == RUNNING) panic("sched running"); if(readeflags()&FL_IF) panic("sched interruptible"); 80103a50: c7 04 24 b6 78 10 80 movl $0x801078b6,(%esp) 80103a57: e8 74 c9 ff ff call 801003d0 <panic> if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(cpu->ncli != 1) panic("sched locks"); if(proc->state == RUNNING) panic("sched running"); 80103a5c: c7 04 24 a8 78 10 80 movl $0x801078a8,(%esp) 80103a63: e8 68 c9 ff ff call 801003d0 <panic> int intena; if(!holding(&ptable.lock)) panic("sched ptable.lock"); if(cpu->ncli != 1) panic("sched locks"); 80103a68: c7 04 24 9c 78 10 80 movl $0x8010789c,(%esp) 80103a6f: e8 5c c9 ff ff call 801003d0 <panic> 80103a74: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103a7a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80103a80 <sleep>: // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 80103a80: 55 push %ebp 80103a81: 89 e5 mov %esp,%ebp 80103a83: 56 push %esi 80103a84: 53 push %ebx 80103a85: 83 ec 10 sub $0x10,%esp if(proc == 0) 80103a88: 65 a1 04 00 00 00 mov %gs:0x4,%eax // Atomically release lock and sleep on chan. // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { 80103a8e: 8b 75 08 mov 0x8(%ebp),%esi 80103a91: 8b 5d 0c mov 0xc(%ebp),%ebx if(proc == 0) 80103a94: 85 c0 test %eax,%eax 80103a96: 0f 84 a1 00 00 00 je 80103b3d <sleep+0xbd> panic("sleep"); if(lk == 0) 80103a9c: 85 db test %ebx,%ebx 80103a9e: 0f 84 8d 00 00 00 je 80103b31 <sleep+0xb1> // change p->state and then call sched. // Once we hold ptable.lock, we can be // guaranteed that we won't miss any wakeup // (wakeup runs with ptable.lock locked), // so it's okay to release lk. if(lk != &ptable.lock){ //DOC: sleeplock0 80103aa4: 81 fb a0 2d 11 80 cmp $0x80112da0,%ebx 80103aaa: 74 5c je 80103b08 <sleep+0x88> acquire(&ptable.lock); //DOC: sleeplock1 80103aac: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103ab3: e8 18 0d 00 00 call 801047d0 <acquire> release(lk); 80103ab8: 89 1c 24 mov %ebx,(%esp) 80103abb: e8 c0 0c 00 00 call 80104780 <release> } // Go to sleep. proc->chan = chan; 80103ac0: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103ac6: 89 70 20 mov %esi,0x20(%eax) proc->state = SLEEPING; 80103ac9: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103acf: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80103ad6: e8 05 ff ff ff call 801039e0 <sched> // Tidy up. proc->chan = 0; 80103adb: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103ae1: c7 40 20 00 00 00 00 movl $0x0,0x20(%eax) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); 80103ae8: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103aef: e8 8c 0c 00 00 call 80104780 <release> acquire(lk); 80103af4: 89 5d 08 mov %ebx,0x8(%ebp) } } 80103af7: 83 c4 10 add $0x10,%esp 80103afa: 5b pop %ebx 80103afb: 5e pop %esi 80103afc: 5d pop %ebp proc->chan = 0; // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); 80103afd: e9 ce 0c 00 00 jmp 801047d0 <acquire> 80103b02: 8d b6 00 00 00 00 lea 0x0(%esi),%esi acquire(&ptable.lock); //DOC: sleeplock1 release(lk); } // Go to sleep. proc->chan = chan; 80103b08: 89 70 20 mov %esi,0x20(%eax) proc->state = SLEEPING; 80103b0b: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103b11: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80103b18: e8 c3 fe ff ff call 801039e0 <sched> // Tidy up. proc->chan = 0; 80103b1d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103b23: c7 40 20 00 00 00 00 movl $0x0,0x20(%eax) // Reacquire original lock. if(lk != &ptable.lock){ //DOC: sleeplock2 release(&ptable.lock); acquire(lk); } } 80103b2a: 83 c4 10 add $0x10,%esp 80103b2d: 5b pop %ebx 80103b2e: 5e pop %esi 80103b2f: 5d pop %ebp 80103b30: c3 ret { if(proc == 0) panic("sleep"); if(lk == 0) panic("sleep without lk"); 80103b31: c7 04 24 d0 78 10 80 movl $0x801078d0,(%esp) 80103b38: e8 93 c8 ff ff call 801003d0 <panic> // Reacquires lock when awakened. void sleep(void *chan, struct spinlock *lk) { if(proc == 0) panic("sleep"); 80103b3d: c7 04 24 ca 78 10 80 movl $0x801078ca,(%esp) 80103b44: e8 87 c8 ff ff call 801003d0 <panic> 80103b49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103b50 <yield>: } // Give up the CPU for one scheduling round. void yield(void) { 80103b50: 55 push %ebp 80103b51: 89 e5 mov %esp,%ebp 80103b53: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); //DOC: yieldlock 80103b56: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103b5d: e8 6e 0c 00 00 call 801047d0 <acquire> proc->state = RUNNABLE; 80103b62: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103b68: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) sched(); 80103b6f: e8 6c fe ff ff call 801039e0 <sched> release(&ptable.lock); 80103b74: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103b7b: e8 00 0c 00 00 call 80104780 <release> } 80103b80: c9 leave 80103b81: c3 ret 80103b82: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103b90 <scheduler2>: //original scheduler void scheduler2(void) { 80103b90: 55 push %ebp 80103b91: 89 e5 mov %esp,%ebp 80103b93: 53 push %ebx 80103b94: 83 ec 14 sub $0x14,%esp 80103b97: 90 nop } static inline void sti(void) { asm volatile("sti"); 80103b98: fb sti } //original scheduler void scheduler2(void) 80103b99: bb d4 2d 11 80 mov $0x80112dd4,%ebx for(;;){ // Enable interrupts on this processor. sti(); acquire(&ptable.lock); 80103b9e: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103ba5: e8 26 0c 00 00 call 801047d0 <acquire> 80103baa: eb 12 jmp 80103bbe <scheduler2+0x2e> 80103bac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103bb0: 81 c3 88 00 00 00 add $0x88,%ebx 80103bb6: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx 80103bbc: 74 52 je 80103c10 <scheduler2+0x80> if(p->state != RUNNABLE) 80103bbe: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 80103bc2: 75 ec jne 80103bb0 <scheduler2+0x20> continue; // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. proc = p; 80103bc4: 65 89 1d 04 00 00 00 mov %ebx,%gs:0x4 switchuvm(p); 80103bcb: 89 1c 24 mov %ebx,(%esp) 80103bce: e8 0d 35 00 00 call 801070e0 <switchuvm> p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103bd3: 8b 43 1c mov 0x1c(%ebx),%eax // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. proc = p; switchuvm(p); p->state = RUNNING; 80103bd6: c7 43 0c 04 00 00 00 movl $0x4,0xc(%ebx) for(;;){ // Enable interrupts on this processor. sti(); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103bdd: 81 c3 88 00 00 00 add $0x88,%ebx // to release ptable.lock and then reacquire it // before jumping back to us. proc = p; switchuvm(p); p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103be3: 89 44 24 04 mov %eax,0x4(%esp) 80103be7: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80103bed: 83 c0 04 add $0x4,%eax 80103bf0: 89 04 24 mov %eax,(%esp) 80103bf3: e8 c4 0e 00 00 call 80104abc <swtch> switchkvm(); 80103bf8: e8 c3 2d 00 00 call 801069c0 <switchkvm> for(;;){ // Enable interrupts on this processor. sti(); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103bfd: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx swtch(&cpu->scheduler, p->context); switchkvm(); // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; 80103c03: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80103c0a: 00 00 00 00 for(;;){ // Enable interrupts on this processor. sti(); acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103c0e: 75 ae jne 80103bbe <scheduler2+0x2e> // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; } release(&ptable.lock); 80103c10: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103c17: e8 64 0b 00 00 call 80104780 <release> } 80103c1c: e9 77 ff ff ff jmp 80103b98 <scheduler2+0x8> 80103c21: eb 0d jmp 80103c30 <scheduler1> 80103c23: 90 nop 80103c24: 90 nop 80103c25: 90 nop 80103c26: 90 nop 80103c27: 90 nop 80103c28: 90 nop 80103c29: 90 nop 80103c2a: 90 nop 80103c2b: 90 nop 80103c2c: 90 nop 80103c2d: 90 nop 80103c2e: 90 nop 80103c2f: 90 nop 80103c30 <scheduler1>: // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler1(void) { 80103c30: 55 push %ebp 80103c31: 89 e5 mov %esp,%ebp 80103c33: 57 push %edi 80103c34: 56 push %esi 80103c35: 53 push %ebx 80103c36: bb c1 60 a8 10 mov $0x10a860c1,%ebx 80103c3b: 83 ec 2c sub $0x2c,%esp 80103c3e: 66 90 xchg %ax,%ax 80103c40: fb sti sd++; //CS 202 //Random number generator //Having lottery winner=rndm_gen(sd)%(total_tickets+1); 80103c41: 31 c0 xor %eax,%eax 80103c43: 83 fb fb cmp $0xfffffffb,%ebx 80103c46: 0f 93 c0 setae %al // - choose a process to run // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler1(void) 80103c49: bf d4 2d 11 80 mov $0x80112dd4,%edi sd++; //CS 202 //Random number generator //Having lottery winner=rndm_gen(sd)%(total_tickets+1); 80103c4e: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 80103c55: 8d 04 02 lea (%edx,%eax,1),%eax 80103c58: 8b 15 c4 a5 10 80 mov 0x8010a5c4,%edx 80103c5e: 8d 04 03 lea (%ebx,%eax,1),%eax //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); 80103c61: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) sd++; //CS 202 //Random number generator //Having lottery winner=rndm_gen(sd)%(total_tickets+1); 80103c68: 8d 4a 01 lea 0x1(%edx),%ecx 80103c6b: 31 d2 xor %edx,%edx 80103c6d: f7 f1 div %ecx 80103c6f: 89 d6 mov %edx,%esi //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); 80103c71: e8 5a 0b 00 00 call 801047d0 <acquire> // - choose a process to run // - swtch to start running that process // - eventually that process transfers control // via swtch back to the scheduler. void scheduler1(void) 80103c76: 31 c0 xor %eax,%eax 80103c78: eb 14 jmp 80103c8e <scheduler1+0x5e> 80103c7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103c80: 81 c7 88 00 00 00 add $0x88,%edi 80103c86: 81 ff d4 4f 11 80 cmp $0x80114fd4,%edi 80103c8c: 74 6a je 80103cf8 <scheduler1+0xc8> //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) 80103c8e: 83 7f 0c 03 cmpl $0x3,0xc(%edi) 80103c92: 75 ec jne 80103c80 <scheduler1+0x50> continue; //cprintf("Counter: %d, Tickets: %d", counter, p->tickets); counter =counter + p->tickets; 80103c94: 03 47 7c add 0x7c(%edi),%eax if(counter < winner) 80103c97: 39 c6 cmp %eax,%esi 80103c99: 77 e5 ja 80103c80 <scheduler1+0x50> // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; proc = p; switchuvm(p); 80103c9b: 89 45 e4 mov %eax,-0x1c(%ebp) // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; 80103c9e: 83 87 80 00 00 00 01 addl $0x1,0x80(%edi) proc = p; 80103ca5: 65 89 3d 04 00 00 00 mov %edi,%gs:0x4 switchuvm(p); 80103cac: 89 3c 24 mov %edi,(%esp) 80103caf: e8 2c 34 00 00 call 801070e0 <switchuvm> p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103cb4: 8b 57 1c mov 0x1c(%edi),%edx // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; proc = p; switchuvm(p); p->state = RUNNING; 80103cb7: c7 47 0c 04 00 00 00 movl $0x4,0xc(%edi) //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cbe: 81 c7 88 00 00 00 add $0x88,%edi //cprintf("pid : ",p->pid); p->count +=1; proc = p; switchuvm(p); p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103cc4: 89 54 24 04 mov %edx,0x4(%esp) 80103cc8: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80103ccf: 83 c2 04 add $0x4,%edx 80103cd2: 89 14 24 mov %edx,(%esp) 80103cd5: e8 e2 0d 00 00 call 80104abc <swtch> switchkvm(); 80103cda: e8 e1 2c 00 00 call 801069c0 <switchkvm> //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cdf: 81 ff d4 4f 11 80 cmp $0x80114fd4,%edi swtch(&cpu->scheduler, p->context); switchkvm(); // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; 80103ce5: 8b 45 e4 mov -0x1c(%ebp),%eax 80103ce8: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80103cef: 00 00 00 00 //cprintf("Winner is : %d\n",winner); counter = 0; // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cf3: 75 99 jne 80103c8e <scheduler1+0x5e> 80103cf5: 8d 76 00 lea 0x0(%esi),%esi // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; } release(&ptable.lock); 80103cf8: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103cff: 81 c3 c1 60 a8 10 add $0x10a860c1,%ebx 80103d05: e8 76 0a 00 00 call 80104780 <release> } 80103d0a: e9 31 ff ff ff jmp 80103c40 <scheduler1+0x10> 80103d0f: 90 nop 80103d10 <scheduler_b>: } } void scheduler_b(void) { 80103d10: 55 push %ebp 80103d11: 89 e5 mov %esp,%ebp 80103d13: 53 push %ebx 80103d14: 83 ec 14 sub $0x14,%esp // int min_pass; //int stride=1; struct proc *p; struct proc *current; current = proc; 80103d17: 65 8b 1d 04 00 00 00 mov %gs:0x4,%ebx 80103d1e: 66 90 xchg %ax,%ax 80103d20: fb sti for(;;) { sti(); //struct proc *current; int min_pass=-1; acquire(&ptable.lock); 80103d21: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103d28: e8 a3 0a 00 00 call 801047d0 <acquire> } } void scheduler_b(void) 80103d2d: b8 d4 2d 11 80 mov $0x80112dd4,%eax 80103d32: ba ff ff ff ff mov $0xffffffff,%edx acquire(&ptable.lock); //min_pass = 10000; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { //cprintf("p ticktes: %d", p->tickets); if(p->state != RUNNABLE) 80103d37: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80103d3b: 74 19 je 80103d56 <scheduler_b+0x46> 80103d3d: 8d 76 00 lea 0x0(%esi),%esi sti(); //struct proc *current; int min_pass=-1; acquire(&ptable.lock); //min_pass = 10000; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103d40: 05 88 00 00 00 add $0x88,%eax //cprintf("p ticktes: %d", p->tickets); if(p->state != RUNNABLE) continue; //if(pid == 0) //pid = p->pid; if(min_pass<0 || p->pass<min_pass) 80103d45: 89 d1 mov %edx,%ecx sti(); //struct proc *current; int min_pass=-1; acquire(&ptable.lock); //min_pass = 10000; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103d47: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80103d4c: 74 2a je 80103d78 <scheduler_b+0x68> { //cprintf("p ticktes: %d", p->tickets); if(p->state != RUNNABLE) 80103d4e: 83 78 0c 03 cmpl $0x3,0xc(%eax) sti(); //struct proc *current; int min_pass=-1; acquire(&ptable.lock); //min_pass = 10000; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103d52: 89 ca mov %ecx,%edx { //cprintf("p ticktes: %d", p->tickets); if(p->state != RUNNABLE) 80103d54: 75 ea jne 80103d40 <scheduler_b+0x30> continue; //if(pid == 0) //pid = p->pid; if(min_pass<0 || p->pass<min_pass) 80103d56: 85 d2 test %edx,%edx 80103d58: 0f 88 8a 00 00 00 js 80103de8 <scheduler_b+0xd8> 80103d5e: 8b 88 84 00 00 00 mov 0x84(%eax),%ecx 80103d64: 39 d1 cmp %edx,%ecx 80103d66: 7d d8 jge 80103d40 <scheduler_b+0x30> 80103d68: 89 c3 mov %eax,%ebx sti(); //struct proc *current; int min_pass=-1; acquire(&ptable.lock); //min_pass = 10000; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103d6a: 05 88 00 00 00 add $0x88,%eax 80103d6f: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80103d74: 75 d8 jne 80103d4e <scheduler_b+0x3e> 80103d76: 66 90 xchg %ax,%ax } //i++; } //cprintf("pid found:%d\n ",p->pid); current->count +=1; current->pass+= 10000/current->tickets; 80103d78: ba 10 27 00 00 mov $0x2710,%edx 80103d7d: 89 d0 mov %edx,%eax 80103d7f: c1 fa 1f sar $0x1f,%edx 80103d82: f7 7b 7c idivl 0x7c(%ebx) // stride = 10; } //i++; } //cprintf("pid found:%d\n ",p->pid); current->count +=1; 80103d85: 83 83 80 00 00 00 01 addl $0x1,0x80(%ebx) current->pass+= 10000/current->tickets; 80103d8c: 01 83 84 00 00 00 add %eax,0x84(%ebx) proc = current; 80103d92: 65 89 1d 04 00 00 00 mov %ebx,%gs:0x4 switchuvm(current); 80103d99: 89 1c 24 mov %ebx,(%esp) 80103d9c: e8 3f 33 00 00 call 801070e0 <switchuvm> current->state = RUNNING; swtch(&cpu->scheduler, current->context); 80103da1: 8b 43 1c mov 0x1c(%ebx),%eax //cprintf("pid found:%d\n ",p->pid); current->count +=1; current->pass+= 10000/current->tickets; proc = current; switchuvm(current); current->state = RUNNING; 80103da4: c7 43 0c 04 00 00 00 movl $0x4,0xc(%ebx) swtch(&cpu->scheduler, current->context); 80103dab: 89 44 24 04 mov %eax,0x4(%esp) 80103daf: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80103db5: 83 c0 04 add $0x4,%eax 80103db8: 89 04 24 mov %eax,(%esp) 80103dbb: e8 fc 0c 00 00 call 80104abc <swtch> switchkvm(); 80103dc0: e8 fb 2b 00 00 call 801069c0 <switchkvm> proc = 0; release(&ptable.lock); 80103dc5: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) switchuvm(current); current->state = RUNNING; swtch(&cpu->scheduler, current->context); switchkvm(); proc = 0; 80103dcc: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80103dd3: 00 00 00 00 release(&ptable.lock); 80103dd7: e8 a4 09 00 00 call 80104780 <release> } 80103ddc: e9 3f ff ff ff jmp 80103d20 <scheduler_b+0x10> 80103de1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi //cprintf("p ticktes: %d", p->tickets); if(p->state != RUNNABLE) continue; //if(pid == 0) //pid = p->pid; if(min_pass<0 || p->pass<min_pass) 80103de8: 8b 88 84 00 00 00 mov 0x84(%eax),%ecx 80103dee: 89 c3 mov %eax,%ebx 80103df0: e9 75 ff ff ff jmp 80103d6a <scheduler_b+0x5a> 80103df5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103df9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103e00 <scheduler>: } void scheduler(void) { 80103e00: 55 push %ebp 80103e01: 89 e5 mov %esp,%ebp 80103e03: 57 push %edi 80103e04: 31 ff xor %edi,%edi 80103e06: 56 push %esi 80103e07: 53 push %ebx 80103e08: 83 ec 1c sub $0x1c,%esp 80103e0b: 90 nop 80103e0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103e10: fb sti min_pass =-1; // Enable interrupts on this processor. sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); 80103e11: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) return (sd*279470273UL)%4294967291UL; } void scheduler(void) 80103e18: be d4 4f 11 80 mov $0x80114fd4,%esi min_pass =-1; // Enable interrupts on this processor. sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); 80103e1d: e8 ae 09 00 00 call 801047d0 <acquire> return (sd*279470273UL)%4294967291UL; } void scheduler(void) 80103e22: b8 d4 2d 11 80 mov $0x80112dd4,%eax 80103e27: ba ff ff ff ff mov $0xffffffff,%edx // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) 80103e2c: 83 78 0c 03 cmpl $0x3,0xc(%eax) 80103e30: 74 1c je 80103e4e <scheduler+0x4e> 80103e32: 8d b6 00 00 00 00 lea 0x0(%esi),%esi sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e38: 05 88 00 00 00 add $0x88,%eax //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) continue; if(p->pass < min_pass || min_pass < 0){ min_pass = p->pass; w_pid = p->pid; 80103e3d: 89 d1 mov %edx,%ecx sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e3f: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80103e44: 74 2a je 80103e70 <scheduler+0x70> //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) 80103e46: 83 78 0c 03 cmpl $0x3,0xc(%eax) sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e4a: 89 ca mov %ecx,%edx //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) 80103e4c: 75 ea jne 80103e38 <scheduler+0x38> continue; if(p->pass < min_pass || min_pass < 0){ 80103e4e: 85 d2 test %edx,%edx 80103e50: 8b 88 84 00 00 00 mov 0x84(%eax),%ecx 80103e56: 78 04 js 80103e5c <scheduler+0x5c> 80103e58: 39 d1 cmp %edx,%ecx 80103e5a: 7d dc jge 80103e38 <scheduler+0x38> min_pass = p->pass; w_pid = p->pid; 80103e5c: 8b 78 10 mov 0x10(%eax),%edi sti(); //CS 202 // Loop over process table looking for process to run. acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e5f: 05 88 00 00 00 add $0x88,%eax 80103e64: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80103e69: 75 db jne 80103e46 <scheduler+0x46> 80103e6b: 90 nop 80103e6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103e70: bb d4 2d 11 80 mov $0x80112dd4,%ebx 80103e75: eb 0b jmp 80103e82 <scheduler+0x82> 80103e77: 90 nop if(p->pass < min_pass || min_pass < 0){ min_pass = p->pass; w_pid = p->pid; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e78: 81 c3 88 00 00 00 add $0x88,%ebx 80103e7e: 39 de cmp %ebx,%esi 80103e80: 74 6e je 80103ef0 <scheduler+0xf0> //cprintf("Inside: %d", p->state); if(p->state != RUNNABLE) 80103e82: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 80103e86: 75 f0 jne 80103e78 <scheduler+0x78> continue; if(p->pid != w_pid) 80103e88: 39 7b 10 cmp %edi,0x10(%ebx) 80103e8b: 75 eb jne 80103e78 <scheduler+0x78> // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; p->pass += (10000/p->tickets); 80103e8d: ba 10 27 00 00 mov $0x2710,%edx 80103e92: 89 d0 mov %edx,%eax 80103e94: c1 fa 1f sar $0x1f,%edx 80103e97: f7 7b 7c idivl 0x7c(%ebx) // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; 80103e9a: 83 83 80 00 00 00 01 addl $0x1,0x80(%ebx) p->pass += (10000/p->tickets); proc = p; 80103ea1: 65 89 1d 04 00 00 00 mov %ebx,%gs:0x4 switchuvm(p); 80103ea8: 89 1c 24 mov %ebx,(%esp) // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. //cprintf("pid : ",p->pid); p->count +=1; p->pass += (10000/p->tickets); 80103eab: 01 83 84 00 00 00 add %eax,0x84(%ebx) proc = p; switchuvm(p); 80103eb1: e8 2a 32 00 00 call 801070e0 <switchuvm> p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103eb6: 8b 43 1c mov 0x1c(%ebx),%eax //cprintf("pid : ",p->pid); p->count +=1; p->pass += (10000/p->tickets); proc = p; switchuvm(p); p->state = RUNNING; 80103eb9: c7 43 0c 04 00 00 00 movl $0x4,0xc(%ebx) if(p->pass < min_pass || min_pass < 0){ min_pass = p->pass; w_pid = p->pid; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ec0: 81 c3 88 00 00 00 add $0x88,%ebx p->count +=1; p->pass += (10000/p->tickets); proc = p; switchuvm(p); p->state = RUNNING; swtch(&cpu->scheduler, p->context); 80103ec6: 89 44 24 04 mov %eax,0x4(%esp) 80103eca: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80103ed0: 83 c0 04 add $0x4,%eax 80103ed3: 89 04 24 mov %eax,(%esp) 80103ed6: e8 e1 0b 00 00 call 80104abc <swtch> switchkvm(); 80103edb: e8 e0 2a 00 00 call 801069c0 <switchkvm> if(p->pass < min_pass || min_pass < 0){ min_pass = p->pass; w_pid = p->pid; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ee0: 39 de cmp %ebx,%esi swtch(&cpu->scheduler, p->context); switchkvm(); // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; 80103ee2: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 80103ee9: 00 00 00 00 if(p->pass < min_pass || min_pass < 0){ min_pass = p->pass; w_pid = p->pid; } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103eed: 75 93 jne 80103e82 <scheduler+0x82> 80103eef: 90 nop // Process is done running for now. // It should have changed its p->state before coming back. proc = 0; } release(&ptable.lock); 80103ef0: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103ef7: e8 84 08 00 00 call 80104780 <release> } 80103efc: e9 0f ff ff ff jmp 80103e10 <scheduler+0x10> 80103f01: eb 0d jmp 80103f10 <wait> 80103f03: 90 nop 80103f04: 90 nop 80103f05: 90 nop 80103f06: 90 nop 80103f07: 90 nop 80103f08: 90 nop 80103f09: 90 nop 80103f0a: 90 nop 80103f0b: 90 nop 80103f0c: 90 nop 80103f0d: 90 nop 80103f0e: 90 nop 80103f0f: 90 nop 80103f10 <wait>: // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80103f10: 55 push %ebp 80103f11: 89 e5 mov %esp,%ebp 80103f13: 53 push %ebx struct proc *p; int havekids, pid; acquire(&ptable.lock); 80103f14: bb d4 2d 11 80 mov $0x80112dd4,%ebx // Wait for a child process to exit and return its pid. // Return -1 if this process has no children. int wait(void) { 80103f19: 83 ec 24 sub $0x24,%esp struct proc *p; int havekids, pid; acquire(&ptable.lock); 80103f1c: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103f23: e8 a8 08 00 00 call 801047d0 <acquire> 80103f28: 31 c0 xor %eax,%eax 80103f2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f30: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx 80103f36: 72 30 jb 80103f68 <wait+0x58> return pid; } } // No point waiting if we don't have any children. if(!havekids || proc->killed){ 80103f38: 85 c0 test %eax,%eax 80103f3a: 74 54 je 80103f90 <wait+0x80> 80103f3c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80103f42: 8b 50 24 mov 0x24(%eax),%edx 80103f45: 85 d2 test %edx,%edx 80103f47: 75 47 jne 80103f90 <wait+0x80> release(&ptable.lock); return -1; } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(proc, &ptable.lock); //DOC: wait-sleep 80103f49: bb d4 2d 11 80 mov $0x80112dd4,%ebx 80103f4e: 89 04 24 mov %eax,(%esp) 80103f51: c7 44 24 04 a0 2d 11 movl $0x80112da0,0x4(%esp) 80103f58: 80 80103f59: e8 22 fb ff ff call 80103a80 <sleep> 80103f5e: 31 c0 xor %eax,%eax acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f60: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx 80103f66: 73 d0 jae 80103f38 <wait+0x28> if(p->parent != proc) 80103f68: 8b 53 14 mov 0x14(%ebx),%edx 80103f6b: 65 3b 15 04 00 00 00 cmp %gs:0x4,%edx 80103f72: 74 0c je 80103f80 <wait+0x70> acquire(&ptable.lock); for(;;){ // Scan through table looking for exited children. havekids = 0; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103f74: 81 c3 88 00 00 00 add $0x88,%ebx 80103f7a: eb b4 jmp 80103f30 <wait+0x20> 80103f7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->parent != proc) continue; havekids = 1; if(p->state == ZOMBIE){ 80103f80: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 80103f84: 74 21 je 80103fa7 <wait+0x97> p->parent = 0; p->name[0] = 0; p->killed = 0; p->state = UNUSED; release(&ptable.lock); return pid; 80103f86: b8 01 00 00 00 mov $0x1,%eax 80103f8b: eb e7 jmp 80103f74 <wait+0x64> 80103f8d: 8d 76 00 lea 0x0(%esi),%esi } } // No point waiting if we don't have any children. if(!havekids || proc->killed){ release(&ptable.lock); 80103f90: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103f97: e8 e4 07 00 00 call 80104780 <release> 80103f9c: b8 ff ff ff ff mov $0xffffffff,%eax } // Wait for children to exit. (See wakeup1 call in proc_exit.) sleep(proc, &ptable.lock); //DOC: wait-sleep } } 80103fa1: 83 c4 24 add $0x24,%esp 80103fa4: 5b pop %ebx 80103fa5: 5d pop %ebp 80103fa6: c3 ret if(p->parent != proc) continue; havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; 80103fa7: 8b 43 10 mov 0x10(%ebx),%eax kfree(p->kstack); 80103faa: 8b 53 08 mov 0x8(%ebx),%edx 80103fad: 89 45 f4 mov %eax,-0xc(%ebp) 80103fb0: 89 14 24 mov %edx,(%esp) 80103fb3: e8 f8 e3 ff ff call 801023b0 <kfree> p->kstack = 0; freevm(p->pgdir); 80103fb8: 8b 53 04 mov 0x4(%ebx),%edx havekids = 1; if(p->state == ZOMBIE){ // Found one. pid = p->pid; kfree(p->kstack); p->kstack = 0; 80103fbb: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 80103fc2: 89 14 24 mov %edx,(%esp) 80103fc5: e8 e6 2d 00 00 call 80106db0 <freevm> p->pid = 0; 80103fca: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 80103fd1: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80103fd8: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80103fdc: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 80103fe3: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80103fea: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80103ff1: e8 8a 07 00 00 call 80104780 <release> return pid; 80103ff6: 8b 45 f4 mov -0xc(%ebp),%eax 80103ff9: eb a6 jmp 80103fa1 <wait+0x91> 80103ffb: 90 nop 80103ffc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104000 <exit>: // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80104000: 55 push %ebp 80104001: 89 e5 mov %esp,%ebp 80104003: 56 push %esi 80104004: 53 push %ebx struct proc *p; int fd; cprintf("number of runs of %s is %d\n",proc->name, proc->count); if(proc == initproc) panic("init exiting"); 80104005: 31 db xor %ebx,%ebx // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { 80104007: 83 ec 10 sub $0x10,%esp struct proc *p; int fd; cprintf("number of runs of %s is %d\n",proc->name, proc->count); 8010400a: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104010: 8b 90 80 00 00 00 mov 0x80(%eax),%edx 80104016: 83 c0 6c add $0x6c,%eax 80104019: 89 44 24 04 mov %eax,0x4(%esp) 8010401d: c7 04 24 e1 78 10 80 movl $0x801078e1,(%esp) 80104024: 89 54 24 08 mov %edx,0x8(%esp) 80104028: e8 43 c8 ff ff call 80100870 <cprintf> if(proc == initproc) 8010402d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104033: 3b 05 c8 a5 10 80 cmp 0x8010a5c8,%eax 80104039: 75 0b jne 80104046 <exit+0x46> 8010403b: e9 10 01 00 00 jmp 80104150 <exit+0x150> panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80104040: 65 a1 04 00 00 00 mov %gs:0x4,%eax if(proc->ofile[fd]){ 80104046: 8d 73 08 lea 0x8(%ebx),%esi 80104049: 8b 44 b0 08 mov 0x8(%eax,%esi,4),%eax 8010404d: 85 c0 test %eax,%eax 8010404f: 74 16 je 80104067 <exit+0x67> fileclose(proc->ofile[fd]); 80104051: 89 04 24 mov %eax,(%esp) 80104054: e8 07 d0 ff ff call 80101060 <fileclose> proc->ofile[fd] = 0; 80104059: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010405f: c7 44 b0 08 00 00 00 movl $0x0,0x8(%eax,%esi,4) 80104066: 00 cprintf("number of runs of %s is %d\n",proc->name, proc->count); if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ 80104067: 83 c3 01 add $0x1,%ebx 8010406a: 83 fb 10 cmp $0x10,%ebx 8010406d: 75 d1 jne 80104040 <exit+0x40> fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } begin_op(); 8010406f: e8 3c ed ff ff call 80102db0 <begin_op> iput(proc->cwd); 80104074: 65 a1 04 00 00 00 mov %gs:0x4,%eax 8010407a: 8b 40 68 mov 0x68(%eax),%eax 8010407d: 89 04 24 mov %eax,(%esp) 80104080: e8 ab d3 ff ff call 80101430 <iput> end_op(); 80104085: e8 f6 eb ff ff call 80102c80 <end_op> proc->cwd = 0; 8010408a: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104090: c7 40 68 00 00 00 00 movl $0x0,0x68(%eax) acquire(&ptable.lock); 80104097: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 8010409e: e8 2d 07 00 00 call 801047d0 <acquire> // Parent might be sleeping in wait(). wakeup1(proc->parent); 801040a3: 65 8b 0d 04 00 00 00 mov %gs:0x4,%ecx // Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) 801040aa: b8 d4 2d 11 80 mov $0x80112dd4,%eax proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); 801040af: 8b 51 14 mov 0x14(%ecx),%edx 801040b2: eb 10 jmp 801040c4 <exit+0xc4> 801040b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801040b8: 05 88 00 00 00 add $0x88,%eax 801040bd: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 801040c2: 74 1e je 801040e2 <exit+0xe2> if(p->state == SLEEPING && p->chan == chan) 801040c4: 83 78 0c 02 cmpl $0x2,0xc(%eax) 801040c8: 75 ee jne 801040b8 <exit+0xb8> 801040ca: 3b 50 20 cmp 0x20(%eax),%edx 801040cd: 75 e9 jne 801040b8 <exit+0xb8> p->state = RUNNABLE; 801040cf: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801040d6: 05 88 00 00 00 add $0x88,%eax 801040db: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 801040e0: 75 e2 jne 801040c4 <exit+0xc4> wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == proc){ p->parent = initproc; 801040e2: 8b 1d c8 a5 10 80 mov 0x8010a5c8,%ebx 801040e8: ba d4 2d 11 80 mov $0x80112dd4,%edx 801040ed: eb 0f jmp 801040fe <exit+0xfe> 801040ef: 90 nop // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801040f0: 81 c2 88 00 00 00 add $0x88,%edx 801040f6: 81 fa d4 4f 11 80 cmp $0x80114fd4,%edx 801040fc: 74 3a je 80104138 <exit+0x138> if(p->parent == proc){ 801040fe: 3b 4a 14 cmp 0x14(%edx),%ecx 80104101: 75 ed jne 801040f0 <exit+0xf0> p->parent = initproc; if(p->state == ZOMBIE) 80104103: 83 7a 0c 05 cmpl $0x5,0xc(%edx) wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == proc){ p->parent = initproc; 80104107: 89 5a 14 mov %ebx,0x14(%edx) if(p->state == ZOMBIE) 8010410a: 75 e4 jne 801040f0 <exit+0xf0> 8010410c: b8 d4 2d 11 80 mov $0x80112dd4,%eax 80104111: eb 11 jmp 80104124 <exit+0x124> 80104113: 90 nop 80104114: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80104118: 05 88 00 00 00 add $0x88,%eax 8010411d: 3d d4 4f 11 80 cmp $0x80114fd4,%eax 80104122: 74 cc je 801040f0 <exit+0xf0> if(p->state == SLEEPING && p->chan == chan) 80104124: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80104128: 75 ee jne 80104118 <exit+0x118> 8010412a: 3b 58 20 cmp 0x20(%eax),%ebx 8010412d: 75 e9 jne 80104118 <exit+0x118> p->state = RUNNABLE; 8010412f: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80104136: eb e0 jmp 80104118 <exit+0x118> wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; 80104138: c7 41 0c 05 00 00 00 movl $0x5,0xc(%ecx) sched(); 8010413f: e8 9c f8 ff ff call 801039e0 <sched> panic("zombie exit"); 80104144: c7 04 24 0b 79 10 80 movl $0x8010790b,(%esp) 8010414b: e8 80 c2 ff ff call 801003d0 <panic> { struct proc *p; int fd; cprintf("number of runs of %s is %d\n",proc->name, proc->count); if(proc == initproc) panic("init exiting"); 80104150: c7 04 24 fe 78 10 80 movl $0x801078fe,(%esp) 80104157: e8 74 c2 ff ff call 801003d0 <panic> 8010415c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104160 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 80104160: 55 push %ebp 80104161: 89 e5 mov %esp,%ebp 80104163: 53 push %ebx 80104164: 83 ec 14 sub $0x14,%esp struct proc *p; char *sp; acquire(&ptable.lock); 80104167: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 8010416e: e8 5d 06 00 00 call 801047d0 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) 80104173: 8b 1d e0 2d 11 80 mov 0x80112de0,%ebx 80104179: 85 db test %ebx,%ebx 8010417b: 0f 84 cd 00 00 00 je 8010424e <allocproc+0xee> // Look in the process table for an UNUSED proc. // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) 80104181: bb 5c 2e 11 80 mov $0x80112e5c,%ebx 80104186: eb 12 jmp 8010419a <allocproc+0x3a> { struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80104188: 81 c3 88 00 00 00 add $0x88,%ebx 8010418e: 81 fb d4 4f 11 80 cmp $0x80114fd4,%ebx 80104194: 0f 84 9e 00 00 00 je 80104238 <allocproc+0xd8> if(p->state == UNUSED) 8010419a: 8b 4b 0c mov 0xc(%ebx),%ecx 8010419d: 85 c9 test %ecx,%ecx 8010419f: 75 e7 jne 80104188 <allocproc+0x28> goto found; release(&ptable.lock); return 0; found: p->state = EMBRYO; 801041a1: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->pid = nextpid++; 801041a8: a1 04 a0 10 80 mov 0x8010a004,%eax 801041ad: 89 43 10 mov %eax,0x10(%ebx) 801041b0: 83 c0 01 add $0x1,%eax 801041b3: a3 04 a0 10 80 mov %eax,0x8010a004 release(&ptable.lock); 801041b8: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801041bf: e8 bc 05 00 00 call 80104780 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 801041c4: e8 97 e1 ff ff call 80102360 <kalloc> 801041c9: 85 c0 test %eax,%eax 801041cb: 89 43 08 mov %eax,0x8(%ebx) 801041ce: 0f 84 84 00 00 00 je 80104258 <allocproc+0xf8> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 801041d4: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx p->tf = (struct trapframe*)sp; 801041da: 89 53 18 mov %edx,0x18(%ebx) // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; 801041dd: c7 80 b0 0f 00 00 c0 movl $0x80105ac0,0xfb0(%eax) 801041e4: 5a 10 80 sp -= sizeof *p->context; p->context = (struct context*)sp; 801041e7: 05 9c 0f 00 00 add $0xf9c,%eax 801041ec: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 801041ef: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 801041f6: 00 801041f7: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801041fe: 00 801041ff: 89 04 24 mov %eax,(%esp) 80104202: e8 69 06 00 00 call 80104870 <memset> p->context->eip = (uint)forkret; 80104207: 8b 43 1c mov 0x1c(%ebx),%eax 8010420a: c7 40 10 90 39 10 80 movl $0x80103990,0x10(%eax) p->tickets = 1; 80104211: c7 43 7c 01 00 00 00 movl $0x1,0x7c(%ebx) p->count = 0; 80104218: c7 83 80 00 00 00 00 movl $0x0,0x80(%ebx) 8010421f: 00 00 00 p->pass = 1; 80104222: c7 83 84 00 00 00 01 movl $0x1,0x84(%ebx) 80104229: 00 00 00 //total_tickets += 1; return p; } 8010422c: 89 d8 mov %ebx,%eax 8010422e: 83 c4 14 add $0x14,%esp 80104231: 5b pop %ebx 80104232: 5d pop %ebp 80104233: c3 ret 80104234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); 80104238: 31 db xor %ebx,%ebx 8010423a: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80104241: e8 3a 05 00 00 call 80104780 <release> p->tickets = 1; p->count = 0; p->pass = 1; //total_tickets += 1; return p; } 80104246: 89 d8 mov %ebx,%eax 80104248: 83 c4 14 add $0x14,%esp 8010424b: 5b pop %ebx 8010424c: 5d pop %ebp 8010424d: c3 ret acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); return 0; 8010424e: bb d4 2d 11 80 mov $0x80112dd4,%ebx 80104253: e9 49 ff ff ff jmp 801041a1 <allocproc+0x41> p->pid = nextpid++; release(&ptable.lock); // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ p->state = UNUSED; 80104258: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) 8010425f: 31 db xor %ebx,%ebx return 0; 80104261: eb c9 jmp 8010422c <allocproc+0xcc> 80104263: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104270 <fork>: // Create a new process copying p as the parent. // Sets up stack to return as if from system call. // Caller must set state of returned proc to RUNNABLE. int fork(void) { 80104270: 55 push %ebp 80104271: 89 e5 mov %esp,%ebp 80104273: 57 push %edi 80104274: 56 push %esi int i, pid; struct proc *np; // Allocate process. if((np = allocproc()) == 0){ 80104275: be ff ff ff ff mov $0xffffffff,%esi // Create a new process copying p as the parent. // Sets up stack to return as if from system call. // Caller must set state of returned proc to RUNNABLE. int fork(void) { 8010427a: 53 push %ebx 8010427b: 83 ec 1c sub $0x1c,%esp int i, pid; struct proc *np; // Allocate process. if((np = allocproc()) == 0){ 8010427e: e8 dd fe ff ff call 80104160 <allocproc> 80104283: 85 c0 test %eax,%eax 80104285: 89 c3 mov %eax,%ebx 80104287: 0f 84 d6 00 00 00 je 80104363 <fork+0xf3> return -1; } // Copy process state from p. if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){ 8010428d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104293: 8b 10 mov (%eax),%edx 80104295: 89 54 24 04 mov %edx,0x4(%esp) 80104299: 8b 40 04 mov 0x4(%eax),%eax 8010429c: 89 04 24 mov %eax,(%esp) 8010429f: e8 8c 2b 00 00 call 80106e30 <copyuvm> 801042a4: 85 c0 test %eax,%eax 801042a6: 89 43 04 mov %eax,0x4(%ebx) 801042a9: 0f 84 be 00 00 00 je 8010436d <fork+0xfd> kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = proc->sz; 801042af: 65 a1 04 00 00 00 mov %gs:0x4,%eax np->parent = proc; *np->tf = *proc->tf; 801042b5: b9 13 00 00 00 mov $0x13,%ecx kfree(np->kstack); np->kstack = 0; np->state = UNUSED; return -1; } np->sz = proc->sz; 801042ba: 8b 00 mov (%eax),%eax 801042bc: 89 03 mov %eax,(%ebx) np->parent = proc; 801042be: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801042c4: 89 43 14 mov %eax,0x14(%ebx) *np->tf = *proc->tf; 801042c7: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 801042ce: 8b 43 18 mov 0x18(%ebx),%eax 801042d1: 8b 72 18 mov 0x18(%edx),%esi 801042d4: 89 c7 mov %eax,%edi 801042d6: f3 a5 rep movsl %ds:(%esi),%es:(%edi) // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; 801042d8: 31 f6 xor %esi,%esi 801042da: 8b 43 18 mov 0x18(%ebx),%eax 801042dd: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) 801042e4: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 801042eb: 90 nop 801042ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; i < NOFILE; i++) if(proc->ofile[i]) 801042f0: 8b 44 b2 28 mov 0x28(%edx,%esi,4),%eax 801042f4: 85 c0 test %eax,%eax 801042f6: 74 13 je 8010430b <fork+0x9b> np->ofile[i] = filedup(proc->ofile[i]); 801042f8: 89 04 24 mov %eax,(%esp) 801042fb: e8 90 cc ff ff call 80100f90 <filedup> 80104300: 89 44 b3 28 mov %eax,0x28(%ebx,%esi,4) 80104304: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx *np->tf = *proc->tf; // Clear %eax so that fork returns 0 in the child. np->tf->eax = 0; for(i = 0; i < NOFILE; i++) 8010430b: 83 c6 01 add $0x1,%esi 8010430e: 83 fe 10 cmp $0x10,%esi 80104311: 75 dd jne 801042f0 <fork+0x80> if(proc->ofile[i]) np->ofile[i] = filedup(proc->ofile[i]); np->cwd = idup(proc->cwd); 80104313: 8b 42 68 mov 0x68(%edx),%eax 80104316: 89 04 24 mov %eax,(%esp) 80104319: e8 72 ce ff ff call 80101190 <idup> 8010431e: 89 43 68 mov %eax,0x68(%ebx) safestrcpy(np->name, proc->name, sizeof(proc->name)); 80104321: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104327: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 8010432e: 00 8010432f: 83 c0 6c add $0x6c,%eax 80104332: 89 44 24 04 mov %eax,0x4(%esp) 80104336: 8d 43 6c lea 0x6c(%ebx),%eax 80104339: 89 04 24 mov %eax,(%esp) 8010433c: e8 1f 07 00 00 call 80104a60 <safestrcpy> pid = np->pid; 80104341: 8b 73 10 mov 0x10(%ebx),%esi acquire(&ptable.lock); 80104344: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 8010434b: e8 80 04 00 00 call 801047d0 <acquire> np->state = RUNNABLE; 80104350: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 80104357: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 8010435e: e8 1d 04 00 00 call 80104780 <release> return pid; } 80104363: 83 c4 1c add $0x1c,%esp 80104366: 89 f0 mov %esi,%eax 80104368: 5b pop %ebx 80104369: 5e pop %esi 8010436a: 5f pop %edi 8010436b: 5d pop %ebp 8010436c: c3 ret return -1; } // Copy process state from p. if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){ kfree(np->kstack); 8010436d: 8b 43 08 mov 0x8(%ebx),%eax 80104370: 89 04 24 mov %eax,(%esp) 80104373: e8 38 e0 ff ff call 801023b0 <kfree> np->kstack = 0; 80104378: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) np->state = UNUSED; 8010437f: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return -1; 80104386: eb db jmp 80104363 <fork+0xf3> 80104388: 90 nop 80104389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104390 <growproc>: // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 80104390: 55 push %ebp 80104391: 89 e5 mov %esp,%ebp 80104393: 83 ec 18 sub $0x18,%esp uint sz; sz = proc->sz; 80104396: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx // Grow current process's memory by n bytes. // Return 0 on success, -1 on failure. int growproc(int n) { 8010439d: 8b 4d 08 mov 0x8(%ebp),%ecx uint sz; sz = proc->sz; 801043a0: 8b 02 mov (%edx),%eax if(n > 0){ 801043a2: 83 f9 00 cmp $0x0,%ecx 801043a5: 7f 19 jg 801043c0 <growproc+0x30> if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0) return -1; } else if(n < 0){ 801043a7: 75 39 jne 801043e2 <growproc+0x52> if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0) return -1; } proc->sz = sz; 801043a9: 89 02 mov %eax,(%edx) switchuvm(proc); 801043ab: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801043b1: 89 04 24 mov %eax,(%esp) 801043b4: e8 27 2d 00 00 call 801070e0 <switchuvm> 801043b9: 31 c0 xor %eax,%eax return 0; } 801043bb: c9 leave 801043bc: c3 ret 801043bd: 8d 76 00 lea 0x0(%esi),%esi { uint sz; sz = proc->sz; if(n > 0){ if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0) 801043c0: 01 c1 add %eax,%ecx 801043c2: 89 4c 24 08 mov %ecx,0x8(%esp) 801043c6: 89 44 24 04 mov %eax,0x4(%esp) 801043ca: 8b 42 04 mov 0x4(%edx),%eax 801043cd: 89 04 24 mov %eax,(%esp) 801043d0: e8 2b 2b 00 00 call 80106f00 <allocuvm> 801043d5: 85 c0 test %eax,%eax 801043d7: 74 27 je 80104400 <growproc+0x70> return -1; } else if(n < 0){ if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0) 801043d9: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 801043e0: eb c7 jmp 801043a9 <growproc+0x19> 801043e2: 01 c1 add %eax,%ecx 801043e4: 89 4c 24 08 mov %ecx,0x8(%esp) 801043e8: 89 44 24 04 mov %eax,0x4(%esp) 801043ec: 8b 42 04 mov 0x4(%edx),%eax 801043ef: 89 04 24 mov %eax,(%esp) 801043f2: e8 19 29 00 00 call 80106d10 <deallocuvm> 801043f7: 85 c0 test %eax,%eax 801043f9: 75 de jne 801043d9 <growproc+0x49> 801043fb: 90 nop 801043fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; } proc->sz = sz; switchuvm(proc); return 0; 80104400: b8 ff ff ff ff mov $0xffffffff,%eax } 80104405: c9 leave 80104406: c3 ret 80104407: 89 f6 mov %esi,%esi 80104409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104410 <userinit>: //PAGEBREAK: 32 // Set up first user process. void userinit(void) { 80104410: 55 push %ebp 80104411: 89 e5 mov %esp,%ebp 80104413: 53 push %ebx 80104414: 83 ec 14 sub $0x14,%esp struct proc *p; extern char _binary_initcode_start[], _binary_initcode_size[]; p = allocproc(); 80104417: e8 44 fd ff ff call 80104160 <allocproc> 8010441c: 89 c3 mov %eax,%ebx initproc = p; 8010441e: a3 c8 a5 10 80 mov %eax,0x8010a5c8 if((p->pgdir = setupkvm()) == 0) 80104423: e8 88 27 00 00 call 80106bb0 <setupkvm> 80104428: 85 c0 test %eax,%eax 8010442a: 89 43 04 mov %eax,0x4(%ebx) 8010442d: 0f 84 ce 00 00 00 je 80104501 <userinit+0xf1> panic("userinit: out of memory?"); inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 80104433: 89 04 24 mov %eax,(%esp) 80104436: c7 44 24 08 2c 00 00 movl $0x2c,0x8(%esp) 8010443d: 00 8010443e: c7 44 24 04 60 a4 10 movl $0x8010a460,0x4(%esp) 80104445: 80 80104446: e8 35 28 00 00 call 80106c80 <inituvm> p->sz = PGSIZE; 8010444b: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 80104451: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) 80104458: 00 80104459: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104460: 00 80104461: 8b 43 18 mov 0x18(%ebx),%eax 80104464: 89 04 24 mov %eax,(%esp) 80104467: e8 04 04 00 00 call 80104870 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 8010446c: 8b 43 18 mov 0x18(%ebx),%eax 8010446f: 66 c7 40 3c 23 00 movw $0x23,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80104475: 8b 43 18 mov 0x18(%ebx),%eax 80104478: 66 c7 40 2c 2b 00 movw $0x2b,0x2c(%eax) p->tf->es = p->tf->ds; 8010447e: 8b 43 18 mov 0x18(%ebx),%eax 80104481: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80104485: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 80104489: 8b 43 18 mov 0x18(%ebx),%eax 8010448c: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80104490: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 80104494: 8b 43 18 mov 0x18(%ebx),%eax 80104497: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 8010449e: 8b 43 18 mov 0x18(%ebx),%eax 801044a1: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 801044a8: 8b 43 18 mov 0x18(%ebx),%eax 801044ab: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 801044b2: 8d 43 6c lea 0x6c(%ebx),%eax 801044b5: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 801044bc: 00 801044bd: c7 44 24 04 30 79 10 movl $0x80107930,0x4(%esp) 801044c4: 80 801044c5: 89 04 24 mov %eax,(%esp) 801044c8: e8 93 05 00 00 call 80104a60 <safestrcpy> p->cwd = namei("/"); 801044cd: c7 04 24 39 79 10 80 movl $0x80107939,(%esp) 801044d4: e8 e7 d9 ff ff call 80101ec0 <namei> 801044d9: 89 43 68 mov %eax,0x68(%ebx) // this assignment to p->state lets other cores // run this process. the acquire forces the above // writes to be visible, and the lock is also needed // because the assignment might not be atomic. acquire(&ptable.lock); 801044dc: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801044e3: e8 e8 02 00 00 call 801047d0 <acquire> p->state = RUNNABLE; 801044e8: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) //asign tickets here again ... release(&ptable.lock); 801044ef: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 801044f6: e8 85 02 00 00 call 80104780 <release> } 801044fb: 83 c4 14 add $0x14,%esp 801044fe: 5b pop %ebx 801044ff: 5d pop %ebp 80104500: c3 ret p = allocproc(); initproc = p; if((p->pgdir = setupkvm()) == 0) panic("userinit: out of memory?"); 80104501: c7 04 24 17 79 10 80 movl $0x80107917,(%esp) 80104508: e8 c3 be ff ff call 801003d0 <panic> 8010450d: 8d 76 00 lea 0x0(%esi),%esi 80104510 <pinit>: static void wakeup1(void *chan); void pinit(void) { 80104510: 55 push %ebp 80104511: 89 e5 mov %esp,%ebp 80104513: 83 ec 18 sub $0x18,%esp initlock(&ptable.lock, "ptable"); 80104516: c7 44 24 04 3b 79 10 movl $0x8010793b,0x4(%esp) 8010451d: 80 8010451e: c7 04 24 a0 2d 11 80 movl $0x80112da0,(%esp) 80104525: e8 16 01 00 00 call 80104640 <initlock> } 8010452a: c9 leave 8010452b: c3 ret 8010452c: 00 00 add %al,(%eax) ... 80104530 <holdingsleep>: release(&lk->lk); } int holdingsleep(struct sleeplock *lk) { 80104530: 55 push %ebp 80104531: 89 e5 mov %esp,%ebp 80104533: 83 ec 18 sub $0x18,%esp 80104536: 89 75 fc mov %esi,-0x4(%ebp) 80104539: 8b 75 08 mov 0x8(%ebp),%esi 8010453c: 89 5d f8 mov %ebx,-0x8(%ebp) int r; acquire(&lk->lk); 8010453f: 8d 5e 04 lea 0x4(%esi),%ebx 80104542: 89 1c 24 mov %ebx,(%esp) 80104545: e8 86 02 00 00 call 801047d0 <acquire> r = lk->locked; 8010454a: 8b 36 mov (%esi),%esi release(&lk->lk); 8010454c: 89 1c 24 mov %ebx,(%esp) 8010454f: e8 2c 02 00 00 call 80104780 <release> return r; } 80104554: 8b 5d f8 mov -0x8(%ebp),%ebx 80104557: 89 f0 mov %esi,%eax 80104559: 8b 75 fc mov -0x4(%ebp),%esi 8010455c: 89 ec mov %ebp,%esp 8010455e: 5d pop %ebp 8010455f: c3 ret 80104560 <releasesleep>: release(&lk->lk); } void releasesleep(struct sleeplock *lk) { 80104560: 55 push %ebp 80104561: 89 e5 mov %esp,%ebp 80104563: 83 ec 18 sub $0x18,%esp 80104566: 89 5d f8 mov %ebx,-0x8(%ebp) 80104569: 8b 5d 08 mov 0x8(%ebp),%ebx 8010456c: 89 75 fc mov %esi,-0x4(%ebp) acquire(&lk->lk); 8010456f: 8d 73 04 lea 0x4(%ebx),%esi 80104572: 89 34 24 mov %esi,(%esp) 80104575: e8 56 02 00 00 call 801047d0 <acquire> lk->locked = 0; 8010457a: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80104580: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104587: 89 1c 24 mov %ebx,(%esp) 8010458a: e8 91 f3 ff ff call 80103920 <wakeup> release(&lk->lk); } 8010458f: 8b 5d f8 mov -0x8(%ebp),%ebx { acquire(&lk->lk); lk->locked = 0; lk->pid = 0; wakeup(lk); release(&lk->lk); 80104592: 89 75 08 mov %esi,0x8(%ebp) } 80104595: 8b 75 fc mov -0x4(%ebp),%esi 80104598: 89 ec mov %ebp,%esp 8010459a: 5d pop %ebp { acquire(&lk->lk); lk->locked = 0; lk->pid = 0; wakeup(lk); release(&lk->lk); 8010459b: e9 e0 01 00 00 jmp 80104780 <release> 801045a0 <acquiresleep>: lk->pid = 0; } void acquiresleep(struct sleeplock *lk) { 801045a0: 55 push %ebp 801045a1: 89 e5 mov %esp,%ebp 801045a3: 56 push %esi 801045a4: 53 push %ebx 801045a5: 83 ec 10 sub $0x10,%esp 801045a8: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 801045ab: 8d 73 04 lea 0x4(%ebx),%esi 801045ae: 89 34 24 mov %esi,(%esp) 801045b1: e8 1a 02 00 00 call 801047d0 <acquire> while (lk->locked) { 801045b6: 8b 13 mov (%ebx),%edx 801045b8: 85 d2 test %edx,%edx 801045ba: 74 16 je 801045d2 <acquiresleep+0x32> 801045bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sleep(lk, &lk->lk); 801045c0: 89 74 24 04 mov %esi,0x4(%esp) 801045c4: 89 1c 24 mov %ebx,(%esp) 801045c7: e8 b4 f4 ff ff call 80103a80 <sleep> void acquiresleep(struct sleeplock *lk) { acquire(&lk->lk); while (lk->locked) { 801045cc: 8b 03 mov (%ebx),%eax 801045ce: 85 c0 test %eax,%eax 801045d0: 75 ee jne 801045c0 <acquiresleep+0x20> sleep(lk, &lk->lk); } lk->locked = 1; 801045d2: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = proc->pid; 801045d8: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801045de: 8b 40 10 mov 0x10(%eax),%eax 801045e1: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 801045e4: 89 75 08 mov %esi,0x8(%ebp) } 801045e7: 83 c4 10 add $0x10,%esp 801045ea: 5b pop %ebx 801045eb: 5e pop %esi 801045ec: 5d pop %ebp while (lk->locked) { sleep(lk, &lk->lk); } lk->locked = 1; lk->pid = proc->pid; release(&lk->lk); 801045ed: e9 8e 01 00 00 jmp 80104780 <release> 801045f2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104600 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 80104600: 55 push %ebp 80104601: 89 e5 mov %esp,%ebp 80104603: 53 push %ebx 80104604: 83 ec 14 sub $0x14,%esp 80104607: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 8010460a: c7 44 24 04 84 79 10 movl $0x80107984,0x4(%esp) 80104611: 80 80104612: 8d 43 04 lea 0x4(%ebx),%eax 80104615: 89 04 24 mov %eax,(%esp) 80104618: e8 23 00 00 00 call 80104640 <initlock> lk->name = name; 8010461d: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 80104620: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80104626: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) void initsleeplock(struct sleeplock *lk, char *name) { initlock(&lk->lk, "sleep lock"); lk->name = name; 8010462d: 89 43 38 mov %eax,0x38(%ebx) lk->locked = 0; lk->pid = 0; } 80104630: 83 c4 14 add $0x14,%esp 80104633: 5b pop %ebx 80104634: 5d pop %ebp 80104635: c3 ret ... 80104640 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 80104640: 55 push %ebp 80104641: 89 e5 mov %esp,%ebp 80104643: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 80104646: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 80104649: c7 00 00 00 00 00 movl $0x0,(%eax) #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { lk->name = name; 8010464f: 89 50 04 mov %edx,0x4(%eax) lk->locked = 0; lk->cpu = 0; 80104652: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 80104659: 5d pop %ebp 8010465a: c3 ret 8010465b: 90 nop 8010465c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104660 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104660: 55 push %ebp uint *ebp; int i; ebp = (uint*)v - 2; 80104661: 31 c0 xor %eax,%eax } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104663: 89 e5 mov %esp,%ebp uint *ebp; int i; ebp = (uint*)v - 2; 80104665: 8b 55 08 mov 0x8(%ebp),%edx } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104668: 8b 4d 0c mov 0xc(%ebp),%ecx 8010466b: 53 push %ebx uint *ebp; int i; ebp = (uint*)v - 2; 8010466c: 83 ea 08 sub $0x8,%edx 8010466f: 90 nop for(i = 0; i < 10; i++){ if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80104670: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 80104676: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 8010467c: 77 1a ja 80104698 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 8010467e: 8b 5a 04 mov 0x4(%edx),%ebx 80104681: 89 1c 81 mov %ebx,(%ecx,%eax,4) { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104684: 83 c0 01 add $0x1,%eax if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp 80104687: 8b 12 mov (%edx),%edx { uint *ebp; int i; ebp = (uint*)v - 2; for(i = 0; i < 10; i++){ 80104689: 83 f8 0a cmp $0xa,%eax 8010468c: 75 e2 jne 80104670 <getcallerpcs+0x10> pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) pcs[i] = 0; } 8010468e: 5b pop %ebx 8010468f: 5d pop %ebp 80104690: c3 ret 80104691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 80104698: 83 f8 09 cmp $0x9,%eax 8010469b: 7f f1 jg 8010468e <getcallerpcs+0x2e> 8010469d: 8d 76 00 lea 0x0(%esi),%esi pcs[i] = 0; 801046a0: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) break; pcs[i] = ebp[1]; // saved %eip ebp = (uint*)ebp[0]; // saved %ebp } for(; i < 10; i++) 801046a7: 83 c0 01 add $0x1,%eax 801046aa: 83 f8 0a cmp $0xa,%eax 801046ad: 75 f1 jne 801046a0 <getcallerpcs+0x40> pcs[i] = 0; } 801046af: 5b pop %ebx 801046b0: 5d pop %ebp 801046b1: c3 ret 801046b2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801046b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801046c0 <holding>: // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801046c0: 55 push %ebp return lock->locked && lock->cpu == cpu; 801046c1: 31 c0 xor %eax,%eax } // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801046c3: 89 e5 mov %esp,%ebp 801046c5: 8b 55 08 mov 0x8(%ebp),%edx return lock->locked && lock->cpu == cpu; 801046c8: 8b 0a mov (%edx),%ecx 801046ca: 85 c9 test %ecx,%ecx 801046cc: 74 10 je 801046de <holding+0x1e> 801046ce: 8b 42 08 mov 0x8(%edx),%eax 801046d1: 65 3b 05 00 00 00 00 cmp %gs:0x0,%eax 801046d8: 0f 94 c0 sete %al 801046db: 0f b6 c0 movzbl %al,%eax } 801046de: 5d pop %ebp 801046df: c3 ret 801046e0 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 801046e0: 55 push %ebp 801046e1: 89 e5 mov %esp,%ebp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801046e3: 9c pushf 801046e4: 59 pop %ecx } static inline void cli(void) { asm volatile("cli"); 801046e5: fa cli int eflags; eflags = readeflags(); cli(); if(cpu->ncli == 0) 801046e6: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801046ec: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx 801046f2: 85 d2 test %edx,%edx 801046f4: 75 18 jne 8010470e <pushcli+0x2e> cpu->intena = eflags & FL_IF; 801046f6: 81 e1 00 02 00 00 and $0x200,%ecx 801046fc: 89 88 b0 00 00 00 mov %ecx,0xb0(%eax) 80104702: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80104708: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx cpu->ncli += 1; 8010470e: 83 c2 01 add $0x1,%edx 80104711: 89 90 ac 00 00 00 mov %edx,0xac(%eax) } 80104717: 5d pop %ebp 80104718: c3 ret 80104719: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104720 <popcli>: void popcli(void) { 80104720: 55 push %ebp 80104721: 89 e5 mov %esp,%ebp 80104723: 83 ec 18 sub $0x18,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 80104726: 9c pushf 80104727: 58 pop %eax if(readeflags()&FL_IF) 80104728: f6 c4 02 test $0x2,%ah 8010472b: 75 43 jne 80104770 <popcli+0x50> panic("popcli - interruptible"); if(--cpu->ncli < 0) 8010472d: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80104734: 8b 82 ac 00 00 00 mov 0xac(%edx),%eax 8010473a: 83 e8 01 sub $0x1,%eax 8010473d: 85 c0 test %eax,%eax 8010473f: 89 82 ac 00 00 00 mov %eax,0xac(%edx) 80104745: 78 1d js 80104764 <popcli+0x44> panic("popcli"); if(cpu->ncli == 0 && cpu->intena) 80104747: 65 a1 00 00 00 00 mov %gs:0x0,%eax 8010474d: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx 80104753: 85 d2 test %edx,%edx 80104755: 75 0b jne 80104762 <popcli+0x42> 80104757: 8b 80 b0 00 00 00 mov 0xb0(%eax),%eax 8010475d: 85 c0 test %eax,%eax 8010475f: 74 01 je 80104762 <popcli+0x42> } static inline void sti(void) { asm volatile("sti"); 80104761: fb sti sti(); } 80104762: c9 leave 80104763: c3 ret popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); if(--cpu->ncli < 0) panic("popcli"); 80104764: c7 04 24 a6 79 10 80 movl $0x801079a6,(%esp) 8010476b: e8 60 bc ff ff call 801003d0 <panic> void popcli(void) { if(readeflags()&FL_IF) panic("popcli - interruptible"); 80104770: c7 04 24 8f 79 10 80 movl $0x8010798f,(%esp) 80104777: e8 54 bc ff ff call 801003d0 <panic> 8010477c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104780 <release>: } // Release the lock. void release(struct spinlock *lk) { 80104780: 55 push %ebp 80104781: 89 e5 mov %esp,%ebp 80104783: 83 ec 18 sub $0x18,%esp 80104786: 8b 45 08 mov 0x8(%ebp),%eax // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { return lock->locked && lock->cpu == cpu; 80104789: 8b 08 mov (%eax),%ecx 8010478b: 85 c9 test %ecx,%ecx 8010478d: 74 0c je 8010479b <release+0x1b> 8010478f: 8b 50 08 mov 0x8(%eax),%edx 80104792: 65 3b 15 00 00 00 00 cmp %gs:0x0,%edx 80104799: 74 0d je 801047a8 <release+0x28> // Release the lock. void release(struct spinlock *lk) { if(!holding(lk)) panic("release"); 8010479b: c7 04 24 ad 79 10 80 movl $0x801079ad,(%esp) 801047a2: e8 29 bc ff ff call 801003d0 <panic> 801047a7: 90 nop lk->pcs[0] = 0; 801047a8: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax) lk->cpu = 0; 801047af: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that all the stores in the critical // section are visible to other cores before the lock is released. // Both the C compiler and the hardware may re-order loads and // stores; __sync_synchronize() tells them both not to. __sync_synchronize(); 801047b6: f0 83 0c 24 00 lock orl $0x0,(%esp) // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); 801047bb: c7 00 00 00 00 00 movl $0x0,(%eax) popcli(); } 801047c1: c9 leave // Release the lock, equivalent to lk->locked = 0. // This code can't use a C assignment, since it might // not be atomic. A real OS would use C atomics here. asm volatile("movl $0, %0" : "+m" (lk->locked) : ); popcli(); 801047c2: e9 59 ff ff ff jmp 80104720 <popcli> 801047c7: 89 f6 mov %esi,%esi 801047c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801047d0 <acquire>: // Loops (spins) until the lock is acquired. // Holding a lock for a long time may cause // other CPUs to waste time spinning to acquire it. void acquire(struct spinlock *lk) { 801047d0: 55 push %ebp 801047d1: 89 e5 mov %esp,%ebp 801047d3: 83 ec 18 sub $0x18,%esp static inline uint readeflags(void) { uint eflags; asm volatile("pushfl; popl %0" : "=r" (eflags)); 801047d6: 9c pushf 801047d7: 59 pop %ecx } static inline void cli(void) { asm volatile("cli"); 801047d8: fa cli { int eflags; eflags = readeflags(); cli(); if(cpu->ncli == 0) 801047d9: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801047df: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx 801047e5: 85 d2 test %edx,%edx 801047e7: 75 18 jne 80104801 <acquire+0x31> cpu->intena = eflags & FL_IF; 801047e9: 81 e1 00 02 00 00 and $0x200,%ecx 801047ef: 89 88 b0 00 00 00 mov %ecx,0xb0(%eax) 801047f5: 65 a1 00 00 00 00 mov %gs:0x0,%eax 801047fb: 8b 90 ac 00 00 00 mov 0xac(%eax),%edx cpu->ncli += 1; 80104801: 83 c2 01 add $0x1,%edx 80104804: 89 90 ac 00 00 00 mov %edx,0xac(%eax) // other CPUs to waste time spinning to acquire it. void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) 8010480a: 8b 55 08 mov 0x8(%ebp),%edx // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { return lock->locked && lock->cpu == cpu; 8010480d: 8b 02 mov (%edx),%eax 8010480f: 85 c0 test %eax,%eax 80104811: 74 0c je 8010481f <acquire+0x4f> 80104813: 8b 42 08 mov 0x8(%edx),%eax 80104816: 65 3b 05 00 00 00 00 cmp %gs:0x0,%eax 8010481d: 74 41 je 80104860 <acquire+0x90> xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 8010481f: b9 01 00 00 00 mov $0x1,%ecx 80104824: eb 05 jmp 8010482b <acquire+0x5b> 80104826: 66 90 xchg %ax,%ax pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) panic("acquire"); // The xchg is atomic. while(xchg(&lk->locked, 1) != 0) 80104828: 8b 55 08 mov 0x8(%ebp),%edx 8010482b: 89 c8 mov %ecx,%eax 8010482d: f0 87 02 lock xchg %eax,(%edx) 80104830: 85 c0 test %eax,%eax 80104832: 75 f4 jne 80104828 <acquire+0x58> ; // Tell the C compiler and the processor to not move loads or stores // past this point, to ensure that the critical section's memory // references happen after the lock is acquired. __sync_synchronize(); 80104834: f0 83 0c 24 00 lock orl $0x0,(%esp) // Record info about lock acquisition for debugging. lk->cpu = cpu; 80104839: 8b 45 08 mov 0x8(%ebp),%eax 8010483c: 65 8b 15 00 00 00 00 mov %gs:0x0,%edx 80104843: 89 50 08 mov %edx,0x8(%eax) getcallerpcs(&lk, lk->pcs); 80104846: 8b 45 08 mov 0x8(%ebp),%eax 80104849: 83 c0 0c add $0xc,%eax 8010484c: 89 44 24 04 mov %eax,0x4(%esp) 80104850: 8d 45 08 lea 0x8(%ebp),%eax 80104853: 89 04 24 mov %eax,(%esp) 80104856: e8 05 fe ff ff call 80104660 <getcallerpcs> } 8010485b: c9 leave 8010485c: c3 ret 8010485d: 8d 76 00 lea 0x0(%esi),%esi void acquire(struct spinlock *lk) { pushcli(); // disable interrupts to avoid deadlock. if(holding(lk)) panic("acquire"); 80104860: c7 04 24 b5 79 10 80 movl $0x801079b5,(%esp) 80104867: e8 64 bb ff ff call 801003d0 <panic> 8010486c: 00 00 add %al,(%eax) ... 80104870 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 80104870: 55 push %ebp 80104871: 89 e5 mov %esp,%ebp 80104873: 83 ec 08 sub $0x8,%esp 80104876: 8b 55 08 mov 0x8(%ebp),%edx 80104879: 89 1c 24 mov %ebx,(%esp) 8010487c: 8b 45 0c mov 0xc(%ebp),%eax 8010487f: 89 7c 24 04 mov %edi,0x4(%esp) 80104883: 8b 4d 10 mov 0x10(%ebp),%ecx if ((int)dst%4 == 0 && n%4 == 0){ 80104886: f6 c2 03 test $0x3,%dl 80104889: 75 05 jne 80104890 <memset+0x20> 8010488b: f6 c1 03 test $0x3,%cl 8010488e: 74 18 je 801048a8 <memset+0x38> } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 80104890: 89 d7 mov %edx,%edi 80104892: fc cld 80104893: f3 aa rep stos %al,%es:(%edi) c &= 0xFF; stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 80104895: 89 d0 mov %edx,%eax 80104897: 8b 1c 24 mov (%esp),%ebx 8010489a: 8b 7c 24 04 mov 0x4(%esp),%edi 8010489e: 89 ec mov %ebp,%esp 801048a0: 5d pop %ebp 801048a1: c3 ret 801048a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi void* memset(void *dst, int c, uint n) { if ((int)dst%4 == 0 && n%4 == 0){ c &= 0xFF; 801048a8: 0f b6 f8 movzbl %al,%edi } static inline void stosl(void *addr, int data, int cnt) { asm volatile("cld; rep stosl" : 801048ab: 89 f8 mov %edi,%eax 801048ad: 89 fb mov %edi,%ebx 801048af: c1 e0 18 shl $0x18,%eax 801048b2: c1 e3 10 shl $0x10,%ebx 801048b5: 09 d8 or %ebx,%eax 801048b7: 09 f8 or %edi,%eax 801048b9: c1 e7 08 shl $0x8,%edi 801048bc: 09 f8 or %edi,%eax 801048be: 89 d7 mov %edx,%edi 801048c0: c1 e9 02 shr $0x2,%ecx 801048c3: fc cld 801048c4: f3 ab rep stos %eax,%es:(%edi) stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 801048c6: 89 d0 mov %edx,%eax 801048c8: 8b 1c 24 mov (%esp),%ebx 801048cb: 8b 7c 24 04 mov 0x4(%esp),%edi 801048cf: 89 ec mov %ebp,%esp 801048d1: 5d pop %ebp 801048d2: c3 ret 801048d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801048d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801048e0 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 801048e0: 55 push %ebp 801048e1: 89 e5 mov %esp,%ebp 801048e3: 8b 55 10 mov 0x10(%ebp),%edx 801048e6: 57 push %edi 801048e7: 8b 7d 0c mov 0xc(%ebp),%edi 801048ea: 56 push %esi 801048eb: 8b 75 08 mov 0x8(%ebp),%esi 801048ee: 53 push %ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801048ef: 85 d2 test %edx,%edx 801048f1: 74 2d je 80104920 <memcmp+0x40> if(*s1 != *s2) 801048f3: 0f b6 1e movzbl (%esi),%ebx 801048f6: 0f b6 0f movzbl (%edi),%ecx 801048f9: 38 cb cmp %cl,%bl 801048fb: 75 2b jne 80104928 <memcmp+0x48> { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801048fd: 83 ea 01 sub $0x1,%edx 80104900: 31 c0 xor %eax,%eax 80104902: eb 18 jmp 8010491c <memcmp+0x3c> 80104904: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(*s1 != *s2) 80104908: 0f b6 5c 06 01 movzbl 0x1(%esi,%eax,1),%ebx 8010490d: 83 ea 01 sub $0x1,%edx 80104910: 0f b6 4c 07 01 movzbl 0x1(%edi,%eax,1),%ecx 80104915: 83 c0 01 add $0x1,%eax 80104918: 38 cb cmp %cl,%bl 8010491a: 75 0c jne 80104928 <memcmp+0x48> { const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 8010491c: 85 d2 test %edx,%edx 8010491e: 75 e8 jne 80104908 <memcmp+0x28> 80104920: 31 c0 xor %eax,%eax return *s1 - *s2; s1++, s2++; } return 0; } 80104922: 5b pop %ebx 80104923: 5e pop %esi 80104924: 5f pop %edi 80104925: 5d pop %ebp 80104926: c3 ret 80104927: 90 nop s1 = v1; s2 = v2; while(n-- > 0){ if(*s1 != *s2) return *s1 - *s2; 80104928: 0f b6 c3 movzbl %bl,%eax 8010492b: 0f b6 c9 movzbl %cl,%ecx 8010492e: 29 c8 sub %ecx,%eax s1++, s2++; } return 0; } 80104930: 5b pop %ebx 80104931: 5e pop %esi 80104932: 5f pop %edi 80104933: 5d pop %ebp 80104934: c3 ret 80104935: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104939: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104940 <memmove>: void* memmove(void *dst, const void *src, uint n) { 80104940: 55 push %ebp 80104941: 89 e5 mov %esp,%ebp 80104943: 57 push %edi 80104944: 8b 45 08 mov 0x8(%ebp),%eax 80104947: 56 push %esi 80104948: 8b 75 0c mov 0xc(%ebp),%esi 8010494b: 53 push %ebx 8010494c: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 8010494f: 39 c6 cmp %eax,%esi 80104951: 73 2d jae 80104980 <memmove+0x40> 80104953: 8d 3c 1e lea (%esi,%ebx,1),%edi 80104956: 39 f8 cmp %edi,%eax 80104958: 73 26 jae 80104980 <memmove+0x40> s += n; d += n; while(n-- > 0) 8010495a: 85 db test %ebx,%ebx 8010495c: 74 1d je 8010497b <memmove+0x3b> s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; 8010495e: 8d 34 18 lea (%eax,%ebx,1),%esi 80104961: 31 d2 xor %edx,%edx 80104963: 90 nop 80104964: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(n-- > 0) *--d = *--s; 80104968: 0f b6 4c 17 ff movzbl -0x1(%edi,%edx,1),%ecx 8010496d: 88 4c 16 ff mov %cl,-0x1(%esi,%edx,1) 80104971: 83 ea 01 sub $0x1,%edx s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; while(n-- > 0) 80104974: 8d 0c 1a lea (%edx,%ebx,1),%ecx 80104977: 85 c9 test %ecx,%ecx 80104979: 75 ed jne 80104968 <memmove+0x28> } else while(n-- > 0) *d++ = *s++; return dst; } 8010497b: 5b pop %ebx 8010497c: 5e pop %esi 8010497d: 5f pop %edi 8010497e: 5d pop %ebp 8010497f: c3 ret s = src; d = dst; if(s < d && s + n > d){ s += n; d += n; while(n-- > 0) 80104980: 31 d2 xor %edx,%edx *--d = *--s; } else while(n-- > 0) 80104982: 85 db test %ebx,%ebx 80104984: 74 f5 je 8010497b <memmove+0x3b> 80104986: 66 90 xchg %ax,%ax *d++ = *s++; 80104988: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 8010498c: 88 0c 10 mov %cl,(%eax,%edx,1) 8010498f: 83 c2 01 add $0x1,%edx s += n; d += n; while(n-- > 0) *--d = *--s; } else while(n-- > 0) 80104992: 39 d3 cmp %edx,%ebx 80104994: 75 f2 jne 80104988 <memmove+0x48> *d++ = *s++; return dst; } 80104996: 5b pop %ebx 80104997: 5e pop %esi 80104998: 5f pop %edi 80104999: 5d pop %ebp 8010499a: c3 ret 8010499b: 90 nop 8010499c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801049a0 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 801049a0: 55 push %ebp 801049a1: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 801049a3: 5d pop %ebp // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { return memmove(dst, src, n); 801049a4: e9 97 ff ff ff jmp 80104940 <memmove> 801049a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801049b0 <strncmp>: } int strncmp(const char *p, const char *q, uint n) { 801049b0: 55 push %ebp 801049b1: 89 e5 mov %esp,%ebp 801049b3: 57 push %edi 801049b4: 8b 7d 10 mov 0x10(%ebp),%edi 801049b7: 56 push %esi 801049b8: 8b 4d 08 mov 0x8(%ebp),%ecx 801049bb: 53 push %ebx 801049bc: 8b 5d 0c mov 0xc(%ebp),%ebx while(n > 0 && *p && *p == *q) 801049bf: 85 ff test %edi,%edi 801049c1: 74 3d je 80104a00 <strncmp+0x50> 801049c3: 0f b6 01 movzbl (%ecx),%eax 801049c6: 84 c0 test %al,%al 801049c8: 75 18 jne 801049e2 <strncmp+0x32> 801049ca: eb 3c jmp 80104a08 <strncmp+0x58> 801049cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801049d0: 83 ef 01 sub $0x1,%edi 801049d3: 74 2b je 80104a00 <strncmp+0x50> n--, p++, q++; 801049d5: 83 c1 01 add $0x1,%ecx 801049d8: 83 c3 01 add $0x1,%ebx } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 801049db: 0f b6 01 movzbl (%ecx),%eax 801049de: 84 c0 test %al,%al 801049e0: 74 26 je 80104a08 <strncmp+0x58> 801049e2: 0f b6 33 movzbl (%ebx),%esi 801049e5: 89 f2 mov %esi,%edx 801049e7: 38 d0 cmp %dl,%al 801049e9: 74 e5 je 801049d0 <strncmp+0x20> n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; 801049eb: 81 e6 ff 00 00 00 and $0xff,%esi 801049f1: 0f b6 c0 movzbl %al,%eax 801049f4: 29 f0 sub %esi,%eax } 801049f6: 5b pop %ebx 801049f7: 5e pop %esi 801049f8: 5f pop %edi 801049f9: 5d pop %ebp 801049fa: c3 ret 801049fb: 90 nop 801049fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 80104a00: 31 c0 xor %eax,%eax n--, p++, q++; if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 80104a02: 5b pop %ebx 80104a03: 5e pop %esi 80104a04: 5f pop %edi 80104a05: 5d pop %ebp 80104a06: c3 ret 80104a07: 90 nop } int strncmp(const char *p, const char *q, uint n) { while(n > 0 && *p && *p == *q) 80104a08: 0f b6 33 movzbl (%ebx),%esi 80104a0b: eb de jmp 801049eb <strncmp+0x3b> 80104a0d: 8d 76 00 lea 0x0(%esi),%esi 80104a10 <strncpy>: return (uchar)*p - (uchar)*q; } char* strncpy(char *s, const char *t, int n) { 80104a10: 55 push %ebp 80104a11: 89 e5 mov %esp,%ebp 80104a13: 8b 45 08 mov 0x8(%ebp),%eax 80104a16: 56 push %esi 80104a17: 8b 4d 10 mov 0x10(%ebp),%ecx 80104a1a: 53 push %ebx 80104a1b: 8b 75 0c mov 0xc(%ebp),%esi 80104a1e: 89 c3 mov %eax,%ebx 80104a20: eb 09 jmp 80104a2b <strncpy+0x1b> 80104a22: 8d b6 00 00 00 00 lea 0x0(%esi),%esi char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 80104a28: 83 c6 01 add $0x1,%esi 80104a2b: 83 e9 01 sub $0x1,%ecx return 0; return (uchar)*p - (uchar)*q; } char* strncpy(char *s, const char *t, int n) 80104a2e: 8d 51 01 lea 0x1(%ecx),%edx { char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 80104a31: 85 d2 test %edx,%edx 80104a33: 7e 0c jle 80104a41 <strncpy+0x31> 80104a35: 0f b6 16 movzbl (%esi),%edx 80104a38: 88 13 mov %dl,(%ebx) 80104a3a: 83 c3 01 add $0x1,%ebx 80104a3d: 84 d2 test %dl,%dl 80104a3f: 75 e7 jne 80104a28 <strncpy+0x18> return 0; return (uchar)*p - (uchar)*q; } char* strncpy(char *s, const char *t, int n) 80104a41: 31 d2 xor %edx,%edx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 80104a43: 85 c9 test %ecx,%ecx 80104a45: 7e 0c jle 80104a53 <strncpy+0x43> 80104a47: 90 nop *s++ = 0; 80104a48: c6 04 13 00 movb $0x0,(%ebx,%edx,1) 80104a4c: 83 c2 01 add $0x1,%edx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) ; while(n-- > 0) 80104a4f: 39 ca cmp %ecx,%edx 80104a51: 75 f5 jne 80104a48 <strncpy+0x38> *s++ = 0; return os; } 80104a53: 5b pop %ebx 80104a54: 5e pop %esi 80104a55: 5d pop %ebp 80104a56: c3 ret 80104a57: 89 f6 mov %esi,%esi 80104a59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104a60 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80104a60: 55 push %ebp 80104a61: 89 e5 mov %esp,%ebp 80104a63: 8b 55 10 mov 0x10(%ebp),%edx 80104a66: 56 push %esi 80104a67: 8b 45 08 mov 0x8(%ebp),%eax 80104a6a: 53 push %ebx 80104a6b: 8b 75 0c mov 0xc(%ebp),%esi char *os; os = s; if(n <= 0) 80104a6e: 85 d2 test %edx,%edx 80104a70: 7e 1f jle 80104a91 <safestrcpy+0x31> 80104a72: 89 c1 mov %eax,%ecx 80104a74: eb 05 jmp 80104a7b <safestrcpy+0x1b> 80104a76: 66 90 xchg %ax,%ax return os; while(--n > 0 && (*s++ = *t++) != 0) 80104a78: 83 c6 01 add $0x1,%esi 80104a7b: 83 ea 01 sub $0x1,%edx 80104a7e: 85 d2 test %edx,%edx 80104a80: 7e 0c jle 80104a8e <safestrcpy+0x2e> 80104a82: 0f b6 1e movzbl (%esi),%ebx 80104a85: 88 19 mov %bl,(%ecx) 80104a87: 83 c1 01 add $0x1,%ecx 80104a8a: 84 db test %bl,%bl 80104a8c: 75 ea jne 80104a78 <safestrcpy+0x18> ; *s = 0; 80104a8e: c6 01 00 movb $0x0,(%ecx) return os; } 80104a91: 5b pop %ebx 80104a92: 5e pop %esi 80104a93: 5d pop %ebp 80104a94: c3 ret 80104a95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104a99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104aa0 <strlen>: int strlen(const char *s) { 80104aa0: 55 push %ebp int n; for(n = 0; s[n]; n++) 80104aa1: 31 c0 xor %eax,%eax return os; } int strlen(const char *s) { 80104aa3: 89 e5 mov %esp,%ebp 80104aa5: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 80104aa8: 80 3a 00 cmpb $0x0,(%edx) 80104aab: 74 0c je 80104ab9 <strlen+0x19> 80104aad: 8d 76 00 lea 0x0(%esi),%esi 80104ab0: 83 c0 01 add $0x1,%eax 80104ab3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 80104ab7: 75 f7 jne 80104ab0 <strlen+0x10> ; return n; } 80104ab9: 5d pop %ebp 80104aba: c3 ret ... 80104abc <swtch>: # Save current register context in old # and then load register context from new. .globl swtch swtch: movl 4(%esp), %eax 80104abc: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 80104ac0: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-save registers pushl %ebp 80104ac4: 55 push %ebp pushl %ebx 80104ac5: 53 push %ebx pushl %esi 80104ac6: 56 push %esi pushl %edi 80104ac7: 57 push %edi # Switch stacks movl %esp, (%eax) 80104ac8: 89 20 mov %esp,(%eax) movl %edx, %esp 80104aca: 89 d4 mov %edx,%esp # Load new callee-save registers popl %edi 80104acc: 5f pop %edi popl %esi 80104acd: 5e pop %esi popl %ebx 80104ace: 5b pop %ebx popl %ebp 80104acf: 5d pop %ebp ret 80104ad0: c3 ret ... 80104ae0 <fetchint>: // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104ae0: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 80104ae7: 55 push %ebp 80104ae8: 89 e5 mov %esp,%ebp 80104aea: 8b 45 08 mov 0x8(%ebp),%eax if(addr >= proc->sz || addr+4 > proc->sz) 80104aed: 8b 12 mov (%edx),%edx 80104aef: 39 c2 cmp %eax,%edx 80104af1: 77 0d ja 80104b00 <fetchint+0x20> return -1; *ip = *(int*)(addr); return 0; 80104af3: b8 ff ff ff ff mov $0xffffffff,%eax } 80104af8: 5d pop %ebp 80104af9: c3 ret 80104afa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104b00: 8d 48 04 lea 0x4(%eax),%ecx 80104b03: 39 ca cmp %ecx,%edx 80104b05: 72 ec jb 80104af3 <fetchint+0x13> return -1; *ip = *(int*)(addr); 80104b07: 8b 10 mov (%eax),%edx 80104b09: 8b 45 0c mov 0xc(%ebp),%eax 80104b0c: 89 10 mov %edx,(%eax) 80104b0e: 31 c0 xor %eax,%eax return 0; } 80104b10: 5d pop %ebp 80104b11: c3 ret 80104b12: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104b19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104b20 <fetchstr>: int fetchstr(uint addr, char **pp) { char *s, *ep; if(addr >= proc->sz) 80104b20: 65 a1 04 00 00 00 mov %gs:0x4,%eax // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 80104b26: 55 push %ebp 80104b27: 89 e5 mov %esp,%ebp 80104b29: 8b 55 08 mov 0x8(%ebp),%edx 80104b2c: 53 push %ebx char *s, *ep; if(addr >= proc->sz) 80104b2d: 39 10 cmp %edx,(%eax) 80104b2f: 77 0f ja 80104b40 <fetchstr+0x20> return -1; *pp = (char*)addr; ep = (char*)proc->sz; for(s = *pp; s < ep; s++) 80104b31: b8 ff ff ff ff mov $0xffffffff,%eax if(*s == 0) return s - *pp; return -1; } 80104b36: 5b pop %ebx 80104b37: 5d pop %ebp 80104b38: c3 ret 80104b39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { char *s, *ep; if(addr >= proc->sz) return -1; *pp = (char*)addr; 80104b40: 8b 45 0c mov 0xc(%ebp),%eax 80104b43: 89 10 mov %edx,(%eax) ep = (char*)proc->sz; 80104b45: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104b4b: 8b 18 mov (%eax),%ebx for(s = *pp; s < ep; s++) 80104b4d: 39 da cmp %ebx,%edx 80104b4f: 73 e0 jae 80104b31 <fetchstr+0x11> if(*s == 0) 80104b51: 31 c0 xor %eax,%eax 80104b53: 89 d1 mov %edx,%ecx 80104b55: 80 3a 00 cmpb $0x0,(%edx) 80104b58: 74 dc je 80104b36 <fetchstr+0x16> 80104b5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(addr >= proc->sz) return -1; *pp = (char*)addr; ep = (char*)proc->sz; for(s = *pp; s < ep; s++) 80104b60: 83 c1 01 add $0x1,%ecx 80104b63: 39 cb cmp %ecx,%ebx 80104b65: 76 ca jbe 80104b31 <fetchstr+0x11> if(*s == 0) 80104b67: 80 39 00 cmpb $0x0,(%ecx) 80104b6a: 75 f4 jne 80104b60 <fetchstr+0x40> 80104b6c: 89 c8 mov %ecx,%eax 80104b6e: 29 d0 sub %edx,%eax 80104b70: eb c4 jmp 80104b36 <fetchstr+0x16> 80104b72: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104b79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104b80 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104b80: 65 a1 04 00 00 00 mov %gs:0x4,%eax } // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 80104b86: 55 push %ebp 80104b87: 89 e5 mov %esp,%ebp return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104b89: 8b 4d 08 mov 0x8(%ebp),%ecx 80104b8c: 8b 50 18 mov 0x18(%eax),%edx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104b8f: 8b 00 mov (%eax),%eax // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104b91: 8b 52 44 mov 0x44(%edx),%edx 80104b94: 8d 54 8a 04 lea 0x4(%edx,%ecx,4),%edx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104b98: 39 c2 cmp %eax,%edx 80104b9a: 72 0c jb 80104ba8 <argint+0x28> return -1; *ip = *(int*)(addr); 80104b9c: b8 ff ff ff ff mov $0xffffffff,%eax // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); } 80104ba1: 5d pop %ebp 80104ba2: c3 ret 80104ba3: 90 nop 80104ba4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104ba8: 8d 4a 04 lea 0x4(%edx),%ecx 80104bab: 39 c8 cmp %ecx,%eax 80104bad: 72 ed jb 80104b9c <argint+0x1c> return -1; *ip = *(int*)(addr); 80104baf: 8b 45 0c mov 0xc(%ebp),%eax 80104bb2: 8b 12 mov (%edx),%edx 80104bb4: 89 10 mov %edx,(%eax) 80104bb6: 31 c0 xor %eax,%eax // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); } 80104bb8: 5d pop %ebp 80104bb9: c3 ret 80104bba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104bc0 <argptr>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104bc0: 65 a1 04 00 00 00 mov %gs:0x4,%eax // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 80104bc6: 55 push %ebp 80104bc7: 89 e5 mov %esp,%ebp 80104bc9: 53 push %ebx // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104bca: 8b 4d 08 mov 0x8(%ebp),%ecx 80104bcd: 8b 50 18 mov 0x18(%eax),%edx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104bd0: 8b 00 mov (%eax),%eax // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 80104bd2: 8b 5d 10 mov 0x10(%ebp),%ebx // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104bd5: 8b 52 44 mov 0x44(%edx),%edx 80104bd8: 8d 54 8a 04 lea 0x4(%edx,%ecx,4),%edx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104bdc: 39 c2 cmp %eax,%edx 80104bde: 73 07 jae 80104be7 <argptr+0x27> 80104be0: 8d 4a 04 lea 0x4(%edx),%ecx 80104be3: 39 c8 cmp %ecx,%eax 80104be5: 73 09 jae 80104bf0 <argptr+0x30> if(argint(n, &i) < 0) return -1; if(size < 0 || (uint)i >= proc->sz || (uint)i+size > proc->sz) return -1; *pp = (char*)i; return 0; 80104be7: b8 ff ff ff ff mov $0xffffffff,%eax } 80104bec: 5b pop %ebx 80104bed: 5d pop %ebp 80104bee: c3 ret 80104bef: 90 nop { int i; if(argint(n, &i) < 0) return -1; if(size < 0 || (uint)i >= proc->sz || (uint)i+size > proc->sz) 80104bf0: 85 db test %ebx,%ebx int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) return -1; *ip = *(int*)(addr); 80104bf2: 8b 12 mov (%edx),%edx { int i; if(argint(n, &i) < 0) return -1; if(size < 0 || (uint)i >= proc->sz || (uint)i+size > proc->sz) 80104bf4: 78 f1 js 80104be7 <argptr+0x27> 80104bf6: 39 c2 cmp %eax,%edx 80104bf8: 73 ed jae 80104be7 <argptr+0x27> 80104bfa: 8d 1c 1a lea (%edx,%ebx,1),%ebx 80104bfd: 39 c3 cmp %eax,%ebx 80104bff: 77 e6 ja 80104be7 <argptr+0x27> return -1; *pp = (char*)i; 80104c01: 8b 45 0c mov 0xc(%ebp),%eax 80104c04: 89 10 mov %edx,(%eax) 80104c06: 31 c0 xor %eax,%eax return 0; 80104c08: eb e2 jmp 80104bec <argptr+0x2c> 80104c0a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104c10 <argstr>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104c10: 65 a1 04 00 00 00 mov %gs:0x4,%eax // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 80104c16: 55 push %ebp 80104c17: 89 e5 mov %esp,%ebp // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { return fetchint(proc->tf->esp + 4 + 4*n, ip); 80104c19: 8b 4d 08 mov 0x8(%ebp),%ecx 80104c1c: 8b 50 18 mov 0x18(%eax),%edx 80104c1f: 8b 52 44 mov 0x44(%edx),%edx 80104c22: 8d 4c 8a 04 lea 0x4(%edx,%ecx,4),%ecx // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) 80104c26: 8b 10 mov (%eax),%edx 80104c28: 39 d1 cmp %edx,%ecx 80104c2a: 73 07 jae 80104c33 <argstr+0x23> 80104c2c: 8d 41 04 lea 0x4(%ecx),%eax 80104c2f: 39 c2 cmp %eax,%edx 80104c31: 73 0d jae 80104c40 <argstr+0x30> if(addr >= proc->sz) return -1; *pp = (char*)addr; ep = (char*)proc->sz; for(s = *pp; s < ep; s++) 80104c33: b8 ff ff ff ff mov $0xffffffff,%eax { int addr; if(argint(n, &addr) < 0) return -1; return fetchstr(addr, pp); } 80104c38: 5d pop %ebp 80104c39: c3 ret 80104c3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi int fetchint(uint addr, int *ip) { if(addr >= proc->sz || addr+4 > proc->sz) return -1; *ip = *(int*)(addr); 80104c40: 8b 09 mov (%ecx),%ecx int fetchstr(uint addr, char **pp) { char *s, *ep; if(addr >= proc->sz) 80104c42: 39 d1 cmp %edx,%ecx 80104c44: 73 ed jae 80104c33 <argstr+0x23> return -1; *pp = (char*)addr; 80104c46: 8b 55 0c mov 0xc(%ebp),%edx 80104c49: 89 c8 mov %ecx,%eax 80104c4b: 89 0a mov %ecx,(%edx) ep = (char*)proc->sz; 80104c4d: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104c54: 8b 12 mov (%edx),%edx for(s = *pp; s < ep; s++) 80104c56: 39 d1 cmp %edx,%ecx 80104c58: 73 d9 jae 80104c33 <argstr+0x23> if(*s == 0) 80104c5a: 80 39 00 cmpb $0x0,(%ecx) 80104c5d: 75 13 jne 80104c72 <argstr+0x62> 80104c5f: eb 1f jmp 80104c80 <argstr+0x70> 80104c61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104c68: 80 38 00 cmpb $0x0,(%eax) 80104c6b: 90 nop 80104c6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104c70: 74 0e je 80104c80 <argstr+0x70> if(addr >= proc->sz) return -1; *pp = (char*)addr; ep = (char*)proc->sz; for(s = *pp; s < ep; s++) 80104c72: 83 c0 01 add $0x1,%eax 80104c75: 39 c2 cmp %eax,%edx 80104c77: 77 ef ja 80104c68 <argstr+0x58> 80104c79: eb b8 jmp 80104c33 <argstr+0x23> 80104c7b: 90 nop 80104c7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(*s == 0) return s - *pp; 80104c80: 29 c8 sub %ecx,%eax { int addr; if(argint(n, &addr) < 0) return -1; return fetchstr(addr, pp); } 80104c82: 5d pop %ebp 80104c83: c3 ret 80104c84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104c8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104c90 <syscall>: [SYS_set_tickets] sys_set_tickets,//CS 202 }; void syscall(void) { 80104c90: 55 push %ebp 80104c91: 89 e5 mov %esp,%ebp 80104c93: 53 push %ebx 80104c94: 83 ec 14 sub $0x14,%esp int num; num = proc->tf->eax; 80104c97: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104c9e: 8b 5a 18 mov 0x18(%edx),%ebx 80104ca1: 8b 43 1c mov 0x1c(%ebx),%eax if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80104ca4: 8d 48 ff lea -0x1(%eax),%ecx 80104ca7: 83 f9 15 cmp $0x15,%ecx 80104caa: 77 1c ja 80104cc8 <syscall+0x38> 80104cac: 8b 0c 85 e0 79 10 80 mov -0x7fef8620(,%eax,4),%ecx 80104cb3: 85 c9 test %ecx,%ecx 80104cb5: 74 11 je 80104cc8 <syscall+0x38> proc->tf->eax = syscalls[num](); 80104cb7: ff d1 call *%ecx 80104cb9: 89 43 1c mov %eax,0x1c(%ebx) } else { cprintf("%d %s: unknown sys call %d\n", proc->pid, proc->name, num); proc->tf->eax = -1; } } 80104cbc: 83 c4 14 add $0x14,%esp 80104cbf: 5b pop %ebx 80104cc0: 5d pop %ebp 80104cc1: c3 ret 80104cc2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi num = proc->tf->eax; if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { proc->tf->eax = syscalls[num](); } else { cprintf("%d %s: unknown sys call %d\n", 80104cc8: 89 44 24 0c mov %eax,0xc(%esp) 80104ccc: 8d 42 6c lea 0x6c(%edx),%eax 80104ccf: 89 44 24 08 mov %eax,0x8(%esp) 80104cd3: 8b 42 10 mov 0x10(%edx),%eax 80104cd6: c7 04 24 bd 79 10 80 movl $0x801079bd,(%esp) 80104cdd: 89 44 24 04 mov %eax,0x4(%esp) 80104ce1: e8 8a bb ff ff call 80100870 <cprintf> proc->pid, proc->name, num); proc->tf->eax = -1; 80104ce6: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104cec: 8b 40 18 mov 0x18(%eax),%eax 80104cef: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } } 80104cf6: 83 c4 14 add $0x14,%esp 80104cf9: 5b pop %ebx 80104cfa: 5d pop %ebp 80104cfb: c3 ret 80104cfc: 00 00 add %al,(%eax) ... 80104d00 <sys_pipe>: return exec(path, argv); } int sys_pipe(void) { 80104d00: 55 push %ebp 80104d01: 89 e5 mov %esp,%ebp 80104d03: 83 ec 28 sub $0x28,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 80104d06: 8d 45 f4 lea -0xc(%ebp),%eax return exec(path, argv); } int sys_pipe(void) { 80104d09: 89 5d f8 mov %ebx,-0x8(%ebp) 80104d0c: 89 75 fc mov %esi,-0x4(%ebp) int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 80104d0f: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) 80104d16: 00 80104d17: 89 44 24 04 mov %eax,0x4(%esp) 80104d1b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104d22: e8 99 fe ff ff call 80104bc0 <argptr> 80104d27: 85 c0 test %eax,%eax 80104d29: 79 15 jns 80104d40 <sys_pipe+0x40> if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) proc->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; 80104d2b: b8 ff ff ff ff mov $0xffffffff,%eax } fd[0] = fd0; fd[1] = fd1; return 0; } 80104d30: 8b 5d f8 mov -0x8(%ebp),%ebx 80104d33: 8b 75 fc mov -0x4(%ebp),%esi 80104d36: 89 ec mov %ebp,%esp 80104d38: 5d pop %ebp 80104d39: c3 ret 80104d3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) return -1; if(pipealloc(&rf, &wf) < 0) 80104d40: 8d 45 ec lea -0x14(%ebp),%eax 80104d43: 89 44 24 04 mov %eax,0x4(%esp) 80104d47: 8d 45 f0 lea -0x10(%ebp),%eax 80104d4a: 89 04 24 mov %eax,(%esp) 80104d4d: e8 ce e8 ff ff call 80103620 <pipealloc> 80104d52: 85 c0 test %eax,%eax 80104d54: 78 d5 js 80104d2b <sys_pipe+0x2b> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 80104d56: 8b 4d f0 mov -0x10(%ebp),%ecx 80104d59: 31 c0 xor %eax,%eax 80104d5b: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80104d62: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ 80104d68: 8b 5c 82 28 mov 0x28(%edx,%eax,4),%ebx 80104d6c: 85 db test %ebx,%ebx 80104d6e: 74 28 je 80104d98 <sys_pipe+0x98> static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 80104d70: 83 c0 01 add $0x1,%eax 80104d73: 83 f8 10 cmp $0x10,%eax 80104d76: 75 f0 jne 80104d68 <sys_pipe+0x68> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) proc->ofile[fd0] = 0; fileclose(rf); 80104d78: 89 0c 24 mov %ecx,(%esp) 80104d7b: e8 e0 c2 ff ff call 80101060 <fileclose> fileclose(wf); 80104d80: 8b 45 ec mov -0x14(%ebp),%eax 80104d83: 89 04 24 mov %eax,(%esp) 80104d86: e8 d5 c2 ff ff call 80101060 <fileclose> 80104d8b: b8 ff ff ff ff mov $0xffffffff,%eax return -1; 80104d90: eb 9e jmp 80104d30 <sys_pipe+0x30> 80104d92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ proc->ofile[fd] = f; 80104d98: 8d 58 08 lea 0x8(%eax),%ebx 80104d9b: 89 4c 9a 08 mov %ecx,0x8(%edx,%ebx,4) if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) return -1; if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 80104d9f: 8b 75 ec mov -0x14(%ebp),%esi 80104da2: 31 d2 xor %edx,%edx 80104da4: 65 8b 0d 04 00 00 00 mov %gs:0x4,%ecx 80104dab: 90 nop 80104dac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ 80104db0: 83 7c 91 28 00 cmpl $0x0,0x28(%ecx,%edx,4) 80104db5: 74 19 je 80104dd0 <sys_pipe+0xd0> static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 80104db7: 83 c2 01 add $0x1,%edx 80104dba: 83 fa 10 cmp $0x10,%edx 80104dbd: 75 f1 jne 80104db0 <sys_pipe+0xb0> if(pipealloc(&rf, &wf) < 0) return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ if(fd0 >= 0) proc->ofile[fd0] = 0; 80104dbf: c7 44 99 08 00 00 00 movl $0x0,0x8(%ecx,%ebx,4) 80104dc6: 00 80104dc7: 8b 4d f0 mov -0x10(%ebp),%ecx 80104dca: eb ac jmp 80104d78 <sys_pipe+0x78> 80104dcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ proc->ofile[fd] = f; 80104dd0: 89 74 91 28 mov %esi,0x28(%ecx,%edx,4) proc->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 80104dd4: 8b 4d f4 mov -0xc(%ebp),%ecx 80104dd7: 89 01 mov %eax,(%ecx) fd[1] = fd1; 80104dd9: 8b 45 f4 mov -0xc(%ebp),%eax 80104ddc: 89 50 04 mov %edx,0x4(%eax) 80104ddf: 31 c0 xor %eax,%eax return 0; 80104de1: e9 4a ff ff ff jmp 80104d30 <sys_pipe+0x30> 80104de6: 8d 76 00 lea 0x0(%esi),%esi 80104de9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104df0 <sys_exec>: return 0; } int sys_exec(void) { 80104df0: 55 push %ebp 80104df1: 89 e5 mov %esp,%ebp 80104df3: 81 ec b8 00 00 00 sub $0xb8,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 80104df9: 8d 45 e4 lea -0x1c(%ebp),%eax return 0; } int sys_exec(void) { 80104dfc: 89 5d f4 mov %ebx,-0xc(%ebp) 80104dff: 89 75 f8 mov %esi,-0x8(%ebp) 80104e02: 89 7d fc mov %edi,-0x4(%ebp) char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 80104e05: 89 44 24 04 mov %eax,0x4(%esp) 80104e09: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104e10: e8 fb fd ff ff call 80104c10 <argstr> 80104e15: 85 c0 test %eax,%eax 80104e17: 79 17 jns 80104e30 <sys_exec+0x40> return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ if(i >= NELEM(argv)) 80104e19: b8 ff ff ff ff mov $0xffffffff,%eax } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); } 80104e1e: 8b 5d f4 mov -0xc(%ebp),%ebx 80104e21: 8b 75 f8 mov -0x8(%ebp),%esi 80104e24: 8b 7d fc mov -0x4(%ebp),%edi 80104e27: 89 ec mov %ebp,%esp 80104e29: 5d pop %ebp 80104e2a: c3 ret 80104e2b: 90 nop 80104e2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 80104e30: 8d 45 e0 lea -0x20(%ebp),%eax 80104e33: 89 44 24 04 mov %eax,0x4(%esp) 80104e37: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104e3e: e8 3d fd ff ff call 80104b80 <argint> 80104e43: 85 c0 test %eax,%eax 80104e45: 78 d2 js 80104e19 <sys_exec+0x29> return -1; } memset(argv, 0, sizeof(argv)); 80104e47: 8d bd 5c ff ff ff lea -0xa4(%ebp),%edi 80104e4d: 31 f6 xor %esi,%esi 80104e4f: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 80104e56: 00 80104e57: 31 db xor %ebx,%ebx 80104e59: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104e60: 00 80104e61: 89 3c 24 mov %edi,(%esp) 80104e64: e8 07 fa ff ff call 80104870 <memset> 80104e69: eb 22 jmp 80104e8d <sys_exec+0x9d> 80104e6b: 90 nop 80104e6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; if(uarg == 0){ argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80104e70: 8d 14 b7 lea (%edi,%esi,4),%edx 80104e73: 89 54 24 04 mov %edx,0x4(%esp) 80104e77: 89 04 24 mov %eax,(%esp) 80104e7a: e8 a1 fc ff ff call 80104b20 <fetchstr> 80104e7f: 85 c0 test %eax,%eax 80104e81: 78 96 js 80104e19 <sys_exec+0x29> if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80104e83: 83 c3 01 add $0x1,%ebx if(i >= NELEM(argv)) 80104e86: 83 fb 20 cmp $0x20,%ebx if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ return -1; } memset(argv, 0, sizeof(argv)); for(i=0;; i++){ 80104e89: 89 de mov %ebx,%esi if(i >= NELEM(argv)) 80104e8b: 74 8c je 80104e19 <sys_exec+0x29> return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 80104e8d: 8d 45 dc lea -0x24(%ebp),%eax 80104e90: 89 44 24 04 mov %eax,0x4(%esp) 80104e94: 8d 04 9d 00 00 00 00 lea 0x0(,%ebx,4),%eax 80104e9b: 03 45 e0 add -0x20(%ebp),%eax 80104e9e: 89 04 24 mov %eax,(%esp) 80104ea1: e8 3a fc ff ff call 80104ae0 <fetchint> 80104ea6: 85 c0 test %eax,%eax 80104ea8: 0f 88 6b ff ff ff js 80104e19 <sys_exec+0x29> return -1; if(uarg == 0){ 80104eae: 8b 45 dc mov -0x24(%ebp),%eax 80104eb1: 85 c0 test %eax,%eax 80104eb3: 75 bb jne 80104e70 <sys_exec+0x80> break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 80104eb5: 8b 45 e4 mov -0x1c(%ebp),%eax if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) return -1; if(uarg == 0){ argv[i] = 0; 80104eb8: c7 84 9d 5c ff ff ff movl $0x0,-0xa4(%ebp,%ebx,4) 80104ebf: 00 00 00 00 break; } if(fetchstr(uarg, &argv[i]) < 0) return -1; } return exec(path, argv); 80104ec3: 89 7c 24 04 mov %edi,0x4(%esp) 80104ec7: 89 04 24 mov %eax,(%esp) 80104eca: e8 11 bb ff ff call 801009e0 <exec> 80104ecf: e9 4a ff ff ff jmp 80104e1e <sys_exec+0x2e> 80104ed4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104eda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104ee0 <sys_chdir>: return 0; } int sys_chdir(void) { 80104ee0: 55 push %ebp 80104ee1: 89 e5 mov %esp,%ebp 80104ee3: 53 push %ebx 80104ee4: 83 ec 24 sub $0x24,%esp char *path; struct inode *ip; begin_op(); 80104ee7: e8 c4 de ff ff call 80102db0 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80104eec: 8d 45 f4 lea -0xc(%ebp),%eax 80104eef: 89 44 24 04 mov %eax,0x4(%esp) 80104ef3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104efa: e8 11 fd ff ff call 80104c10 <argstr> 80104eff: 85 c0 test %eax,%eax 80104f01: 78 5d js 80104f60 <sys_chdir+0x80> 80104f03: 8b 45 f4 mov -0xc(%ebp),%eax 80104f06: 89 04 24 mov %eax,(%esp) 80104f09: e8 b2 cf ff ff call 80101ec0 <namei> 80104f0e: 85 c0 test %eax,%eax 80104f10: 89 c3 mov %eax,%ebx 80104f12: 74 4c je 80104f60 <sys_chdir+0x80> end_op(); return -1; } ilock(ip); 80104f14: 89 04 24 mov %eax,(%esp) 80104f17: e8 44 cd ff ff call 80101c60 <ilock> if(ip->type != T_DIR){ 80104f1c: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104f21: 75 35 jne 80104f58 <sys_chdir+0x78> iunlockput(ip); end_op(); return -1; } iunlock(ip); 80104f23: 89 1c 24 mov %ebx,(%esp) 80104f26: e8 c5 cc ff ff call 80101bf0 <iunlock> iput(proc->cwd); 80104f2b: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104f31: 8b 40 68 mov 0x68(%eax),%eax 80104f34: 89 04 24 mov %eax,(%esp) 80104f37: e8 f4 c4 ff ff call 80101430 <iput> end_op(); 80104f3c: e8 3f dd ff ff call 80102c80 <end_op> proc->cwd = ip; 80104f41: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80104f47: 89 58 68 mov %ebx,0x68(%eax) return 0; } 80104f4a: 83 c4 24 add $0x24,%esp return -1; } iunlock(ip); iput(proc->cwd); end_op(); proc->cwd = ip; 80104f4d: 31 c0 xor %eax,%eax return 0; } 80104f4f: 5b pop %ebx 80104f50: 5d pop %ebp 80104f51: c3 ret 80104f52: 8d b6 00 00 00 00 lea 0x0(%esi),%esi end_op(); return -1; } ilock(ip); if(ip->type != T_DIR){ iunlockput(ip); 80104f58: 89 1c 24 mov %ebx,(%esp) 80104f5b: e8 e0 cc ff ff call 80101c40 <iunlockput> end_op(); 80104f60: e8 1b dd ff ff call 80102c80 <end_op> iunlock(ip); iput(proc->cwd); end_op(); proc->cwd = ip; return 0; } 80104f65: 83 c4 24 add $0x24,%esp return -1; } ilock(ip); if(ip->type != T_DIR){ iunlockput(ip); end_op(); 80104f68: b8 ff ff ff ff mov $0xffffffff,%eax iunlock(ip); iput(proc->cwd); end_op(); proc->cwd = ip; return 0; } 80104f6d: 5b pop %ebx 80104f6e: 5d pop %ebp 80104f6f: c3 ret 80104f70 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104f70: 55 push %ebp 80104f71: 89 e5 mov %esp,%ebp 80104f73: 83 ec 58 sub $0x58,%esp 80104f76: 89 4d c4 mov %ecx,-0x3c(%ebp) 80104f79: 8b 4d 08 mov 0x8(%ebp),%ecx 80104f7c: 89 75 f8 mov %esi,-0x8(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 80104f7f: 8d 75 d6 lea -0x2a(%ebp),%esi return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104f82: 89 5d f4 mov %ebx,-0xc(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 80104f85: 31 db xor %ebx,%ebx return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104f87: 89 7d fc mov %edi,-0x4(%ebp) 80104f8a: 89 d7 mov %edx,%edi 80104f8c: 89 4d c0 mov %ecx,-0x40(%ebp) uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 80104f8f: 89 74 24 04 mov %esi,0x4(%esp) 80104f93: 89 04 24 mov %eax,(%esp) 80104f96: e8 05 cf ff ff call 80101ea0 <nameiparent> 80104f9b: 85 c0 test %eax,%eax 80104f9d: 74 47 je 80104fe6 <create+0x76> return 0; ilock(dp); 80104f9f: 89 04 24 mov %eax,(%esp) 80104fa2: 89 45 bc mov %eax,-0x44(%ebp) 80104fa5: e8 b6 cc ff ff call 80101c60 <ilock> if((ip = dirlookup(dp, name, &off)) != 0){ 80104faa: 8b 55 bc mov -0x44(%ebp),%edx 80104fad: 8d 45 e4 lea -0x1c(%ebp),%eax 80104fb0: 89 44 24 08 mov %eax,0x8(%esp) 80104fb4: 89 74 24 04 mov %esi,0x4(%esp) 80104fb8: 89 14 24 mov %edx,(%esp) 80104fbb: e8 c0 c9 ff ff call 80101980 <dirlookup> 80104fc0: 8b 55 bc mov -0x44(%ebp),%edx 80104fc3: 85 c0 test %eax,%eax 80104fc5: 89 c3 mov %eax,%ebx 80104fc7: 74 4f je 80105018 <create+0xa8> iunlockput(dp); 80104fc9: 89 14 24 mov %edx,(%esp) 80104fcc: e8 6f cc ff ff call 80101c40 <iunlockput> ilock(ip); 80104fd1: 89 1c 24 mov %ebx,(%esp) 80104fd4: e8 87 cc ff ff call 80101c60 <ilock> if(type == T_FILE && ip->type == T_FILE) 80104fd9: 66 83 ff 02 cmp $0x2,%di 80104fdd: 75 19 jne 80104ff8 <create+0x88> 80104fdf: 66 83 7b 50 02 cmpw $0x2,0x50(%ebx) 80104fe4: 75 12 jne 80104ff8 <create+0x88> panic("create: dirlink"); iunlockput(dp); return ip; } 80104fe6: 89 d8 mov %ebx,%eax 80104fe8: 8b 75 f8 mov -0x8(%ebp),%esi 80104feb: 8b 5d f4 mov -0xc(%ebp),%ebx 80104fee: 8b 7d fc mov -0x4(%ebp),%edi 80104ff1: 89 ec mov %ebp,%esp 80104ff3: 5d pop %ebp 80104ff4: c3 ret 80104ff5: 8d 76 00 lea 0x0(%esi),%esi if((ip = dirlookup(dp, name, &off)) != 0){ iunlockput(dp); ilock(ip); if(type == T_FILE && ip->type == T_FILE) return ip; iunlockput(ip); 80104ff8: 89 1c 24 mov %ebx,(%esp) 80104ffb: 31 db xor %ebx,%ebx 80104ffd: e8 3e cc ff ff call 80101c40 <iunlockput> panic("create: dirlink"); iunlockput(dp); return ip; } 80105002: 89 d8 mov %ebx,%eax 80105004: 8b 75 f8 mov -0x8(%ebp),%esi 80105007: 8b 5d f4 mov -0xc(%ebp),%ebx 8010500a: 8b 7d fc mov -0x4(%ebp),%edi 8010500d: 89 ec mov %ebp,%esp 8010500f: 5d pop %ebp 80105010: c3 ret 80105011: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return ip; iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) 80105018: 0f bf c7 movswl %di,%eax 8010501b: 89 44 24 04 mov %eax,0x4(%esp) 8010501f: 8b 02 mov (%edx),%eax 80105021: 89 55 bc mov %edx,-0x44(%ebp) 80105024: 89 04 24 mov %eax,(%esp) 80105027: e8 f4 ca ff ff call 80101b20 <ialloc> 8010502c: 8b 55 bc mov -0x44(%ebp),%edx 8010502f: 85 c0 test %eax,%eax 80105031: 89 c3 mov %eax,%ebx 80105033: 0f 84 cb 00 00 00 je 80105104 <create+0x194> panic("create: ialloc"); ilock(ip); 80105039: 89 55 bc mov %edx,-0x44(%ebp) 8010503c: 89 04 24 mov %eax,(%esp) 8010503f: e8 1c cc ff ff call 80101c60 <ilock> ip->major = major; 80105044: 0f b7 45 c4 movzwl -0x3c(%ebp),%eax 80105048: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = minor; 8010504c: 0f b7 4d c0 movzwl -0x40(%ebp),%ecx ip->nlink = 1; 80105050: 66 c7 43 56 01 00 movw $0x1,0x56(%ebx) if((ip = ialloc(dp->dev, type)) == 0) panic("create: ialloc"); ilock(ip); ip->major = major; ip->minor = minor; 80105056: 66 89 4b 54 mov %cx,0x54(%ebx) ip->nlink = 1; iupdate(ip); 8010505a: 89 1c 24 mov %ebx,(%esp) 8010505d: e8 4e c2 ff ff call 801012b0 <iupdate> if(type == T_DIR){ // Create . and .. entries. 80105062: 66 83 ff 01 cmp $0x1,%di 80105066: 8b 55 bc mov -0x44(%ebp),%edx 80105069: 74 3d je 801050a8 <create+0x138> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) panic("create dots"); } if(dirlink(dp, name, ip->inum) < 0) 8010506b: 8b 43 04 mov 0x4(%ebx),%eax 8010506e: 89 14 24 mov %edx,(%esp) 80105071: 89 55 bc mov %edx,-0x44(%ebp) 80105074: 89 74 24 04 mov %esi,0x4(%esp) 80105078: 89 44 24 08 mov %eax,0x8(%esp) 8010507c: e8 af c9 ff ff call 80101a30 <dirlink> 80105081: 8b 55 bc mov -0x44(%ebp),%edx 80105084: 85 c0 test %eax,%eax 80105086: 0f 88 84 00 00 00 js 80105110 <create+0x1a0> panic("create: dirlink"); iunlockput(dp); 8010508c: 89 14 24 mov %edx,(%esp) 8010508f: e8 ac cb ff ff call 80101c40 <iunlockput> return ip; } 80105094: 89 d8 mov %ebx,%eax 80105096: 8b 75 f8 mov -0x8(%ebp),%esi 80105099: 8b 5d f4 mov -0xc(%ebp),%ebx 8010509c: 8b 7d fc mov -0x4(%ebp),%edi 8010509f: 89 ec mov %ebp,%esp 801050a1: 5d pop %ebp 801050a2: c3 ret 801050a3: 90 nop 801050a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ip->minor = minor; ip->nlink = 1; iupdate(ip); if(type == T_DIR){ // Create . and .. entries. dp->nlink++; // for ".." 801050a8: 66 83 42 56 01 addw $0x1,0x56(%edx) iupdate(dp); 801050ad: 89 14 24 mov %edx,(%esp) 801050b0: 89 55 bc mov %edx,-0x44(%ebp) 801050b3: e8 f8 c1 ff ff call 801012b0 <iupdate> // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 801050b8: 8b 43 04 mov 0x4(%ebx),%eax 801050bb: c7 44 24 04 4c 7a 10 movl $0x80107a4c,0x4(%esp) 801050c2: 80 801050c3: 89 1c 24 mov %ebx,(%esp) 801050c6: 89 44 24 08 mov %eax,0x8(%esp) 801050ca: e8 61 c9 ff ff call 80101a30 <dirlink> 801050cf: 8b 55 bc mov -0x44(%ebp),%edx 801050d2: 85 c0 test %eax,%eax 801050d4: 78 22 js 801050f8 <create+0x188> 801050d6: 8b 42 04 mov 0x4(%edx),%eax 801050d9: c7 44 24 04 4b 7a 10 movl $0x80107a4b,0x4(%esp) 801050e0: 80 801050e1: 89 1c 24 mov %ebx,(%esp) 801050e4: 89 44 24 08 mov %eax,0x8(%esp) 801050e8: e8 43 c9 ff ff call 80101a30 <dirlink> 801050ed: 8b 55 bc mov -0x44(%ebp),%edx 801050f0: 85 c0 test %eax,%eax 801050f2: 0f 89 73 ff ff ff jns 8010506b <create+0xfb> panic("create dots"); 801050f8: c7 04 24 4e 7a 10 80 movl $0x80107a4e,(%esp) 801050ff: e8 cc b2 ff ff call 801003d0 <panic> iunlockput(ip); return 0; } if((ip = ialloc(dp->dev, type)) == 0) panic("create: ialloc"); 80105104: c7 04 24 3c 7a 10 80 movl $0x80107a3c,(%esp) 8010510b: e8 c0 b2 ff ff call 801003d0 <panic> if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) panic("create dots"); } if(dirlink(dp, name, ip->inum) < 0) panic("create: dirlink"); 80105110: c7 04 24 5a 7a 10 80 movl $0x80107a5a,(%esp) 80105117: e8 b4 b2 ff ff call 801003d0 <panic> 8010511c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105120 <sys_mknod>: return 0; } int sys_mknod(void) { 80105120: 55 push %ebp 80105121: 89 e5 mov %esp,%ebp 80105123: 83 ec 28 sub $0x28,%esp struct inode *ip; char *path; int major, minor; begin_op(); 80105126: e8 85 dc ff ff call 80102db0 <begin_op> if((argstr(0, &path)) < 0 || 8010512b: 8d 45 f4 lea -0xc(%ebp),%eax 8010512e: 89 44 24 04 mov %eax,0x4(%esp) 80105132: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105139: e8 d2 fa ff ff call 80104c10 <argstr> 8010513e: 85 c0 test %eax,%eax 80105140: 78 5e js 801051a0 <sys_mknod+0x80> argint(1, &major) < 0 || 80105142: 8d 45 f0 lea -0x10(%ebp),%eax 80105145: 89 44 24 04 mov %eax,0x4(%esp) 80105149: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105150: e8 2b fa ff ff call 80104b80 <argint> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 80105155: 85 c0 test %eax,%eax 80105157: 78 47 js 801051a0 <sys_mknod+0x80> argint(1, &major) < 0 || argint(2, &minor) < 0 || 80105159: 8d 45 ec lea -0x14(%ebp),%eax 8010515c: 89 44 24 04 mov %eax,0x4(%esp) 80105160: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80105167: e8 14 fa ff ff call 80104b80 <argint> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 8010516c: 85 c0 test %eax,%eax 8010516e: 78 30 js 801051a0 <sys_mknod+0x80> argint(1, &major) < 0 || argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ 80105170: 0f bf 45 ec movswl -0x14(%ebp),%eax 80105174: ba 03 00 00 00 mov $0x3,%edx 80105179: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 8010517d: 89 04 24 mov %eax,(%esp) 80105180: 8b 45 f4 mov -0xc(%ebp),%eax 80105183: e8 e8 fd ff ff call 80104f70 <create> struct inode *ip; char *path; int major, minor; begin_op(); if((argstr(0, &path)) < 0 || 80105188: 85 c0 test %eax,%eax 8010518a: 74 14 je 801051a0 <sys_mknod+0x80> argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); return -1; } iunlockput(ip); 8010518c: 89 04 24 mov %eax,(%esp) 8010518f: e8 ac ca ff ff call 80101c40 <iunlockput> end_op(); 80105194: e8 e7 da ff ff call 80102c80 <end_op> 80105199: 31 c0 xor %eax,%eax return 0; } 8010519b: c9 leave 8010519c: c3 ret 8010519d: 8d 76 00 lea 0x0(%esi),%esi begin_op(); if((argstr(0, &path)) < 0 || argint(1, &major) < 0 || argint(2, &minor) < 0 || (ip = create(path, T_DEV, major, minor)) == 0){ end_op(); 801051a0: e8 db da ff ff call 80102c80 <end_op> 801051a5: b8 ff ff ff ff mov $0xffffffff,%eax return -1; } iunlockput(ip); end_op(); return 0; } 801051aa: c9 leave 801051ab: c3 ret 801051ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801051b0 <sys_mkdir>: return fd; } int sys_mkdir(void) { 801051b0: 55 push %ebp 801051b1: 89 e5 mov %esp,%ebp 801051b3: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 801051b6: e8 f5 db ff ff call 80102db0 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 801051bb: 8d 45 f4 lea -0xc(%ebp),%eax 801051be: 89 44 24 04 mov %eax,0x4(%esp) 801051c2: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801051c9: e8 42 fa ff ff call 80104c10 <argstr> 801051ce: 85 c0 test %eax,%eax 801051d0: 78 2e js 80105200 <sys_mkdir+0x50> 801051d2: 8b 45 f4 mov -0xc(%ebp),%eax 801051d5: 31 c9 xor %ecx,%ecx 801051d7: ba 01 00 00 00 mov $0x1,%edx 801051dc: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801051e3: e8 88 fd ff ff call 80104f70 <create> 801051e8: 85 c0 test %eax,%eax 801051ea: 74 14 je 80105200 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 801051ec: 89 04 24 mov %eax,(%esp) 801051ef: e8 4c ca ff ff call 80101c40 <iunlockput> end_op(); 801051f4: e8 87 da ff ff call 80102c80 <end_op> 801051f9: 31 c0 xor %eax,%eax return 0; } 801051fb: c9 leave 801051fc: c3 ret 801051fd: 8d 76 00 lea 0x0(%esi),%esi char *path; struct inode *ip; begin_op(); if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ end_op(); 80105200: e8 7b da ff ff call 80102c80 <end_op> 80105205: b8 ff ff ff ff mov $0xffffffff,%eax return -1; } iunlockput(ip); end_op(); return 0; } 8010520a: c9 leave 8010520b: c3 ret 8010520c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105210 <sys_link>: } // Create the path new as a link to the same inode as old. int sys_link(void) { 80105210: 55 push %ebp 80105211: 89 e5 mov %esp,%ebp 80105213: 83 ec 48 sub $0x48,%esp char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105216: 8d 45 e0 lea -0x20(%ebp),%eax } // Create the path new as a link to the same inode as old. int sys_link(void) { 80105219: 89 5d f4 mov %ebx,-0xc(%ebp) 8010521c: 89 75 f8 mov %esi,-0x8(%ebp) 8010521f: 89 7d fc mov %edi,-0x4(%ebp) char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105222: 89 44 24 04 mov %eax,0x4(%esp) 80105226: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010522d: e8 de f9 ff ff call 80104c10 <argstr> 80105232: 85 c0 test %eax,%eax 80105234: 79 12 jns 80105248 <sys_link+0x38> ilock(ip); ip->nlink--; iupdate(ip); iunlockput(ip); end_op(); return -1; 80105236: b8 ff ff ff ff mov $0xffffffff,%eax } 8010523b: 8b 5d f4 mov -0xc(%ebp),%ebx 8010523e: 8b 75 f8 mov -0x8(%ebp),%esi 80105241: 8b 7d fc mov -0x4(%ebp),%edi 80105244: 89 ec mov %ebp,%esp 80105246: 5d pop %ebp 80105247: c3 ret sys_link(void) { char name[DIRSIZ], *new, *old; struct inode *dp, *ip; if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80105248: 8d 45 e4 lea -0x1c(%ebp),%eax 8010524b: 89 44 24 04 mov %eax,0x4(%esp) 8010524f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105256: e8 b5 f9 ff ff call 80104c10 <argstr> 8010525b: 85 c0 test %eax,%eax 8010525d: 78 d7 js 80105236 <sys_link+0x26> return -1; begin_op(); 8010525f: e8 4c db ff ff call 80102db0 <begin_op> if((ip = namei(old)) == 0){ 80105264: 8b 45 e0 mov -0x20(%ebp),%eax 80105267: 89 04 24 mov %eax,(%esp) 8010526a: e8 51 cc ff ff call 80101ec0 <namei> 8010526f: 85 c0 test %eax,%eax 80105271: 89 c3 mov %eax,%ebx 80105273: 0f 84 a6 00 00 00 je 8010531f <sys_link+0x10f> end_op(); return -1; } ilock(ip); 80105279: 89 04 24 mov %eax,(%esp) 8010527c: e8 df c9 ff ff call 80101c60 <ilock> if(ip->type == T_DIR){ 80105281: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80105286: 0f 84 8b 00 00 00 je 80105317 <sys_link+0x107> iunlockput(ip); end_op(); return -1; } ip->nlink++; 8010528c: 66 83 43 56 01 addw $0x1,0x56(%ebx) iupdate(ip); iunlock(ip); if((dp = nameiparent(new, name)) == 0) 80105291: 8d 7d d2 lea -0x2e(%ebp),%edi end_op(); return -1; } ip->nlink++; iupdate(ip); 80105294: 89 1c 24 mov %ebx,(%esp) 80105297: e8 14 c0 ff ff call 801012b0 <iupdate> iunlock(ip); 8010529c: 89 1c 24 mov %ebx,(%esp) 8010529f: e8 4c c9 ff ff call 80101bf0 <iunlock> if((dp = nameiparent(new, name)) == 0) 801052a4: 8b 45 e4 mov -0x1c(%ebp),%eax 801052a7: 89 7c 24 04 mov %edi,0x4(%esp) 801052ab: 89 04 24 mov %eax,(%esp) 801052ae: e8 ed cb ff ff call 80101ea0 <nameiparent> 801052b3: 85 c0 test %eax,%eax 801052b5: 89 c6 mov %eax,%esi 801052b7: 74 49 je 80105302 <sys_link+0xf2> goto bad; ilock(dp); 801052b9: 89 04 24 mov %eax,(%esp) 801052bc: e8 9f c9 ff ff call 80101c60 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 801052c1: 8b 06 mov (%esi),%eax 801052c3: 3b 03 cmp (%ebx),%eax 801052c5: 75 33 jne 801052fa <sys_link+0xea> 801052c7: 8b 43 04 mov 0x4(%ebx),%eax 801052ca: 89 7c 24 04 mov %edi,0x4(%esp) 801052ce: 89 34 24 mov %esi,(%esp) 801052d1: 89 44 24 08 mov %eax,0x8(%esp) 801052d5: e8 56 c7 ff ff call 80101a30 <dirlink> 801052da: 85 c0 test %eax,%eax 801052dc: 78 1c js 801052fa <sys_link+0xea> iunlockput(dp); goto bad; } iunlockput(dp); 801052de: 89 34 24 mov %esi,(%esp) 801052e1: e8 5a c9 ff ff call 80101c40 <iunlockput> iput(ip); 801052e6: 89 1c 24 mov %ebx,(%esp) 801052e9: e8 42 c1 ff ff call 80101430 <iput> end_op(); 801052ee: e8 8d d9 ff ff call 80102c80 <end_op> 801052f3: 31 c0 xor %eax,%eax return 0; 801052f5: e9 41 ff ff ff jmp 8010523b <sys_link+0x2b> if((dp = nameiparent(new, name)) == 0) goto bad; ilock(dp); if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ iunlockput(dp); 801052fa: 89 34 24 mov %esi,(%esp) 801052fd: e8 3e c9 ff ff call 80101c40 <iunlockput> end_op(); return 0; bad: ilock(ip); 80105302: 89 1c 24 mov %ebx,(%esp) 80105305: e8 56 c9 ff ff call 80101c60 <ilock> ip->nlink--; 8010530a: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 8010530f: 89 1c 24 mov %ebx,(%esp) 80105312: e8 99 bf ff ff call 801012b0 <iupdate> iunlockput(ip); 80105317: 89 1c 24 mov %ebx,(%esp) 8010531a: e8 21 c9 ff ff call 80101c40 <iunlockput> end_op(); 8010531f: e8 5c d9 ff ff call 80102c80 <end_op> 80105324: b8 ff ff ff ff mov $0xffffffff,%eax return -1; 80105329: e9 0d ff ff ff jmp 8010523b <sys_link+0x2b> 8010532e: 66 90 xchg %ax,%ax 80105330 <sys_open>: return ip; } int sys_open(void) { 80105330: 55 push %ebp 80105331: 89 e5 mov %esp,%ebp 80105333: 83 ec 38 sub $0x38,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80105336: 8d 45 f4 lea -0xc(%ebp),%eax return ip; } int sys_open(void) { 80105339: 89 5d f8 mov %ebx,-0x8(%ebp) 8010533c: 89 75 fc mov %esi,-0x4(%ebp) char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 8010533f: 89 44 24 04 mov %eax,0x4(%esp) 80105343: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010534a: e8 c1 f8 ff ff call 80104c10 <argstr> 8010534f: 85 c0 test %eax,%eax 80105351: 79 15 jns 80105368 <sys_open+0x38> if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); iunlockput(ip); end_op(); return -1; 80105353: b8 ff ff ff ff mov $0xffffffff,%eax f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); f->writable = (omode & O_WRONLY) || (omode & O_RDWR); return fd; } 80105358: 8b 5d f8 mov -0x8(%ebp),%ebx 8010535b: 8b 75 fc mov -0x4(%ebp),%esi 8010535e: 89 ec mov %ebp,%esp 80105360: 5d pop %ebp 80105361: c3 ret 80105362: 8d b6 00 00 00 00 lea 0x0(%esi),%esi char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80105368: 8d 45 f0 lea -0x10(%ebp),%eax 8010536b: 89 44 24 04 mov %eax,0x4(%esp) 8010536f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105376: e8 05 f8 ff ff call 80104b80 <argint> 8010537b: 85 c0 test %eax,%eax 8010537d: 78 d4 js 80105353 <sys_open+0x23> return -1; begin_op(); 8010537f: e8 2c da ff ff call 80102db0 <begin_op> if(omode & O_CREATE){ 80105384: f6 45 f1 02 testb $0x2,-0xf(%ebp) 80105388: 74 66 je 801053f0 <sys_open+0xc0> ip = create(path, T_FILE, 0, 0); 8010538a: 8b 45 f4 mov -0xc(%ebp),%eax 8010538d: 31 c9 xor %ecx,%ecx 8010538f: ba 02 00 00 00 mov $0x2,%edx 80105394: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010539b: e8 d0 fb ff ff call 80104f70 <create> if(ip == 0){ 801053a0: 85 c0 test %eax,%eax return -1; begin_op(); if(omode & O_CREATE){ ip = create(path, T_FILE, 0, 0); 801053a2: 89 c3 mov %eax,%ebx if(ip == 0){ 801053a4: 74 3a je 801053e0 <sys_open+0xb0> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 801053a6: e8 35 bc ff ff call 80100fe0 <filealloc> 801053ab: 85 c0 test %eax,%eax 801053ad: 89 c6 mov %eax,%esi 801053af: 74 27 je 801053d8 <sys_open+0xa8> 801053b1: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 801053b8: 31 c0 xor %eax,%eax 801053ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ 801053c0: 8b 4c 82 28 mov 0x28(%edx,%eax,4),%ecx 801053c4: 85 c9 test %ecx,%ecx 801053c6: 74 58 je 80105420 <sys_open+0xf0> static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 801053c8: 83 c0 01 add $0x1,%eax 801053cb: 83 f8 10 cmp $0x10,%eax 801053ce: 75 f0 jne 801053c0 <sys_open+0x90> } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ if(f) fileclose(f); 801053d0: 89 34 24 mov %esi,(%esp) 801053d3: e8 88 bc ff ff call 80101060 <fileclose> iunlockput(ip); 801053d8: 89 1c 24 mov %ebx,(%esp) 801053db: e8 60 c8 ff ff call 80101c40 <iunlockput> end_op(); 801053e0: e8 9b d8 ff ff call 80102c80 <end_op> 801053e5: b8 ff ff ff ff mov $0xffffffff,%eax return -1; 801053ea: e9 69 ff ff ff jmp 80105358 <sys_open+0x28> 801053ef: 90 nop if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 801053f0: 8b 45 f4 mov -0xc(%ebp),%eax 801053f3: 89 04 24 mov %eax,(%esp) 801053f6: e8 c5 ca ff ff call 80101ec0 <namei> 801053fb: 85 c0 test %eax,%eax 801053fd: 89 c3 mov %eax,%ebx 801053ff: 74 df je 801053e0 <sys_open+0xb0> end_op(); return -1; } ilock(ip); 80105401: 89 04 24 mov %eax,(%esp) 80105404: e8 57 c8 ff ff call 80101c60 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80105409: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 8010540e: 75 96 jne 801053a6 <sys_open+0x76> 80105410: 8b 75 f0 mov -0x10(%ebp),%esi 80105413: 85 f6 test %esi,%esi 80105415: 74 8f je 801053a6 <sys_open+0x76> 80105417: eb bf jmp 801053d8 <sys_open+0xa8> 80105419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi { int fd; for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] == 0){ proc->ofile[fd] = f; 80105420: 89 74 82 28 mov %esi,0x28(%edx,%eax,4) fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80105424: 89 45 e4 mov %eax,-0x1c(%ebp) 80105427: 89 1c 24 mov %ebx,(%esp) 8010542a: e8 c1 c7 ff ff call 80101bf0 <iunlock> end_op(); 8010542f: e8 4c d8 ff ff call 80102c80 <end_op> f->type = FD_INODE; 80105434: c7 06 02 00 00 00 movl $0x2,(%esi) f->ip = ip; 8010543a: 89 5e 10 mov %ebx,0x10(%esi) f->off = 0; 8010543d: c7 46 14 00 00 00 00 movl $0x0,0x14(%esi) f->readable = !(omode & O_WRONLY); 80105444: 8b 55 f0 mov -0x10(%ebp),%edx 80105447: 83 f2 01 xor $0x1,%edx 8010544a: 83 e2 01 and $0x1,%edx 8010544d: 88 56 08 mov %dl,0x8(%esi) f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80105450: f6 45 f0 03 testb $0x3,-0x10(%ebp) 80105454: 0f 95 46 09 setne 0x9(%esi) return fd; 80105458: 8b 45 e4 mov -0x1c(%ebp),%eax 8010545b: e9 f8 fe ff ff jmp 80105358 <sys_open+0x28> 80105460 <sys_unlink>: } //PAGEBREAK! int sys_unlink(void) { 80105460: 55 push %ebp 80105461: 89 e5 mov %esp,%ebp 80105463: 57 push %edi 80105464: 56 push %esi 80105465: 53 push %ebx 80105466: 83 ec 6c sub $0x6c,%esp struct inode *ip, *dp; struct dirent de; char name[DIRSIZ], *path; uint off; if(argstr(0, &path) < 0) 80105469: 8d 45 e4 lea -0x1c(%ebp),%eax 8010546c: 89 44 24 04 mov %eax,0x4(%esp) 80105470: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105477: e8 94 f7 ff ff call 80104c10 <argstr> 8010547c: 89 c2 mov %eax,%edx 8010547e: b8 ff ff ff ff mov $0xffffffff,%eax 80105483: 85 d2 test %edx,%edx 80105485: 0f 88 0b 01 00 00 js 80105596 <sys_unlink+0x136> return -1; begin_op(); 8010548b: e8 20 d9 ff ff call 80102db0 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80105490: 8b 45 e4 mov -0x1c(%ebp),%eax 80105493: 8d 5d d2 lea -0x2e(%ebp),%ebx 80105496: 89 5c 24 04 mov %ebx,0x4(%esp) 8010549a: 89 04 24 mov %eax,(%esp) 8010549d: e8 fe c9 ff ff call 80101ea0 <nameiparent> 801054a2: 85 c0 test %eax,%eax 801054a4: 89 45 a4 mov %eax,-0x5c(%ebp) 801054a7: 0f 84 4e 01 00 00 je 801055fb <sys_unlink+0x19b> end_op(); return -1; } ilock(dp); 801054ad: 8b 45 a4 mov -0x5c(%ebp),%eax 801054b0: 89 04 24 mov %eax,(%esp) 801054b3: e8 a8 c7 ff ff call 80101c60 <ilock> // Cannot unlink "." or "..". if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 801054b8: c7 44 24 04 4c 7a 10 movl $0x80107a4c,0x4(%esp) 801054bf: 80 801054c0: 89 1c 24 mov %ebx,(%esp) 801054c3: e8 b8 bd ff ff call 80101280 <namecmp> 801054c8: 85 c0 test %eax,%eax 801054ca: 0f 84 20 01 00 00 je 801055f0 <sys_unlink+0x190> 801054d0: c7 44 24 04 4b 7a 10 movl $0x80107a4b,0x4(%esp) 801054d7: 80 801054d8: 89 1c 24 mov %ebx,(%esp) 801054db: e8 a0 bd ff ff call 80101280 <namecmp> 801054e0: 85 c0 test %eax,%eax 801054e2: 0f 84 08 01 00 00 je 801055f0 <sys_unlink+0x190> goto bad; if((ip = dirlookup(dp, name, &off)) == 0) 801054e8: 8d 45 e0 lea -0x20(%ebp),%eax 801054eb: 89 44 24 08 mov %eax,0x8(%esp) 801054ef: 8b 45 a4 mov -0x5c(%ebp),%eax 801054f2: 89 5c 24 04 mov %ebx,0x4(%esp) 801054f6: 89 04 24 mov %eax,(%esp) 801054f9: e8 82 c4 ff ff call 80101980 <dirlookup> 801054fe: 85 c0 test %eax,%eax 80105500: 89 c6 mov %eax,%esi 80105502: 0f 84 e8 00 00 00 je 801055f0 <sys_unlink+0x190> goto bad; ilock(ip); 80105508: 89 04 24 mov %eax,(%esp) 8010550b: e8 50 c7 ff ff call 80101c60 <ilock> if(ip->nlink < 1) 80105510: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 80105515: 0f 8e 22 01 00 00 jle 8010563d <sys_unlink+0x1dd> panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ 8010551b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80105520: 74 7e je 801055a0 <sys_unlink+0x140> iunlockput(ip); goto bad; } memset(&de, 0, sizeof(de)); 80105522: 8d 5d c2 lea -0x3e(%ebp),%ebx 80105525: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 8010552c: 00 8010552d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105534: 00 80105535: 89 1c 24 mov %ebx,(%esp) 80105538: e8 33 f3 ff ff call 80104870 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 8010553d: 8b 45 e0 mov -0x20(%ebp),%eax 80105540: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80105547: 00 80105548: 89 5c 24 04 mov %ebx,0x4(%esp) 8010554c: 89 44 24 08 mov %eax,0x8(%esp) 80105550: 8b 45 a4 mov -0x5c(%ebp),%eax 80105553: 89 04 24 mov %eax,(%esp) 80105556: e8 f5 c1 ff ff call 80101750 <writei> 8010555b: 83 f8 10 cmp $0x10,%eax 8010555e: 0f 85 cd 00 00 00 jne 80105631 <sys_unlink+0x1d1> panic("unlink: writei"); if(ip->type == T_DIR){ 80105564: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80105569: 0f 84 a1 00 00 00 je 80105610 <sys_unlink+0x1b0> dp->nlink--; iupdate(dp); } iunlockput(dp); 8010556f: 8b 45 a4 mov -0x5c(%ebp),%eax 80105572: 89 04 24 mov %eax,(%esp) 80105575: e8 c6 c6 ff ff call 80101c40 <iunlockput> ip->nlink--; 8010557a: 66 83 6e 56 01 subw $0x1,0x56(%esi) iupdate(ip); 8010557f: 89 34 24 mov %esi,(%esp) 80105582: e8 29 bd ff ff call 801012b0 <iupdate> iunlockput(ip); 80105587: 89 34 24 mov %esi,(%esp) 8010558a: e8 b1 c6 ff ff call 80101c40 <iunlockput> end_op(); 8010558f: e8 ec d6 ff ff call 80102c80 <end_op> 80105594: 31 c0 xor %eax,%eax bad: iunlockput(dp); end_op(); return -1; } 80105596: 83 c4 6c add $0x6c,%esp 80105599: 5b pop %ebx 8010559a: 5e pop %esi 8010559b: 5f pop %edi 8010559c: 5d pop %ebp 8010559d: c3 ret 8010559e: 66 90 xchg %ax,%ax isdirempty(struct inode *dp) { int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 801055a0: 83 7e 58 20 cmpl $0x20,0x58(%esi) 801055a4: 0f 86 78 ff ff ff jbe 80105522 <sys_unlink+0xc2> 801055aa: 8d 7d b2 lea -0x4e(%ebp),%edi 801055ad: bb 20 00 00 00 mov $0x20,%ebx 801055b2: eb 10 jmp 801055c4 <sys_unlink+0x164> 801055b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801055b8: 83 c3 10 add $0x10,%ebx 801055bb: 3b 5e 58 cmp 0x58(%esi),%ebx 801055be: 0f 83 5e ff ff ff jae 80105522 <sys_unlink+0xc2> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 801055c4: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 801055cb: 00 801055cc: 89 5c 24 08 mov %ebx,0x8(%esp) 801055d0: 89 7c 24 04 mov %edi,0x4(%esp) 801055d4: 89 34 24 mov %esi,(%esp) 801055d7: e8 94 c2 ff ff call 80101870 <readi> 801055dc: 83 f8 10 cmp $0x10,%eax 801055df: 75 44 jne 80105625 <sys_unlink+0x1c5> panic("isdirempty: readi"); if(de.inum != 0) 801055e1: 66 83 7d b2 00 cmpw $0x0,-0x4e(%ebp) 801055e6: 74 d0 je 801055b8 <sys_unlink+0x158> ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); if(ip->type == T_DIR && !isdirempty(ip)){ iunlockput(ip); 801055e8: 89 34 24 mov %esi,(%esp) 801055eb: e8 50 c6 ff ff call 80101c40 <iunlockput> end_op(); return 0; bad: iunlockput(dp); 801055f0: 8b 45 a4 mov -0x5c(%ebp),%eax 801055f3: 89 04 24 mov %eax,(%esp) 801055f6: e8 45 c6 ff ff call 80101c40 <iunlockput> end_op(); 801055fb: e8 80 d6 ff ff call 80102c80 <end_op> return -1; } 80105600: 83 c4 6c add $0x6c,%esp return 0; bad: iunlockput(dp); end_op(); 80105603: b8 ff ff ff ff mov $0xffffffff,%eax return -1; } 80105608: 5b pop %ebx 80105609: 5e pop %esi 8010560a: 5f pop %edi 8010560b: 5d pop %ebp 8010560c: c3 ret 8010560d: 8d 76 00 lea 0x0(%esi),%esi memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); if(ip->type == T_DIR){ dp->nlink--; 80105610: 8b 45 a4 mov -0x5c(%ebp),%eax 80105613: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80105618: 89 04 24 mov %eax,(%esp) 8010561b: e8 90 bc ff ff call 801012b0 <iupdate> 80105620: e9 4a ff ff ff jmp 8010556f <sys_unlink+0x10f> int off; struct dirent de; for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("isdirempty: readi"); 80105625: c7 04 24 7c 7a 10 80 movl $0x80107a7c,(%esp) 8010562c: e8 9f ad ff ff call 801003d0 <panic> goto bad; } memset(&de, 0, sizeof(de)); if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) panic("unlink: writei"); 80105631: c7 04 24 8e 7a 10 80 movl $0x80107a8e,(%esp) 80105638: e8 93 ad ff ff call 801003d0 <panic> if((ip = dirlookup(dp, name, &off)) == 0) goto bad; ilock(ip); if(ip->nlink < 1) panic("unlink: nlink < 1"); 8010563d: c7 04 24 6a 7a 10 80 movl $0x80107a6a,(%esp) 80105644: e8 87 ad ff ff call 801003d0 <panic> 80105649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105650 <argfd.clone.0>: #include "fcntl.h" // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) 80105650: 55 push %ebp 80105651: 89 e5 mov %esp,%ebp 80105653: 83 ec 28 sub $0x28,%esp 80105656: 89 5d f8 mov %ebx,-0x8(%ebp) 80105659: 89 c3 mov %eax,%ebx { int fd; struct file *f; if(argint(n, &fd) < 0) 8010565b: 8d 45 f4 lea -0xc(%ebp),%eax #include "fcntl.h" // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) 8010565e: 89 75 fc mov %esi,-0x4(%ebp) 80105661: 89 d6 mov %edx,%esi { int fd; struct file *f; if(argint(n, &fd) < 0) 80105663: 89 44 24 04 mov %eax,0x4(%esp) 80105667: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010566e: e8 0d f5 ff ff call 80104b80 <argint> 80105673: 85 c0 test %eax,%eax 80105675: 79 11 jns 80105688 <argfd.clone.0+0x38> if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0) return -1; if(pfd) *pfd = fd; if(pf) *pf = f; 80105677: b8 ff ff ff ff mov $0xffffffff,%eax return 0; } 8010567c: 8b 5d f8 mov -0x8(%ebp),%ebx 8010567f: 8b 75 fc mov -0x4(%ebp),%esi 80105682: 89 ec mov %ebp,%esp 80105684: 5d pop %ebp 80105685: c3 ret 80105686: 66 90 xchg %ax,%ax int fd; struct file *f; if(argint(n, &fd) < 0) return -1; if(fd < 0 || fd >= NOFILE || (f=proc->ofile[fd]) == 0) 80105688: 8b 45 f4 mov -0xc(%ebp),%eax 8010568b: 83 f8 0f cmp $0xf,%eax 8010568e: 77 e7 ja 80105677 <argfd.clone.0+0x27> 80105690: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx 80105697: 8b 54 82 28 mov 0x28(%edx,%eax,4),%edx 8010569b: 85 d2 test %edx,%edx 8010569d: 74 d8 je 80105677 <argfd.clone.0+0x27> return -1; if(pfd) 8010569f: 85 db test %ebx,%ebx 801056a1: 74 02 je 801056a5 <argfd.clone.0+0x55> *pfd = fd; 801056a3: 89 03 mov %eax,(%ebx) if(pf) 801056a5: 31 c0 xor %eax,%eax 801056a7: 85 f6 test %esi,%esi 801056a9: 74 d1 je 8010567c <argfd.clone.0+0x2c> *pf = f; 801056ab: 89 16 mov %edx,(%esi) 801056ad: eb cd jmp 8010567c <argfd.clone.0+0x2c> 801056af: 90 nop 801056b0 <sys_dup>: return -1; } int sys_dup(void) { 801056b0: 55 push %ebp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 801056b1: 31 c0 xor %eax,%eax return -1; } int sys_dup(void) { 801056b3: 89 e5 mov %esp,%ebp 801056b5: 53 push %ebx 801056b6: 83 ec 24 sub $0x24,%esp struct file *f; int fd; if(argfd(0, 0, &f) < 0) 801056b9: 8d 55 f4 lea -0xc(%ebp),%edx 801056bc: e8 8f ff ff ff call 80105650 <argfd.clone.0> 801056c1: 85 c0 test %eax,%eax 801056c3: 79 13 jns 801056d8 <sys_dup+0x28> static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 801056c5: bb ff ff ff ff mov $0xffffffff,%ebx return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); return fd; } 801056ca: 89 d8 mov %ebx,%eax 801056cc: 83 c4 24 add $0x24,%esp 801056cf: 5b pop %ebx 801056d0: 5d pop %ebp 801056d1: c3 ret 801056d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi struct file *f; int fd; if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) 801056d8: 8b 55 f4 mov -0xc(%ebp),%edx 801056db: 31 db xor %ebx,%ebx 801056dd: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801056e3: eb 0b jmp 801056f0 <sys_dup+0x40> 801056e5: 8d 76 00 lea 0x0(%esi),%esi static int fdalloc(struct file *f) { int fd; for(fd = 0; fd < NOFILE; fd++){ 801056e8: 83 c3 01 add $0x1,%ebx 801056eb: 83 fb 10 cmp $0x10,%ebx 801056ee: 74 d5 je 801056c5 <sys_dup+0x15> if(proc->ofile[fd] == 0){ 801056f0: 8b 4c 98 28 mov 0x28(%eax,%ebx,4),%ecx 801056f4: 85 c9 test %ecx,%ecx 801056f6: 75 f0 jne 801056e8 <sys_dup+0x38> proc->ofile[fd] = f; 801056f8: 89 54 98 28 mov %edx,0x28(%eax,%ebx,4) if(argfd(0, 0, &f) < 0) return -1; if((fd=fdalloc(f)) < 0) return -1; filedup(f); 801056fc: 8b 45 f4 mov -0xc(%ebp),%eax 801056ff: 89 04 24 mov %eax,(%esp) 80105702: e8 89 b8 ff ff call 80100f90 <filedup> return fd; 80105707: eb c1 jmp 801056ca <sys_dup+0x1a> 80105709: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105710 <sys_read>: } int sys_read(void) { 80105710: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105711: 31 c0 xor %eax,%eax return fd; } int sys_read(void) { 80105713: 89 e5 mov %esp,%ebp 80105715: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105718: 8d 55 f4 lea -0xc(%ebp),%edx 8010571b: e8 30 ff ff ff call 80105650 <argfd.clone.0> 80105720: 85 c0 test %eax,%eax 80105722: 79 0c jns 80105730 <sys_read+0x20> return -1; return fileread(f, p, n); 80105724: b8 ff ff ff ff mov $0xffffffff,%eax } 80105729: c9 leave 8010572a: c3 ret 8010572b: 90 nop 8010572c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105730: 8d 45 f0 lea -0x10(%ebp),%eax 80105733: 89 44 24 04 mov %eax,0x4(%esp) 80105737: c7 04 24 02 00 00 00 movl $0x2,(%esp) 8010573e: e8 3d f4 ff ff call 80104b80 <argint> 80105743: 85 c0 test %eax,%eax 80105745: 78 dd js 80105724 <sys_read+0x14> 80105747: 8b 45 f0 mov -0x10(%ebp),%eax 8010574a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105751: 89 44 24 08 mov %eax,0x8(%esp) 80105755: 8d 45 ec lea -0x14(%ebp),%eax 80105758: 89 44 24 04 mov %eax,0x4(%esp) 8010575c: e8 5f f4 ff ff call 80104bc0 <argptr> 80105761: 85 c0 test %eax,%eax 80105763: 78 bf js 80105724 <sys_read+0x14> return -1; return fileread(f, p, n); 80105765: 8b 45 f0 mov -0x10(%ebp),%eax 80105768: 89 44 24 08 mov %eax,0x8(%esp) 8010576c: 8b 45 ec mov -0x14(%ebp),%eax 8010576f: 89 44 24 04 mov %eax,0x4(%esp) 80105773: 8b 45 f4 mov -0xc(%ebp),%eax 80105776: 89 04 24 mov %eax,(%esp) 80105779: e8 02 b7 ff ff call 80100e80 <fileread> } 8010577e: c9 leave 8010577f: c3 ret 80105780 <sys_write>: int sys_write(void) { 80105780: 55 push %ebp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105781: 31 c0 xor %eax,%eax return fileread(f, p, n); } int sys_write(void) { 80105783: 89 e5 mov %esp,%ebp 80105785: 83 ec 28 sub $0x28,%esp struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80105788: 8d 55 f4 lea -0xc(%ebp),%edx 8010578b: e8 c0 fe ff ff call 80105650 <argfd.clone.0> 80105790: 85 c0 test %eax,%eax 80105792: 79 0c jns 801057a0 <sys_write+0x20> return -1; return filewrite(f, p, n); 80105794: b8 ff ff ff ff mov $0xffffffff,%eax } 80105799: c9 leave 8010579a: c3 ret 8010579b: 90 nop 8010579c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi { struct file *f; int n; char *p; if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801057a0: 8d 45 f0 lea -0x10(%ebp),%eax 801057a3: 89 44 24 04 mov %eax,0x4(%esp) 801057a7: c7 04 24 02 00 00 00 movl $0x2,(%esp) 801057ae: e8 cd f3 ff ff call 80104b80 <argint> 801057b3: 85 c0 test %eax,%eax 801057b5: 78 dd js 80105794 <sys_write+0x14> 801057b7: 8b 45 f0 mov -0x10(%ebp),%eax 801057ba: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801057c1: 89 44 24 08 mov %eax,0x8(%esp) 801057c5: 8d 45 ec lea -0x14(%ebp),%eax 801057c8: 89 44 24 04 mov %eax,0x4(%esp) 801057cc: e8 ef f3 ff ff call 80104bc0 <argptr> 801057d1: 85 c0 test %eax,%eax 801057d3: 78 bf js 80105794 <sys_write+0x14> return -1; return filewrite(f, p, n); 801057d5: 8b 45 f0 mov -0x10(%ebp),%eax 801057d8: 89 44 24 08 mov %eax,0x8(%esp) 801057dc: 8b 45 ec mov -0x14(%ebp),%eax 801057df: 89 44 24 04 mov %eax,0x4(%esp) 801057e3: 8b 45 f4 mov -0xc(%ebp),%eax 801057e6: 89 04 24 mov %eax,(%esp) 801057e9: e8 72 b5 ff ff call 80100d60 <filewrite> } 801057ee: c9 leave 801057ef: c3 ret 801057f0 <sys_fstat>: return 0; } int sys_fstat(void) { 801057f0: 55 push %ebp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 801057f1: 31 c0 xor %eax,%eax return 0; } int sys_fstat(void) { 801057f3: 89 e5 mov %esp,%ebp 801057f5: 83 ec 28 sub $0x28,%esp struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 801057f8: 8d 55 f4 lea -0xc(%ebp),%edx 801057fb: e8 50 fe ff ff call 80105650 <argfd.clone.0> 80105800: 85 c0 test %eax,%eax 80105802: 79 0c jns 80105810 <sys_fstat+0x20> return -1; return filestat(f, st); 80105804: b8 ff ff ff ff mov $0xffffffff,%eax } 80105809: c9 leave 8010580a: c3 ret 8010580b: 90 nop 8010580c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sys_fstat(void) { struct file *f; struct stat *st; if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80105810: 8d 45 f0 lea -0x10(%ebp),%eax 80105813: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 8010581a: 00 8010581b: 89 44 24 04 mov %eax,0x4(%esp) 8010581f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105826: e8 95 f3 ff ff call 80104bc0 <argptr> 8010582b: 85 c0 test %eax,%eax 8010582d: 78 d5 js 80105804 <sys_fstat+0x14> return -1; return filestat(f, st); 8010582f: 8b 45 f0 mov -0x10(%ebp),%eax 80105832: 89 44 24 04 mov %eax,0x4(%esp) 80105836: 8b 45 f4 mov -0xc(%ebp),%eax 80105839: 89 04 24 mov %eax,(%esp) 8010583c: e8 ff b6 ff ff call 80100f40 <filestat> } 80105841: c9 leave 80105842: c3 ret 80105843: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105849: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105850 <sys_close>: return filewrite(f, p, n); } int sys_close(void) { 80105850: 55 push %ebp 80105851: 89 e5 mov %esp,%ebp 80105853: 83 ec 28 sub $0x28,%esp int fd; struct file *f; if(argfd(0, &fd, &f) < 0) 80105856: 8d 55 f0 lea -0x10(%ebp),%edx 80105859: 8d 45 f4 lea -0xc(%ebp),%eax 8010585c: e8 ef fd ff ff call 80105650 <argfd.clone.0> 80105861: 89 c2 mov %eax,%edx 80105863: b8 ff ff ff ff mov $0xffffffff,%eax 80105868: 85 d2 test %edx,%edx 8010586a: 78 1e js 8010588a <sys_close+0x3a> return -1; proc->ofile[fd] = 0; 8010586c: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105872: 8b 55 f4 mov -0xc(%ebp),%edx 80105875: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 8010587c: 00 fileclose(f); 8010587d: 8b 45 f0 mov -0x10(%ebp),%eax 80105880: 89 04 24 mov %eax,(%esp) 80105883: e8 d8 b7 ff ff call 80101060 <fileclose> 80105888: 31 c0 xor %eax,%eax return 0; } 8010588a: c9 leave 8010588b: c3 ret 8010588c: 00 00 add %al,(%eax) ... 80105890 <sys_getpid>: return kill(pid); } int sys_getpid(void) { 80105890: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105896: 55 push %ebp 80105897: 89 e5 mov %esp,%ebp return proc->pid; } 80105899: 5d pop %ebp return kill(pid); } int sys_getpid(void) { 8010589a: 8b 40 10 mov 0x10(%eax),%eax return proc->pid; } 8010589d: c3 ret 8010589e: 66 90 xchg %ax,%ax 801058a0 <sys_set_tickets>: } //Our system call int sys_set_tickets(void) { 801058a0: 55 push %ebp 801058a1: 89 e5 mov %esp,%ebp 801058a3: 83 ec 28 sub $0x28,%esp int n; if(argint(0,&n)<0) 801058a6: 8d 45 f4 lea -0xc(%ebp),%eax 801058a9: 89 44 24 04 mov %eax,0x4(%esp) 801058ad: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801058b4: e8 c7 f2 ff ff call 80104b80 <argint> 801058b9: 89 c2 mov %eax,%edx 801058bb: b8 ff ff ff ff mov $0xffffffff,%eax 801058c0: 85 d2 test %edx,%edx 801058c2: 78 0b js 801058cf <sys_set_tickets+0x2f> return -1; //if(argint(1, &pid)<0) // return -1; return set_tickets(n); 801058c4: 8b 45 f4 mov -0xc(%ebp),%eax 801058c7: 89 04 24 mov %eax,(%esp) 801058ca: e8 61 de ff ff call 80103730 <set_tickets> } 801058cf: c9 leave 801058d0: c3 ret 801058d1: eb 0d jmp 801058e0 <sys_uptime> 801058d3: 90 nop 801058d4: 90 nop 801058d5: 90 nop 801058d6: 90 nop 801058d7: 90 nop 801058d8: 90 nop 801058d9: 90 nop 801058da: 90 nop 801058db: 90 nop 801058dc: 90 nop 801058dd: 90 nop 801058de: 90 nop 801058df: 90 nop 801058e0 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 801058e0: 55 push %ebp 801058e1: 89 e5 mov %esp,%ebp 801058e3: 53 push %ebx 801058e4: 83 ec 14 sub $0x14,%esp uint xticks; acquire(&tickslock); 801058e7: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 801058ee: e8 dd ee ff ff call 801047d0 <acquire> xticks = ticks; 801058f3: 8b 1d 20 58 11 80 mov 0x80115820,%ebx release(&tickslock); 801058f9: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 80105900: e8 7b ee ff ff call 80104780 <release> return xticks; } 80105905: 83 c4 14 add $0x14,%esp 80105908: 89 d8 mov %ebx,%eax 8010590a: 5b pop %ebx 8010590b: 5d pop %ebp 8010590c: c3 ret 8010590d: 8d 76 00 lea 0x0(%esi),%esi 80105910 <sys_sleep>: return addr; } int sys_sleep(void) { 80105910: 55 push %ebp 80105911: 89 e5 mov %esp,%ebp 80105913: 53 push %ebx 80105914: 83 ec 24 sub $0x24,%esp int n; uint ticks0; if(argint(0, &n) < 0) 80105917: 8d 45 f4 lea -0xc(%ebp),%eax 8010591a: 89 44 24 04 mov %eax,0x4(%esp) 8010591e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105925: e8 56 f2 ff ff call 80104b80 <argint> 8010592a: 89 c2 mov %eax,%edx 8010592c: b8 ff ff ff ff mov $0xffffffff,%eax 80105931: 85 d2 test %edx,%edx 80105933: 78 59 js 8010598e <sys_sleep+0x7e> return -1; acquire(&tickslock); 80105935: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 8010593c: e8 8f ee ff ff call 801047d0 <acquire> ticks0 = ticks; while(ticks - ticks0 < n){ 80105941: 8b 55 f4 mov -0xc(%ebp),%edx uint ticks0; if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; 80105944: 8b 1d 20 58 11 80 mov 0x80115820,%ebx while(ticks - ticks0 < n){ 8010594a: 85 d2 test %edx,%edx 8010594c: 75 22 jne 80105970 <sys_sleep+0x60> 8010594e: eb 48 jmp 80105998 <sys_sleep+0x88> if(proc->killed){ release(&tickslock); return -1; } sleep(&ticks, &tickslock); 80105950: c7 44 24 04 e0 4f 11 movl $0x80114fe0,0x4(%esp) 80105957: 80 80105958: c7 04 24 20 58 11 80 movl $0x80115820,(%esp) 8010595f: e8 1c e1 ff ff call 80103a80 <sleep> if(argint(0, &n) < 0) return -1; acquire(&tickslock); ticks0 = ticks; while(ticks - ticks0 < n){ 80105964: a1 20 58 11 80 mov 0x80115820,%eax 80105969: 29 d8 sub %ebx,%eax 8010596b: 3b 45 f4 cmp -0xc(%ebp),%eax 8010596e: 73 28 jae 80105998 <sys_sleep+0x88> if(proc->killed){ 80105970: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105976: 8b 40 24 mov 0x24(%eax),%eax 80105979: 85 c0 test %eax,%eax 8010597b: 74 d3 je 80105950 <sys_sleep+0x40> release(&tickslock); 8010597d: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 80105984: e8 f7 ed ff ff call 80104780 <release> 80105989: b8 ff ff ff ff mov $0xffffffff,%eax } sleep(&ticks, &tickslock); } release(&tickslock); return 0; } 8010598e: 83 c4 24 add $0x24,%esp 80105991: 5b pop %ebx 80105992: 5d pop %ebp 80105993: c3 ret 80105994: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 80105998: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 8010599f: e8 dc ed ff ff call 80104780 <release> return 0; } 801059a4: 83 c4 24 add $0x24,%esp release(&tickslock); return -1; } sleep(&ticks, &tickslock); } release(&tickslock); 801059a7: 31 c0 xor %eax,%eax return 0; } 801059a9: 5b pop %ebx 801059aa: 5d pop %ebp 801059ab: c3 ret 801059ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801059b0 <sys_sbrk>: return proc->pid; } int sys_sbrk(void) { 801059b0: 55 push %ebp 801059b1: 89 e5 mov %esp,%ebp 801059b3: 53 push %ebx 801059b4: 83 ec 24 sub $0x24,%esp int addr; int n; if(argint(0, &n) < 0) 801059b7: 8d 45 f4 lea -0xc(%ebp),%eax 801059ba: 89 44 24 04 mov %eax,0x4(%esp) 801059be: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801059c5: e8 b6 f1 ff ff call 80104b80 <argint> 801059ca: 85 c0 test %eax,%eax 801059cc: 79 12 jns 801059e0 <sys_sbrk+0x30> return -1; addr = proc->sz; if(growproc(n) < 0) return -1; return addr; 801059ce: b8 ff ff ff ff mov $0xffffffff,%eax } 801059d3: 83 c4 24 add $0x24,%esp 801059d6: 5b pop %ebx 801059d7: 5d pop %ebp 801059d8: c3 ret 801059d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi int addr; int n; if(argint(0, &n) < 0) return -1; addr = proc->sz; 801059e0: 65 a1 04 00 00 00 mov %gs:0x4,%eax 801059e6: 8b 18 mov (%eax),%ebx if(growproc(n) < 0) 801059e8: 8b 45 f4 mov -0xc(%ebp),%eax 801059eb: 89 04 24 mov %eax,(%esp) 801059ee: e8 9d e9 ff ff call 80104390 <growproc> 801059f3: 89 c2 mov %eax,%edx int addr; int n; if(argint(0, &n) < 0) return -1; addr = proc->sz; 801059f5: 89 d8 mov %ebx,%eax if(growproc(n) < 0) 801059f7: 85 d2 test %edx,%edx 801059f9: 79 d8 jns 801059d3 <sys_sbrk+0x23> 801059fb: eb d1 jmp 801059ce <sys_sbrk+0x1e> 801059fd: 8d 76 00 lea 0x0(%esi),%esi 80105a00 <sys_kill>: return wait(); } int sys_kill(void) { 80105a00: 55 push %ebp 80105a01: 89 e5 mov %esp,%ebp 80105a03: 83 ec 28 sub $0x28,%esp int pid; if(argint(0, &pid) < 0) 80105a06: 8d 45 f4 lea -0xc(%ebp),%eax 80105a09: 89 44 24 04 mov %eax,0x4(%esp) 80105a0d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105a14: e8 67 f1 ff ff call 80104b80 <argint> 80105a19: 89 c2 mov %eax,%edx 80105a1b: b8 ff ff ff ff mov $0xffffffff,%eax 80105a20: 85 d2 test %edx,%edx 80105a22: 78 0b js 80105a2f <sys_kill+0x2f> return -1; return kill(pid); 80105a24: 8b 45 f4 mov -0xc(%ebp),%eax 80105a27: 89 04 24 mov %eax,(%esp) 80105a2a: e8 61 de ff ff call 80103890 <kill> } 80105a2f: c9 leave 80105a30: c3 ret 80105a31: eb 0d jmp 80105a40 <sys_wait> 80105a33: 90 nop 80105a34: 90 nop 80105a35: 90 nop 80105a36: 90 nop 80105a37: 90 nop 80105a38: 90 nop 80105a39: 90 nop 80105a3a: 90 nop 80105a3b: 90 nop 80105a3c: 90 nop 80105a3d: 90 nop 80105a3e: 90 nop 80105a3f: 90 nop 80105a40 <sys_wait>: return 0; // not reached } int sys_wait(void) { 80105a40: 55 push %ebp 80105a41: 89 e5 mov %esp,%ebp 80105a43: 83 ec 08 sub $0x8,%esp return wait(); } 80105a46: c9 leave } int sys_wait(void) { return wait(); 80105a47: e9 c4 e4 ff ff jmp 80103f10 <wait> 80105a4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105a50 <sys_exit>: return fork(); } int sys_exit(void) { 80105a50: 55 push %ebp 80105a51: 89 e5 mov %esp,%ebp 80105a53: 83 ec 08 sub $0x8,%esp exit(); 80105a56: e8 a5 e5 ff ff call 80104000 <exit> return 0; // not reached } 80105a5b: 31 c0 xor %eax,%eax 80105a5d: c9 leave 80105a5e: c3 ret 80105a5f: 90 nop 80105a60 <sys_fork>: #include "mmu.h" #include "proc.h" int sys_fork(void) { 80105a60: 55 push %ebp 80105a61: 89 e5 mov %esp,%ebp 80105a63: 83 ec 08 sub $0x8,%esp return fork(); } 80105a66: c9 leave #include "proc.h" int sys_fork(void) { return fork(); 80105a67: e9 04 e8 ff ff jmp 80104270 <fork> 80105a6c: 00 00 add %al,(%eax) ... 80105a70 <timerinit>: #define TIMER_RATEGEN 0x04 // mode 2, rate generator #define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first void timerinit(void) { 80105a70: 55 push %ebp } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80105a71: ba 43 00 00 00 mov $0x43,%edx 80105a76: 89 e5 mov %esp,%ebp 80105a78: 83 ec 18 sub $0x18,%esp 80105a7b: b8 34 00 00 00 mov $0x34,%eax 80105a80: ee out %al,(%dx) 80105a81: b8 9c ff ff ff mov $0xffffff9c,%eax 80105a86: b2 40 mov $0x40,%dl 80105a88: ee out %al,(%dx) 80105a89: b8 2e 00 00 00 mov $0x2e,%eax 80105a8e: ee out %al,(%dx) // Interrupt 100 times/sec. outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); outb(IO_TIMER1, TIMER_DIV(100) % 256); outb(IO_TIMER1, TIMER_DIV(100) / 256); picenable(IRQ_TIMER); 80105a8f: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105a96: e8 25 d8 ff ff call 801032c0 <picenable> } 80105a9b: c9 leave 80105a9c: c3 ret 80105a9d: 00 00 add %al,(%eax) ... 80105aa0 <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 80105aa0: 1e push %ds pushl %es 80105aa1: 06 push %es pushl %fs 80105aa2: 0f a0 push %fs pushl %gs 80105aa4: 0f a8 push %gs pushal 80105aa6: 60 pusha # Set up data and per-cpu segments. movw $(SEG_KDATA<<3), %ax 80105aa7: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 80105aab: 8e d8 mov %eax,%ds movw %ax, %es 80105aad: 8e c0 mov %eax,%es movw $(SEG_KCPU<<3), %ax 80105aaf: 66 b8 18 00 mov $0x18,%ax movw %ax, %fs 80105ab3: 8e e0 mov %eax,%fs movw %ax, %gs 80105ab5: 8e e8 mov %eax,%gs # Call trap(tf), where tf=%esp pushl %esp 80105ab7: 54 push %esp call trap 80105ab8: e8 43 00 00 00 call 80105b00 <trap> addl $4, %esp 80105abd: 83 c4 04 add $0x4,%esp 80105ac0 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 80105ac0: 61 popa popl %gs 80105ac1: 0f a9 pop %gs popl %fs 80105ac3: 0f a1 pop %fs popl %es 80105ac5: 07 pop %es popl %ds 80105ac6: 1f pop %ds addl $0x8, %esp # trapno and errcode 80105ac7: 83 c4 08 add $0x8,%esp iret 80105aca: cf iret 80105acb: 00 00 add %al,(%eax) 80105acd: 00 00 add %al,(%eax) ... 80105ad0 <idtinit>: initlock(&tickslock, "time"); } void idtinit(void) { 80105ad0: 55 push %ebp lidt(struct gatedesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; pd[1] = (uint)p; 80105ad1: b8 20 50 11 80 mov $0x80115020,%eax 80105ad6: 89 e5 mov %esp,%ebp 80105ad8: 83 ec 10 sub $0x10,%esp static inline void lidt(struct gatedesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 80105adb: 66 c7 45 fa ff 07 movw $0x7ff,-0x6(%ebp) pd[1] = (uint)p; 80105ae1: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80105ae5: c1 e8 10 shr $0x10,%eax 80105ae8: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 80105aec: 8d 45 fa lea -0x6(%ebp),%eax 80105aef: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 80105af2: c9 leave 80105af3: c3 ret 80105af4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105afa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80105b00 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80105b00: 55 push %ebp 80105b01: 89 e5 mov %esp,%ebp 80105b03: 83 ec 38 sub $0x38,%esp 80105b06: 89 5d f4 mov %ebx,-0xc(%ebp) 80105b09: 8b 5d 08 mov 0x8(%ebp),%ebx 80105b0c: 89 75 f8 mov %esi,-0x8(%ebp) 80105b0f: 89 7d fc mov %edi,-0x4(%ebp) if(tf->trapno == T_SYSCALL){ 80105b12: 8b 43 30 mov 0x30(%ebx),%eax 80105b15: 83 f8 40 cmp $0x40,%eax 80105b18: 0f 84 d2 00 00 00 je 80105bf0 <trap+0xf0> if(proc->killed) exit(); return; } switch(tf->trapno){ 80105b1e: 83 e8 20 sub $0x20,%eax 80105b21: 83 f8 1f cmp $0x1f,%eax 80105b24: 0f 86 be 00 00 00 jbe 80105be8 <trap+0xe8> lapiceoi(); break; //PAGEBREAK: 13 default: if(proc == 0 || (tf->cs&3) == 0){ 80105b2a: 65 8b 0d 04 00 00 00 mov %gs:0x4,%ecx 80105b31: 85 c9 test %ecx,%ecx 80105b33: 0f 84 e7 01 00 00 je 80105d20 <trap+0x220> 80105b39: f6 43 3c 03 testb $0x3,0x3c(%ebx) 80105b3d: 0f 84 dd 01 00 00 je 80105d20 <trap+0x220> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 80105b43: 0f 20 d7 mov %cr2,%edi cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpunum(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105b46: 8b 73 38 mov 0x38(%ebx),%esi 80105b49: e8 d2 ce ff ff call 80102a20 <cpunum> "eip 0x%x addr 0x%x--kill proc\n", proc->pid, proc->name, tf->trapno, tf->err, cpunum(), tf->eip, 80105b4e: 65 8b 15 04 00 00 00 mov %gs:0x4,%edx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpunum(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105b55: 89 7c 24 1c mov %edi,0x1c(%esp) 80105b59: 89 74 24 18 mov %esi,0x18(%esp) 80105b5d: 89 44 24 14 mov %eax,0x14(%esp) 80105b61: 8b 43 34 mov 0x34(%ebx),%eax 80105b64: 89 44 24 10 mov %eax,0x10(%esp) 80105b68: 8b 43 30 mov 0x30(%ebx),%eax 80105b6b: 89 44 24 0c mov %eax,0xc(%esp) 80105b6f: 8d 42 6c lea 0x6c(%edx),%eax 80105b72: 89 44 24 08 mov %eax,0x8(%esp) 80105b76: 8b 42 10 mov 0x10(%edx),%eax 80105b79: c7 04 24 f8 7a 10 80 movl $0x80107af8,(%esp) 80105b80: 89 44 24 04 mov %eax,0x4(%esp) 80105b84: e8 e7 ac ff ff call 80100870 <cprintf> "eip 0x%x addr 0x%x--kill proc\n", proc->pid, proc->name, tf->trapno, tf->err, cpunum(), tf->eip, rcr2()); proc->killed = 1; 80105b89: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105b8f: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 80105b96: 66 90 xchg %ax,%ax } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(proc && proc->killed && (tf->cs&3) == DPL_USER) 80105b98: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105b9e: 85 c0 test %eax,%eax 80105ba0: 74 34 je 80105bd6 <trap+0xd6> 80105ba2: 8b 50 24 mov 0x24(%eax),%edx 80105ba5: 85 d2 test %edx,%edx 80105ba7: 74 10 je 80105bb9 <trap+0xb9> 80105ba9: 0f b7 53 3c movzwl 0x3c(%ebx),%edx 80105bad: 83 e2 03 and $0x3,%edx 80105bb0: 83 fa 03 cmp $0x3,%edx 80105bb3: 0f 84 4f 01 00 00 je 80105d08 <trap+0x208> exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) 80105bb9: 83 78 0c 04 cmpl $0x4,0xc(%eax) 80105bbd: 0f 84 1d 01 00 00 je 80105ce0 <trap+0x1e0> yield(); // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) 80105bc3: 8b 40 24 mov 0x24(%eax),%eax 80105bc6: 85 c0 test %eax,%eax 80105bc8: 74 0c je 80105bd6 <trap+0xd6> 80105bca: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 80105bce: 83 e0 03 and $0x3,%eax 80105bd1: 83 f8 03 cmp $0x3,%eax 80105bd4: 74 3c je 80105c12 <trap+0x112> exit(); } 80105bd6: 8b 5d f4 mov -0xc(%ebp),%ebx 80105bd9: 8b 75 f8 mov -0x8(%ebp),%esi 80105bdc: 8b 7d fc mov -0x4(%ebp),%edi 80105bdf: 89 ec mov %ebp,%esp 80105be1: 5d pop %ebp 80105be2: c3 ret 80105be3: 90 nop 80105be4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(proc->killed) exit(); return; } switch(tf->trapno){ 80105be8: ff 24 85 48 7b 10 80 jmp *-0x7fef84b8(,%eax,4) 80105bef: 90 nop //PAGEBREAK: 41 void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(proc->killed) 80105bf0: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105bf6: 8b 70 24 mov 0x24(%eax),%esi 80105bf9: 85 f6 test %esi,%esi 80105bfb: 75 2b jne 80105c28 <trap+0x128> exit(); proc->tf = tf; 80105bfd: 89 58 18 mov %ebx,0x18(%eax) syscall(); 80105c00: e8 8b f0 ff ff call 80104c90 <syscall> if(proc->killed) 80105c05: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105c0b: 8b 58 24 mov 0x24(%eax),%ebx 80105c0e: 85 db test %ebx,%ebx 80105c10: 74 c4 je 80105bd6 <trap+0xd6> yield(); // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); } 80105c12: 8b 5d f4 mov -0xc(%ebp),%ebx 80105c15: 8b 75 f8 mov -0x8(%ebp),%esi 80105c18: 8b 7d fc mov -0x4(%ebp),%edi 80105c1b: 89 ec mov %ebp,%esp 80105c1d: 5d pop %ebp if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); 80105c1e: e9 dd e3 ff ff jmp 80104000 <exit> 80105c23: 90 nop 80105c24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi void trap(struct trapframe *tf) { if(tf->trapno == T_SYSCALL){ if(proc->killed) exit(); 80105c28: e8 d3 e3 ff ff call 80104000 <exit> 80105c2d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105c33: eb c8 jmp 80105bfd <trap+0xfd> 80105c35: 8d 76 00 lea 0x0(%esi),%esi release(&tickslock); } lapiceoi(); break; case T_IRQ0 + IRQ_IDE: ideintr(); 80105c38: e8 e3 c4 ff ff call 80102120 <ideintr> lapiceoi(); 80105c3d: e8 0e cb ff ff call 80102750 <lapiceoi> break; 80105c42: e9 51 ff ff ff jmp 80105b98 <trap+0x98> 80105c47: 90 nop uartintr(); lapiceoi(); break; case T_IRQ0 + 7: case T_IRQ0 + IRQ_SPURIOUS: cprintf("cpu%d: spurious interrupt at %x:%x\n", 80105c48: 8b 7b 38 mov 0x38(%ebx),%edi 80105c4b: 0f b7 73 3c movzwl 0x3c(%ebx),%esi 80105c4f: e8 cc cd ff ff call 80102a20 <cpunum> 80105c54: c7 04 24 a0 7a 10 80 movl $0x80107aa0,(%esp) 80105c5b: 89 7c 24 0c mov %edi,0xc(%esp) 80105c5f: 89 74 24 08 mov %esi,0x8(%esp) 80105c63: 89 44 24 04 mov %eax,0x4(%esp) 80105c67: e8 04 ac ff ff call 80100870 <cprintf> cpunum(), tf->cs, tf->eip); lapiceoi(); 80105c6c: e8 df ca ff ff call 80102750 <lapiceoi> break; 80105c71: e9 22 ff ff ff jmp 80105b98 <trap+0x98> 80105c76: 66 90 xchg %ax,%ax 80105c78: 90 nop 80105c79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi case T_IRQ0 + IRQ_KBD: kbdintr(); lapiceoi(); break; case T_IRQ0 + IRQ_COM1: uartintr(); 80105c80: e8 9b 01 00 00 call 80105e20 <uartintr> lapiceoi(); 80105c85: e8 c6 ca ff ff call 80102750 <lapiceoi> break; 80105c8a: e9 09 ff ff ff jmp 80105b98 <trap+0x98> 80105c8f: 90 nop break; case T_IRQ0 + IRQ_IDE+1: // Bochs generates spurious IDE1 interrupts. break; case T_IRQ0 + IRQ_KBD: kbdintr(); 80105c90: e8 5b c9 ff ff call 801025f0 <kbdintr> lapiceoi(); 80105c95: e8 b6 ca ff ff call 80102750 <lapiceoi> break; 80105c9a: e9 f9 fe ff ff jmp 80105b98 <trap+0x98> 80105c9f: 90 nop return; } switch(tf->trapno){ case T_IRQ0 + IRQ_TIMER: if(cpunum() == 0){ 80105ca0: e8 7b cd ff ff call 80102a20 <cpunum> 80105ca5: 85 c0 test %eax,%eax 80105ca7: 75 94 jne 80105c3d <trap+0x13d> acquire(&tickslock); 80105ca9: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 80105cb0: e8 1b eb ff ff call 801047d0 <acquire> ticks++; 80105cb5: 83 05 20 58 11 80 01 addl $0x1,0x80115820 wakeup(&ticks); 80105cbc: c7 04 24 20 58 11 80 movl $0x80115820,(%esp) 80105cc3: e8 58 dc ff ff call 80103920 <wakeup> release(&tickslock); 80105cc8: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) 80105ccf: e8 ac ea ff ff call 80104780 <release> 80105cd4: e9 64 ff ff ff jmp 80105c3d <trap+0x13d> 80105cd9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) 80105ce0: 83 7b 30 20 cmpl $0x20,0x30(%ebx) 80105ce4: 0f 85 d9 fe ff ff jne 80105bc3 <trap+0xc3> 80105cea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi yield(); 80105cf0: e8 5b de ff ff call 80103b50 <yield> // Check if the process has been killed since we yielded if(proc && proc->killed && (tf->cs&3) == DPL_USER) 80105cf5: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105cfb: 85 c0 test %eax,%eax 80105cfd: 0f 85 c0 fe ff ff jne 80105bc3 <trap+0xc3> 80105d03: e9 ce fe ff ff jmp 80105bd6 <trap+0xd6> // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(proc && proc->killed && (tf->cs&3) == DPL_USER) exit(); 80105d08: e8 f3 e2 ff ff call 80104000 <exit> // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(proc && proc->state == RUNNING && tf->trapno == T_IRQ0+IRQ_TIMER) 80105d0d: 65 a1 04 00 00 00 mov %gs:0x4,%eax 80105d13: 85 c0 test %eax,%eax 80105d15: 0f 85 9e fe ff ff jne 80105bb9 <trap+0xb9> 80105d1b: e9 b6 fe ff ff jmp 80105bd6 <trap+0xd6> 80105d20: 0f 20 d7 mov %cr2,%edi //PAGEBREAK: 13 default: if(proc == 0 || (tf->cs&3) == 0){ // In kernel, it must be our mistake. cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80105d23: 8b 73 38 mov 0x38(%ebx),%esi 80105d26: e8 f5 cc ff ff call 80102a20 <cpunum> 80105d2b: 89 7c 24 10 mov %edi,0x10(%esp) 80105d2f: 89 74 24 0c mov %esi,0xc(%esp) 80105d33: 89 44 24 08 mov %eax,0x8(%esp) 80105d37: 8b 43 30 mov 0x30(%ebx),%eax 80105d3a: c7 04 24 c4 7a 10 80 movl $0x80107ac4,(%esp) 80105d41: 89 44 24 04 mov %eax,0x4(%esp) 80105d45: e8 26 ab ff ff call 80100870 <cprintf> tf->trapno, cpunum(), tf->eip, rcr2()); panic("trap"); 80105d4a: c7 04 24 3b 7b 10 80 movl $0x80107b3b,(%esp) 80105d51: e8 7a a6 ff ff call 801003d0 <panic> 80105d56: 8d 76 00 lea 0x0(%esi),%esi 80105d59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105d60 <tvinit>: struct spinlock tickslock; uint ticks; void tvinit(void) { 80105d60: 55 push %ebp 80105d61: 31 c0 xor %eax,%eax 80105d63: 89 e5 mov %esp,%ebp 80105d65: ba 20 50 11 80 mov $0x80115020,%edx 80105d6a: 83 ec 18 sub $0x18,%esp 80105d6d: 8d 76 00 lea 0x0(%esi),%esi int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 80105d70: 8b 0c 85 0c a0 10 80 mov -0x7fef5ff4(,%eax,4),%ecx 80105d77: 66 89 0c c5 20 50 11 mov %cx,-0x7feeafe0(,%eax,8) 80105d7e: 80 80105d7f: c1 e9 10 shr $0x10,%ecx 80105d82: 66 c7 44 c2 02 08 00 movw $0x8,0x2(%edx,%eax,8) 80105d89: c6 44 c2 04 00 movb $0x0,0x4(%edx,%eax,8) 80105d8e: c6 44 c2 05 8e movb $0x8e,0x5(%edx,%eax,8) 80105d93: 66 89 4c c2 06 mov %cx,0x6(%edx,%eax,8) void tvinit(void) { int i; for(i = 0; i < 256; i++) 80105d98: 83 c0 01 add $0x1,%eax 80105d9b: 3d 00 01 00 00 cmp $0x100,%eax 80105da0: 75 ce jne 80105d70 <tvinit+0x10> SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 80105da2: a1 0c a1 10 80 mov 0x8010a10c,%eax initlock(&tickslock, "time"); 80105da7: c7 44 24 04 40 7b 10 movl $0x80107b40,0x4(%esp) 80105dae: 80 80105daf: c7 04 24 e0 4f 11 80 movl $0x80114fe0,(%esp) { int i; for(i = 0; i < 256; i++) SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 80105db6: 66 c7 05 22 52 11 80 movw $0x8,0x80115222 80105dbd: 08 00 80105dbf: 66 a3 20 52 11 80 mov %ax,0x80115220 80105dc5: c1 e8 10 shr $0x10,%eax 80105dc8: c6 05 24 52 11 80 00 movb $0x0,0x80115224 80105dcf: c6 05 25 52 11 80 ef movb $0xef,0x80115225 80105dd6: 66 a3 26 52 11 80 mov %ax,0x80115226 initlock(&tickslock, "time"); 80105ddc: e8 5f e8 ff ff call 80104640 <initlock> } 80105de1: c9 leave 80105de2: c3 ret ... 80105df0 <uartgetc>: } static int uartgetc(void) { if(!uart) 80105df0: a1 cc a5 10 80 mov 0x8010a5cc,%eax outb(COM1+0, c); } static int uartgetc(void) { 80105df5: 55 push %ebp 80105df6: 89 e5 mov %esp,%ebp if(!uart) 80105df8: 85 c0 test %eax,%eax 80105dfa: 75 0c jne 80105e08 <uartgetc+0x18> return -1; if(!(inb(COM1+5) & 0x01)) return -1; return inb(COM1+0); 80105dfc: b8 ff ff ff ff mov $0xffffffff,%eax } 80105e01: 5d pop %ebp 80105e02: c3 ret 80105e03: 90 nop 80105e04: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105e08: ba fd 03 00 00 mov $0x3fd,%edx 80105e0d: ec in (%dx),%al static int uartgetc(void) { if(!uart) return -1; if(!(inb(COM1+5) & 0x01)) 80105e0e: a8 01 test $0x1,%al 80105e10: 74 ea je 80105dfc <uartgetc+0xc> 80105e12: b2 f8 mov $0xf8,%dl 80105e14: ec in (%dx),%al return -1; return inb(COM1+0); 80105e15: 0f b6 c0 movzbl %al,%eax } 80105e18: 5d pop %ebp 80105e19: c3 ret 80105e1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105e20 <uartintr>: void uartintr(void) { 80105e20: 55 push %ebp 80105e21: 89 e5 mov %esp,%ebp 80105e23: 83 ec 18 sub $0x18,%esp consoleintr(uartgetc); 80105e26: c7 04 24 f0 5d 10 80 movl $0x80105df0,(%esp) 80105e2d: e8 0e a8 ff ff call 80100640 <consoleintr> } 80105e32: c9 leave 80105e33: c3 ret 80105e34: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105e3a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80105e40 <uartputc>: uartputc(*p); } void uartputc(int c) { 80105e40: 55 push %ebp 80105e41: 89 e5 mov %esp,%ebp 80105e43: 56 push %esi 80105e44: be fd 03 00 00 mov $0x3fd,%esi 80105e49: 53 push %ebx int i; if(!uart) 80105e4a: 31 db xor %ebx,%ebx uartputc(*p); } void uartputc(int c) { 80105e4c: 83 ec 10 sub $0x10,%esp int i; if(!uart) 80105e4f: 8b 15 cc a5 10 80 mov 0x8010a5cc,%edx 80105e55: 85 d2 test %edx,%edx 80105e57: 75 1e jne 80105e77 <uartputc+0x37> 80105e59: eb 2c jmp 80105e87 <uartputc+0x47> 80105e5b: 90 nop 80105e5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80105e60: 83 c3 01 add $0x1,%ebx microdelay(10); 80105e63: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80105e6a: e8 01 c9 ff ff call 80102770 <microdelay> { int i; if(!uart) return; for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 80105e6f: 81 fb 80 00 00 00 cmp $0x80,%ebx 80105e75: 74 07 je 80105e7e <uartputc+0x3e> 80105e77: 89 f2 mov %esi,%edx 80105e79: ec in (%dx),%al 80105e7a: a8 20 test $0x20,%al 80105e7c: 74 e2 je 80105e60 <uartputc+0x20> } static inline void outb(ushort port, uchar data) { asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80105e7e: ba f8 03 00 00 mov $0x3f8,%edx 80105e83: 8b 45 08 mov 0x8(%ebp),%eax 80105e86: ee out %al,(%dx) microdelay(10); outb(COM1+0, c); } 80105e87: 83 c4 10 add $0x10,%esp 80105e8a: 5b pop %ebx 80105e8b: 5e pop %esi 80105e8c: 5d pop %ebp 80105e8d: c3 ret 80105e8e: 66 90 xchg %ax,%ax 80105e90 <uartinit>: static int uart; // is there a uart? void uartinit(void) { 80105e90: 55 push %ebp 80105e91: 31 c9 xor %ecx,%ecx 80105e93: 89 e5 mov %esp,%ebp 80105e95: 89 c8 mov %ecx,%eax 80105e97: 57 push %edi 80105e98: bf fa 03 00 00 mov $0x3fa,%edi 80105e9d: 56 push %esi 80105e9e: 89 fa mov %edi,%edx 80105ea0: 53 push %ebx 80105ea1: 83 ec 1c sub $0x1c,%esp 80105ea4: ee out %al,(%dx) 80105ea5: bb fb 03 00 00 mov $0x3fb,%ebx 80105eaa: b8 80 ff ff ff mov $0xffffff80,%eax 80105eaf: 89 da mov %ebx,%edx 80105eb1: ee out %al,(%dx) 80105eb2: b8 0c 00 00 00 mov $0xc,%eax 80105eb7: b2 f8 mov $0xf8,%dl 80105eb9: ee out %al,(%dx) 80105eba: be f9 03 00 00 mov $0x3f9,%esi 80105ebf: 89 c8 mov %ecx,%eax 80105ec1: 89 f2 mov %esi,%edx 80105ec3: ee out %al,(%dx) 80105ec4: b8 03 00 00 00 mov $0x3,%eax 80105ec9: 89 da mov %ebx,%edx 80105ecb: ee out %al,(%dx) 80105ecc: b2 fc mov $0xfc,%dl 80105ece: 89 c8 mov %ecx,%eax 80105ed0: ee out %al,(%dx) 80105ed1: b8 01 00 00 00 mov $0x1,%eax 80105ed6: 89 f2 mov %esi,%edx 80105ed8: ee out %al,(%dx) static inline uchar inb(ushort port) { uchar data; asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105ed9: b2 fd mov $0xfd,%dl 80105edb: ec in (%dx),%al outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) 80105edc: 3c ff cmp $0xff,%al 80105ede: 74 55 je 80105f35 <uartinit+0xa5> return; uart = 1; 80105ee0: c7 05 cc a5 10 80 01 movl $0x1,0x8010a5cc 80105ee7: 00 00 00 80105eea: 89 fa mov %edi,%edx 80105eec: ec in (%dx),%al 80105eed: b2 f8 mov $0xf8,%dl 80105eef: ec in (%dx),%al // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); 80105ef0: bb c8 7b 10 80 mov $0x80107bc8,%ebx // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); 80105ef5: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80105efc: e8 bf d3 ff ff call 801032c0 <picenable> ioapicenable(IRQ_COM1, 0); 80105f01: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105f08: 00 80105f09: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80105f10: e8 3b c3 ff ff call 80102250 <ioapicenable> 80105f15: b8 78 00 00 00 mov $0x78,%eax 80105f1a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi // Announce that we're here. for(p="xv6...\n"; *p; p++) uartputc(*p); 80105f20: 0f be c0 movsbl %al,%eax inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105f23: 83 c3 01 add $0x1,%ebx uartputc(*p); 80105f26: 89 04 24 mov %eax,(%esp) 80105f29: e8 12 ff ff ff call 80105e40 <uartputc> inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) 80105f2e: 0f b6 03 movzbl (%ebx),%eax 80105f31: 84 c0 test %al,%al 80105f33: 75 eb jne 80105f20 <uartinit+0x90> uartputc(*p); } 80105f35: 83 c4 1c add $0x1c,%esp 80105f38: 5b pop %ebx 80105f39: 5e pop %esi 80105f3a: 5f pop %edi 80105f3b: 5d pop %ebp 80105f3c: c3 ret 80105f3d: 00 00 add %al,(%eax) ... 80105f40 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80105f40: 6a 00 push $0x0 pushl $0 80105f42: 6a 00 push $0x0 jmp alltraps 80105f44: e9 57 fb ff ff jmp 80105aa0 <alltraps> 80105f49 <vector1>: .globl vector1 vector1: pushl $0 80105f49: 6a 00 push $0x0 pushl $1 80105f4b: 6a 01 push $0x1 jmp alltraps 80105f4d: e9 4e fb ff ff jmp 80105aa0 <alltraps> 80105f52 <vector2>: .globl vector2 vector2: pushl $0 80105f52: 6a 00 push $0x0 pushl $2 80105f54: 6a 02 push $0x2 jmp alltraps 80105f56: e9 45 fb ff ff jmp 80105aa0 <alltraps> 80105f5b <vector3>: .globl vector3 vector3: pushl $0 80105f5b: 6a 00 push $0x0 pushl $3 80105f5d: 6a 03 push $0x3 jmp alltraps 80105f5f: e9 3c fb ff ff jmp 80105aa0 <alltraps> 80105f64 <vector4>: .globl vector4 vector4: pushl $0 80105f64: 6a 00 push $0x0 pushl $4 80105f66: 6a 04 push $0x4 jmp alltraps 80105f68: e9 33 fb ff ff jmp 80105aa0 <alltraps> 80105f6d <vector5>: .globl vector5 vector5: pushl $0 80105f6d: 6a 00 push $0x0 pushl $5 80105f6f: 6a 05 push $0x5 jmp alltraps 80105f71: e9 2a fb ff ff jmp 80105aa0 <alltraps> 80105f76 <vector6>: .globl vector6 vector6: pushl $0 80105f76: 6a 00 push $0x0 pushl $6 80105f78: 6a 06 push $0x6 jmp alltraps 80105f7a: e9 21 fb ff ff jmp 80105aa0 <alltraps> 80105f7f <vector7>: .globl vector7 vector7: pushl $0 80105f7f: 6a 00 push $0x0 pushl $7 80105f81: 6a 07 push $0x7 jmp alltraps 80105f83: e9 18 fb ff ff jmp 80105aa0 <alltraps> 80105f88 <vector8>: .globl vector8 vector8: pushl $8 80105f88: 6a 08 push $0x8 jmp alltraps 80105f8a: e9 11 fb ff ff jmp 80105aa0 <alltraps> 80105f8f <vector9>: .globl vector9 vector9: pushl $0 80105f8f: 6a 00 push $0x0 pushl $9 80105f91: 6a 09 push $0x9 jmp alltraps 80105f93: e9 08 fb ff ff jmp 80105aa0 <alltraps> 80105f98 <vector10>: .globl vector10 vector10: pushl $10 80105f98: 6a 0a push $0xa jmp alltraps 80105f9a: e9 01 fb ff ff jmp 80105aa0 <alltraps> 80105f9f <vector11>: .globl vector11 vector11: pushl $11 80105f9f: 6a 0b push $0xb jmp alltraps 80105fa1: e9 fa fa ff ff jmp 80105aa0 <alltraps> 80105fa6 <vector12>: .globl vector12 vector12: pushl $12 80105fa6: 6a 0c push $0xc jmp alltraps 80105fa8: e9 f3 fa ff ff jmp 80105aa0 <alltraps> 80105fad <vector13>: .globl vector13 vector13: pushl $13 80105fad: 6a 0d push $0xd jmp alltraps 80105faf: e9 ec fa ff ff jmp 80105aa0 <alltraps> 80105fb4 <vector14>: .globl vector14 vector14: pushl $14 80105fb4: 6a 0e push $0xe jmp alltraps 80105fb6: e9 e5 fa ff ff jmp 80105aa0 <alltraps> 80105fbb <vector15>: .globl vector15 vector15: pushl $0 80105fbb: 6a 00 push $0x0 pushl $15 80105fbd: 6a 0f push $0xf jmp alltraps 80105fbf: e9 dc fa ff ff jmp 80105aa0 <alltraps> 80105fc4 <vector16>: .globl vector16 vector16: pushl $0 80105fc4: 6a 00 push $0x0 pushl $16 80105fc6: 6a 10 push $0x10 jmp alltraps 80105fc8: e9 d3 fa ff ff jmp 80105aa0 <alltraps> 80105fcd <vector17>: .globl vector17 vector17: pushl $17 80105fcd: 6a 11 push $0x11 jmp alltraps 80105fcf: e9 cc fa ff ff jmp 80105aa0 <alltraps> 80105fd4 <vector18>: .globl vector18 vector18: pushl $0 80105fd4: 6a 00 push $0x0 pushl $18 80105fd6: 6a 12 push $0x12 jmp alltraps 80105fd8: e9 c3 fa ff ff jmp 80105aa0 <alltraps> 80105fdd <vector19>: .globl vector19 vector19: pushl $0 80105fdd: 6a 00 push $0x0 pushl $19 80105fdf: 6a 13 push $0x13 jmp alltraps 80105fe1: e9 ba fa ff ff jmp 80105aa0 <alltraps> 80105fe6 <vector20>: .globl vector20 vector20: pushl $0 80105fe6: 6a 00 push $0x0 pushl $20 80105fe8: 6a 14 push $0x14 jmp alltraps 80105fea: e9 b1 fa ff ff jmp 80105aa0 <alltraps> 80105fef <vector21>: .globl vector21 vector21: pushl $0 80105fef: 6a 00 push $0x0 pushl $21 80105ff1: 6a 15 push $0x15 jmp alltraps 80105ff3: e9 a8 fa ff ff jmp 80105aa0 <alltraps> 80105ff8 <vector22>: .globl vector22 vector22: pushl $0 80105ff8: 6a 00 push $0x0 pushl $22 80105ffa: 6a 16 push $0x16 jmp alltraps 80105ffc: e9 9f fa ff ff jmp 80105aa0 <alltraps> 80106001 <vector23>: .globl vector23 vector23: pushl $0 80106001: 6a 00 push $0x0 pushl $23 80106003: 6a 17 push $0x17 jmp alltraps 80106005: e9 96 fa ff ff jmp 80105aa0 <alltraps> 8010600a <vector24>: .globl vector24 vector24: pushl $0 8010600a: 6a 00 push $0x0 pushl $24 8010600c: 6a 18 push $0x18 jmp alltraps 8010600e: e9 8d fa ff ff jmp 80105aa0 <alltraps> 80106013 <vector25>: .globl vector25 vector25: pushl $0 80106013: 6a 00 push $0x0 pushl $25 80106015: 6a 19 push $0x19 jmp alltraps 80106017: e9 84 fa ff ff jmp 80105aa0 <alltraps> 8010601c <vector26>: .globl vector26 vector26: pushl $0 8010601c: 6a 00 push $0x0 pushl $26 8010601e: 6a 1a push $0x1a jmp alltraps 80106020: e9 7b fa ff ff jmp 80105aa0 <alltraps> 80106025 <vector27>: .globl vector27 vector27: pushl $0 80106025: 6a 00 push $0x0 pushl $27 80106027: 6a 1b push $0x1b jmp alltraps 80106029: e9 72 fa ff ff jmp 80105aa0 <alltraps> 8010602e <vector28>: .globl vector28 vector28: pushl $0 8010602e: 6a 00 push $0x0 pushl $28 80106030: 6a 1c push $0x1c jmp alltraps 80106032: e9 69 fa ff ff jmp 80105aa0 <alltraps> 80106037 <vector29>: .globl vector29 vector29: pushl $0 80106037: 6a 00 push $0x0 pushl $29 80106039: 6a 1d push $0x1d jmp alltraps 8010603b: e9 60 fa ff ff jmp 80105aa0 <alltraps> 80106040 <vector30>: .globl vector30 vector30: pushl $0 80106040: 6a 00 push $0x0 pushl $30 80106042: 6a 1e push $0x1e jmp alltraps 80106044: e9 57 fa ff ff jmp 80105aa0 <alltraps> 80106049 <vector31>: .globl vector31 vector31: pushl $0 80106049: 6a 00 push $0x0 pushl $31 8010604b: 6a 1f push $0x1f jmp alltraps 8010604d: e9 4e fa ff ff jmp 80105aa0 <alltraps> 80106052 <vector32>: .globl vector32 vector32: pushl $0 80106052: 6a 00 push $0x0 pushl $32 80106054: 6a 20 push $0x20 jmp alltraps 80106056: e9 45 fa ff ff jmp 80105aa0 <alltraps> 8010605b <vector33>: .globl vector33 vector33: pushl $0 8010605b: 6a 00 push $0x0 pushl $33 8010605d: 6a 21 push $0x21 jmp alltraps 8010605f: e9 3c fa ff ff jmp 80105aa0 <alltraps> 80106064 <vector34>: .globl vector34 vector34: pushl $0 80106064: 6a 00 push $0x0 pushl $34 80106066: 6a 22 push $0x22 jmp alltraps 80106068: e9 33 fa ff ff jmp 80105aa0 <alltraps> 8010606d <vector35>: .globl vector35 vector35: pushl $0 8010606d: 6a 00 push $0x0 pushl $35 8010606f: 6a 23 push $0x23 jmp alltraps 80106071: e9 2a fa ff ff jmp 80105aa0 <alltraps> 80106076 <vector36>: .globl vector36 vector36: pushl $0 80106076: 6a 00 push $0x0 pushl $36 80106078: 6a 24 push $0x24 jmp alltraps 8010607a: e9 21 fa ff ff jmp 80105aa0 <alltraps> 8010607f <vector37>: .globl vector37 vector37: pushl $0 8010607f: 6a 00 push $0x0 pushl $37 80106081: 6a 25 push $0x25 jmp alltraps 80106083: e9 18 fa ff ff jmp 80105aa0 <alltraps> 80106088 <vector38>: .globl vector38 vector38: pushl $0 80106088: 6a 00 push $0x0 pushl $38 8010608a: 6a 26 push $0x26 jmp alltraps 8010608c: e9 0f fa ff ff jmp 80105aa0 <alltraps> 80106091 <vector39>: .globl vector39 vector39: pushl $0 80106091: 6a 00 push $0x0 pushl $39 80106093: 6a 27 push $0x27 jmp alltraps 80106095: e9 06 fa ff ff jmp 80105aa0 <alltraps> 8010609a <vector40>: .globl vector40 vector40: pushl $0 8010609a: 6a 00 push $0x0 pushl $40 8010609c: 6a 28 push $0x28 jmp alltraps 8010609e: e9 fd f9 ff ff jmp 80105aa0 <alltraps> 801060a3 <vector41>: .globl vector41 vector41: pushl $0 801060a3: 6a 00 push $0x0 pushl $41 801060a5: 6a 29 push $0x29 jmp alltraps 801060a7: e9 f4 f9 ff ff jmp 80105aa0 <alltraps> 801060ac <vector42>: .globl vector42 vector42: pushl $0 801060ac: 6a 00 push $0x0 pushl $42 801060ae: 6a 2a push $0x2a jmp alltraps 801060b0: e9 eb f9 ff ff jmp 80105aa0 <alltraps> 801060b5 <vector43>: .globl vector43 vector43: pushl $0 801060b5: 6a 00 push $0x0 pushl $43 801060b7: 6a 2b push $0x2b jmp alltraps 801060b9: e9 e2 f9 ff ff jmp 80105aa0 <alltraps> 801060be <vector44>: .globl vector44 vector44: pushl $0 801060be: 6a 00 push $0x0 pushl $44 801060c0: 6a 2c push $0x2c jmp alltraps 801060c2: e9 d9 f9 ff ff jmp 80105aa0 <alltraps> 801060c7 <vector45>: .globl vector45 vector45: pushl $0 801060c7: 6a 00 push $0x0 pushl $45 801060c9: 6a 2d push $0x2d jmp alltraps 801060cb: e9 d0 f9 ff ff jmp 80105aa0 <alltraps> 801060d0 <vector46>: .globl vector46 vector46: pushl $0 801060d0: 6a 00 push $0x0 pushl $46 801060d2: 6a 2e push $0x2e jmp alltraps 801060d4: e9 c7 f9 ff ff jmp 80105aa0 <alltraps> 801060d9 <vector47>: .globl vector47 vector47: pushl $0 801060d9: 6a 00 push $0x0 pushl $47 801060db: 6a 2f push $0x2f jmp alltraps 801060dd: e9 be f9 ff ff jmp 80105aa0 <alltraps> 801060e2 <vector48>: .globl vector48 vector48: pushl $0 801060e2: 6a 00 push $0x0 pushl $48 801060e4: 6a 30 push $0x30 jmp alltraps 801060e6: e9 b5 f9 ff ff jmp 80105aa0 <alltraps> 801060eb <vector49>: .globl vector49 vector49: pushl $0 801060eb: 6a 00 push $0x0 pushl $49 801060ed: 6a 31 push $0x31 jmp alltraps 801060ef: e9 ac f9 ff ff jmp 80105aa0 <alltraps> 801060f4 <vector50>: .globl vector50 vector50: pushl $0 801060f4: 6a 00 push $0x0 pushl $50 801060f6: 6a 32 push $0x32 jmp alltraps 801060f8: e9 a3 f9 ff ff jmp 80105aa0 <alltraps> 801060fd <vector51>: .globl vector51 vector51: pushl $0 801060fd: 6a 00 push $0x0 pushl $51 801060ff: 6a 33 push $0x33 jmp alltraps 80106101: e9 9a f9 ff ff jmp 80105aa0 <alltraps> 80106106 <vector52>: .globl vector52 vector52: pushl $0 80106106: 6a 00 push $0x0 pushl $52 80106108: 6a 34 push $0x34 jmp alltraps 8010610a: e9 91 f9 ff ff jmp 80105aa0 <alltraps> 8010610f <vector53>: .globl vector53 vector53: pushl $0 8010610f: 6a 00 push $0x0 pushl $53 80106111: 6a 35 push $0x35 jmp alltraps 80106113: e9 88 f9 ff ff jmp 80105aa0 <alltraps> 80106118 <vector54>: .globl vector54 vector54: pushl $0 80106118: 6a 00 push $0x0 pushl $54 8010611a: 6a 36 push $0x36 jmp alltraps 8010611c: e9 7f f9 ff ff jmp 80105aa0 <alltraps> 80106121 <vector55>: .globl vector55 vector55: pushl $0 80106121: 6a 00 push $0x0 pushl $55 80106123: 6a 37 push $0x37 jmp alltraps 80106125: e9 76 f9 ff ff jmp 80105aa0 <alltraps> 8010612a <vector56>: .globl vector56 vector56: pushl $0 8010612a: 6a 00 push $0x0 pushl $56 8010612c: 6a 38 push $0x38 jmp alltraps 8010612e: e9 6d f9 ff ff jmp 80105aa0 <alltraps> 80106133 <vector57>: .globl vector57 vector57: pushl $0 80106133: 6a 00 push $0x0 pushl $57 80106135: 6a 39 push $0x39 jmp alltraps 80106137: e9 64 f9 ff ff jmp 80105aa0 <alltraps> 8010613c <vector58>: .globl vector58 vector58: pushl $0 8010613c: 6a 00 push $0x0 pushl $58 8010613e: 6a 3a push $0x3a jmp alltraps 80106140: e9 5b f9 ff ff jmp 80105aa0 <alltraps> 80106145 <vector59>: .globl vector59 vector59: pushl $0 80106145: 6a 00 push $0x0 pushl $59 80106147: 6a 3b push $0x3b jmp alltraps 80106149: e9 52 f9 ff ff jmp 80105aa0 <alltraps> 8010614e <vector60>: .globl vector60 vector60: pushl $0 8010614e: 6a 00 push $0x0 pushl $60 80106150: 6a 3c push $0x3c jmp alltraps 80106152: e9 49 f9 ff ff jmp 80105aa0 <alltraps> 80106157 <vector61>: .globl vector61 vector61: pushl $0 80106157: 6a 00 push $0x0 pushl $61 80106159: 6a 3d push $0x3d jmp alltraps 8010615b: e9 40 f9 ff ff jmp 80105aa0 <alltraps> 80106160 <vector62>: .globl vector62 vector62: pushl $0 80106160: 6a 00 push $0x0 pushl $62 80106162: 6a 3e push $0x3e jmp alltraps 80106164: e9 37 f9 ff ff jmp 80105aa0 <alltraps> 80106169 <vector63>: .globl vector63 vector63: pushl $0 80106169: 6a 00 push $0x0 pushl $63 8010616b: 6a 3f push $0x3f jmp alltraps 8010616d: e9 2e f9 ff ff jmp 80105aa0 <alltraps> 80106172 <vector64>: .globl vector64 vector64: pushl $0 80106172: 6a 00 push $0x0 pushl $64 80106174: 6a 40 push $0x40 jmp alltraps 80106176: e9 25 f9 ff ff jmp 80105aa0 <alltraps> 8010617b <vector65>: .globl vector65 vector65: pushl $0 8010617b: 6a 00 push $0x0 pushl $65 8010617d: 6a 41 push $0x41 jmp alltraps 8010617f: e9 1c f9 ff ff jmp 80105aa0 <alltraps> 80106184 <vector66>: .globl vector66 vector66: pushl $0 80106184: 6a 00 push $0x0 pushl $66 80106186: 6a 42 push $0x42 jmp alltraps 80106188: e9 13 f9 ff ff jmp 80105aa0 <alltraps> 8010618d <vector67>: .globl vector67 vector67: pushl $0 8010618d: 6a 00 push $0x0 pushl $67 8010618f: 6a 43 push $0x43 jmp alltraps 80106191: e9 0a f9 ff ff jmp 80105aa0 <alltraps> 80106196 <vector68>: .globl vector68 vector68: pushl $0 80106196: 6a 00 push $0x0 pushl $68 80106198: 6a 44 push $0x44 jmp alltraps 8010619a: e9 01 f9 ff ff jmp 80105aa0 <alltraps> 8010619f <vector69>: .globl vector69 vector69: pushl $0 8010619f: 6a 00 push $0x0 pushl $69 801061a1: 6a 45 push $0x45 jmp alltraps 801061a3: e9 f8 f8 ff ff jmp 80105aa0 <alltraps> 801061a8 <vector70>: .globl vector70 vector70: pushl $0 801061a8: 6a 00 push $0x0 pushl $70 801061aa: 6a 46 push $0x46 jmp alltraps 801061ac: e9 ef f8 ff ff jmp 80105aa0 <alltraps> 801061b1 <vector71>: .globl vector71 vector71: pushl $0 801061b1: 6a 00 push $0x0 pushl $71 801061b3: 6a 47 push $0x47 jmp alltraps 801061b5: e9 e6 f8 ff ff jmp 80105aa0 <alltraps> 801061ba <vector72>: .globl vector72 vector72: pushl $0 801061ba: 6a 00 push $0x0 pushl $72 801061bc: 6a 48 push $0x48 jmp alltraps 801061be: e9 dd f8 ff ff jmp 80105aa0 <alltraps> 801061c3 <vector73>: .globl vector73 vector73: pushl $0 801061c3: 6a 00 push $0x0 pushl $73 801061c5: 6a 49 push $0x49 jmp alltraps 801061c7: e9 d4 f8 ff ff jmp 80105aa0 <alltraps> 801061cc <vector74>: .globl vector74 vector74: pushl $0 801061cc: 6a 00 push $0x0 pushl $74 801061ce: 6a 4a push $0x4a jmp alltraps 801061d0: e9 cb f8 ff ff jmp 80105aa0 <alltraps> 801061d5 <vector75>: .globl vector75 vector75: pushl $0 801061d5: 6a 00 push $0x0 pushl $75 801061d7: 6a 4b push $0x4b jmp alltraps 801061d9: e9 c2 f8 ff ff jmp 80105aa0 <alltraps> 801061de <vector76>: .globl vector76 vector76: pushl $0 801061de: 6a 00 push $0x0 pushl $76 801061e0: 6a 4c push $0x4c jmp alltraps 801061e2: e9 b9 f8 ff ff jmp 80105aa0 <alltraps> 801061e7 <vector77>: .globl vector77 vector77: pushl $0 801061e7: 6a 00 push $0x0 pushl $77 801061e9: 6a 4d push $0x4d jmp alltraps 801061eb: e9 b0 f8 ff ff jmp 80105aa0 <alltraps> 801061f0 <vector78>: .globl vector78 vector78: pushl $0 801061f0: 6a 00 push $0x0 pushl $78 801061f2: 6a 4e push $0x4e jmp alltraps 801061f4: e9 a7 f8 ff ff jmp 80105aa0 <alltraps> 801061f9 <vector79>: .globl vector79 vector79: pushl $0 801061f9: 6a 00 push $0x0 pushl $79 801061fb: 6a 4f push $0x4f jmp alltraps 801061fd: e9 9e f8 ff ff jmp 80105aa0 <alltraps> 80106202 <vector80>: .globl vector80 vector80: pushl $0 80106202: 6a 00 push $0x0 pushl $80 80106204: 6a 50 push $0x50 jmp alltraps 80106206: e9 95 f8 ff ff jmp 80105aa0 <alltraps> 8010620b <vector81>: .globl vector81 vector81: pushl $0 8010620b: 6a 00 push $0x0 pushl $81 8010620d: 6a 51 push $0x51 jmp alltraps 8010620f: e9 8c f8 ff ff jmp 80105aa0 <alltraps> 80106214 <vector82>: .globl vector82 vector82: pushl $0 80106214: 6a 00 push $0x0 pushl $82 80106216: 6a 52 push $0x52 jmp alltraps 80106218: e9 83 f8 ff ff jmp 80105aa0 <alltraps> 8010621d <vector83>: .globl vector83 vector83: pushl $0 8010621d: 6a 00 push $0x0 pushl $83 8010621f: 6a 53 push $0x53 jmp alltraps 80106221: e9 7a f8 ff ff jmp 80105aa0 <alltraps> 80106226 <vector84>: .globl vector84 vector84: pushl $0 80106226: 6a 00 push $0x0 pushl $84 80106228: 6a 54 push $0x54 jmp alltraps 8010622a: e9 71 f8 ff ff jmp 80105aa0 <alltraps> 8010622f <vector85>: .globl vector85 vector85: pushl $0 8010622f: 6a 00 push $0x0 pushl $85 80106231: 6a 55 push $0x55 jmp alltraps 80106233: e9 68 f8 ff ff jmp 80105aa0 <alltraps> 80106238 <vector86>: .globl vector86 vector86: pushl $0 80106238: 6a 00 push $0x0 pushl $86 8010623a: 6a 56 push $0x56 jmp alltraps 8010623c: e9 5f f8 ff ff jmp 80105aa0 <alltraps> 80106241 <vector87>: .globl vector87 vector87: pushl $0 80106241: 6a 00 push $0x0 pushl $87 80106243: 6a 57 push $0x57 jmp alltraps 80106245: e9 56 f8 ff ff jmp 80105aa0 <alltraps> 8010624a <vector88>: .globl vector88 vector88: pushl $0 8010624a: 6a 00 push $0x0 pushl $88 8010624c: 6a 58 push $0x58 jmp alltraps 8010624e: e9 4d f8 ff ff jmp 80105aa0 <alltraps> 80106253 <vector89>: .globl vector89 vector89: pushl $0 80106253: 6a 00 push $0x0 pushl $89 80106255: 6a 59 push $0x59 jmp alltraps 80106257: e9 44 f8 ff ff jmp 80105aa0 <alltraps> 8010625c <vector90>: .globl vector90 vector90: pushl $0 8010625c: 6a 00 push $0x0 pushl $90 8010625e: 6a 5a push $0x5a jmp alltraps 80106260: e9 3b f8 ff ff jmp 80105aa0 <alltraps> 80106265 <vector91>: .globl vector91 vector91: pushl $0 80106265: 6a 00 push $0x0 pushl $91 80106267: 6a 5b push $0x5b jmp alltraps 80106269: e9 32 f8 ff ff jmp 80105aa0 <alltraps> 8010626e <vector92>: .globl vector92 vector92: pushl $0 8010626e: 6a 00 push $0x0 pushl $92 80106270: 6a 5c push $0x5c jmp alltraps 80106272: e9 29 f8 ff ff jmp 80105aa0 <alltraps> 80106277 <vector93>: .globl vector93 vector93: pushl $0 80106277: 6a 00 push $0x0 pushl $93 80106279: 6a 5d push $0x5d jmp alltraps 8010627b: e9 20 f8 ff ff jmp 80105aa0 <alltraps> 80106280 <vector94>: .globl vector94 vector94: pushl $0 80106280: 6a 00 push $0x0 pushl $94 80106282: 6a 5e push $0x5e jmp alltraps 80106284: e9 17 f8 ff ff jmp 80105aa0 <alltraps> 80106289 <vector95>: .globl vector95 vector95: pushl $0 80106289: 6a 00 push $0x0 pushl $95 8010628b: 6a 5f push $0x5f jmp alltraps 8010628d: e9 0e f8 ff ff jmp 80105aa0 <alltraps> 80106292 <vector96>: .globl vector96 vector96: pushl $0 80106292: 6a 00 push $0x0 pushl $96 80106294: 6a 60 push $0x60 jmp alltraps 80106296: e9 05 f8 ff ff jmp 80105aa0 <alltraps> 8010629b <vector97>: .globl vector97 vector97: pushl $0 8010629b: 6a 00 push $0x0 pushl $97 8010629d: 6a 61 push $0x61 jmp alltraps 8010629f: e9 fc f7 ff ff jmp 80105aa0 <alltraps> 801062a4 <vector98>: .globl vector98 vector98: pushl $0 801062a4: 6a 00 push $0x0 pushl $98 801062a6: 6a 62 push $0x62 jmp alltraps 801062a8: e9 f3 f7 ff ff jmp 80105aa0 <alltraps> 801062ad <vector99>: .globl vector99 vector99: pushl $0 801062ad: 6a 00 push $0x0 pushl $99 801062af: 6a 63 push $0x63 jmp alltraps 801062b1: e9 ea f7 ff ff jmp 80105aa0 <alltraps> 801062b6 <vector100>: .globl vector100 vector100: pushl $0 801062b6: 6a 00 push $0x0 pushl $100 801062b8: 6a 64 push $0x64 jmp alltraps 801062ba: e9 e1 f7 ff ff jmp 80105aa0 <alltraps> 801062bf <vector101>: .globl vector101 vector101: pushl $0 801062bf: 6a 00 push $0x0 pushl $101 801062c1: 6a 65 push $0x65 jmp alltraps 801062c3: e9 d8 f7 ff ff jmp 80105aa0 <alltraps> 801062c8 <vector102>: .globl vector102 vector102: pushl $0 801062c8: 6a 00 push $0x0 pushl $102 801062ca: 6a 66 push $0x66 jmp alltraps 801062cc: e9 cf f7 ff ff jmp 80105aa0 <alltraps> 801062d1 <vector103>: .globl vector103 vector103: pushl $0 801062d1: 6a 00 push $0x0 pushl $103 801062d3: 6a 67 push $0x67 jmp alltraps 801062d5: e9 c6 f7 ff ff jmp 80105aa0 <alltraps> 801062da <vector104>: .globl vector104 vector104: pushl $0 801062da: 6a 00 push $0x0 pushl $104 801062dc: 6a 68 push $0x68 jmp alltraps 801062de: e9 bd f7 ff ff jmp 80105aa0 <alltraps> 801062e3 <vector105>: .globl vector105 vector105: pushl $0 801062e3: 6a 00 push $0x0 pushl $105 801062e5: 6a 69 push $0x69 jmp alltraps 801062e7: e9 b4 f7 ff ff jmp 80105aa0 <alltraps> 801062ec <vector106>: .globl vector106 vector106: pushl $0 801062ec: 6a 00 push $0x0 pushl $106 801062ee: 6a 6a push $0x6a jmp alltraps 801062f0: e9 ab f7 ff ff jmp 80105aa0 <alltraps> 801062f5 <vector107>: .globl vector107 vector107: pushl $0 801062f5: 6a 00 push $0x0 pushl $107 801062f7: 6a 6b push $0x6b jmp alltraps 801062f9: e9 a2 f7 ff ff jmp 80105aa0 <alltraps> 801062fe <vector108>: .globl vector108 vector108: pushl $0 801062fe: 6a 00 push $0x0 pushl $108 80106300: 6a 6c push $0x6c jmp alltraps 80106302: e9 99 f7 ff ff jmp 80105aa0 <alltraps> 80106307 <vector109>: .globl vector109 vector109: pushl $0 80106307: 6a 00 push $0x0 pushl $109 80106309: 6a 6d push $0x6d jmp alltraps 8010630b: e9 90 f7 ff ff jmp 80105aa0 <alltraps> 80106310 <vector110>: .globl vector110 vector110: pushl $0 80106310: 6a 00 push $0x0 pushl $110 80106312: 6a 6e push $0x6e jmp alltraps 80106314: e9 87 f7 ff ff jmp 80105aa0 <alltraps> 80106319 <vector111>: .globl vector111 vector111: pushl $0 80106319: 6a 00 push $0x0 pushl $111 8010631b: 6a 6f push $0x6f jmp alltraps 8010631d: e9 7e f7 ff ff jmp 80105aa0 <alltraps> 80106322 <vector112>: .globl vector112 vector112: pushl $0 80106322: 6a 00 push $0x0 pushl $112 80106324: 6a 70 push $0x70 jmp alltraps 80106326: e9 75 f7 ff ff jmp 80105aa0 <alltraps> 8010632b <vector113>: .globl vector113 vector113: pushl $0 8010632b: 6a 00 push $0x0 pushl $113 8010632d: 6a 71 push $0x71 jmp alltraps 8010632f: e9 6c f7 ff ff jmp 80105aa0 <alltraps> 80106334 <vector114>: .globl vector114 vector114: pushl $0 80106334: 6a 00 push $0x0 pushl $114 80106336: 6a 72 push $0x72 jmp alltraps 80106338: e9 63 f7 ff ff jmp 80105aa0 <alltraps> 8010633d <vector115>: .globl vector115 vector115: pushl $0 8010633d: 6a 00 push $0x0 pushl $115 8010633f: 6a 73 push $0x73 jmp alltraps 80106341: e9 5a f7 ff ff jmp 80105aa0 <alltraps> 80106346 <vector116>: .globl vector116 vector116: pushl $0 80106346: 6a 00 push $0x0 pushl $116 80106348: 6a 74 push $0x74 jmp alltraps 8010634a: e9 51 f7 ff ff jmp 80105aa0 <alltraps> 8010634f <vector117>: .globl vector117 vector117: pushl $0 8010634f: 6a 00 push $0x0 pushl $117 80106351: 6a 75 push $0x75 jmp alltraps 80106353: e9 48 f7 ff ff jmp 80105aa0 <alltraps> 80106358 <vector118>: .globl vector118 vector118: pushl $0 80106358: 6a 00 push $0x0 pushl $118 8010635a: 6a 76 push $0x76 jmp alltraps 8010635c: e9 3f f7 ff ff jmp 80105aa0 <alltraps> 80106361 <vector119>: .globl vector119 vector119: pushl $0 80106361: 6a 00 push $0x0 pushl $119 80106363: 6a 77 push $0x77 jmp alltraps 80106365: e9 36 f7 ff ff jmp 80105aa0 <alltraps> 8010636a <vector120>: .globl vector120 vector120: pushl $0 8010636a: 6a 00 push $0x0 pushl $120 8010636c: 6a 78 push $0x78 jmp alltraps 8010636e: e9 2d f7 ff ff jmp 80105aa0 <alltraps> 80106373 <vector121>: .globl vector121 vector121: pushl $0 80106373: 6a 00 push $0x0 pushl $121 80106375: 6a 79 push $0x79 jmp alltraps 80106377: e9 24 f7 ff ff jmp 80105aa0 <alltraps> 8010637c <vector122>: .globl vector122 vector122: pushl $0 8010637c: 6a 00 push $0x0 pushl $122 8010637e: 6a 7a push $0x7a jmp alltraps 80106380: e9 1b f7 ff ff jmp 80105aa0 <alltraps> 80106385 <vector123>: .globl vector123 vector123: pushl $0 80106385: 6a 00 push $0x0 pushl $123 80106387: 6a 7b push $0x7b jmp alltraps 80106389: e9 12 f7 ff ff jmp 80105aa0 <alltraps> 8010638e <vector124>: .globl vector124 vector124: pushl $0 8010638e: 6a 00 push $0x0 pushl $124 80106390: 6a 7c push $0x7c jmp alltraps 80106392: e9 09 f7 ff ff jmp 80105aa0 <alltraps> 80106397 <vector125>: .globl vector125 vector125: pushl $0 80106397: 6a 00 push $0x0 pushl $125 80106399: 6a 7d push $0x7d jmp alltraps 8010639b: e9 00 f7 ff ff jmp 80105aa0 <alltraps> 801063a0 <vector126>: .globl vector126 vector126: pushl $0 801063a0: 6a 00 push $0x0 pushl $126 801063a2: 6a 7e push $0x7e jmp alltraps 801063a4: e9 f7 f6 ff ff jmp 80105aa0 <alltraps> 801063a9 <vector127>: .globl vector127 vector127: pushl $0 801063a9: 6a 00 push $0x0 pushl $127 801063ab: 6a 7f push $0x7f jmp alltraps 801063ad: e9 ee f6 ff ff jmp 80105aa0 <alltraps> 801063b2 <vector128>: .globl vector128 vector128: pushl $0 801063b2: 6a 00 push $0x0 pushl $128 801063b4: 68 80 00 00 00 push $0x80 jmp alltraps 801063b9: e9 e2 f6 ff ff jmp 80105aa0 <alltraps> 801063be <vector129>: .globl vector129 vector129: pushl $0 801063be: 6a 00 push $0x0 pushl $129 801063c0: 68 81 00 00 00 push $0x81 jmp alltraps 801063c5: e9 d6 f6 ff ff jmp 80105aa0 <alltraps> 801063ca <vector130>: .globl vector130 vector130: pushl $0 801063ca: 6a 00 push $0x0 pushl $130 801063cc: 68 82 00 00 00 push $0x82 jmp alltraps 801063d1: e9 ca f6 ff ff jmp 80105aa0 <alltraps> 801063d6 <vector131>: .globl vector131 vector131: pushl $0 801063d6: 6a 00 push $0x0 pushl $131 801063d8: 68 83 00 00 00 push $0x83 jmp alltraps 801063dd: e9 be f6 ff ff jmp 80105aa0 <alltraps> 801063e2 <vector132>: .globl vector132 vector132: pushl $0 801063e2: 6a 00 push $0x0 pushl $132 801063e4: 68 84 00 00 00 push $0x84 jmp alltraps 801063e9: e9 b2 f6 ff ff jmp 80105aa0 <alltraps> 801063ee <vector133>: .globl vector133 vector133: pushl $0 801063ee: 6a 00 push $0x0 pushl $133 801063f0: 68 85 00 00 00 push $0x85 jmp alltraps 801063f5: e9 a6 f6 ff ff jmp 80105aa0 <alltraps> 801063fa <vector134>: .globl vector134 vector134: pushl $0 801063fa: 6a 00 push $0x0 pushl $134 801063fc: 68 86 00 00 00 push $0x86 jmp alltraps 80106401: e9 9a f6 ff ff jmp 80105aa0 <alltraps> 80106406 <vector135>: .globl vector135 vector135: pushl $0 80106406: 6a 00 push $0x0 pushl $135 80106408: 68 87 00 00 00 push $0x87 jmp alltraps 8010640d: e9 8e f6 ff ff jmp 80105aa0 <alltraps> 80106412 <vector136>: .globl vector136 vector136: pushl $0 80106412: 6a 00 push $0x0 pushl $136 80106414: 68 88 00 00 00 push $0x88 jmp alltraps 80106419: e9 82 f6 ff ff jmp 80105aa0 <alltraps> 8010641e <vector137>: .globl vector137 vector137: pushl $0 8010641e: 6a 00 push $0x0 pushl $137 80106420: 68 89 00 00 00 push $0x89 jmp alltraps 80106425: e9 76 f6 ff ff jmp 80105aa0 <alltraps> 8010642a <vector138>: .globl vector138 vector138: pushl $0 8010642a: 6a 00 push $0x0 pushl $138 8010642c: 68 8a 00 00 00 push $0x8a jmp alltraps 80106431: e9 6a f6 ff ff jmp 80105aa0 <alltraps> 80106436 <vector139>: .globl vector139 vector139: pushl $0 80106436: 6a 00 push $0x0 pushl $139 80106438: 68 8b 00 00 00 push $0x8b jmp alltraps 8010643d: e9 5e f6 ff ff jmp 80105aa0 <alltraps> 80106442 <vector140>: .globl vector140 vector140: pushl $0 80106442: 6a 00 push $0x0 pushl $140 80106444: 68 8c 00 00 00 push $0x8c jmp alltraps 80106449: e9 52 f6 ff ff jmp 80105aa0 <alltraps> 8010644e <vector141>: .globl vector141 vector141: pushl $0 8010644e: 6a 00 push $0x0 pushl $141 80106450: 68 8d 00 00 00 push $0x8d jmp alltraps 80106455: e9 46 f6 ff ff jmp 80105aa0 <alltraps> 8010645a <vector142>: .globl vector142 vector142: pushl $0 8010645a: 6a 00 push $0x0 pushl $142 8010645c: 68 8e 00 00 00 push $0x8e jmp alltraps 80106461: e9 3a f6 ff ff jmp 80105aa0 <alltraps> 80106466 <vector143>: .globl vector143 vector143: pushl $0 80106466: 6a 00 push $0x0 pushl $143 80106468: 68 8f 00 00 00 push $0x8f jmp alltraps 8010646d: e9 2e f6 ff ff jmp 80105aa0 <alltraps> 80106472 <vector144>: .globl vector144 vector144: pushl $0 80106472: 6a 00 push $0x0 pushl $144 80106474: 68 90 00 00 00 push $0x90 jmp alltraps 80106479: e9 22 f6 ff ff jmp 80105aa0 <alltraps> 8010647e <vector145>: .globl vector145 vector145: pushl $0 8010647e: 6a 00 push $0x0 pushl $145 80106480: 68 91 00 00 00 push $0x91 jmp alltraps 80106485: e9 16 f6 ff ff jmp 80105aa0 <alltraps> 8010648a <vector146>: .globl vector146 vector146: pushl $0 8010648a: 6a 00 push $0x0 pushl $146 8010648c: 68 92 00 00 00 push $0x92 jmp alltraps 80106491: e9 0a f6 ff ff jmp 80105aa0 <alltraps> 80106496 <vector147>: .globl vector147 vector147: pushl $0 80106496: 6a 00 push $0x0 pushl $147 80106498: 68 93 00 00 00 push $0x93 jmp alltraps 8010649d: e9 fe f5 ff ff jmp 80105aa0 <alltraps> 801064a2 <vector148>: .globl vector148 vector148: pushl $0 801064a2: 6a 00 push $0x0 pushl $148 801064a4: 68 94 00 00 00 push $0x94 jmp alltraps 801064a9: e9 f2 f5 ff ff jmp 80105aa0 <alltraps> 801064ae <vector149>: .globl vector149 vector149: pushl $0 801064ae: 6a 00 push $0x0 pushl $149 801064b0: 68 95 00 00 00 push $0x95 jmp alltraps 801064b5: e9 e6 f5 ff ff jmp 80105aa0 <alltraps> 801064ba <vector150>: .globl vector150 vector150: pushl $0 801064ba: 6a 00 push $0x0 pushl $150 801064bc: 68 96 00 00 00 push $0x96 jmp alltraps 801064c1: e9 da f5 ff ff jmp 80105aa0 <alltraps> 801064c6 <vector151>: .globl vector151 vector151: pushl $0 801064c6: 6a 00 push $0x0 pushl $151 801064c8: 68 97 00 00 00 push $0x97 jmp alltraps 801064cd: e9 ce f5 ff ff jmp 80105aa0 <alltraps> 801064d2 <vector152>: .globl vector152 vector152: pushl $0 801064d2: 6a 00 push $0x0 pushl $152 801064d4: 68 98 00 00 00 push $0x98 jmp alltraps 801064d9: e9 c2 f5 ff ff jmp 80105aa0 <alltraps> 801064de <vector153>: .globl vector153 vector153: pushl $0 801064de: 6a 00 push $0x0 pushl $153 801064e0: 68 99 00 00 00 push $0x99 jmp alltraps 801064e5: e9 b6 f5 ff ff jmp 80105aa0 <alltraps> 801064ea <vector154>: .globl vector154 vector154: pushl $0 801064ea: 6a 00 push $0x0 pushl $154 801064ec: 68 9a 00 00 00 push $0x9a jmp alltraps 801064f1: e9 aa f5 ff ff jmp 80105aa0 <alltraps> 801064f6 <vector155>: .globl vector155 vector155: pushl $0 801064f6: 6a 00 push $0x0 pushl $155 801064f8: 68 9b 00 00 00 push $0x9b jmp alltraps 801064fd: e9 9e f5 ff ff jmp 80105aa0 <alltraps> 80106502 <vector156>: .globl vector156 vector156: pushl $0 80106502: 6a 00 push $0x0 pushl $156 80106504: 68 9c 00 00 00 push $0x9c jmp alltraps 80106509: e9 92 f5 ff ff jmp 80105aa0 <alltraps> 8010650e <vector157>: .globl vector157 vector157: pushl $0 8010650e: 6a 00 push $0x0 pushl $157 80106510: 68 9d 00 00 00 push $0x9d jmp alltraps 80106515: e9 86 f5 ff ff jmp 80105aa0 <alltraps> 8010651a <vector158>: .globl vector158 vector158: pushl $0 8010651a: 6a 00 push $0x0 pushl $158 8010651c: 68 9e 00 00 00 push $0x9e jmp alltraps 80106521: e9 7a f5 ff ff jmp 80105aa0 <alltraps> 80106526 <vector159>: .globl vector159 vector159: pushl $0 80106526: 6a 00 push $0x0 pushl $159 80106528: 68 9f 00 00 00 push $0x9f jmp alltraps 8010652d: e9 6e f5 ff ff jmp 80105aa0 <alltraps> 80106532 <vector160>: .globl vector160 vector160: pushl $0 80106532: 6a 00 push $0x0 pushl $160 80106534: 68 a0 00 00 00 push $0xa0 jmp alltraps 80106539: e9 62 f5 ff ff jmp 80105aa0 <alltraps> 8010653e <vector161>: .globl vector161 vector161: pushl $0 8010653e: 6a 00 push $0x0 pushl $161 80106540: 68 a1 00 00 00 push $0xa1 jmp alltraps 80106545: e9 56 f5 ff ff jmp 80105aa0 <alltraps> 8010654a <vector162>: .globl vector162 vector162: pushl $0 8010654a: 6a 00 push $0x0 pushl $162 8010654c: 68 a2 00 00 00 push $0xa2 jmp alltraps 80106551: e9 4a f5 ff ff jmp 80105aa0 <alltraps> 80106556 <vector163>: .globl vector163 vector163: pushl $0 80106556: 6a 00 push $0x0 pushl $163 80106558: 68 a3 00 00 00 push $0xa3 jmp alltraps 8010655d: e9 3e f5 ff ff jmp 80105aa0 <alltraps> 80106562 <vector164>: .globl vector164 vector164: pushl $0 80106562: 6a 00 push $0x0 pushl $164 80106564: 68 a4 00 00 00 push $0xa4 jmp alltraps 80106569: e9 32 f5 ff ff jmp 80105aa0 <alltraps> 8010656e <vector165>: .globl vector165 vector165: pushl $0 8010656e: 6a 00 push $0x0 pushl $165 80106570: 68 a5 00 00 00 push $0xa5 jmp alltraps 80106575: e9 26 f5 ff ff jmp 80105aa0 <alltraps> 8010657a <vector166>: .globl vector166 vector166: pushl $0 8010657a: 6a 00 push $0x0 pushl $166 8010657c: 68 a6 00 00 00 push $0xa6 jmp alltraps 80106581: e9 1a f5 ff ff jmp 80105aa0 <alltraps> 80106586 <vector167>: .globl vector167 vector167: pushl $0 80106586: 6a 00 push $0x0 pushl $167 80106588: 68 a7 00 00 00 push $0xa7 jmp alltraps 8010658d: e9 0e f5 ff ff jmp 80105aa0 <alltraps> 80106592 <vector168>: .globl vector168 vector168: pushl $0 80106592: 6a 00 push $0x0 pushl $168 80106594: 68 a8 00 00 00 push $0xa8 jmp alltraps 80106599: e9 02 f5 ff ff jmp 80105aa0 <alltraps> 8010659e <vector169>: .globl vector169 vector169: pushl $0 8010659e: 6a 00 push $0x0 pushl $169 801065a0: 68 a9 00 00 00 push $0xa9 jmp alltraps 801065a5: e9 f6 f4 ff ff jmp 80105aa0 <alltraps> 801065aa <vector170>: .globl vector170 vector170: pushl $0 801065aa: 6a 00 push $0x0 pushl $170 801065ac: 68 aa 00 00 00 push $0xaa jmp alltraps 801065b1: e9 ea f4 ff ff jmp 80105aa0 <alltraps> 801065b6 <vector171>: .globl vector171 vector171: pushl $0 801065b6: 6a 00 push $0x0 pushl $171 801065b8: 68 ab 00 00 00 push $0xab jmp alltraps 801065bd: e9 de f4 ff ff jmp 80105aa0 <alltraps> 801065c2 <vector172>: .globl vector172 vector172: pushl $0 801065c2: 6a 00 push $0x0 pushl $172 801065c4: 68 ac 00 00 00 push $0xac jmp alltraps 801065c9: e9 d2 f4 ff ff jmp 80105aa0 <alltraps> 801065ce <vector173>: .globl vector173 vector173: pushl $0 801065ce: 6a 00 push $0x0 pushl $173 801065d0: 68 ad 00 00 00 push $0xad jmp alltraps 801065d5: e9 c6 f4 ff ff jmp 80105aa0 <alltraps> 801065da <vector174>: .globl vector174 vector174: pushl $0 801065da: 6a 00 push $0x0 pushl $174 801065dc: 68 ae 00 00 00 push $0xae jmp alltraps 801065e1: e9 ba f4 ff ff jmp 80105aa0 <alltraps> 801065e6 <vector175>: .globl vector175 vector175: pushl $0 801065e6: 6a 00 push $0x0 pushl $175 801065e8: 68 af 00 00 00 push $0xaf jmp alltraps 801065ed: e9 ae f4 ff ff jmp 80105aa0 <alltraps> 801065f2 <vector176>: .globl vector176 vector176: pushl $0 801065f2: 6a 00 push $0x0 pushl $176 801065f4: 68 b0 00 00 00 push $0xb0 jmp alltraps 801065f9: e9 a2 f4 ff ff jmp 80105aa0 <alltraps> 801065fe <vector177>: .globl vector177 vector177: pushl $0 801065fe: 6a 00 push $0x0 pushl $177 80106600: 68 b1 00 00 00 push $0xb1 jmp alltraps 80106605: e9 96 f4 ff ff jmp 80105aa0 <alltraps> 8010660a <vector178>: .globl vector178 vector178: pushl $0 8010660a: 6a 00 push $0x0 pushl $178 8010660c: 68 b2 00 00 00 push $0xb2 jmp alltraps 80106611: e9 8a f4 ff ff jmp 80105aa0 <alltraps> 80106616 <vector179>: .globl vector179 vector179: pushl $0 80106616: 6a 00 push $0x0 pushl $179 80106618: 68 b3 00 00 00 push $0xb3 jmp alltraps 8010661d: e9 7e f4 ff ff jmp 80105aa0 <alltraps> 80106622 <vector180>: .globl vector180 vector180: pushl $0 80106622: 6a 00 push $0x0 pushl $180 80106624: 68 b4 00 00 00 push $0xb4 jmp alltraps 80106629: e9 72 f4 ff ff jmp 80105aa0 <alltraps> 8010662e <vector181>: .globl vector181 vector181: pushl $0 8010662e: 6a 00 push $0x0 pushl $181 80106630: 68 b5 00 00 00 push $0xb5 jmp alltraps 80106635: e9 66 f4 ff ff jmp 80105aa0 <alltraps> 8010663a <vector182>: .globl vector182 vector182: pushl $0 8010663a: 6a 00 push $0x0 pushl $182 8010663c: 68 b6 00 00 00 push $0xb6 jmp alltraps 80106641: e9 5a f4 ff ff jmp 80105aa0 <alltraps> 80106646 <vector183>: .globl vector183 vector183: pushl $0 80106646: 6a 00 push $0x0 pushl $183 80106648: 68 b7 00 00 00 push $0xb7 jmp alltraps 8010664d: e9 4e f4 ff ff jmp 80105aa0 <alltraps> 80106652 <vector184>: .globl vector184 vector184: pushl $0 80106652: 6a 00 push $0x0 pushl $184 80106654: 68 b8 00 00 00 push $0xb8 jmp alltraps 80106659: e9 42 f4 ff ff jmp 80105aa0 <alltraps> 8010665e <vector185>: .globl vector185 vector185: pushl $0 8010665e: 6a 00 push $0x0 pushl $185 80106660: 68 b9 00 00 00 push $0xb9 jmp alltraps 80106665: e9 36 f4 ff ff jmp 80105aa0 <alltraps> 8010666a <vector186>: .globl vector186 vector186: pushl $0 8010666a: 6a 00 push $0x0 pushl $186 8010666c: 68 ba 00 00 00 push $0xba jmp alltraps 80106671: e9 2a f4 ff ff jmp 80105aa0 <alltraps> 80106676 <vector187>: .globl vector187 vector187: pushl $0 80106676: 6a 00 push $0x0 pushl $187 80106678: 68 bb 00 00 00 push $0xbb jmp alltraps 8010667d: e9 1e f4 ff ff jmp 80105aa0 <alltraps> 80106682 <vector188>: .globl vector188 vector188: pushl $0 80106682: 6a 00 push $0x0 pushl $188 80106684: 68 bc 00 00 00 push $0xbc jmp alltraps 80106689: e9 12 f4 ff ff jmp 80105aa0 <alltraps> 8010668e <vector189>: .globl vector189 vector189: pushl $0 8010668e: 6a 00 push $0x0 pushl $189 80106690: 68 bd 00 00 00 push $0xbd jmp alltraps 80106695: e9 06 f4 ff ff jmp 80105aa0 <alltraps> 8010669a <vector190>: .globl vector190 vector190: pushl $0 8010669a: 6a 00 push $0x0 pushl $190 8010669c: 68 be 00 00 00 push $0xbe jmp alltraps 801066a1: e9 fa f3 ff ff jmp 80105aa0 <alltraps> 801066a6 <vector191>: .globl vector191 vector191: pushl $0 801066a6: 6a 00 push $0x0 pushl $191 801066a8: 68 bf 00 00 00 push $0xbf jmp alltraps 801066ad: e9 ee f3 ff ff jmp 80105aa0 <alltraps> 801066b2 <vector192>: .globl vector192 vector192: pushl $0 801066b2: 6a 00 push $0x0 pushl $192 801066b4: 68 c0 00 00 00 push $0xc0 jmp alltraps 801066b9: e9 e2 f3 ff ff jmp 80105aa0 <alltraps> 801066be <vector193>: .globl vector193 vector193: pushl $0 801066be: 6a 00 push $0x0 pushl $193 801066c0: 68 c1 00 00 00 push $0xc1 jmp alltraps 801066c5: e9 d6 f3 ff ff jmp 80105aa0 <alltraps> 801066ca <vector194>: .globl vector194 vector194: pushl $0 801066ca: 6a 00 push $0x0 pushl $194 801066cc: 68 c2 00 00 00 push $0xc2 jmp alltraps 801066d1: e9 ca f3 ff ff jmp 80105aa0 <alltraps> 801066d6 <vector195>: .globl vector195 vector195: pushl $0 801066d6: 6a 00 push $0x0 pushl $195 801066d8: 68 c3 00 00 00 push $0xc3 jmp alltraps 801066dd: e9 be f3 ff ff jmp 80105aa0 <alltraps> 801066e2 <vector196>: .globl vector196 vector196: pushl $0 801066e2: 6a 00 push $0x0 pushl $196 801066e4: 68 c4 00 00 00 push $0xc4 jmp alltraps 801066e9: e9 b2 f3 ff ff jmp 80105aa0 <alltraps> 801066ee <vector197>: .globl vector197 vector197: pushl $0 801066ee: 6a 00 push $0x0 pushl $197 801066f0: 68 c5 00 00 00 push $0xc5 jmp alltraps 801066f5: e9 a6 f3 ff ff jmp 80105aa0 <alltraps> 801066fa <vector198>: .globl vector198 vector198: pushl $0 801066fa: 6a 00 push $0x0 pushl $198 801066fc: 68 c6 00 00 00 push $0xc6 jmp alltraps 80106701: e9 9a f3 ff ff jmp 80105aa0 <alltraps> 80106706 <vector199>: .globl vector199 vector199: pushl $0 80106706: 6a 00 push $0x0 pushl $199 80106708: 68 c7 00 00 00 push $0xc7 jmp alltraps 8010670d: e9 8e f3 ff ff jmp 80105aa0 <alltraps> 80106712 <vector200>: .globl vector200 vector200: pushl $0 80106712: 6a 00 push $0x0 pushl $200 80106714: 68 c8 00 00 00 push $0xc8 jmp alltraps 80106719: e9 82 f3 ff ff jmp 80105aa0 <alltraps> 8010671e <vector201>: .globl vector201 vector201: pushl $0 8010671e: 6a 00 push $0x0 pushl $201 80106720: 68 c9 00 00 00 push $0xc9 jmp alltraps 80106725: e9 76 f3 ff ff jmp 80105aa0 <alltraps> 8010672a <vector202>: .globl vector202 vector202: pushl $0 8010672a: 6a 00 push $0x0 pushl $202 8010672c: 68 ca 00 00 00 push $0xca jmp alltraps 80106731: e9 6a f3 ff ff jmp 80105aa0 <alltraps> 80106736 <vector203>: .globl vector203 vector203: pushl $0 80106736: 6a 00 push $0x0 pushl $203 80106738: 68 cb 00 00 00 push $0xcb jmp alltraps 8010673d: e9 5e f3 ff ff jmp 80105aa0 <alltraps> 80106742 <vector204>: .globl vector204 vector204: pushl $0 80106742: 6a 00 push $0x0 pushl $204 80106744: 68 cc 00 00 00 push $0xcc jmp alltraps 80106749: e9 52 f3 ff ff jmp 80105aa0 <alltraps> 8010674e <vector205>: .globl vector205 vector205: pushl $0 8010674e: 6a 00 push $0x0 pushl $205 80106750: 68 cd 00 00 00 push $0xcd jmp alltraps 80106755: e9 46 f3 ff ff jmp 80105aa0 <alltraps> 8010675a <vector206>: .globl vector206 vector206: pushl $0 8010675a: 6a 00 push $0x0 pushl $206 8010675c: 68 ce 00 00 00 push $0xce jmp alltraps 80106761: e9 3a f3 ff ff jmp 80105aa0 <alltraps> 80106766 <vector207>: .globl vector207 vector207: pushl $0 80106766: 6a 00 push $0x0 pushl $207 80106768: 68 cf 00 00 00 push $0xcf jmp alltraps 8010676d: e9 2e f3 ff ff jmp 80105aa0 <alltraps> 80106772 <vector208>: .globl vector208 vector208: pushl $0 80106772: 6a 00 push $0x0 pushl $208 80106774: 68 d0 00 00 00 push $0xd0 jmp alltraps 80106779: e9 22 f3 ff ff jmp 80105aa0 <alltraps> 8010677e <vector209>: .globl vector209 vector209: pushl $0 8010677e: 6a 00 push $0x0 pushl $209 80106780: 68 d1 00 00 00 push $0xd1 jmp alltraps 80106785: e9 16 f3 ff ff jmp 80105aa0 <alltraps> 8010678a <vector210>: .globl vector210 vector210: pushl $0 8010678a: 6a 00 push $0x0 pushl $210 8010678c: 68 d2 00 00 00 push $0xd2 jmp alltraps 80106791: e9 0a f3 ff ff jmp 80105aa0 <alltraps> 80106796 <vector211>: .globl vector211 vector211: pushl $0 80106796: 6a 00 push $0x0 pushl $211 80106798: 68 d3 00 00 00 push $0xd3 jmp alltraps 8010679d: e9 fe f2 ff ff jmp 80105aa0 <alltraps> 801067a2 <vector212>: .globl vector212 vector212: pushl $0 801067a2: 6a 00 push $0x0 pushl $212 801067a4: 68 d4 00 00 00 push $0xd4 jmp alltraps 801067a9: e9 f2 f2 ff ff jmp 80105aa0 <alltraps> 801067ae <vector213>: .globl vector213 vector213: pushl $0 801067ae: 6a 00 push $0x0 pushl $213 801067b0: 68 d5 00 00 00 push $0xd5 jmp alltraps 801067b5: e9 e6 f2 ff ff jmp 80105aa0 <alltraps> 801067ba <vector214>: .globl vector214 vector214: pushl $0 801067ba: 6a 00 push $0x0 pushl $214 801067bc: 68 d6 00 00 00 push $0xd6 jmp alltraps 801067c1: e9 da f2 ff ff jmp 80105aa0 <alltraps> 801067c6 <vector215>: .globl vector215 vector215: pushl $0 801067c6: 6a 00 push $0x0 pushl $215 801067c8: 68 d7 00 00 00 push $0xd7 jmp alltraps 801067cd: e9 ce f2 ff ff jmp 80105aa0 <alltraps> 801067d2 <vector216>: .globl vector216 vector216: pushl $0 801067d2: 6a 00 push $0x0 pushl $216 801067d4: 68 d8 00 00 00 push $0xd8 jmp alltraps 801067d9: e9 c2 f2 ff ff jmp 80105aa0 <alltraps> 801067de <vector217>: .globl vector217 vector217: pushl $0 801067de: 6a 00 push $0x0 pushl $217 801067e0: 68 d9 00 00 00 push $0xd9 jmp alltraps 801067e5: e9 b6 f2 ff ff jmp 80105aa0 <alltraps> 801067ea <vector218>: .globl vector218 vector218: pushl $0 801067ea: 6a 00 push $0x0 pushl $218 801067ec: 68 da 00 00 00 push $0xda jmp alltraps 801067f1: e9 aa f2 ff ff jmp 80105aa0 <alltraps> 801067f6 <vector219>: .globl vector219 vector219: pushl $0 801067f6: 6a 00 push $0x0 pushl $219 801067f8: 68 db 00 00 00 push $0xdb jmp alltraps 801067fd: e9 9e f2 ff ff jmp 80105aa0 <alltraps> 80106802 <vector220>: .globl vector220 vector220: pushl $0 80106802: 6a 00 push $0x0 pushl $220 80106804: 68 dc 00 00 00 push $0xdc jmp alltraps 80106809: e9 92 f2 ff ff jmp 80105aa0 <alltraps> 8010680e <vector221>: .globl vector221 vector221: pushl $0 8010680e: 6a 00 push $0x0 pushl $221 80106810: 68 dd 00 00 00 push $0xdd jmp alltraps 80106815: e9 86 f2 ff ff jmp 80105aa0 <alltraps> 8010681a <vector222>: .globl vector222 vector222: pushl $0 8010681a: 6a 00 push $0x0 pushl $222 8010681c: 68 de 00 00 00 push $0xde jmp alltraps 80106821: e9 7a f2 ff ff jmp 80105aa0 <alltraps> 80106826 <vector223>: .globl vector223 vector223: pushl $0 80106826: 6a 00 push $0x0 pushl $223 80106828: 68 df 00 00 00 push $0xdf jmp alltraps 8010682d: e9 6e f2 ff ff jmp 80105aa0 <alltraps> 80106832 <vector224>: .globl vector224 vector224: pushl $0 80106832: 6a 00 push $0x0 pushl $224 80106834: 68 e0 00 00 00 push $0xe0 jmp alltraps 80106839: e9 62 f2 ff ff jmp 80105aa0 <alltraps> 8010683e <vector225>: .globl vector225 vector225: pushl $0 8010683e: 6a 00 push $0x0 pushl $225 80106840: 68 e1 00 00 00 push $0xe1 jmp alltraps 80106845: e9 56 f2 ff ff jmp 80105aa0 <alltraps> 8010684a <vector226>: .globl vector226 vector226: pushl $0 8010684a: 6a 00 push $0x0 pushl $226 8010684c: 68 e2 00 00 00 push $0xe2 jmp alltraps 80106851: e9 4a f2 ff ff jmp 80105aa0 <alltraps> 80106856 <vector227>: .globl vector227 vector227: pushl $0 80106856: 6a 00 push $0x0 pushl $227 80106858: 68 e3 00 00 00 push $0xe3 jmp alltraps 8010685d: e9 3e f2 ff ff jmp 80105aa0 <alltraps> 80106862 <vector228>: .globl vector228 vector228: pushl $0 80106862: 6a 00 push $0x0 pushl $228 80106864: 68 e4 00 00 00 push $0xe4 jmp alltraps 80106869: e9 32 f2 ff ff jmp 80105aa0 <alltraps> 8010686e <vector229>: .globl vector229 vector229: pushl $0 8010686e: 6a 00 push $0x0 pushl $229 80106870: 68 e5 00 00 00 push $0xe5 jmp alltraps 80106875: e9 26 f2 ff ff jmp 80105aa0 <alltraps> 8010687a <vector230>: .globl vector230 vector230: pushl $0 8010687a: 6a 00 push $0x0 pushl $230 8010687c: 68 e6 00 00 00 push $0xe6 jmp alltraps 80106881: e9 1a f2 ff ff jmp 80105aa0 <alltraps> 80106886 <vector231>: .globl vector231 vector231: pushl $0 80106886: 6a 00 push $0x0 pushl $231 80106888: 68 e7 00 00 00 push $0xe7 jmp alltraps 8010688d: e9 0e f2 ff ff jmp 80105aa0 <alltraps> 80106892 <vector232>: .globl vector232 vector232: pushl $0 80106892: 6a 00 push $0x0 pushl $232 80106894: 68 e8 00 00 00 push $0xe8 jmp alltraps 80106899: e9 02 f2 ff ff jmp 80105aa0 <alltraps> 8010689e <vector233>: .globl vector233 vector233: pushl $0 8010689e: 6a 00 push $0x0 pushl $233 801068a0: 68 e9 00 00 00 push $0xe9 jmp alltraps 801068a5: e9 f6 f1 ff ff jmp 80105aa0 <alltraps> 801068aa <vector234>: .globl vector234 vector234: pushl $0 801068aa: 6a 00 push $0x0 pushl $234 801068ac: 68 ea 00 00 00 push $0xea jmp alltraps 801068b1: e9 ea f1 ff ff jmp 80105aa0 <alltraps> 801068b6 <vector235>: .globl vector235 vector235: pushl $0 801068b6: 6a 00 push $0x0 pushl $235 801068b8: 68 eb 00 00 00 push $0xeb jmp alltraps 801068bd: e9 de f1 ff ff jmp 80105aa0 <alltraps> 801068c2 <vector236>: .globl vector236 vector236: pushl $0 801068c2: 6a 00 push $0x0 pushl $236 801068c4: 68 ec 00 00 00 push $0xec jmp alltraps 801068c9: e9 d2 f1 ff ff jmp 80105aa0 <alltraps> 801068ce <vector237>: .globl vector237 vector237: pushl $0 801068ce: 6a 00 push $0x0 pushl $237 801068d0: 68 ed 00 00 00 push $0xed jmp alltraps 801068d5: e9 c6 f1 ff ff jmp 80105aa0 <alltraps> 801068da <vector238>: .globl vector238 vector238: pushl $0 801068da: 6a 00 push $0x0 pushl $238 801068dc: 68 ee 00 00 00 push $0xee jmp alltraps 801068e1: e9 ba f1 ff ff jmp 80105aa0 <alltraps> 801068e6 <vector239>: .globl vector239 vector239: pushl $0 801068e6: 6a 00 push $0x0 pushl $239 801068e8: 68 ef 00 00 00 push $0xef jmp alltraps 801068ed: e9 ae f1 ff ff jmp 80105aa0 <alltraps> 801068f2 <vector240>: .globl vector240 vector240: pushl $0 801068f2: 6a 00 push $0x0 pushl $240 801068f4: 68 f0 00 00 00 push $0xf0 jmp alltraps 801068f9: e9 a2 f1 ff ff jmp 80105aa0 <alltraps> 801068fe <vector241>: .globl vector241 vector241: pushl $0 801068fe: 6a 00 push $0x0 pushl $241 80106900: 68 f1 00 00 00 push $0xf1 jmp alltraps 80106905: e9 96 f1 ff ff jmp 80105aa0 <alltraps> 8010690a <vector242>: .globl vector242 vector242: pushl $0 8010690a: 6a 00 push $0x0 pushl $242 8010690c: 68 f2 00 00 00 push $0xf2 jmp alltraps 80106911: e9 8a f1 ff ff jmp 80105aa0 <alltraps> 80106916 <vector243>: .globl vector243 vector243: pushl $0 80106916: 6a 00 push $0x0 pushl $243 80106918: 68 f3 00 00 00 push $0xf3 jmp alltraps 8010691d: e9 7e f1 ff ff jmp 80105aa0 <alltraps> 80106922 <vector244>: .globl vector244 vector244: pushl $0 80106922: 6a 00 push $0x0 pushl $244 80106924: 68 f4 00 00 00 push $0xf4 jmp alltraps 80106929: e9 72 f1 ff ff jmp 80105aa0 <alltraps> 8010692e <vector245>: .globl vector245 vector245: pushl $0 8010692e: 6a 00 push $0x0 pushl $245 80106930: 68 f5 00 00 00 push $0xf5 jmp alltraps 80106935: e9 66 f1 ff ff jmp 80105aa0 <alltraps> 8010693a <vector246>: .globl vector246 vector246: pushl $0 8010693a: 6a 00 push $0x0 pushl $246 8010693c: 68 f6 00 00 00 push $0xf6 jmp alltraps 80106941: e9 5a f1 ff ff jmp 80105aa0 <alltraps> 80106946 <vector247>: .globl vector247 vector247: pushl $0 80106946: 6a 00 push $0x0 pushl $247 80106948: 68 f7 00 00 00 push $0xf7 jmp alltraps 8010694d: e9 4e f1 ff ff jmp 80105aa0 <alltraps> 80106952 <vector248>: .globl vector248 vector248: pushl $0 80106952: 6a 00 push $0x0 pushl $248 80106954: 68 f8 00 00 00 push $0xf8 jmp alltraps 80106959: e9 42 f1 ff ff jmp 80105aa0 <alltraps> 8010695e <vector249>: .globl vector249 vector249: pushl $0 8010695e: 6a 00 push $0x0 pushl $249 80106960: 68 f9 00 00 00 push $0xf9 jmp alltraps 80106965: e9 36 f1 ff ff jmp 80105aa0 <alltraps> 8010696a <vector250>: .globl vector250 vector250: pushl $0 8010696a: 6a 00 push $0x0 pushl $250 8010696c: 68 fa 00 00 00 push $0xfa jmp alltraps 80106971: e9 2a f1 ff ff jmp 80105aa0 <alltraps> 80106976 <vector251>: .globl vector251 vector251: pushl $0 80106976: 6a 00 push $0x0 pushl $251 80106978: 68 fb 00 00 00 push $0xfb jmp alltraps 8010697d: e9 1e f1 ff ff jmp 80105aa0 <alltraps> 80106982 <vector252>: .globl vector252 vector252: pushl $0 80106982: 6a 00 push $0x0 pushl $252 80106984: 68 fc 00 00 00 push $0xfc jmp alltraps 80106989: e9 12 f1 ff ff jmp 80105aa0 <alltraps> 8010698e <vector253>: .globl vector253 vector253: pushl $0 8010698e: 6a 00 push $0x0 pushl $253 80106990: 68 fd 00 00 00 push $0xfd jmp alltraps 80106995: e9 06 f1 ff ff jmp 80105aa0 <alltraps> 8010699a <vector254>: .globl vector254 vector254: pushl $0 8010699a: 6a 00 push $0x0 pushl $254 8010699c: 68 fe 00 00 00 push $0xfe jmp alltraps 801069a1: e9 fa f0 ff ff jmp 80105aa0 <alltraps> 801069a6 <vector255>: .globl vector255 vector255: pushl $0 801069a6: 6a 00 push $0x0 pushl $255 801069a8: 68 ff 00 00 00 push $0xff jmp alltraps 801069ad: e9 ee f0 ff ff jmp 80105aa0 <alltraps> ... 801069c0 <switchkvm>: } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 801069c0: a1 24 58 11 80 mov 0x80115824,%eax // Switch h/w page table register to the kernel-only page table, // for when no process is running. void switchkvm(void) { 801069c5: 55 push %ebp 801069c6: 89 e5 mov %esp,%ebp 801069c8: 2d 00 00 00 80 sub $0x80000000,%eax 801069cd: 0f 22 d8 mov %eax,%cr3 lcr3(V2P(kpgdir)); // switch to the kernel page table } 801069d0: 5d pop %ebp 801069d1: c3 ret 801069d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801069d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801069e0 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 801069e0: 55 push %ebp 801069e1: 89 e5 mov %esp,%ebp 801069e3: 83 ec 28 sub $0x28,%esp 801069e6: 89 5d f8 mov %ebx,-0x8(%ebp) pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 801069e9: 89 d3 mov %edx,%ebx 801069eb: c1 eb 16 shr $0x16,%ebx 801069ee: 8d 1c 98 lea (%eax,%ebx,4),%ebx // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 801069f1: 89 75 fc mov %esi,-0x4(%ebp) pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ 801069f4: 8b 33 mov (%ebx),%esi 801069f6: f7 c6 01 00 00 00 test $0x1,%esi 801069fc: 74 22 je 80106a20 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 801069fe: 81 e6 00 f0 ff ff and $0xfffff000,%esi 80106a04: 81 ee 00 00 00 80 sub $0x80000000,%esi // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 80106a0a: c1 ea 0a shr $0xa,%edx 80106a0d: 81 e2 fc 0f 00 00 and $0xffc,%edx 80106a13: 8d 04 16 lea (%esi,%edx,1),%eax } 80106a16: 8b 5d f8 mov -0x8(%ebp),%ebx 80106a19: 8b 75 fc mov -0x4(%ebp),%esi 80106a1c: 89 ec mov %ebp,%esp 80106a1e: 5d pop %ebp 80106a1f: c3 ret pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 80106a20: 85 c9 test %ecx,%ecx 80106a22: 75 04 jne 80106a28 <walkpgdir+0x48> // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 80106a24: 31 c0 xor %eax,%eax 80106a26: eb ee jmp 80106a16 <walkpgdir+0x36> pde = &pgdir[PDX(va)]; if(*pde & PTE_P){ pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); } else { if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 80106a28: 89 55 f4 mov %edx,-0xc(%ebp) 80106a2b: e8 30 b9 ff ff call 80102360 <kalloc> 80106a30: 85 c0 test %eax,%eax 80106a32: 89 c6 mov %eax,%esi 80106a34: 74 ee je 80106a24 <walkpgdir+0x44> return 0; // Make sure all those PTE_P bits are zero. memset(pgtab, 0, PGSIZE); 80106a36: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106a3d: 00 80106a3e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106a45: 00 80106a46: 89 04 24 mov %eax,(%esp) 80106a49: e8 22 de ff ff call 80104870 <memset> // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; 80106a4e: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 80106a54: 83 c8 07 or $0x7,%eax 80106a57: 89 03 mov %eax,(%ebx) 80106a59: 8b 55 f4 mov -0xc(%ebp),%edx 80106a5c: eb ac jmp 80106a0a <walkpgdir+0x2a> 80106a5e: 66 90 xchg %ax,%ax 80106a60 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106a60: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106a61: 31 c9 xor %ecx,%ecx //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106a63: 89 e5 mov %esp,%ebp 80106a65: 83 ec 08 sub $0x8,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106a68: 8b 55 0c mov 0xc(%ebp),%edx 80106a6b: 8b 45 08 mov 0x8(%ebp),%eax 80106a6e: e8 6d ff ff ff call 801069e0 <walkpgdir> if((*pte & PTE_P) == 0) 80106a73: 8b 00 mov (%eax),%eax 80106a75: a8 01 test $0x1,%al 80106a77: 75 07 jne 80106a80 <uva2ka+0x20> return 0; if((*pte & PTE_U) == 0) return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106a79: 31 c0 xor %eax,%eax } 80106a7b: c9 leave 80106a7c: c3 ret 80106a7d: 8d 76 00 lea 0x0(%esi),%esi pte_t *pte; pte = walkpgdir(pgdir, uva, 0); if((*pte & PTE_P) == 0) return 0; if((*pte & PTE_U) == 0) 80106a80: a8 04 test $0x4,%al 80106a82: 74 f5 je 80106a79 <uva2ka+0x19> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106a84: 25 00 f0 ff ff and $0xfffff000,%eax 80106a89: 2d 00 00 00 80 sub $0x80000000,%eax } 80106a8e: c9 leave 80106a8f: c3 ret 80106a90 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 80106a90: 55 push %ebp 80106a91: 89 e5 mov %esp,%ebp 80106a93: 57 push %edi 80106a94: 56 push %esi 80106a95: 53 push %ebx 80106a96: 83 ec 2c sub $0x2c,%esp 80106a99: 8b 5d 14 mov 0x14(%ebp),%ebx 80106a9c: 8b 55 0c mov 0xc(%ebp),%edx char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106a9f: 85 db test %ebx,%ebx 80106aa1: 74 75 je 80106b18 <copyout+0x88> copyout(pde_t *pgdir, uint va, void *p, uint len) { char *buf, *pa0; uint n, va0; buf = (char*)p; 80106aa3: 8b 45 10 mov 0x10(%ebp),%eax 80106aa6: 89 45 e4 mov %eax,-0x1c(%ebp) 80106aa9: eb 39 jmp 80106ae4 <copyout+0x54> 80106aab: 90 nop 80106aac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106ab0: 89 f7 mov %esi,%edi if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106ab2: 8b 4d e4 mov -0x1c(%ebp),%ecx while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106ab5: 29 d7 sub %edx,%edi 80106ab7: 81 c7 00 10 00 00 add $0x1000,%edi 80106abd: 39 df cmp %ebx,%edi 80106abf: 0f 47 fb cmova %ebx,%edi if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106ac2: 29 f2 sub %esi,%edx 80106ac4: 8d 14 10 lea (%eax,%edx,1),%edx 80106ac7: 89 7c 24 08 mov %edi,0x8(%esp) 80106acb: 89 4c 24 04 mov %ecx,0x4(%esp) 80106acf: 89 14 24 mov %edx,(%esp) 80106ad2: e8 69 de ff ff call 80104940 <memmove> { char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106ad7: 29 fb sub %edi,%ebx 80106ad9: 74 3d je 80106b18 <copyout+0x88> n = PGSIZE - (va - va0); if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; 80106adb: 01 7d e4 add %edi,-0x1c(%ebp) va = va0 + PGSIZE; 80106ade: 8d 96 00 10 00 00 lea 0x1000(%esi),%edx uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); 80106ae4: 8b 4d 08 mov 0x8(%ebp),%ecx char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ va0 = (uint)PGROUNDDOWN(va); 80106ae7: 89 d6 mov %edx,%esi 80106ae9: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 80106aef: 89 55 e0 mov %edx,-0x20(%ebp) 80106af2: 89 74 24 04 mov %esi,0x4(%esp) 80106af6: 89 0c 24 mov %ecx,(%esp) 80106af9: e8 62 ff ff ff call 80106a60 <uva2ka> if(pa0 == 0) 80106afe: 8b 55 e0 mov -0x20(%ebp),%edx 80106b01: 85 c0 test %eax,%eax 80106b03: 75 ab jne 80106ab0 <copyout+0x20> len -= n; buf += n; va = va0 + PGSIZE; } return 0; } 80106b05: 83 c4 2c add $0x2c,%esp if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; 80106b08: b8 ff ff ff ff mov $0xffffffff,%eax } return 0; } 80106b0d: 5b pop %ebx 80106b0e: 5e pop %esi 80106b0f: 5f pop %edi 80106b10: 5d pop %ebp 80106b11: c3 ret 80106b12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106b18: 83 c4 2c add $0x2c,%esp if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); len -= n; buf += n; va = va0 + PGSIZE; 80106b1b: 31 c0 xor %eax,%eax } return 0; } 80106b1d: 5b pop %ebx 80106b1e: 5e pop %esi 80106b1f: 5f pop %edi 80106b20: 5d pop %ebp 80106b21: c3 ret 80106b22: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106b29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106b30 <mappages>: // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 80106b30: 55 push %ebp 80106b31: 89 e5 mov %esp,%ebp 80106b33: 57 push %edi 80106b34: 56 push %esi 80106b35: 53 push %ebx char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80106b36: 89 d3 mov %edx,%ebx last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80106b38: 8d 7c 0a ff lea -0x1(%edx,%ecx,1),%edi // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 80106b3c: 83 ec 2c sub $0x2c,%esp 80106b3f: 8b 75 08 mov 0x8(%ebp),%esi 80106b42: 89 45 e4 mov %eax,-0x1c(%ebp) char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80106b45: 81 e3 00 f0 ff ff and $0xfffff000,%ebx last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80106b4b: 81 e7 00 f0 ff ff and $0xfffff000,%edi for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 80106b51: 83 4d 0c 01 orl $0x1,0xc(%ebp) 80106b55: eb 1d jmp 80106b74 <mappages+0x44> 80106b57: 90 nop a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) 80106b58: f6 00 01 testb $0x1,(%eax) 80106b5b: 75 45 jne 80106ba2 <mappages+0x72> panic("remap"); *pte = pa | perm | PTE_P; 80106b5d: 8b 55 0c mov 0xc(%ebp),%edx 80106b60: 09 f2 or %esi,%edx if(a == last) 80106b62: 39 fb cmp %edi,%ebx for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 80106b64: 89 10 mov %edx,(%eax) if(a == last) 80106b66: 74 30 je 80106b98 <mappages+0x68> break; a += PGSIZE; 80106b68: 81 c3 00 10 00 00 add $0x1000,%ebx pa += PGSIZE; 80106b6e: 81 c6 00 10 00 00 add $0x1000,%esi pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) 80106b74: 8b 45 e4 mov -0x1c(%ebp),%eax 80106b77: b9 01 00 00 00 mov $0x1,%ecx 80106b7c: 89 da mov %ebx,%edx 80106b7e: e8 5d fe ff ff call 801069e0 <walkpgdir> 80106b83: 85 c0 test %eax,%eax 80106b85: 75 d1 jne 80106b58 <mappages+0x28> break; a += PGSIZE; pa += PGSIZE; } return 0; } 80106b87: 83 c4 2c add $0x2c,%esp *pte = pa | perm | PTE_P; if(a == last) break; a += PGSIZE; pa += PGSIZE; } 80106b8a: b8 ff ff ff ff mov $0xffffffff,%eax return 0; } 80106b8f: 5b pop %ebx 80106b90: 5e pop %esi 80106b91: 5f pop %edi 80106b92: 5d pop %ebp 80106b93: c3 ret 80106b94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106b98: 83 c4 2c add $0x2c,%esp if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; if(a == last) 80106b9b: 31 c0 xor %eax,%eax break; a += PGSIZE; pa += PGSIZE; } return 0; } 80106b9d: 5b pop %ebx 80106b9e: 5e pop %esi 80106b9f: 5f pop %edi 80106ba0: 5d pop %ebp 80106ba1: c3 ret last = (char*)PGROUNDDOWN(((uint)va) + size - 1); for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); 80106ba2: c7 04 24 d0 7b 10 80 movl $0x80107bd0,(%esp) 80106ba9: e8 22 98 ff ff call 801003d0 <panic> 80106bae: 66 90 xchg %ax,%ax 80106bb0 <setupkvm>: }; // Set up kernel part of a page table. pde_t* setupkvm(void) { 80106bb0: 55 push %ebp 80106bb1: 89 e5 mov %esp,%ebp 80106bb3: 56 push %esi 80106bb4: 53 push %ebx 80106bb5: 83 ec 10 sub $0x10,%esp pde_t *pgdir; struct kmap *k; if((pgdir = (pde_t*)kalloc()) == 0) 80106bb8: e8 a3 b7 ff ff call 80102360 <kalloc> 80106bbd: 85 c0 test %eax,%eax 80106bbf: 89 c6 mov %eax,%esi 80106bc1: 74 53 je 80106c16 <setupkvm+0x66> return 0; memset(pgdir, 0, PGSIZE); 80106bc3: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106bca: 00 80106bcb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106bd2: 00 80106bd3: 89 04 24 mov %eax,(%esp) 80106bd6: e8 95 dc ff ff call 80104870 <memset> if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106bdb: b8 60 a4 10 80 mov $0x8010a460,%eax 80106be0: 3d 20 a4 10 80 cmp $0x8010a420,%eax 80106be5: 76 2f jbe 80106c16 <setupkvm+0x66> { (void*)DEVSPACE, DEVSPACE, 0, PTE_W}, // more devices }; // Set up kernel part of a page table. pde_t* setupkvm(void) 80106be7: bb 20 a4 10 80 mov $0x8010a420,%ebx return 0; memset(pgdir, 0, PGSIZE); if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106bec: 8b 53 0c mov 0xc(%ebx),%edx 80106bef: 8b 43 04 mov 0x4(%ebx),%eax 80106bf2: 8b 4b 08 mov 0x8(%ebx),%ecx 80106bf5: 89 54 24 04 mov %edx,0x4(%esp) 80106bf9: 8b 13 mov (%ebx),%edx 80106bfb: 89 04 24 mov %eax,(%esp) 80106bfe: 29 c1 sub %eax,%ecx 80106c00: 89 f0 mov %esi,%eax 80106c02: e8 29 ff ff ff call 80106b30 <mappages> 80106c07: 85 c0 test %eax,%eax 80106c09: 78 15 js 80106c20 <setupkvm+0x70> if((pgdir = (pde_t*)kalloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106c0b: 83 c3 10 add $0x10,%ebx 80106c0e: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx 80106c14: 75 d6 jne 80106bec <setupkvm+0x3c> if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, k->perm) < 0) return 0; return pgdir; } 80106c16: 83 c4 10 add $0x10,%esp 80106c19: 89 f0 mov %esi,%eax 80106c1b: 5b pop %ebx 80106c1c: 5e pop %esi 80106c1d: 5d pop %ebp 80106c1e: c3 ret 80106c1f: 90 nop return 0; memset(pgdir, 0, PGSIZE); if (P2V(PHYSTOP) > (void*)DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106c20: 31 f6 xor %esi,%esi (uint)k->phys_start, k->perm) < 0) return 0; return pgdir; } 80106c22: 83 c4 10 add $0x10,%esp 80106c25: 89 f0 mov %esi,%eax 80106c27: 5b pop %ebx 80106c28: 5e pop %esi 80106c29: 5d pop %ebp 80106c2a: c3 ret 80106c2b: 90 nop 80106c2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106c30 <kvmalloc>: // Allocate one page table for the machine for the kernel address // space for scheduler processes. void kvmalloc(void) { 80106c30: 55 push %ebp 80106c31: 89 e5 mov %esp,%ebp 80106c33: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 80106c36: e8 75 ff ff ff call 80106bb0 <setupkvm> 80106c3b: a3 24 58 11 80 mov %eax,0x80115824 80106c40: 2d 00 00 00 80 sub $0x80000000,%eax 80106c45: 0f 22 d8 mov %eax,%cr3 switchkvm(); } 80106c48: c9 leave 80106c49: c3 ret 80106c4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106c50 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106c50: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106c51: 31 c9 xor %ecx,%ecx // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106c53: 89 e5 mov %esp,%ebp 80106c55: 83 ec 18 sub $0x18,%esp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106c58: 8b 55 0c mov 0xc(%ebp),%edx 80106c5b: 8b 45 08 mov 0x8(%ebp),%eax 80106c5e: e8 7d fd ff ff call 801069e0 <walkpgdir> if(pte == 0) 80106c63: 85 c0 test %eax,%eax 80106c65: 74 05 je 80106c6c <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80106c67: 83 20 fb andl $0xfffffffb,(%eax) } 80106c6a: c9 leave 80106c6b: c3 ret { pte_t *pte; pte = walkpgdir(pgdir, uva, 0); if(pte == 0) panic("clearpteu"); 80106c6c: c7 04 24 d6 7b 10 80 movl $0x80107bd6,(%esp) 80106c73: e8 58 97 ff ff call 801003d0 <panic> 80106c78: 90 nop 80106c79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106c80 <inituvm>: // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106c80: 55 push %ebp 80106c81: 89 e5 mov %esp,%ebp 80106c83: 83 ec 38 sub $0x38,%esp 80106c86: 89 75 f8 mov %esi,-0x8(%ebp) 80106c89: 8b 75 10 mov 0x10(%ebp),%esi 80106c8c: 8b 45 08 mov 0x8(%ebp),%eax 80106c8f: 89 7d fc mov %edi,-0x4(%ebp) 80106c92: 8b 7d 0c mov 0xc(%ebp),%edi 80106c95: 89 5d f4 mov %ebx,-0xc(%ebp) char *mem; if(sz >= PGSIZE) 80106c98: 81 fe ff 0f 00 00 cmp $0xfff,%esi // Load the initcode into address 0 of pgdir. // sz must be less than a page. void inituvm(pde_t *pgdir, char *init, uint sz) { 80106c9e: 89 45 e4 mov %eax,-0x1c(%ebp) char *mem; if(sz >= PGSIZE) 80106ca1: 77 59 ja 80106cfc <inituvm+0x7c> panic("inituvm: more than a page"); mem = kalloc(); 80106ca3: e8 b8 b6 ff ff call 80102360 <kalloc> memset(mem, 0, PGSIZE); 80106ca8: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106caf: 00 80106cb0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106cb7: 00 { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); 80106cb8: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 80106cba: 89 04 24 mov %eax,(%esp) 80106cbd: e8 ae db ff ff call 80104870 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 80106cc2: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106cc8: b9 00 10 00 00 mov $0x1000,%ecx 80106ccd: 89 04 24 mov %eax,(%esp) 80106cd0: 8b 45 e4 mov -0x1c(%ebp),%eax 80106cd3: 31 d2 xor %edx,%edx 80106cd5: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 80106cdc: 00 80106cdd: e8 4e fe ff ff call 80106b30 <mappages> memmove(mem, init, sz); 80106ce2: 89 75 10 mov %esi,0x10(%ebp) } 80106ce5: 8b 75 f8 mov -0x8(%ebp),%esi if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); memmove(mem, init, sz); 80106ce8: 89 7d 0c mov %edi,0xc(%ebp) } 80106ceb: 8b 7d fc mov -0x4(%ebp),%edi if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); memmove(mem, init, sz); 80106cee: 89 5d 08 mov %ebx,0x8(%ebp) } 80106cf1: 8b 5d f4 mov -0xc(%ebp),%ebx 80106cf4: 89 ec mov %ebp,%esp 80106cf6: 5d pop %ebp if(sz >= PGSIZE) panic("inituvm: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); memmove(mem, init, sz); 80106cf7: e9 44 dc ff ff jmp 80104940 <memmove> inituvm(pde_t *pgdir, char *init, uint sz) { char *mem; if(sz >= PGSIZE) panic("inituvm: more than a page"); 80106cfc: c7 04 24 e0 7b 10 80 movl $0x80107be0,(%esp) 80106d03: e8 c8 96 ff ff call 801003d0 <panic> 80106d08: 90 nop 80106d09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106d10 <deallocuvm>: // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106d10: 55 push %ebp 80106d11: 89 e5 mov %esp,%ebp 80106d13: 57 push %edi 80106d14: 56 push %esi 80106d15: 53 push %ebx 80106d16: 83 ec 2c sub $0x2c,%esp 80106d19: 8b 75 0c mov 0xc(%ebp),%esi pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106d1c: 39 75 10 cmp %esi,0x10(%ebp) // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106d1f: 8b 7d 08 mov 0x8(%ebp),%edi pte_t *pte; uint a, pa; if(newsz >= oldsz) return oldsz; 80106d22: 89 f0 mov %esi,%eax deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) { pte_t *pte; uint a, pa; if(newsz >= oldsz) 80106d24: 73 75 jae 80106d9b <deallocuvm+0x8b> return oldsz; a = PGROUNDUP(newsz); 80106d26: 8b 5d 10 mov 0x10(%ebp),%ebx 80106d29: 81 c3 ff 0f 00 00 add $0xfff,%ebx 80106d2f: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < oldsz; a += PGSIZE){ 80106d35: 39 de cmp %ebx,%esi 80106d37: 77 3a ja 80106d73 <deallocuvm+0x63> 80106d39: eb 5d jmp 80106d98 <deallocuvm+0x88> 80106d3b: 90 nop 80106d3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi pte = walkpgdir(pgdir, (char*)a, 0); if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ 80106d40: 8b 10 mov (%eax),%edx 80106d42: f6 c2 01 test $0x1,%dl 80106d45: 74 22 je 80106d69 <deallocuvm+0x59> pa = PTE_ADDR(*pte); if(pa == 0) 80106d47: 81 e2 00 f0 ff ff and $0xfffff000,%edx 80106d4d: 74 54 je 80106da3 <deallocuvm+0x93> panic("kfree"); char *v = P2V(pa); kfree(v); 80106d4f: 81 ea 00 00 00 80 sub $0x80000000,%edx 80106d55: 89 45 e4 mov %eax,-0x1c(%ebp) 80106d58: 89 14 24 mov %edx,(%esp) 80106d5b: e8 50 b6 ff ff call 801023b0 <kfree> *pte = 0; 80106d60: 8b 45 e4 mov -0x1c(%ebp),%eax 80106d63: c7 00 00 00 00 00 movl $0x0,(%eax) if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 80106d69: 81 c3 00 10 00 00 add $0x1000,%ebx 80106d6f: 39 de cmp %ebx,%esi 80106d71: 76 25 jbe 80106d98 <deallocuvm+0x88> pte = walkpgdir(pgdir, (char*)a, 0); 80106d73: 31 c9 xor %ecx,%ecx 80106d75: 89 da mov %ebx,%edx 80106d77: 89 f8 mov %edi,%eax 80106d79: e8 62 fc ff ff call 801069e0 <walkpgdir> if(!pte) 80106d7e: 85 c0 test %eax,%eax 80106d80: 75 be jne 80106d40 <deallocuvm+0x30> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 80106d82: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 80106d88: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); for(; a < oldsz; a += PGSIZE){ 80106d8e: 81 c3 00 10 00 00 add $0x1000,%ebx 80106d94: 39 de cmp %ebx,%esi 80106d96: 77 db ja 80106d73 <deallocuvm+0x63> char *v = P2V(pa); kfree(v); *pte = 0; } } return newsz; 80106d98: 8b 45 10 mov 0x10(%ebp),%eax } 80106d9b: 83 c4 2c add $0x2c,%esp 80106d9e: 5b pop %ebx 80106d9f: 5e pop %esi 80106da0: 5f pop %edi 80106da1: 5d pop %ebp 80106da2: c3 ret if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ pa = PTE_ADDR(*pte); if(pa == 0) panic("kfree"); 80106da3: c7 04 24 52 75 10 80 movl $0x80107552,(%esp) 80106daa: e8 21 96 ff ff call 801003d0 <panic> 80106daf: 90 nop 80106db0 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80106db0: 55 push %ebp 80106db1: 89 e5 mov %esp,%ebp 80106db3: 56 push %esi 80106db4: 53 push %ebx 80106db5: 83 ec 10 sub $0x10,%esp 80106db8: 8b 5d 08 mov 0x8(%ebp),%ebx uint i; if(pgdir == 0) 80106dbb: 85 db test %ebx,%ebx 80106dbd: 74 5e je 80106e1d <freevm+0x6d> panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); 80106dbf: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80106dc6: 00 80106dc7: 31 f6 xor %esi,%esi 80106dc9: c7 44 24 04 00 00 00 movl $0x80000000,0x4(%esp) 80106dd0: 80 80106dd1: 89 1c 24 mov %ebx,(%esp) 80106dd4: e8 37 ff ff ff call 80106d10 <deallocuvm> 80106dd9: eb 10 jmp 80106deb <freevm+0x3b> 80106ddb: 90 nop 80106ddc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; i < NPDENTRIES; i++){ 80106de0: 83 c6 01 add $0x1,%esi 80106de3: 81 fe 00 04 00 00 cmp $0x400,%esi 80106de9: 74 24 je 80106e0f <freevm+0x5f> if(pgdir[i] & PTE_P){ 80106deb: 8b 04 b3 mov (%ebx,%esi,4),%eax 80106dee: a8 01 test $0x1,%al 80106df0: 74 ee je 80106de0 <freevm+0x30> char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); 80106df2: 25 00 f0 ff ff and $0xfffff000,%eax uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106df7: 83 c6 01 add $0x1,%esi if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); 80106dfa: 2d 00 00 00 80 sub $0x80000000,%eax 80106dff: 89 04 24 mov %eax,(%esp) 80106e02: e8 a9 b5 ff ff call 801023b0 <kfree> uint i; if(pgdir == 0) panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106e07: 81 fe 00 04 00 00 cmp $0x400,%esi 80106e0d: 75 dc jne 80106deb <freevm+0x3b> if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106e0f: 89 5d 08 mov %ebx,0x8(%ebp) } 80106e12: 83 c4 10 add $0x10,%esp 80106e15: 5b pop %ebx 80106e16: 5e pop %esi 80106e17: 5d pop %ebp if(pgdir[i] & PTE_P){ char * v = P2V(PTE_ADDR(pgdir[i])); kfree(v); } } kfree((char*)pgdir); 80106e18: e9 93 b5 ff ff jmp 801023b0 <kfree> freevm(pde_t *pgdir) { uint i; if(pgdir == 0) panic("freevm: no pgdir"); 80106e1d: c7 04 24 fa 7b 10 80 movl $0x80107bfa,(%esp) 80106e24: e8 a7 95 ff ff call 801003d0 <panic> 80106e29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106e30 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80106e30: 55 push %ebp 80106e31: 89 e5 mov %esp,%ebp 80106e33: 57 push %edi 80106e34: 56 push %esi 80106e35: 53 push %ebx 80106e36: 83 ec 2c sub $0x2c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80106e39: e8 72 fd ff ff call 80106bb0 <setupkvm> 80106e3e: 85 c0 test %eax,%eax 80106e40: 89 c6 mov %eax,%esi 80106e42: 0f 84 91 00 00 00 je 80106ed9 <copyuvm+0xa9> return 0; for(i = 0; i < sz; i += PGSIZE){ 80106e48: 8b 45 0c mov 0xc(%ebp),%eax 80106e4b: 85 c0 test %eax,%eax 80106e4d: 0f 84 86 00 00 00 je 80106ed9 <copyuvm+0xa9> 80106e53: 31 db xor %ebx,%ebx 80106e55: eb 54 jmp 80106eab <copyuvm+0x7b> 80106e57: 90 nop panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106e58: 8b 45 e4 mov -0x1c(%ebp),%eax 80106e5b: 89 3c 24 mov %edi,(%esp) if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) 80106e5e: 81 ef 00 00 00 80 sub $0x80000000,%edi panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106e64: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106e6b: 00 80106e6c: 25 00 f0 ff ff and $0xfffff000,%eax 80106e71: 2d 00 00 00 80 sub $0x80000000,%eax 80106e76: 89 44 24 04 mov %eax,0x4(%esp) 80106e7a: e8 c1 da ff ff call 80104940 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) 80106e7f: 8b 45 e4 mov -0x1c(%ebp),%eax 80106e82: b9 00 10 00 00 mov $0x1000,%ecx 80106e87: 89 da mov %ebx,%edx 80106e89: 89 3c 24 mov %edi,(%esp) 80106e8c: 25 ff 0f 00 00 and $0xfff,%eax 80106e91: 89 44 24 04 mov %eax,0x4(%esp) 80106e95: 89 f0 mov %esi,%eax 80106e97: e8 94 fc ff ff call 80106b30 <mappages> 80106e9c: 85 c0 test %eax,%eax 80106e9e: 78 2f js 80106ecf <copyuvm+0x9f> uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ 80106ea0: 81 c3 00 10 00 00 add $0x1000,%ebx 80106ea6: 39 5d 0c cmp %ebx,0xc(%ebp) 80106ea9: 76 2e jbe 80106ed9 <copyuvm+0xa9> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80106eab: 8b 45 08 mov 0x8(%ebp),%eax 80106eae: 31 c9 xor %ecx,%ecx 80106eb0: 89 da mov %ebx,%edx 80106eb2: e8 29 fb ff ff call 801069e0 <walkpgdir> 80106eb7: 85 c0 test %eax,%eax 80106eb9: 74 28 je 80106ee3 <copyuvm+0xb3> panic("copyuvm: pte should exist"); if(!(*pte & PTE_P)) 80106ebb: 8b 00 mov (%eax),%eax 80106ebd: a8 01 test $0x1,%al 80106ebf: 89 45 e4 mov %eax,-0x1c(%ebp) 80106ec2: 74 2b je 80106eef <copyuvm+0xbf> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) 80106ec4: e8 97 b4 ff ff call 80102360 <kalloc> 80106ec9: 85 c0 test %eax,%eax 80106ecb: 89 c7 mov %eax,%edi 80106ecd: 75 89 jne 80106e58 <copyuvm+0x28> goto bad; } return d; bad: freevm(d); 80106ecf: 89 34 24 mov %esi,(%esp) 80106ed2: 31 f6 xor %esi,%esi 80106ed4: e8 d7 fe ff ff call 80106db0 <freevm> return 0; } 80106ed9: 83 c4 2c add $0x2c,%esp 80106edc: 89 f0 mov %esi,%eax 80106ede: 5b pop %ebx 80106edf: 5e pop %esi 80106ee0: 5f pop %edi 80106ee1: 5d pop %ebp 80106ee2: c3 ret if((d = setupkvm()) == 0) return 0; for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) panic("copyuvm: pte should exist"); 80106ee3: c7 04 24 0b 7c 10 80 movl $0x80107c0b,(%esp) 80106eea: e8 e1 94 ff ff call 801003d0 <panic> if(!(*pte & PTE_P)) panic("copyuvm: page not present"); 80106eef: c7 04 24 25 7c 10 80 movl $0x80107c25,(%esp) 80106ef6: e8 d5 94 ff ff call 801003d0 <panic> 80106efb: 90 nop 80106efc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106f00 <allocuvm>: // Allocate page tables and physical memory to grow process from oldsz to // newsz, which need not be page aligned. Returns new size or 0 on error. int allocuvm(pde_t *pgdir, uint oldsz, uint newsz) { 80106f00: 55 push %ebp 80106f01: 89 e5 mov %esp,%ebp 80106f03: 57 push %edi 80106f04: 56 push %esi 80106f05: 53 push %ebx 80106f06: 83 ec 2c sub $0x2c,%esp 80106f09: 8b 7d 10 mov 0x10(%ebp),%edi char *mem; uint a; if(newsz >= KERNBASE) 80106f0c: 85 ff test %edi,%edi 80106f0e: 89 7d e4 mov %edi,-0x1c(%ebp) 80106f11: 0f 88 9c 00 00 00 js 80106fb3 <allocuvm+0xb3> return 0; if(newsz < oldsz) 80106f17: 8b 45 0c mov 0xc(%ebp),%eax 80106f1a: 39 45 e4 cmp %eax,-0x1c(%ebp) 80106f1d: 0f 82 a5 00 00 00 jb 80106fc8 <allocuvm+0xc8> return oldsz; a = PGROUNDUP(oldsz); 80106f23: 8b 75 0c mov 0xc(%ebp),%esi 80106f26: 81 c6 ff 0f 00 00 add $0xfff,%esi 80106f2c: 81 e6 00 f0 ff ff and $0xfffff000,%esi for(; a < newsz; a += PGSIZE){ 80106f32: 39 f7 cmp %esi,%edi 80106f34: 77 50 ja 80106f86 <allocuvm+0x86> 80106f36: e9 90 00 00 00 jmp 80106fcb <allocuvm+0xcb> 80106f3b: 90 nop 80106f3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(mem == 0){ cprintf("allocuvm out of memory\n"); deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); 80106f40: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106f47: 00 80106f48: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106f4f: 00 80106f50: 89 04 24 mov %eax,(%esp) 80106f53: e8 18 d9 ff ff call 80104870 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 80106f58: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106f5e: b9 00 10 00 00 mov $0x1000,%ecx 80106f63: 89 04 24 mov %eax,(%esp) 80106f66: 8b 45 08 mov 0x8(%ebp),%eax 80106f69: 89 f2 mov %esi,%edx 80106f6b: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 80106f72: 00 80106f73: e8 b8 fb ff ff call 80106b30 <mappages> 80106f78: 85 c0 test %eax,%eax 80106f7a: 78 5c js 80106fd8 <allocuvm+0xd8> return 0; if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ 80106f7c: 81 c6 00 10 00 00 add $0x1000,%esi 80106f82: 39 f7 cmp %esi,%edi 80106f84: 76 45 jbe 80106fcb <allocuvm+0xcb> mem = kalloc(); 80106f86: e8 d5 b3 ff ff call 80102360 <kalloc> if(mem == 0){ 80106f8b: 85 c0 test %eax,%eax if(newsz < oldsz) return oldsz; a = PGROUNDUP(oldsz); for(; a < newsz; a += PGSIZE){ mem = kalloc(); 80106f8d: 89 c3 mov %eax,%ebx if(mem == 0){ 80106f8f: 75 af jne 80106f40 <allocuvm+0x40> cprintf("allocuvm out of memory\n"); 80106f91: c7 04 24 3f 7c 10 80 movl $0x80107c3f,(%esp) 80106f98: e8 d3 98 ff ff call 80100870 <cprintf> deallocuvm(pgdir, newsz, oldsz); 80106f9d: 8b 45 0c mov 0xc(%ebp),%eax 80106fa0: 89 7c 24 04 mov %edi,0x4(%esp) 80106fa4: 89 44 24 08 mov %eax,0x8(%esp) 80106fa8: 8b 45 08 mov 0x8(%ebp),%eax 80106fab: 89 04 24 mov %eax,(%esp) 80106fae: e8 5d fd ff ff call 80106d10 <deallocuvm> 80106fb3: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) kfree(mem); return 0; } } return newsz; } 80106fba: 8b 45 e4 mov -0x1c(%ebp),%eax 80106fbd: 83 c4 2c add $0x2c,%esp 80106fc0: 5b pop %ebx 80106fc1: 5e pop %esi 80106fc2: 5f pop %edi 80106fc3: 5d pop %ebp 80106fc4: c3 ret 80106fc5: 8d 76 00 lea 0x0(%esi),%esi uint a; if(newsz >= KERNBASE) return 0; if(newsz < oldsz) return oldsz; 80106fc8: 89 45 e4 mov %eax,-0x1c(%ebp) kfree(mem); return 0; } } return newsz; } 80106fcb: 8b 45 e4 mov -0x1c(%ebp),%eax 80106fce: 83 c4 2c add $0x2c,%esp 80106fd1: 5b pop %ebx 80106fd2: 5e pop %esi 80106fd3: 5f pop %edi 80106fd4: 5d pop %ebp 80106fd5: c3 ret 80106fd6: 66 90 xchg %ax,%ax deallocuvm(pgdir, newsz, oldsz); return 0; } memset(mem, 0, PGSIZE); if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ cprintf("allocuvm out of memory (2)\n"); 80106fd8: c7 04 24 57 7c 10 80 movl $0x80107c57,(%esp) 80106fdf: e8 8c 98 ff ff call 80100870 <cprintf> deallocuvm(pgdir, newsz, oldsz); 80106fe4: 8b 45 0c mov 0xc(%ebp),%eax 80106fe7: 89 7c 24 04 mov %edi,0x4(%esp) 80106feb: 89 44 24 08 mov %eax,0x8(%esp) 80106fef: 8b 45 08 mov 0x8(%ebp),%eax 80106ff2: 89 04 24 mov %eax,(%esp) 80106ff5: e8 16 fd ff ff call 80106d10 <deallocuvm> kfree(mem); 80106ffa: 89 1c 24 mov %ebx,(%esp) 80106ffd: e8 ae b3 ff ff call 801023b0 <kfree> 80107002: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) return 0; } } return newsz; } 80107009: 8b 45 e4 mov -0x1c(%ebp),%eax 8010700c: 83 c4 2c add $0x2c,%esp 8010700f: 5b pop %ebx 80107010: 5e pop %esi 80107011: 5f pop %edi 80107012: 5d pop %ebp 80107013: c3 ret 80107014: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010701a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80107020 <loaduvm>: // Load a program segment into pgdir. addr must be page-aligned // and the pages from addr to addr+sz must already be mapped. int loaduvm(pde_t *pgdir, char *addr, struct inode *ip, uint offset, uint sz) { 80107020: 55 push %ebp 80107021: 89 e5 mov %esp,%ebp 80107023: 57 push %edi 80107024: 56 push %esi 80107025: 53 push %ebx 80107026: 83 ec 2c sub $0x2c,%esp 80107029: 8b 7d 0c mov 0xc(%ebp),%edi uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) 8010702c: f7 c7 ff 0f 00 00 test $0xfff,%edi 80107032: 0f 85 96 00 00 00 jne 801070ce <loaduvm+0xae> panic("loaduvm: addr must be page aligned"); 80107038: 8b 75 18 mov 0x18(%ebp),%esi 8010703b: 31 db xor %ebx,%ebx for(i = 0; i < sz; i += PGSIZE){ 8010703d: 85 f6 test %esi,%esi 8010703f: 75 18 jne 80107059 <loaduvm+0x39> 80107041: eb 75 jmp 801070b8 <loaduvm+0x98> 80107043: 90 nop 80107044: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80107048: 81 c3 00 10 00 00 add $0x1000,%ebx 8010704e: 81 ee 00 10 00 00 sub $0x1000,%esi 80107054: 39 5d 18 cmp %ebx,0x18(%ebp) 80107057: 76 5f jbe 801070b8 <loaduvm+0x98> if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 80107059: 8b 45 08 mov 0x8(%ebp),%eax 8010705c: 31 c9 xor %ecx,%ecx 8010705e: 8d 14 1f lea (%edi,%ebx,1),%edx 80107061: e8 7a f9 ff ff call 801069e0 <walkpgdir> 80107066: 85 c0 test %eax,%eax 80107068: 74 58 je 801070c2 <loaduvm+0xa2> panic("loaduvm: address should exist"); pa = PTE_ADDR(*pte); 8010706a: 8b 00 mov (%eax),%eax if(sz - i < PGSIZE) 8010706c: 81 fe 00 10 00 00 cmp $0x1000,%esi 80107072: ba 00 10 00 00 mov $0x1000,%edx 80107077: 0f 42 d6 cmovb %esi,%edx n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 8010707a: 8b 4d 14 mov 0x14(%ebp),%ecx 8010707d: 89 54 24 0c mov %edx,0xc(%esp) 80107081: 89 55 e4 mov %edx,-0x1c(%ebp) 80107084: 25 00 f0 ff ff and $0xfffff000,%eax 80107089: 2d 00 00 00 80 sub $0x80000000,%eax 8010708e: 89 44 24 04 mov %eax,0x4(%esp) 80107092: 8b 45 10 mov 0x10(%ebp),%eax 80107095: 8d 0c 0b lea (%ebx,%ecx,1),%ecx 80107098: 89 4c 24 08 mov %ecx,0x8(%esp) 8010709c: 89 04 24 mov %eax,(%esp) 8010709f: e8 cc a7 ff ff call 80101870 <readi> 801070a4: 8b 55 e4 mov -0x1c(%ebp),%edx 801070a7: 39 d0 cmp %edx,%eax 801070a9: 74 9d je 80107048 <loaduvm+0x28> return -1; } return 0; } 801070ab: 83 c4 2c add $0x2c,%esp pa = PTE_ADDR(*pte); if(sz - i < PGSIZE) n = sz - i; else n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) 801070ae: b8 ff ff ff ff mov $0xffffffff,%eax return -1; } return 0; } 801070b3: 5b pop %ebx 801070b4: 5e pop %esi 801070b5: 5f pop %edi 801070b6: 5d pop %ebp 801070b7: c3 ret 801070b8: 83 c4 2c add $0x2c,%esp uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ 801070bb: 31 c0 xor %eax,%eax n = PGSIZE; if(readi(ip, P2V(pa), offset+i, n) != n) return -1; } return 0; } 801070bd: 5b pop %ebx 801070be: 5e pop %esi 801070bf: 5f pop %edi 801070c0: 5d pop %ebp 801070c1: c3 ret if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); for(i = 0; i < sz; i += PGSIZE){ if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) panic("loaduvm: address should exist"); 801070c2: c7 04 24 73 7c 10 80 movl $0x80107c73,(%esp) 801070c9: e8 02 93 ff ff call 801003d0 <panic> { uint i, pa, n; pte_t *pte; if((uint) addr % PGSIZE != 0) panic("loaduvm: addr must be page aligned"); 801070ce: c7 04 24 d0 7c 10 80 movl $0x80107cd0,(%esp) 801070d5: e8 f6 92 ff ff call 801003d0 <panic> 801070da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801070e0 <switchuvm>: } // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { 801070e0: 55 push %ebp 801070e1: 89 e5 mov %esp,%ebp 801070e3: 53 push %ebx 801070e4: 83 ec 14 sub $0x14,%esp 801070e7: 8b 5d 08 mov 0x8(%ebp),%ebx if(p == 0) 801070ea: 85 db test %ebx,%ebx 801070ec: 0f 84 aa 00 00 00 je 8010719c <switchuvm+0xbc> panic("switchuvm: no process"); if(p->kstack == 0) 801070f2: 8b 4b 08 mov 0x8(%ebx),%ecx 801070f5: 85 c9 test %ecx,%ecx 801070f7: 0f 84 b7 00 00 00 je 801071b4 <switchuvm+0xd4> panic("switchuvm: no kstack"); if(p->pgdir == 0) 801070fd: 8b 53 04 mov 0x4(%ebx),%edx 80107100: 85 d2 test %edx,%edx 80107102: 0f 84 a0 00 00 00 je 801071a8 <switchuvm+0xc8> panic("switchuvm: no pgdir"); pushcli(); 80107108: e8 d3 d5 ff ff call 801046e0 <pushcli> cpu->gdt[SEG_TSS] = SEG16(STS_T32A, &cpu->ts, sizeof(cpu->ts)-1, 0); 8010710d: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80107113: 8d 50 08 lea 0x8(%eax),%edx 80107116: 89 d1 mov %edx,%ecx 80107118: 66 89 90 a2 00 00 00 mov %dx,0xa2(%eax) 8010711f: c1 e9 10 shr $0x10,%ecx 80107122: c1 ea 18 shr $0x18,%edx 80107125: 88 88 a4 00 00 00 mov %cl,0xa4(%eax) 8010712b: c6 80 a5 00 00 00 99 movb $0x99,0xa5(%eax) 80107132: 66 c7 80 a0 00 00 00 movw $0x67,0xa0(%eax) 80107139: 67 00 8010713b: c6 80 a6 00 00 00 40 movb $0x40,0xa6(%eax) 80107142: 88 90 a7 00 00 00 mov %dl,0xa7(%eax) cpu->gdt[SEG_TSS].s = 0; 80107148: 65 a1 00 00 00 00 mov %gs:0x0,%eax 8010714e: 80 a0 a5 00 00 00 ef andb $0xef,0xa5(%eax) cpu->ts.ss0 = SEG_KDATA << 3; 80107155: 65 a1 00 00 00 00 mov %gs:0x0,%eax 8010715b: 66 c7 40 10 10 00 movw $0x10,0x10(%eax) cpu->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80107161: 8b 53 08 mov 0x8(%ebx),%edx 80107164: 65 a1 00 00 00 00 mov %gs:0x0,%eax 8010716a: 81 c2 00 10 00 00 add $0x1000,%edx 80107170: 89 50 0c mov %edx,0xc(%eax) // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space cpu->ts.iomb = (ushort) 0xFFFF; 80107173: 65 a1 00 00 00 00 mov %gs:0x0,%eax 80107179: 66 c7 40 6e ff ff movw $0xffff,0x6e(%eax) } static inline void ltr(ushort sel) { asm volatile("ltr %0" : : "r" (sel)); 8010717f: b8 30 00 00 00 mov $0x30,%eax 80107184: 0f 00 d8 ltr %ax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 80107187: 8b 43 04 mov 0x4(%ebx),%eax 8010718a: 2d 00 00 00 80 sub $0x80000000,%eax 8010718f: 0f 22 d8 mov %eax,%cr3 ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); } 80107192: 83 c4 14 add $0x14,%esp 80107195: 5b pop %ebx 80107196: 5d pop %ebp // setting IOPL=0 in eflags *and* iomb beyond the tss segment limit // forbids I/O instructions (e.g., inb and outb) from user space cpu->ts.iomb = (ushort) 0xFFFF; ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); 80107197: e9 84 d5 ff ff jmp 80104720 <popcli> // Switch TSS and h/w page table to correspond to process p. void switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); 8010719c: c7 04 24 91 7c 10 80 movl $0x80107c91,(%esp) 801071a3: e8 28 92 ff ff call 801003d0 <panic> if(p->kstack == 0) panic("switchuvm: no kstack"); if(p->pgdir == 0) panic("switchuvm: no pgdir"); 801071a8: c7 04 24 bc 7c 10 80 movl $0x80107cbc,(%esp) 801071af: e8 1c 92 ff ff call 801003d0 <panic> switchuvm(struct proc *p) { if(p == 0) panic("switchuvm: no process"); if(p->kstack == 0) panic("switchuvm: no kstack"); 801071b4: c7 04 24 a7 7c 10 80 movl $0x80107ca7,(%esp) 801071bb: e8 10 92 ff ff call 801003d0 <panic> 801071c0 <seginit>: // Set up CPU's kernel segment descriptors. // Run once on entry on each CPU. void seginit(void) { 801071c0: 55 push %ebp 801071c1: 89 e5 mov %esp,%ebp 801071c3: 83 ec 18 sub $0x18,%esp // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpunum()]; 801071c6: e8 55 b8 ff ff call 80102a20 <cpunum> 801071cb: 69 c0 bc 00 00 00 imul $0xbc,%eax,%eax 801071d1: 05 a0 27 11 80 add $0x801127a0,%eax c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); // Map cpu and proc -- these are private per cpu. c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); 801071d6: 8d 90 b4 00 00 00 lea 0xb4(%eax),%edx 801071dc: 66 89 90 8a 00 00 00 mov %dx,0x8a(%eax) 801071e3: 89 d1 mov %edx,%ecx 801071e5: c1 ea 18 shr $0x18,%edx 801071e8: 88 90 8f 00 00 00 mov %dl,0x8f(%eax) 801071ee: c1 e9 10 shr $0x10,%ecx lgdt(c->gdt, sizeof(c->gdt)); 801071f1: 8d 50 70 lea 0x70(%eax),%edx // Map "logical" addresses to virtual addresses using identity map. // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. c = &cpus[cpunum()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801071f4: 66 c7 40 78 ff ff movw $0xffff,0x78(%eax) 801071fa: 66 c7 40 7a 00 00 movw $0x0,0x7a(%eax) 80107200: c6 40 7c 00 movb $0x0,0x7c(%eax) 80107204: c6 40 7d 9a movb $0x9a,0x7d(%eax) 80107208: c6 40 7e cf movb $0xcf,0x7e(%eax) 8010720c: c6 40 7f 00 movb $0x0,0x7f(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 80107210: 66 c7 80 80 00 00 00 movw $0xffff,0x80(%eax) 80107217: ff ff 80107219: 66 c7 80 82 00 00 00 movw $0x0,0x82(%eax) 80107220: 00 00 80107222: c6 80 84 00 00 00 00 movb $0x0,0x84(%eax) 80107229: c6 80 85 00 00 00 92 movb $0x92,0x85(%eax) 80107230: c6 80 86 00 00 00 cf movb $0xcf,0x86(%eax) 80107237: c6 80 87 00 00 00 00 movb $0x0,0x87(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 8010723e: 66 c7 80 90 00 00 00 movw $0xffff,0x90(%eax) 80107245: ff ff 80107247: 66 c7 80 92 00 00 00 movw $0x0,0x92(%eax) 8010724e: 00 00 80107250: c6 80 94 00 00 00 00 movb $0x0,0x94(%eax) 80107257: c6 80 95 00 00 00 fa movb $0xfa,0x95(%eax) 8010725e: c6 80 96 00 00 00 cf movb $0xcf,0x96(%eax) 80107265: c6 80 97 00 00 00 00 movb $0x0,0x97(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 8010726c: 66 c7 80 98 00 00 00 movw $0xffff,0x98(%eax) 80107273: ff ff 80107275: 66 c7 80 9a 00 00 00 movw $0x0,0x9a(%eax) 8010727c: 00 00 8010727e: c6 80 9c 00 00 00 00 movb $0x0,0x9c(%eax) 80107285: c6 80 9d 00 00 00 f2 movb $0xf2,0x9d(%eax) 8010728c: c6 80 9e 00 00 00 cf movb $0xcf,0x9e(%eax) 80107293: c6 80 9f 00 00 00 00 movb $0x0,0x9f(%eax) // Map cpu and proc -- these are private per cpu. c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); 8010729a: 66 c7 80 88 00 00 00 movw $0x0,0x88(%eax) 801072a1: 00 00 801072a3: 88 88 8c 00 00 00 mov %cl,0x8c(%eax) 801072a9: c6 80 8d 00 00 00 92 movb $0x92,0x8d(%eax) 801072b0: c6 80 8e 00 00 00 c0 movb $0xc0,0x8e(%eax) static inline void lgdt(struct segdesc *p, int size) { volatile ushort pd[3]; pd[0] = size-1; 801072b7: 66 c7 45 f2 37 00 movw $0x37,-0xe(%ebp) pd[1] = (uint)p; 801072bd: 66 89 55 f4 mov %dx,-0xc(%ebp) pd[2] = (uint)p >> 16; 801072c1: c1 ea 10 shr $0x10,%edx 801072c4: 66 89 55 f6 mov %dx,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 801072c8: 8d 55 f2 lea -0xe(%ebp),%edx 801072cb: 0f 01 12 lgdtl (%edx) } static inline void loadgs(ushort v) { asm volatile("movw %0, %%gs" : : "r" (v)); 801072ce: ba 18 00 00 00 mov $0x18,%edx 801072d3: 8e ea mov %edx,%gs lgdt(c->gdt, sizeof(c->gdt)); loadgs(SEG_KCPU << 3); // Initialize cpu-local storage. cpu = c; 801072d5: 65 a3 00 00 00 00 mov %eax,%gs:0x0 proc = 0; 801072db: 65 c7 05 04 00 00 00 movl $0x0,%gs:0x4 801072e2: 00 00 00 00 } 801072e6: c9 leave 801072e7: c3 ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r9 push %rbp push %rdx lea addresses_A_ht+0x1747b, %rbp nop nop and $31071, %r12 vmovups (%rbp), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %r9 nop nop nop nop cmp $8494, %rdx lea addresses_A_ht+0xc97b, %r10 and $62024, %r11 movb $0x61, (%r10) nop nop nop nop nop sub $9335, %rbp pop %rdx pop %rbp pop %r9 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r9 push %rcx push %rsi // Store mov $0xcbb, %rcx nop nop nop nop nop inc %r12 movl $0x51525354, (%rcx) nop nop and %rsi, %rsi // Faulty Load lea addresses_A+0x1d0bb, %r15 clflush (%r15) xor %r9, %r9 vmovups (%r15), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r12 lea oracles, %rcx and $0xff, %r12 shlq $12, %r12 mov (%rcx,%r12,1), %r12 pop %rsi pop %rcx pop %r9 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 7, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'00': 40} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced // at the Lawrence Livermore National Laboratory. All Rights reserved. See files // LICENSE and NOTICE for details. LLNL-CODE-806117. // // This file is part of the MFEM library. For more information and source code // availability visit https://mfem.org. // // MFEM is free software; you can redistribute it and/or modify it under the // terms of the BSD-3 license. We welcome feedback and contributions, see file // CONTRIBUTING.md for details. #include "fem.hpp" #include <cmath> namespace mfem { void LinearFormIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { mfem_error("LinearFormIntegrator::AssembleRHSElementVect(...)"); } void LinearFormIntegrator::AssembleRHSElementVect( const FiniteElement &el1, const FiniteElement &el2, FaceElementTransformations &Tr, Vector &elvect) { mfem_error("LinearFormIntegrator::AssembleRHSElementVect(...)"); } void DomainLFIntegrator::AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); shape.SetSize(dof); // vector of size dof elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { // ir = &IntRules.Get(el.GetGeomType(), // oa * el.GetOrder() + ob + Tr.OrderW()); ir = &IntRules.Get(el.GetGeomType(), oa * el.GetOrder() + ob); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); double val = Tr.Weight() * Q.Eval(Tr, ip); el.CalcPhysShape(Tr, shape); add(elvect, ip.weight * val, shape, elvect); } } void DomainLFIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { MFEM_ASSERT(delta != NULL, "coefficient must be DeltaCoefficient"); elvect.SetSize(fe.GetDof()); fe.CalcPhysShape(Trans, elvect); elvect *= delta->EvalDelta(Trans, Trans.GetIntPoint()); } void DomainLFGradIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); int spaceDim = Tr.GetSpaceDim(); dshape.SetSize(dof, spaceDim); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2 * el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint(&ip); el.CalcPhysDShape(Tr, dshape); Q.Eval(Qvec, Tr, ip); Qvec *= ip.weight * Tr.Weight(); dshape.AddMult(Qvec, elvect); } } void DomainLFGradIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { MFEM_ASSERT(vec_delta != NULL,"coefficient must be VectorDeltaCoefficient"); int dof = fe.GetDof(); int spaceDim = Trans.GetSpaceDim(); dshape.SetSize(dof, spaceDim); fe.CalcPhysDShape(Trans, dshape); vec_delta->EvalDelta(Qvec, Trans, Trans.GetIntPoint()); elvect.SetSize(dof); dshape.Mult(Qvec, elvect); } void BoundaryLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); shape.SetSize(dof); // vector of size dof elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <---------- ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); double val = Tr.Weight() * Q.Eval(Tr, ip); el.CalcShape(ip, shape); add(elvect, ip.weight * val, shape, elvect); } } void BoundaryLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { int dof = el.GetDof(); shape.SetSize(dof); // vector of size dof elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <------ user control ir = &IntRules.Get(Tr.FaceGeom, intorder); // of integration order } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); // Set the integration point in the face and the neighboring element Tr.SetAllIntPoints(&ip); // Access the neighboring element's integration point const IntegrationPoint &eip = Tr.GetElement1IntPoint(); double val = Tr.Face->Weight() * ip.weight * Q.Eval(*Tr.Face, ip); el.CalcShape(eip, shape); add(elvect, val, shape, elvect); } } void BoundaryNormalLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dim = el.GetDim()+1; int dof = el.GetDof(); Vector nor(dim), Qvec; shape.SetSize(dof); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <---------- ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint(&ip); CalcOrtho(Tr.Jacobian(), nor); Q.Eval(Qvec, Tr, ip); el.CalcShape(ip, shape); elvect.Add(ip.weight*(Qvec*nor), shape); } } void BoundaryTangentialLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dim = el.GetDim()+1; int dof = el.GetDof(); Vector tangent(dim), Qvec; shape.SetSize(dof); elvect.SetSize(dof); elvect = 0.0; if (dim != 2) { mfem_error("These methods make sense only in 2D problems."); } const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <---------- ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint(&ip); const DenseMatrix &Jac = Tr.Jacobian(); tangent(0) = Jac(0,0); tangent(1) = Jac(1,0); Q.Eval(Qvec, Tr, ip); el.CalcShape(ip, shape); add(elvect, ip.weight*(Qvec*tangent), shape, elvect); } } void VectorDomainLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int vdim = Q.GetVDim(); int dof = el.GetDof(); double val,cf; shape.SetSize(dof); // vector of size dof elvect.SetSize(dof * vdim); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2*el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); val = Tr.Weight(); el.CalcShape(ip, shape); Q.Eval (Qvec, Tr, ip); for (int k = 0; k < vdim; k++) { cf = val * Qvec(k); for (int s = 0; s < dof; s++) { elvect(dof*k+s) += ip.weight * cf * shape(s); } } } } void VectorDomainLFIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { MFEM_ASSERT(vec_delta != NULL, "coefficient must be VectorDeltaCoefficient"); int vdim = Q.GetVDim(); int dof = fe.GetDof(); shape.SetSize(dof); fe.CalcPhysShape(Trans, shape); vec_delta->EvalDelta(Qvec, Trans, Trans.GetIntPoint()); elvect.SetSize(dof*vdim); DenseMatrix elvec_as_mat(elvect.GetData(), dof, vdim); MultVWt(shape, Qvec, elvec_as_mat); } void VectorBoundaryLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int vdim = Q.GetVDim(); int dof = el.GetDof(); shape.SetSize(dof); vec.SetSize(vdim); elvect.SetSize(dof * vdim); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2*el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Q.Eval(vec, Tr, ip); Tr.SetIntPoint (&ip); vec *= Tr.Weight() * ip.weight; el.CalcShape(ip, shape); for (int k = 0; k < vdim; k++) for (int s = 0; s < dof; s++) { elvect(dof*k+s) += vec(k) * shape(s); } } } void VectorBoundaryLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { int vdim = Q.GetVDim(); int dof = el.GetDof(); shape.SetSize(dof); vec.SetSize(vdim); elvect.SetSize(dof * vdim); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2*el.GetOrder(); ir = &IntRules.Get(Tr.GetGeometryType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); // Set the integration point in the face and the neighboring element Tr.SetAllIntPoints(&ip); // Access the neighboring element's integration point const IntegrationPoint &eip = Tr.GetElement1IntPoint(); // Use Tr transformation in case Q depends on boundary attribute Q.Eval(vec, Tr, ip); vec *= Tr.Weight() * ip.weight; el.CalcShape(eip, shape); for (int k = 0; k < vdim; k++) { for (int s = 0; s < dof; s++) { elvect(dof*k+s) += vec(k) * shape(s); } } } } void VectorFEDomainLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); int spaceDim = Tr.GetSpaceDim(); vshape.SetSize(dof,spaceDim); vec.SetSize(spaceDim); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { // int intorder = 2*el.GetOrder() - 1; // ok for O(h^{k+1}) conv. in L2 int intorder = 2*el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); el.CalcVShape(Tr, vshape); QF.Eval (vec, Tr, ip); vec *= ip.weight * Tr.Weight(); vshape.AddMult (vec, elvect); } } void VectorFEDomainLFIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { MFEM_ASSERT(vec_delta != NULL, "coefficient must be VectorDeltaCoefficient"); int dof = fe.GetDof(); int spaceDim = Trans.GetSpaceDim(); vshape.SetSize(dof, spaceDim); fe.CalcPhysVShape(Trans, vshape); vec_delta->EvalDelta(vec, Trans, Trans.GetIntPoint()); elvect.SetSize(dof); vshape.Mult(vec, elvect); } void VectorFEDomainLFCurlIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); int spaceDim = Tr.GetSpaceDim(); int n=(spaceDim == 3)? spaceDim : 1; curlshape.SetSize(dof,n); vec.SetSize(n); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2*el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); el.CalcPhysCurlShape(Tr, curlshape); QF->Eval(vec, Tr, ip); vec *= ip.weight * Tr.Weight(); curlshape.AddMult (vec, elvect); } } void VectorFEDomainLFCurlIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { int spaceDim = Trans.GetSpaceDim(); MFEM_ASSERT(vec_delta != NULL, "coefficient must be VectorDeltaCoefficient"); int dof = fe.GetDof(); int n=(spaceDim == 3)? spaceDim : 1; vec.SetSize(n); curlshape.SetSize(dof, n); elvect.SetSize(dof); fe.CalcPhysCurlShape(Trans, curlshape); vec_delta->EvalDelta(vec, Trans, Trans.GetIntPoint()); curlshape.Mult(vec, elvect); } void VectorFEDomainLFDivIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); divshape.SetSize(dof); // vector of size dof elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = 2 * el.GetOrder(); ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); double val = Tr.Weight() * Q.Eval(Tr, ip); el.CalcPhysDivShape(Tr, divshape); add(elvect, ip.weight * val, divshape, elvect); } } void VectorFEDomainLFDivIntegrator::AssembleDeltaElementVect( const FiniteElement &fe, ElementTransformation &Trans, Vector &elvect) { MFEM_ASSERT(delta != NULL, "coefficient must be DeltaCoefficient"); elvect.SetSize(fe.GetDof()); fe.CalcPhysDivShape(Trans, elvect); elvect *= delta->EvalDelta(Trans, Trans.GetIntPoint()); } void VectorBoundaryFluxLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dim = el.GetDim()+1; int dof = el.GetDof(); shape.SetSize (dof); nor.SetSize (dim); elvect.SetSize (dim*dof); const IntegrationRule *ir = IntRule; if (ir == NULL) { ir = &IntRules.Get(el.GetGeomType(), el.GetOrder() + 1); } elvect = 0.0; for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint (&ip); CalcOrtho(Tr.Jacobian(), nor); el.CalcShape (ip, shape); nor *= Sign * ip.weight * F -> Eval (Tr, ip); for (int j = 0; j < dof; j++) for (int k = 0; k < dim; k++) { elvect(dof*k+j) += nor(k) * shape(j); } } } void VectorFEBoundaryFluxLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); shape.SetSize(dof); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <---------- ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); el.CalcShape(ip, shape); double val = ip.weight; if (F) { Tr.SetIntPoint (&ip); val *= F->Eval(Tr, ip); } elvect.Add(val, shape); } } void VectorFEBoundaryTangentLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { int dof = el.GetDof(); DenseMatrix vshape(dof, 2); Vector f_loc(3); Vector f_hat(2); elvect.SetSize(dof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { int intorder = oa * el.GetOrder() + ob; // <---------- ir = &IntRules.Get(el.GetGeomType(), intorder); } for (int i = 0; i < ir->GetNPoints(); i++) { const IntegrationPoint &ip = ir->IntPoint(i); Tr.SetIntPoint(&ip); f.Eval(f_loc, Tr, ip); Tr.Jacobian().MultTranspose(f_loc, f_hat); el.CalcVShape(ip, vshape); Swap<double>(f_hat(0), f_hat(1)); f_hat(0) = -f_hat(0); f_hat *= ip.weight; vshape.AddMult(f_hat, elvect); } } void BoundaryFlowIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { mfem_error("BoundaryFlowIntegrator::AssembleRHSElementVect\n" " is not implemented as boundary integrator!\n" " Use LinearForm::AddBdrFaceIntegrator instead of\n" " LinearForm::AddBoundaryIntegrator."); } void BoundaryFlowIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { int dim, ndof, order; double un, w, vu_data[3], nor_data[3]; dim = el.GetDim(); ndof = el.GetDof(); Vector vu(vu_data, dim), nor(nor_data, dim); const IntegrationRule *ir = IntRule; if (ir == NULL) { // Assuming order(u)==order(mesh) order = Tr.Elem1->OrderW() + 2*el.GetOrder(); if (el.Space() == FunctionSpace::Pk) { order++; } ir = &IntRules.Get(Tr.GetGeometryType(), order); } shape.SetSize(ndof); elvect.SetSize(ndof); elvect = 0.0; for (int p = 0; p < ir->GetNPoints(); p++) { const IntegrationPoint &ip = ir->IntPoint(p); // Set the integration point in the face and the neighboring element Tr.SetAllIntPoints(&ip); // Access the neighboring element's integration point const IntegrationPoint &eip = Tr.GetElement1IntPoint(); el.CalcShape(eip, shape); // Use Tr.Elem1 transformation for u so that it matches the coefficient // used with the ConvectionIntegrator and/or the DGTraceIntegrator. u->Eval(vu, *Tr.Elem1, eip); if (dim == 1) { nor(0) = 2*eip.x - 1.0; } else { CalcOrtho(Tr.Jacobian(), nor); } un = vu * nor; w = 0.5*alpha*un - beta*fabs(un); w *= ip.weight*f->Eval(Tr, ip); elvect.Add(w, shape); } } void DGDirichletLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { mfem_error("DGDirichletLFIntegrator::AssembleRHSElementVect"); } void DGDirichletLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { int dim, ndof; bool kappa_is_nonzero = (kappa != 0.); double w; dim = el.GetDim(); ndof = el.GetDof(); nor.SetSize(dim); nh.SetSize(dim); ni.SetSize(dim); adjJ.SetSize(dim); if (MQ) { mq.SetSize(dim); } shape.SetSize(ndof); dshape.SetSize(ndof, dim); dshape_dn.SetSize(ndof); elvect.SetSize(ndof); elvect = 0.0; const IntegrationRule *ir = IntRule; if (ir == NULL) { // a simple choice for the integration order; is this OK? int order = 2*el.GetOrder(); ir = &IntRules.Get(Tr.GetGeometryType(), order); } for (int p = 0; p < ir->GetNPoints(); p++) { const IntegrationPoint &ip = ir->IntPoint(p); // Set the integration point in the face and the neighboring element Tr.SetAllIntPoints(&ip); // Access the neighboring element's integration point const IntegrationPoint &eip = Tr.GetElement1IntPoint(); if (dim == 1) { nor(0) = 2*eip.x - 1.0; } else { CalcOrtho(Tr.Jacobian(), nor); } el.CalcShape(eip, shape); el.CalcDShape(eip, dshape); // compute uD through the face transformation w = ip.weight * uD->Eval(Tr, ip) / Tr.Elem1->Weight(); if (!MQ) { if (Q) { w *= Q->Eval(*Tr.Elem1, eip); } ni.Set(w, nor); } else { nh.Set(w, nor); MQ->Eval(mq, *Tr.Elem1, eip); mq.MultTranspose(nh, ni); } CalcAdjugate(Tr.Elem1->Jacobian(), adjJ); adjJ.Mult(ni, nh); dshape.Mult(nh, dshape_dn); elvect.Add(sigma, dshape_dn); if (kappa_is_nonzero) { elvect.Add(kappa*(ni*nor), shape); } } } void DGElasticityDirichletLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, ElementTransformation &Tr, Vector &elvect) { mfem_error("DGElasticityDirichletLFIntegrator::AssembleRHSElementVect"); } void DGElasticityDirichletLFIntegrator::AssembleRHSElementVect( const FiniteElement &el, FaceElementTransformations &Tr, Vector &elvect) { MFEM_ASSERT(Tr.Elem2No < 0, "interior boundary is not supported"); #ifdef MFEM_THREAD_SAFE Vector shape; DenseMatrix dshape; DenseMatrix adjJ; DenseMatrix dshape_ps; Vector nor; Vector dshape_dn; Vector dshape_du; Vector u_dir; #endif const int dim = el.GetDim(); const int ndofs = el.GetDof(); const int nvdofs = dim*ndofs; elvect.SetSize(nvdofs); elvect = 0.0; adjJ.SetSize(dim); shape.SetSize(ndofs); dshape.SetSize(ndofs, dim); dshape_ps.SetSize(ndofs, dim); nor.SetSize(dim); dshape_dn.SetSize(ndofs); dshape_du.SetSize(ndofs); u_dir.SetSize(dim); const IntegrationRule *ir = IntRule; if (ir == NULL) { const int order = 2*el.GetOrder(); // <----- ir = &IntRules.Get(Tr.GetGeometryType(), order); } for (int pi = 0; pi < ir->GetNPoints(); ++pi) { const IntegrationPoint &ip = ir->IntPoint(pi); // Set the integration point in the face and the neighboring element Tr.SetAllIntPoints(&ip); // Access the neighboring element's integration point const IntegrationPoint &eip = Tr.GetElement1IntPoint(); // Evaluate the Dirichlet b.c. using the face transformation. uD.Eval(u_dir, Tr, ip); el.CalcShape(eip, shape); el.CalcDShape(eip, dshape); CalcAdjugate(Tr.Elem1->Jacobian(), adjJ); Mult(dshape, adjJ, dshape_ps); if (dim == 1) { nor(0) = 2*eip.x - 1.0; } else { CalcOrtho(Tr.Jacobian(), nor); } double wL, wM, jcoef; { const double w = ip.weight / Tr.Elem1->Weight(); wL = w * lambda->Eval(*Tr.Elem1, eip); wM = w * mu->Eval(*Tr.Elem1, eip); jcoef = kappa * (wL + 2.0*wM) * (nor*nor); dshape_ps.Mult(nor, dshape_dn); dshape_ps.Mult(u_dir, dshape_du); } // alpha < uD, (lambda div(v) I + mu (grad(v) + grad(v)^T)) . n > + // + kappa < h^{-1} (lambda + 2 mu) uD, v > // i = idof + ndofs * im // v_phi(i,d) = delta(im,d) phi(idof) // div(v_phi(i)) = dphi(idof,im) // (grad(v_phi(i)))(k,l) = delta(im,k) dphi(idof,l) // // term 1: // alpha < uD, lambda div(v_phi(i)) n > // alpha lambda div(v_phi(i)) (uD.n) = // alpha lambda dphi(idof,im) (uD.n) --> quadrature --> // ip.weight/det(J1) alpha lambda (uD.nor) dshape_ps(idof,im) = // alpha * wL * (u_dir*nor) * dshape_ps(idof,im) // term 2: // < alpha uD, mu grad(v_phi(i)).n > = // alpha mu uD^T grad(v_phi(i)) n = // alpha mu uD(k) delta(im,k) dphi(idof,l) n(l) = // alpha mu uD(im) dphi(idof,l) n(l) --> quadrature --> // ip.weight/det(J1) alpha mu uD(im) dshape_ps(idof,l) nor(l) = // alpha * wM * u_dir(im) * dshape_dn(idof) // term 3: // < alpha uD, mu (grad(v_phi(i)))^T n > = // alpha mu n^T grad(v_phi(i)) uD = // alpha mu n(k) delta(im,k) dphi(idof,l) uD(l) = // alpha mu n(im) dphi(idof,l) uD(l) --> quadrature --> // ip.weight/det(J1) alpha mu nor(im) dshape_ps(idof,l) uD(l) = // alpha * wM * nor(im) * dshape_du(idof) // term j: // < kappa h^{-1} (lambda + 2 mu) uD, v_phi(i) > = // kappa/h (lambda + 2 mu) uD(k) v_phi(i,k) = // kappa/h (lambda + 2 mu) uD(k) delta(im,k) phi(idof) = // kappa/h (lambda + 2 mu) uD(im) phi(idof) --> quadrature --> // [ 1/h = |nor|/det(J1) ] // ip.weight/det(J1) |nor|^2 kappa (lambda + 2 mu) uD(im) phi(idof) = // jcoef * u_dir(im) * shape(idof) wM *= alpha; const double t1 = alpha * wL * (u_dir*nor); for (int im = 0, i = 0; im < dim; ++im) { const double t2 = wM * u_dir(im); const double t3 = wM * nor(im); const double tj = jcoef * u_dir(im); for (int idof = 0; idof < ndofs; ++idof, ++i) { elvect(i) += (t1*dshape_ps(idof,im) + t2*dshape_dn(idof) + t3*dshape_du(idof) + tj*shape(idof)); } } } } void VectorQuadratureLFIntegrator::AssembleRHSElementVect( const FiniteElement &fe, ElementTransformation &Tr, Vector &elvect) { const IntegrationRule *ir = &vqfc.GetQuadFunction().GetSpace()->GetElementIntRule(Tr.ElementNo); const int nqp = ir->GetNPoints(); const int vdim = vqfc.GetVDim(); const int ndofs = fe.GetDof(); Vector shape(ndofs); Vector temp(vdim); elvect.SetSize(vdim * ndofs); elvect = 0.0; for (int q = 0; q < nqp; q++) { const IntegrationPoint &ip = ir->IntPoint(q); Tr.SetIntPoint(&ip); const double w = Tr.Weight() * ip.weight; vqfc.Eval(temp, Tr, ip); fe.CalcShape(ip, shape); for (int ind = 0; ind < vdim; ind++) { for (int nd = 0; nd < ndofs; nd++) { elvect(nd + ind * ndofs) += w * shape(nd) * temp(ind); } } } } void QuadratureLFIntegrator::AssembleRHSElementVect(const FiniteElement &fe, ElementTransformation &Tr, Vector &elvect) { const IntegrationRule *ir = &qfc.GetQuadFunction().GetSpace()->GetElementIntRule(Tr.ElementNo); const int nqp = ir->GetNPoints(); const int ndofs = fe.GetDof(); Vector shape(ndofs); elvect.SetSize(ndofs); elvect = 0.0; for (int q = 0; q < nqp; q++) { const IntegrationPoint &ip = ir->IntPoint(q); Tr.SetIntPoint (&ip); const double w = Tr.Weight() * ip.weight; double temp = qfc.Eval(Tr, ip); fe.CalcShape(ip, shape); shape *= (w * temp); elvect += shape; } } }
; ; Invoke a GSX/GIOS function with 2 coordinates (4 values) in "ptsin" ; ; ; $Id: gios_2px_callee.asm $ ; SECTION code_clib PUBLIC gios_2px_callee PUBLIC _gios_2px_callee EXTERN gios EXTERN gios_ctl EXTERN gios_ptsin PUBLIC ASMDISP_GIOS_2PX gios_2px_callee: _gios_2px_callee: pop bc ld hl,gios_ptsin+7 pop de ld (hl),d dec hl ld (hl),e dec hl pop de ld (hl),d dec hl ld (hl),e dec hl pop de ld (hl),d dec hl ld (hl),e dec hl pop de ld (hl),d dec hl ld (hl),e pop de ; fn push bc .asmentry ld hl,gios_ctl+2 ; n_ptsin ld (hl),2 ; 2 xy coordinates = (4 int parameters) inc hl ld (hl),0 ld h,d ; fn ld l,e jp gios DEFC ASMDISP_GIOS_2PX = asmentry - gios_2px_callee
; A265228: Interleave the even numbers with the numbers that are congruent to {1, 3, 7} mod 8. ; 0,1,2,3,4,7,6,9,8,11,10,15,12,17,14,19,16,23,18,25,20,27,22,31,24,33,26,35,28,39,30,41,32,43,34,47,36,49,38,51,40,55,42,57,44,59,46,63,48,65,50,67,52,71,54,73,56,75,58,79,60,81,62,83,64,87,66,89,68,91,70,95,72,97,74,99,76,103,78,105,80,107,82,111,84,113,86,115,88,119,90,121,92,123,94,127,96,129,98,131,100,135,102,137,104,139,106,143,108,145,110,147,112,151,114,153,116,155,118,159,120,161,122,163,124,167,126,169,128,171,130,175,132,177,134,179,136,183,138,185,140,187,142,191,144,193,146,195,148,199,150,201,152,203,154,207,156,209,158,211,160,215,162,217,164,219,166,223,168,225,170,227,172,231,174,233,176,235,178,239,180,241,182,243,184,247,186,249,188,251,190,255,192,257,194,259,196,263,198,265,200,267,202,271,204,273,206,275,208,279,210,281,212,283,214,287,216,289,218,291,220,295,222,297,224,299,226,303,228,305,230,307,232,311,234,313,236,315,238,319,240,321,242,323,244,327,246,329,248,331 mov $3,$0 mov $4,$0 mod $0,2 mov $2,$4 lpb $0,1 trn $0,1 pow $1,$0 add $1,$2 div $1,6 mul $1,2 lpe add $1,$3
; ; jiss2fst-64.asm - fast integer IDCT (64-bit SSE2) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; Copyright 2009 D. R. Commander ; ; Based on ; x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/projecpt/showfiles.php?group_id=6208 ; ; This file contains a fast, not so accurate integer implementation of ; the inverse DCT (Discrete Cosine Transform). The following code is ; based directly on the IJG's original jidctfst.c; see the jidctfst.c ; for more details. ; ; [TAB8] %include "jsimdext.inc" %include "jdct.inc" ; -------------------------------------------------------------------------- %define CONST_BITS 8 ; 14 is also OK. %define PASS1_BITS 2 %if IFAST_SCALE_BITS != PASS1_BITS %error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'." %endif %if CONST_BITS == 8 F_1_082 equ 277 ; FIX(1.082392200) F_1_414 equ 362 ; FIX(1.414213562) F_1_847 equ 473 ; FIX(1.847759065) F_2_613 equ 669 ; FIX(2.613125930) F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1) %else ; NASM cannot do compile-time arithmetic on floating-point constants. %define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) F_1_082 equ DESCALE(1162209775,30-CONST_BITS) ; FIX(1.082392200) F_1_414 equ DESCALE(1518500249,30-CONST_BITS) ; FIX(1.414213562) F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) F_2_613 equ DESCALE(2805822602,30-CONST_BITS) ; FIX(2.613125930) F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1) %endif ; -------------------------------------------------------------------------- SECTION SEG_CONST ; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow) ; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw) %define PRE_MULTIPLY_SCALE_BITS 2 %define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS) alignz 16 global EXTN(jconst_idct_ifast_sse2) PRIVATE EXTN(jconst_idct_ifast_sse2): PW_F1414 times 8 dw F_1_414 << CONST_SHIFT PW_F1847 times 8 dw F_1_847 << CONST_SHIFT PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT PW_F1082 times 8 dw F_1_082 << CONST_SHIFT PB_CENTERJSAMP times 16 db CENTERJSAMPLE alignz 16 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 64 ; ; Perform dequantization and inverse DCT on one block of coefficients. ; ; GLOBAL(void) ; jsimd_idct_ifast_sse2 (void * dct_table, JCOEFPTR coef_block, ; JSAMPARRAY output_buf, JDIMENSION output_col) ; ; r10 = jpeg_component_info * compptr ; r11 = JCOEFPTR coef_block ; r12 = JSAMPARRAY output_buf ; r13 = JDIMENSION output_col %define original_rbp rbp+0 %define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] %define WK_NUM 2 align 16 global EXTN(jsimd_idct_ifast_sse2) PRIVATE EXTN(jsimd_idct_ifast_sse2): push rbp mov rax,rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits mov [rsp],rax mov rbp,rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args ; ---- Pass 1: process columns from input. mov rdx, r10 ; quantptr mov rsi, r11 ; inptr %ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2 mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)] or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)] jnz near .columnDCT movdqa xmm0, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] por xmm1, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] por xmm1, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] por xmm0, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] por xmm1,xmm0 packsswb xmm1,xmm1 packsswb xmm1,xmm1 movd eax,xmm1 test rax,rax jnz short .columnDCT ; -- AC terms all zero movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_ISLOW_MULT_TYPE)] movdqa xmm7,xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07) punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03) punpckhwd xmm7,xmm7 ; xmm7=(04 04 05 05 06 06 07 07) pshufd xmm6,xmm0,0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00) pshufd xmm2,xmm0,0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01) pshufd xmm5,xmm0,0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02) pshufd xmm0,xmm0,0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03) pshufd xmm1,xmm7,0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04) pshufd xmm4,xmm7,0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05) pshufd xmm3,xmm7,0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06) pshufd xmm7,xmm7,0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07) movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1 movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3 jmp near .column_end %endif .columnDCT: ; -- Even part movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_JCOEF)] movdqa xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_JCOEF)] pmullw xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_IFAST_MULT_TYPE)] pmullw xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_IFAST_MULT_TYPE)] movdqa xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_JCOEF)] movdqa xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_JCOEF)] pmullw xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_IFAST_MULT_TYPE)] pmullw xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_IFAST_MULT_TYPE)] movdqa xmm4,xmm0 movdqa xmm5,xmm1 psubw xmm0,xmm2 ; xmm0=tmp11 psubw xmm1,xmm3 paddw xmm4,xmm2 ; xmm4=tmp10 paddw xmm5,xmm3 ; xmm5=tmp13 psllw xmm1,PRE_MULTIPLY_SCALE_BITS pmulhw xmm1,[rel PW_F1414] psubw xmm1,xmm5 ; xmm1=tmp12 movdqa xmm6,xmm4 movdqa xmm7,xmm0 psubw xmm4,xmm5 ; xmm4=tmp3 psubw xmm0,xmm1 ; xmm0=tmp2 paddw xmm6,xmm5 ; xmm6=tmp0 paddw xmm7,xmm1 ; xmm7=tmp1 movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3 movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2 ; -- Odd part movdqa xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_JCOEF)] movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_JCOEF)] pmullw xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_IFAST_MULT_TYPE)] pmullw xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_IFAST_MULT_TYPE)] movdqa xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_JCOEF)] movdqa xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_JCOEF)] pmullw xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_IFAST_MULT_TYPE)] pmullw xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_IFAST_MULT_TYPE)] movdqa xmm4,xmm2 movdqa xmm0,xmm5 psubw xmm2,xmm1 ; xmm2=z12 psubw xmm5,xmm3 ; xmm5=z10 paddw xmm4,xmm1 ; xmm4=z11 paddw xmm0,xmm3 ; xmm0=z13 movdqa xmm1,xmm5 ; xmm1=z10(unscaled) psllw xmm2,PRE_MULTIPLY_SCALE_BITS psllw xmm5,PRE_MULTIPLY_SCALE_BITS movdqa xmm3,xmm4 psubw xmm4,xmm0 paddw xmm3,xmm0 ; xmm3=tmp7 psllw xmm4,PRE_MULTIPLY_SCALE_BITS pmulhw xmm4,[rel PW_F1414] ; xmm4=tmp11 ; To avoid overflow... ; ; (Original) ; tmp12 = -2.613125930 * z10 + z5; ; ; (This implementation) ; tmp12 = (-1.613125930 - 1) * z10 + z5; ; = -1.613125930 * z10 - z10 + z5; movdqa xmm0,xmm5 paddw xmm5,xmm2 pmulhw xmm5,[rel PW_F1847] ; xmm5=z5 pmulhw xmm0,[rel PW_MF1613] pmulhw xmm2,[rel PW_F1082] psubw xmm0,xmm1 psubw xmm2,xmm5 ; xmm2=tmp10 paddw xmm0,xmm5 ; xmm0=tmp12 ; -- Final output stage psubw xmm0,xmm3 ; xmm0=tmp6 movdqa xmm1,xmm6 movdqa xmm5,xmm7 paddw xmm6,xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07) paddw xmm7,xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17) psubw xmm1,xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77) psubw xmm5,xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67) psubw xmm4,xmm0 ; xmm4=tmp5 movdqa xmm3,xmm6 ; transpose coefficients(phase 1) punpcklwd xmm6,xmm7 ; xmm6=(00 10 01 11 02 12 03 13) punpckhwd xmm3,xmm7 ; xmm3=(04 14 05 15 06 16 07 17) movdqa xmm0,xmm5 ; transpose coefficients(phase 1) punpcklwd xmm5,xmm1 ; xmm5=(60 70 61 71 62 72 63 73) punpckhwd xmm0,xmm1 ; xmm0=(64 74 65 75 66 76 67 77) movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2 movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3 movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73) movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77) paddw xmm2,xmm4 ; xmm2=tmp4 movdqa xmm5,xmm7 movdqa xmm0,xmm1 paddw xmm7,xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27) paddw xmm1,xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47) psubw xmm5,xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57) psubw xmm0,xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37) movdqa xmm4,xmm7 ; transpose coefficients(phase 1) punpcklwd xmm7,xmm0 ; xmm7=(20 30 21 31 22 32 23 33) punpckhwd xmm4,xmm0 ; xmm4=(24 34 25 35 26 36 27 37) movdqa xmm2,xmm1 ; transpose coefficients(phase 1) punpcklwd xmm1,xmm5 ; xmm1=(40 50 41 51 42 52 43 53) punpckhwd xmm2,xmm5 ; xmm2=(44 54 45 55 46 56 47 57) movdqa xmm0,xmm3 ; transpose coefficients(phase 2) punpckldq xmm3,xmm4 ; xmm3=(04 14 24 34 05 15 25 35) punpckhdq xmm0,xmm4 ; xmm0=(06 16 26 36 07 17 27 37) movdqa xmm5,xmm6 ; transpose coefficients(phase 2) punpckldq xmm6,xmm7 ; xmm6=(00 10 20 30 01 11 21 31) punpckhdq xmm5,xmm7 ; xmm5=(02 12 22 32 03 13 23 33) movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73) movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77) movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35) movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37) movdqa xmm3,xmm1 ; transpose coefficients(phase 2) punpckldq xmm1,xmm4 ; xmm1=(40 50 60 70 41 51 61 71) punpckhdq xmm3,xmm4 ; xmm3=(42 52 62 72 43 53 63 73) movdqa xmm0,xmm2 ; transpose coefficients(phase 2) punpckldq xmm2,xmm7 ; xmm2=(44 54 64 74 45 55 65 75) punpckhdq xmm0,xmm7 ; xmm0=(46 56 66 76 47 57 67 77) movdqa xmm4,xmm6 ; transpose coefficients(phase 3) punpcklqdq xmm6,xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70) punpckhqdq xmm4,xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71) movdqa xmm7,xmm5 ; transpose coefficients(phase 3) punpcklqdq xmm5,xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72) punpckhqdq xmm7,xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73) movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35) movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37) movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1 movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3 movdqa xmm4,xmm1 ; transpose coefficients(phase 3) punpcklqdq xmm1,xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74) punpckhqdq xmm4,xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75) movdqa xmm7,xmm3 ; transpose coefficients(phase 3) punpcklqdq xmm3,xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76) punpckhqdq xmm7,xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77) .column_end: ; -- Prefetch the next coefficient block prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 0*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 1*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 2*32] prefetchnta [rsi + DCTSIZE2*SIZEOF_JCOEF + 3*32] ; ---- Pass 2: process rows from work array, store into output array. mov rax, [original_rbp] mov rdi, r12 ; (JSAMPROW *) mov eax, r13d ; -- Even part ; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6 movdqa xmm2,xmm6 movdqa xmm0,xmm5 psubw xmm6,xmm1 ; xmm6=tmp11 psubw xmm5,xmm3 paddw xmm2,xmm1 ; xmm2=tmp10 paddw xmm0,xmm3 ; xmm0=tmp13 psllw xmm5,PRE_MULTIPLY_SCALE_BITS pmulhw xmm5,[rel PW_F1414] psubw xmm5,xmm0 ; xmm5=tmp12 movdqa xmm1,xmm2 movdqa xmm3,xmm6 psubw xmm2,xmm0 ; xmm2=tmp3 psubw xmm6,xmm5 ; xmm6=tmp2 paddw xmm1,xmm0 ; xmm1=tmp0 paddw xmm3,xmm5 ; xmm3=tmp1 movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1 movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3 movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3 movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2 ; -- Odd part ; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7 movdqa xmm2,xmm0 movdqa xmm6,xmm4 psubw xmm0,xmm7 ; xmm0=z12 psubw xmm4,xmm5 ; xmm4=z10 paddw xmm2,xmm7 ; xmm2=z11 paddw xmm6,xmm5 ; xmm6=z13 movdqa xmm7,xmm4 ; xmm7=z10(unscaled) psllw xmm0,PRE_MULTIPLY_SCALE_BITS psllw xmm4,PRE_MULTIPLY_SCALE_BITS movdqa xmm5,xmm2 psubw xmm2,xmm6 paddw xmm5,xmm6 ; xmm5=tmp7 psllw xmm2,PRE_MULTIPLY_SCALE_BITS pmulhw xmm2,[rel PW_F1414] ; xmm2=tmp11 ; To avoid overflow... ; ; (Original) ; tmp12 = -2.613125930 * z10 + z5; ; ; (This implementation) ; tmp12 = (-1.613125930 - 1) * z10 + z5; ; = -1.613125930 * z10 - z10 + z5; movdqa xmm6,xmm4 paddw xmm4,xmm0 pmulhw xmm4,[rel PW_F1847] ; xmm4=z5 pmulhw xmm6,[rel PW_MF1613] pmulhw xmm0,[rel PW_F1082] psubw xmm6,xmm7 psubw xmm0,xmm4 ; xmm0=tmp10 paddw xmm6,xmm4 ; xmm6=tmp12 ; -- Final output stage psubw xmm6,xmm5 ; xmm6=tmp6 movdqa xmm7,xmm1 movdqa xmm4,xmm3 paddw xmm1,xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70) paddw xmm3,xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71) psraw xmm1,(PASS1_BITS+3) ; descale psraw xmm3,(PASS1_BITS+3) ; descale psubw xmm7,xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77) psubw xmm4,xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76) psraw xmm7,(PASS1_BITS+3) ; descale psraw xmm4,(PASS1_BITS+3) ; descale psubw xmm2,xmm6 ; xmm2=tmp5 packsswb xmm1,xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76) packsswb xmm3,xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77) movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2 movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3 paddw xmm0,xmm2 ; xmm0=tmp4 movdqa xmm4,xmm5 movdqa xmm7,xmm6 paddw xmm5,xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72) paddw xmm6,xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74) psraw xmm5,(PASS1_BITS+3) ; descale psraw xmm6,(PASS1_BITS+3) ; descale psubw xmm4,xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75) psubw xmm7,xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73) psraw xmm4,(PASS1_BITS+3) ; descale psraw xmm7,(PASS1_BITS+3) ; descale movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP] packsswb xmm5,xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74) packsswb xmm7,xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75) paddb xmm1,xmm2 paddb xmm3,xmm2 paddb xmm5,xmm2 paddb xmm7,xmm2 movdqa xmm0,xmm1 ; transpose coefficients(phase 1) punpcklbw xmm1,xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71) punpckhbw xmm0,xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77) movdqa xmm6,xmm5 ; transpose coefficients(phase 1) punpcklbw xmm5,xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73) punpckhbw xmm6,xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75) movdqa xmm4,xmm1 ; transpose coefficients(phase 2) punpcklwd xmm1,xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33) punpckhwd xmm4,xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73) movdqa xmm2,xmm6 ; transpose coefficients(phase 2) punpcklwd xmm6,xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37) punpckhwd xmm2,xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77) movdqa xmm3,xmm1 ; transpose coefficients(phase 3) punpckldq xmm1,xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17) punpckhdq xmm3,xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37) movdqa xmm7,xmm4 ; transpose coefficients(phase 3) punpckldq xmm4,xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57) punpckhdq xmm7,xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77) pshufd xmm5,xmm1,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07) pshufd xmm0,xmm3,0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27) pshufd xmm6,xmm4,0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47) pshufd xmm2,xmm7,0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67) mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+2*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3 mov rdx, JSAMPROW [rdi+4*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+6*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm4 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7 mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+3*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm0 mov rdx, JSAMPROW [rdi+5*SIZEOF_JSAMPROW] mov rsi, JSAMPROW [rdi+7*SIZEOF_JSAMPROW] movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6 movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2 uncollect_args mov rsp,rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 16
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. ;; ==++== ;; ;; ;; ==--== #include "ksarm64.h" #include "asmconstants.h" #include "asmmacros.h" IMPORT VirtualMethodFixupWorker IMPORT ExternalMethodFixupWorker IMPORT PreStubWorker IMPORT NDirectImportWorker IMPORT VSD_ResolveWorker IMPORT StubDispatchFixupWorker IMPORT JIT_InternalThrow IMPORT ComPreStubWorker IMPORT COMToCLRWorker IMPORT CallDescrWorkerUnwindFrameChainHandler IMPORT UMEntryPrestubUnwindFrameChainHandler IMPORT UMThunkStubUnwindFrameChainHandler IMPORT TheUMEntryPrestubWorker IMPORT GetThread IMPORT CreateThreadBlockThrow IMPORT UMThunkStubRareDisableWorker IMPORT UM2MDoADCallBack IMPORT GetCurrentSavedRedirectContext IMPORT LinkFrameAndThrow IMPORT FixContextHandler IMPORT OnHijackWorker #ifdef FEATURE_READYTORUN IMPORT DynamicHelperWorker #endif IMPORT ObjIsInstanceOfNoGC IMPORT ArrayStoreCheck SETALIAS g_pObjectClass, ?g_pObjectClass@@3PEAVMethodTable@@EA IMPORT $g_pObjectClass IMPORT g_ephemeral_low IMPORT g_ephemeral_high IMPORT g_lowest_address IMPORT g_highest_address IMPORT g_card_table IMPORT g_TrapReturningThreads IMPORT g_dispatch_cache_chain_success_counter #ifdef WRITE_BARRIER_CHECK SETALIAS g_GCShadow, ?g_GCShadow@@3PEAEEA SETALIAS g_GCShadowEnd, ?g_GCShadowEnd@@3PEAEEA IMPORT g_lowest_address IMPORT $g_GCShadow IMPORT $g_GCShadowEnd #endif // WRITE_BARRIER_CHECK IMPORT JIT_GetSharedNonGCStaticBase_Helper IMPORT JIT_GetSharedGCStaticBase_Helper TEXTAREA ;; LPVOID __stdcall GetCurrentIP(void); LEAF_ENTRY GetCurrentIP mov x0, lr ret lr LEAF_END ;; LPVOID __stdcall GetCurrentSP(void); LEAF_ENTRY GetCurrentSP mov x0, sp ret lr LEAF_END ;;----------------------------------------------------------------------------- ;; This routine captures the machine state. It is used by helper method frame ;;----------------------------------------------------------------------------- ;;void LazyMachStateCaptureState(struct LazyMachState *pState); LEAF_ENTRY LazyMachStateCaptureState ;; marks that this is not yet valid mov w1, #0 str w1, [x0, #MachState__isValid] str lr, [x0, #LazyMachState_captureIp] ;; str instruction does not save sp register directly so move to temp register mov x1, sp str x1, [x0, #LazyMachState_captureSp] ;; save non-volatile registers that can contain object references add x1, x0, #LazyMachState_captureX19_X29 stp x19, x20, [x1, #(16*0)] stp x21, x22, [x1, #(16*1)] stp x23, x24, [x1, #(16*2)] stp x25, x26, [x1, #(16*3)] stp x27, x28, [x1, #(16*4)] str x29, [x1, #(16*5)] ret lr LEAF_END ; ; If a preserved register were pushed onto the stack between ; the managed caller and the H_M_F, ptrX19_X29 will point to its ; location on the stack and it would have been updated on the ; stack by the GC already and it will be popped back into the ; appropriate register when the appropriate epilog is run. ; ; Otherwise, the register is preserved across all the code ; in this HCALL or FCALL, so we need to update those registers ; here because the GC will have updated our copies in the ; frame. ; ; So, if ptrX19_X29 points into the MachState, we need to update ; the register here. That's what this macro does. ; MACRO RestoreRegMS $regIndex, $reg ; Incoming: ; ; x0 = address of MachState ; ; $regIndex: Index of the register (x19-x29). For x19, index is 19. ; For x20, index is 20, and so on. ; ; $reg: Register name (e.g. x19, x20, etc) ; ; Get the address of the specified captured register from machine state add x2, x0, #(MachState__captureX19_X29 + (($regIndex-19)*8)) ; Get the content of specified preserved register pointer from machine state ldr x3, [x0, #(MachState__ptrX19_X29 + (($regIndex-19)*8))] cmp x2, x3 bne %FT0 ldr $reg, [x2] 0 MEND ; EXTERN_C int __fastcall HelperMethodFrameRestoreState( ; INDEBUG_COMMA(HelperMethodFrame *pFrame) ; MachState *pState ; ) LEAF_ENTRY HelperMethodFrameRestoreState #ifdef _DEBUG mov x0, x1 #endif ; If machine state is invalid, then simply exit ldr w1, [x0, #MachState__isValid] cmp w1, #0 beq Done RestoreRegMS 19, X19 RestoreRegMS 20, X20 RestoreRegMS 21, X21 RestoreRegMS 22, X22 RestoreRegMS 23, X23 RestoreRegMS 24, X24 RestoreRegMS 25, X25 RestoreRegMS 26, X26 RestoreRegMS 27, X27 RestoreRegMS 28, X28 RestoreRegMS 29, X29 Done ; Its imperative that the return value of HelperMethodFrameRestoreState is zero ; as it is used in the state machine to loop until it becomes zero. ; Refer to HELPER_METHOD_FRAME_END macro for details. mov x0,#0 ret lr LEAF_END ; ------------------------------------------------------------------ ; The call in ndirect import precode points to this function. NESTED_ENTRY NDirectImportThunk PROLOG_SAVE_REG_PAIR fp, lr, #-160! SAVE_ARGUMENT_REGISTERS sp, 16 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 88 mov x0, x12 bl NDirectImportWorker mov x12, x0 ; pop the stack and restore original register state RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 88 RESTORE_ARGUMENT_REGISTERS sp, 16 EPILOG_RESTORE_REG_PAIR fp, lr, #160! ; If we got back from NDirectImportWorker, the MD has been successfully ; linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG x12 NESTED_END ; ------------------------------------------------------------------ ; The call in fixup precode initally points to this function. ; The pupose of this function is to load the MethodDesc and forward the call to prestub. NESTED_ENTRY PrecodeFixupThunk ; x12 = FixupPrecode * ; On Exit ; x12 = MethodDesc* ; x13, x14 Trashed ; Inline computation done by FixupPrecode::GetMethodDesc() ldrb w13, [x12, #Offset_PrecodeChunkIndex] ; m_PrecodeChunkIndex ldrb w14, [x12, #Offset_MethodDescChunkIndex] ; m_MethodDescChunkIndex add x12,x12,w13,uxtw #FixupPrecode_ALIGNMENT_SHIFT_1 add x13,x12,w13,uxtw #FixupPrecode_ALIGNMENT_SHIFT_2 ldr x13, [x13,#SIZEOF__FixupPrecode] add x12,x13,w14,uxtw #MethodDesc_ALIGNMENT_SHIFT b ThePreStub NESTED_END ; ------------------------------------------------------------------ NESTED_ENTRY ThePreStub PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov x1, METHODDESC_REGISTER ; pMethodDesc bl PreStubWorker mov x9, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG x9 NESTED_END ;; ------------------------------------------------------------------ ;; ThePreStubPatch() LEAF_ENTRY ThePreStubPatch nop ThePreStubPatchLabel EXPORT ThePreStubPatchLabel ret lr LEAF_END ;----------------------------------------------------------------------------- ; The following Macros help in WRITE_BARRIER Implemetations ; WRITE_BARRIER_ENTRY ; ; Declare the start of a write barrier function. Use similarly to NESTED_ENTRY. This is the only legal way ; to declare a write barrier function. ; MACRO WRITE_BARRIER_ENTRY $name LEAF_ENTRY $name MEND ; WRITE_BARRIER_END ; ; The partner to WRITE_BARRIER_ENTRY, used like NESTED_END. ; MACRO WRITE_BARRIER_END $__write_barrier_name LEAF_END_MARKED $__write_barrier_name MEND ; void JIT_ByRefWriteBarrier ; On entry: ; x13 : the source address (points to object reference to write) ; x14 : the destination address (object reference written here) ; ; On exit: ; x12 : trashed ; x13 : incremented by 8 ; x14 : incremented by 8 ; x15 : trashed ; WRITE_BARRIER_ENTRY JIT_ByRefWriteBarrier ldr x15, [x13], 8 b JIT_CheckedWriteBarrier WRITE_BARRIER_END JIT_ByRefWriteBarrier ;----------------------------------------------------------------------------- ; Simple WriteBarriers ; void JIT_CheckedWriteBarrier(Object** dst, Object* src) ; On entry: ; x14 : the destination address (LHS of the assignment) ; x15 : the object reference (RHS of the assignment) ; ; On exit: ; x12 : trashed ; x14 : incremented by 8 ; x15 : trashed ; WRITE_BARRIER_ENTRY JIT_CheckedWriteBarrier adrp x12, g_lowest_address ldr x12, [x12, g_lowest_address] cmp x14, x12 blt NotInHeap adrp x12, g_highest_address ldr x12, [x12, g_highest_address] cmp x14, x12 blt JIT_WriteBarrier NotInHeap str x15, [x14], 8 ret lr WRITE_BARRIER_END JIT_CheckedWriteBarrier ; void JIT_WriteBarrier(Object** dst, Object* src) ; On entry: ; x14 : the destination address (LHS of the assignment) ; x15 : the object reference (RHS of the assignment) ; ; On exit: ; x12 : trashed ; x14 : incremented by 8 ; x15 : trashed ; WRITE_BARRIER_ENTRY JIT_WriteBarrier stlr x15, [x14] #ifdef WRITE_BARRIER_CHECK ; Update GC Shadow Heap ; need temporary registers. Save them before using. stp x12, x13, [sp, #-16]! ; Compute address of shadow heap location: ; pShadow = $g_GCShadow + (x14 - g_lowest_address) adrp x12, g_lowest_address ldr x12, [x12, g_lowest_address] sub x12, x14, x12 adrp x13, $g_GCShadow ldr x13, [x13, $g_GCShadow] add x12, x13, x12 ; if (pShadow >= $g_GCShadowEnd) goto end adrp x13, $g_GCShadowEnd ldr x13, [x13, $g_GCShadowEnd] cmp x12, x13 bhs shadowupdateend ; *pShadow = x15 str x15, [x12] ; Ensure that the write to the shadow heap occurs before the read from the GC heap so that race ; conditions are caught by INVALIDGCVALUE. dmb ish ; if ([x14] == x15) goto end ldr x13, [x14] cmp x13, x15 beq shadowupdateend ; *pShadow = INVALIDGCVALUE (0xcccccccd) mov x13, #0 movk x13, #0xcccd movk x13, #0xcccc, LSL #16 str x13, [x12] shadowupdateend ldp x12, x13, [sp],#16 #endif ; Branch to Exit if the reference is not in the Gen0 heap ; adrp x12, g_ephemeral_low ldr x12, [x12, g_ephemeral_low] cmp x15, x12 blo Exit adrp x12, g_ephemeral_high ldr x12, [x12, g_ephemeral_high] cmp x15, x12 bhi Exit ; Check if we need to update the card table adrp x12, g_card_table ldr x12, [x12, g_card_table] add x15, x12, x14 lsr #11 ldrb w12, [x15] cmp x12, 0xFF beq Exit UpdateCardTable mov x12, 0xFF strb w12, [x15] Exit add x14, x14, 8 ret lr WRITE_BARRIER_END JIT_WriteBarrier ; ------------------------------------------------------------------ ; Start of the writeable code region LEAF_ENTRY JIT_PatchedCodeStart ret lr LEAF_END ; ------------------------------------------------------------------ ; End of the writeable code region LEAF_ENTRY JIT_PatchedCodeLast ret lr LEAF_END ;------------------------------------------------ ; VirtualMethodFixupStub ; ; In NGEN images, virtual slots inherited from cross-module dependencies ; point to a jump thunk that calls into the following function that will ; call into a VM helper. The VM helper is responsible for patching up ; thunk, upon executing the precode, so that all subsequent calls go directly ; to the actual method body. ; ; This is done lazily for performance reasons. ; ; On entry: ; ; x0 = "this" pointer ; x12 = Address of thunk NESTED_ENTRY VirtualMethodFixupStub ; Save arguments and return address PROLOG_SAVE_REG_PAIR fp, lr, #-160! SAVE_ARGUMENT_REGISTERS sp, 16 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 88 ; Refer to ZapImportVirtualThunk::Save ; for details on this. ; ; Move the thunk start address in x1 mov x1, x12 ; Call the helper in the VM to perform the actual fixup ; and tell us where to tail call. x0 already contains ; the this pointer. bl VirtualMethodFixupWorker ; On return, x0 contains the target to tailcall to mov x12, x0 ; pop the stack and restore original register state RESTORE_ARGUMENT_REGISTERS sp, 16 RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 88 EPILOG_RESTORE_REG_PAIR fp, lr, #160! PATCH_LABEL VirtualMethodFixupPatchLabel ; and tailcall to the actual method EPILOG_BRANCH_REG x12 NESTED_END ;------------------------------------------------ ; ExternalMethodFixupStub ; ; In NGEN images, calls to cross-module external methods initially ; point to a jump thunk that calls into the following function that will ; call into a VM helper. The VM helper is responsible for patching up the ; thunk, upon executing the precode, so that all subsequent calls go directly ; to the actual method body. ; ; This is done lazily for performance reasons. ; ; On entry: ; ; x12 = Address of thunk NESTED_ENTRY ExternalMethodFixupStub PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov x1, x12 ; pThunk bl ExternalMethodFixupWorker ; mov the address we patched to in x12 so that we can tail call to it mov x12, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL PATCH_LABEL ExternalMethodFixupPatchLabel EPILOG_BRANCH_REG x12 NESTED_END ; void SinglecastDelegateInvokeStub(Delegate *pThis) LEAF_ENTRY SinglecastDelegateInvokeStub cmp x0, #0 beq LNullThis ldr x16, [x0, #DelegateObject___methodPtr] ldr x0, [x0, #DelegateObject___target] br x16 LNullThis mov x0, #CORINFO_NullReferenceException_ASM b JIT_InternalThrow LEAF_END #ifdef FEATURE_COMINTEROP ; ------------------------------------------------------------------ ; COM to CLR stub called the first time a particular method is invoked. ; ; On entry: ; x12 : ComCallMethodDesc* provided by prepad thunk ; plus user arguments in registers and on the stack ; ; On exit: ; tail calls to real method ; NESTED_ENTRY ComCallPreStub GBLA ComCallPreStub_FrameSize GBLA ComCallPreStub_StackAlloc GBLA ComCallPreStub_FrameOffset GBLA ComCallPreStub_ErrorReturnOffset GBLA ComCallPreStub_FirstStackAdjust ComCallPreStub_FrameSize SETA (SIZEOF__GSCookie + SIZEOF__ComMethodFrame) ComCallPreStub_FirstStackAdjust SETA (SIZEOF__ArgumentRegisters + 2 * 8) ; reg args , fp & lr already pushed ComCallPreStub_StackAlloc SETA ComCallPreStub_FrameSize - ComCallPreStub_FirstStackAdjust ComCallPreStub_StackAlloc SETA ComCallPreStub_StackAlloc + SIZEOF__FloatArgumentRegisters + 8; 8 for ErrorReturn IF ComCallPreStub_StackAlloc:MOD:16 != 0 ComCallPreStub_StackAlloc SETA ComCallPreStub_StackAlloc + 8 ENDIF ComCallPreStub_FrameOffset SETA (ComCallPreStub_StackAlloc - (SIZEOF__ComMethodFrame - ComCallPreStub_FirstStackAdjust)) ComCallPreStub_ErrorReturnOffset SETA SIZEOF__FloatArgumentRegisters IF (ComCallPreStub_FirstStackAdjust):MOD:16 != 0 ComCallPreStub_FirstStackAdjust SETA ComCallPreStub_FirstStackAdjust + 8 ENDIF ; Save arguments and return address PROLOG_SAVE_REG_PAIR fp, lr, #-ComCallPreStub_FirstStackAdjust! PROLOG_STACK_ALLOC ComCallPreStub_StackAlloc SAVE_ARGUMENT_REGISTERS sp, (16+ComCallPreStub_StackAlloc) SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0 str x12, [sp, #(ComCallPreStub_FrameOffset + UnmanagedToManagedFrame__m_pvDatum)] add x0, sp, #(ComCallPreStub_FrameOffset) add x1, sp, #(ComCallPreStub_ErrorReturnOffset) bl ComPreStubWorker cbz x0, ComCallPreStub_ErrorExit mov x12, x0 ; pop the stack and restore original register state RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 0 RESTORE_ARGUMENT_REGISTERS sp, (16+ComCallPreStub_StackAlloc) EPILOG_STACK_FREE ComCallPreStub_StackAlloc EPILOG_RESTORE_REG_PAIR fp, lr, #ComCallPreStub_FirstStackAdjust! ; and tailcall to the actual method EPILOG_BRANCH_REG x12 ComCallPreStub_ErrorExit ldr x0, [sp, #(ComCallPreStub_ErrorReturnOffset)] ; ErrorReturn ; pop the stack EPILOG_STACK_FREE ComCallPreStub_StackAlloc EPILOG_RESTORE_REG_PAIR fp, lr, #ComCallPreStub_FirstStackAdjust! EPILOG_RETURN NESTED_END ; ------------------------------------------------------------------ ; COM to CLR stub which sets up a ComMethodFrame and calls COMToCLRWorker. ; ; On entry: ; x12 : ComCallMethodDesc* provided by prepad thunk ; plus user arguments in registers and on the stack ; ; On exit: ; Result in x0/d0 as per the real method being called ; NESTED_ENTRY GenericComCallStub GBLA GenericComCallStub_FrameSize GBLA GenericComCallStub_StackAlloc GBLA GenericComCallStub_FrameOffset GBLA GenericComCallStub_FirstStackAdjust GenericComCallStub_FrameSize SETA (SIZEOF__GSCookie + SIZEOF__ComMethodFrame) GenericComCallStub_FirstStackAdjust SETA (SIZEOF__ArgumentRegisters + 2 * 8) GenericComCallStub_StackAlloc SETA GenericComCallStub_FrameSize - GenericComCallStub_FirstStackAdjust GenericComCallStub_StackAlloc SETA GenericComCallStub_StackAlloc + SIZEOF__FloatArgumentRegisters IF (GenericComCallStub_StackAlloc):MOD:16 != 0 GenericComCallStub_StackAlloc SETA GenericComCallStub_StackAlloc + 8 ENDIF GenericComCallStub_FrameOffset SETA (GenericComCallStub_StackAlloc - (SIZEOF__ComMethodFrame - GenericComCallStub_FirstStackAdjust)) IF (GenericComCallStub_FirstStackAdjust):MOD:16 != 0 GenericComCallStub_FirstStackAdjust SETA GenericComCallStub_FirstStackAdjust + 8 ENDIF ; Save arguments and return address PROLOG_SAVE_REG_PAIR fp, lr, #-GenericComCallStub_FirstStackAdjust! PROLOG_STACK_ALLOC GenericComCallStub_StackAlloc SAVE_ARGUMENT_REGISTERS sp, (16+GenericComCallStub_StackAlloc) SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0 str x12, [sp, #(GenericComCallStub_FrameOffset + UnmanagedToManagedFrame__m_pvDatum)] add x1, sp, #GenericComCallStub_FrameOffset bl COMToCLRWorker ; pop the stack EPILOG_STACK_FREE GenericComCallStub_StackAlloc EPILOG_RESTORE_REG_PAIR fp, lr, #GenericComCallStub_FirstStackAdjust! EPILOG_RETURN NESTED_END ; ------------------------------------------------------------------ ; COM to CLR stub called from COMToCLRWorker that actually dispatches to the real managed method. ; ; On entry: ; x0 : dwStackSlots, count of argument stack slots to copy ; x1 : pFrame, ComMethodFrame pushed by GenericComCallStub above ; x2 : pTarget, address of code to call ; x3 : pSecretArg, hidden argument passed to target above in x12 ; x4 : pDangerousThis, managed 'this' reference ; ; On exit: ; Result in x0/d0 as per the real method being called ; NESTED_ENTRY COMToCLRDispatchHelper,,CallDescrWorkerUnwindFrameChainHandler PROLOG_SAVE_REG_PAIR fp, lr, #-16! cbz x0, COMToCLRDispatchHelper_RegSetup add x9, x1, #SIZEOF__ComMethodFrame add x9, x9, x0, LSL #3 COMToCLRDispatchHelper_StackLoop ldr x8, [x9, #-8]! str x8, [sp, #-8]! sub x0, x0, #1 cbnz x0, COMToCLRDispatchHelper_StackLoop COMToCLRDispatchHelper_RegSetup RESTORE_FLOAT_ARGUMENT_REGISTERS x1, -1 * GenericComCallStub_FrameOffset mov lr, x2 mov x12, x3 mov x0, x4 ldp x2, x3, [x1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 16)] ldp x4, x5, [x1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 32)] ldp x6, x7, [x1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 48)] ldr x8, [x1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 64)] ldr x1, [x1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 8)] blr lr EPILOG_STACK_RESTORE EPILOG_RESTORE_REG_PAIR fp, lr, #16! EPILOG_RETURN NESTED_END #endif ; FEATURE_COMINTEROP ; ; x12 = UMEntryThunk* ; NESTED_ENTRY TheUMEntryPrestub,,UMEntryPrestubUnwindFrameChainHandler ; Save arguments and return address PROLOG_SAVE_REG_PAIR fp, lr, #-160! SAVE_ARGUMENT_REGISTERS sp, 16 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 88 mov x0, x12 bl TheUMEntryPrestubWorker ; save real target address in x12. mov x12, x0 ; pop the stack and restore original register state RESTORE_ARGUMENT_REGISTERS sp, 16 RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 88 EPILOG_RESTORE_REG_PAIR fp, lr, #160! ; and tailcall to the actual method EPILOG_BRANCH_REG x12 NESTED_END ; ; x12 = UMEntryThunk* ; NESTED_ENTRY UMThunkStub,,UMThunkStubUnwindFrameChainHandler ; Save arguments and return address PROLOG_SAVE_REG_PAIR fp, lr, #-112! ; 72 for regArgs, 8 for x19 & 8 for x12 & 8 for 16-byte align ; save callee saved reg x19. x19 is used in the method to store thread* PROLOG_SAVE_REG x19, #96 SAVE_ARGUMENT_REGISTERS sp, 16 GBLA UMThunkStub_HiddenArg ; offset of saved UMEntryThunk * GBLA UMThunkStub_StackArgs ; offset of original stack args (total size of UMThunkStub frame) UMThunkStub_HiddenArg SETA 88 UMThunkStub_StackArgs SETA 112 ; save UMEntryThunk* str x12, [sp, #UMThunkStub_HiddenArg] ; assuming GetThread does not clobber FP Args bl GetThread cbz x0, UMThunkStub_DoThreadSetup UMThunkStub_HaveThread mov x19, x0 ; x19 = Thread * mov x9, 1 ; m_fPreemptiveGCDisabled is 4 byte field so using 32-bit variant str w9, [x19, #Thread__m_fPreemptiveGCDisabled] ldr x2, =g_TrapReturningThreads ldr x3, [x2] ; assuming x0 contains Thread* before jumping to UMThunkStub_DoTrapReturningThreads cbnz x3, UMThunkStub_DoTrapReturningThreads UMThunkStub_InCooperativeMode ldr x12, [fp, #UMThunkStub_HiddenArg] ; x12 = UMEntryThunk* ldr x0, [x19, #Thread__m_pDomain] ; m_dwDomainId is 4 bytes so using 32-bit variant ldr w1, [x12, #UMEntryThunk__m_dwDomainId] ldr w0, [x0, #AppDomain__m_dwId] cmp w0, w1 bne UMThunkStub_WrongAppDomain ldr x3, [x12, #UMEntryThunk__m_pUMThunkMarshInfo] ; x3 = m_pUMThunkMarshInfo ; m_cbActualArgSize is UINT32 and hence occupies 4 bytes ldr w2, [x3, #UMThunkMarshInfo__m_cbActualArgSize] ; w2 = Stack arg bytes cbz w2, UMThunkStub_RegArgumentsSetup ; extend to 64-bits uxtw x2, w2 ; Source pointer add x0, fp, #UMThunkStub_StackArgs ; move source pointer to end of Stack Args add x0, x0, x2 ; Count of stack slot pairs to copy (divide by 16) lsr x1, x2, #4 ; Is there an extra stack slot (can happen when stack arg bytes not multiple of 16) and x2, x2, #8 ; If yes then start source pointer from 16 byte aligned stack slot add x0, x0, x2 ; increment stack slot pair count by 1 if x2 is not zero add x1, x1, x2, LSR #3 UMThunkStub_StackLoop ldp x4, x5, [x0, #-16]! ; pre-Index stp x4, x5, [sp, #-16]! ; pre-Index subs x1, x1, #1 bne UMThunkStub_StackLoop UMThunkStub_RegArgumentsSetup ldr x16, [x3, #UMThunkMarshInfo__m_pILStub] RESTORE_ARGUMENT_REGISTERS fp, 16 blr x16 UMThunkStub_PostCall mov x4, 0 ; m_fPreemptiveGCDisabled is 4 byte field so using 32-bit variant str w4, [x19, #Thread__m_fPreemptiveGCDisabled] EPILOG_STACK_RESTORE EPILOG_RESTORE_REG x19, #96 EPILOG_RESTORE_REG_PAIR fp, lr, #112! EPILOG_RETURN UMThunkStub_DoThreadSetup sub sp, sp, #SIZEOF__FloatArgumentRegisters SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0 bl CreateThreadBlockThrow RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 0 add sp, sp, #SIZEOF__FloatArgumentRegisters b UMThunkStub_HaveThread UMThunkStub_DoTrapReturningThreads sub sp, sp, #SIZEOF__FloatArgumentRegisters SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0 ; x0 already contains Thread* pThread ; UMEntryThunk* pUMEntry ldr x1, [fp, #UMThunkStub_HiddenArg] bl UMThunkStubRareDisableWorker RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 0 add sp, sp, #SIZEOF__FloatArgumentRegisters b UMThunkStub_InCooperativeMode UMThunkStub_WrongAppDomain ; Saving FP Args as this is read by UM2MThunk_WrapperHelper sub sp, sp, #SIZEOF__FloatArgumentRegisters SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0 ; UMEntryThunk* pUMEntry ldr x0, [fp, #UMThunkStub_HiddenArg] ; void * pArgs add x2, fp, #16 ; remaining arguments are unused bl UM2MDoADCallBack ; restore any integral return value(s) ldp x0, x1, [fp, #16] ; restore any FP or HFA return value(s) RESTORE_FLOAT_ARGUMENT_REGISTERS sp, 0 b UMThunkStub_PostCall NESTED_END ; UM2MThunk_WrapperHelper(void *pThunkArgs, // x0 ; int cbStackArgs, // x1 (unused) ; void *pAddr, // x2 (unused) ; UMEntryThunk *pEntryThunk, // x3 ; Thread *pThread) // x4 ; pThunkArgs points to the argument registers pushed on the stack by UMThunkStub NESTED_ENTRY UM2MThunk_WrapperHelper PROLOG_SAVE_REG_PAIR fp, lr, #-32! PROLOG_SAVE_REG x19, #16 ; save pThunkArgs in non-volatile reg. It is required after return from call to ILStub mov x19, x0 ; ARM64TODO - Is this required by ILStub mov x12, x3 ; // x12 = UMEntryThunk * ; ; Note that layout of the arguments is given by UMThunkStub frame ; ldr x3, [x3, #UMEntryThunk__m_pUMThunkMarshInfo] ; m_cbActualArgSize is 4-byte field ldr w2, [x3, #UMThunkMarshInfo__m_cbActualArgSize] cbz w2, UM2MThunk_WrapperHelper_RegArgumentsSetup ; extend to 64- bits uxtw x2, w2 ; Source pointer. Subtracting 16 bytes due to fp & lr add x6, x0, #(UMThunkStub_StackArgs-16) ; move source ptr to end of Stack Args add x6, x6, x2 ; Count of stack slot pairs to copy (divide by 16) lsr x1, x2, #4 ; Is there an extra stack slot? (can happen when stack arg bytes not multiple of 16) and x2, x2, #8 ; If yes then start source pointer from 16 byte aligned stack slot add x6, x6, x2 ; increment stack slot pair count by 1 if x2 is not zero add x1, x1, x2, LSR #3 UM2MThunk_WrapperHelper_StackLoop ldp x4, x5, [x6, #-16]! stp x4, x5, [sp, #-16]! subs x1, x1, #1 bne UM2MThunk_WrapperHelper_StackLoop UM2MThunk_WrapperHelper_RegArgumentsSetup ldr x16, [x3, #(UMThunkMarshInfo__m_pILStub)] ; reload floating point registers RESTORE_FLOAT_ARGUMENT_REGISTERS x0, -1 * (SIZEOF__FloatArgumentRegisters + 16) ; reload argument registers RESTORE_ARGUMENT_REGISTERS x0, 0 blr x16 ; save any integral return value(s) stp x0, x1, [x19] ; save any FP or HFA return value(s) SAVE_FLOAT_ARGUMENT_REGISTERS x19, -1 * (SIZEOF__FloatArgumentRegisters + 16) EPILOG_STACK_RESTORE EPILOG_RESTORE_REG x19, #16 EPILOG_RESTORE_REG_PAIR fp, lr, #32! EPILOG_RETURN NESTED_END #ifdef FEATURE_HIJACK ; ------------------------------------------------------------------ ; Hijack function for functions which return a scalar type or a struct (value type) NESTED_ENTRY OnHijackTripThread PROLOG_SAVE_REG_PAIR fp, lr, #-144! ; Spill callee saved registers PROLOG_SAVE_REG_PAIR x19, x20, #16 PROLOG_SAVE_REG_PAIR x21, x22, #32 PROLOG_SAVE_REG_PAIR x23, x24, #48 PROLOG_SAVE_REG_PAIR x25, x26, #64 PROLOG_SAVE_REG_PAIR x27, x28, #80 ; save any integral return value(s) stp x0, x1, [sp, #96] ; save any FP/HFA return value(s) stp d0, d1, [sp, #112] stp d2, d3, [sp, #128] mov x0, sp bl OnHijackWorker ; restore any integral return value(s) ldp x0, x1, [sp, #96] ; restore any FP/HFA return value(s) ldp d0, d1, [sp, #112] ldp d2, d3, [sp, #128] EPILOG_RESTORE_REG_PAIR x19, x20, #16 EPILOG_RESTORE_REG_PAIR x21, x22, #32 EPILOG_RESTORE_REG_PAIR x23, x24, #48 EPILOG_RESTORE_REG_PAIR x25, x26, #64 EPILOG_RESTORE_REG_PAIR x27, x28, #80 EPILOG_RESTORE_REG_PAIR fp, lr, #144! EPILOG_RETURN NESTED_END #endif ; FEATURE_HIJACK ;; ------------------------------------------------------------------ ;; Redirection Stub for GC in fully interruptible method GenerateRedirectedHandledJITCaseStub GCThreadControl ;; ------------------------------------------------------------------ GenerateRedirectedHandledJITCaseStub DbgThreadControl ;; ------------------------------------------------------------------ GenerateRedirectedHandledJITCaseStub UserSuspend #ifdef _DEBUG ; ------------------------------------------------------------------ ; Redirection Stub for GC Stress GenerateRedirectedHandledJITCaseStub GCStress #endif ; ------------------------------------------------------------------ ; This helper enables us to call into a funclet after restoring Fp register NESTED_ENTRY CallEHFunclet ; On entry: ; ; X0 = throwable ; X1 = PC to invoke ; X2 = address of X19 register in CONTEXT record; used to restore the non-volatile registers of CrawlFrame ; X3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. ; ; Using below prolog instead of PROLOG_SAVE_REG_PAIR fp,lr, #-16! ; is intentional. Above statement would also emit instruction to save ; sp in fp. If sp is saved in fp in prolog then it is not expected that fp can change in the body ; of method. However, this method needs to be able to change fp before calling funclet. ; This is required to access locals in funclet. PROLOG_SAVE_REG_PAIR_NO_FP fp,lr, #-96! ; Spill callee saved registers PROLOG_SAVE_REG_PAIR x19, x20, 16 PROLOG_SAVE_REG_PAIR x21, x22, 32 PROLOG_SAVE_REG_PAIR x23, x24, 48 PROLOG_SAVE_REG_PAIR x25, x26, 64 PROLOG_SAVE_REG_PAIR x27, x28, 80 ; Save the SP of this function. We cannot store SP directly. mov fp, sp str fp, [x3] ldp x19, x20, [x2, #0] ldp x21, x22, [x2, #16] ldp x23, x24, [x2, #32] ldp x25, x26, [x2, #48] ldp x27, x28, [x2, #64] ldr fp, [x2, #80] ; offset of fp in CONTEXT relative to X19 ; Invoke the funclet blr x1 nop EPILOG_RESTORE_REG_PAIR x19, x20, 16 EPILOG_RESTORE_REG_PAIR x21, x22, 32 EPILOG_RESTORE_REG_PAIR x23, x24, 48 EPILOG_RESTORE_REG_PAIR x25, x26, 64 EPILOG_RESTORE_REG_PAIR x27, x28, 80 EPILOG_RESTORE_REG_PAIR fp, lr, #96! EPILOG_RETURN NESTED_END CallEHFunclet ; This helper enables us to call into a filter funclet by passing it the CallerSP to lookup the ; frame pointer for accessing the locals in the parent method. NESTED_ENTRY CallEHFilterFunclet PROLOG_SAVE_REG_PAIR fp, lr, #-16! ; On entry: ; ; X0 = throwable ; X1 = SP of the caller of the method/funclet containing the filter ; X2 = PC to invoke ; X3 = address of the location where the SP of funclet's caller (i.e. this helper) should be saved. ; ; Save the SP of this function str fp, [x3] ; Invoke the filter funclet blr x2 EPILOG_RESTORE_REG_PAIR fp, lr, #16! EPILOG_RETURN NESTED_END CallEHFilterFunclet GBLA FaultingExceptionFrame_StackAlloc GBLA FaultingExceptionFrame_FrameOffset FaultingExceptionFrame_StackAlloc SETA (SIZEOF__GSCookie + SIZEOF__FaultingExceptionFrame) FaultingExceptionFrame_FrameOffset SETA SIZEOF__GSCookie MACRO GenerateRedirectedStubWithFrame $STUB, $TARGET ; ; This is the primary function to which execution will be redirected to. ; NESTED_ENTRY $STUB ; ; IN: lr: original IP before redirect ; PROLOG_SAVE_REG_PAIR fp, lr, #-16! PROLOG_STACK_ALLOC FaultingExceptionFrame_StackAlloc ; At this point, the stack maybe misaligned if the thread abort was asynchronously ; triggered in the prolog or epilog of the managed method. For such a case, we must ; align the stack before calling into the VM. ; ; Runtime check for 16-byte alignment. mov x0, sp and x0, x0, #15 sub sp, sp, x0 ; Save pointer to FEF for GetFrameFromRedirectedStubStackFrame add x19, sp, #FaultingExceptionFrame_FrameOffset ; Prepare to initialize to NULL mov x1,#0 str x1, [x19] ; Initialize vtbl (it is not strictly necessary) str x1, [x19, #FaultingExceptionFrame__m_fFilterExecuted] ; Initialize BOOL for personality routine mov x0, x19 ; move the ptr to FEF in X0 bl $TARGET ; Target should not return. EMIT_BREAKPOINT NESTED_END $STUB MEND ; ------------------------------------------------------------------ ; ; Helpers for async (NullRef, AccessViolation) exceptions ; NESTED_ENTRY NakedThrowHelper2,,FixContextHandler PROLOG_SAVE_REG_PAIR fp,lr, #-16! ; On entry: ; ; X0 = Address of FaultingExceptionFrame bl LinkFrameAndThrow ; Target should not return. EMIT_BREAKPOINT NESTED_END NakedThrowHelper2 GenerateRedirectedStubWithFrame NakedThrowHelper, NakedThrowHelper2 ; ------------------------------------------------------------------ ; ResolveWorkerChainLookupAsmStub ; ; This method will perform a quick chained lookup of the entry if the ; initial cache lookup fails. ; ; On Entry: ; x9 contains the pointer to the current ResolveCacheElem ; x11 contains the address of the indirection (and the flags in the low two bits) ; x12 contains our contract the DispatchToken ; Must be preserved: ; x0 contains the instance object ref that we are making an interface call on ; x9 Must point to a ResolveCacheElem [For Sanity] ; [x1-x7] contains any additional register arguments for the interface method ; ; Loaded from x0 ; x13 contains our type the MethodTable (from object ref in x0) ; ; On Exit: ; x0, [x1-x7] arguments for the interface implementation target ; ; On Exit (to ResolveWorkerAsmStub): ; x11 contains the address of the indirection and the flags in the low two bits. ; x12 contains our contract (DispatchToken) ; x16,x17 will be trashed ; GBLA BACKPATCH_FLAG ; two low bit flags used by ResolveWorkerAsmStub GBLA PROMOTE_CHAIN_FLAG ; two low bit flags used by ResolveWorkerAsmStub BACKPATCH_FLAG SETA 1 PROMOTE_CHAIN_FLAG SETA 2 NESTED_ENTRY ResolveWorkerChainLookupAsmStub tst x11, #BACKPATCH_FLAG ; First we check if x11 has the BACKPATCH_FLAG set bne Fail ; If the BACKPATCH_FLAGS is set we will go directly to the ResolveWorkerAsmStub ldr x13, [x0] ; retrieve the MethodTable from the object ref in x0 MainLoop ldr x9, [x9, #ResolveCacheElem__pNext] ; x9 <= the next entry in the chain cmp x9, #0 beq Fail ldp x16, x17, [x9] cmp x16, x13 ; compare our MT with the one in the ResolveCacheElem bne MainLoop cmp x17, x12 ; compare our DispatchToken with one in the ResolveCacheElem bne MainLoop Success ldr x13, =g_dispatch_cache_chain_success_counter ldr x16, [x13] subs x16, x16, #1 str x16, [x13] blt Promote ldr x16, [x9, #ResolveCacheElem__target] ; get the ImplTarget br x16 ; branch to interface implemenation target Promote ; Move this entry to head postion of the chain mov x16, #256 str x16, [x13] ; be quick to reset the counter so we don't get a bunch of contending threads orr x11, x11, #PROMOTE_CHAIN_FLAG ; set PROMOTE_CHAIN_FLAG mov x12, x9 ; We pass the ResolveCacheElem to ResolveWorkerAsmStub instead of the DispatchToken Fail b ResolveWorkerAsmStub ; call the ResolveWorkerAsmStub method to transition into the VM NESTED_END ResolveWorkerChainLookupAsmStub ;; ------------------------------------------------------------------ ;; void ResolveWorkerAsmStub(args in regs x0-x7 & stack and possibly retbuf arg in x8, x11:IndirectionCellAndFlags, x12:DispatchToken) ;; ;; The stub dispatch thunk which transfers control to VSD_ResolveWorker. NESTED_ENTRY ResolveWorkerAsmStub PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock and x1, x11, #-4 ; Indirection cell mov x2, x12 ; DispatchToken and x3, x11, #3 ; flag bl VSD_ResolveWorker mov x9, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG x9 NESTED_END #ifdef FEATURE_READYTORUN NESTED_ENTRY DelayLoad_MethodCall PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov x1, x11 ; Indirection cell mov x2, x9 ; sectionIndex mov x3, x10 ; Module* bl ExternalMethodFixupWorker mov x12, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL ; Share patch label b ExternalMethodFixupPatchLabel NESTED_END MACRO DynamicHelper $frameFlags, $suffix NESTED_ENTRY DelayLoad_Helper$suffix PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov x1, x11 ; Indirection cell mov x2, x9 ; sectionIndex mov x3, x10 ; Module* mov x4, $frameFlags bl DynamicHelperWorker cbnz x0, %FT0 ldr x0, [sp, #__PWTB_ArgumentRegisters] EPILOG_WITH_TRANSITION_BLOCK_RETURN 0 mov x12, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG x12 NESTED_END MEND DynamicHelper DynamicHelperFrameFlags_Default DynamicHelper DynamicHelperFrameFlags_ObjectArg, _Obj DynamicHelper DynamicHelperFrameFlags_ObjectArg | DynamicHelperFrameFlags_ObjectArg2, _ObjObj #endif // FEATURE_READYTORUN #ifdef FEATURE_PREJIT ;; ------------------------------------------------------------------ ;; void StubDispatchFixupStub(args in regs x0-x7 & stack and possibly retbuff arg in x8, x11:IndirectionCellAndFlags, x12:DispatchToken) ;; ;; The stub dispatch thunk which transfers control to StubDispatchFixupWorker. NESTED_ENTRY StubDispatchFixupStub PROLOG_WITH_TRANSITION_BLOCK add x0, sp, #__PWTB_TransitionBlock ; pTransitionBlock and x1, x11, #-4 ; Indirection cell mov x2, #0 ; sectionIndex mov x3, #0 ; pModule bl StubDispatchFixupWorker mov x9, x0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL PATCH_LABEL StubDispatchFixupPatchLabel EPILOG_BRANCH_REG x9 NESTED_END #endif #ifdef FEATURE_COMINTEROP ; ------------------------------------------------------------------ ; Function used by COM interop to get floating point return value (since it's not in the same ; register(s) as non-floating point values). ; ; On entry; ; x0 : size of the FP result (4 or 8 bytes) ; x1 : pointer to 64-bit buffer to receive result ; ; On exit: ; buffer pointed to by x1 on entry contains the float or double argument as appropriate ; LEAF_ENTRY getFPReturn str d0, [x1] LEAF_END ; ------------------------------------------------------------------ ; Function used by COM interop to set floating point return value (since it's not in the same ; register(s) as non-floating point values). ; ; On entry: ; x0 : size of the FP result (4 or 8 bytes) ; x1 : 32-bit or 64-bit FP result ; ; On exit: ; s0 : float result if x0 == 4 ; d0 : double result if x0 == 8 ; LEAF_ENTRY setFPReturn fmov d0, x1 LEAF_END #endif ; ; JIT Static access helpers when coreclr host specifies single appdomain flag ; ; ------------------------------------------------------------------ ; void* JIT_GetSharedNonGCStaticBase(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedNonGCStaticBase_SingleAppDomain ; If class is not initialized, bail to C++ helper add x2, x0, #DomainLocalModule__m_pDataBlob ldrb w2, [x2, w1] tst w2, #1 beq CallHelper1 ret lr CallHelper1 ; Tail call JIT_GetSharedNonGCStaticBase_Helper b JIT_GetSharedNonGCStaticBase_Helper LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedNonGCStaticBaseNoCtor(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedNonGCStaticBaseNoCtor_SingleAppDomain ret lr LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedGCStaticBase(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedGCStaticBase_SingleAppDomain ; If class is not initialized, bail to C++ helper add x2, x0, #DomainLocalModule__m_pDataBlob ldrb w2, [x2, w1] tst w2, #1 beq CallHelper2 ldr x0, [x0, #DomainLocalModule__m_pGCStatics] ret lr CallHelper2 ; Tail call Jit_GetSharedGCStaticBase_Helper b JIT_GetSharedGCStaticBase_Helper LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedGCStaticBaseNoCtor(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedGCStaticBaseNoCtor_SingleAppDomain ldr x0, [x0, #DomainLocalModule__m_pGCStatics] ret lr LEAF_END ; ------------------------------------------------------------------ ;__declspec(naked) void F_CALL_CONV JIT_Stelem_Ref(PtrArray* array, unsigned idx, Object* val) LEAF_ENTRY JIT_Stelem_Ref ; We retain arguments as they were passed and use x0 == array x1 == idx x2 == val ; check for null array cbz x0, ThrowNullReferenceException ; idx bounds check ldr x3,[x0,#ArrayBase__m_NumComponents] cmp x3, x1 bls ThrowIndexOutOfRangeException ; fast path to null assignment (doesn't need any write-barriers) cbz x2, AssigningNull ; Verify the array-type and val-type matches before writing ldr x12, [x0] ; x12 = array MT ldr x3, [x2] ; x3 = val->GetMethodTable() ldr x12, [x12, #MethodTable__m_ElementType] ; array->GetArrayElementTypeHandle() cmp x3, x12 beq JIT_Stelem_DoWrite ; Types didnt match but allow writing into an array of objects ldr x3, =$g_pObjectClass ldr x3, [x3] ; x3 = *g_pObjectClass cmp x3, x12 ; array type matches with Object* beq JIT_Stelem_DoWrite ; array type and val type do not exactly match. Raise frame and do detailed match b JIT_Stelem_Ref_NotExactMatch AssigningNull ; Assigning null doesn't need write barrier add x0, x0, x1, LSL #3 ; x0 = x0 + (x1 x 8) = array->m_array[idx] str x2, [x0, #PtrArray__m_Array] ; array->m_array[idx] = val ret ThrowNullReferenceException ; Tail call JIT_InternalThrow(NullReferenceException) ldr x0, =CORINFO_NullReferenceException_ASM b JIT_InternalThrow ThrowIndexOutOfRangeException ; Tail call JIT_InternalThrow(NullReferenceException) ldr x0, =CORINFO_IndexOutOfRangeException_ASM b JIT_InternalThrow LEAF_END ; ------------------------------------------------------------------ ; __declspec(naked) void F_CALL_CONV JIT_Stelem_Ref_NotExactMatch(PtrArray* array, ; unsigned idx, Object* val) ; x12 = array->GetArrayElementTypeHandle() ; NESTED_ENTRY JIT_Stelem_Ref_NotExactMatch PROLOG_SAVE_REG_PAIR fp, lr, #-48! stp x0, x1, [sp, #16] str x2, [sp, #32] ; allow in case val can be casted to array element type ; call ObjIsInstanceOfNoGC(val, array->GetArrayElementTypeHandle()) mov x1, x12 ; array->GetArrayElementTypeHandle() mov x0, x2 bl ObjIsInstanceOfNoGC cmp x0, TypeHandle_CanCast beq DoWrite ; ObjIsInstance returned TypeHandle::CanCast ; check via raising frame NeedFrame add x1, sp, #16 ; x1 = &array add x0, sp, #32 ; x0 = &val bl ArrayStoreCheck ; ArrayStoreCheck(&val, &array) DoWrite ldp x0, x1, [sp, #16] ldr x2, [sp, #32] EPILOG_RESTORE_REG_PAIR fp, lr, #48! EPILOG_BRANCH JIT_Stelem_DoWrite NESTED_END ; ------------------------------------------------------------------ ; __declspec(naked) void F_CALL_CONV JIT_Stelem_DoWrite(PtrArray* array, unsigned idx, Object* val) LEAF_ENTRY JIT_Stelem_DoWrite ; Setup args for JIT_WriteBarrier. x14 = &array->m_array[idx] x15 = val add x14, x0, #PtrArray__m_Array ; x14 = &array->m_array add x14, x14, x1, LSL #3 mov x15, x2 ; x15 = val ; Branch to the write barrier (which is already correctly overwritten with ; single or multi-proc code based on the current CPU b JIT_WriteBarrier LEAF_END ; Must be at very end of file END
#include <stdlib.h> #include <string.h> #include "vrclient_private.h" #include "vrclient_defs.h" #include "openvr_v0.9.10/openvr.h" using namespace vr; extern "C" { #include "struct_converters.h" #pragma pack(push, 8) struct winRenderModel_TextureMap_t_0910 { uint16_t unWidth; uint16_t unHeight; const uint8_t * rubTextureMapData; RenderModel_TextureMap_t *linux_side; } __attribute__ ((ms_struct)); #pragma pack(pop) void struct_RenderModel_TextureMap_t_0910_lin_to_win(void *l, void *w) { struct winRenderModel_TextureMap_t_0910 *win = (struct winRenderModel_TextureMap_t_0910 *)w; RenderModel_TextureMap_t *lin = (RenderModel_TextureMap_t *)l; win->unWidth = lin->unWidth; win->unHeight = lin->unHeight; win->rubTextureMapData = lin->rubTextureMapData; } void struct_RenderModel_TextureMap_t_0910_win_to_lin(void *w, void *l) { struct winRenderModel_TextureMap_t_0910 *win = (struct winRenderModel_TextureMap_t_0910 *)w; RenderModel_TextureMap_t *lin = (RenderModel_TextureMap_t *)l; lin->unWidth = win->unWidth; lin->unHeight = win->unHeight; lin->rubTextureMapData = win->rubTextureMapData; } struct winRenderModel_TextureMap_t_0910 *struct_RenderModel_TextureMap_t_0910_wrap(void *l) { struct winRenderModel_TextureMap_t_0910 *win = (struct winRenderModel_TextureMap_t_0910 *)malloc(sizeof(*win)); RenderModel_TextureMap_t *lin = (RenderModel_TextureMap_t *)l; win->unWidth = lin->unWidth; win->unHeight = lin->unHeight; win->rubTextureMapData = lin->rubTextureMapData; win->linux_side = lin; return win; } struct RenderModel_TextureMap_t *struct_RenderModel_TextureMap_t_0910_unwrap(winRenderModel_TextureMap_t_0910 *w) { RenderModel_TextureMap_t *ret = w->linux_side; free(w); return ret; } #pragma pack(push, 8) struct winRenderModel_t_0910 { uint64_t ulInternalHandle; const vr::RenderModel_Vertex_t * rVertexData; uint32_t unVertexCount; const uint16_t * rIndexData; uint32_t unTriangleCount; winRenderModel_TextureMap_t_0910 diffuseTexture __attribute__((aligned(4))); RenderModel_t *linux_side; } __attribute__ ((ms_struct)); #pragma pack(pop) void struct_RenderModel_t_0910_lin_to_win(void *l, void *w) { struct winRenderModel_t_0910 *win = (struct winRenderModel_t_0910 *)w; RenderModel_t *lin = (RenderModel_t *)l; win->ulInternalHandle = lin->ulInternalHandle; win->rVertexData = lin->rVertexData; win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; struct_RenderModel_TextureMap_t_0910_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); } void struct_RenderModel_t_0910_win_to_lin(void *w, void *l) { struct winRenderModel_t_0910 *win = (struct winRenderModel_t_0910 *)w; RenderModel_t *lin = (RenderModel_t *)l; lin->ulInternalHandle = win->ulInternalHandle; lin->rVertexData = win->rVertexData; lin->unVertexCount = win->unVertexCount; lin->rIndexData = win->rIndexData; lin->unTriangleCount = win->unTriangleCount; struct_RenderModel_TextureMap_t_0910_win_to_lin(&win->diffuseTexture, &lin->diffuseTexture); } struct winRenderModel_t_0910 *struct_RenderModel_t_0910_wrap(void *l) { struct winRenderModel_t_0910 *win = (struct winRenderModel_t_0910 *)malloc(sizeof(*win)); RenderModel_t *lin = (RenderModel_t *)l; win->ulInternalHandle = lin->ulInternalHandle; win->rVertexData = lin->rVertexData; win->unVertexCount = lin->unVertexCount; win->rIndexData = lin->rIndexData; win->unTriangleCount = lin->unTriangleCount; struct_RenderModel_TextureMap_t_0910_lin_to_win(&lin->diffuseTexture, &win->diffuseTexture); win->linux_side = lin; return win; } struct RenderModel_t *struct_RenderModel_t_0910_unwrap(winRenderModel_t_0910 *w) { RenderModel_t *ret = w->linux_side; free(w); return ret; } #pragma pack(push, 8) struct winVRControllerState001_t_0910 { uint32_t unPacketNum; uint64_t ulButtonPressed; uint64_t ulButtonTouched; vr::VRControllerAxis_t rAxis[5]; } __attribute__ ((ms_struct)); #pragma pack(pop) void struct_VRControllerState001_t_0910_lin_to_win(void *l, void *w, uint32_t sz) { struct winVRControllerState001_t_0910 *win = (struct winVRControllerState001_t_0910 *)w; VRControllerState001_t *lin = (VRControllerState001_t *)l; win->unPacketNum = lin->unPacketNum; win->ulButtonPressed = lin->ulButtonPressed; win->ulButtonTouched = lin->ulButtonTouched; memcpy(win->rAxis, lin->rAxis, sizeof(win->rAxis)); } void struct_VRControllerState001_t_0910_win_to_lin(void *w, void *l) { struct winVRControllerState001_t_0910 *win = (struct winVRControllerState001_t_0910 *)w; VRControllerState001_t *lin = (VRControllerState001_t *)l; lin->unPacketNum = win->unPacketNum; lin->ulButtonPressed = win->ulButtonPressed; lin->ulButtonTouched = win->ulButtonTouched; memcpy(lin->rAxis, win->rAxis, sizeof(lin->rAxis)); } #pragma pack(push, 8) struct winCompositor_FrameTiming_0910 { uint32_t size; double frameStart; float frameVSync; uint32_t droppedFrames; uint32_t frameIndex; vr::TrackedDevicePose_t pose __attribute__((aligned(4))); float prediction; float m_flFrameIntervalMs; float m_flSceneRenderCpuMs; float m_flSceneRenderGpuMs; float m_flCompositorRenderCpuMs; float m_flCompositorRenderGpuMs; float m_flPresentCallCpuMs; float m_flRunningStartMs; } __attribute__ ((ms_struct)); #pragma pack(pop) void struct_Compositor_FrameTiming_0910_lin_to_win(void *l, void *w) { struct winCompositor_FrameTiming_0910 *win = (struct winCompositor_FrameTiming_0910 *)w; Compositor_FrameTiming *lin = (Compositor_FrameTiming *)l; win->size = sizeof(*win); win->frameStart = lin->frameStart; win->frameVSync = lin->frameVSync; win->droppedFrames = lin->droppedFrames; win->frameIndex = lin->frameIndex; win->pose = lin->pose; win->prediction = lin->prediction; win->m_flFrameIntervalMs = lin->m_flFrameIntervalMs; win->m_flSceneRenderCpuMs = lin->m_flSceneRenderCpuMs; win->m_flSceneRenderGpuMs = lin->m_flSceneRenderGpuMs; win->m_flCompositorRenderCpuMs = lin->m_flCompositorRenderCpuMs; win->m_flCompositorRenderGpuMs = lin->m_flCompositorRenderGpuMs; win->m_flPresentCallCpuMs = lin->m_flPresentCallCpuMs; win->m_flRunningStartMs = lin->m_flRunningStartMs; } void struct_Compositor_FrameTiming_0910_win_to_lin(void *w, void *l) { struct winCompositor_FrameTiming_0910 *win = (struct winCompositor_FrameTiming_0910 *)w; Compositor_FrameTiming *lin = (Compositor_FrameTiming *)l; lin->size = sizeof(*lin); lin->frameStart = win->frameStart; lin->frameVSync = win->frameVSync; lin->droppedFrames = win->droppedFrames; lin->frameIndex = win->frameIndex; lin->pose = win->pose; lin->prediction = win->prediction; lin->m_flFrameIntervalMs = win->m_flFrameIntervalMs; lin->m_flSceneRenderCpuMs = win->m_flSceneRenderCpuMs; lin->m_flSceneRenderGpuMs = win->m_flSceneRenderGpuMs; lin->m_flCompositorRenderCpuMs = win->m_flCompositorRenderCpuMs; lin->m_flCompositorRenderGpuMs = win->m_flCompositorRenderGpuMs; lin->m_flPresentCallCpuMs = win->m_flPresentCallCpuMs; lin->m_flRunningStartMs = win->m_flRunningStartMs; } }
db 0 ; species ID placeholder db 111, 83, 68, 39, 92, 82 ; hp atk def spd sat sdf db WATER, GROUND ; type db 75 ; catch rate db 166 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/gastrodon/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_INDETERMINATE, EGG_WATER_1 ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, TOXIC, ROCK_SMASH, HIDDEN_POWER, SNORE, BLIZZARD, HYPER_BEAM, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, EARTHQUAKE, RETURN, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, SANDSTORM, DEFENSE_CURL, REST, ATTRACT, SURF, STRENGTH, FLASH, WHIRLPOOL, WATERFALL, ICE_BEAM ; end
; A011750: Expansion of (1 + x^2)/(1 + x + x^2 + x^3 + x^5) mod 2. ; 1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,1,0,0,1,0,0,1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,0,1,1,0 seq $0,70614 ; a(n) = n^5 mod 31. sub $0,1 trn $0,1 bin $0,4 add $0,1 mod $0,2
; A293145: a(n) = n! * [x^n] exp(n*x/(1 - x)). ; Submitted by Jon Maiga ; 1,1,8,99,1696,37225,997056,31535371,1150303232,47538819729,2195314048000,112032721984051,6261138045038592,380309520560089081,24946892219825709056,1757549042234670166875,132356128415391650676736,10610067001068927596601889,902057202129607760380428288,81072484653018865939240247299,7680104492039080430177484800000,764843632729506875340946212769161,79883382761958958136335536643637248,8731298047434559464179120299681685419,996739671046394426814436741142236102656 mov $2,1 mov $3,$0 mov $4,1 lpb $3 mul $2,$3 div $2,$4 mul $2,$0 sub $3,1 max $3,1 add $4,1 add $5,1 add $6,$2 mul $6,$5 lpe add $6,$2 mov $0,$6
;; Licensed to the .NET Foundation under one or more agreements. ;; The .NET Foundation licenses this file to you under the MIT license. ;; See the LICENSE file in the project root for more information. .586 .model flat option casemap:none .code include AsmMacros.inc ifdef FEATURE_DYNAMIC_CODE ;; ;; Defines an assembly thunk used to make a transition from managed code to a callee, ;; then (based on the return value from the callee), either returning or jumping to ;; a new location while preserving the input arguments. The usage of this thunk also ;; ensures arguments passed are properly reported. ;; ;; TODO: This code currently only tailcalls, and does not return. ;; ;; Inputs: ;; ecx, edx, stack space three pops down: arguments as normal ;; first register sized fields on the stack is the location of the target code ;; the UniversalTransitionThunk will call ;; second register sized field on the stack is the parameter to the target function ;; followed by the return address of the whole method. (This method cannot be called ;; via a call instruction, it must be jumped to.) The fake entrypoint is in place to ;; convince the stack walker this is a normal framed function. ;; ;; NOTE! FOR CORRECTNESS THIS FUNCTION REQUIRES THAT ALL NON-LEAF MANAGED FUNCTIONS HAVE ;; FRAME POINTERS, OR THE STACK WALKER CAN'T STACKWALK OUT OF HERE ;; ; ; Frame layout is: ; ; {StackPassedArgs} ChildSP+018 CallerSP+000 ; {CallerRetaddr} ChildSP+014 CallerSP-004 ; {CallerEBP} ChildSP+010 CallerSP-008 ; {ReturnBlock (0x8 bytes)} ChildSP+008 CallerSP-010 ; -- On input (i.e., when control jumps to RhpUniversalTransition), the low 4 bytes of ; the ReturnBlock area holds the address of the callee and the high 4 bytes holds the ; extra argument to pass to the callee. ; {IntArgRegs (edx,ecx) (0x8 bytes)} ChildSP+000 CallerSP-018 ; {CalleeRetaddr} ChildSP-004 CallerSP-01c ; ; NOTE: If the frame layout ever changes, the C++ UniversalTransitionStackFrame structure ; must be updated as well. ; ; NOTE: The callee receives a pointer to the base of the pushed IntArgRegs, and the callee ; has knowledge of the exact layout of the entire frame. ; ; NOTE: The stack walker guarantees that conservative GC reporting will be applied to ; everything between the base of the IntArgRegs and the top of the StackPassedArgs. ; UNIVERSAL_TRANSITION macro FunctionName FASTCALL_FUNC Rhp&FunctionName&_FAKE_ENTRY, 0 ; Set up an ebp frame push ebp mov ebp, esp push eax push eax ALTERNATE_ENTRY Rhp&FunctionName&@0 push ecx push edx ; ; Call out to the target, while storing and reporting arguments to the GC. ; mov eax, [ebp-8] ; Get the address of the callee mov edx, [ebp-4] ; Get the extra argument to pass to the callee lea ecx, [ebp-10h] ; Get pointer to edx value pushed above call eax EXPORT_POINTER_TO_ADDRESS _PointerToReturnFrom&FunctionName ; We cannot make the label public as that tricks DIA stackwalker into thinking ; it's the beginning of a method. For this reason we export an auxiliary variable ; holding the address instead. pop edx pop ecx add esp, 8 pop ebp jmp eax FASTCALL_ENDFUNC endm ; To enable proper step-in behavior in the debugger, we need to have two instances ; of the thunk. For the first one, the debugger steps into the call in the function, ; for the other, it steps over it. UNIVERSAL_TRANSITION UniversalTransition UNIVERSAL_TRANSITION UniversalTransition_DebugStepTailCall endif end
; void p_stack_init(void *p) SECTION code_adt_p_stack PUBLIC p_stack_init defc p_stack_init = asm_p_stack_init INCLUDE "adt/p_stack/z80/asm_p_stack_init.asm"
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %r8 push %r9 push %rcx push %rdi push %rsi lea addresses_D_ht+0x42d, %rsi lea addresses_A_ht+0x2a2d, %rdi nop nop nop nop nop sub %r8, %r8 mov $62, %rcx rep movsw inc %rcx lea addresses_A_ht+0x8c5d, %r15 nop nop nop dec %rsi mov $0x6162636465666768, %r9 movq %r9, (%r15) nop nop add $2500, %r8 lea addresses_WT_ht+0xc52d, %rcx nop nop inc %r13 mov (%rcx), %r9w nop nop nop nop inc %rcx lea addresses_WC_ht+0x1e78f, %rsi lea addresses_UC_ht+0x1ba2d, %rdi nop sub $27011, %r14 mov $114, %rcx rep movsw nop nop nop inc %r13 pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %rax push %rbx push %rdx push %rsi // Load lea addresses_RW+0xc7ad, %r13 dec %rbx vmovups (%r13), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdx cmp %r11, %r11 // Store lea addresses_RW+0x1de2d, %rsi cmp %rax, %rax mov $0x5152535455565758, %r13 movq %r13, %xmm3 vmovups %ymm3, (%rsi) nop and %rbx, %rbx // Store lea addresses_US+0x18b2d, %rbx nop nop nop nop and $40652, %r13 mov $0x5152535455565758, %rax movq %rax, (%rbx) nop nop xor %rsi, %rsi // Store lea addresses_RW+0x1ba8d, %r13 nop and %rsi, %rsi movb $0x51, (%r13) nop xor %rbx, %rbx // Store lea addresses_WC+0xf7bb, %rbx nop nop nop nop xor %r13, %r13 movw $0x5152, (%rbx) nop nop nop and $53208, %rdx // Store lea addresses_D+0x14a2d, %r12 nop nop nop cmp %r13, %r13 movb $0x51, (%r12) and $10556, %rax // Store lea addresses_D+0x2a2d, %rdx nop nop nop nop and %rsi, %rsi movl $0x51525354, (%rdx) nop nop nop nop inc %r13 // Store lea addresses_RW+0x1ff38, %rsi clflush (%rsi) nop nop nop nop and $1197, %r11 movb $0x51, (%rsi) nop nop nop nop nop inc %rax // Faulty Load lea addresses_PSE+0x22d, %rax nop nop nop nop cmp %rdx, %rdx vmovups (%rax), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r13 lea oracles, %r11 and $0xff, %r13 shlq $12, %r13 mov (%r11,%r13,1), %r13 pop %rsi pop %rdx pop %rbx pop %rax pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': True, 'congruent': 8, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A164094: a(n) = 3*2^n + 2. ; 5,8,14,26,50,98,194,386,770,1538,3074,6146,12290,24578,49154,98306,196610,393218,786434,1572866,3145730,6291458,12582914,25165826,50331650,100663298,201326594,402653186,805306370,1610612738,3221225474,6442450946,12884901890,25769803778,51539607554,103079215106,206158430210,412316860418,824633720834,1649267441666,3298534883330,6597069766658,13194139533314,26388279066626,52776558133250,105553116266498,211106232532994,422212465065986,844424930131970,1688849860263938,3377699720527874,6755399441055746,13510798882111490,27021597764222978,54043195528445954,108086391056891906,216172782113783810,432345564227567618,864691128455135234,1729382256910270466,3458764513820540930,6917529027641081858,13835058055282163714,27670116110564327426,55340232221128654850,110680464442257309698,221360928884514619394,442721857769029238786,885443715538058477570,1770887431076116955138,3541774862152233910274,7083549724304467820546,14167099448608935641090,28334198897217871282178,56668397794435742564354,113336795588871485128706,226673591177742970257410,453347182355485940514818,906694364710971881029634,1813388729421943762059266,3626777458843887524118530,7253554917687775048237058,14507109835375550096474114,29014219670751100192948226,58028439341502200385896450,116056878683004400771792898,232113757366008801543585794,464227514732017603087171586,928455029464035206174343170,1856910058928070412348686338,3713820117856140824697372674,7427640235712281649394745346,14855280471424563298789490690,29710560942849126597578981378,59421121885698253195157962754,118842243771396506390315925506,237684487542793012780631851010,475368975085586025561263702018,950737950171172051122527404034,1901475900342344102245054808066 mov $1,2 pow $1,$0 mul $1,3 add $1,2 mov $0,$1
; A181983: a(n) = (-1)^(n+1) * n. ; 0,1,-2,3,-4,5,-6,7,-8,9,-10,11,-12,13,-14,15,-16,17,-18,19,-20,21,-22,23,-24,25,-26,27,-28,29,-30,31,-32,33,-34,35,-36,37,-38,39,-40,41,-42,43,-44,45,-46,47,-48,49,-50,51,-52,53,-54,55,-56,57,-58,59 sub $0,1 mov $1,-2 bin $1,$0 mov $0,$1
; Copyright 2011-2017 Mersenne Research, Inc. All rights reserved ; Author: George Woltman ; Email: woltman@alum.mit.edu ; ; These routines implement the AVX version of normalization part of a r4dwpn (radix-4 delayed with partial normalization) FFT. ; TITLE setup IFNDEF X86_64 .686 .XMM .MODEL FLAT ENDIF INCLUDE unravel.mac INCLUDE extrn.mac INCLUDE yarch.mac INCLUDE ybasics.mac INCLUDE ymult.mac INCLUDE ynormal.mac _TEXT SEGMENT ;; ;; Routines to do the normalization after a multiply ;; ; Macro to loop through all the FFT values and apply the proper normalization ; routine. IFNDEF X86_64 saved_rsi EQU PPTR [rsp+first_local] loopcount1 EQU DPTR [rsp+first_local+SZPTR] loopcount2 EQU DPTR [rsp+first_local+SZPTR+4] loopcount3 EQU DPTR [rsp+first_local+SZPTR+8] blk8_counter EQU BYTE PTR [rsp+first_local+SZPTR+12] inorm MACRO lab, ttp, zero, echk, const, base2 LOCAL noadd, ilp0, ilp1, ilp2, not8, done PROCFLP lab int_prolog SZPTR+16,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error no zero mov edx, ADDIN_ROW ;; Is this the time to do our addin? no zero cmp edx, THIS_BLOCK no zero jne short noadd ;; Jump if addin does not occur now no zero mov edi, ADDIN_OFFSET ;; Get address to add value into no zero vmovsd xmm0, ADDIN_VALUE ;; Get the requested add-in value no zero vaddsd xmm0, xmm0, Q [rsi][rdi] ;; Add in the FFT value no zero vmovsd Q [rsi][rdi], xmm0 ;; Save the new value noadd: mov saved_rsi, rsi ;; Save for top_carry_adjust ynorm_wpn_preload ttp, base2, zero, echk, const mov rdx, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries mov rdi, norm_ptr1 ;; Load big/little & fudge flags array ptr mov blk8_counter, 0 ;; Clear counter mov eax, count3 ;; Load count of grp multipliers mov loopcount3, eax ;; Save loop counter ttp movzx rbx, WORD PTR [rdi] ;; Preload 4 big vs. little & fudge flags ilp0: mov eax, count2 ;; Load wpn count mov loopcount2, eax ;; Save count ilp1: mov eax, cache_line_multiplier ;; Load inner loop counter mov loopcount1, rax ;; Save loop counter vmovapd ymm2, [rbp+0*32] ;; Load carries vmovapd ymm3, [rbp+1*32] ilp2: ynorm_wpn ttp, base2, zero, echk, const ;; Normalize 8 values bump rsi, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags sub loopcount1, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ystore [rbp+0*32], ymm2 ;; Save carries ystore [rbp+1*32], ymm3 add rsi, normblkdst ;; Add 0 or 64 every clmblkdst bump rbp, 64 ;; Next set of carries add blk8_counter, 80h/4 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub loopcount2, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp bump rdx, 2*YMM_GMD ;; Next set of group multipliers sub loopcount3, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error ; Handle adjusting the carry out of the topmost FFT word mov eax, THIS_BLOCK ;; Check for processing last block cmp eax, LAST_PASS1_BLOCK ;; BUG - should we jump to 4 common top carry propagate end codes? does it save much? there are a lot of inorm variants! jne done ;; Jump if not last block mov rsi, saved_rsi ;; Restore FFT data ptr ;; BUG - isn't rbp pointing just past last carry?? isn't last carry in ymm5 now? ynorm_top_carry_wpn doesn't use this info ttp ynorm_top_carry_wpn ttp, base2 ;; Adjust carry if k > 1 done: int_epilog SZPTR+16,0,0 ENDPP lab ENDM ELSE IFDEF YIMPL_WPN1_FFTS saved_rsi EQU PPTR [rsp+first_local] loopcount1 EQU DPTR [rsp+first_local+SZPTR] loopcount2 EQU DPTR [rsp+first_local+SZPTR+4] loopcount3 EQU DPTR [rsp+first_local+SZPTR+8] blk8_counter EQU BYTE PTR [rsp+first_local+SZPTR+12] inorm MACRO lab, ttp, zero, echk, const, base2 LOCAL noadd, noinc, ilp0, ilp1, ilp2, not8, done PROCFLP lab int_prolog SZPTR+16,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error no zero mov edx, ADDIN_ROW ;; Is this the time to do our addin? no zero cmp edx, THIS_BLOCK no zero jne short noadd ;; Jump if addin does not occur now no zero mov edi, ADDIN_OFFSET ;; Get address to add value into no zero vmovsd xmm0, ADDIN_VALUE ;; Get the requested add-in value no zero vaddsd xmm0, xmm0, Q [rsi][rdi] ;; Add in the FFT value no zero vmovsd Q [rsi][rdi], xmm0 ;; Save the new value noadd: mov saved_rsi, rsi ;; Save for top_carry_adjust ynorm_wpn_preload ttp, base2, zero, echk, const mov r12, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries ttp mov rdi, norm_ptr1 ;; Load big/little & fudge flags array ptr mov blk8_counter, 0 ;; Clear counter mov eax, count5 ;; Load count of grp multipliers (divided by 2) mov loopcount3, eax ;; Save loop counter ilp0: mov eax, count4 ;; Load wpn count (divided by 2) mov loopcount2, eax ;; Save count mov r15, r12 ;; Calc 2nd group multiplier pointer ttp cmp count2, 1 ;; If count is one, 2nd group multiplier must point to the next group ttp jne short noinc ;; If count2 is more than one, 2nd group multiplier is same as 1st group multiplier ttp bump r15, 2*YMM_GMD ;; Bump 2nd group multiplier pointer noinc: ttp lea r9, [r15+2*YMM_GMD] ;; Prefetch pointer for group multipliers ilp1: mov eax, cache_line_multiplier ;; Load inner loop counter mov loopcount1, eax ;; Save loop counter ttp lea r14, [rdi+2*rax] ;; Calc 2nd big/lit ptr shl rax, 6 ;; Calc 2nd src pointer (rsi + clm * 64 + normblkdst) lea r13, [rsi+rax] add r13, normblkdst ;; OPTIMIZATION - old wpn didn't reload rbx every clm block. Rearranging big/lit data could achieve this as well (and can save the r14 register in ynorm_wpn) ttp movzx rbx, WORD PTR [rdi] ;; Preload 4 big vs. little & fudge flags ttp movzx rcx, WORD PTR [r14] ;; Preload 4 big vs. little & fudge flags vmovapd ymm2, [rbp+0*32] ;; Load carries vmovapd ymm3, [rbp+1*32] vmovapd ymm9, [rbp+2*32] vmovapd ymm10, [rbp+3*32] ilp2: ynorm_wpn ttp, base2, zero, echk, const ;; Normalize 2 sets of 8 values bump rsi, 64 ;; Next cache line bump r13, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags ttp bump r14, 2 ;; Next big/little flags sub loopcount1, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ystore [rbp+0*32], ymm2 ;; Save carries ystore [rbp+1*32], ymm3 ystore [rbp+2*32], ymm9 ystore [rbp+3*32], ymm10 bump rbp, 4*32 ;; Next set of carries ttp mov rdi, r14 ;; Calculate address of next big/lit ptr mov rsi, r13 ;; Calculate address of next source add rsi, normblkdst ;; Add 0 or 64 every clmblkdst add blk8_counter, 80h/2 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub loopcount2, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp lea r12, [r15+2*YMM_GMD] ;; Next set of group multipliers sub loopcount3, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error ; Handle adjusting the carry out of the topmost FFT word mov eax, THIS_BLOCK ;; Check for processing last block cmp eax, LAST_PASS1_BLOCK ;; BUG - should we jump to 4 common top carry propagate end codes? does it save much? there are a lot of inorm variants! jne done ;; Jump if not last block mov rsi, saved_rsi ;; Restore FFT data ptr ;; BUG - isn't rbp pointing just past last carry?? isn't last carry in ymm5 now? ynorm_top_carry_wpn doesn't use this info ynorm_top_carry_wpn ttp, base2 ;; Adjust carry if k > 1 done: int_epilog SZPTR+16,0,0 ENDPP lab ENDM ENDIF ;; In wpn4 FFTs we know count2 will be even. Consequently, we only need one group pointer in ynorm_wpn IFDEF YIMPL_WPN4_FFTS saved_rsi EQU PPTR [rsp+first_local] loopcount2 EQU DPTR [rsp+first_local+SZPTR+0] loopcount3 EQU DPTR [rsp+first_local+SZPTR+4] blk8_counter EQU BYTE PTR [rsp+first_local+SZPTR+8] inorm MACRO lab, ttp, zero, echk, const, base2 LOCAL noadd, ilp0, ilp1, ilp2, not8, done PROCFLP lab int_prolog SZPTR+12,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error no zero mov edx, ADDIN_ROW ;; Is this the time to do our addin? no zero cmp edx, THIS_BLOCK no zero jne short noadd ;; Jump if addin does not occur now no zero mov edi, ADDIN_OFFSET ;; Get address to add value into no zero vmovsd xmm0, ADDIN_VALUE ;; Get the requested add-in value no zero vaddsd xmm0, xmm0, Q [rsi][rdi] ;; Add in the FFT value no zero vmovsd Q [rsi][rdi], xmm0 ;; Save the new value noadd: mov saved_rsi, rsi ;; Save for top_carry_adjust ynorm_wpn_preload ttp, base2, zero, echk, const mov r12, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries ttp mov rdi, norm_ptr1 ;; Load big/little & fudge flags array ptr mov blk8_counter, 0 ;; Clear counter mov eax, count5 ;; Load count of grp multipliers (divided by 2) mov loopcount3, eax ;; Save loop counter ilp0: mov eax, count4 ;; Load wpn count (divided by 2) mov loopcount2, eax ;; Save count ttp lea r9, [r12+2*YMM_GMD] ;; Prefetch pointer for group multipliers ilp1: mov eax, cache_line_multiplier ;; Load inner loop counter mov r15, rax ;; Save loop counter ttp lea r14, [rdi+2*rax] ;; Calc 2nd big/lit ptr shl rax, 6 ;; Calc 2nd src pointer (rsi + clm * 64 + normblkdst) lea r13, [rsi+rax] add r13, normblkdst ;; OPTIMIZATION - old wpn didn't reload rbx every clm block. Rearranging big/lit data could achieve this as well (and can save the r14 register in ynorm_wpn) ttp movzx rbx, WORD PTR [rdi] ;; Preload 4 big vs. little & fudge flags ttp movzx rcx, WORD PTR [r14] ;; Preload 4 big vs. little & fudge flags vmovapd ymm2, [rbp+0*32] ;; Load carries vmovapd ymm3, [rbp+1*32] vmovapd ymm9, [rbp+2*32] vmovapd ymm10, [rbp+3*32] ilp2: ynorm_wpn ttp, base2, zero, echk, const ;; Normalize 2 sets of 8 values bump rsi, 64 ;; Next cache line bump r13, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags ttp bump r14, 2 ;; Next big/little flags sub r15, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ystore [rbp+0*32], ymm2 ;; Save carries ystore [rbp+1*32], ymm3 ystore [rbp+2*32], ymm9 ystore [rbp+3*32], ymm10 bump rbp, 4*32 ;; Next set of carries ttp mov rdi, r14 ;; Calculate address of next big/lit ptr mov rsi, r13 ;; Calculate address of next source add rsi, normblkdst ;; Add 0 or 64 every clmblkdst add blk8_counter, 80h/2 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub loopcount2, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp lea r12, [r12+2*YMM_GMD] ;; Next set of group multipliers sub loopcount3, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error ; Handle adjusting the carry out of the topmost FFT word mov eax, THIS_BLOCK ;; Check for processing last block cmp eax, LAST_PASS1_BLOCK ;; BUG - should we jump to 4 common top carry propagate end codes? does it save much? there are a lot of inorm variants! jne done ;; Jump if not last block mov rsi, saved_rsi ;; Restore FFT data ptr ;; BUG - isn't rbp pointing just past last carry?? isn't last carry in ymm5 now? ynorm_top_carry_wpn doesn't use this info ynorm_top_carry_wpn ttp, base2 ;; Adjust carry if k > 1 done: int_epilog SZPTR+12,0,0 ENDPP lab ENDM ENDIF ENDIF IFNDEF X86_64 loopcount2z EQU DPTR [rsp+first_local] loopcount3z EQU DPTR [rsp+first_local+4] blk8_counterz EQU BYTE PTR [rsp+first_local+8] zpnorm MACRO lab, ttp, echk, const, base2, khi, c1, cm1 LOCAL ilp0, ilp1, ilp2, not8 PROCFLP lab int_prolog 12,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error ynorm_wpn_zpad_preload ttp, base2, echk, const, khi, c1, cm1 mov rdx, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries mov rdi, norm_ptr1 ;; Load big/little flags array ptr mov blk8_counterz, 0 ;; Clear counter mov eax, count3 ;; Load count of grp multipliers mov loopcount3z, eax ;; Save loop counter ttp movzx rbx, WORD PTR [rdi] ;; Preload big vs. little & fudge flags ilp0: mov eax, count2 ;; Load wpn count mov loopcount2z, eax ;; Save loop counter ilp1: mov ecx, cache_line_multiplier ;; Load inner loop counter ystore ymm2, [rbp+0*32] ;; Preload carries ystore ymm3, [rbp+1*32] ilp2: ynorm_wpn_zpad ttp, base2, echk, const, khi, c1, cm1 ;; Normalize 8 values bump rsi, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags sub rcx, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ystore [rbp+0*32], ymm2 ;; Store carries ystore [rbp+1*32], ymm3 add rsi, normblkdst ;; Add 0 or 64 every clmblkdst bump rbp, 64 ;; Next set of carries add blk8_counterz, 80h/4 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub loopcount2z, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp bump rdx, YMM_GMD ;; Next set of group multipliers sub loopcount3z, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error int_epilog 12,0,0 ENDPP lab ENDM ELSE IFDEF YIMPL_WPN1_FFTS loopcount2z EQU DPTR [rsp+first_local+0] zpnorm MACRO lab, ttp, echk, const, base2, khi, c1, cm1 LOCAL noinc, ilp0, ilp1, ilp2, not8 PROCFLP lab int_prolog 4,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error ynorm_wpn_zpad_preload ttp, base2, echk, const, khi, c1, cm1 mov r12, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries mov rdi, norm_ptr1 ;; Load big/little flags array ptr mov eax, count5 ;; Load count of grp multipliers (divided by 2) mov r10, rax ;; Save loop counter ilp0: mov eax, count4 ;; Load wpn count (divided by 2) mov loopcount2z, eax ;; Save loop counter mov r15, r12 ;; Calc 2nd group multiplier pointer ttp cmp count2, 1 ;; If count is one, 2nd group multiplier must point to the next group ttp jne short noinc ;; If count2 is more than one, 2nd group multiplier is same as 1st group multiplier ttp bump r15, YMM_GMD ;; Bump 2nd group multiplier pointer noinc: ttp lea r9, [r15+YMM_GMD] ;; Prefetch pointer for group multipliers ilp1: mov eax, cache_line_multiplier ;; Load inner loop counter mov r8, rax ;; Save loop counter ttp lea r14, [rdi+2*rax] ;; Calc 2nd big/lit ptr shl rax, 6 ;; Calc 2nd src pointer (rsi + clm * 64 + normblkdst) lea r13, [rsi+rax] add r13, normblkdst ;; OPTIMIZATION - old wpn didn't reload rbx every clm block. Rearranging big/lit data could achieve this as well (and can save the r14 register in ynorm_wpn) ttp movzx rbx, WORD PTR [rdi] ;; Preload 4 big vs. little & fudge flags ttp movzx rcx, WORD PTR [r14] ;; Preload 4 big vs. little & fudge flags vmovapd ymm2, [rbp+0*32] ;; Preload carries vmovapd ymm3, [rbp+1*32] vmovapd ymm9, [rbp+2*32] vmovapd ymm10, [rbp+3*32] ;; OPTIMZATION - always store carries 3/10 in the +BIGVAL format IF (@INSTR(,%yarch,<FMA3>) NE 0) vaddpd ymm3, ymm3, ymm12 ;; Add in YMM_BIGVAL vaddpd ymm10, ymm10, ymm12 ENDIF ilp2: ynorm_wpn_zpad ttp, base2, echk, const, khi, c1, cm1 ;; Normalize 2 sets of 8 values bump rsi, 64 ;; Next cache line bump r13, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags ttp bump r14, 2 ;; Next big/little flags sub r8, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ;; OPTIMZATION - always store carries 3/10 in the +BIGVAL format IF (@INSTR(,%yarch,<FMA3>) NE 0) vsubpd ymm3, ymm3, ymm12 ;; Subtract out YMM_BIGVAL vsubpd ymm10, ymm10, ymm12 ENDIF ystore [rbp+0*32], ymm2 ;; Store carries ystore [rbp+1*32], ymm3 ystore [rbp+2*32], ymm9 ystore [rbp+3*32], ymm10 bump rbp, 4*32 ;; Next set of carries ttp mov rdi, r14 ;; Calculate address of next big/lit ptr mov rsi, r13 ;; Calculate address of next source add rsi, normblkdst ;; Add 0 or 64 every clmblkdst add r10w, 8000h/2 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub loopcount2z, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp lea r12, [r15+YMM_GMD] ;; Next set of group multipliers sub r10w, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error int_epilog 4,0,0 ENDPP lab ENDM ENDIF ;; In wpn4 FFTs we know count2 will be even. Consequently, we only need one group pointer in ynorm_wpn IFDEF YIMPL_WPN4_FFTS zpnorm MACRO lab, ttp, echk, const, base2, khi, c1, cm1 LOCAL ilp0, ilp1, ilp2, not8 PROCFLP lab int_prolog 0,0,0 echk vmovapd ymm6, YMM_MAXERR ;; Load maximum error ynorm_wpn_zpad_preload ttp, base2, echk, const, khi, c1, cm1 mov r12, norm_grp_mults ;; Addr of the group multipliers mov rbp, carries ;; Addr of the carries mov rdi, norm_ptr1 ;; Load big/little flags array ptr mov eax, count5 ;; Load count of grp multipliers (divided by 2) mov r10, rax ;; Save loop counter ilp0: mov eax, count4 ;; Load wpn count (divided by 2) mov r15, rax ;; Save loop counter ttp lea r9, [r12+YMM_GMD] ;; Prefetch pointer for group multipliers ilp1: mov eax, cache_line_multiplier ;; Load inner loop counter mov r8, rax ;; Save loop counter ttp lea r14, [rdi+2*rax] ;; Calc 2nd big/lit ptr shl rax, 6 ;; Calc 2nd src pointer (rsi + clm * 64 + normblkdst) lea r13, [rsi+rax] add r13, normblkdst ;; OPTIMIZATION - old wpn didn't reload rbx every clm block. Rearranging big/lit data could achieve this as well (and can save the r14 register in ynorm_wpn) ttp movzx rbx, WORD PTR [rdi] ;; Preload 4 big vs. little & fudge flags ttp movzx rcx, WORD PTR [r14] ;; Preload 4 big vs. little & fudge flags vmovapd ymm2, [rbp+0*32] ;; Preload carries vmovapd ymm3, [rbp+1*32] vmovapd ymm9, [rbp+2*32] vmovapd ymm10, [rbp+3*32] ;; OPTIMZATION - always store carries 3/10 in the +BIGVAL format IF (@INSTR(,%yarch,<FMA3>) NE 0) vaddpd ymm3, ymm3, ymm12 ;; Add in YMM_BIGVAL vaddpd ymm10, ymm10, ymm12 ENDIF ilp2: ynorm_wpn_zpad ttp, base2, echk, const, khi, c1, cm1 ;; Normalize 2 sets of 8 values bump rsi, 64 ;; Next cache line bump r13, 64 ;; Next cache line ttp bump rdi, 2 ;; Next big/little flags ttp bump r14, 2 ;; Next big/little flags sub r8, 1 ;; Test loop counter jnz ilp2 ;; Loop til done ;; OPTIMZATION - always store carries 3/10 in the +BIGVAL format IF (@INSTR(,%yarch,<FMA3>) NE 0) vsubpd ymm3, ymm3, ymm12 ;; Subtract out YMM_BIGVAL vsubpd ymm10, ymm10, ymm12 ENDIF ystore [rbp+0*32], ymm2 ;; Store carries ystore [rbp+1*32], ymm3 ystore [rbp+2*32], ymm9 ystore [rbp+3*32], ymm10 bump rbp, 4*32 ;; Next set of carries ttp mov rdi, r14 ;; Calculate address of next big/lit ptr mov rsi, r13 ;; Calculate address of next source add rsi, normblkdst ;; Add 0 or 64 every clmblkdst add r10w, 8000h/2 ;; Test for a multiple of 8 blocks jnc short not8 add rsi, normblkdst8 ;; Add 64 or -64 every 8 clmblkdsts not8: sub r15, 1 ;; Test loop counter jnz ilp1 ;; Iterate ttp lea r12, [r12+YMM_GMD] ;; Next set of group multipliers sub r10w, 1 ;; Test outer loop counter jnz ilp0 ;; Iterate echk ystore YMM_MAXERR, ymm6 ;; Save maximum error int_epilog 0,0,0 ENDPP lab ENDM ENDIF ENDIF ; The 16 different normalization routines. One for each combination of ; rational/irrational, zeroing/no zeroing, error check/no error check, and ; mul by const/no mul by const. inorm yr3, noexec, noexec, noexec, noexec, exec inorm yr3e, noexec, noexec, exec, noexec, exec inorm yr3c, noexec, noexec, noexec, exec, exec inorm yr3ec, noexec, noexec, exec, exec, exec inorm yr3z, noexec, exec, noexec, noexec, exec inorm yr3ze, noexec, exec, exec, noexec, exec inorm yi3, exec, noexec, noexec, noexec, exec inorm yi3e, exec, noexec, exec, noexec, exec inorm yi3c, exec, noexec, noexec, exec, exec inorm yi3ec, exec, noexec, exec, exec, exec inorm yi3z, exec, exec, noexec, noexec, exec inorm yi3ze, exec, exec, exec, noexec, exec zpnorm yr3zp, noexec, noexec, noexec, exec, exec, noexec, noexec zpnorm yr3zpc1, noexec, noexec, noexec, exec, exec, exec, noexec zpnorm yr3zpcm1, noexec, noexec, noexec, exec, exec, noexec, exec zpnorm yr3zpe, noexec, exec, noexec, exec, exec, noexec, noexec zpnorm yr3zpec1, noexec, exec, noexec, exec, exec, exec, noexec zpnorm yr3zpecm1, noexec, exec, noexec, exec, exec, noexec, exec zpnorm yr3zpc, noexec, noexec, exec, exec, exec, noexec, noexec zpnorm yr3zpec, noexec, exec, exec, exec, exec, noexec, noexec zpnorm yi3zp, exec, noexec, noexec, exec, exec, noexec, noexec zpnorm yi3zpc1, exec, noexec, noexec, exec, exec, exec, noexec zpnorm yi3zpcm1, exec, noexec, noexec, exec, exec, noexec, exec zpnorm yi3zpe, exec, exec, noexec, exec, exec, noexec, noexec zpnorm yi3zpec1, exec, exec, noexec, exec, exec, exec, noexec zpnorm yi3zpecm1, exec, exec, noexec, exec, exec, noexec, exec zpnorm yi3zpc, exec, noexec, exec, exec, exec, noexec, noexec zpnorm yi3zpec, exec, exec, exec, exec, exec, noexec, noexec zpnorm yr3zpk, noexec, noexec, noexec, exec, noexec, noexec, noexec zpnorm yr3zpkc1, noexec, noexec, noexec, exec, noexec, exec, noexec zpnorm yr3zpkcm1, noexec, noexec, noexec, exec, noexec, noexec, exec zpnorm yr3zpek, noexec, exec, noexec, exec, noexec, noexec, noexec zpnorm yr3zpekc1, noexec, exec, noexec, exec, noexec, exec, noexec zpnorm yr3zpekcm1, noexec, exec, noexec, exec, noexec, noexec, exec zpnorm yr3zpck, noexec, noexec, exec, exec, noexec, noexec, noexec zpnorm yr3zpeck, noexec, exec, exec, exec, noexec, noexec, noexec zpnorm yi3zpk, exec, noexec, noexec, exec, noexec, noexec, noexec zpnorm yi3zpkc1, exec, noexec, noexec, exec, noexec, exec, noexec zpnorm yi3zpkcm1, exec, noexec, noexec, exec, noexec, noexec, exec zpnorm yi3zpek, exec, exec, noexec, exec, noexec, noexec, noexec zpnorm yi3zpekc1, exec, exec, noexec, exec, noexec, exec, noexec zpnorm yi3zpekcm1, exec, exec, noexec, exec, noexec, noexec, exec zpnorm yi3zpck, exec, noexec, exec, exec, noexec, noexec, noexec zpnorm yi3zpeck, exec, exec, exec, exec, noexec, noexec, noexec inorm yr3b, noexec, noexec, noexec, noexec, noexec inorm yr3eb, noexec, noexec, exec, noexec, noexec inorm yr3cb, noexec, noexec, noexec, exec, noexec inorm yr3ecb, noexec, noexec, exec, exec, noexec inorm yi3b, exec, noexec, noexec, noexec, noexec inorm yi3eb, exec, noexec, exec, noexec, noexec inorm yi3cb, exec, noexec, noexec, exec, noexec inorm yi3ecb, exec, noexec, exec, exec, noexec zpnorm yr3zpb, noexec, noexec, noexec, noexec, exec, noexec, noexec zpnorm yr3zpbc1, noexec, noexec, noexec, noexec, exec, exec, noexec zpnorm yr3zpbcm1, noexec, noexec, noexec, noexec, exec, noexec, exec zpnorm yr3zpeb, noexec, exec, noexec, noexec, exec, noexec, noexec zpnorm yr3zpebc1, noexec, exec, noexec, noexec, exec, exec, noexec zpnorm yr3zpebcm1, noexec, exec, noexec, noexec, exec, noexec, exec zpnorm yr3zpcb, noexec, noexec, exec, noexec, exec, noexec, noexec zpnorm yr3zpecb, noexec, exec, exec, noexec, exec, noexec, noexec zpnorm yi3zpb, exec, noexec, noexec, noexec, exec, noexec, noexec zpnorm yi3zpbc1, exec, noexec, noexec, noexec, exec, exec, noexec zpnorm yi3zpbcm1, exec, noexec, noexec, noexec, exec, noexec, exec zpnorm yi3zpeb, exec, exec, noexec, noexec, exec, noexec, noexec zpnorm yi3zpebc1, exec, exec, noexec, noexec, exec, exec, noexec zpnorm yi3zpebcm1, exec, exec, noexec, noexec, exec, noexec, exec zpnorm yi3zpcb, exec, noexec, exec, noexec, exec, noexec, noexec zpnorm yi3zpecb, exec, exec, exec, noexec, exec, noexec, noexec zpnorm yr3zpbk, noexec, noexec, noexec, noexec, noexec, noexec, noexec zpnorm yr3zpbkc1, noexec, noexec, noexec, noexec, noexec, exec, noexec zpnorm yr3zpbkcm1, noexec, noexec, noexec, noexec, noexec, noexec, exec zpnorm yr3zpebk, noexec, exec, noexec, noexec, noexec, noexec, noexec zpnorm yr3zpebkc1, noexec, exec, noexec, noexec, noexec, exec, noexec zpnorm yr3zpebkcm1, noexec, exec, noexec, noexec, noexec, noexec, exec zpnorm yr3zpcbk, noexec, noexec, exec, noexec, noexec, noexec, noexec zpnorm yr3zpecbk, noexec, exec, exec, noexec, noexec, noexec, noexec zpnorm yi3zpbk, exec, noexec, noexec, noexec, noexec, noexec, noexec zpnorm yi3zpbkc1, exec, noexec, noexec, noexec, noexec, exec, noexec zpnorm yi3zpbkcm1, exec, noexec, noexec, noexec, noexec, noexec, exec zpnorm yi3zpebk, exec, exec, noexec, noexec, noexec, noexec, noexec zpnorm yi3zpebkc1, exec, exec, noexec, noexec, noexec, exec, noexec zpnorm yi3zpebkcm1, exec, exec, noexec, noexec, noexec, noexec, exec zpnorm yi3zpcbk, exec, noexec, exec, noexec, noexec, noexec, noexec zpnorm yi3zpecbk, exec, exec, exec, noexec, noexec, noexec, noexec _TEXT ENDS END
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. #include "../inc/globals.h" #include "LSM6DSLSensor.h" #include "LIS2MDLSensor.h" #include "HTS221Sensor.h" #include "LPS22HBSensor.h" #include "IrDASensor.h" #include "../inc/sensors.h" #define FREEMEM(d) if (d != NULL) { delete d; d = NULL; } SensorController::~SensorController() { FREEMEM(i2c) FREEMEM(accelGyro) FREEMEM(magnetometer) FREEMEM(tempHumidity) FREEMEM(pressure) FREEMEM(irdaSensor) } #undef FREEMEM void SensorController::initSensors() { LOG_VERBOSE("SensorController::initSensors"); // LSM6DSL i2c = new DevI2C(D14, D15); accelGyro = new LSM6DSLSensor(*i2c, D4, D5); accelGyro->init(NULL); accelGyro->enableAccelerator(); accelGyro->enableGyroscope(); // enable double tap detection accelGyro->enablePedometer(); accelGyro->setPedometerThreshold(LSM6DSL_PEDOMETER_THRESHOLD_MID_LOW); // LIS2MDL magnetometer = new LIS2MDLSensor(*i2c); magnetometer->init(NULL); // HTS221 tempHumidity = new HTS221Sensor(*i2c); tempHumidity->init(NULL); // LPS22HB pressure = new LPS22HBSensor(*i2c); pressure->init(NULL); // IrDA irdaSensor = new IRDASensor(); irdaSensor->init(); } // HTS221 float SensorController::readHumidity() { LOG_VERBOSE("SensorController::readHumidity"); assert(tempHumidity != NULL); if (tempHumidity == NULL) { LOG_ERROR("Trying to do readHumidity while the sensor wasn't initialized."); return 0xFFFF; } float humidityValue; tempHumidity->reset(); if (tempHumidity->getHumidity(&humidityValue) == 0) return humidityValue; else return 0xFFFF; } float SensorController::readTemperature() { LOG_VERBOSE("SensorController::readTemperature"); assert(tempHumidity != NULL); if (tempHumidity == NULL) { LOG_ERROR("Trying to do readTemperature while the sensor wasn't initialized."); return 0xFFFF; } float tempValue; tempHumidity->reset(); if (tempHumidity->getTemperature(&tempValue) == 0) return tempValue; else return 0xFFFF; } // LPS22HB float SensorController::readPressure() { LOG_VERBOSE("SensorController::readPressure"); assert(pressure != NULL); if (pressure == NULL) { LOG_ERROR("Trying to do readPressure while the sensor wasn't initialized."); return 0xFFFF; } float presureValue; if (pressure->getPressure(&presureValue) == 0) return presureValue; else return 0xFFFF; } // LIS2MDL void SensorController::readMagnetometer(int *axes) { LOG_VERBOSE("SensorController::readMagnetometer"); bool hasFailed = false; assert(magnetometer != NULL); if (magnetometer == NULL) { LOG_ERROR("Trying to do readMagnetometer while the sensor wasn't initialized."); hasFailed = true; } else if (magnetometer->getMAxes(axes) != 0) { hasFailed = true; } if (hasFailed) { axes[0] = 0xFFFF; axes[1] = 0xFFFF; axes[2] = 0xFFFF; } } // LSM6DSL void SensorController::readAccelerometer(int *axes) { LOG_VERBOSE("SensorController::readAccelerometer"); bool hasFailed = false; assert(accelGyro != NULL); if (accelGyro == NULL) { LOG_ERROR("Trying to do readAccelerometer while the sensor wasn't initialized."); hasFailed = true; } if (accelGyro->getXAxes(axes) != 0) { hasFailed = true; } if (hasFailed) { axes[0] = 0xFFFF; axes[1] = 0xFFFF; axes[2] = 0xFFFF; } } void SensorController::readGyroscope(int *axes) { LOG_VERBOSE("SensorController::readGyroscope"); bool hasFailed = false; assert(accelGyro != NULL); if (accelGyro == NULL) { LOG_ERROR("Trying to do readGyroscope while the sensor wasn't initialized."); hasFailed = true; } if (accelGyro->getGAxes(axes) != 0) { hasFailed = true; } if (hasFailed) { axes[0] = 0xFFFF; axes[1] = 0xFFFF; axes[2] = 0xFFFF; } } bool SensorController::checkForShake() { int steps = 0; bool shake = false; assert(accelGyro != NULL); if (accelGyro == NULL) { LOG_ERROR("Trying to do checkForShake while the sensor wasn't initialized."); return false; } accelGyro->getStepCounter(&steps); if (steps > 1) { shake = true; } accelGyro->resetStepCounter(); return shake; } // RGB LED void SensorController::setLedColor(uint8_t red, uint8_t green, uint8_t blue) { rgbLed.setColor(red, green, blue); } void SensorController::turnLedOff() { LOG_VERBOSE("SensorController::turnLedOff"); rgbLed.turnOff(); } void SensorController::transmitIR() { LOG_VERBOSE("SensorController::transmitIR"); assert(irdaSensor != NULL); if (irdaSensor == NULL) { LOG_ERROR("Trying to do transmitIR while the sensor wasn't initialized."); return; } unsigned char data = 1; for (int i = 0; i < 20; i++) { int irda_status = irdaSensor->IRDATransmit(&data, 1, 100); if(irda_status != 0) { LOG_ERROR("Unable to transmit through IrDA"); } delay(150); } }
; A113311: Expansion of (1+x)^2/(1-x). ; 1,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 mul $0,2 mov $1,3 min $1,$0 add $1,1 mov $0,$1
Name: kart-init-p.asm Type: file Size: 59305 Last-Modified: '1992-08-30T15:00:00Z' SHA-1: DED2947D7EC7E56FBF44025C62DEA63E68B7B150 Description: null
; A071024: Triangle read by rows giving successive states of cellular automaton generated by "Rule 92". ; 1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,0,1,0,1,0,1,0 add $0,2 mov $2,$0 cal $2,134868 ; A103451 * A002260. mov $5,2 lpb $4,2 mov $0,$2 sub $5,$2 lpb $5 gcd $5,$0 lpe cmp $26,0 add $1,$26 lpe
ifdef RAX .code extern OriginalFuncs_version:QWORD GetFileVersionInfoA proc jmp QWORD ptr OriginalFuncs_version[0 * 8] GetFileVersionInfoA endp GetFileVersionInfoByHandle proc jmp QWORD ptr OriginalFuncs_version[1 * 8] GetFileVersionInfoByHandle endp GetFileVersionInfoExA proc jmp QWORD ptr OriginalFuncs_version[2 * 8] GetFileVersionInfoExA endp GetFileVersionInfoExW proc jmp QWORD ptr OriginalFuncs_version[3 * 8] GetFileVersionInfoExW endp GetFileVersionInfoSizeA proc jmp QWORD ptr OriginalFuncs_version[4 * 8] GetFileVersionInfoSizeA endp GetFileVersionInfoSizeExA proc jmp QWORD ptr OriginalFuncs_version[5 * 8] GetFileVersionInfoSizeExA endp GetFileVersionInfoSizeExW proc jmp QWORD ptr OriginalFuncs_version[6 * 8] GetFileVersionInfoSizeExW endp GetFileVersionInfoSizeW proc jmp QWORD ptr OriginalFuncs_version[7 * 8] GetFileVersionInfoSizeW endp GetFileVersionInfoW proc jmp QWORD ptr OriginalFuncs_version[8 * 8] GetFileVersionInfoW endp VerFindFileA proc jmp QWORD ptr OriginalFuncs_version[9 * 8] VerFindFileA endp VerFindFileW proc jmp QWORD ptr OriginalFuncs_version[10 * 8] VerFindFileW endp VerInstallFileA proc jmp QWORD ptr OriginalFuncs_version[11 * 8] VerInstallFileA endp VerInstallFileW proc jmp QWORD ptr OriginalFuncs_version[12 * 8] VerInstallFileW endp VerLanguageNameA proc jmp QWORD ptr OriginalFuncs_version[13 * 8] VerLanguageNameA endp VerLanguageNameW proc jmp QWORD ptr OriginalFuncs_version[14 * 8] VerLanguageNameW endp VerQueryValueA proc jmp QWORD ptr OriginalFuncs_version[15 * 8] VerQueryValueA endp VerQueryValueW proc jmp QWORD ptr OriginalFuncs_version[16 * 8] VerQueryValueW endp else .model flat, C .stack 4096 .code extern OriginalFuncs_version:DWORD GetFileVersionInfoA proc jmp DWORD ptr OriginalFuncs_version[0 * 4] GetFileVersionInfoA endp GetFileVersionInfoByHandle proc jmp DWORD ptr OriginalFuncs_version[1 * 4] GetFileVersionInfoByHandle endp GetFileVersionInfoExA proc jmp DWORD ptr OriginalFuncs_version[2 * 4] GetFileVersionInfoExA endp GetFileVersionInfoExW proc jmp DWORD ptr OriginalFuncs_version[3 * 4] GetFileVersionInfoExW endp GetFileVersionInfoSizeA proc jmp DWORD ptr OriginalFuncs_version[4 * 4] GetFileVersionInfoSizeA endp GetFileVersionInfoSizeExA proc jmp DWORD ptr OriginalFuncs_version[5 * 4] GetFileVersionInfoSizeExA endp GetFileVersionInfoSizeExW proc jmp DWORD ptr OriginalFuncs_version[6 * 4] GetFileVersionInfoSizeExW endp GetFileVersionInfoSizeW proc jmp DWORD ptr OriginalFuncs_version[7 * 4] GetFileVersionInfoSizeW endp GetFileVersionInfoW proc jmp DWORD ptr OriginalFuncs_version[8 * 4] GetFileVersionInfoW endp VerFindFileA proc jmp DWORD ptr OriginalFuncs_version[9 * 4] VerFindFileA endp VerFindFileW proc jmp DWORD ptr OriginalFuncs_version[10 * 4] VerFindFileW endp VerInstallFileA proc jmp DWORD ptr OriginalFuncs_version[11 * 4] VerInstallFileA endp VerInstallFileW proc jmp DWORD ptr OriginalFuncs_version[12 * 4] VerInstallFileW endp VerLanguageNameA proc jmp DWORD ptr OriginalFuncs_version[13 * 4] VerLanguageNameA endp VerLanguageNameW proc jmp DWORD ptr OriginalFuncs_version[14 * 4] VerLanguageNameW endp VerQueryValueA proc jmp DWORD ptr OriginalFuncs_version[15 * 4] VerQueryValueA endp VerQueryValueW proc jmp DWORD ptr OriginalFuncs_version[16 * 4] VerQueryValueW endp endif end
dc.w word_35D5E-Map_BPZElephantBlock dc.w word_35D6C-Map_BPZElephantBlock word_35D5E: dc.w 2 ; DATA XREF: ROM:00035D5Ao dc.b $F0, $F, 0, $6E, $FF, $F8 dc.b $F0, $F, 0, $7E, 0, $18 word_35D6C: dc.w 3 ; DATA XREF: ROM:00035D5Ao dc.b $F0, $F, 0, $6E, $FF, $F8 dc.b $F0, $F, 0, $7E, 0, $18 dc.b $F0, $F, 0, $7E, 0, $38
; ; ; ZX Spectrum ZXMMC specific routines ; code by Alessandro Poppi ; ported to z88dk by Stefano Bodrato - Mar 2010 ; ; $Id: mmc_write_block.asm,v 1.2 2015/01/19 01:33:11 pauloscustodio Exp $ ; ; Write a 512 byte data block to the MMC card ; extern int __LIB__ mmc_write_block(struct MMC mmc_descriptor, long card_address, unsigned char *address); ; ;----------------------------------------------------------------------------------------- ; WRITE BLOCK OF DATA subroutine. By now, we don't use the MULTIPLE_BLOCK transfer. ; ; This routine only works for blocksize = 512 (two OUTI sequence). ; ; HL, DE= MSB, LSB of 32bit address in MMC memory ; IX = ram buffer address ; ; RETURN code in A: ; 0 = OK ; 1 = read_block command error ; 2 = write error (no "5" response from MMC) ; ; Destroys AF, B, DE, HL, IX. ;----------------------------------------------------------------------------------------- ; PUBLIC mmc_write_block EXTERN mmc_write_command EXTERN mmc_write_data EXTERN mmc_send_command EXTERN mmc_wait_response EXTERN clock32 EXTERN cs_high EXTERN card_select INCLUDE "zxmmc.def" mmc_write_block: ld ix,0 add ix,sp ld l,(ix+8) ld h,(ix+9) ; MMC struct ld a,(hl) inc hl ; ptr to MMC mask to be used to select port ld a,(hl) ld (card_select), a ld l,(ix+6) ld h,(ix+7) ; RAM ptr push hl ld e,(ix+2) ; LSB ld d,(ix+3) ; . ld l,(ix+4) ; . ld h,(ix+5) ; MSB ;;pop ix ld a,MMC_WRITE_SINGLE_BLOCK ; Command code for block read call mmc_send_command and a jr z,noerror pop hl ld h,0 ld l,a ret noerror: ld a,$FE out (SPI_PORT),a ; first byte to be sent = DATA TOKEN ;;;write_mmc_block: ;;push bc ld bc,SPI_PORT ; C = PORT, B = 0 for 256 bytes on first OTIR ;push hl ;push ix ;pop hl pop hl otir nop ; without this NOP, the 2nd half of the 512 bytes block would miss some write cycles otir ; on the CPLD if Z80 runs at 21MHz ;push hl ;pop ix ;pop hl ld a,$95 ; CRC... (!) out (SPI_PORT),a nop nop out (SPI_PORT),a call mmc_wait_response ;;pop bc and $1F ; masks useful response bits cp 5 ;jr z,write_mmc_block ; OK jr z,wait_busy ; OK ld hl,2 ; no data token from MMC ret ;write_mmc_block: ; ld a,d ; update the pointer with the block to be written ; add BLOCKSIZE/256 ; 2 if blocksize = 512 ; jr nc,no_overw ; inc hl ;no_overw: ; ld d,a wait_busy: call mmc_wait_response ; MMC will report "00" until busy and a jr z,wait_busy call cs_high call clock32 ; 32 more clock cycles ld hl,0 ret
<% from pwnlib.shellcraft.powerpc.linux import syscall %> <%page args="out_fd, in_fd, offset, count"/> <%docstring> Invokes the syscall sendfile. See 'man 2 sendfile' for more information. Arguments: out_fd(int): out_fd in_fd(int): in_fd offset(off_t): offset count(size_t): count </%docstring> ${syscall('SYS_sendfile', out_fd, in_fd, offset, count)}
/* +------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | https://www.mrpt.org/ | | | | Copyright (c) 2005-2021, Individual contributors, see AUTHORS file | | See: https://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See: https://www.mrpt.org/License | +------------------------------------------------------------------------+ */ // ------------------------------------------------------ // This test file is a subset of a complete example. See: // [MRPT]/samples/ransac-data-association/ // ------------------------------------------------------ #include <gtest/gtest.h> #include <mrpt/maps/CSimplePointsMap.h> #include <mrpt/math/geometry.h> #include <mrpt/poses/CPose2D.h> #include <mrpt/poses/CPosePDFGaussian.h> #include <mrpt/poses/CPosePDFSOG.h> #include <mrpt/random.h> #include <mrpt/tfest/se2.h> using namespace mrpt; using namespace mrpt::math; using namespace mrpt::random; using namespace mrpt::maps; using namespace mrpt::tfest; using namespace mrpt::poses; using namespace std; // ============= PARAMETERS =================== const size_t NUM_OBSERVATIONS_TO_SIMUL = 15; const size_t RANSAC_MINIMUM_INLIERS = 9; // Min. # of inliers to accept const float normalizationStd = 0.10f; // 1 sigma noise (meters) const float ransac_mahalanobisDistanceThreshold = 5.0f; const size_t MINIMUM_RANSAC_ITERS = 100000; const size_t NUM_MAP_FEATS = 50; const double MAP_SIZE_X = 30; const double MAP_SIZE_Y = 15; // ============================================== struct TObs { size_t ID; // Ground truth ID double x, y; }; // Return true if test succeds. // Due to RANSAC being non-deterministic, there exists a small chance of failed // tests even if the algorithm is ok. bool ransac_data_assoc_run() { getRandomGenerator().randomize(); // randomize with time // -------------------------------- // Load feature map: // -------------------------------- CSimplePointsMap the_map; // Generate random MAP: the_map.resize(NUM_MAP_FEATS); for (size_t i = 0; i < NUM_MAP_FEATS; i++) { the_map.setPoint( i, getRandomGenerator().drawUniform(0, MAP_SIZE_X), getRandomGenerator().drawUniform(0, MAP_SIZE_Y)); } const size_t nMapPts = the_map.size(); const size_t nObs = NUM_OBSERVATIONS_TO_SIMUL; // Read the observations themselves: vector<TObs> observations; observations.resize(nObs); const mrpt::poses::CPose2D GT_pose( mrpt::random::getRandomGenerator().drawUniform(-10, 10 + MAP_SIZE_X), mrpt::random::getRandomGenerator().drawUniform(-10, 10 + MAP_SIZE_Y), mrpt::random::getRandomGenerator().drawUniform(-M_PI, M_PI)); const mrpt::poses::CPose2D GT_pose_inv = -GT_pose; std::vector<std::pair<size_t, float>> idxs; the_map.kdTreeRadiusSearch2D(GT_pose.x(), GT_pose.y(), 1000, idxs); ASSERT_(idxs.size() >= nObs); for (size_t i = 0; i < nObs; i++) { double gx, gy; the_map.getPoint(idxs[i].first, gx, gy); double lx, ly; GT_pose_inv.composePoint(gx, gy, lx, ly); observations[i].ID = idxs[i].first; observations[i].x = lx + mrpt::random::getRandomGenerator().drawGaussian1D( 0, normalizationStd); observations[i].y = ly + mrpt::random::getRandomGenerator().drawGaussian1D( 0, normalizationStd); } // ---------------------------------------------------- // Generate list of individual-compatible pairings // ---------------------------------------------------- TMatchingPairList all_correspondences; all_correspondences.reserve(nMapPts * nObs); // ALL possibilities: for (size_t j = 0; j < nObs; j++) { TMatchingPair match; match.localIdx = j; match.local.x = observations[j].x; match.local.y = observations[j].y; for (size_t i = 0; i < nMapPts; i++) { match.globalIdx = i; the_map.getPoint(i, match.global.x, match.global.y); all_correspondences.push_back(match); } } // ---------------------------------------------------- // Run RANSAC-based D-A // ---------------------------------------------------- mrpt::tfest::TSE2RobustParams params; mrpt::tfest::TSE2RobustResult results; params.ransac_minSetSize = RANSAC_MINIMUM_INLIERS; // ransac_minSetSize (to // add the solution to // the SOG) params.ransac_maxSetSize = all_correspondences .size(); // ransac_maxSetSize: Test with all data points params.ransac_mahalanobisDistanceThreshold = ransac_mahalanobisDistanceThreshold; params.ransac_nSimulations = 0; // 0=auto params.ransac_fuseByCorrsMatch = true; params.ransac_fuseMaxDiffXY = 0.01f; params.ransac_fuseMaxDiffPhi = 0.1_deg; params.ransac_algorithmForLandmarks = true; params.probability_find_good_model = 0.999999; params.ransac_min_nSimulations = MINIMUM_RANSAC_ITERS; // (a lower limit to the auto-detected value of // ransac_nSimulations) params.verbose = false; // Run ransac data-association: mrpt::tfest::se2_l2_robust( all_correspondences, normalizationStd, params, results); // mrpt::poses::CPosePDFSOG & best_poses = results.transformation; TMatchingPairList& out_best_pairings = results.largestSubSet; // Reconstruct the SE(2) transformation for these pairings: mrpt::poses::CPosePDFGaussian solution_pose; mrpt::tfest::se2_l2(out_best_pairings, solution_pose); // Normalized covariance: scale! solution_pose.cov *= square(normalizationStd); if (!(solution_pose.mean.distanceTo(GT_pose) < 0.9 && std::abs(solution_pose.mean.phi() - GT_pose.phi()) < 10.0_deg)) { std::cerr << "Solution pose: " << solution_pose.mean << endl << "Ground truth pose: " << GT_pose << endl; return false; } return true; } TEST(tfest, ransac_data_assoc) { // Run randomized experiments: bool any_ok = false; for (int i = 0; i < 3; i++) if (ransac_data_assoc_run()) any_ok = true; EXPECT_TRUE(any_ok); }
; ********************************************************************************* ; ********************************************************************************* ; ; File: multiply.asm ; Purpose: 16 bit unsigned multiply ; Date : 1st January 2019 ; Author: paul@robsons.org.uk ; ; ********************************************************************************* ; ********************************************************************************* ; calculate HL = HL * BC @word sys.multiply() push de ld d,b ld e,c call MULTMultiply16 pop de ret ; ********************************************************************************* ; ; Does HL = HL * DE ; ; ********************************************************************************* MULTMultiply16: push bc push de ld b,h ; get multipliers in DE/BC ld c,l ld hl,0 ; zero total __Core__Mult_Loop: bit 0,c ; lsb of shifter is non-zero jr z,__Core__Mult_Shift add hl,de ; add adder to total __Core__Mult_Shift: srl b ; shift BC right. rr c ex de,hl ; shift DE left add hl,hl ex de,hl ld a,b ; loop back if BC is nonzero or c jr nz,__Core__Mult_Loop pop de pop bc ret
; FILE *open_memstream_callee(char **bufp, size_t *sizep) SECTION code_stdio PUBLIC _open_memstream_callee EXTERN asm_open_memstream _open_memstream_callee: pop hl pop de ex (sp),hl jp asm_open_memstream
; void sp1_MoveSprPix(struct sp1_ss *s, struct sp1_Rect *clip, uchar *frame, uint x, uint y) ; CALLER linkage for function pointers SECTION code_clib SECTION code_temp_sp1 PUBLIC sp1_MoveSprPix EXTERN asm_sp1_MoveSprPix sp1_MoveSprPix: pop af pop bc pop de pop hl pop iy pop ix push hl push hl push hl push de push bc push af jp asm_sp1_MoveSprPix
; A310496: Coordination sequence Gal.6.327.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Jamie Morken(s2) ; 1,4,10,16,20,24,30,34,38,44,50,54,58,64,70,74,78,84,88,92,98,104,108,112,118,124,128,132,138,142,146,152,158,162,166,172,178,182,186,192,196,200,206,212,216,220,226,232,236,240 mov $1,$0 mov $2,$0 mul $0,12 sub $0,1 seq $1,314720 ; Coordination sequence Gal.6.245.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. mod $0,$1 add $0,1 mul $2,2 add $0,$2
; A271359: a(n) = k*Fibonacci(2*n+1) + (k+1)*Fibonacci(2*n), where k=5. ; 5,16,43,113,296,775,2029,5312,13907,36409,95320,249551,653333,1710448,4478011,11723585,30692744,80354647,210371197,550758944,1441905635,3774957961,9882968248,25873946783,67738872101,177342669520,464289136459,1215524739857,3182285083112,8331330509479,21811706445325,57103788826496,149499660034163,391395191275993,1024685913793816,2682662550105455,7023301736522549,18387242659462192,48138426241864027,126028036066129889,329945681956525640,863809009803447031,2261481347453815453,5920635032557999328 mov $1,5 lpb $0 sub $0,1 add $2,$1 add $1,6 add $1,$2 lpe mov $0,$1
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args=""/> <%docstring> Invokes the syscall geteuid. See 'man 2 geteuid' for more information. Arguments: </%docstring> ${syscall('SYS_geteuid')}
#include <uWS/uWS.h> #include <iostream> #include "json.hpp" #include "PID.h" #include <math.h> // for convenience using json = nlohmann::json; // For converting back and forth between radians and degrees. constexpr double pi() { return M_PI; } double deg2rad(double x) { return x * pi() / 180; } double rad2deg(double x) { return x * 180 / pi(); } // Checks if the SocketIO event has JSON data. // If there is data the JSON object in string format will be returned, // else the empty string "" will be returned. std::string hasData(std::string s) { auto found_null = s.find("null"); auto b1 = s.find_first_of("["); auto b2 = s.find_last_of("]"); if (found_null != std::string::npos) { return ""; } else if (b1 != std::string::npos && b2 != std::string::npos) { return s.substr(b1, b2 - b1 + 1); } return ""; } int main() { uWS::Hub h; PID pid; // Initialize the pid variable. //pid.init(0.2, 5.0, 0.004); pid.init(0.15, 5.0, 0.004); h.onMessage([&pid](uWS::WebSocket<uWS::SERVER> ws, char *data, size_t length, uWS::OpCode opCode) { // "42" at the start of the message means there's a websocket message event. // The 4 signifies a websocket message // The 2 signifies a websocket event if (length && length > 2 && data[0] == '4' && data[1] == '2') { auto s = hasData(std::string(data).substr(0, length)); if (s != "") { auto j = json::parse(s); std::string event = j[0].get<std::string>(); if (event == "telemetry") { // j[1] is the data JSON object double cte = std::stod(j[1]["cte"].get<std::string>()); double speed = std::stod(j[1]["speed"].get<std::string>()); double angle = std::stod(j[1]["steering_angle"].get<std::string>()); double steer_value = pid.getSteerValue(cte); /* * NOTE: Feel free to play around with the throttle and speed. Maybe use * another PID controller to control the speed! */ //std::cout << "cte: " << cte << ", steer: " << steer_value << std::endl; json msgJson; msgJson["steering_angle"] = steer_value; msgJson["throttle"] = 0.3; auto msg = "42[\"steer\"," + msgJson.dump() + "]"; //std::cout << msg << std::endl; ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); } } else { // Manual driving std::string msg = "42[\"manual\",{}]"; ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); } } }); // We don't need this since we're not using HTTP but if it's removed the program // doesn't compile :-( h.onHttpRequest([](uWS::HttpResponse *res, uWS::HttpRequest req, char *data, size_t, size_t) { const std::string s = "<h1>Hello world!</h1>"; if (req.getUrl().valueLength == 1) { res->end(s.data(), s.length()); } else { // i guess this should be done more gracefully? res->end(nullptr, 0); } }); h.onConnection([&h](uWS::WebSocket<uWS::SERVER> ws, uWS::HttpRequest req) { std::cout << "Connected!!!" << std::endl; }); h.onDisconnection([&h](uWS::WebSocket<uWS::SERVER> ws, int code, char *message, size_t length) { ws.close(); std::cout << "Disconnected" << std::endl; }); int port = 4567; if (h.listen(port)) { std::cout << "Listening to port " << port << std::endl; } else { std::cerr << "Failed to listen to port" << std::endl; return -1; } h.run(); }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xfae, %rcx nop nop nop nop nop and %rdx, %rdx mov $0x6162636465666768, %r10 movq %r10, %xmm6 vmovups %ymm6, (%rcx) nop nop inc %rax lea addresses_WC_ht+0x1542e, %r13 nop nop sub $33375, %r14 movl $0x61626364, (%r13) xor %rcx, %rcx lea addresses_normal_ht+0x4d6a, %rcx nop nop dec %r10 movb (%rcx), %al nop nop sub $21591, %r13 lea addresses_A_ht+0xff6e, %r10 nop nop nop nop nop cmp %rcx, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm4 and $0xffffffffffffffc0, %r10 vmovaps %ymm4, (%r10) nop nop nop nop nop xor $52492, %r10 lea addresses_WC_ht+0x1520e, %rsi lea addresses_A_ht+0x1d41c, %rdi xor %rax, %rax mov $126, %rcx rep movsl nop nop nop nop nop add $55136, %rdx lea addresses_A_ht+0x772e, %rdi nop nop nop nop nop sub $38435, %r14 movb (%rdi), %r10b nop xor $20020, %rsi lea addresses_UC_ht+0x1532e, %rcx nop nop and $57637, %rax mov (%rcx), %r14 nop nop add %rdx, %rdx lea addresses_A_ht+0x2e2e, %rsi lea addresses_WC_ht+0xd79a, %rdi clflush (%rsi) nop nop cmp %rdx, %rdx mov $25, %rcx rep movsw nop nop nop nop nop add %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r14 push %r9 push %rbx push %rsi // Store lea addresses_WC+0xbe2e, %rbx nop add %r11, %r11 movw $0x5152, (%rbx) nop nop nop nop inc %rsi // Store lea addresses_A+0x1e4ae, %rbx nop nop nop cmp $55593, %r14 mov $0x5152535455565758, %r13 movq %r13, %xmm5 vmovups %ymm5, (%rbx) nop nop nop nop nop cmp $20002, %r12 // Faulty Load lea addresses_D+0x1b22e, %r12 nop nop nop cmp $22573, %rbx movups (%r12), %xmm6 vpextrq $1, %xmm6, %r9 lea oracles, %r12 and $0xff, %r9 shlq $12, %r9 mov (%r12,%r9,1), %r9 pop %rsi pop %rbx pop %r9 pop %r14 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}} {'36': 18131} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
.data .text main: addi $5, $0, 0 addi $6, $0, 11 addi $7, $0, 1 loop: add $5, $5, $7 addi $7, $7, 1 sub $8, $6, $7 bgtz $8, loop finish: add $4, $0, $5 add $2, $0, 1 syscall add $2, $0, 10 syscall
db DEX_LAPRAS ; pokedex id db 130, 85, 80, 60, 95 ; hp atk def spd spc db WATER, ICE ; type db 45 ; catch rate db 219 ; base exp INCBIN "gfx/pokemon/front/lapras.pic", 0, 1 ; sprite dimensions dw LaprasPicFront, LaprasPicBack db WATER_GUN, GROWL, NO_MOVE, NO_MOVE ; level 1 learnset db GROWTH_SLOW ; growth rate ; tm/hm learnset tmhm TOXIC, COUNTER, BODY_SLAM, TAKE_DOWN, DOUBLE_EDGE, \ BUBBLEBEAM, WATER_GUN, ICE_BEAM, BLIZZARD, HYPER_BEAM, \ RAGE, SOLARBEAM, DRAGON_RAGE, THUNDERBOLT, THUNDER, \ PSYCHIC_M, MIMIC, DOUBLE_TEAM, REFLECT, BIDE, \ SKULL_BASH, REST, PSYWAVE, SUBSTITUTE, SURF, \ STRENGTH ; end db 0 ; padding
; A023471: n-29. ; -29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 sub $0,29 mul $0,120259084288 mov $1,$0 div $1,120259084288
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x15979, %rsi lea addresses_UC_ht+0xad79, %rdi nop nop cmp %r12, %r12 mov $13, %rcx rep movsl nop nop nop and $63787, %rcx lea addresses_A_ht+0x1b79, %rsi lea addresses_UC_ht+0x1a9d9, %rdi nop nop add %r13, %r13 mov $79, %rcx rep movsw nop nop nop sub %rsi, %rsi lea addresses_D_ht+0x1a979, %rsi lea addresses_normal_ht+0x35f9, %rdi nop nop nop nop and $55756, %r13 mov $32, %rcx rep movsl nop nop nop nop dec %r12 lea addresses_D_ht+0x55f9, %rsi lea addresses_UC_ht+0xd079, %rdi clflush (%rsi) nop nop nop cmp %r8, %r8 mov $43, %rcx rep movsl nop nop and $56284, %r8 lea addresses_WC_ht+0x5179, %rdi clflush (%rdi) nop nop nop add %rbx, %rbx movb $0x61, (%rdi) nop inc %rcx lea addresses_D_ht+0x4aa3, %rsi lea addresses_WT_ht+0x12c95, %rdi nop nop nop nop nop cmp $22736, %r15 mov $18, %rcx rep movsl nop nop nop and $21443, %r8 lea addresses_WC_ht+0x123f2, %rsi lea addresses_normal_ht+0x1685, %rdi nop nop nop dec %r15 mov $72, %rcx rep movsl nop nop nop nop nop sub %rdi, %rdi lea addresses_D_ht+0x979, %rcx nop sub %rbx, %rbx mov (%rcx), %r8 nop nop nop and $36600, %r8 lea addresses_WC_ht+0x67f9, %rsi lea addresses_normal_ht+0x1579, %rdi sub $1496, %r8 mov $113, %rcx rep movsq nop nop nop nop nop and $35382, %rcx lea addresses_WT_ht+0x10179, %rdi nop xor $57488, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm4 vmovups %ymm4, (%rdi) cmp $23334, %r13 lea addresses_D_ht+0x3d0f, %rsi nop nop nop nop cmp $29602, %r15 mov (%rsi), %rbx nop nop cmp %r13, %r13 pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %rax push %rbp push %rdx push %rsi // Store lea addresses_WC+0x30c, %rdx nop nop add $49484, %rsi mov $0x5152535455565758, %r14 movq %r14, %xmm4 vmovups %ymm4, (%rdx) nop nop sub %rdx, %rdx // Faulty Load lea addresses_RW+0x9179, %rax nop xor $52454, %rbp mov (%rax), %r14 lea oracles, %rsi and $0xff, %r14 shlq $12, %r14 mov (%rsi,%r14,1), %r14 pop %rsi pop %rdx pop %rbp pop %rax pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}} {'32': 4149} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/cloudesl/model/DescribeUserLogRequest.h> using AlibabaCloud::Cloudesl::Model::DescribeUserLogRequest; DescribeUserLogRequest::DescribeUserLogRequest() : RpcServiceRequest("cloudesl", "2020-02-01", "DescribeUserLog") { setMethod(HttpRequest::Method::Post); } DescribeUserLogRequest::~DescribeUserLogRequest() {} std::string DescribeUserLogRequest::getExtraParams()const { return extraParams_; } void DescribeUserLogRequest::setExtraParams(const std::string& extraParams) { extraParams_ = extraParams; setBodyParameter("ExtraParams", extraParams); } std::string DescribeUserLogRequest::getStoreId()const { return storeId_; } void DescribeUserLogRequest::setStoreId(const std::string& storeId) { storeId_ = storeId; setBodyParameter("StoreId", storeId); } std::string DescribeUserLogRequest::getUserId()const { return userId_; } void DescribeUserLogRequest::setUserId(const std::string& userId) { userId_ = userId; setBodyParameter("UserId", userId); } int DescribeUserLogRequest::getPageNumber()const { return pageNumber_; } void DescribeUserLogRequest::setPageNumber(int pageNumber) { pageNumber_ = pageNumber; setBodyParameter("PageNumber", std::to_string(pageNumber)); } std::string DescribeUserLogRequest::getFromDate()const { return fromDate_; } void DescribeUserLogRequest::setFromDate(const std::string& fromDate) { fromDate_ = fromDate; setBodyParameter("FromDate", fromDate); } std::string DescribeUserLogRequest::getOperationStatus()const { return operationStatus_; } void DescribeUserLogRequest::setOperationStatus(const std::string& operationStatus) { operationStatus_ = operationStatus; setBodyParameter("OperationStatus", operationStatus); } std::string DescribeUserLogRequest::getToDate()const { return toDate_; } void DescribeUserLogRequest::setToDate(const std::string& toDate) { toDate_ = toDate; setBodyParameter("ToDate", toDate); } std::string DescribeUserLogRequest::getEslBarCode()const { return eslBarCode_; } void DescribeUserLogRequest::setEslBarCode(const std::string& eslBarCode) { eslBarCode_ = eslBarCode; setBodyParameter("EslBarCode", eslBarCode); } int DescribeUserLogRequest::getPageSize()const { return pageSize_; } void DescribeUserLogRequest::setPageSize(int pageSize) { pageSize_ = pageSize; setBodyParameter("PageSize", std::to_string(pageSize)); } std::string DescribeUserLogRequest::getItemBarCode()const { return itemBarCode_; } void DescribeUserLogRequest::setItemBarCode(const std::string& itemBarCode) { itemBarCode_ = itemBarCode; setBodyParameter("ItemBarCode", itemBarCode); } std::string DescribeUserLogRequest::getItemShortTitle()const { return itemShortTitle_; } void DescribeUserLogRequest::setItemShortTitle(const std::string& itemShortTitle) { itemShortTitle_ = itemShortTitle; setBodyParameter("ItemShortTitle", itemShortTitle); } std::string DescribeUserLogRequest::getOperationType()const { return operationType_; } void DescribeUserLogRequest::setOperationType(const std::string& operationType) { operationType_ = operationType; setBodyParameter("OperationType", operationType); } std::string DescribeUserLogRequest::getLogId()const { return logId_; } void DescribeUserLogRequest::setLogId(const std::string& logId) { logId_ = logId; setBodyParameter("LogId", logId); }
; @Author Muhammad Quwais Safutra ; JANGAN DI COPAS ATAU DI DEBUG SENDIRIAN. TAKUTNYA MATI / ERROR KOMPUTERNYA ESCCH EQU 0 CANCEL EQU 1BH ;Cancel with ESC TOGLINS EQU TRUE ;One key toggles insert mode TOGLPRN EQU TRUE ;One key toggles printer echo NUMDEV EQU 6 ;Include "COM1" as I/O device name ZEROEXT EQU TRUE ELSE ESCCH EQU 1BH CANCEL EQU "X"-"@" ;Cancel with Ctrl-X TOGLINS EQU FALSE ;Separate keys for insert mode on and off TOGLPRN EQU FALSE ;Separate keys for printer echo on and off NUMDEV EQU 5 ;Number of I/O device names ZEROEXT EQU FALSE ENDIF MAXCALL EQU 36 MAXCOM EQU 46 INTBASE EQU 80H INTTAB EQU 20H ENTRYPOINTSEG EQU 0CH ENTRYPOINT EQU INTBASE+40H CONTC EQU INTTAB+3 EXIT EQU INTBASE+8 LONGJUMP EQU 0EAH LONGCALL EQU 9AH MAXDIF EQU 0FFFH SAVEXIT EQU 10 ; Field definition for FCBs FCBLOCK STRUC DB 12 DUP (?) ;Drive code and name EXTENT DW ? RECSIZ DW ? ;Size of record (user settable) FILSIZ DW ? ;Size of file in bytes DRVBP DW ? ;BP for SEARCH FIRST and SEARCH NEXT FDATE DW ? ;Date of last writing FTIME DW ? ;Time of last writing DEVID DB ? ;Device ID number, bits 0-5 ;bit 7=0 for file, bit 7=1 for I/O device ;If file, bit 6=0 if dirty ;If I/O device, bit 6=0 if EOF (input) FIRCLUS DW ? ;First cluster of file LSTCLUS DW ? ;Last cluster accessed CLUSPOS DW ? ;Position of last cluster accessed DB ? ;Forces NR to offset 32 NR DB ? ;Next record RR DB 3 DUP (?) ;Random record FCBLOCK ENDS FILDIRENT = FILSIZ ;Used only by SEARCH FIRST and SEARCH NEXT ; Description of 32-byte directory entry (same as returned by SEARCH FIRST ; and SEARCH NEXT, functions 17 and 18). ; ; Location bytes Description ; ; 0 11 File name and extension ( 0E5H if empty) ; 11 1 Attributes. Bits 1 or 2 make file hidden ; 12 10 Zero field (for expansion) ; 22 2 Time. Bits 0-4=seconds/2, bits 5-10=minute, 11-15=hour ; 24 2 Date. Bits 0-4=day, bits 5-8=month, bits 9-15=year-1980 ; 26 2 First allocation unit ( < 4080 ) ; 28 4 File size, in bytes (LSB first, 30 bits max.) ; ; The File Allocation Table uses a 12-bit entry for each allocation unit on ; the disk. These entries are packed, two for every three bytes. The contents ; of entry number N is found by 1) multiplying N by 1.5; 2) adding the result ; to the base address of the Allocation Table; 3) fetching the 16-bit word at ; this address; 4) If N was odd (so that N*1.5 was not an integer), shift the ; word right four bits; 5) mask to 12 bits (AND with 0FFF hex). Entry number ; zero is used as an end-of-file trap in the OS and as a flag for directory ; entry size (if SMALLDIR selected). Entry 1 is reserved for future use. The ; first available allocation unit is assigned entry number two, and even ; though it is the first, is called cluster 2. Entries greater than 0FF8H are ; end of file marks; entries of zero are unallocated. Otherwise, the contents ; of a FAT entry is the number of the next cluster in the file. ; Field definition for Drive Parameter Block DPBLOCK STRUC DEVNUM DB ? ;I/O driver number DRVNUM DB ? ;Physical Unit number SECSIZ DW ? ;Size of physical sector in bytes CLUSMSK DB ? ;Sectors/cluster - 1 CLUSSHFT DB ? ;Log2 of sectors/cluster FIRFAT DW ? ;Starting record of FATs FATCNT DB ? ;Number of FATs for this drive MAXENT DW ? ;Number of directory entries FIRREC DW ? ;First sector of first cluster MAXCLUS DW ? ;Number of clusters on drive + 1 FATSIZ DB ? ;Number of records occupied by FAT FIRDIR DW ? ;Starting record of directory FAT DW ? ;Pointer to start of FAT DPBLOCK ENDS DPBSIZ EQU 20 ;Size of the structure in bytes DIRSEC = FIRREC ;Number of dir. sectors (init temporary) DSKSIZ = MAXCLUS ;Size of disk (temp used during init only) ;The following are all of the segments used ;They are declared in the order that they should be placed in the executable CODE SEGMENT CODE ENDS CONSTANTS SEGMENT BYTE CONSTANTS ENDS DATA SEGMENT WORD DATA ENDS DOSGROUP GROUP CODE,CONSTANTS,DATA SEGBIOS SEGMENT SEGBIOS ENDS ; BOIS entry point definitions IF IBM BIOSSEG EQU 60H ENDIF IF NOT IBM BIOSSEG EQU 40H ENDIF SEGBIOS SEGMENT AT BIOSSEG ORG 0 DB 3 DUP (?) ;Reserve room for jump to init code BIOSSTAT DB 3 DUP (?) ;Console input status check BIOSIN DB 3 DUP (?) ;Get console character BIOSOUT DB 3 DUP (?) ;Output console character BIOSPRINT DB 3 DUP (?) ;Output to printer BIOSAUXIN DB 3 DUP (?) ;Get byte from auxilliary BIOSAUXOUT DB 3 DUP (?) ;Output byte to auxilliary BIOSREAD DB 3 DUP (?) ;Disk read BIOSWRITE DB 3 DUP (?) ;Disk write BIOSDSKCHG DB 3 DUP (?) ;Dsik-change status BIOSSETDATE DB 3 DUP (?) ;Set date BIOSSETTIME DB 3 DUP (?) ;Set time BIOSGETTIME DB 3 DUP (?) ;Get time and date BIOSFLUSH DB 3 DUP (?) ;Clear console input buffer BIOSMAPDEV DB 3 DUP (?) ;Dynamic disk table mapper SEGBIOS ENDS ; Location of user registers relative user stack pointer STKPTRS STRUC AXSAVE DW ? BXSAVE DW ? CXSAVE DW ? DXSAVE DW ? SISAVE DW ? DISAVE DW ? BPSAVE DW ? DSSAVE DW ? ESSAVE DW ? IPSAVE DW ? CSSAVE DW ? FSAVE DW ? STKPTRS ENDS ; Start of code CODE SEGMENT ASSUME CS:DOSGROUP,DS:DOSGROUP,ES:DOSGROUP,SS:DOSGROUP ORG 0 CODSTRT EQU $ JMP DOSINIT ESCCHAR DB ESCCH ;Lead-in character for escape sequences ESCTAB: IF NOT IBM DB "S" ;Copy one char DB "V" ;Skip one char DB "T" ;Copy to char DB "W" ;Skip to char DB "U" ;Copy line DB "E" ;Kill line (no change in template) DB "J" ;Reedit line (new template) DB "D" ;Backspace DB "P" ;Enter insert mode DB "Q" ;Exit insert mode DB "R" ;Escape character DB "R" ;End of table ENDIF IF IBM DB 64 ;Crtl-Z - F6 DB 77 ;Copy one char - --> DB 59 ;Copy one char - F1 DB 83 ;Skip one char - DEL DB 60 ;Copy to char - F2 DB 62 ;Skip to char - F4 DB 61 ;Copy line - F3 DB 61 ;Kill line (no change to template ) - Not used DB 63 ;Reedit line (new template) - F5 DB 75 ;Backspace - <-- DB 82 ;Enter insert mode - INS (toggle) DB 65 ;Escape character - F7 DB 65 ;End of table ENDIF ESCTABLEN EQU $-ESCTAB IF NOT IBM HEADER DB 13,10,"MS-DOS version 1.25" IF HIGHMEM DB "H" ENDIF IF DSKTEST DB "D" ENDIF DB 13,10 DB "Copyright 1981,82 Microsoft, Inc.",13,10,"$" ENDIF QUIT: MOV AH,0 JMP SHORT SAVREGS COMMAND: ;Interrupt call entry point CMP AH,MAXCOM JBE SAVREGS BADCALL: MOV AL,0 IRET: IRET ENTRY: ;System call entry point and dispatcher POP AX ;IP from the long call at 5 POP AX ;Segment from the long call at 5 POP CS:[TEMP] ;IP from the CALL 5 PUSHF ;Start re-ordering the stack CLI PUSH AX ;Save segment PUSH CS:[TEMP] ;Stack now ordered as if INT had been used CMP CL,MAXCALL ;This entry point doesn't get as many calls JA BADCALL MOV AH,CL SAVREGS: PUSH ES PUSH DS PUSH BP PUSH DI PUSH SI PUSH DX PUSH CX PUSH BX PUSH AX IF DSKTEST MOV AX,CS:[SPSAVE] MOV CS:[NSP],AX MOV AX,CS:[SSSAVE] MOV CS:[NSS],AX POP AX PUSH AX ENDIF MOV CS:[SPSAVE],SP MOV CS:[SSSAVE],SS MOV SP,CS MOV SS,SP REDISP: MOV SP,OFFSET DOSGROUP:IOSTACK STI ;Stack OK now MOV BL,AH MOV BH,0 SHL BX,1 CLD CMP AH,12 JLE SAMSTK MOV SP,OFFSET DOSGROUP:DSKSTACK SAMSTK: CALL CS:[BX+DISPATCH] LEAVE: CLI MOV SP,CS:[SPSAVE] MOV SS,CS:[SSSAVE] MOV BP,SP MOV BYTE PTR [BP.AXSAVE],AL IF DSKTEST MOV AX,CS:[NSP] MOV CS:[SPSAVE],AX MOV AX,CS:[NSS] MOV CS:[SSSAVE],AX ENDIF POP AX POP BX POP CX POP DX POP SI POP DI POP BP POP DS POP ES IRET ; Standard Functions DISPATCH DW ABORT ;0 DW CONIN DW CONOUT DW READER DW PUNCH DW LIST ;5 DW RAWIO DW RAWINP DW IN DW PRTBUF DW BUFIN ;10 DW CONSTAT DW FLUSHKB DW DSKRESET DW SELDSK DW OPEN ;15 DW CLOSE DW SRCHFRST DW SRCHNXT DW DELETE DW SEQRD ;20 DW SEQWRT DW CREATE DW RENAME DW INUSE DW GETDRV ;25 DW SETDMA DW GETFATPT DW GETFATPTDL DW GETRDONLY DW SETATTRIB ;30 DW GETDSKPT DW USERCODE DW RNDRD DW RNDWRT DW FILESIZE ;35 DW SETRNDREC ; Extended Functions DW SETVECT DW NEWBASE DW BLKRD DW BLKWRT ;40 DW MAKEFCB DW GETDATE DW SETDATE DW GETTIME DW SETTIME ;45 DW VERIFY INUSE: GETIO: SETIO: GETRDONLY: SETATTRIB: USERCODE: MOV AL,0 RET VERIFY: AND AL,1 MOV CS:VERFLG,AL RET FLUSHKB: PUSH AX CALL FAR PTR BIOSFLUSH POP AX MOV AH,AL CMP AL,1 JZ REDISPJ CMP AL,6 JZ REDISPJ CMP AL,7 JZ REDISPJ CMP AL,8 JZ REDISPJ CMP AL,10 JZ REDISPJ MOV AL,0 RET REDISPJ:JMP REDISP READER: AUXIN: CALL STATCHK CALL FAR PTR BIOSAUXIN RET PUNCH: MOV AL,DL AUXOUT: PUSH AX CALL STATCHK POP AX CALL FAR PTR BIOSAUXOUT RET UNPACK: ; Inputs: ; DS = CS ; BX = Cluster number ; BP = Base of drive parameters ; SI = Pointer to drive FAT ; Outputs: ; DI = Contents of FAT for given cluster ; Zero set means DI=0 (free cluster) ; No other registers affected. Fatal error if cluster too big. CMP BX,[BP.MAXCLUS] JA HURTFAT LEA DI,[SI+BX] SHR BX,1 MOV DI,[DI+BX] JNC HAVCLUS SHR DI,1 SHR DI,1 SHR DI,1 SHR DI,1 STC HAVCLUS: RCL BX,1 AND DI,0FFFH RET HURTFAT: PUSH AX MOV AH,80H ;Signal Bad FAT to INT 24H handler MOV DI,0FFFH ;In case INT 24H returns (it shouldn't) CALL FATAL POP AX ;Try to ignore bad FAT RET PACK: ; Inputs: ; DS = CS ; BX = Cluster number ; DX = Data ; SI = Pointer to drive FAT ; Outputs: ; The data is stored in the FAT at the given cluster. ; BX,DX,DI all destroyed ; No other registers affected MOV DI,BX SHR BX,1 ADD BX,SI ADD BX,DI SHR DI,1 MOV DI,[BX] JNC ALIGNED SHL DX,1 SHL DX,1 SHL DX,1 SHL DX,1 AND DI,0FH JMP SHORT PACKIN ALIGNED: AND DI,0F000H PACKIN: OR DI,DX MOV [BX],DI RET DEVNAME: MOV SI,OFFSET DOSGROUP:IONAME ;List of I/O devices with file names MOV BH,NUMDEV ;BH = number of device names LOOKIO: MOV DI,OFFSET DOSGROUP:NAME1 MOV CX,4 ;All devices are 4 letters REPE CMPSB ;Check for name in list JZ IOCHK ;If first 3 letters OK, check for the rest ADD SI,CX ;Point to next device name DEC BH JNZ LOOKIO CRET: STC ;Not found RET IOCHK: IF IBM CMP BH,NUMDEV ;Is it the first device? JNZ NOTCOM1 MOV BH,2 ;Make it the same as AUX NOTCOM1: ENDIF NEG BH MOV CX,2 ;Check rest of name but not extension MOV AX,2020H REPE SCASW ;Make sure rest of name is blanks JNZ CRET RET1: RET ;Zero set so CREATE works GETFILE: ; Same as GETNAME except ES:DI points to FCB on successful return CALL MOVNAME JC RET1 PUSH DX PUSH DS CALL FINDNAME POP ES POP DI RET2: RET GETNAME: ; Inputs: ; DS,DX point to FCB ; Function: ; Find file name in disk directory. First byte is ; drive number (0=current disk). "?" matches any ; character. ; Outputs: ; Carry set if file not found ; ELSE ; Zero set if attributes match (always except when creating) ; BP = Base of drive parameters ; DS = CS ; ES = CS ; BX = Pointer into directory buffer ; SI = Pointer to First Cluster field in directory entry ; [DIRBUF] has directory record with match ; [NAME1] has file name ; All other registers destroyed. CALL MOVNAME JC RET2 ;Bad file name? FINDNAME: MOV AX,CS MOV DS,AX CALL DEVNAME JNC RET2 CALL STARTSRCH CONTSRCH: CALL GETENTRY JC RET2 SRCH: MOV AH,BYTE PTR [BX] OR AH,AH ;End of directory? JZ FREE CMP AH,[DELALL] ;Free entry? JZ FREE MOV SI,BX MOV DI,OFFSET DOSGROUP:NAME1 MOV CX,11 WILDCRD: REPE CMPSB JZ FOUND CMP BYTE PTR [DI-1],"?" JZ WILDCRD NEXTENT: CALL NEXTENTRY JNC SRCH RET3: RET FREE: CMP [ENTFREE],-1 ;Found a free entry before? JNZ TSTALL ;If so, ignore this one MOV CX,[LASTENT] MOV [ENTFREE],CX TSTALL: CMP AH,[DELALL] ;At end of directory? JZ NEXTENT ;No - continue search STC ;Report not found RET FOUND: ;Check if attributes allow finding it MOV AH,[ATTRIB] ;Attributes of search NOT AH AND AH,[SI] ;Compare with attributes of file ADD SI,15 AND AH,6 ;Only look at bits 1 and 2 JZ RET3 TEST BYTE PTR [CREATING],-1 ;Pass back mismatch if creating JZ NEXTENT ;Otherwise continue searching RET GETENTRY: ; Inputs: ; [LASTENT] has previously searched directory entry ; Function: ; Locates next sequential directory entry in preparation for search ; Outputs: ; Carry set if none ; ELSE ; AL = Current directory block ; BX = Pointer to next directory entry in [DIRBUF] ; DX = Pointer to first byte after end of DIRBUF ; [LASTENT] = New directory entry number MOV AX,[LASTENT] INC AX ;Start with next entry CMP AX,[BP.MAXENT] JAE NONE GETENT: MOV [LASTENT],AX MOV CL,4 SHL AX,CL XOR DX,DX SHL AX,1 RCL DX,1 ;Account for overflow in last shift MOV BX,[BP.SECSIZ] AND BL,255-31 ;Must be multiple of 32 DIV BX MOV BX,DX ;Position within sector MOV AH,[BP.DEVNUM] ;AL=Directory sector no. CMP AX,[DIRBUFID] JZ HAVDIRBUF PUSH BX CALL DIRREAD POP BX HAVDIRBUF: MOV DX,OFFSET DOSGROUP:DIRBUF ADD BX,DX ADD DX,[BP.SECSIZ] RET NEXTENTRY: ; Inputs: ; Same as outputs of GETENTRY, above ; Function: ; Update AL, BX, and [LASTENT] for next directory entry. ; Carry set if no more. MOV DI,[LASTENT] INC DI CMP DI,[BP.MAXENT] JAE NONE MOV [LASTENT],DI ADD BX,32 CMP BX,DX JB HAVIT INC AL ;Next directory sector PUSH DX ;Save limit CALL DIRREAD POP DX MOV BX,OFFSET DOSGROUP:DIRBUF HAVIT: CLC RET NONE: CALL CHKDIRWRITE STC RET4: RET DELETE: ; System call 19 CALL MOVNAME MOV AL,-1 JC RET4 MOV AL,CS:[ATTRIB] AND AL,6 ;Look only at hidden bits CMP AL,6 ;Both must be set JNZ NOTALL MOV CX,11 MOV AL,"?" MOV DI,OFFSET DOSGROUP:NAME1 REPE SCASB ;See if name is *.* JNZ NOTALL MOV BYTE PTR CS:[DELALL],0 ;DEL *.* - flag deleting all NOTALL: CALL FINDNAME MOV AL,-1 JC RET4 OR BH,BH ;Check if device name JS RET4 ;Can't delete I/O devices DELFILE: MOV BYTE PTR [DIRTYDIR],-1 MOV AH,[DELALL] MOV BYTE PTR [BX],AH MOV BX,[SI] MOV SI,[BP.FAT] OR BX,BX JZ DELNXT CMP BX,[BP.MAXCLUS] JA DELNXT CALL RELEASE DELNXT: CALL CONTSRCH JNC DELFILE CALL FATWRT CALL CHKDIRWRITE XOR AL,AL RET RENAME: ;System call 23 CALL MOVNAME JC ERRET ADD SI,5 MOV DI,OFFSET DOSGROUP:NAME2 CALL LODNAME JC ERRET ;Report error if second name invalid CALL FINDNAME JC ERRET OR BH,BH ;Check if I/O device name JS ERRET ;If so, can't rename it MOV SI,OFFSET DOSGROUP:NAME1 MOV DI,OFFSET DOSGROUP:NAME3 MOV CX,6 ;6 words (12 bytes)--include attribute byte REP MOVSW ;Copy name to search for RENFIL: MOV DI,OFFSET DOSGROUP:NAME1 MOV SI,OFFSET DOSGROUP:NAME2 MOV CX,11 NEWNAM: LODSB CMP AL,"?" JNZ NOCHG MOV AL,[BX] NOCHG: STOSB INC BX LOOP NEWNAM MOV BYTE PTR [DI],6 ;Stop duplicates with any attributes CALL DEVNAME ;Check if giving it a device name JNC RENERR PUSH [LASTENT] ;Save position of match MOV [LASTENT],-1 ;Search entire directory for duplicate CALL CONTSRCH ;See if new name already exists POP AX JNC RENERR ;Error if found CALL GETENT ;Re-read matching entry MOV DI,BX MOV SI,OFFSET DOSGROUP:NAME1 MOV CX,5 MOVSB REP MOVSW ;Replace old name with new one MOV BYTE PTR [DIRTYDIR],-1 ;Flag change in directory MOV SI,OFFSET DOSGROUP:NAME3 MOV DI,OFFSET DOSGROUP:NAME1 MOV CX,6 ;Include attribute byte REP MOVSW ;Copy name back into search buffer CALL CONTSRCH JNC RENFIL CALL CHKDIRWRITE XOR AL,AL RET RENERR: CALL CHKDIRWRITE ERRET: MOV AL,-1 RET5: RET MOVNAME: ; Inputs: ; DS, DX point to FCB or extended FCB ; Outputs: ; DS:DX point to normal FCB ; ES = CS ; If file name OK: ; BP has base of driver parameters ; [NAME1] has name in upper case ; All registers except DX destroyed ; Carry set if bad file name or drive MOV CS:WORD PTR [CREATING],0E500H ;Not creating, not DEL *.* MOV AX,CS MOV ES,AX MOV DI,OFFSET DOSGROUP:NAME1 MOV SI,DX LODSB MOV CS:[EXTFCB],AL ;Set flag if extended FCB in use MOV AH,0 ;Set default attributes CMP AL,-1 ;Is it an extended FCB? JNZ HAVATTRB ADD DX,7 ;Adjust to point to normal FCB ADD SI,6 ;Point to drive select byte MOV AH,[SI-1] ;Get attribute byte LODSB ;Get drive select byte HAVATTRB: MOV CS:[ATTRIB],AH ;Save attributes CALL GETTHISDRV LODNAME: ; This entry point copies a file name from DS,SI ; to ES,DI converting to upper case. CMP BYTE PTR [SI]," " ;Don't allow blank as first letter STC ;In case of error JZ RET5 MOV CX,11 MOVCHK: CALL GETLET JB RET5 JNZ STOLET ;Is it a delimiter? CMP AL," " ;This is the only delimiter allowed STC ;In case of error JNZ RET5 STOLET: STOSB LOOP MOVCHK CLC ;Got through whole name - no error RET6: RET GETTHISDRV: CMP CS:[NUMDRV],AL JC RET6 DEC AL JNS PHYDRV MOV AL,CS:[CURDRV] PHYDRV: MOV CS:[THISDRV],AL RET OPEN: ;System call 15 CALL GETFILE DOOPEN: ; Enter here to perform OPEN on file already found ; in directory. DS=CS, BX points to directory ; entry in DIRBUF, SI points to First Cluster field, and ; ES:DI point to the FCB to be opened. This entry point ; is used by CREATE. JC ERRET OR BH,BH ;Check if file is I/O device JS OPENDEV ;Special handler if so MOV AL,[THISDRV] INC AX STOSB XOR AX,AX IF ZEROEXT ADD DI,11 STOSW ;Zero low byte of extent field if IBM only ENDIF IF NOT ZEROEXT ADD DI,12 ;Point to high half of CURRENT BLOCK field STOSB ;Set it to zero (CP/M programs set low byte) ENDIF MOV AL,128 ;Default record size STOSW ;Set record size LODSW ;Get starting cluster MOV DX,AX ;Save it for the moment MOVSW ;Transfer size to FCB MOVSW MOV AX,[SI-8] ;Get date STOSW ;Save date in FCB MOV AX,[SI-10] ;Get time STOSW ;Save it in FCB MOV AL,[BP.DEVNUM] OR AL,40H STOSB MOV AX,DX ;Restore starting cluster STOSW ; first cluster STOSW ; last cluster accessed XOR AX,AX STOSW ; position of last cluster RET OPENDEV: ADD DI,13 ;point to 2nd half of extent field XOR AX,AX STOSB ;Set it to zero MOV AL,128 STOSW ;Set record size to 128 XOR AX,AX STOSW STOSW ;Set current size to zero CALL DATE16 STOSW ;Date is todays XCHG AX,DX STOSW ;Use current time MOV AL,BH ;Get device number STOSB XOR AL,AL ;No error RET FATERR: XCHG AX,DI ;Put error code in DI MOV AH,2 ;While trying to read FAT MOV AL,[THISDRV] ;Tell which drive CALL FATAL1 JMP SHORT FATREAD STARTSRCH: MOV AX,-1 MOV [LASTENT],AX MOV [ENTFREE],AX FATREAD: ; Inputs: ; DS = CS ; Function: ; If disk may have been changed, FAT is read in and buffers are ; flagged invalid. If not, no action is taken. ; Outputs: ; BP = Base of drive parameters ; Carry set if invalid drive returned by MAPDEV ; All other registers destroyed MOV AL,[THISDRV] XOR AH,AH ;Set default response to zero & clear carry CALL FAR PTR BIOSDSKCHG ;See what BIOS has to say JC FATERR CALL GETBP MOV AL,[THISDRV] ;Use physical unit number MOV SI,[BP.FAT] OR AH,[SI-1] ;Dirty byte for FAT JS NEWDSK ;If either say new disk, then it's so JNZ MAPDRV MOV AH,1 CMP AX,WORD PTR [BUFDRVNO] ;Does buffer have dirty sector of this drive? JZ MAPDRV NEWDSK: CMP AL,[BUFDRVNO] ;See if buffer is for this drive JNZ BUFOK ;If not, don't touch it MOV [BUFSECNO],0 ;Flag buffers invalid MOV WORD PTR [BUFDRVNO],00FFH BUFOK: MOV [DIRBUFID],-1 CALL FIGFAT NEXTFAT: PUSH AX CALL DSKREAD POP AX JC BADFAT SUB AL,[BP.FATCNT] JZ NEWFAT CALL FATWRT NEWFAT: MOV SI,[BP.FAT] MOV AL,[BP.DEVNUM] MOV AH,[SI] ;Get first byte of FAT OR AH,0F8H ;Put in range CALL FAR PTR BIOSMAPDEV MOV AH,0 MOV [SI-2],AX ;Set device no. and reset dirty bit MAPDRV: MOV AL,[SI-2] ;Get device number GETBP: MOV BP,[DRVTAB] ;Just in case drive isn't valid AND AL,3FH ;Mask out dirty bit CMP AL,[NUMIO] CMC JC RET7 PUSH AX MOV AH,DPBSIZ MUL AH ADD BP,AX POP AX RET7: RET BADFAT: MOV CX,DI ADD DX,CX DEC AL JNZ NEXTFAT CALL FIGFAT ;Reset registers CALL DREAD ;Try first FAT once more JMP SHORT NEWFAT OKRET1: MOV AL,0 RET CLOSE: ;System call 16 MOV DI,DX CMP BYTE PTR [DI],-1 ;Check for extended FCB JNZ NORMFCB3 ADD DI,7 NORMFCB3: TEST BYTE PTR [DI.DEVID],0C0H ;Allow only dirty files JNZ OKRET1 ;can't close if I/O device, or not writen MOV AL,[DI] ;Get physical unit number DEC AL ;Make zero = drive A MOV AH,1 ;Look for dirty buffer CMP AX,CS:WORD PTR [BUFDRVNO] JNZ FNDDIR ;Write back dirty buffer if on same drive PUSH DX PUSH DS PUSH CS POP DS MOV BYTE PTR [DIRTYBUF],0 MOV BX,[BUFFER] MOV CX,1 MOV DX,[BUFSECNO] MOV BP,[BUFDRVBP] CALL DWRITE POP DS POP DX FNDDIR: CALL GETFILE BADCLOSEJ: JC BADCLOSE MOV CX,ES:[DI.FIRCLUS] MOV [SI],CX MOV DX,ES:WORD PTR [DI.FILSIZ] MOV [SI+2],DX MOV DX,ES:WORD PTR [DI.FILSIZ+2] MOV [SI+4],DX MOV DX,ES:[DI.FDATE] MOV [SI-2],DX MOV DX,ES:[DI.FTIME] MOV [SI-4],DX CALL DIRWRITE CHKFATWRT: ; Do FATWRT only if FAT is dirty and uses same I/O driver MOV SI,[BP.FAT] MOV AL,[BP.DEVNUM] MOV AH,1 CMP [SI-2],AX ;See if FAT dirty and uses same driver JNZ OKRET FATWRT: ; Inputs: ; DS = CS ; BP = Base of drive parameter table ; Function: ; Write the FAT back to disk and reset FAT ; dirty bit. ; Outputs: ; AL = 0 ; BP unchanged ; All other registers destroyed CALL FIGFAT MOV BYTE PTR [BX-1],0 EACHFAT: PUSH DX PUSH CX PUSH BX PUSH AX CALL DWRITE POP AX POP BX POP CX POP DX ADD DX,CX DEC AL JNZ EACHFAT OKRET: MOV AL,0 RET BADCLOSE: MOV SI,[BP.FAT] MOV BYTE PTR [SI-1],0 MOV AL,-1 RET FIGFAT: ; Loads registers with values needed to read or ; write a FAT. MOV AL,[BP.FATCNT] MOV BX,[BP.FAT] MOV CL,[BP.FATSIZ] ;No. of records occupied by FAT MOV CH,0 MOV DX,[BP.FIRFAT] ;Record number of start of FATs RET DIRCOMP: ; Prepare registers for directory read or write CBW ADD AX,[BP.FIRDIR] MOV DX,AX MOV BX,OFFSET DOSGROUP:DIRBUF MOV CX,1 RET CREATE: ;System call 22 CALL MOVNAME JC ERRET3 MOV DI,OFFSET DOSGROUP:NAME1 MOV CX,11 MOV AL,"?" REPNE SCASB JZ ERRET3 MOV CS:BYTE PTR [CREATING],-1 PUSH DX PUSH DS CALL FINDNAME JNC EXISTENT MOV AX,[ENTFREE] ;First free entry found in FINDNAME CMP AX,-1 JZ ERRPOP CALL GETENT ;Point at that free entry JMP SHORT FREESPOT ERRPOP: POP DS POP DX ERRET3: MOV AL,-1 RET EXISTENT: JNZ ERRPOP ;Error if attributes don't match OR BH,BH ;Check if file is I/O device JS OPENJMP ;If so, no action MOV CX,[SI] ;Get pointer to clusters JCXZ FREESPOT CMP CX,[BP.MAXCLUS] JA FREESPOT PUSH BX MOV BX,CX MOV SI,[BP.FAT] CALL RELEASE ;Free any data already allocated CALL FATWRT POP BX FREESPOT: MOV DI,BX MOV SI,OFFSET DOSGROUP:NAME1 MOV CX,5 MOVSB REP MOVSW MOV AL,[ATTRIB] STOSB XOR AX,AX MOV CL,5 REP STOSW CALL DATE16 XCHG AX,DX STOSW XCHG AX,DX STOSW XOR AX,AX PUSH DI MOV CL,6 SMALLENT: REP STOSB PUSH BX CALL DIRWRITE POP BX POP SI OPENJMP: CLC ;Clear carry so OPEN won't fail POP ES POP DI JMP DOOPEN DIRREAD: ; Inputs: ; DS = CS ; AL = Directory block number ; BP = Base of drive parameters ; Function: ; Read the directory block into DIRBUF. ; Outputs: ; AX,BP unchanged ; All other registers destroyed. PUSH AX CALL CHKDIRWRITE POP AX PUSH AX MOV AH,[BP.DEVNUM] MOV [DIRBUFID],AX CALL DIRCOMP CALL DREAD POP AX RET8: RET DREAD: ; Inputs: ; BX,DS = Transfer address ; CX = Number of sectors ; DX = Absolute record number ; BP = Base of drive parameters ; Function: ; Calls BIOS to perform disk read. If BIOS reports ; errors, will call HARDERR for further action. ; BP preserved. All other registers destroyed. CALL DSKREAD JNC RET8 MOV CS:BYTE PTR [READOP],0 CALL HARDERR CMP AL,1 ;Check for retry JZ DREAD RET ;Ignore otherwise HARDERR: ;Hard disk error handler. Entry conditions: ; DS:BX = Original disk transfer address ; DX = Original logical sector number ; CX = Number of sectors to go (first one gave the error) ; AX = Hardware error code ; DI = Original sector transfer count ; BP = Base of drive parameters ; [READOP] = 0 for read, 1 for write XCHG AX,DI ;Error code in DI, count in AX SUB AX,CX ;Number of sectors successfully transferred ADD DX,AX ;First sector number to retry PUSH DX MUL [BP.SECSIZ] ;Number of bytes transferred POP DX ADD BX,AX ;First address for retry MOV AH,0 ;Flag disk section in error CMP DX,[BP.FIRFAT] ;In reserved area? JB ERRINT INC AH ;Flag for FAT CMP DX,[BP.FIRDIR] ;In FAT? JB ERRINT INC AH CMP DX,[BP.FIRREC] ;In directory? JB ERRINT INC AH ;Must be in data area ERRINT: SHL AH,1 ;Make room for read/write bit OR AH,CS:[READOP] FATAL: MOV AL,[BP.DRVNUM] ;Get drive number FATAL1: PUSH BP ;The only thing we preserve MOV CS:[CONTSTK],SP CLI ;Prepare to play with stack MOV SS,CS:[SSSAVE] MOV SP,CS:[SPSAVE] ;User stack pointer restored INT 24H ;Fatal error interrupt vector MOV CS:[SPSAVE],SP MOV CS:[SSSAVE],SS MOV SP,CS MOV SS,SP MOV SP,CS:[CONTSTK] STI POP BP CMP AL,2 JZ ERROR RET DSKREAD: MOV AL,[BP.DEVNUM] PUSH BP PUSH BX PUSH CX PUSH DX CALL FAR PTR BIOSREAD POP DX POP DI POP BX POP BP RET9: RET CHKDIRWRITE: TEST BYTE PTR [DIRTYDIR],-1 JZ RET9 DIRWRITE: ; Inputs: ; DS = CS ; AL = Directory block number ; BP = Base of drive parameters ; Function: ; Write the directory block into DIRBUF. ; Outputs: ; BP unchanged ; All other registers destroyed. MOV BYTE PTR [DIRTYDIR],0 MOV AL,BYTE PTR [DIRBUFID] CALL DIRCOMP DWRITE: ; Inputs: ; BX,DS = Transfer address ; CX = Number of sectors ; DX = Absolute record number ; BP = Base of drive parameters ; Function: ; Calls BIOS to perform disk write. If BIOS reports ; errors, will call HARDERR for further action. ; BP preserved. All other registers destroyed. MOV AL,[BP.DEVNUM] MOV AH,CS:VERFLG PUSH BP PUSH BX PUSH CX PUSH DX CALL FAR PTR BIOSWRITE POP DX POP DI POP BX POP BP JNC RET9 MOV CS:BYTE PTR [READOP],1 CALL HARDERR CMP AL,1 ;Check for retry JZ DWRITE RET ABORT: LDS SI,CS:DWORD PTR [SPSAVE] MOV DS,[SI.CSSAVE] XOR AX,AX MOV ES,AX MOV SI,SAVEXIT MOV DI,EXIT MOVSW MOVSW MOVSW MOVSW MOVSW MOVSW ERROR: MOV AX,CS MOV DS,AX MOV ES,AX CALL WRTFATS XOR AX,AX CLI MOV SS,[SSSAVE] MOV SP,[SPSAVE] MOV DS,AX MOV SI,EXIT MOV DI,OFFSET DOSGROUP:EXITHOLD MOVSW MOVSW POP AX POP BX POP CX POP DX POP SI POP DI POP BP POP DS POP ES STI ;Stack OK now JMP CS:DWORD PTR [EXITHOLD] SEQRD: ;System call 20 CALL GETREC CALL LOAD JMP SHORT FINSEQ SEQWRT: ;System call 21 CALL GETREC CALL STORE FINSEQ: JCXZ SETNREX ADD AX,1 ADC DX,0 JMP SHORT SETNREX RNDRD: ;System call 33 CALL GETRRPOS1 CALL LOAD JMP SHORT FINRND RNDWRT: ;System call 34 CALL GETRRPOS1 CALL STORE JMP SHORT FINRND BLKRD: ;System call 39 CALL GETRRPOS CALL LOAD JMP SHORT FINBLK BLKWRT: ;System call 40 CALL GETRRPOS CALL STORE FINBLK: LDS SI,DWORD PTR [SPSAVE] MOV [SI.CXSAVE],CX JCXZ FINRND ADD AX,1 ADC DX,0 FINRND: MOV ES:WORD PTR [DI.RR],AX MOV ES:[DI.RR+2],DL OR DH,DH JZ SETNREX MOV ES:[DI.RR+3],DH ;Save 4 byte of RECPOS only if significant SETNREX: MOV CX,AX AND AL,7FH MOV ES:[DI.NR],AL AND CL,80H SHL CX,1 RCL DX,1 MOV AL,CH MOV AH,DL MOV ES:[DI.EXTENT],AX MOV AL,CS:[DSKERR] RET GETRRPOS1: MOV CX,1 GETRRPOS: MOV DI,DX CMP BYTE PTR [DI],-1 JNZ NORMFCB1 ADD DI,7 NORMFCB1: MOV AX,WORD PTR [DI.RR] MOV DX,WORD PTR [DI.RR+2] RET NOFILERR: XOR CX,CX MOV BYTE PTR [DSKERR],4 POP BX RET SETUP: ; Inputs: ; DS:DI point to FCB ; DX:AX = Record position in file of disk transfer ; CX = Record count ; Outputs: ; DS = CS ; ES:DI point to FCB ; BL = DEVID from FCB ; CX = No. of bytes to transfer ; BP = Base of drive parameters ; SI = FAT pointer ; [RECCNT] = Record count ; [RECPOS] = Record position in file ; [FCB] = DI ; [NEXTADD] = Displacement of disk transfer within segment ; [SECPOS] = Position of first sector ; [BYTPOS] = Byte position in file ; [BYTSECPOS] = Byte position in first sector ; [CLUSNUM] = First cluster ; [SECCLUSPOS] = Sector within first cluster ; [DSKERR] = 0 (no errors yet) ; [TRANS] = 0 (No transfers yet) ; [THISDRV] = Physical drive unit number ; If SETUP detects no records will be transfered, it returns 1 level up ; with CX = 0. PUSH AX MOV AL,[DI] DEC AL MOV CS:[THISDRV],AL MOV AL,[DI.DEVID] MOV SI,[DI.RECSIZ] OR SI,SI JNZ HAVRECSIZ MOV SI,128 MOV [DI.RECSIZ],SI HAVRECSIZ: PUSH DS POP ES ;Set ES to DS PUSH CS POP DS ;Set DS to CS OR AL,AL ;Is it a device? JNS NOTDEVICE MOV AL,0 ;Fake in drive 0 so we can get SP NOTDEVICE: CALL GETBP POP AX JC NOFILERR CMP SI,64 ;Check if highest byte of RECPOS is significant JB SMALREC MOV DH,0 ;Ignore MSB if record >= 64 bytes SMALREC: MOV [RECCNT],CX MOV WORD PTR [RECPOS],AX MOV WORD PTR [RECPOS+2],DX MOV [FCB],DI MOV BX,[DMAADD] MOV [NEXTADD],BX MOV BYTE PTR [DSKERR],0 MOV BYTE PTR [TRANS],0 MOV BX,DX MUL SI MOV WORD PTR [BYTPOS],AX PUSH DX MOV AX,BX MUL SI POP BX ADD AX,BX ADC DX,0 ;Ripple carry JNZ EOFERR MOV WORD PTR [BYTPOS+2],AX MOV DX,AX MOV AX,WORD PTR [BYTPOS] MOV BX,[BP.SECSIZ] CMP DX,BX ;See if divide will overflow JNC EOFERR DIV BX MOV [SECPOS],AX MOV [BYTSECPOS],DX MOV DX,AX AND AL,[BP.CLUSMSK] MOV [SECCLUSPOS],AL MOV AX,CX ;Record count MOV CL,[BP.CLUSSHFT] SHR DX,CL MOV [CLUSNUM],DX MUL SI ;Multiply by bytes per record MOV CX,AX ADD AX,[DMAADD] ;See if it will fit in one segment ADC DX,0 JZ OK ;Must be less than 64K MOV AX,[DMAADD] NEG AX ;Amount of room left in segment JNZ PARTSEG ;All 64K available? DEC AX ;If so, reduce by one PARTSEG: XOR DX,DX DIV SI ;How many records will fit? MOV [RECCNT],AX MUL SI ;Translate that back into bytes MOV BYTE PTR [DSKERR],2 ;Flag that trimming took place MOV CX,AX JCXZ NOROOM OK: MOV BL,ES:[DI.DEVID] MOV SI,[BP.FAT] RET EOFERR: MOV BYTE PTR [DSKERR],1 XOR CX,CX NOROOM: POP BX ;Kill return address RET BREAKDOWN: ;Inputs: ; DS = CS ; CX = Length of disk transfer in bytes ; BP = Base of drive parameters ; [BYTSECPOS] = Byte position witin first sector ;Outputs: ; [BYTCNT1] = Bytes to transfer in first sector ; [SECCNT] = No. of whole sectors to transfer ; [BYTCNT2] = Bytes to transfer in last sector ;AX, BX, DX destroyed. No other registers affected. MOV AX,[BYTSECPOS] MOV BX,CX OR AX,AX JZ SAVFIR ;Partial first sector? SUB AX,[BP.SECSIZ] NEG AX ;Max number of bytes left in first sector SUB BX,AX ;Subtract from total length JAE SAVFIR ADD AX,BX ;Don't use all of the rest of the sector XOR BX,BX ;And no bytes are left SAVFIR: MOV [BYTCNT1],AX MOV AX,BX XOR DX,DX DIV [BP.SECSIZ] ;How many whole sectors? MOV [SECCNT],AX MOV [BYTCNT2],DX ;Bytes remaining for last sector RET10: RET FNDCLUS: ; Inputs: ; DS = CS ; CX = No. of clusters to skip ; BP = Base of drive parameters ; SI = FAT pointer ; ES:DI point to FCB ; Outputs: ; BX = Last cluster skipped to ; CX = No. of clusters remaining (0 unless EOF) ; DX = Position of last cluster ; DI destroyed. No other registers affected. MOV BX,ES:[DI.LSTCLUS] MOV DX,ES:[DI.CLUSPOS] OR BX,BX JZ NOCLUS SUB CX,DX JNB FINDIT ADD CX,DX XOR DX,DX MOV BX,ES:[DI.FIRCLUS] FINDIT: JCXZ RET10 SKPCLP: CALL UNPACK CMP DI,0FF8H JAE RET10 XCHG BX,DI INC DX LOOP SKPCLP RET NOCLUS: INC CX DEC DX RET BUFSEC: ; Inputs: ; AL = 0 if buffer must be read, 1 if no pre-read needed ; BP = Base of drive parameters ; [CLUSNUM] = Physical cluster number ; [SECCLUSPOS] = Sector position of transfer within cluster ; [BYTCNT1] = Size of transfer ; Function: ; Insure specified sector is in buffer, flushing buffer before ; read if necessary. ; Outputs: ; SI = Pointer to buffer ; DI = Pointer to transfer address ; CX = Number of bytes ; [NEXTADD] updated ; [TRANS] set to indicate a transfer will occur MOV DX,[CLUSNUM] MOV BL,[SECCLUSPOS] CALL FIGREC MOV [PREREAD],AL CMP DX,[BUFSECNO] JNZ GETSEC MOV AL,[BUFDRVNO] CMP AL,[THISDRV] JZ FINBUF ;Already have it? GETSEC: XOR AL,AL XCHG [DIRTYBUF],AL ;Read dirty flag and reset it OR AL,AL JZ RDSEC PUSH DX PUSH BP MOV BP,[BUFDRVBP] MOV BX,[BUFFER] MOV CX,1 MOV DX,[BUFSECNO] CALL DWRITE POP BP POP DX RDSEC: TEST BYTE PTR [PREREAD],-1 JNZ SETBUF XOR AX,AX MOV [BUFSECNO],AX ;Set buffer valid in case of disk error DEC AX MOV [BUFDRVNO],AL MOV BX,[BUFFER] MOV CX,1 PUSH DX CALL DREAD POP DX SETBUF: MOV [BUFSECNO],DX MOV AL,[THISDRV] MOV [BUFDRVNO],AL MOV [BUFDRVBP],BP FINBUF: MOV BYTE PTR [TRANS],1 ;A transfer is taking place MOV DI,[NEXTADD] MOV SI,DI MOV CX,[BYTCNT1] ADD SI,CX MOV [NEXTADD],SI MOV SI,[BUFFER] ADD SI,[BYTSECPOS] RET BUFRD: XOR AL,AL ;Pre-read necessary CALL BUFSEC PUSH ES MOV ES,[DMAADD+2] SHR CX,1 JNC EVENRD MOVSB EVENRD: REP MOVSW POP ES RET BUFWRT: MOV AX,[SECPOS] INC AX ;Set for next sector MOV [SECPOS],AX CMP AX,[VALSEC] ;Has sector been written before? MOV AL,1 JA NOREAD ;Skip preread if SECPOS>VALSEC MOV AL,0 NOREAD: CALL BUFSEC XCHG DI,SI PUSH DS PUSH ES PUSH CS POP ES MOV DS,[DMAADD+2] SHR CX,1 JNC EVENWRT MOVSB EVENWRT: REP MOVSW POP ES POP DS MOV BYTE PTR [DIRTYBUF],1 RET NEXTSEC: TEST BYTE PTR [TRANS],-1 JZ CLRET MOV AL,[SECCLUSPOS] INC AL CMP AL,[BP.CLUSMSK] JBE SAVPOS MOV BX,[CLUSNUM] CMP BX,0FF8H JAE NONEXT MOV SI,[BP.FAT] CALL UNPACK MOV [CLUSNUM],DI INC [LASTPOS] MOV AL,0 SAVPOS: MOV [SECCLUSPOS],AL CLRET: CLC RET NONEXT: STC RET TRANBUF: LODSB STOSB CMP AL,13 ;Check for carriage return JNZ NORMCH MOV BYTE PTR [SI],10 NORMCH: CMP AL,10 LOOPNZ TRANBUF JNZ ENDRDCON CALL OUT ;Transmit linefeed XOR SI,SI OR CX,CX JNZ GETBUF OR AL,1 ;Clear zero flag--not end of file ENDRDCON: MOV [CONTPOS],SI ENDRDDEV: MOV [NEXTADD],DI POP ES JNZ SETFCBJ ;Zero set if Ctrl-Z found in input MOV DI,[FCB] AND ES:BYTE PTR [DI.DEVID],0FFH-40H ;Mark as no more data available SETFCBJ: JMP SETFCB READDEV: PUSH ES LES DI,DWORD PTR [DMAADD] INC BL JZ READCON INC BL JNZ ENDRDDEV READAUX: CALL AUXIN STOSB CMP AL,1AH LOOPNZ READAUX JMP SHORT ENDRDDEV READCON: PUSH CS POP DS MOV SI,[CONTPOS] OR SI,SI JNZ TRANBUF CMP BYTE PTR [CONBUF],128 JZ GETBUF MOV WORD PTR [CONBUF],0FF80H ;Set up 128-byte buffer with no template GETBUF: PUSH CX PUSH ES PUSH DI MOV DX,OFFSET DOSGROUP:CONBUF CALL BUFIN ;Get input buffer POP DI POP ES POP CX MOV SI,2 + OFFSET DOSGROUP:CONBUF CMP BYTE PTR [SI],1AH ;Check for Ctrl-Z in first character JNZ TRANBUF MOV AL,1AH STOSB MOV AL,10 CALL OUT ;Send linefeed XOR SI,SI JMP SHORT ENDRDCON RDERR: XOR CX,CX JMP WRTERR RDLASTJ:JMP RDLAST LOAD: ; Inputs: ; DS:DI point to FCB ; DX:AX = Position in file to read ; CX = No. of records to read ; Outputs: ; DX:AX = Position of last record read ; CX = No. of bytes read ; ES:DI point to FCB ; LSTCLUS, CLUSPOS fields in FCB set CALL SETUP OR BL,BL ;Check for named device I/O JS READDEV MOV AX,ES:WORD PTR [DI.FILSIZ] MOV BX,ES:WORD PTR [DI.FILSIZ+2] SUB AX,WORD PTR [BYTPOS] SBB BX,WORD PTR [BYTPOS+2] JB RDERR JNZ ENUF OR AX,AX JZ RDERR CMP AX,CX JAE ENUF MOV CX,AX ENUF: CALL BREAKDOWN MOV CX,[CLUSNUM] CALL FNDCLUS OR CX,CX JNZ RDERR MOV [LASTPOS],DX MOV [CLUSNUM],BX CMP [BYTCNT1],0 JZ RDMID CALL BUFRD RDMID: CMP [SECCNT],0 JZ RDLASTJ CALL NEXTSEC JC SETFCB MOV BYTE PTR [TRANS],1 ;A transfer is taking place ONSEC: MOV DL,[SECCLUSPOS] MOV CX,[SECCNT] MOV BX,[CLUSNUM] RDLP: CALL OPTIMIZE PUSH DI PUSH AX PUSH DS MOV DS,[DMAADD+2] PUSH DX PUSH BX PUSHF ;Save carry flag CALL DREAD POPF ;Restore carry flag POP DI ;Initial transfer address POP AX ;First sector transfered POP DS JC NOTBUFFED ;Was one of those sectors in the buffer? CMP BYTE PTR [DIRTYBUF],0 ;Is buffer dirty? JZ NOTBUFFED ;If not no problem ;We have transfered in a sector from disk when a dirty copy of it is in the buffer. ;We must transfer the sector from the buffer to correct memory address SUB AX,[BUFSECNO] ;How many sectors into the transfer? NEG AX MOV CX,[BP.SECSIZ] MUL CX ;How many bytes into the transfer? ADD DI,AX MOV SI,[BUFFER] PUSH ES MOV ES,[DMAADD+2] ;Get disk transfer segment SHR CX,1 REP MOVSW JNC EVENMOV MOVSB EVENMOV: POP ES NOTBUFFED: POP CX POP BX JCXZ RDLAST CMP BX,0FF8H JAE SETFCB MOV DL,0 INC [LASTPOS] ;We'll be using next cluster JMP SHORT RDLP SETFCB: MOV SI,[FCB] MOV AX,[NEXTADD] MOV DI,AX SUB AX,[DMAADD] ;Number of bytes transfered XOR DX,DX MOV CX,ES:[SI.RECSIZ] DIV CX ;Number of records CMP AX,[RECCNT] ;Check if all records transferred JZ FULLREC MOV BYTE PTR [DSKERR],1 OR DX,DX JZ FULLREC ;If remainder 0, then full record transfered MOV BYTE PTR [DSKERR],3 ;Flag partial last record SUB CX,DX ;Bytes left in last record PUSH ES MOV ES,[DMAADD+2] XCHG AX,BX ;Save the record count temporarily XOR AX,AX ;Fill with zeros SHR CX,1 JNC EVENFIL STOSB EVENFIL: REP STOSW XCHG AX,BX ;Restore record count to AX POP ES INC AX ;Add last (partial) record to total FULLREC: MOV CX,AX MOV DI,SI ;ES:DI point to FCB SETCLUS: MOV AX,[CLUSNUM] MOV ES:[DI.LSTCLUS],AX MOV AX,[LASTPOS] MOV ES:[DI.CLUSPOS],AX ADDREC: MOV AX,WORD PTR [RECPOS] MOV DX,WORD PTR [RECPOS+2] JCXZ RET28 ;If no records read, don't change position DEC CX ADD AX,CX ;Update current record position ADC DX,0 INC CX RET28: RET RDLAST: MOV AX,[BYTCNT2] OR AX,AX JZ SETFCB MOV [BYTCNT1],AX CALL NEXTSEC JC SETFCB MOV [BYTSECPOS],0 CALL BUFRD JMP SHORT SETFCB WRTDEV: PUSH DS LDS SI,DWORD PTR [DMAADD] OR BL,40H INC BL JZ WRTCON INC BL JZ WRTAUX INC BL JZ ENDWRDEV ;Done if device is NUL WRTLST: LODSB CMP AL,1AH JZ ENDWRDEV CALL LISTOUT LOOP WRTLST JMP SHORT ENDWRDEV WRTAUX: LODSB CALL AUXOUT CMP AL,1AH LOOPNZ WRTAUX JMP SHORT ENDWRDEV WRTCON: LODSB CMP AL,1AH JZ ENDWRDEV CALL OUT LOOP WRTCON ENDWRDEV: POP DS MOV CX,[RECCNT] MOV DI,[FCB] JMP SHORT ADDREC HAVSTART: MOV CX,AX CALL SKPCLP JCXZ DOWRTJ CALL ALLOCATE JNC DOWRTJ WRTERR: MOV BYTE PTR [DSKERR],1 LVDSK: MOV AX,WORD PTR [RECPOS] MOV DX,WORD PTR [RECPOS+2] MOV DI,[FCB] RET DOWRTJ: JMP DOWRT WRTEOFJ: JMP WRTEOF STORE: ; Inputs: ; DS:DI point to FCB ; DX:AX = Position in file of disk transfer ; CX = Record count ; Outputs: ; DX:AX = Position of last record written ; CX = No. of records written ; ES:DI point to FCB ; LSTCLUS, CLUSPOS fields in FCB set CALL SETUP CALL DATE16 MOV ES:[DI.FDATE],AX MOV ES:[DI.FTIME],DX OR BL,BL JS WRTDEV AND BL,3FH ;Mark file as dirty MOV ES:[DI.DEVID],BL CALL BREAKDOWN MOV AX,WORD PTR [BYTPOS] MOV DX,WORD PTR [BYTPOS+2] JCXZ WRTEOFJ DEC CX ADD AX,CX ADC DX,0 ;AX:DX=last byte accessed DIV [BP.SECSIZ] ;AX=last sector accessed MOV CL,[BP.CLUSSHFT] SHR AX,CL ;Last cluster to be accessed PUSH AX MOV AX,ES:WORD PTR [DI.FILSIZ] MOV DX,ES:WORD PTR [DI.FILSIZ+2] DIV [BP.SECSIZ] OR DX,DX JZ NORNDUP INC AX ;Round up if any remainder NORNDUP: MOV [VALSEC],AX ;Number of sectors that have been written POP AX MOV CX,[CLUSNUM] ;First cluster accessed CALL FNDCLUS MOV [CLUSNUM],BX MOV [LASTPOS],DX SUB AX,DX ;Last cluster minus current cluster JZ DOWRT ;If we have last clus, we must have first JCXZ HAVSTART ;See if no more data PUSH CX ;No. of clusters short of first MOV CX,AX CALL ALLOCATE POP AX JC WRTERR MOV CX,AX MOV DX,[LASTPOS] INC DX DEC CX JZ NOSKIP CALL SKPCLP NOSKIP: MOV [CLUSNUM],BX MOV [LASTPOS],DX DOWRT: CMP [BYTCNT1],0 JZ WRTMID MOV BX,[CLUSNUM] CALL BUFWRT WRTMID: MOV AX,[SECCNT] OR AX,AX JZ WRTLAST ADD [SECPOS],AX CALL NEXTSEC MOV BYTE PTR [TRANS],1 ;A transfer is taking place MOV DL,[SECCLUSPOS] MOV BX,[CLUSNUM] MOV CX,[SECCNT] WRTLP: CALL OPTIMIZE JC NOTINBUF ;Is one of the sectors buffered? MOV [BUFSECNO],0 ;If so, invalidate the buffer since we're MOV WORD PTR [BUFDRVNO],0FFH ; completely rewritting it NOTINBUF: PUSH DI PUSH AX PUSH DS MOV DS,[DMAADD+2] CALL DWRITE POP DS POP CX POP BX JCXZ WRTLAST MOV DL,0 INC [LASTPOS] ;We'll be using next cluster JMP SHORT WRTLP WRTLAST: MOV AX,[BYTCNT2] OR AX,AX JZ FINWRT MOV [BYTCNT1],AX CALL NEXTSEC MOV [BYTSECPOS],0 CALL BUFWRT FINWRT: MOV AX,[NEXTADD] SUB AX,[DMAADD] ADD AX,WORD PTR [BYTPOS] MOV DX,WORD PTR [BYTPOS+2] ADC DX,0 MOV CX,DX MOV DI,[FCB] CMP AX,ES:WORD PTR [DI.FILSIZ] SBB CX,ES:WORD PTR [DI.FILSIZ+2] JB SAMSIZ MOV ES:WORD PTR [DI.FILSIZ],AX MOV ES:WORD PTR [DI.FILSIZ+2],DX SAMSIZ: MOV CX,[RECCNT] JMP SETCLUS WRTERRJ:JMP WRTERR WRTEOF: MOV CX,AX OR CX,DX JZ KILLFIL SUB AX,1 SBB DX,0 DIV [BP.SECSIZ] MOV CL,[BP.CLUSSHFT] SHR AX,CL MOV CX,AX CALL FNDCLUS JCXZ RELFILE CALL ALLOCATE JC WRTERRJ UPDATE: MOV DI,[FCB] MOV AX,WORD PTR [BYTPOS] MOV ES:WORD PTR [DI.FILSIZ],AX MOV AX,WORD PTR [BYTPOS+2] MOV ES:WORD PTR [DI.FILSIZ+2],AX XOR CX,CX JMP ADDREC RELFILE: MOV DX,0FFFH CALL RELBLKS SETDIRT: MOV BYTE PTR [SI-1],1 JMP SHORT UPDATE KILLFIL: XOR BX,BX XCHG BX,ES:[DI.FIRCLUS] OR BX,BX JZ UPDATE CALL RELEASE JMP SHORT SETDIRT OPTIMIZE: ; Inputs: ; DS = CS ; BX = Physical cluster ; CX = No. of records ; DL = sector within cluster ; BP = Base of drives parameters ; [NEXTADD] = transfer address ; Outputs: ; AX = No. of records remaining ; BX = Transfer address ; CX = No. or records to be transferred ; DX = Physical sector address ; DI = Next cluster ; Carry clear if a sector to transfer is in the buffer ; Carry set otherwise ; [CLUSNUM] = Last cluster accessed ; [NEXTADD] updated ; BP unchanged. Note that segment of transfer not set. PUSH DX PUSH BX MOV AL,[BP.CLUSMSK] INC AL ;Number of sectors per cluster MOV AH,AL SUB AL,DL ;AL = Number of sectors left in first cluster MOV DX,CX MOV SI,[BP.FAT] MOV CX,0 OPTCLUS: ;AL has number of sectors available in current cluster ;AH has number of sectors available in next cluster ;BX has current physical cluster ;CX has number of sequential sectors found so far ;DX has number of sectors left to transfer ;SI has FAT pointer CALL UNPACK ADD CL,AL ADC CH,0 CMP CX,DX JAE BLKDON MOV AL,AH INC BX CMP DI,BX JZ OPTCLUS DEC BX FINCLUS: MOV [CLUSNUM],BX ;Last cluster accessed SUB DX,CX ;Number of sectors still needed PUSH DX MOV AX,CX MUL [BP.SECSIZ] ;Number of sectors times sector size MOV SI,[NEXTADD] ADD AX,SI ;Adjust by size of transfer MOV [NEXTADD],AX POP AX ;Number of sectors still needed POP DX ;Starting cluster SUB BX,DX ;Number of new clusters accessed ADD [LASTPOS],BX POP BX ;BL = sector postion within cluster CALL FIGREC MOV BX,SI ;Now let's see if any of these sectors are already in the buffer CMP [BUFSECNO],DX JC RET100 ;If DX > [BUFSECNO] then not in buffer MOV SI,DX ADD SI,CX ;Last sector + 1 CMP [BUFSECNO],SI CMC JC RET100 ;If SI <= [BUFSECNO] then not in buffer PUSH AX MOV AL,[BP.DEVNUM] CMP AL,[BUFDRVNO] ;Is buffer for this drive? POP AX JZ RET100 ;If so, then we match STC ;No match RET100: RET BLKDON: SUB CX,DX ;Number of sectors in cluster we don't want SUB AH,CL ;Number of sectors in cluster we accepted DEC AH ;Adjust to mean position within cluster MOV [SECCLUSPOS],AH MOV CX,DX ;Anyway, make the total equal to the request JMP SHORT FINCLUS FIGREC: ;Inputs: ; DX = Physical cluster number ; BL = Sector postion within cluster ; BP = Base of drive parameters ;Outputs: ; DX = physical sector number ;No other registers affected. PUSH CX MOV CL,[BP.CLUSSHFT] DEC DX DEC DX SHL DX,CL OR DL,BL ADD DX,[BP.FIRREC] POP CX RET GETREC: ; Inputs: ; DS:DX point to FCB ; Outputs: ; CX = 1 ; DX:AX = Record number determined by EXTENT and NR fields ; DS:DI point to FCB ; No other registers affected. MOV DI,DX CMP BYTE PTR [DI],-1 ;Check for extended FCB JNZ NORMFCB2 ADD DI,7 NORMFCB2: MOV CX,1 MOV AL,[DI.NR] MOV DX,[DI.EXTENT] SHL AL,1 SHR DX,1 RCR AL,1 MOV AH,DL MOV DL,DH MOV DH,0 RET ALLOCATE: ; Inputs: ; DS = CS ; ES = Segment of FCB ; BX = Last cluster of file (0 if null file) ; CX = No. of clusters to allocate ; DX = Position of cluster BX ; BP = Base of drive parameters ; SI = FAT pointer ; [FCB] = Displacement of FCB within segment ; Outputs: ; IF insufficient space ; THEN ; Carry set ; CX = max. no. of records that could be added to file ; ELSE ; Carry clear ; BX = First cluster allocated ; FAT is fully updated including dirty bit ; FIRCLUS field of FCB set if file was null ; SI,BP unchanged. All other registers destroyed. PUSH [SI] PUSH DX PUSH CX PUSH BX MOV AX,BX ALLOC: MOV DX,BX FINDFRE: INC BX CMP BX,[BP.MAXCLUS] JLE TRYOUT CMP AX,1 JG TRYIN POP BX MOV DX,0FFFH CALL RELBLKS POP AX ;No. of clusters requested SUB AX,CX ;AX=No. of clusters allocated POP DX POP [SI] INC DX ;Position of first cluster allocated ADD AX,DX ;AX=max no. of cluster in file MOV DL,[BP.CLUSMSK] MOV DH,0 INC DX ;DX=records/cluster MUL DX ;AX=max no. of records in file MOV CX,AX SUB CX,WORD PTR [RECPOS] ;CX=max no. of records that could be written JA MAXREC XOR CX,CX ;If CX was negative, zero it MAXREC: STC RET11: RET TRYOUT: CALL UNPACK JZ HAVFRE TRYIN: DEC AX JLE FINDFRE XCHG AX,BX CALL UNPACK JZ HAVFRE XCHG AX,BX JMP SHORT FINDFRE HAVFRE: XCHG BX,DX MOV AX,DX CALL PACK MOV BX,AX LOOP ALLOC MOV DX,0FFFH CALL PACK MOV BYTE PTR [SI-1],1 POP BX POP CX ;Don't need this stuff since we're successful POP DX CALL UNPACK POP [SI] XCHG BX,DI OR DI,DI JNZ RET11 MOV DI,[FCB] MOV ES:[DI.FIRCLUS],BX RET12: RET RELEASE: ; Inputs: ; DS = CS ; BX = Cluster in file ; SI = FAT pointer ; BP = Base of drive parameters ; Function: ; Frees cluster chain starting with [BX] ; AX,BX,DX,DI all destroyed. Other registers unchanged. XOR DX,DX RELBLKS: ; Enter here with DX=0FFFH to put an end-of-file mark ; in the first cluster and free the rest in the chain. CALL UNPACK JZ RET12 MOV AX,DI CALL PACK CMP AX,0FF8H MOV BX,AX JB RELEASE RET13: RET GETEOF: ; Inputs: ; BX = Cluster in a file ; SI = Base of drive FAT ; DS = CS ; Outputs: ; BX = Last cluster in the file ; DI destroyed. No other registers affected. CALL UNPACK CMP DI,0FF8H JAE RET13 MOV BX,DI JMP SHORT GETEOF SRCHFRST: ;System call 17 CALL GETFILE SAVPLCE: ; Search-for-next enters here to save place and report ; findings. JC KILLSRCH OR BH,BH JS SRCHDEV MOV AX,[LASTENT] MOV ES:[DI.FILDIRENT],AX MOV ES:[DI.DRVBP],BP ;Information in directory entry must be copied into the first ; 33 bytes starting at the disk transfer address. MOV SI,BX LES DI,DWORD PTR [DMAADD] MOV AX,00FFH CMP AL,[EXTFCB] JNZ NORMFCB STOSW INC AL STOSW STOSW MOV AL,[ATTRIB] STOSB NORMFCB: MOV AL,[THISDRV] INC AL STOSB ;Set drive number MOV CX,16 REP MOVSW ;Copy remaining 10 characters of name XOR AL,AL RET KILLSRCH: KILLSRCH1 EQU KILLSRCH+1 ;The purpose of the KILLSRCH1 label is to provide a jump label to the following ; instruction which leaves out the segment override. MOV WORD PTR ES:[DI.FILDIRENT],-1 MOV AL,-1 RET SRCHDEV: MOV ES:[DI.FILDIRENT],BX LES DI,DWORD PTR [DMAADD] XOR AX,AX STOSB ;Zero drive byte SUB SI,4 ;Point to device name MOVSW MOVSW MOV AX,2020H STOSB STOSW STOSW STOSW ;Fill with 8 blanks XOR AX,AX MOV CX,10 REP STOSW STOSB RET14: RET SRCHNXT: ;System call 18 CALL MOVNAME MOV DI,DX JC NEAR PTR KILLSRCH1 MOV BP,[DI.DRVBP] MOV AX,[DI.FILDIRENT] OR AX,AX JS NEAR PTR KILLSRCH1 PUSH DX PUSH DS PUSH CS POP DS MOV [LASTENT],AX CALL CONTSRCH POP ES POP DI JMP SAVPLCE FILESIZE: ;System call 35 CALL GETFILE MOV AL,-1 JC RET14 ADD DI,33 ;Write size in RR field MOV CX,ES:[DI.RECSIZ-33] OR CX,CX JNZ RECOK MOV CX,128 RECOK: XOR AX,AX XOR DX,DX ;Intialize size to zero OR BH,BH ;Check for named I/O device JS DEVSIZ INC SI INC SI ;Point to length field MOV AX,[SI+2] ;Get high word of size DIV CX PUSH AX ;Save high part of result LODSW ;Get low word of size DIV CX OR DX,DX ;Check for zero remainder POP DX JZ DEVSIZ INC AX ;Round up for partial record JNZ DEVSIZ ;Propagate carry? INC DX DEVSIZ: STOSW MOV AX,DX STOSB MOV AL,0 CMP CX,64 JAE RET14 ;Only 3-byte field if RECSIZ >= 64 MOV ES:[DI],AH RET SETDMA: ;System call 26 MOV CS:[DMAADD],DX MOV CS:[DMAADD+2],DS RET NOSUCHDRV: MOV AL,-1 RET GETFATPT: ;System call 27 MOV DL,0 ;Use default drive GETFATPTDL: ;System call 28 PUSH CS POP DS MOV AL,DL CALL GETTHISDRV JC NOSUCHDRV CALL FATREAD MOV BX,[BP.FAT] MOV AL,[BP.CLUSMSK] INC AL MOV DX,[BP.MAXCLUS] DEC DX MOV CX,[BP.SECSIZ] LDS SI,DWORD PTR [SPSAVE] MOV [SI.BXSAVE],BX MOV [SI.DXSAVE],DX MOV [SI.CXSAVE],CX MOV [SI.DSSAVE],CS RET GETDSKPT: ;System call 31 PUSH CS POP DS MOV AL,[CURDRV] MOV [THISDRV],AL CALL FATREAD LDS SI,DWORD PTR [SPSAVE] MOV [SI.BXSAVE],BP MOV [SI.DSSAVE],CS RET DSKRESET: ;System call 13 PUSH CS POP DS WRTFATS: ; DS=CS. Writes back all dirty FATs. All registers destroyed. XOR AL,AL XCHG AL,[DIRTYBUF] OR AL,AL JZ NOBUF MOV BP,[BUFDRVBP] MOV DX,[BUFSECNO] MOV BX,[BUFFER] MOV CX,1 CALL DWRITE NOBUF: MOV CL,[NUMIO] MOV CH,0 MOV BP,[DRVTAB] WRTFAT: PUSH CX CALL CHKFATWRT POP CX ADD BP,DPBSIZ LOOP WRTFAT RET GETDRV: ;System call 25 MOV AL,CS:[CURDRV] RET15: RET SETRNDREC: ;System call 36 CALL GETREC MOV [DI+33],AX MOV [DI+35],DL CMP [DI.RECSIZ],64 JAE RET15 MOV [DI+36],DH ;Set 4th byte only if record size < 64 RET16: RET SELDSK: ;System call 14 MOV AL,CS:[NUMDRV] CMP DL,AL JNB RET17 MOV CS:[CURDRV],DL RET17: RET BUFIN: ;System call 10 MOV AX,CS MOV ES,AX MOV SI,DX MOV CH,0 LODSW OR AL,AL JZ RET17 MOV BL,AH MOV BH,CH CMP AL,BL JBE NOEDIT CMP BYTE PTR [BX+SI],0DH JZ EDITON NOEDIT: MOV BL,CH EDITON: MOV DL,AL DEC DX NEWLIN: MOV AL,CS:[CARPOS] MOV CS:[STARTPOS],AL PUSH SI MOV DI,OFFSET DOSGROUP:INBUF MOV AH,CH MOV BH,CH MOV DH,CH GETCH: CALL IN CMP AL,"F"-"@" ;Ignore ^F JZ GETCH CMP AL,CS:ESCCHAR JZ ESC CMP AL,7FH JZ BACKSP CMP AL,8 JZ BACKSP CMP AL,13 JZ ENDLIN CMP AL,10 JZ PHYCRLF CMP AL,CANCEL JZ KILNEW SAVCH: CMP DH,DL JAE BUFFUL STOSB INC DH CALL BUFOUT OR AH,AH JNZ GETCH CMP BH,BL JAE GETCH INC SI INC BH JMP SHORT GETCH BUFFUL: MOV AL,7 CALL OUT JMP SHORT GETCH ESC: CALL IN MOV CL,ESCTABLEN PUSH DI MOV DI,OFFSET DOSGROUP:ESCTAB REPNE SCASB POP DI SHL CX,1 MOV BP,CX JMP [BP+OFFSET DOSGROUP:ESCFUNC] ENDLIN: STOSB CALL OUT POP DI MOV [DI-1],DH INC DH COPYNEW: MOV BP,ES MOV BX,DS MOV ES,BX MOV DS,BP MOV SI,OFFSET DOSGROUP:INBUF MOV CL,DH REP MOVSB RET CRLF: MOV AL,13 CALL OUT MOV AL,10 JMP OUT PHYCRLF: CALL CRLF JMP SHORT GETCH KILNEW: MOV AL,"\" CALL OUT POP SI PUTNEW: CALL CRLF MOV AL,CS:[STARTPOS] CALL TAB JMP NEWLIN BACKSP: OR DH,DH JZ OLDBAK CALL BACKUP MOV AL,ES:[DI] CMP AL," " JAE OLDBAK CMP AL,9 JZ BAKTAB CALL BACKMES OLDBAK: OR AH,AH JNZ GETCH1 OR BH,BH JZ GETCH1 DEC BH DEC SI GETCH1: JMP GETCH BAKTAB: PUSH DI DEC DI STD MOV CL,DH MOV AL," " PUSH BX MOV BL,7 JCXZ FIGTAB FNDPOS: SCASB JNA CHKCNT CMP ES:BYTE PTR [DI+1],9 JZ HAVTAB DEC BL CHKCNT: LOOP FNDPOS FIGTAB: SUB BL,CS:[STARTPOS] HAVTAB: SUB BL,DH ADD CL,BL AND CL,7 CLD POP BX POP DI JZ OLDBAK TABBAK: CALL BACKMES LOOP TABBAK JMP SHORT OLDBAK BACKUP: DEC DH DEC DI BACKMES: MOV AL,8 CALL OUT MOV AL," " CALL OUT MOV AL,8 JMP OUT TWOESC: MOV AL,ESCCH JMP SAVCH COPYLIN: MOV CL,BL SUB CL,BH JMP SHORT COPYEACH COPYSTR: CALL FINDOLD JMP SHORT COPYEACH COPYONE: MOV CL,1 COPYEACH: MOV AH,0 CMP DH,DL JZ GETCH2 CMP BH,BL JZ GETCH2 LODSB STOSB CALL BUFOUT INC BH INC DH LOOP COPYEACH GETCH2: JMP GETCH SKIPONE: CMP BH,BL JZ GETCH2 INC BH INC SI JMP GETCH SKIPSTR: CALL FINDOLD ADD SI,CX ADD BH,CL JMP GETCH FINDOLD: CALL IN MOV CL,BL SUB CL,BH JZ NOTFND DEC CX JZ NOTFND PUSH ES PUSH DS POP ES PUSH DI MOV DI,SI INC DI REPNE SCASB POP DI POP ES JNZ NOTFND NOT CL ADD CL,BL SUB CL,BH RET30: RET NOTFND: POP BP JMP GETCH REEDIT: MOV AL,"@" CALL OUT POP DI PUSH DI PUSH ES PUSH DS CALL COPYNEW POP DS POP ES POP SI MOV BL,DH JMP PUTNEW ENTERINS: IF TOGLINS NOT AH JMP GETCH ENDIF IF NOT TOGLINS MOV AH,-1 JMP GETCH EXITINS: MOV AH,0 JMP GETCH ENDIF ESCFUNC DW GETCH DW TWOESC IF NOT TOGLINS DW EXITINS ENDIF DW ENTERINS DW BACKSP DW REEDIT DW KILNEW DW COPYLIN DW SKIPSTR DW COPYSTR DW SKIPONE DW COPYONE IF IBM DW COPYONE DW CTRLZ CTRLZ: MOV AL,"Z"-"@" JMP SAVCH ENDIF BUFOUT: CMP AL," " JAE OUT CMP AL,9 JZ OUT PUSH AX MOV AL,"^" CALL OUT POP AX OR AL,40H JMP SHORT OUT NOSTOP: CMP AL,"P"-"@" JZ INCHK IF NOT TOGLPRN CMP AL,"N"-"@" JZ INCHK ENDIF CMP AL,"C"-"@" JZ INCHK RET CONOUT: ;System call 2 MOV AL,DL OUT: CMP AL,20H JB CTRLOUT CMP AL,7FH JZ OUTCH INC CS:BYTE PTR [CARPOS] OUTCH: PUSH AX CALL STATCHK POP AX CALL FAR PTR BIOSOUT TEST CS:BYTE PTR [PFLAG],-1 JZ RET18 CALL FAR PTR BIOSPRINT RET18: RET STATCHK: CALL FAR PTR BIOSSTAT JZ RET18 CMP AL,'S'-'@' JNZ NOSTOP CALL FAR PTR BIOSIN ;Eat Cntrl-S INCHK: CALL FAR PTR BIOSIN CMP AL,'P'-'@' JZ PRINTON IF NOT TOGLPRN CMP AL,'N'-'@' JZ PRINTOFF ENDIF CMP AL,'C'-'@' JNZ RET18 ; Ctrl-C handler. ; "^C" and CR/LF is printed. Then the user registers are restored and the ; user CTRL-C handler is executed. At this point the top of the stack has ; 1) the interrupt return address should the user CTRL-C handler wish to ; allow processing to continue; 2) the original interrupt return address ; to the code that performed the function call in the first place. If the ; user CTRL-C handler wishes to continue, it must leave all registers ; unchanged and IRET. The function that was interrupted will simply be ; repeated. MOV AL,3 ;Display "^C" CALL BUFOUT CALL CRLF CLI ;Prepare to play with stack MOV SS,CS:[SSSAVE] MOV SP,CS:[SPSAVE] ;User stack now restored POP AX POP BX POP CX POP DX POP SI POP DI POP BP POP DS POP ES ;User registers now restored INT CONTC ;Execute user Ctrl-C handler JMP COMMAND ;Repeat command otherwise PRINTON: IF TOGLPRN NOT CS:BYTE PTR [PFLAG] RET ENDIF IF NOT TOGLPRN MOV CS:BYTE PTR [PFLAG],1 RET PRINTOFF: MOV CS:BYTE PTR [PFLAG],0 RET ENDIF CTRLOUT: CMP AL,13 JZ ZERPOS CMP AL,8 JZ BACKPOS CMP AL,9 JNZ OUTCHJ MOV AL,CS:[CARPOS] OR AL,0F8H NEG AL TAB: PUSH CX MOV CL,AL MOV CH,0 JCXZ POPTAB TABLP: MOV AL," " CALL OUT LOOP TABLP POPTAB: POP CX RET19: RET ZERPOS: MOV CS:BYTE PTR [CARPOS],0 OUTCHJ: JMP OUTCH BACKPOS: DEC CS:BYTE PTR [CARPOS] JMP OUTCH CONSTAT: ;System call 11 CALL STATCHK MOV AL,0 JZ RET19 OR AL,-1 RET CONIN: ;System call 1 CALL IN PUSH AX CALL OUT POP AX RET IN: ;System call 8 CALL INCHK JZ IN RET29: RET RAWIO: ;System call 6 MOV AL,DL CMP AL,-1 JNZ RAWOUT LDS SI,DWORD PTR CS:[SPSAVE] ;Get pointer to register save area CALL FAR PTR BIOSSTAT JNZ RESFLG OR BYTE PTR [SI.FSAVE],40H ;Set user's zero flag XOR AL,AL RET RESFLG: AND BYTE PTR [SI.FSAVE],0FFH-40H ;Reset user's zero flag RAWINP: ;System call 7 CALL FAR PTR BIOSIN RET RAWOUT: CALL FAR PTR BIOSOUT RET LIST: ;System call 5 MOV AL,DL LISTOUT: PUSH AX CALL STATCHK POP AX CALL FAR PTR BIOSPRINT RET20: RET PRTBUF: ;System call 9 MOV SI,DX OUTSTR: LODSB CMP AL,"$" JZ RET20 CALL OUT JMP SHORT OUTSTR OUTMES: ;String output for internal messages LODS CS:BYTE PTR [SI] CMP AL,"$" JZ RET20 CALL OUT JMP SHORT OUTMES MAKEFCB: ;Interrupt call 41 DRVBIT EQU 2 NAMBIT EQU 4 EXTBIT EQU 8 MOV DL,0 ;Flag--not ambiguous file name TEST AL,DRVBIT ;Use current drive field if default? JNZ DEFDRV MOV BYTE PTR ES:[DI],0 ;No - use default drive DEFDRV: INC DI MOV CX,8 TEST AL,NAMBIT ;Use current name fiels as defualt? XCHG AX,BX ;Save bits in BX MOV AL," " JZ FILLB ;If not, go fill with blanks ADD DI,CX XOR CX,CX ;Don't fill any FILLB: REP STOSB MOV CL,3 TEST BL,EXTBIT ;Use current extension as default JZ FILLB2 ADD DI,CX XOR CX,CX FILLB2: REP STOSB XCHG AX,CX ;Put zero in AX STOSW STOSW ;Initialize two words after to zero SUB DI,16 ;Point back at start TEST BL,1 ;Scan off separators if not zero JZ SKPSPC CALL SCANB ;Peel off blanks and tabs CALL DELIM ;Is it a one-time-only delimiter? JNZ NOSCAN INC SI ;Skip over the delimiter SKPSPC: CALL SCANB ;Always kill preceding blanks and tabs NOSCAN: CALL GETLET JBE NODRV ;Quit if termination character CMP BYTE PTR[SI],":" ;Check for potential drive specifier JNZ NODRV INC SI ;Skip over colon SUB AL,"@" ;Convert drive letter to binary drive number JBE BADDRV ;Valid drive numbers are 1-15 CMP AL,CS:[NUMDRV] JBE HAVDRV BADDRV: MOV DL,-1 HAVDRV: STOSB ;Put drive specifier in first byte INC SI DEC DI ;Counteract next two instructions NODRV: DEC SI ;Back up INC DI ;Skip drive byte MOV CX,8 CALL GETWORD ;Get 8-letter file name CMP BYTE PTR [SI],"." JNZ NODOT INC SI ;Skip over dot if present MOV CX,3 ;Get 3-letter extension CALL MUSTGETWORD NODOT: LDS BX,CS:DWORD PTR [SPSAVE] MOV [BX.SISAVE],SI MOV AL,DL RET NONAM: ADD DI,CX DEC SI RET GETWORD: CALL GETLET JBE NONAM ;Exit if invalid character DEC SI MUSTGETWORD: CALL GETLET JBE FILLNAM JCXZ MUSTGETWORD DEC CX CMP AL,"*" ;Check for ambiguous file specifier JNZ NOSTAR MOV AL,"?" REP STOSB NOSTAR: STOSB CMP AL,"?" JNZ MUSTGETWORD OR DL,1 ;Flag ambiguous file name JMP MUSTGETWORD FILLNAM: MOV AL," " REP STOSB DEC SI RET21: RET SCANB: LODSB CALL SPCHK JZ SCANB DEC SI RET GETLET: ;Get a byte from [SI], convert it to upper case, and compare for delimiter. ;ZF set if a delimiter, CY set if a control character (other than TAB). LODSB AND AL,7FH CMP AL,"a" JB CHK CMP AL,"z" JA CHK SUB AL,20H ;Convert to upper case CHK: CMP AL,"." JZ RET21 CMP AL,'"' JZ RET21 CMP AL,"/" JZ RET21 CMP AL,"[" JZ RET21 CMP AL,"]" JZ RET21 IF IBM DELIM: ENDIF CMP AL,":" ;Allow ":" as separator in IBM version JZ RET21 IF NOT IBM DELIM: ENDIF CMP AL,"+" JZ RET101 CMP AL,"=" JZ RET101 CMP AL,";" JZ RET101 CMP AL,"," JZ RET101 SPCHK: CMP AL,9 ;Filter out tabs too JZ RET101 ;WARNING! " " MUST be the last compare CMP AL," " RET101: RET SETVECT: ; Interrupt call 37 XOR BX,BX MOV ES,BX MOV BL,AL SHL BX,1 SHL BX,1 MOV ES:[BX],DX MOV ES:[BX+2],DS RET NEWBASE: ; Interrupt call 38 MOV ES,DX LDS SI,CS:DWORD PTR [SPSAVE] MOV DS,[SI.CSSAVE] XOR SI,SI MOV DI,SI MOV AX,DS:[2] MOV CX,80H REP MOVSW SETMEM: ; Inputs: ; AX = Size of memory in paragraphs ; DX = Segment ; Function: ; Completely prepares a program base at the ; specified segment. ; Outputs: ; DS = DX ; ES = DX ; [0] has INT 20H ; [2] = First unavailable segment ([ENDMEM]) ; [5] to [9] form a long call to the entry point ; [10] to [13] have exit address (from INT 22H) ; [14] to [17] have ctrl-C exit address (from INT 23H) ; [18] to [21] have fatal error address (from INT 24H) ; DX,BP unchanged. All other registers destroyed. XOR CX,CX MOV DS,CX MOV ES,DX MOV SI,EXIT MOV DI,SAVEXIT MOVSW MOVSW MOVSW MOVSW MOVSW MOVSW MOV ES:[2],AX SUB AX,DX CMP AX,MAXDIF JBE HAVDIF MOV AX,MAXDIF HAVDIF: MOV BX,ENTRYPOINTSEG SUB BX,AX SHL AX,1 SHL AX,1 SHL AX,1 SHL AX,1 MOV DS,DX MOV DS:[6],AX MOV DS:[8],BX MOV DS:[0],20CDH ;"INT INTTAB" MOV DS:(BYTE PTR [5]),LONGCALL RET DATE16: PUSH CX CALL READTIME SHL CL,1 ;Minutes to left part of byte SHL CL,1 SHL CX,1 ;Push hours and minutes to left end SHL CX,1 SHL CX,1 SHR DH,1 ;Count every two seconds OR CL,DH ;Combine seconds with hours and minutes MOV DX,CX POP CX MOV AX,WORD PTR [MONTH] ;Fetch month and year SHL AL,1 ;Push month to left to make room for day SHL AL,1 SHL AL,1 SHL AL,1 SHL AX,1 OR AL,[DAY] RET22: RET FOURYEARS EQU 3*365+366 READTIME: ;Gets time in CX:DX. Figures new date if it has changed. ;Uses AX, CX, DX. CALL FAR PTR BIOSGETTIME CMP AX,[DAYCNT] ;See if day count is the same JZ RET22 CMP AX,FOURYEARS*30 ;Number of days in 120 years JAE RET22 ;Ignore if too large MOV [DAYCNT],AX PUSH SI PUSH CX PUSH DX ;Save time XOR DX,DX MOV CX,FOURYEARS ;Number of days in 4 years DIV CX ;Compute number of 4-year units SHL AX,1 SHL AX,1 SHL AX,1 ;Multiply by 8 (no. of half-years) MOV CX,AX ;<240 implies AH=0 MOV SI,OFFSET DOSGROUP:YRTAB ;Table of days in each year CALL DSLIDE ;Find out which of four years we're in SHR CX,1 ;Convert half-years to whole years JNC SK ;Extra half-year? ADD DX,200 SK: CALL SETYEAR MOV CL,1 ;At least at first month in year MOV SI,OFFSET DOSGROUP:MONTAB ;Table of days in each month CALL DSLIDE ;Find out which month we're in MOV [MONTH],CL INC DX ;Remainder is day of month (start with one) MOV [DAY],DL CALL WKDAY ;Set day of week POP DX POP CX POP SI RET23: RET DSLIDE: MOV AH,0 DSLIDE1: LODSB ;Get count of days CMP DX,AX ;See if it will fit JB RET23 ;If not, done SUB DX,AX INC CX ;Count one more month/year JMP SHORT DSLIDE1 SETYEAR: ;Set year with value in CX. Adjust length of February for this year. MOV BYTE PTR [YEAR],CL CHKYR: TEST CL,3 ;Check for leap year MOV AL,28 JNZ SAVFEB ;28 days if no leap year INC AL ;Add leap day SAVFEB: MOV [MONTAB+1],AL ;Store for February RET ;Days in year YRTAB DB 200,166 ;Leap year DB 200,165 DB 200,165 DB 200,165 ;Days of each month MONTAB DB 31 ;January DB 28 ;February--reset each time year changes DB 31 ;March DB 30 ;April DB 31 ;May DB 30 ;June DB 31 ;July DB 31 ;August DB 30 ;September DB 31 ;October DB 30 ;November DB 31 ;December GETDATE: ;Function call 42 PUSH CS POP DS CALL READTIME ;Check for rollover to next day MOV AX,[YEAR] MOV BX,WORD PTR [DAY] LDS SI,DWORD PTR [SPSAVE] ;Get pointer to user registers MOV [SI.DXSAVE],BX ;DH=month, DL=day ADD AX,1980 ;Put bias back MOV [SI.CXSAVE],AX ;CX=year MOV AL,CS:[WEEKDAY] RET24: RET SETDATE: ;Function call 43 MOV AL,-1 ;Be ready to flag error SUB CX,1980 ;Fix bias in year JC RET24 ;Error if not big enough CMP CX,119 ;Year must be less than 2100 JA RET24 OR DH,DH JZ RET24 OR DL,DL JZ RET24 ;Error if either month or day is 0 CMP DH,12 ;Check against max. month JA RET24 PUSH CS POP DS CALL CHKYR ;Set Feb. up for new year MOV AL,DH MOV BX,OFFSET DOSGROUP:MONTAB-1 XLAT ;Look up days in month CMP AL,DL MOV AL,-1 ;Restore error flag, just in case JB RET24 ;Error if too many days CALL SETYEAR MOV WORD PTR [DAY],DX ;Set both day and month SHR CX,1 SHR CX,1 MOV AX,FOURYEARS MOV BX,DX MUL CX MOV CL,BYTE PTR [YEAR] AND CL,3 MOV SI,OFFSET DOSGROUP:YRTAB MOV DX,AX SHL CX,1 ;Two entries per year, so double count CALL DSUM ;Add up the days in each year MOV CL,BH ;Month of year MOV SI,OFFSET DOSGROUP:MONTAB DEC CX ;Account for months starting with one CALL DSUM ;Add up days in each month MOV CL,BL ;Day of month DEC CX ;Account for days starting with one ADD DX,CX ;Add in to day total XCHG AX,DX ;Get day count in AX MOV [DAYCNT],AX CALL FAR PTR BIOSSETDATE WKDAY: MOV AX,[DAYCNT] XOR DX,DX MOV CX,7 INC AX INC AX ;First day was Tuesday DIV CX ;Compute day of week MOV [WEEKDAY],DL XOR AL,AL ;Flag OK RET25: RET DSUM: MOV AH,0 JCXZ RET25 DSUM1: LODSB ADD DX,AX LOOP DSUM1 RET GETTIME: ;Function call 44 PUSH CS POP DS CALL READTIME LDS SI,DWORD PTR [SPSAVE] ;Get pointer to user registers MOV [SI.DXSAVE],DX MOV [SI.CXSAVE],CX XOR AL,AL RET26: RET SETTIME: ;Function call 45 ;Time is in CX:DX in hours, minutes, seconds, 1/100 sec. MOV AL,-1 ;Flag in case of error CMP CH,24 ;Check hours JAE RET26 CMP CL,60 ;Check minutes JAE RET26 CMP DH,60 ;Check seconds JAE RET26 CMP DL,100 ;Check 1/100's JAE RET26 CALL FAR PTR BIOSSETTIME XOR AL,AL RET ; Default handler for division overflow trap DIVOV: PUSH SI PUSH AX MOV SI,OFFSET DOSGROUP:DIVMES CALL OUTMES POP AX POP SI INT 23H ;Use Ctrl-C abort on divide overflow IRET CODSIZ EQU $-CODSTRT ;Size of code segment CODE ENDS ;***** DATA AREA ***** CONSTANTS SEGMENT BYTE ORG 0 CONSTRT EQU $ ;Start of constants segment IONAME: IF NOT IBM DB "PRN ","LST ","NUL ","AUX ","CON " ENDIF IF IBM DB "COM1","PRN ","LPT1","NUL ","AUX ","CON " ENDIF DIVMES DB 13,10,"Divide overflow",13,10,"$" CARPOS DB 0 STARTPOS DB 0 PFLAG DB 0 DIRTYDIR DB 0 ;Dirty buffer flag NUMDRV DB 0 ;Number of drives NUMIO DB ? ;Number of disk tables VERFLG DB 0 ;Initialize with verify off CONTPOS DW 0 DMAADD DW 80H ;User's disk transfer address (disp/seg) DW ? ENDMEM DW ? MAXSEC DW 0 BUFFER DW ? BUFSECNO DW 0 BUFDRVNO DB -1 DIRTYBUF DB 0 BUFDRVBP DW ? DIRBUFID DW -1 DAY DB 0 MONTH DB 0 YEAR DW 0 DAYCNT DW -1 WEEKDAY DB 0 CURDRV DB 0 ;Default to drive A DRVTAB DW 0 ;Address of start of DPBs DOSLEN EQU CODSIZ+($-CONSTRT) ;Size of CODE + CONSTANTS segments CONSTANTS ENDS DATA SEGMENT WORD ; Init code overlaps with data area below ORG 0 INBUF DB 128 DUP (?) CONBUF DB 131 DUP (?) ;The rest of INBUF and console buffer LASTENT DW ? EXITHOLD DB 4 DUP (?) FATBASE DW ? NAME1 DB 11 DUP (?) ;File name buffer ATTRIB DB ? NAME2 DB 11 DUP (?) NAME3 DB 12 DUP (?) EXTFCB DB ? ;WARNING - the following two items are accessed as a word CREATING DB ? DELALL DB ? TEMP LABEL WORD SPSAVE DW ? SSSAVE DW ? CONTSTK DW ? SECCLUSPOS DB ? ;Position of first sector within cluster DSKERR DB ? TRANS DB ? PREREAD DB ? ;0 means preread; 1 means optional READOP DB ? THISDRV DB ? EVEN FCB DW ? ;Address of user FCB NEXTADD DW ? RECPOS DB 4 DUP (?) RECCNT DW ? LASTPOS DW ? CLUSNUM DW ? SECPOS DW ? ;Position of first sector accessed VALSEC DW ? ;Number of valid (previously written) sectors BYTSECPOS DW ? ;Position of first byte within sector BYTPOS DB 4 DUP (?) ;Byte position in file of access BYTCNT1 DW ? ;No. of bytes in first sector BYTCNT2 DW ? ;No. of bytes in last sector SECCNT DW ? ;No. of whole sectors ENTFREE DW ? DB 80H DUP (?) ;Stack space IOSTACK LABEL BYTE DB 80H DUP (?) DSKSTACK LABEL BYTE IF DSKTEST NSS DW ? NSP DW ? ENDIF DIRBUF LABEL WORD ;Init code below overlaps with data area above ORG 0 MOVFAT: ;This section of code is safe from being overwritten by block move REP MOVS BYTE PTR [DI],[SI] CLD MOV ES:[DMAADD+2],DX MOV SI,[DRVTAB] ;Address of first DPB MOV AL,-1 MOV CL,[NUMIO] ;Number of DPBs FLGFAT: MOV DI,ES:[SI.FAT] ;get pointer to FAT DEC DI ;Point to dirty byte STOSB ;Flag as unused ADD SI,DPBSIZ ;Point to next DPB LOOP FLGFAT MOV AX,[ENDMEM] CALL SETMEM ;Set up segment XXX PROC FAR RET XXX ENDP DOSINIT: CLI CLD PUSH CS POP ES MOV ES:[ENDMEM],DX LODSB ;Get no. of drives & no. of I/O drivers MOV ES:[NUMIO],AL MOV DI,OFFSET DOSGROUP:MEMSTRT PERDRV: MOV BP,DI MOV AL,ES:[DRVCNT] STOSB ;DEVNUM LODSB ;Physical unit no. STOSB ;DRVNUM CMP AL,15 JA BADINIT CBW ;Index into FAT size table SHL AX,1 ADD AX,OFFSET DOSGROUP:FATSIZTAB XCHG BX,AX LODSW ;Pointer to DPT PUSH SI MOV SI,AX LODSW STOSW ;SECSIZ MOV DX,AX CMP AX,ES:[MAXSEC] JBE NOTMAX MOV ES:[MAXSEC],AX NOTMAX: LODSB DEC AL STOSB ;CLUSMSK JZ HAVSHFT CBW FIGSHFT: INC AH SAR AL,1 JNZ FIGSHFT MOV AL,AH HAVSHFT: STOSB ;CLUSSHFT MOVSW ;FIRFAT (= number of reserved sectors) MOVSB ;FATCNT MOVSW ;MAXENT MOV AX,DX ;SECSIZ again MOV CL,5 SHR AX,CL MOV CX,AX ;Directory entries per sector DEC AX ADD AX,ES:[BP.MAXENT] XOR DX,DX DIV CX STOSW ;DIRSEC (temporarily) MOVSW ;DSKSIZ (temporarily) FNDFATSIZ: MOV AL,1 MOV DX,1 GETFATSIZ: PUSH DX CALL FIGFATSIZ POP DX CMP AL,DL ;Compare newly computed FAT size with trial JZ HAVFATSIZ ;Has sequence converged? CMP AL,DH ;Compare with previous trial MOV DH,DL MOV DL,AL ;Shuffle trials JNZ GETFATSIZ ;Continue iterations if not oscillating DEC WORD PTR ES:[BP.DSKSIZ] ;Damp those oscillations JMP SHORT FNDFATSIZ ;Try again BADINIT: MOV SI,OFFSET DOSGROUP:BADMES CALL OUTMES STI HLT HAVFATSIZ: STOSB ;FATSIZ MUL ES:BYTE PTR[BP.FATCNT] ;Space occupied by all FATs ADD AX,ES:[BP.FIRFAT] STOSW ;FIRDIR ADD AX,ES:[BP.DIRSEC] MOV ES:[BP.FIRREC],AX ;Destroys DIRSEC CALL FIGMAX MOV ES:[BP.MAXCLUS],CX MOV AX,BX ;Pointer into FAT size table STOSW ;Allocate space for FAT pointer MOV AL,ES:[BP.FATSIZ] XOR AH,AH MUL ES:[BP.SECSIZ] CMP AX,ES:[BX] ;Bigger than already allocated JBE SMFAT MOV ES:[BX],AX SMFAT: POP SI ;Restore pointer to init. table MOV AL,ES:[DRVCNT] INC AL MOV ES:[DRVCNT],AL CMP AL,ES:[NUMIO] JAE CONTINIT JMP PERDRV BADINITJ: JMP BADINIT CONTINIT: PUSH CS POP DS ;Calculate true address of buffers, FATs, free space MOV BP,[MAXSEC] MOV AX,OFFSET DOSGROUP:DIRBUF ADD AX,BP MOV [BUFFER],AX ;Start of buffer ADD AX,BP MOV [DRVTAB],AX ;Start of DPBs SHL BP,1 ;Two sectors - directory and buffer ADD BP,DI ;Allocate buffer space ADD BP,ADJFAC ;True address of FATs PUSH BP MOV SI,OFFSET DOSGROUP:FATSIZTAB MOV DI,SI MOV CX,16 TOTFATSIZ: INC BP ;Add one for Dirty byte INC BP ;Add one for I/O device number LODSW ;Get size of this FAT XCHG AX,BP STOSW ;Save address of this FAT ADD BP,AX ;Compute size of next FAT CMP AX,BP ;If size was zero done LOOPNZ TOTFATSIZ MOV AL,15 SUB AL,CL ;Compute number of FATs used MOV [NUMDRV],AL XOR AX,AX ;Set zero flag REPZ SCASW ;Make sure all other entries are zero JNZ BADINITJ ADD BP,15 ;True start of free space MOV CL,4 SHR BP,CL ;First free segment MOV DX,CS ADD DX,BP MOV BX,0FH MOV CX,[ENDMEM] CMP CX,1 ;Use memory scan? JNZ SETEND MOV CX,DX ;Start scanning just after DOS MEMSCAN: INC CX JZ SETEND MOV DS,CX MOV AL,[BX] NOT AL MOV [BX],AL CMP AL,[BX] NOT AL MOV [BX],AL JZ MEMSCAN SETEND: IF HIGHMEM SUB CX,BP MOV BP,CX ;Segment of DOS MOV DX,CS ;Program segment ENDIF IF NOT HIGHMEM MOV BP,CS ENDIF ; BP has segment of DOS (whether to load high or run in place) ; DX has program segment (whether after DOS or overlaying DOS) ; CX has size of memory in paragraphs (reduced by DOS size if HIGHMEM) MOV CS:[ENDMEM],CX IF HIGHMEM MOV ES,BP XOR SI,SI MOV DI,SI MOV CX,(DOSLEN+1)/2 PUSH CS POP DS REP MOVSW ;Move DOS to high memory ENDIF XOR AX,AX MOV DS,AX MOV ES,AX MOV DI,INTBASE MOV AX,OFFSET DOSGROUP:QUIT STOSW ;Set abort address--displacement MOV AX,BP MOV BYTE PTR DS:[ENTRYPOINT],LONGJUMP MOV WORD PTR DS:[ENTRYPOINT+1],OFFSET DOSGROUP:ENTRY MOV WORD PTR DS:[ENTRYPOINT+3],AX MOV WORD PTR DS:[0],OFFSET DOSGROUP:DIVOV ;Set default divide trap address MOV DS:[2],AX MOV CX,9 REP STOSW ;Set 5 segments (skip 2 between each) MOV WORD PTR DS:[INTBASE+4],OFFSET DOSGROUP:COMMAND MOV WORD PTR DS:[INTBASE+12],OFFSET DOSGROUP:IRET ;Ctrl-C exit MOV WORD PTR DS:[INTBASE+16],OFFSET DOSGROUP:IRET ;Fatal error exit MOV AX,OFFSET BIOSREAD STOSW MOV AX,BIOSSEG STOSW STOSW ;Add 2 to DI STOSW MOV WORD PTR DS:[INTBASE+18H],OFFSET BIOSWRITE MOV WORD PTR DS:[EXIT],100H MOV WORD PTR DS:[EXIT+2],DX IF NOT IBM MOV SI,OFFSET DOSGROUP:HEADER CALL OUTMES ENDIF PUSH CS POP DS PUSH CS POP ES ;Move the FATs into position MOV AL,[NUMIO] CBW XCHG AX,CX MOV DI,OFFSET DOSGROUP:MEMSTRT.FAT FATPOINT: MOV SI,WORD PTR [DI] ;Get address within FAT address table MOVSW ;Set address of this FAT ADD DI,DPBSIZ-2 ;Point to next DPB LOOP FATPOINT POP CX ;True address of first FAT MOV SI,OFFSET DOSGROUP:MEMSTRT ;Place to move DPBs from MOV DI,[DRVTAB] ;Place to move DPBs to SUB CX,DI ;Total length of DPBs CMP DI,SI JBE MOVJMP ;Are we moving to higher or lower memory? DEC CX ;Move backwards to higher memory ADD DI,CX ADD SI,CX INC CX STD MOVJMP: MOV ES,BP JMP MOVFAT FIGFATSIZ: MUL ES:BYTE PTR[BP.FATCNT] ADD AX,ES:[BP.FIRFAT] ADD AX,ES:[BP.DIRSEC] FIGMAX: ;AX has equivalent of FIRREC SUB AX,ES:[BP.DSKSIZ] NEG AX MOV CL,ES:[BP.CLUSSHFT] SHR AX,CL INC AX MOV CX,AX ;MAXCLUS INC AX MOV DX,AX SHR DX,1 ADC AX,DX ;Size of FAT in bytes MOV SI,ES:[BP.SECSIZ] ADD AX,SI DEC AX XOR DX,DX DIV SI RET BADMES: DB 13,10,"INIT TABLE BAD",13,10,"$" FATSIZTAB: DW 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DRVCNT DB 0 MEMSTRT LABEL WORD ADJFAC EQU DIRBUF-MEMSTRT DATA ENDS END 
; ; Philips VG-5000 Graphics Functions ; ; cls () -- clear screen ; ; Stefano Bodrato - Oct 2015 ; ; ; $Id: clsgraph.asm,v 1.1 2015/10/09 13:02:42 stefano Exp $ ; PUBLIC cleargraphics EXTERN base_graphics .cleargraphics ; ld d,' ' ; ld e,7 ; white on black ld h,25+6 .loop2 ld l,40 .loop1 push hl ld de,128+32+64+16+64*256 dec l call 92h pop hl dec l jr nz,loop1 dec h ld a,h cp 7 jr nz,loop2 ld h,0 ld l,40 .loop3 push hl ld de,128+32+64+16+64*256 dec l call 92h pop hl dec l jr nz,loop3 ret
; A094391: A Beatty sequence using exp(Pi/4)/(exp(Pi/4)-1). ; 1,3,5,7,9,11,12,14,16,18,20,22,23,25,27,29,31,33,34,36,38,40,42,44,45,47,49,51,53,55,56,58,60,62,64,66,68,69,71,73,75,77,79,80,82,84,86,88,90,91,93,95,97,99,101,102,104,106,108,110,112,113,115,117,119,121,123 add $0,1 mul $0,68 div $0,37 mov $1,$0
[BITS 64] section .text global idt_flush idt_flush: lidt [rdi] ret %macro push_all 0 push rax push rbx push rcx push rdx push rsi push rdi push rbp push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 %endmacro %macro pop_all 0 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rbp pop rdi pop rsi pop rdx pop rcx pop rbx pop rax %endmacro %macro INTERRUPT_NAME 1 dq __interrupt%1 %endmacro %macro INTERRUPT_ERR 1 __interrupt%1: push %1 jmp __interrupt_common %endmacro %macro INTERRUPT_NOERR 1 __interrupt%1: push 0 push %1 jmp __interrupt_common %endmacro section .text extern interrupts_handler __interrupt_common: cld push_all mov rdi, rsp call interrupts_handler mov rsp, rax pop_all add rsp, 16 ; pop errcode and int number sti iretq INTERRUPT_NOERR 0 INTERRUPT_NOERR 1 INTERRUPT_NOERR 2 INTERRUPT_NOERR 3 INTERRUPT_NOERR 4 INTERRUPT_NOERR 5 INTERRUPT_NOERR 6 INTERRUPT_NOERR 7 INTERRUPT_ERR 8 INTERRUPT_NOERR 9 INTERRUPT_ERR 10 INTERRUPT_ERR 11 INTERRUPT_ERR 12 INTERRUPT_ERR 13 INTERRUPT_ERR 14 INTERRUPT_NOERR 15 INTERRUPT_NOERR 16 INTERRUPT_ERR 17 INTERRUPT_NOERR 18 INTERRUPT_NOERR 19 INTERRUPT_NOERR 20 INTERRUPT_NOERR 21 INTERRUPT_NOERR 22 INTERRUPT_NOERR 23 INTERRUPT_NOERR 24 INTERRUPT_NOERR 25 INTERRUPT_NOERR 26 INTERRUPT_NOERR 27 INTERRUPT_NOERR 28 INTERRUPT_NOERR 29 INTERRUPT_ERR 30 INTERRUPT_NOERR 31 INTERRUPT_NOERR 32 INTERRUPT_NOERR 33 INTERRUPT_NOERR 34 INTERRUPT_NOERR 35 INTERRUPT_NOERR 36 INTERRUPT_NOERR 37 INTERRUPT_NOERR 38 INTERRUPT_NOERR 39 INTERRUPT_NOERR 40 INTERRUPT_NOERR 41 INTERRUPT_NOERR 42 INTERRUPT_NOERR 43 INTERRUPT_NOERR 44 INTERRUPT_NOERR 45 INTERRUPT_NOERR 46 INTERRUPT_NOERR 47 INTERRUPT_NOERR 50 INTERRUPT_NOERR 127 INTERRUPT_NOERR 100 section .data global __interrupt_vector __interrupt_vector: INTERRUPT_NAME 0 INTERRUPT_NAME 1 INTERRUPT_NAME 2 INTERRUPT_NAME 3 INTERRUPT_NAME 4 INTERRUPT_NAME 5 INTERRUPT_NAME 6 INTERRUPT_NAME 7 INTERRUPT_NAME 8 INTERRUPT_NAME 9 INTERRUPT_NAME 10 INTERRUPT_NAME 11 INTERRUPT_NAME 12 INTERRUPT_NAME 13 INTERRUPT_NAME 14 INTERRUPT_NAME 15 INTERRUPT_NAME 16 INTERRUPT_NAME 17 INTERRUPT_NAME 18 INTERRUPT_NAME 19 INTERRUPT_NAME 20 INTERRUPT_NAME 21 INTERRUPT_NAME 22 INTERRUPT_NAME 23 INTERRUPT_NAME 24 INTERRUPT_NAME 25 INTERRUPT_NAME 26 INTERRUPT_NAME 27 INTERRUPT_NAME 28 INTERRUPT_NAME 29 INTERRUPT_NAME 30 INTERRUPT_NAME 31 INTERRUPT_NAME 32 INTERRUPT_NAME 33 INTERRUPT_NAME 34 INTERRUPT_NAME 35 INTERRUPT_NAME 36 INTERRUPT_NAME 37 INTERRUPT_NAME 38 INTERRUPT_NAME 39 INTERRUPT_NAME 40 INTERRUPT_NAME 41 INTERRUPT_NAME 42 INTERRUPT_NAME 43 INTERRUPT_NAME 44 INTERRUPT_NAME 45 INTERRUPT_NAME 46 INTERRUPT_NAME 47 INTERRUPT_NAME 127 INTERRUPT_NAME 100
;add a series of 10 bytes stores in the memory from locations ;20,000H to 20,009. Store the result immediately after the series. CODE SEGMENT assume CS:Code mov ax,2000H mov ds,ax mov si,0000H ;starting offset address = 0000H mov cx,000AH ;10 bytes = 'A' mov ax,0000H ;ax initialized to store sum kcab: add al,[si] ;indirect register addressing jnc jump ;jump if no carry inc ah ;if sum is greater than 8 bit jump: inc si ;point to next offset loop kcab ;decrement cx by 1 mov [si],ax ;store final result in 20,009H HLT CODE ENDS
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_UC_ht+0x11aa3, %rcx nop nop nop nop nop add $60430, %r13 movb (%rcx), %r14b nop nop nop nop nop and $60430, %rax lea addresses_normal_ht+0x13cd1, %r8 clflush (%r8) nop nop nop nop nop sub %rcx, %rcx mov $0x6162636465666768, %r13 movq %r13, %xmm5 movups %xmm5, (%r8) nop nop add $61235, %r14 lea addresses_UC_ht+0x6d1, %r9 nop nop nop nop sub %r11, %r11 movb (%r9), %r8b nop nop nop nop xor %r8, %r8 lea addresses_A_ht+0x5551, %rsi lea addresses_WC_ht+0xeacb, %rdi clflush (%rdi) nop nop nop and $27590, %r14 mov $54, %rcx rep movsb nop nop and %r8, %r8 lea addresses_WC_ht+0xe6d1, %rcx nop nop inc %r9 movb $0x61, (%rcx) xor %r11, %r11 lea addresses_WC_ht+0x1b0d1, %rcx nop nop nop xor %rax, %rax movl $0x61626364, (%rcx) nop add $35872, %rax lea addresses_UC_ht+0x10077, %rsi lea addresses_A_ht+0xd4d1, %rdi nop sub $57558, %r8 mov $116, %rcx rep movsq nop nop nop xor $9556, %r13 lea addresses_UC_ht+0x1dad1, %r11 nop dec %r14 mov (%r11), %r8w nop nop nop nop inc %r9 lea addresses_WT_ht+0xb731, %rax nop and $61111, %r8 movl $0x61626364, (%rax) nop nop nop add %r9, %r9 lea addresses_WC_ht+0x119d1, %rsi lea addresses_UC_ht+0x177d9, %rdi nop sub %rax, %rax mov $65, %rcx rep movsw nop xor $61538, %rax lea addresses_D_ht+0x15657, %rsi lea addresses_UC_ht+0x5ad1, %rdi clflush (%rdi) nop nop nop xor $58565, %r14 mov $27, %rcx rep movsq nop nop nop nop inc %rax lea addresses_D_ht+0x1e771, %rsi nop nop nop nop nop dec %rax mov $0x6162636465666768, %r8 movq %r8, (%rsi) nop and $49276, %r9 lea addresses_UC_ht+0x2cd1, %rsi lea addresses_WC_ht+0x12771, %rdi nop nop add $61592, %r14 mov $27, %rcx rep movsl nop nop nop nop inc %r9 lea addresses_WT_ht+0x1471, %rsi lea addresses_A_ht+0x12ad1, %rdi nop nop nop nop nop add $13245, %r9 mov $34, %rcx rep movsl nop nop nop nop dec %r14 lea addresses_normal_ht+0xf3f1, %rsi lea addresses_normal_ht+0x2dd1, %rdi clflush (%rsi) nop nop nop nop add $62380, %r8 mov $116, %rcx rep movsw nop nop nop nop nop cmp $8944, %r14 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r14 push %rcx push %rdi // Load lea addresses_PSE+0x1c7a9, %r12 nop nop nop and %r14, %r14 mov (%r12), %r11 nop nop sub $51500, %rcx // Faulty Load lea addresses_RW+0x188d1, %r10 nop nop nop nop add $59301, %r12 mov (%r10), %r11 lea oracles, %r14 and $0xff, %r11 shlq $12, %r11 mov (%r14,%r11,1), %r11 pop %rdi pop %rcx pop %r14 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 3}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': True, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 10}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; Glass: Making sure reorganizing blocks of code that involve local labels are handled fine org #4000 global1: ld hl, variable ; jp global2.local ; -mdl global2.local: ld (hl), 1 ; jp global1.local ; -mdl global1.local: inc hl ld (hl), 2 loop: jp loop global2: ret global3: jp z, global3.local ret global3.local: ld (hl), 2 ret org #c000 variable: org $ + 1
// Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "uritests.h" #include "guiutil.h" #include "walletmodel.h" #include <QUrl> void URITests::uriTests() { SendCoinsRecipient rv; QUrl uri; uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?req-dontexist=")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?dontexist=")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 0); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?label=Some Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString("Some Example Address")); QVERIFY(rv.amount == 0); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?amount=0.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100000); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?amount=1.001")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100100000); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?amount=100&label=Some Example")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.amount == 10000000000LL); QVERIFY(rv.label == QString("Some Example")); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?message=Some Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString()); QVERIFY(GUIUtil::parseBitcoinURI("lpa://D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?message=Some Example Address", &rv)); QVERIFY(rv.address == QString("D72dLgywmL73JyTwQBfuU29CADz9yCJ99v")); QVERIFY(rv.label == QString()); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?req-message=Some Example Address")); QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?amount=1,000&label=Some Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); uri.setUrl(QString("lpa:D72dLgywmL73JyTwQBfuU29CADz9yCJ99v?amount=1,000.0&label=Some Example")); QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); }
; A267935: Decimal representation of the n-th iteration of the "Rule 249" elementary cellular automaton starting with a single ON (black) cell. ; 1,1,27,127,511,2047,8191,32767,131071,524287,2097151,8388607,33554431,134217727,536870911,2147483647,8589934591,34359738367,137438953471,549755813887,2199023255551,8796093022207,35184372088831,140737488355327,562949953421311,2251799813685247,9007199254740991,36028797018963967,144115188075855871,576460752303423487,2305843009213693951,9223372036854775807,36893488147419103231,147573952589676412927,590295810358705651711,2361183241434822606847,9444732965739290427391,37778931862957161709567,151115727451828646838271,604462909807314587353087,2417851639229258349412351,9671406556917033397649407,38685626227668133590597631,154742504910672534362390527,618970019642690137449562111,2475880078570760549798248447,9903520314283042199192993791,39614081257132168796771975167,158456325028528675187087900671,633825300114114700748351602687,2535301200456458802993406410751,10141204801825835211973625643007,40564819207303340847894502572031,162259276829213363391578010288127,649037107316853453566312041152511,2596148429267413814265248164610047,10384593717069655257060992658440191,41538374868278621028243970633760767,166153499473114484112975882535043071,664613997892457936451903530140172287 lpb $0 mov $1,$0 mov $0,1 seq $1,267886 ; Decimal representation of the n-th iteration of the "Rule 235" elementary cellular automaton starting with a single ON (black) cell. sub $1,1 lpe add $1,1 mov $0,$1
.data a.0: .word 0 b.1: .word 0 c.2: .word 0 d.3: .word 0 e.4: .word 0 f.5: .word 0 g.6: .word 0 .text runtime: addi $sp, $sp, -4 sw $ra, 0($sp) lw $ra, 0($sp) addi $sp, $sp, 4 jr $ra .end runtime .globl main .ent main main: li $3, 1 # a.0 -> $3 li $5, 3 # b.1 -> $5 sw $5, b.1 # spilled b.1, freed $5 li $5, 2 # c.2 -> $5 sw $5, c.2 # spilled c.2, freed $5 li $5, 4 # d.3 -> $5 sw $5, d.3 # spilled d.3, freed $5 li $5, 4 # e.4 -> $5 sw $5, e.4 # spilled e.4, freed $5 li $5, 8 # f.5 -> $5 sw $5, f.5 # spilled f.5, freed $5 li $5, 0 # g.6 -> $5 move $5, $3 # g.6 -> $5 # Store dirty variables back into memory sw $3, a.0 sw $5, g.6 li $2, 10 syscall .end main
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*************************************************************************************/ /* StressLog.cpp */ /*************************************************************************************/ /*************************************************************************************/ #include "stdafx.h" // precompiled headers #include "switches.h" #include "stresslog.h" #include "clrhost.h" #define DONOT_DEFINE_ETW_CALLBACK #include "eventtracebase.h" #include "ex.h" #if !defined(STRESS_LOG_READONLY) #ifdef HOST_WINDOWS HANDLE StressLogChunk::s_LogChunkHeap = NULL; #endif thread_local ThreadStressLog* StressLog::t_pCurrentThreadLog; thread_local bool t_triedToCreateThreadStressLog; #endif // !STRESS_LOG_READONLY /*********************************************************************************/ #if defined(HOST_X86) /* This is like QueryPerformanceCounter but a lot faster. On machines with variable-speed CPUs (for power management), this is not accurate, but may be good enough. */ __forceinline __declspec(naked) unsigned __int64 getTimeStamp() { STATIC_CONTRACT_LEAF; __asm { RDTSC // read time stamp counter ret }; } #else // HOST_X86 unsigned __int64 getTimeStamp() { STATIC_CONTRACT_LEAF; LARGE_INTEGER ret; ZeroMemory(&ret, sizeof(LARGE_INTEGER)); QueryPerformanceCounter(&ret); return ret.QuadPart; } #endif // HOST_X86 #if defined(HOST_X86) && !defined(HOST_UNIX) /*********************************************************************************/ /* Get the the frequency cooresponding to 'getTimeStamp'. For x86, this is the frequency of the RDTSC instruction, which is just the clock rate of the CPU. This can vary due to power management, so this is at best a rough approximation. */ unsigned __int64 getTickFrequency() { // // At startup, the OS calculates the CPU clock frequency and makes it available // at HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0 // unsigned __int64 hz = 0; HKEY hKey; if (ERROR_SUCCESS == RegOpenKeyExW( HKEY_LOCAL_MACHINE, W("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey)) { DWORD mhz; DWORD mhzType; DWORD cbMhz = (DWORD)sizeof(mhz); if (ERROR_SUCCESS == RegQueryValueExW( hKey, W("~MHz"), NULL, &mhzType, (LPBYTE)&mhz, &cbMhz)) { _ASSERTE(REG_DWORD == mhzType); _ASSERTE((DWORD)sizeof(mhz) == cbMhz); hz = (unsigned __int64)mhz * 1000000; } RegCloseKey(hKey); } return hz; } #else // HOST_X86 /*********************************************************************************/ /* Get the the frequency cooresponding to 'getTimeStamp'. For non-x86 architectures, this is just the performance counter frequency. */ unsigned __int64 getTickFrequency() { LARGE_INTEGER ret; ZeroMemory(&ret, sizeof(LARGE_INTEGER)); QueryPerformanceFrequency(&ret); return ret.QuadPart; } #endif // HOST_X86 #ifdef STRESS_LOG StressLog StressLog::theLog = { 0, 0, 0, 0, 0, 0, TLS_OUT_OF_INDEXES, 0, 0, 0 }; const static unsigned __int64 RECYCLE_AGE = 0x40000000L; // after a billion cycles, we can discard old threads /*********************************************************************************/ void StressLog::Enter(CRITSEC_COOKIE) { STATIC_CONTRACT_LEAF; IncCantAllocCount(); ClrEnterCriticalSection(theLog.lock); DecCantAllocCount(); } void StressLog::Leave(CRITSEC_COOKIE) { STATIC_CONTRACT_LEAF; IncCantAllocCount(); ClrLeaveCriticalSection(theLog.lock); DecCantAllocCount(); } /*********************************************************************************/ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxBytesPerThreadArg, unsigned maxBytesTotalArg, void* moduleBase, LPWSTR logFilename) { STATIC_CONTRACT_LEAF; if (theLog.MaxSizePerThread != 0) { // guard ourself against multiple initialization. First init wins. return; } theLog.lock = ClrCreateCriticalSection(CrstStressLog, (CrstFlags)(CRST_UNSAFE_ANYMODE | CRST_DEBUGGER_THREAD | CRST_TAKEN_DURING_SHUTDOWN)); // StressLog::Terminate is going to free memory. size_t maxBytesPerThread = maxBytesPerThreadArg; if (maxBytesPerThread < STRESSLOG_CHUNK_SIZE) { // in this case, interpret the number as GB maxBytesPerThread *= (1024 * 1024 * 1024); } theLog.MaxSizePerThread = (unsigned)min(maxBytesPerThread,0xffffffff); size_t maxBytesTotal = maxBytesTotalArg; if (maxBytesTotal < STRESSLOG_CHUNK_SIZE * 256) { // in this case, interpret the number as GB maxBytesTotal *= (1024 * 1024 * 1024); } theLog.MaxSizeTotal = (unsigned)min(maxBytesTotal, 0xffffffff); theLog.totalChunk = 0; theLog.facilitiesToLog = facilities | LF_ALWAYS; theLog.levelToLog = level; theLog.deadCount = 0; theLog.tickFrequency = getTickFrequency(); GetSystemTimeAsFileTime(&theLog.startTime); theLog.startTimeStamp = getTimeStamp(); theLog.moduleOffset = (SIZE_T)moduleBase; #ifndef HOST_UNIX #ifdef _DEBUG HMODULE hModNtdll = GetModuleHandleA("ntdll.dll"); theLog.RtlCaptureStackBackTrace = reinterpret_cast<PFNRtlCaptureStackBackTrace>( GetProcAddress(hModNtdll, "RtlCaptureStackBackTrace")); #endif // _DEBUG #endif // !HOST_UNIX #if !defined (STRESS_LOG_READONLY) && defined(HOST_WINDOWS) if (logFilename == nullptr) { StressLogChunk::s_LogChunkHeap = HeapCreate(0, STRESSLOG_CHUNK_SIZE * 128, 0); if (StressLogChunk::s_LogChunkHeap == NULL) { StressLogChunk::s_LogChunkHeap = GetProcessHeap(); } _ASSERTE(StressLogChunk::s_LogChunkHeap); } #endif //!STRESS_LOG_READONLY #ifdef MEMORY_MAPPED_STRESSLOG if (logFilename != nullptr) { if (maxBytesTotal < sizeof(StressLogHeader)) { return; } HandleHolder hFile = WszCreateFile(logFilename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, // default security descriptor CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return; } size_t fileSize = maxBytesTotal; HandleHolder hMap = WszCreateFileMapping(hFile, NULL, PAGE_READWRITE, (DWORD)(fileSize >> 32), (DWORD)fileSize, NULL); if (hMap == NULL) { return; } theLog.hMapView = MapViewOfFileEx(hMap, FILE_MAP_ALL_ACCESS, 0, 0, fileSize, (void*)0x400000000000); if (theLog.hMapView == NULL) { return; } StressLogHeader* hdr = (StressLogHeader*)(uint8_t*)(void*)theLog.hMapView; hdr->headerSize = sizeof(StressLogHeader); hdr->magic = 'STRL'; hdr->version = 0x00010001; hdr->memoryBase = (uint8_t*)hdr; hdr->memoryCur = hdr->memoryBase + sizeof(StressLogHeader); hdr->memoryLimit = hdr->memoryBase + fileSize; hdr->logs = nullptr; hdr->tickFrequency = theLog.tickFrequency; hdr->startTimeStamp = theLog.startTimeStamp; theLog.stressLogHeader = hdr; // copy coreclr image - just for the string literals } #endif AddModule((uint8_t*)moduleBase); } void StressLog::AddModule(uint8_t* moduleBase) { unsigned moduleIndex = 0; #ifdef MEMORY_MAPPED_STRESSLOG StressLogHeader* hdr = theLog.stressLogHeader; #endif //MEMORY_MAPPED_STRESSLOG size_t cumSize = 0; while (moduleIndex < MAX_MODULES && theLog.modules[moduleIndex].baseAddress != nullptr) { if (theLog.modules[moduleIndex].baseAddress == moduleBase) return; cumSize += theLog.modules[moduleIndex].size; moduleIndex++; } if (moduleIndex >= MAX_MODULES) { DebugBreak(); return; } theLog.modules[moduleIndex].baseAddress = moduleBase; #ifdef MEMORY_MAPPED_STRESSLOG if (hdr != nullptr) { hdr->modules[moduleIndex].baseAddress = moduleBase; } #endif //MEMORY_MAPPED_STRESSLOG #ifdef HOST_WINDOWS uint8_t* addr = moduleBase; while (true) { MEMORY_BASIC_INFORMATION mbi; size_t size = VirtualQuery(addr, &mbi, sizeof(mbi)); if (size == 0) break; // copy the region containing string literals to the memory mapped file if (mbi.AllocationBase != moduleBase) break; ptrdiff_t offs = (uint8_t*)mbi.BaseAddress - (uint8_t*)mbi.AllocationBase + cumSize; addr += mbi.RegionSize; theLog.modules[moduleIndex].size = (size_t)(addr - (uint8_t*)moduleBase); #ifdef MEMORY_MAPPED_STRESSLOG if (hdr != nullptr) { memcpy(&hdr->moduleImage[offs], mbi.BaseAddress, mbi.RegionSize); hdr->modules[moduleIndex].size = (size_t)(addr - (uint8_t*)moduleBase); } #endif //MEMORY_MAPPED_STRESSLOG } #else //HOST_WINDOWS // as it is not easy to obtain module size on Linux or OSX, // just guess and hope for the best size_t remainingSize = StressMsg::maxOffset - cumSize; theLog.modules[moduleIndex].size = remainingSize / 2; #endif //HOST_WINDOWS } /*********************************************************************************/ void StressLog::Terminate(BOOL fProcessDetach) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FORBID_FAULT; theLog.facilitiesToLog = 0; StressLogLockHolder lockh(theLog.lock, FALSE); if (!fProcessDetach) { lockh.Acquire(); lockh.Release(); // The Enter() Leave() forces a memory barrier on weak memory model systems // we want all the other threads to notice that facilitiesToLog is now zero // This is not strictly threadsafe, since there is no way of insuring when all the // threads are out of logMsg. In practice, since they can no longer enter logMsg // and there are no blocking operations in logMsg, simply sleeping will insure // that everyone gets out. ClrSleepEx(2, FALSE); lockh.Acquire(); } // Free the log memory ThreadStressLog* ptr = theLog.logs; theLog.logs = 0; while(ptr != 0) { ThreadStressLog* tmp = ptr; ptr = ptr->next; delete tmp; } if (!fProcessDetach) { lockh.Release(); } #if !defined (STRESS_LOG_READONLY) && defined(HOST_WINDOWS) if (StressLogChunk::s_LogChunkHeap != NULL && StressLogChunk::s_LogChunkHeap != GetProcessHeap ()) { HeapDestroy (StressLogChunk::s_LogChunkHeap); } #endif //!STRESS_LOG_READONLY } /*********************************************************************************/ /* create a new thread stress log buffer associated with Thread local slot, for the Stress log */ ThreadStressLog* StressLog::CreateThreadStressLog() { CONTRACTL { NOTHROW; GC_NOTRIGGER; FORBID_FAULT; } CONTRACTL_END; static PVOID callerID = NULL; ThreadStressLog* msgs = t_pCurrentThreadLog; if (msgs != NULL) { return msgs; } if (callerID == ClrTeb::GetFiberPtrId()) { return NULL; } #if defined(HOST_WINDOWS) && !defined(MEMORY_MAPPED_STRESSLOG) if (!StressLogChunk::s_LogChunkHeap) { return NULL; } #endif //if we are not allowed to allocate stress log, we should not even try to take the lock if (IsInCantAllocStressLogRegion ()) { return NULL; } // if it looks like we won't be allowed to allocate a new chunk, exit early if (theLog.deadCount == 0 && !AllowNewChunk (0)) { return NULL; } StressLogLockHolder lockh(theLog.lock, FALSE); class NestedCaller { public: NestedCaller() { } ~NestedCaller() { callerID = NULL; } void Mark() { callerID = ClrTeb::GetFiberPtrId(); } }; NestedCaller nested; BOOL noFLSNow = FALSE; PAL_CPP_TRY { // Acquiring the lack can throw an OOM exception the first time its called on a thread. We go // ahead and try to provoke that now, before we've altered the list of available stress logs, and bail if // we fail. lockh.Acquire(); nested.Mark(); // ClrFlsSetValue can throw an OOM exception the first time its called on a thread for a given slot. We go // ahead and try to provoke that now, before we've altered the list of available stress logs, and bail if // we fail. t_pCurrentThreadLog = NULL; } #pragma warning(suppress: 4101) PAL_CPP_CATCH_DERIVED(OutOfMemoryException, obj) { // Just leave on any exception. Note: can't goto or return from within EX_CATCH... noFLSNow = TRUE; } PAL_CPP_ENDTRY; if (noFLSNow == FALSE && theLog.facilitiesToLog != 0) msgs = CreateThreadStressLogHelper(); return msgs; } ThreadStressLog* StressLog::CreateThreadStressLogHelper() { CONTRACTL { NOTHROW; GC_NOTRIGGER; FORBID_FAULT; CANNOT_TAKE_LOCK; } CONTRACTL_END; BOOL skipInsert = FALSE; ThreadStressLog* msgs = NULL; // See if we can recycle a dead thread if (theLog.deadCount > 0) { unsigned __int64 recycleStamp = getTimeStamp() - RECYCLE_AGE; msgs = theLog.logs; //find out oldest dead ThreadStressLog in case we can't find one within //recycle age but can't create a new chunk ThreadStressLog * oldestDeadMsg = NULL; while(msgs != 0) { if (msgs->isDead) { BOOL hasTimeStamp = msgs->curPtr != (StressMsg *)msgs->chunkListTail->EndPtr(); if (hasTimeStamp && msgs->curPtr->timeStamp < recycleStamp) { skipInsert = TRUE; InterlockedDecrement(&theLog.deadCount); break; } if (!oldestDeadMsg) { oldestDeadMsg = msgs; } else if (hasTimeStamp && oldestDeadMsg->curPtr->timeStamp > msgs->curPtr->timeStamp) { oldestDeadMsg = msgs; } } msgs = msgs->next; } //if the total stress log size limit is already passed and we can't add new chunk, //always reuse the oldest dead msg if (!AllowNewChunk (0) && !msgs) { msgs = oldestDeadMsg; skipInsert = TRUE; InterlockedDecrement(&theLog.deadCount); } } if (msgs == 0) { FAULT_NOT_FATAL(); // We don't mind if we can't allocate here, we'll try again later. if (IsInCantAllocStressLogRegion ()) { goto LEAVE; } msgs = new (nothrow) ThreadStressLog; if (msgs == 0 ||!msgs->IsValid ()) { delete msgs; msgs = 0; #ifdef MEMORY_MAPPED_STRESSLOG if (!t_triedToCreateThreadStressLog && theLog.stressLogHeader != nullptr) { theLog.stressLogHeader->threadsWithNoLog++; t_triedToCreateThreadStressLog = true; } #endif //MEMORY_MAPPED_STRESSLOG goto LEAVE; } } else { // recycle old thread msg msgs->threadId = GetCurrentThreadId(); StressLogChunk* slc = msgs->chunkListHead; while (true) { if (slc == msgs->chunkListTail) break; slc = slc->next; } } msgs->Activate (); t_pCurrentThreadLog = msgs; if (!skipInsert) { #ifdef _DEBUG ThreadStressLog* walk = theLog.logs; while (walk) { _ASSERTE (walk != msgs); walk = walk->next; } #endif // Put it into the stress log msgs->next = theLog.logs; theLog.logs = msgs; #ifdef MEMORY_MAPPED_STRESSLOG if (theLog.stressLogHeader != nullptr) theLog.stressLogHeader->logs = msgs; #endif // MEMORY_MAPPED_STRESSLOG } LEAVE: ; return msgs; } /*********************************************************************************/ /* static */ void StressLog::ThreadDetach() { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FORBID_FAULT; STATIC_CONTRACT_CANNOT_TAKE_LOCK; ThreadStressLog* msgs = t_pCurrentThreadLog; #ifndef DACCESS_COMPILE if (msgs == 0) { return; } t_pCurrentThreadLog = NULL; // We are deleting a fiber. The thread is running a different fiber now. // We should write this message to the StressLog for deleted fiber. msgs->LogMsg (LF_STARTUP, 0, "******* DllMain THREAD_DETACH called Thread dying *******\n"); #endif msgs->isDead = TRUE; InterlockedIncrement(&theLog.deadCount); } BOOL StressLog::AllowNewChunk (LONG numChunksInCurThread) { _ASSERTE (numChunksInCurThread <= theLog.totalChunk); DWORD perThreadLimit = theLog.MaxSizePerThread; #ifndef DACCESS_COMPILE if (numChunksInCurThread == 0 && IsSuspendEEThread()) return TRUE; if (IsGCSpecialThread()) { perThreadLimit *= GC_STRESSLOG_MULTIPLY; } #endif if ((DWORD)numChunksInCurThread * STRESSLOG_CHUNK_SIZE >= perThreadLimit) { return FALSE; } return theLog.MaxSizeTotal == 0xffffffff || (DWORD)theLog.totalChunk * STRESSLOG_CHUNK_SIZE < theLog.MaxSizeTotal; } BOOL StressLog::ReserveStressLogChunks (unsigned chunksToReserve) { ThreadStressLog* msgs = t_pCurrentThreadLog; if (msgs == 0) { msgs = CreateThreadStressLog(); if (msgs == 0) return FALSE; } if (chunksToReserve == 0) { chunksToReserve = (theLog.MaxSizePerThread + STRESSLOG_CHUNK_SIZE - 1) / STRESSLOG_CHUNK_SIZE; } LONG numTries = (LONG)chunksToReserve - msgs->chunkListLength; for (LONG i = 0; i < numTries; i++) { msgs->GrowChunkList (); } return msgs->chunkListLength >= (LONG)chunksToReserve; } void (*FSwitchToSOTolerant)(); void (*FSwitchToSOIntolerant)(); void TrackSO(BOOL tolerance) { if (tolerance) { if (FSwitchToSOTolerant) { FSwitchToSOTolerant(); } } else { if (FSwitchToSOIntolerant) { FSwitchToSOIntolerant(); } } } /*********************************************************************************/ /* fetch a buffer that can be used to write a stress message, it is thread safe */ FORCEINLINE void ThreadStressLog::LogMsg(unsigned facility, int cArgs, const char* format, va_list Args) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FORBID_FAULT; // Asserts in this function cause infinite loops in the asserting mechanism. // Just use debug breaks instead. #ifndef DACCESS_COMPILE #ifdef _DEBUG // _ASSERTE ( cArgs >= 0 && cArgs <= 63 ); if (cArgs < 0 || cArgs > 63) DebugBreak(); #endif // size_t offs = 0; unsigned moduleIndex = 0; size_t cumSize = 0; offs = 0; while (moduleIndex < StressLog::MAX_MODULES) { offs = (uint8_t*)format - StressLog::theLog.modules[moduleIndex].baseAddress; if (offs < StressLog::theLog.modules[moduleIndex].size) { offs += cumSize; break; } cumSize += StressLog::theLog.modules[moduleIndex].size; moduleIndex++; } // _ASSERTE ( offs < StressMsg::maxOffset ); if (offs >= StressMsg::maxOffset) { #ifdef _DEBUG DebugBreak(); // in lieu of the above _ASSERTE #endif // _DEBUG // Set it to this string instead. offs = #ifdef _DEBUG (size_t)"<BUG: StressLog format string beyond maxOffset>"; #else // _DEBUG 0; // a 0 offset is ignored by StressLog::Dump #endif // _DEBUG else } // Get next available slot StressMsg* msg = AdvanceWrite(cArgs); msg->timeStamp = getTimeStamp(); msg->facility = facility; msg->formatOffset = offs; msg->numberOfArgs = cArgs & 0x7; msg->numberOfArgsX = cArgs >> 3; for ( int i = 0; i < cArgs; ++i ) { void* data = va_arg(Args, void*); msg->args[i] = data; } // only store curPtr once the msg is complete curPtr = msg; #ifdef _DEBUG if (!IsValid () || threadId != GetCurrentThreadId ()) DebugBreak(); #endif // _DEBUG #endif //DACCESS_COMPILE } void ThreadStressLog::LogMsg(unsigned facility, int cArgs, const char* format, ...) { va_list Args; va_start(Args, format); LogMsg(facility, cArgs, format, Args); va_end(Args); } FORCEINLINE BOOL StressLog::InlinedStressLogOn(unsigned facility, unsigned level) { STATIC_CONTRACT_LEAF; STATIC_CONTRACT_SUPPORTS_DAC; #if defined(DACCESS_COMPILE) return FALSE; #else return ((theLog.facilitiesToLog & facility) && (level <= theLog.levelToLog)); #endif } BOOL StressLog::StressLogOn(unsigned facility, unsigned level) { STATIC_CONTRACT_LEAF; STATIC_CONTRACT_SUPPORTS_DAC; return InlinedStressLogOn(facility, level); } FORCEINLINE BOOL StressLog::InlinedETWLogOn(unsigned facility, unsigned level) { STATIC_CONTRACT_LEAF; STATIC_CONTRACT_SUPPORTS_DAC; return FALSE; } BOOL StressLog::ETWLogOn(unsigned facility, unsigned level) { STATIC_CONTRACT_LEAF; STATIC_CONTRACT_SUPPORTS_DAC; return InlinedETWLogOn(facility, level); } #if !defined(DACCESS_COMPILE) BOOL StressLog::LogOn(unsigned facility, unsigned level) { STATIC_CONTRACT_LEAF; STATIC_CONTRACT_SUPPORTS_DAC; return InlinedStressLogOn(facility, level) || InlinedETWLogOn(facility, level); } #endif /* static */ void StressLog::LogMsg(unsigned level, unsigned facility, int cArgs, const char* format, ...) { STATIC_CONTRACT_SUPPORTS_DAC; #ifndef DACCESS_COMPILE STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_FORBID_FAULT; STATIC_CONTRACT_SUPPORTS_DAC; // Any stresslog LogMsg could theoretically create a new stress log and thus // enter a critical section. But we don't want these to cause violations in // CANNOT_TAKE_LOCK callers, since the callers would otherwise be fine in runs that don't // set the stress log config parameter. CONTRACT_VIOLATION(TakesLockViolation); _ASSERTE(cArgs >= 0 && cArgs <= 63); va_list Args; if (InlinedStressLogOn(facility, level)) { ThreadStressLog* msgs = t_pCurrentThreadLog; if (msgs == 0) { msgs = CreateThreadStressLog(); if (msgs == 0) return; } va_start(Args, format); msgs->LogMsg(facility, cArgs, format, Args); va_end(Args); } // Stress Log ETW feature available only on the desktop versions of the runtime #endif //!DACCESS_COMPILE } /* static */ void StressLog::LogMsg(unsigned level, unsigned facility, const StressLogMsg &msg) { STATIC_CONTRACT_SUPPORTS_DAC; #ifndef DACCESS_COMPILE STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_GC_NOTRIGGER; STATIC_CONTRACT_FORBID_FAULT; STATIC_CONTRACT_SUPPORTS_DAC; // Any stresslog LogMsg could theoretically create a new stress log and thus // enter a critical section. But we don't want these to cause violations in // CANNOT_TAKE_LOCK callers, since the callers would otherwise be fine in runs that don't // set the stress log config parameter. CONTRACT_VIOLATION(TakesLockViolation); _ASSERTE(msg.m_cArgs >= 0 && msg.m_cArgs <= 63); if (InlinedStressLogOn(facility, level)) { #ifdef HOST_WINDOWS // On Linux, this cast: (va_list)msg.m_args gives a compile error ThreadStressLog* msgs = t_pCurrentThreadLog; if (msgs == 0) { msgs = CreateThreadStressLog(); if (msgs == 0) return; } msgs->LogMsg(facility, msg.m_cArgs, msg.m_format, (va_list)msg.m_args); #endif //HOST_WINDOWS } // Stress Log ETW feature available only on the desktop versions of the runtime #endif //!DACCESS_COMPILE } #ifdef _DEBUG /* static */ void StressLog::LogCallStack(const char *const callTag){ if (theLog.RtlCaptureStackBackTrace) { size_t CallStackTrace[MAX_CALL_STACK_TRACE]; ULONG hash; USHORT stackTraceCount = theLog.RtlCaptureStackBackTrace (2, MAX_CALL_STACK_TRACE, (PVOID *)CallStackTrace, &hash); if (stackTraceCount > MAX_CALL_STACK_TRACE) stackTraceCount = MAX_CALL_STACK_TRACE; LogMsgOL("Start of %s stack \n", callTag); USHORT i = 0; for (;i < stackTraceCount; i++) { LogMsgOL("(%s stack)%pK\n", callTag, CallStackTrace[i]); } LogMsgOL("End of %s stack\n", callTag); } } #endif //_DEBUG #ifdef MEMORY_MAPPED_STRESSLOG void* StressLog::AllocMemoryMapped(size_t n) { if ((ptrdiff_t)n > 0) { StressLogHeader* hdr = theLog.stressLogHeader; assert(hdr != nullptr); uint8_t* newMemValue = (uint8_t*)InterlockedAdd64((LONG64*)&hdr->memoryCur, n); if (newMemValue < hdr->memoryLimit) { return newMemValue - n; } // when we run out, we just can't allocate anymore hdr->memoryCur = hdr->memoryLimit; } return nullptr; } void* __cdecl ThreadStressLog::operator new(size_t n, const NoThrow&) NOEXCEPT { if (StressLogChunk::s_LogChunkHeap != NULL) { //no need to zero memory because we could handle garbage contents return HeapAlloc(StressLogChunk::s_LogChunkHeap, 0, n); } else { return StressLog::AllocMemoryMapped(n); } } #endif //MEMORY_MAPPED_STRESSLOG #endif // STRESS_LOG
// Boost.Assign library // // Copyright Thorsten Ottosen 2003-2004. Use, modification and // distribution is subject to the Boost Software License, Version // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // For more information, see http://www.boost.org/libs/assign/ // #ifndef BOOST_ASSIGN_HPP #define BOOST_ASSIGN_HPP #if defined(_MSC_VER) # pragma once #endif #include <boost/assign/std.hpp> #include <boost/assign/list_of.hpp> #include <boost/assign/list_inserter.hpp> #include <boost/assign/assignment_exception.hpp> #endif
// _ _____ __________ // | | / / _ | / __/_ __/ Visibility // | |/ / __ |_\ \ / / Across // |___/_/ |_/___/ /_/ Space and Time // // SPDX-FileCopyrightText: (c) 2020 The VAST Contributors // SPDX-License-Identifier: BSD-3-Clause #define SUITE address_synopsis #include "vast/address_synopsis.hpp" #include "vast/address.hpp" #include "vast/concept/parseable/to.hpp" #include "vast/concept/parseable/vast/address.hpp" #include "vast/hash/hash_append.hpp" #include "vast/hash/legacy_hash.hpp" #include "vast/si_literals.hpp" #include "vast/synopsis.hpp" #include "vast/synopsis_factory.hpp" #include "vast/test/fixtures/actor_system.hpp" #include "vast/test/synopsis.hpp" #include "vast/test/test.hpp" #include "vast/type.hpp" #include <caf/actor_system.hpp> #include <caf/actor_system_config.hpp> using namespace std::string_literals; using namespace caf; using namespace vast; using namespace vast::test; using namespace vast::si_literals; TEST(failed construction) { // If there's no type attribute with Bloom filter parameters present, // construction fails. auto x = make_address_synopsis<legacy_hash>(type{address_type{}}, caf::settings{}); CHECK_EQUAL(x, nullptr); } namespace { struct fixture : fixtures::deterministic_actor_system { fixture() { factory<synopsis>::add(type{address_type{}}, make_address_synopsis<legacy_hash>); } caf::settings opts; }; auto to_addr_view(std::string_view str) { return make_data_view(unbox(to<address>(str))); } } // namespace FIXTURE_SCOPE(address_filter_synopsis_tests, fixture) TEST(construction via custom factory) { using namespace vast::test::nft; // Minimally sized Bloom filter to test expected collisions. auto t = type{address_type{}, {{"synopsis", "bloomfilter(1,0.1)"}}}; auto x = factory<synopsis>::make(t, opts); REQUIRE_NOT_EQUAL(x, nullptr); x->add(to_addr_view("192.168.0.1")); auto verify = verifier{x.get()}; verify(to_addr_view("192.168.0.1"), {N, N, N, N, N, N, T, N, N, N, N, N}); MESSAGE("collisions"); verify(to_addr_view("192.168.0.6"), {N, N, N, N, N, N, F, N, N, N, N, N}); verify(to_addr_view("192.168.0.11"), {N, N, N, N, N, N, T, N, N, N, N, N}); } TEST(serialization with custom attribute type) { auto t = type{address_type{}, {{"synopsis", "bloomfilter(1000,0.1)"}}}; CHECK_ROUNDTRIP_DEREF(factory<synopsis>::make(t, opts)); } TEST(construction based on partition size) { opts["max-partition-size"] = 1_Mi; auto ptr = factory<synopsis>::make(type{address_type{}}, opts); REQUIRE_NOT_EQUAL(ptr, nullptr); CHECK_ROUNDTRIP_DEREF(std::move(ptr)); } TEST(updated params after shrinking) { opts["buffer-input-data"] = true; opts["max-partition-size"] = 1_Mi; auto ptr = factory<synopsis>::make(type{address_type{}}, opts); ptr->add(to_addr_view("192.168.0.1")); ptr->add(to_addr_view("192.168.0.2")); ptr->add(to_addr_view("192.168.0.3")); ptr->add(to_addr_view("192.168.0.4")); ptr->add(to_addr_view("192.168.0.5")); auto shrunk = ptr->shrink(); auto type = shrunk->type(); auto params = unbox(parse_parameters(type)); // The size will be rounded up to the next power of two. CHECK_EQUAL(*params.n, 8u); auto recovered = roundtrip(std::move(shrunk)); REQUIRE(recovered); auto recovered_params = unbox(parse_parameters(type)); CHECK_EQUAL(*recovered_params.n, 8u); auto r1 = unbox( recovered->lookup(relational_operator::equal, to_addr_view("192.168.0.1"))); auto r2 = unbox(recovered->lookup(relational_operator::equal, to_addr_view("255.255.255.255"))); CHECK(r1); CHECK(!r2); } FIXTURE_SCOPE_END()
; A183626: Number of (n+1) X 4 0..2 arrays with every 2 X 2 subblock summing to 4. ; Submitted by Jamie Morken(s2) ; 115,189,355,741,1675,4029,10195,26901,73435,205869,588835,1709061,5012395,14807709,43964275,130975221,391090555,1169601549,3501464515,10489713381,31439779915,94260619389,282664417555,847758371541,2542805352475,7627476533229,22880550551395,68637893557701,205906164480235,617703461055069,1853080318394035,5559180825639861,16677422217835195,50032026135336909,150095597369673475,450285830036346021,1350855565963689355,4052562849600370749,12157680852219717715,36473027163496364181,109419050704163514715 add $0,2 mov $1,3 pow $1,$0 mov $2,2 pow $2,$0 mul $2,14 add $1,$2 mov $0,$1 add $0,50
global getKey global hasKey hasKey: push rbp mov rbp,rsp mov rax,0 in al,64h and al,0x01 leave ret getKey: push rbp mov rbp,rsp mov rax,0 in al, 60h leave ret
; A101448: Nonnegative numbers k such that 2k + 11 is prime. ; 0,1,3,4,6,9,10,13,15,16,18,21,24,25,28,30,31,34,36,39,43,45,46,48,49,51,58,60,63,64,69,70,73,76,78,81,84,85,90,91,93,94,100,106,108,109,111,114,115,120,123,126,129,130,133,135,136,141,148,150,151,153,160,163,168,169,171,174,178,181,184,186,189,193,195,199,204,205,210,211,214,216,219,223,225,226,228,234,238,240,244,246,249,255,256,265,268,273,276,279 add $0,3 seq $0,98090 ; Numbers k such that 2k-3 is prime. sub $0,7
/**************************************************************************** * * Copyright (c) 2013-2016 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /** * @file commander.cpp * * Main state machine / business logic * * @author Petri Tanskanen <petri.tanskanen@inf.ethz.ch> * @author Lorenz Meier <lorenz@px4.io> * @author Thomas Gubler <thomas@px4.io> * @author Julian Oes <julian@oes.ch> * @author Anton Babushkin <anton@px4.io> * @author Sander Smeets <sander@droneslab.com> */ #include <cmath> // NAN /* commander module headers */ #include "accelerometer_calibration.h" #include "airspeed_calibration.h" #include "baro_calibration.h" #include "calibration_routines.h" #include "commander_helper.h" #include "esc_calibration.h" #include "gyro_calibration.h" #include "mag_calibration.h" #include "PreflightCheck.h" #include "px4_custom_mode.h" #include "rc_calibration.h" #include "state_machine_helper.h" /* PX4 headers */ #include <dataman/dataman.h> #include <drivers/drv_hrt.h> #include <drivers/drv_tone_alarm.h> #include <geo/geo.h> #include <navigator/navigation.h> #include <px4_defines.h> #include <px4_config.h> #include <px4_posix.h> #include <px4_shutdown.h> #include <px4_tasks.h> #include <px4_time.h> #include <systemlib/circuit_breaker.h> #include <systemlib/err.h> #include <systemlib/mavlink_log.h> #include <systemlib/param/param.h> #include <systemlib/rc_check.h> #include <systemlib/state_table.h> #include <float.h> #include <systemlib/hysteresis/hysteresis.h> #include <board_config.h> #include <sys/stat.h> #include <string.h> #include <math.h> #include <poll.h> #include <float.h> #include <matrix/math.hpp> #include <uORB/uORB.h> #include <uORB/topics/actuator_armed.h> #include <uORB/topics/actuator_controls.h> #include <uORB/topics/battery_status.h> #include <uORB/topics/cpuload.h> #include <uORB/topics/differential_pressure.h> #include <uORB/topics/geofence_result.h> #include <uORB/topics/home_position.h> #include <uORB/topics/manual_control_setpoint.h> #include <uORB/topics/mavlink_log.h> #include <uORB/topics/mission.h> #include <uORB/topics/mission_result.h> #include <uORB/topics/offboard_control_mode.h> #include <uORB/topics/position_setpoint_triplet.h> #include <uORB/topics/vehicle_roi.h> #include <uORB/topics/parameter_update.h> #include <uORB/topics/safety.h> #include <uORB/topics/sensor_combined.h> #include <uORB/topics/subsystem_info.h> #include <uORB/topics/system_power.h> #include <uORB/topics/telemetry_status.h> #include <uORB/topics/vehicle_attitude.h> #include <uORB/topics/vehicle_command.h> #include <uORB/topics/vehicle_command_ack.h> #include <uORB/topics/vehicle_global_position.h> #include <uORB/topics/vehicle_gps_position.h> #include <uORB/topics/vehicle_land_detected.h> #include <uORB/topics/vehicle_local_position.h> #include <uORB/topics/vehicle_status_flags.h> #include <uORB/topics/vtol_vehicle_status.h> typedef enum VEHICLE_MODE_FLAG { VEHICLE_MODE_FLAG_CUSTOM_MODE_ENABLED=1, /* 0b00000001 Reserved for future use. | */ VEHICLE_MODE_FLAG_TEST_ENABLED=2, /* 0b00000010 system has a test mode enabled. This flag is intended for temporary system tests and should not be used for stable implementations. | */ VEHICLE_MODE_FLAG_AUTO_ENABLED=4, /* 0b00000100 autonomous mode enabled, system finds its own goal positions. Guided flag can be set or not, depends on the actual implementation. | */ VEHICLE_MODE_FLAG_GUIDED_ENABLED=8, /* 0b00001000 guided mode enabled, system flies MISSIONs / mission items. | */ VEHICLE_MODE_FLAG_STABILIZE_ENABLED=16, /* 0b00010000 system stabilizes electronically its attitude (and optionally position). It needs however further control inputs to move around. | */ VEHICLE_MODE_FLAG_HIL_ENABLED=32, /* 0b00100000 hardware in the loop simulation. All motors / actuators are blocked, but internal software is full operational. | */ VEHICLE_MODE_FLAG_MANUAL_INPUT_ENABLED=64, /* 0b01000000 remote control input is enabled. | */ VEHICLE_MODE_FLAG_SAFETY_ARMED=128, /* 0b10000000 MAV safety set to armed. Motors are enabled / running / can start. Ready to fly. | */ VEHICLE_MODE_FLAG_ENUM_END=129, /* | */ } VEHICLE_MODE_FLAG; static constexpr uint8_t COMMANDER_MAX_GPS_NOISE = 60; /**< Maximum percentage signal to noise ratio allowed for GPS reception */ /* Decouple update interval and hysteresis counters, all depends on intervals */ #define COMMANDER_MONITORING_INTERVAL 10000 #define COMMANDER_MONITORING_LOOPSPERMSEC (1/(COMMANDER_MONITORING_INTERVAL/1000.0f)) #define MAVLINK_OPEN_INTERVAL 50000 #define STICK_ON_OFF_LIMIT 0.9f #define POSITION_TIMEOUT (1 * 1000 * 1000) /**< consider the local or global position estimate invalid after 1000ms */ #define FAILSAFE_DEFAULT_TIMEOUT (3 * 1000 * 1000) /**< hysteresis time - the failsafe will trigger after 3 seconds in this state */ #define OFFBOARD_TIMEOUT 500000 #define DIFFPRESS_TIMEOUT 2000000 #define HOTPLUG_SENS_TIMEOUT (8 * 1000 * 1000) /**< wait for hotplug sensors to come online for upto 8 seconds */ #define PRINT_INTERVAL 5000000 #define PRINT_MODE_REJECT_INTERVAL 500000 #define INAIR_RESTART_HOLDOFF_INTERVAL 500000 #define HIL_ID_MIN 1000 #define HIL_ID_MAX 1999 /* Controls the probation period which is the amount of time required for position and velocity checks to pass before the validity can be changed from false to true*/ #define POSVEL_PROBATION_TAKEOFF 30E6 /**< probation duration set at takeoff (usec) */ #define POSVEL_PROBATION_MIN 1E6 /**< minimum probation duration (usec) */ #define POSVEL_PROBATION_MAX 100E6 /**< maximum probation duration (usec) */ #define POSVEL_VALID_PROBATION_FACTOR 10 /**< the rate at which the probation duration is increased while checks are failing */ /* * Probation times for position and velocity validity checks to pass if failed * Signed integers are used because these can become negative values before constraints are applied */ static int64_t gpos_probation_time_us = POSVEL_PROBATION_TAKEOFF; static int64_t gvel_probation_time_us = POSVEL_PROBATION_TAKEOFF; static int64_t lpos_probation_time_us = POSVEL_PROBATION_TAKEOFF; static int64_t lvel_probation_time_us = POSVEL_PROBATION_TAKEOFF; /* Mavlink log uORB handle */ static orb_advert_t mavlink_log_pub = nullptr; /* System autostart ID */ static int autostart_id; /* flags */ static bool commander_initialized = false; static volatile bool thread_should_exit = false; /**< daemon exit flag */ static volatile bool thread_running = false; /**< daemon status flag */ static int daemon_task; /**< Handle of daemon task / thread */ static bool _usb_telemetry_active = false; static hrt_abstime commander_boot_timestamp = 0; static unsigned int leds_counter; /* To remember when last notification was sent */ static uint64_t last_print_mode_reject_time = 0; static systemlib::Hysteresis auto_disarm_hysteresis(false); static float eph_threshold = 5.0f; // Horizontal position error threshold (m) static float epv_threshold = 10.0f; // Vertivcal position error threshold (m) static float evh_threshold = 1.0f; // Horizontal velocity error threshold (m) static hrt_abstime last_lpos_fail_time_us = 0; // Last time that the local position validity recovery check failed (usec) static hrt_abstime last_gpos_fail_time_us = 0; // Last time that the global position validity recovery check failed (usec) static hrt_abstime last_lvel_fail_time_us = 0; // Last time that the local velocity validity recovery check failed (usec) static hrt_abstime last_gvel_fail_time_us = 0; // Last time that the global velocity validity recovery check failed (usec) static hrt_abstime gpos_last_update_time_us = 0; // last time a global position update was received (usec) /* pre-flight EKF checks */ static float max_ekf_pos_ratio = 0.5f; static float max_ekf_vel_ratio = 0.5f; static float max_ekf_hgt_ratio = 0.5f; static float max_ekf_yaw_ratio = 0.5f; static float max_ekf_dvel_bias = 2.0e-3f; static float max_ekf_dang_bias = 3.5e-4f; /* pre-flight IMU consistency checks */ static float max_imu_acc_diff = 0.7f; static float max_imu_gyr_diff = 0.09f; static float min_stick_change = 0.25f; static struct vehicle_status_s status = {}; static struct vehicle_roi_s _roi = {}; static struct battery_status_s battery = {}; static struct actuator_armed_s armed = {}; static struct safety_s safety = {}; static struct vehicle_control_mode_s control_mode = {}; static struct offboard_control_mode_s offboard_control_mode = {}; static struct home_position_s _home = {}; static int32_t _flight_mode_slots[manual_control_setpoint_s::MODE_SLOT_MAX]; static struct commander_state_s internal_state = {}; static struct mission_result_s _mission_result = {}; static uint8_t main_state_before_rtl = commander_state_s::MAIN_STATE_MAX; static unsigned _last_mission_instance = 0; static manual_control_setpoint_s sp_man = {}; ///< the current manual control setpoint static manual_control_setpoint_s _last_sp_man = {}; ///< the manual control setpoint valid at the last mode switch static uint8_t _last_sp_man_arm_switch = 0; static struct vtol_vehicle_status_s vtol_status = {}; static struct cpuload_s cpuload = {}; static uint8_t main_state_prev = 0; static bool warning_action_on = false; static bool last_overload = false; static struct status_flags_s status_flags = {}; static uint64_t rc_signal_lost_timestamp; // Time at which the RC reception was lost static float avionics_power_rail_voltage; // voltage of the avionics power rail static bool arm_without_gps = false; static bool arm_mission_required = false; static bool _last_condition_global_position_valid = false; static struct vehicle_land_detected_s land_detector = {}; /** * The daemon app only briefly exists to start * the background job. The stack size assigned in the * Makefile does only apply to this management task. * * The actual stack size should be set in the call * to task_create(). * * @ingroup apps */ extern "C" __EXPORT int commander_main(int argc, char *argv[]); /** * Print the correct usage. */ void usage(const char *reason); /** * React to commands that are sent e.g. from the mavlink module. */ bool handle_command(struct vehicle_status_s *status, const struct safety_s *safety, struct vehicle_command_s *cmd, struct actuator_armed_s *armed, struct home_position_s *home, struct vehicle_global_position_s *global_pos, struct vehicle_local_position_s *local_pos, struct vehicle_attitude_s *attitude, orb_advert_t *home_pub, orb_advert_t *command_ack_pub, struct vehicle_command_ack_s *command_ack, struct vehicle_roi_s *roi, orb_advert_t *roi_pub, bool *changed); /** * Mainloop of commander. */ int commander_thread_main(int argc, char *argv[]); void control_status_leds(vehicle_status_s *status_local, const actuator_armed_s *actuator_armed, bool changed, battery_status_s *battery_local, const cpuload_s *cpuload_local); void get_circuit_breaker_params(); void check_valid(hrt_abstime timestamp, hrt_abstime timeout, bool valid_in, bool *valid_out, bool *changed); transition_result_t set_main_state_rc(struct vehicle_status_s *status, vehicle_global_position_s *global_position, vehicle_local_position_s *local_position, bool *changed); void reset_posvel_validity(vehicle_global_position_s *global_position, vehicle_local_position_s *local_position, bool *changed); void check_posvel_validity(bool data_valid, float data_accuracy, float required_accuracy, uint64_t data_timestamp_us, hrt_abstime *last_fail_time_us, int64_t *probation_time_us, bool *valid_state, bool *validity_changed); void set_control_mode(); bool stabilization_required(); void print_reject_mode(struct vehicle_status_s *current_status, const char *msg); void print_reject_arm(const char *msg); void print_status(); transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub, const char *armedBy); /** * @brief This function initializes the home position of the vehicle. This happens first time we get a good GPS fix and each * time the vehicle is armed with a good GPS fix. **/ static void commander_set_home_position(orb_advert_t &homePub, home_position_s &home, const vehicle_local_position_s &localPosition, const vehicle_global_position_s &globalPosition, const vehicle_attitude_s &attitude); /** * Loop that runs at a lower rate and priority for calibration and parameter tasks. */ void *commander_low_prio_loop(void *arg); static void answer_command(struct vehicle_command_s &cmd, unsigned result, orb_advert_t &command_ack_pub, vehicle_command_ack_s &command_ack); /* publish vehicle status flags from the global variable status_flags*/ static void publish_status_flags(orb_advert_t &vehicle_status_flags_pub); static int power_button_state_notification_cb(board_power_button_state_notification_e request) { // Note: this can be called from IRQ handlers if (request == PWR_BUTTON_REQUEST_SHUT_DOWN) { px4_shutdown_request(false, false); } return PWR_BUTTON_RESPONSE_SHUT_DOWN_PENDING; } /** * check whether autostart ID is in the reserved range for HIL setups */ static bool is_hil_setup(int id) { return (id >= HIL_ID_MIN) && (id <= HIL_ID_MAX); } int commander_main(int argc, char *argv[]) { if (argc < 2) { usage("missing command"); return 1; } if (!strcmp(argv[1], "start")) { if (thread_running) { warnx("already running"); /* this is not an error */ return 0; } thread_should_exit = false; daemon_task = px4_task_spawn_cmd("commander", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT + 40, 3700, commander_thread_main, (char * const *)&argv[0]); unsigned constexpr max_wait_us = 1000000; unsigned constexpr max_wait_steps = 2000; unsigned i; for (i = 0; i < max_wait_steps; i++) { usleep(max_wait_us / max_wait_steps); if (thread_running) { break; } } return !(i < max_wait_steps); } if (!strcmp(argv[1], "stop")) { if (!thread_running) { warnx("commander already stopped"); return 0; } thread_should_exit = true; while (thread_running) { usleep(200000); warnx("."); } warnx("terminated."); return 0; } /* commands needing the app to run below */ if (!thread_running) { warnx("\tcommander not started"); return 1; } if (!strcmp(argv[1], "status")) { print_status(); return 0; } if (!strcmp(argv[1], "calibrate")) { if (argc > 2) { int calib_ret = OK; if (!strcmp(argv[2], "mag")) { calib_ret = do_mag_calibration(&mavlink_log_pub); } else if (!strcmp(argv[2], "accel")) { calib_ret = do_accel_calibration(&mavlink_log_pub); } else if (!strcmp(argv[2], "gyro")) { calib_ret = do_gyro_calibration(&mavlink_log_pub); } else if (!strcmp(argv[2], "level")) { calib_ret = do_level_calibration(&mavlink_log_pub); } else if (!strcmp(argv[2], "esc")) { calib_ret = do_esc_calibration(&mavlink_log_pub, &armed); } else if (!strcmp(argv[2], "airspeed")) { calib_ret = do_airspeed_calibration(&mavlink_log_pub); } else { warnx("argument %s unsupported.", argv[2]); } if (calib_ret) { warnx("calibration failed, exiting."); return 1; } else { return 0; } } else { warnx("missing argument"); } } if (!strcmp(argv[1], "check")) { int checkres = 0; checkres = preflight_check(&status, &mavlink_log_pub, false, true, &status_flags, &battery, true, false, hrt_elapsed_time(&commander_boot_timestamp)); warnx("Preflight check: %s", (checkres == 0) ? "OK" : "FAILED"); checkres = preflight_check(&status, &mavlink_log_pub, true, true, &status_flags, &battery, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); warnx("Prearm check: %s", (checkres == 0) ? "OK" : "FAILED"); return 0; } if (!strcmp(argv[1], "arm")) { if (TRANSITION_CHANGED != arm_disarm(true, &mavlink_log_pub, "command line")) { warnx("arming failed"); } return 0; } if (!strcmp(argv[1], "disarm")) { if (TRANSITION_DENIED == arm_disarm(false, &mavlink_log_pub, "command line")) { warnx("rejected disarm"); } return 0; } if (!strcmp(argv[1], "takeoff")) { /* see if we got a home position */ if (status_flags.condition_local_position_valid) { if (TRANSITION_DENIED != arm_disarm(true, &mavlink_log_pub, "command line")) { vehicle_command_s cmd = {}; cmd.target_system = status.system_id; cmd.target_component = status.component_id; cmd.command = vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF; cmd.param1 = NAN; /* minimum pitch */ /* param 2-3 unused */ cmd.param2 = NAN; cmd.param3 = NAN; cmd.param4 = NAN; cmd.param5 = NAN; cmd.param6 = NAN; cmd.param7 = NAN; orb_advert_t h = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH); (void)orb_unadvertise(h); } else { warnx("arming failed"); } } else { warnx("rejecting takeoff, no position lock yet. Please retry.."); } return 0; } if (!strcmp(argv[1], "land")) { vehicle_command_s cmd = {}; cmd.target_system = status.system_id; cmd.target_component = status.component_id; cmd.command = vehicle_command_s::VEHICLE_CMD_NAV_LAND; /* param 2-3 unused */ cmd.param2 = NAN; cmd.param3 = NAN; cmd.param4 = NAN; cmd.param5 = NAN; cmd.param6 = NAN; cmd.param7 = NAN; orb_advert_t h = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH); (void)orb_unadvertise(h); return 0; } if (!strcmp(argv[1], "transition")) { vehicle_command_s cmd = {}; cmd.target_system = status.system_id; cmd.target_component = status.component_id; cmd.command = vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION; /* transition to the other mode */ cmd.param1 = (status.is_rotary_wing) ? vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW : vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC; /* param 2-3 unused */ cmd.param2 = NAN; cmd.param3 = NAN; cmd.param4 = NAN; cmd.param5 = NAN; cmd.param6 = NAN; cmd.param7 = NAN; orb_advert_t h = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH); (void)orb_unadvertise(h); return 0; } if (!strcmp(argv[1], "mode")) { if (argc > 2) { uint8_t new_main_state = commander_state_s::MAIN_STATE_MAX; if (!strcmp(argv[2], "manual")) { new_main_state = commander_state_s::MAIN_STATE_MANUAL; } else if (!strcmp(argv[2], "altctl")) { new_main_state = commander_state_s::MAIN_STATE_ALTCTL; } else if (!strcmp(argv[2], "posctl")) { new_main_state = commander_state_s::MAIN_STATE_POSCTL; } else if (!strcmp(argv[2], "auto:mission")) { new_main_state = commander_state_s::MAIN_STATE_AUTO_MISSION; } else if (!strcmp(argv[2], "auto:loiter")) { new_main_state = commander_state_s::MAIN_STATE_AUTO_LOITER; } else if (!strcmp(argv[2], "auto:rtl")) { new_main_state = commander_state_s::MAIN_STATE_AUTO_RTL; } else if (!strcmp(argv[2], "acro")) { new_main_state = commander_state_s::MAIN_STATE_ACRO; } else if (!strcmp(argv[2], "offboard")) { new_main_state = commander_state_s::MAIN_STATE_OFFBOARD; } else if (!strcmp(argv[2], "stabilized")) { new_main_state = commander_state_s::MAIN_STATE_STAB; } else if (!strcmp(argv[2], "rattitude")) { new_main_state = commander_state_s::MAIN_STATE_RATTITUDE; } else if (!strcmp(argv[2], "auto:takeoff")) { new_main_state = commander_state_s::MAIN_STATE_AUTO_TAKEOFF; } else if (!strcmp(argv[2], "auto:land")) { new_main_state = commander_state_s::MAIN_STATE_AUTO_LAND; } else { warnx("argument %s unsupported.", argv[2]); } if (TRANSITION_DENIED == main_state_transition(&status, new_main_state, main_state_prev, &status_flags, &internal_state)) { warnx("mode change failed"); } return 0; } else { warnx("missing argument"); } } if (!strcmp(argv[1], "lockdown")) { if (argc < 3) { usage("not enough arguments, missing [on, off]"); return 1; } vehicle_command_s cmd = {}; cmd.target_system = status.system_id; cmd.target_component = status.component_id; cmd.command = vehicle_command_s::VEHICLE_CMD_DO_FLIGHTTERMINATION; /* if the comparison matches for off (== 0) set 0.0f, 2.0f (on) else */ cmd.param1 = strcmp(argv[2], "off") ? 2.0f : 0.0f; /* lockdown */ orb_advert_t h = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH); (void)orb_unadvertise(h); return 0; } usage("unrecognized command"); return 1; } void usage(const char *reason) { if (reason && *reason > 0) { PX4_INFO("%s", reason); } PX4_INFO("usage: commander {start|stop|status|calibrate|check|arm|disarm|takeoff|land|transition|mode}\n"); } void print_status() { warnx("type: %s", (status.is_rotary_wing) ? "symmetric motion" : "forward motion"); warnx("safety: USB enabled: %s, power state valid: %s", (status_flags.usb_connected) ? "[OK]" : "[NO]", (status_flags.condition_power_input_valid) ? " [OK]" : "[NO]"); warnx("avionics rail: %6.2f V", (double)avionics_power_rail_voltage); warnx("home: lat = %.7f, lon = %.7f, alt = %.2f, yaw: %.2f", _home.lat, _home.lon, (double)_home.alt, (double)_home.yaw); warnx("home: x = %.7f, y = %.7f, z = %.2f ", (double)_home.x, (double)_home.y, (double)_home.z); warnx("datalink: %s", (status.data_link_lost) ? "LOST" : "OK"); #ifdef __PX4_POSIX warnx("main state: %d", internal_state.main_state); warnx("nav state: %d", status.nav_state); #endif /* read all relevant states */ int state_sub = orb_subscribe(ORB_ID(vehicle_status)); struct vehicle_status_s state; orb_copy(ORB_ID(vehicle_status), state_sub, &state); const char *armed_str; switch (status.arming_state) { case vehicle_status_s::ARMING_STATE_INIT: armed_str = "INIT"; break; case vehicle_status_s::ARMING_STATE_STANDBY: armed_str = "STANDBY"; break; case vehicle_status_s::ARMING_STATE_ARMED: armed_str = "ARMED"; break; case vehicle_status_s::ARMING_STATE_ARMED_ERROR: armed_str = "ARMED_ERROR"; break; case vehicle_status_s::ARMING_STATE_STANDBY_ERROR: armed_str = "STANDBY_ERROR"; break; case vehicle_status_s::ARMING_STATE_REBOOT: armed_str = "REBOOT"; break; case vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE: armed_str = "IN_AIR_RESTORE"; break; default: armed_str = "ERR: UNKNOWN STATE"; break; } px4_close(state_sub); warnx("arming: %s", armed_str); } static orb_advert_t status_pub; transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub_local, const char *armedBy) { transition_result_t arming_res = TRANSITION_NOT_CHANGED; // For HIL platforms, require that simulated sensors are connected if (arm && hrt_absolute_time() > commander_boot_timestamp + INAIR_RESTART_HOLDOFF_INTERVAL && is_hil_setup(autostart_id) && status.hil_state != vehicle_status_s::HIL_STATE_ON) { mavlink_log_critical(mavlink_log_pub_local, "HIL platform: Connect to simulator before arming"); return TRANSITION_DENIED; } // Transition the armed state. By passing mavlink_log_pub to arming_state_transition it will // output appropriate error messages if the state cannot transition. arming_res = arming_state_transition(&status, &battery, &safety, arm ? vehicle_status_s::ARMING_STATE_ARMED : vehicle_status_s::ARMING_STATE_STANDBY, &armed, true /* fRunPreArmChecks */, mavlink_log_pub_local, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); if (arming_res == TRANSITION_CHANGED) { mavlink_log_info(mavlink_log_pub_local, "%s by %s", arm ? "ARMED" : "DISARMED", armedBy); } else if (arming_res == TRANSITION_DENIED) { tune_negative(true); } return arming_res; } bool handle_command(struct vehicle_status_s *status_local, const struct safety_s *safety_local, struct vehicle_command_s *cmd, struct actuator_armed_s *armed_local, struct home_position_s *home, struct vehicle_global_position_s *global_pos, struct vehicle_local_position_s *local_pos, struct vehicle_attitude_s *attitude, orb_advert_t *home_pub, orb_advert_t *command_ack_pub, struct vehicle_command_ack_s *command_ack, struct vehicle_roi_s *roi, orb_advert_t *roi_pub, bool *changed) { /* only handle commands that are meant to be handled by this system and component */ if (cmd->target_system != status_local->system_id || ((cmd->target_component != status_local->component_id) && (cmd->target_component != 0))) { // component_id 0: valid for all components return false; } /* result of the command */ unsigned cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED; /* request to set different system mode */ switch (cmd->command) { case vehicle_command_s::VEHICLE_CMD_DO_REPOSITION: { // Just switch the flight mode here, the navigator takes care of // doing something sensible with the coordinates. Its designed // to not require navigator and command to receive / process // the data at the exact same time. // Check if a mode switch had been requested if ((((uint32_t)cmd->param2) & 1) > 0) { transition_result_t main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); if ((main_ret != TRANSITION_DENIED)) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; mavlink_log_critical(&mavlink_log_pub, "Rejecting reposition command"); } } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } } break; case vehicle_command_s::VEHICLE_CMD_DO_SET_MODE: { uint8_t base_mode = (uint8_t)cmd->param1; uint8_t custom_main_mode = (uint8_t)cmd->param2; uint8_t custom_sub_mode = (uint8_t)cmd->param3; transition_result_t arming_ret = TRANSITION_NOT_CHANGED; transition_result_t main_ret = TRANSITION_NOT_CHANGED; /* set HIL state */ hil_state_t new_hil_state = (base_mode & VEHICLE_MODE_FLAG_HIL_ENABLED) ? vehicle_status_s::HIL_STATE_ON : vehicle_status_s::HIL_STATE_OFF; transition_result_t hil_ret = hil_state_transition(new_hil_state, status_pub, status_local, &mavlink_log_pub); // We ignore base_mode & VEHICLE_MODE_FLAG_SAFETY_ARMED because // the command VEHICLE_CMD_COMPONENT_ARM_DISARM should be used // instead according to the latest mavlink spec. if (base_mode & VEHICLE_MODE_FLAG_CUSTOM_MODE_ENABLED) { /* use autopilot-specific mode */ if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_MANUAL) { /* MANUAL */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_ALTCTL) { /* ALTCTL */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_ALTCTL, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_POSCTL) { /* POSCTL */ reset_posvel_validity(global_pos, local_pos, changed); main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_AUTO) { /* AUTO */ if (custom_sub_mode > 0) { reset_posvel_validity(global_pos, local_pos, changed); switch(custom_sub_mode) { case PX4_CUSTOM_SUB_MODE_AUTO_LOITER: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); break; case PX4_CUSTOM_SUB_MODE_AUTO_MISSION: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_MISSION, main_state_prev, &status_flags, &internal_state); break; case PX4_CUSTOM_SUB_MODE_AUTO_RTL: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state); break; case PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_TAKEOFF, main_state_prev, &status_flags, &internal_state); break; case PX4_CUSTOM_SUB_MODE_AUTO_LAND: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LAND, main_state_prev, &status_flags, &internal_state); break; case PX4_CUSTOM_SUB_MODE_AUTO_FOLLOW_TARGET: main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_FOLLOW_TARGET, main_state_prev, &status_flags, &internal_state); break; default: main_ret = TRANSITION_DENIED; mavlink_log_critical(&mavlink_log_pub, "Unsupported auto mode"); break; } } else { main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_MISSION, main_state_prev, &status_flags, &internal_state); } } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_ACRO) { /* ACRO */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_ACRO, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_RATTITUDE) { /* RATTITUDE */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_RATTITUDE, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_STABILIZED) { /* STABILIZED */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } else if (custom_main_mode == PX4_CUSTOM_MAIN_MODE_OFFBOARD) { reset_posvel_validity(global_pos, local_pos, changed); /* OFFBOARD */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_OFFBOARD, main_state_prev, &status_flags, &internal_state); } } else { /* use base mode */ if (base_mode & VEHICLE_MODE_FLAG_AUTO_ENABLED) { /* AUTO */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_MISSION, main_state_prev, &status_flags, &internal_state); } else if (base_mode & VEHICLE_MODE_FLAG_MANUAL_INPUT_ENABLED) { if (base_mode & VEHICLE_MODE_FLAG_GUIDED_ENABLED) { /* POSCTL */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); } else if (base_mode & VEHICLE_MODE_FLAG_STABILIZE_ENABLED) { /* STABILIZED */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } else { /* MANUAL */ main_ret = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } } } if ((hil_ret != TRANSITION_DENIED) && (arming_ret != TRANSITION_DENIED) && (main_ret != TRANSITION_DENIED)) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; if (arming_ret == TRANSITION_DENIED) { mavlink_log_critical(&mavlink_log_pub, "Rejecting arming cmd"); } } } break; case vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM: { // Adhere to MAVLink specs, but base on knowledge that these fundamentally encode ints // for logic state parameters if (static_cast<int>(cmd->param1 + 0.5f) != 0 && static_cast<int>(cmd->param1 + 0.5f) != 1) { mavlink_log_critical(&mavlink_log_pub, "Unsupported ARM_DISARM param: %.3f", (double)cmd->param1); } else { bool cmd_arms = (static_cast<int>(cmd->param1 + 0.5f) == 1); // Flick to inair restore first if this comes from an onboard system if (cmd->source_system == status_local->system_id && cmd->source_component == status_local->component_id) { status.arming_state = vehicle_status_s::ARMING_STATE_IN_AIR_RESTORE; } else { // Refuse to arm if preflight checks have failed if ((!status_local->hil_state) != vehicle_status_s::HIL_STATE_ON && !status_flags.condition_system_sensors_initialized) { mavlink_log_critical(&mavlink_log_pub, "Arming DENIED. Preflight checks have failed."); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_DENIED; break; } // Refuse to arm if in manual with non-zero throttle if (cmd_arms && (status_local->nav_state == vehicle_status_s::NAVIGATION_STATE_MANUAL || status_local->nav_state == vehicle_status_s::NAVIGATION_STATE_ACRO || status_local->nav_state == vehicle_status_s::NAVIGATION_STATE_STAB || status_local->nav_state == vehicle_status_s::NAVIGATION_STATE_RATTITUDE) && (sp_man.z > 0.1f)) { mavlink_log_critical(&mavlink_log_pub, "Arming DENIED. Manual throttle non-zero."); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_DENIED; break; } } transition_result_t arming_res = arm_disarm(cmd_arms, &mavlink_log_pub, "arm/disarm component command"); if (arming_res == TRANSITION_DENIED) { mavlink_log_critical(&mavlink_log_pub, "REJECTING component arm cmd"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; /* update home position on arming if at least 500 ms from commander start spent to avoid setting home on in-air restart */ if (cmd_arms && (arming_res == TRANSITION_CHANGED) && (hrt_absolute_time() > (commander_boot_timestamp + INAIR_RESTART_HOLDOFF_INTERVAL))) { commander_set_home_position(*home_pub, *home, *local_pos, *global_pos, *attitude); } } } } break; case vehicle_command_s::VEHICLE_CMD_DO_FLIGHTTERMINATION: { if (cmd->param1 > 1.5f) { armed_local->lockdown = true; warnx("forcing lockdown (motors off)"); } else if (cmd->param1 > 0.5f) { //XXX update state machine? armed_local->force_failsafe = true; warnx("forcing failsafe (termination)"); /* param2 is currently used for other failsafe modes */ status_local->engine_failure_cmd = false; status_flags.data_link_lost_cmd = false; status_flags.gps_failure_cmd = false; status_flags.rc_signal_lost_cmd = false; status_flags.vtol_transition_failure_cmd = false; if ((int)cmd->param2 <= 0) { /* reset all commanded failure modes */ warnx("reset all non-flighttermination failsafe commands"); } else if ((int)cmd->param2 == 1) { /* trigger engine failure mode */ status_local->engine_failure_cmd = true; warnx("engine failure mode commanded"); } else if ((int)cmd->param2 == 2) { /* trigger data link loss mode */ status_flags.data_link_lost_cmd = true; warnx("data link loss mode commanded"); } else if ((int)cmd->param2 == 3) { /* trigger gps loss mode */ status_flags.gps_failure_cmd = true; warnx("GPS loss mode commanded"); } else if ((int)cmd->param2 == 4) { /* trigger rc loss mode */ status_flags.rc_signal_lost_cmd = true; warnx("RC loss mode commanded"); } else if ((int)cmd->param2 == 5) { /* trigger vtol transition failure mode */ status_flags.vtol_transition_failure_cmd = true; warnx("vtol transition failure mode commanded"); } } else { armed_local->force_failsafe = false; armed_local->lockdown = false; warnx("disabling failsafe and lockdown"); } cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } break; case vehicle_command_s::VEHICLE_CMD_DO_SET_HOME: { bool use_current = cmd->param1 > 0.5f; if (use_current) { /* use current position */ if (status_flags.condition_global_position_valid) { home->lat = global_pos->lat; home->lon = global_pos->lon; home->alt = global_pos->alt; home->timestamp = hrt_absolute_time(); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } } else { /* use specified position */ home->lat = cmd->param5; home->lon = cmd->param6; home->alt = cmd->param7; home->timestamp = hrt_absolute_time(); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } if (cmd_result == vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED) { mavlink_and_console_log_info(&mavlink_log_pub, "Home position: %.7f, %.7f, %.2f", home->lat, home->lon, (double)home->alt); /* announce new home position */ if (*home_pub != nullptr) { orb_publish(ORB_ID(home_position), *home_pub, home); } else { *home_pub = orb_advertise(ORB_ID(home_position), home); } /* mark home position as set */ status_flags.condition_home_position_valid = true; } } break; case vehicle_command_s::VEHICLE_CMD_NAV_GUIDED_ENABLE: { transition_result_t res = TRANSITION_DENIED; static main_state_t main_state_pre_offboard = commander_state_s::MAIN_STATE_MANUAL; if (internal_state.main_state != commander_state_s::MAIN_STATE_OFFBOARD) { main_state_pre_offboard = internal_state.main_state; } if (cmd->param1 > 0.5f) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_OFFBOARD, main_state_prev, &status_flags, &internal_state); if (res == TRANSITION_DENIED) { print_reject_mode(status_local, "OFFBOARD"); status_flags.offboard_control_set_by_command = false; } else { /* Set flag that offboard was set via command, main state is not overridden by rc */ status_flags.offboard_control_set_by_command = true; } } else { /* If the mavlink command is used to enable or disable offboard control: * switch back to previous mode when disabling */ res = main_state_transition(status_local, main_state_pre_offboard, main_state_prev, &status_flags, &internal_state); status_flags.offboard_control_set_by_command = false; } if (res == TRANSITION_DENIED) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } } break; case vehicle_command_s::VEHICLE_CMD_NAV_RETURN_TO_LAUNCH: { /* switch to RTL which ends the mission */ if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state)) { mavlink_and_console_log_info(&mavlink_log_pub, "Returning to launch"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { mavlink_log_critical(&mavlink_log_pub, "Return to launch denied"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } } break; case vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF: { /* ok, home set, use it to take off */ if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_TAKEOFF, main_state_prev, &status_flags, &internal_state)) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else if (internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_TAKEOFF) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { mavlink_log_critical(&mavlink_log_pub, "Takeoff denied, disarm and re-try"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } } break; case vehicle_command_s::VEHICLE_CMD_NAV_LAND: { if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LAND, main_state_prev, &status_flags, &internal_state)) { mavlink_and_console_log_info(&mavlink_log_pub, "Landing at current position"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { mavlink_log_critical(&mavlink_log_pub, "Landing denied, land manually"); cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; } } break; case vehicle_command_s::VEHICLE_CMD_NAV_ROI: case vehicle_command_s::VEHICLE_CMD_DO_SET_ROI: { roi->mode = cmd->param1; if (roi->mode == vehicle_roi_s::VEHICLE_ROI_WPINDEX) { roi->mission_seq = cmd->param2; } else if (roi->mode == vehicle_roi_s::VEHICLE_ROI_LOCATION) { roi->lat = cmd->param5; roi->lon = cmd->param6; roi->alt = cmd->param7; } else if (roi->mode == vehicle_roi_s::VEHICLE_ROI_TARGET) { roi->target_seq = cmd->param2; } if (*roi_pub != nullptr) { orb_publish(ORB_ID(vehicle_roi), *roi_pub, roi); } else { *roi_pub = orb_advertise(ORB_ID(vehicle_roi), roi); } cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; break; } case vehicle_command_s::VEHICLE_CMD_MISSION_START: { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_DENIED; // check if current mission and first item are valid if (_mission_result.valid) { // requested first mission item valid if (PX4_ISFINITE(cmd->param1) && (cmd->param1 >= 0) && (cmd->param1 < _mission_result.seq_total)) { // switch to AUTO_MISSION and ARM if ((TRANSITION_DENIED != main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_MISSION, main_state_prev, &status_flags, &internal_state)) && (TRANSITION_DENIED != arm_disarm(true, &mavlink_log_pub, "mission start command"))) { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED; } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; mavlink_log_critical(&mavlink_log_pub, "Mission start denied"); } } } else { mavlink_log_critical(&mavlink_log_pub, "Mission start denied, no valid mission"); } } break; case vehicle_command_s::VEHICLE_CMD_CUSTOM_0: case vehicle_command_s::VEHICLE_CMD_CUSTOM_1: case vehicle_command_s::VEHICLE_CMD_CUSTOM_2: case vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL: case vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONFIGURE: case vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL_QUAT: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_REBOOT_SHUTDOWN: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_CALIBRATION: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_SET_SENSOR_OFFSETS: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_STORAGE: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_UAVCAN: case vehicle_command_s::VEHICLE_CMD_PAYLOAD_PREPARE_DEPLOY: case vehicle_command_s::VEHICLE_CMD_PAYLOAD_CONTROL_DEPLOY: case vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION: case vehicle_command_s::VEHICLE_CMD_DO_TRIGGER_CONTROL: case vehicle_command_s::VEHICLE_CMD_DO_DIGICAM_CONTROL: case vehicle_command_s::VEHICLE_CMD_DO_SET_CAM_TRIGG_DIST: case vehicle_command_s::VEHICLE_CMD_DO_SET_CAM_TRIGG_INTERVAL: case vehicle_command_s::VEHICLE_CMD_SET_CAMERA_MODE: case vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED: case vehicle_command_s::VEHICLE_CMD_DO_LAND_START: case vehicle_command_s::VEHICLE_CMD_DO_GO_AROUND: case vehicle_command_s::VEHICLE_CMD_START_RX_PAIR: case vehicle_command_s::VEHICLE_CMD_LOGGING_START: case vehicle_command_s::VEHICLE_CMD_LOGGING_STOP: case vehicle_command_s::VEHICLE_CMD_NAV_DELAY: /* ignore commands that handled in low prio loop */ break; default: /* Warn about unsupported commands, this makes sense because only commands * to this component ID (or all) are passed by mavlink. */ answer_command(*cmd, vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED, *command_ack_pub, *command_ack); break; } if (cmd_result != vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED) { /* already warned about unsupported commands in "default" case */ answer_command(*cmd, cmd_result, *command_ack_pub, *command_ack); } return true; } /** * @brief This function initializes the home position of the vehicle. This happens first time we get a good GPS fix and each * time the vehicle is armed with a good GPS fix. **/ static void commander_set_home_position(orb_advert_t &homePub, home_position_s &home, const vehicle_local_position_s &localPosition, const vehicle_global_position_s &globalPosition, const vehicle_attitude_s &attitude) { //Need global position fix to be able to set home if (!status_flags.condition_global_position_valid) { return; } //Ensure that the GPS accuracy is good enough for intializing home if (globalPosition.eph > eph_threshold || globalPosition.epv > epv_threshold) { return; } //Set home position home.timestamp = hrt_absolute_time(); home.lat = globalPosition.lat; home.lon = globalPosition.lon; home.alt = globalPosition.alt; home.x = localPosition.x; home.y = localPosition.y; home.z = localPosition.z; matrix::Eulerf euler = matrix::Quatf(attitude.q); home.yaw = euler.psi(); PX4_INFO("home: %.7f, %.7f, %.2f", home.lat, home.lon, (double)home.alt); /* announce new home position */ if (homePub != nullptr) { orb_publish(ORB_ID(home_position), homePub, &home); } else { homePub = orb_advertise(ORB_ID(home_position), &home); } //Play tune first time we initialize HOME if (!status_flags.condition_home_position_valid) { tune_home_set(true); } /* mark home position as set */ status_flags.condition_home_position_valid = true; } int commander_thread_main(int argc, char *argv[]) { /* not yet initialized */ commander_initialized = false; bool sensor_fail_tune_played = false; bool arm_tune_played = false; bool was_landed = true; bool was_falling = false; bool was_armed = false; bool startup_in_hil = false; // XXX for now just set sensors as initialized status_flags.condition_system_sensors_initialized = true; #ifdef __PX4_NUTTX /* NuttX indicates 3 arguments when only 2 are present */ argc -= 1; argv += 1; #endif if (argc > 2) { if (!strcmp(argv[2],"-hil")) { startup_in_hil = true; } else { PX4_ERR("Argument %s not supported, abort.", argv[2]); thread_should_exit = true; } } /* set parameters */ param_t _param_sys_type = param_find("MAV_TYPE"); param_t _param_system_id = param_find("MAV_SYS_ID"); param_t _param_component_id = param_find("MAV_COMP_ID"); param_t _param_enable_datalink_loss = param_find("NAV_DLL_ACT"); param_t _param_offboard_loss_act = param_find("COM_OBL_ACT"); param_t _param_offboard_loss_rc_act = param_find("COM_OBL_RC_ACT"); param_t _param_enable_rc_loss = param_find("NAV_RCL_ACT"); param_t _param_datalink_loss_timeout = param_find("COM_DL_LOSS_T"); param_t _param_rc_loss_timeout = param_find("COM_RC_LOSS_T"); param_t _param_datalink_regain_timeout = param_find("COM_DL_REG_T"); param_t _param_ef_throttle_thres = param_find("COM_EF_THROT"); param_t _param_ef_current2throttle_thres = param_find("COM_EF_C2T"); param_t _param_ef_time_thres = param_find("COM_EF_TIME"); param_t _param_autostart_id = param_find("SYS_AUTOSTART"); param_t _param_rc_in_off = param_find("COM_RC_IN_MODE"); param_t _param_rc_arm_hyst = param_find("COM_RC_ARM_HYST"); param_t _param_min_stick_change = param_find("COM_RC_STICK_OV"); param_t _param_eph = param_find("COM_HOME_H_T"); param_t _param_epv = param_find("COM_HOME_V_T"); param_t _param_geofence_action = param_find("GF_ACTION"); param_t _param_disarm_land = param_find("COM_DISARM_LAND"); param_t _param_low_bat_act = param_find("COM_LOW_BAT_ACT"); param_t _param_offboard_loss_timeout = param_find("COM_OF_LOSS_T"); param_t _param_arm_without_gps = param_find("COM_ARM_WO_GPS"); param_t _param_arm_switch_is_button = param_find("COM_ARM_SWISBTN"); param_t _param_rc_override = param_find("COM_RC_OVERRIDE"); param_t _param_arm_mission_required = param_find("COM_ARM_MIS_REQ"); param_t _param_fmode_1 = param_find("COM_FLTMODE1"); param_t _param_fmode_2 = param_find("COM_FLTMODE2"); param_t _param_fmode_3 = param_find("COM_FLTMODE3"); param_t _param_fmode_4 = param_find("COM_FLTMODE4"); param_t _param_fmode_5 = param_find("COM_FLTMODE5"); param_t _param_fmode_6 = param_find("COM_FLTMODE6"); /* pre-flight EKF checks */ param_t _param_max_ekf_pos_ratio = param_find("COM_ARM_EKF_POS"); param_t _param_max_ekf_vel_ratio = param_find("COM_ARM_EKF_VEL"); param_t _param_max_ekf_hgt_ratio = param_find("COM_ARM_EKF_HGT"); param_t _param_max_ekf_yaw_ratio = param_find("COM_ARM_EKF_YAW"); param_t _param_max_ekf_dvel_bias = param_find("COM_ARM_EKF_AB"); param_t _param_max_ekf_dang_bias = param_find("COM_ARM_EKF_GB"); /* pre-flight IMU consistency checks */ param_t _param_max_imu_acc_diff = param_find("COM_ARM_IMU_ACC"); param_t _param_max_imu_gyr_diff = param_find("COM_ARM_IMU_GYR"); /* failsafe response to loss of navigation accuracy */ param_t _param_posctl_nav_loss_act = param_find("COM_POSCTL_NAVL"); // These are too verbose, but we will retain them a little longer // until we are sure we really don't need them. // const char *main_states_str[commander_state_s::MAIN_STATE_MAX]; // main_states_str[commander_state_s::MAIN_STATE_MANUAL] = "MANUAL"; // main_states_str[commander_state_s::MAIN_STATE_ALTCTL] = "ALTCTL"; // main_states_str[commander_state_s::MAIN_STATE_POSCTL] = "POSCTL"; // main_states_str[commander_state_s::MAIN_STATE_AUTO_MISSION] = "AUTO_MISSION"; // main_states_str[commander_state_s::MAIN_STATE_AUTO_LOITER] = "AUTO_LOITER"; // main_states_str[commander_state_s::MAIN_STATE_AUTO_RTL] = "AUTO_RTL"; // main_states_str[commander_state_s::MAIN_STATE_ACRO] = "ACRO"; // main_states_str[commander_state_s::MAIN_STATE_STAB] = "STAB"; // main_states_str[commander_state_s::MAIN_STATE_OFFBOARD] = "OFFBOARD"; // const char *nav_states_str[vehicle_status_s::NAVIGATION_STATE_MAX]; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_MANUAL] = "MANUAL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_STAB] = "STAB"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_RATTITUDE] = "RATTITUDE"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_ALTCTL] = "ALTCTL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_POSCTL] = "POSCTL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION] = "AUTO_MISSION"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER] = "AUTO_LOITER"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_RTL] = "AUTO_RTL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF] = "AUTO_TAKEOFF"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_RCRECOVER] = "AUTO_RCRECOVER"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_RTGS] = "AUTO_RTGS"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL] = "AUTO_LANDENGFAIL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL] = "AUTO_LANDGPSFAIL"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_ACRO] = "ACRO"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_AUTO_LAND] = "LAND"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_DESCEND] = "DESCEND"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_TERMINATION] = "TERMINATION"; // nav_states_str[vehicle_status_s::NAVIGATION_STATE_OFFBOARD] = "OFFBOARD"; /* pthread for slow low prio thread */ pthread_t commander_low_prio_thread; /* initialize */ if (led_init() != OK) { PX4_WARN("LED init failed"); } if (buzzer_init() != OK) { PX4_WARN("Buzzer init failed"); } if (board_register_power_state_notification_cb(power_button_state_notification_cb) != 0) { PX4_ERR("Failed to register power notification callback"); } /* vehicle status topic */ memset(&status, 0, sizeof(status)); // We want to accept RC inputs as default status_flags.rc_input_blocked = false; status.rc_input_mode = vehicle_status_s::RC_IN_MODE_DEFAULT; internal_state.main_state = commander_state_s::MAIN_STATE_MANUAL; internal_state.timestamp = hrt_absolute_time(); main_state_prev = commander_state_s::MAIN_STATE_MAX; status.nav_state = vehicle_status_s::NAVIGATION_STATE_MANUAL; status.arming_state = vehicle_status_s::ARMING_STATE_INIT; if (startup_in_hil) { status.hil_state = vehicle_status_s::HIL_STATE_ON; } else { status.hil_state = vehicle_status_s::HIL_STATE_OFF; } status.failsafe = false; /* neither manual nor offboard control commands have been received */ status_flags.offboard_control_signal_found_once = false; status_flags.rc_signal_found_once = false; /* assume we don't have a valid baro on startup */ status_flags.barometer_failure = true; status_flags.ever_had_barometer_data = false; /* mark all signals lost as long as they haven't been found */ status.rc_signal_lost = true; status_flags.offboard_control_signal_lost = true; status.data_link_lost = true; status_flags.offboard_control_loss_timeout = false; status_flags.condition_system_prearm_error_reported = false; status_flags.condition_system_hotplug_timeout = false; status.timestamp = hrt_absolute_time(); status_flags.condition_power_input_valid = true; avionics_power_rail_voltage = -1.0f; status_flags.usb_connected = false; // CIRCUIT BREAKERS status_flags.circuit_breaker_engaged_power_check = false; status_flags.circuit_breaker_engaged_airspd_check = false; status_flags.circuit_breaker_engaged_enginefailure_check = false; status_flags.circuit_breaker_engaged_gpsfailure_check = false; get_circuit_breaker_params(); /* Set position and velocity validty to false */ status_flags.condition_global_position_valid = false; status_flags.condition_global_velocity_valid = false; status_flags.condition_local_position_valid = false; status_flags.condition_local_velocity_valid = false; status_flags.condition_local_altitude_valid = false; // initialize gps failure to false if circuit breaker enabled if (status_flags.circuit_breaker_engaged_gpsfailure_check) { status_flags.gps_failure = false; } else { status_flags.gps_failure = true; } /* publish initial state */ status_pub = orb_advertise(ORB_ID(vehicle_status), &status); if (status_pub == nullptr) { warnx("ERROR: orb_advertise for topic vehicle_status failed (uorb app running?).\n"); warnx("exiting."); px4_task_exit(PX4_ERROR); } /* Initialize armed with all false */ memset(&armed, 0, sizeof(armed)); /* armed topic */ orb_advert_t armed_pub = orb_advertise(ORB_ID(actuator_armed), &armed); /* vehicle control mode topic */ memset(&control_mode, 0, sizeof(control_mode)); orb_advert_t control_mode_pub = orb_advertise(ORB_ID(vehicle_control_mode), &control_mode); /* home position */ orb_advert_t home_pub = nullptr; memset(&_home, 0, sizeof(_home)); /* region of interest */ orb_advert_t roi_pub = nullptr; memset(&_roi, 0, sizeof(_roi)); /* command ack */ orb_advert_t command_ack_pub = nullptr; struct vehicle_command_ack_s command_ack; memset(&command_ack, 0, sizeof(command_ack)); /* init mission state, do it here to allow navigator to use stored mission even if mavlink failed to start */ orb_advert_t mission_pub = nullptr; mission_s mission; orb_advert_t commander_state_pub = nullptr; orb_advert_t vehicle_status_flags_pub = nullptr; if (dm_read(DM_KEY_MISSION_STATE, 0, &mission, sizeof(mission_s)) == sizeof(mission_s)) { if (mission.dataman_id >= 0 && mission.dataman_id <= 1) { if (mission.count > 0) { mavlink_log_info(&mavlink_log_pub, "[cmd] Mission #%d loaded, %u WPs, curr: %d", mission.dataman_id, mission.count, mission.current_seq); } } else { const char *missionfail = "reading mission state failed"; warnx("%s", missionfail); mavlink_log_critical(&mavlink_log_pub, missionfail); /* initialize mission state in dataman */ mission.dataman_id = 0; mission.count = 0; mission.current_seq = 0; dm_write(DM_KEY_MISSION_STATE, 0, DM_PERSIST_POWER_ON_RESET, &mission, sizeof(mission_s)); } mission_pub = orb_advertise(ORB_ID(offboard_mission), &mission); orb_publish(ORB_ID(offboard_mission), mission_pub, &mission); } int ret; /* Start monitoring loop */ unsigned counter = 0; unsigned stick_off_counter = 0; unsigned stick_on_counter = 0; bool low_battery_voltage_actions_done = false; bool critical_battery_voltage_actions_done = false; bool emergency_battery_voltage_actions_done = false; bool status_changed = true; bool param_init_forced = true; bool updated = false; /* Subscribe to safety topic */ int safety_sub = orb_subscribe(ORB_ID(safety)); memset(&safety, 0, sizeof(safety)); safety.safety_switch_available = false; safety.safety_off = false; /* Subscribe to mission result topic */ int mission_result_sub = orb_subscribe(ORB_ID(mission_result)); /* Subscribe to geofence result topic */ int geofence_result_sub = orb_subscribe(ORB_ID(geofence_result)); struct geofence_result_s geofence_result; memset(&geofence_result, 0, sizeof(geofence_result)); /* Subscribe to manual control data */ int sp_man_sub = orb_subscribe(ORB_ID(manual_control_setpoint)); memset(&sp_man, 0, sizeof(sp_man)); /* Subscribe to offboard control data */ int offboard_control_mode_sub = orb_subscribe(ORB_ID(offboard_control_mode)); memset(&offboard_control_mode, 0, sizeof(offboard_control_mode)); /* Subscribe to telemetry status topics */ int telemetry_subs[ORB_MULTI_MAX_INSTANCES]; uint64_t telemetry_last_heartbeat[ORB_MULTI_MAX_INSTANCES]; uint64_t telemetry_last_dl_loss[ORB_MULTI_MAX_INSTANCES]; bool telemetry_preflight_checks_reported[ORB_MULTI_MAX_INSTANCES]; bool telemetry_lost[ORB_MULTI_MAX_INSTANCES]; for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) { telemetry_subs[i] = -1; telemetry_last_heartbeat[i] = 0; telemetry_last_dl_loss[i] = 0; telemetry_lost[i] = true; telemetry_preflight_checks_reported[i] = false; } /* Subscribe to global position */ int global_position_sub = orb_subscribe(ORB_ID(vehicle_global_position)); struct vehicle_global_position_s global_position; memset(&global_position, 0, sizeof(global_position)); /* Init EPH and EPV */ global_position.eph = 1000.0f; global_position.epv = 1000.0f; /* Subscribe to local position data */ int local_position_sub = orb_subscribe(ORB_ID(vehicle_local_position)); struct vehicle_local_position_s local_position = {}; /* Subscribe to attitude data */ int attitude_sub = orb_subscribe(ORB_ID(vehicle_attitude)); struct vehicle_attitude_s attitude = {}; /* Subscribe to land detector */ int land_detector_sub = orb_subscribe(ORB_ID(vehicle_land_detected)); land_detector.landed = true; /* * The home position is set based on GPS only, to prevent a dependency between * position estimator and commander. RAW GPS is more than good enough for a * non-flying vehicle. */ /* Subscribe to GPS topic */ int gps_sub = orb_subscribe(ORB_ID(vehicle_gps_position)); struct vehicle_gps_position_s gps_position; memset(&gps_position, 0, sizeof(gps_position)); gps_position.eph = FLT_MAX; gps_position.epv = FLT_MAX; /* Subscribe to sensor topic */ int sensor_sub = orb_subscribe(ORB_ID(sensor_combined)); struct sensor_combined_s sensors; memset(&sensors, 0, sizeof(sensors)); /* Subscribe to differential pressure topic */ int diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure)); struct differential_pressure_s diff_pres; memset(&diff_pres, 0, sizeof(diff_pres)); /* Subscribe to command topic */ int cmd_sub = orb_subscribe(ORB_ID(vehicle_command)); struct vehicle_command_s cmd; memset(&cmd, 0, sizeof(cmd)); /* Subscribe to parameters changed topic */ int param_changed_sub = orb_subscribe(ORB_ID(parameter_update)); /* Subscribe to battery topic */ int battery_sub = orb_subscribe(ORB_ID(battery_status)); memset(&battery, 0, sizeof(battery)); /* Subscribe to subsystem info topic */ int subsys_sub = orb_subscribe(ORB_ID(subsystem_info)); struct subsystem_info_s info; memset(&info, 0, sizeof(info)); /* Subscribe to position setpoint triplet */ int pos_sp_triplet_sub = orb_subscribe(ORB_ID(position_setpoint_triplet)); struct position_setpoint_triplet_s pos_sp_triplet; memset(&pos_sp_triplet, 0, sizeof(pos_sp_triplet)); /* Subscribe to system power */ int system_power_sub = orb_subscribe(ORB_ID(system_power)); struct system_power_s system_power; memset(&system_power, 0, sizeof(system_power)); /* Subscribe to actuator controls (outputs) */ int actuator_controls_sub = orb_subscribe(ORB_ID_VEHICLE_ATTITUDE_CONTROLS); struct actuator_controls_s actuator_controls; memset(&actuator_controls, 0, sizeof(actuator_controls)); /* Subscribe to vtol vehicle status topic */ int vtol_vehicle_status_sub = orb_subscribe(ORB_ID(vtol_vehicle_status)); //struct vtol_vehicle_status_s vtol_status; memset(&vtol_status, 0, sizeof(vtol_status)); vtol_status.vtol_in_rw_mode = true; //default for vtol is rotary wing int cpuload_sub = orb_subscribe(ORB_ID(cpuload)); memset(&cpuload, 0, sizeof(cpuload)); control_status_leds(&status, &armed, true, &battery, &cpuload); /* now initialized */ commander_initialized = true; thread_running = true; /* update vehicle status to find out vehicle type (required for preflight checks) */ param_get(_param_sys_type, &(status.system_type)); // get system type status.is_rotary_wing = is_rotary_wing(&status) || is_vtol(&status); status.is_vtol = is_vtol(&status); bool checkAirspeed = false; /* Perform airspeed check only if circuit breaker is not * engaged and it's not a rotary wing */ if (!status_flags.circuit_breaker_engaged_airspd_check && (!status.is_rotary_wing || status.is_vtol)) { checkAirspeed = true; } // Run preflight check int32_t rc_in_off = 0; bool hotplug_timeout = hrt_elapsed_time(&commander_boot_timestamp) > HOTPLUG_SENS_TIMEOUT; param_get(_param_autostart_id, &autostart_id); param_get(_param_rc_in_off, &rc_in_off); int32_t arm_switch_is_button = 0; param_get(_param_arm_switch_is_button, &arm_switch_is_button); int32_t arm_without_gps_param = 0; param_get(_param_arm_without_gps, &arm_without_gps_param); arm_without_gps = (arm_without_gps_param == 1); int32_t arm_mission_required_param = 0; param_get(_param_arm_mission_required, &arm_mission_required_param); arm_mission_required = (arm_mission_required_param == 1); status.rc_input_mode = rc_in_off; if (is_hil_setup(autostart_id)) { // HIL configuration selected: real sensors will be disabled status_flags.condition_system_sensors_initialized = false; set_tune_override(TONE_STARTUP_TUNE); //normal boot tune } else { // sensor diagnostics done continuously, not just at boot so don't warn about any issues just yet status_flags.condition_system_sensors_initialized = Commander::preflightCheck(&mavlink_log_pub, true, true, true, true, checkAirspeed, (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), !status_flags.circuit_breaker_engaged_gpsfailure_check, /* checkDynamic */ false, is_vtol(&status), /* reportFailures */ false, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp)); set_tune_override(TONE_STARTUP_TUNE); //normal boot tune } // user adjustable duration required to assert arm/disarm via throttle/rudder stick int32_t rc_arm_hyst = 100; param_get(_param_rc_arm_hyst, &rc_arm_hyst); rc_arm_hyst *= COMMANDER_MONITORING_LOOPSPERMSEC; commander_boot_timestamp = hrt_absolute_time(); transition_result_t arming_ret; int32_t datalink_loss_act = 0; int32_t rc_loss_act = 0; int32_t datalink_loss_timeout = 10; float rc_loss_timeout = 0.5; int32_t datalink_regain_timeout = 0; float offboard_loss_timeout = 0.0f; int32_t offboard_loss_act = 0; int32_t offboard_loss_rc_act = 0; int32_t posctl_nav_loss_act = 0; int32_t geofence_action = 0; /* RC override auto modes */ int32_t rc_override = 0; /* Thresholds for engine failure detection */ int32_t ef_throttle_thres = 1.0f; int32_t ef_current2throttle_thres = 0.0f; int32_t ef_time_thres = 1000.0f; uint64_t timestamp_engine_healthy = 0; /**< absolute time when engine was healty */ int32_t disarm_when_landed = 0; int32_t low_bat_action = 0; /* check which state machines for changes, clear "changed" flag */ bool arming_state_changed = false; bool main_state_changed = false; bool failsafe_old = false; bool have_taken_off_since_arming = false; /* initialize low priority thread */ pthread_attr_t commander_low_prio_attr; pthread_attr_init(&commander_low_prio_attr); pthread_attr_setstacksize(&commander_low_prio_attr, PX4_STACK_ADJUSTED(3000)); #ifndef __PX4_QURT // This is not supported by QURT (yet). struct sched_param param; (void)pthread_attr_getschedparam(&commander_low_prio_attr, &param); /* low priority */ param.sched_priority = SCHED_PRIORITY_DEFAULT - 50; (void)pthread_attr_setschedparam(&commander_low_prio_attr, &param); #endif pthread_create(&commander_low_prio_thread, &commander_low_prio_attr, commander_low_prio_loop, nullptr); pthread_attr_destroy(&commander_low_prio_attr); while (!thread_should_exit) { arming_ret = TRANSITION_NOT_CHANGED; /* update parameters */ orb_check(param_changed_sub, &updated); if (updated || param_init_forced) { /* parameters changed */ struct parameter_update_s param_changed; orb_copy(ORB_ID(parameter_update), param_changed_sub, &param_changed); /* update parameters */ if (!armed.armed) { if (param_get(_param_sys_type, &(status.system_type)) != OK) { warnx("failed getting new system type"); } /* disable manual override for all systems that rely on electronic stabilization */ if (is_rotary_wing(&status) || (is_vtol(&status) && vtol_status.vtol_in_rw_mode)) { status.is_rotary_wing = true; } else { status.is_rotary_wing = false; } /* set vehicle_status.is_vtol flag */ status.is_vtol = is_vtol(&status); /* check and update system / component ID */ param_get(_param_system_id, &(status.system_id)); param_get(_param_component_id, &(status.component_id)); get_circuit_breaker_params(); status_changed = true; } /* Safety parameters */ param_get(_param_enable_datalink_loss, &datalink_loss_act); param_get(_param_enable_rc_loss, &rc_loss_act); param_get(_param_datalink_loss_timeout, &datalink_loss_timeout); param_get(_param_rc_loss_timeout, &rc_loss_timeout); param_get(_param_rc_in_off, &rc_in_off); status.rc_input_mode = rc_in_off; param_get(_param_rc_arm_hyst, &rc_arm_hyst); param_get(_param_min_stick_change, &min_stick_change); param_get(_param_rc_override, &rc_override); // percentage (* 0.01) needs to be doubled because RC total interval is 2, not 1 min_stick_change *= 0.02f; rc_arm_hyst *= COMMANDER_MONITORING_LOOPSPERMSEC; param_get(_param_datalink_regain_timeout, &datalink_regain_timeout); param_get(_param_ef_throttle_thres, &ef_throttle_thres); param_get(_param_ef_current2throttle_thres, &ef_current2throttle_thres); param_get(_param_ef_time_thres, &ef_time_thres); param_get(_param_geofence_action, &geofence_action); param_get(_param_disarm_land, &disarm_when_landed); // If we update parameters the first time // make sure the hysteresis time gets set. // After that it will be set in the main state // machine based on the arming state. if (param_init_forced) { auto_disarm_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)disarm_when_landed * 1000000); } param_get(_param_low_bat_act, &low_bat_action); param_get(_param_offboard_loss_timeout, &offboard_loss_timeout); param_get(_param_offboard_loss_act, &offboard_loss_act); param_get(_param_offboard_loss_rc_act, &offboard_loss_rc_act); param_get(_param_arm_switch_is_button, &arm_switch_is_button); param_get(_param_arm_without_gps, &arm_without_gps_param); arm_without_gps = (arm_without_gps_param == 1); param_get(_param_arm_mission_required, &arm_mission_required_param); arm_mission_required = (arm_mission_required_param == 1); /* Autostart id */ param_get(_param_autostart_id, &autostart_id); /* EPH / EPV */ param_get(_param_eph, &eph_threshold); param_get(_param_epv, &epv_threshold); /* flight mode slots */ param_get(_param_fmode_1, &_flight_mode_slots[0]); param_get(_param_fmode_2, &_flight_mode_slots[1]); param_get(_param_fmode_3, &_flight_mode_slots[2]); param_get(_param_fmode_4, &_flight_mode_slots[3]); param_get(_param_fmode_5, &_flight_mode_slots[4]); param_get(_param_fmode_6, &_flight_mode_slots[5]); /* pre-flight EKF checks */ param_get(_param_max_ekf_pos_ratio, &max_ekf_pos_ratio); param_get(_param_max_ekf_vel_ratio, &max_ekf_vel_ratio); param_get(_param_max_ekf_hgt_ratio, &max_ekf_hgt_ratio); param_get(_param_max_ekf_yaw_ratio, &max_ekf_yaw_ratio); param_get(_param_max_ekf_dvel_bias, &max_ekf_dvel_bias); param_get(_param_max_ekf_dang_bias, &max_ekf_dang_bias); /* pre-flight IMU consistency checks */ param_get(_param_max_imu_acc_diff, &max_imu_acc_diff); param_get(_param_max_imu_gyr_diff, &max_imu_gyr_diff); /* failsafe response to loss of navigation accuracy */ param_get(_param_posctl_nav_loss_act, &posctl_nav_loss_act); param_init_forced = false; } orb_check(sp_man_sub, &updated); if (updated) { orb_copy(ORB_ID(manual_control_setpoint), sp_man_sub, &sp_man); } orb_check(offboard_control_mode_sub, &updated); if (updated) { orb_copy(ORB_ID(offboard_control_mode), offboard_control_mode_sub, &offboard_control_mode); } if (offboard_control_mode.timestamp != 0 && offboard_control_mode.timestamp + OFFBOARD_TIMEOUT > hrt_absolute_time()) { if (status_flags.offboard_control_signal_lost) { status_flags.offboard_control_signal_lost = false; status_flags.offboard_control_loss_timeout = false; status_changed = true; } } else { if (!status_flags.offboard_control_signal_lost) { status_flags.offboard_control_signal_lost = true; status_changed = true; } /* check timer if offboard was there but now lost */ if (!status_flags.offboard_control_loss_timeout && offboard_control_mode.timestamp != 0) { if (offboard_loss_timeout < FLT_EPSILON) { /* execute loss action immediately */ status_flags.offboard_control_loss_timeout = true; } else { /* wait for timeout if set */ status_flags.offboard_control_loss_timeout = offboard_control_mode.timestamp + OFFBOARD_TIMEOUT + offboard_loss_timeout * 1e6f < hrt_absolute_time(); } if (status_flags.offboard_control_loss_timeout) { status_changed = true; } } } for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) { if (telemetry_subs[i] < 0 && (OK == orb_exists(ORB_ID(telemetry_status), i))) { telemetry_subs[i] = orb_subscribe_multi(ORB_ID(telemetry_status), i); } orb_check(telemetry_subs[i], &updated); if (updated) { struct telemetry_status_s telemetry; memset(&telemetry, 0, sizeof(telemetry)); orb_copy(ORB_ID(telemetry_status), telemetry_subs[i], &telemetry); /* perform system checks when new telemetry link connected */ if (/* we first connect a link or re-connect a link after loosing it or haven't yet reported anything */ (telemetry_last_heartbeat[i] == 0 || (hrt_elapsed_time(&telemetry_last_heartbeat[i]) > 3 * 1000 * 1000) || !telemetry_preflight_checks_reported[i]) && /* and this link has a communication partner */ (telemetry.heartbeat_time > 0) && /* and it is still connected */ (hrt_elapsed_time(&telemetry.heartbeat_time) < 2 * 1000 * 1000) && /* and the system is not already armed (and potentially flying) */ !armed.armed) { hotplug_timeout = hrt_elapsed_time(&commander_boot_timestamp) > HOTPLUG_SENS_TIMEOUT; /* flag the checks as reported for this link when we actually report them */ telemetry_preflight_checks_reported[i] = hotplug_timeout; /* provide RC and sensor status feedback to the user */ if (is_hil_setup(autostart_id)) { /* HIL configuration: check only RC input */ (void)Commander::preflightCheck(&mavlink_log_pub, false, false, false, false, false, (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), false, /* checkDynamic */ true, is_vtol(&status), /* reportFailures */ false, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp)); } else { /* check sensors also */ (void)Commander::preflightCheck(&mavlink_log_pub, true, true, true, true, checkAirspeed, (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), !arm_without_gps, /* checkDynamic */ true, is_vtol(&status), /* reportFailures */ hotplug_timeout, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp)); } } /* set (and don't reset) telemetry via USB as active once a MAVLink connection is up */ if (telemetry.type == telemetry_status_s::TELEMETRY_STATUS_RADIO_TYPE_USB) { _usb_telemetry_active = true; } if (telemetry.heartbeat_time > 0) { telemetry_last_heartbeat[i] = telemetry.heartbeat_time; } } } orb_check(sensor_sub, &updated); if (updated) { orb_copy(ORB_ID(sensor_combined), sensor_sub, &sensors); /* Check if the barometer is healthy and issue a warning in the GCS if not so. * Because the barometer is used for calculating AMSL altitude which is used to ensure * vertical separation from other airtraffic the operator has to know when the * barometer is inoperational. * */ hrt_abstime baro_timestamp = sensors.timestamp + sensors.baro_timestamp_relative; if (hrt_elapsed_time(&baro_timestamp) < FAILSAFE_DEFAULT_TIMEOUT) { /* handle the case where baro was regained */ if (status_flags.barometer_failure) { status_flags.barometer_failure = false; status_changed = true; if (status_flags.ever_had_barometer_data) { mavlink_log_critical(&mavlink_log_pub, "baro healthy"); } status_flags.ever_had_barometer_data = true; } } else { if (!status_flags.barometer_failure) { status_flags.barometer_failure = true; status_changed = true; mavlink_log_critical(&mavlink_log_pub, "baro failed"); } } } orb_check(diff_pres_sub, &updated); if (updated) { orb_copy(ORB_ID(differential_pressure), diff_pres_sub, &diff_pres); } orb_check(system_power_sub, &updated); if (updated) { orb_copy(ORB_ID(system_power), system_power_sub, &system_power); if (hrt_elapsed_time(&system_power.timestamp) < 200000) { if (system_power.servo_valid && !system_power.brick_valid && !system_power.usb_connected) { /* flying only on servo rail, this is unsafe */ status_flags.condition_power_input_valid = false; } else { status_flags.condition_power_input_valid = true; } /* copy avionics voltage */ avionics_power_rail_voltage = system_power.voltage5V_v; /* if the USB hardware connection went away, reboot */ if (status_flags.usb_connected && !system_power.usb_connected) { /* * apparently the USB cable went away but we are still powered, * so lets reset to a classic non-usb state. */ mavlink_log_critical(&mavlink_log_pub, "USB disconnected, rebooting.") usleep(400000); px4_shutdown_request(true, false); } /* finally judge the USB connected state based on software detection */ status_flags.usb_connected = _usb_telemetry_active; } } check_valid(diff_pres.timestamp, DIFFPRESS_TIMEOUT, true, &(status_flags.condition_airspeed_valid), &status_changed); /* update safety topic */ orb_check(safety_sub, &updated); if (updated) { bool previous_safety_off = safety.safety_off; orb_copy(ORB_ID(safety), safety_sub, &safety); /* disarm if safety is now on and still armed */ if (status.hil_state == vehicle_status_s::HIL_STATE_OFF && safety.safety_switch_available && !safety.safety_off && armed.armed) { arming_state_t new_arming_state = (status.arming_state == vehicle_status_s::ARMING_STATE_ARMED ? vehicle_status_s::ARMING_STATE_STANDBY : vehicle_status_s::ARMING_STATE_STANDBY_ERROR); if (TRANSITION_CHANGED == arming_state_transition(&status, &battery, &safety, new_arming_state, &armed, true /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp))) { mavlink_log_info(&mavlink_log_pub, "DISARMED by safety switch"); arming_state_changed = true; } } //Notify the user if the status of the safety switch changes if (safety.safety_switch_available && previous_safety_off != safety.safety_off) { if (safety.safety_off) { set_tune(TONE_NOTIFY_POSITIVE_TUNE); } else { tune_neutral(true); } status_changed = true; } } /* update vtol vehicle status*/ orb_check(vtol_vehicle_status_sub, &updated); if (updated) { /* vtol status changed */ orb_copy(ORB_ID(vtol_vehicle_status), vtol_vehicle_status_sub, &vtol_status); status.vtol_fw_permanent_stab = vtol_status.fw_permanent_stab; /* Make sure that this is only adjusted if vehicle really is of type vtol */ if (is_vtol(&status)) { status.is_rotary_wing = vtol_status.vtol_in_rw_mode; status.in_transition_mode = vtol_status.vtol_in_trans_mode; status.in_transition_to_fw = vtol_status.in_transition_to_fw; status_flags.vtol_transition_failure = vtol_status.vtol_transition_failsafe; status_flags.vtol_transition_failure_cmd = vtol_status.vtol_transition_failsafe; armed.soft_stop = !status.is_rotary_wing; } status_changed = true; } // Check if quality checking of position accuracy and consistency is to be performed bool run_quality_checks = !status_flags.circuit_breaker_engaged_posfailure_check; /* update global position estimate and check for timeout */ bool gpos_updated = false; orb_check(global_position_sub, &gpos_updated); if (gpos_updated) { orb_copy(ORB_ID(vehicle_global_position), global_position_sub, &global_position); gpos_last_update_time_us = hrt_absolute_time(); } // Perform a separate timeout validity test on the global position data. // This is necessary because the global position message is by definition valid if published. if ((hrt_absolute_time() - gpos_last_update_time_us) > 1000000) { status_flags.condition_global_position_valid = false; status_flags.condition_global_velocity_valid = false; } /* run global position accuracy checks */ if (gpos_updated) { if (run_quality_checks) { check_posvel_validity(true, global_position.eph, eph_threshold, global_position.timestamp, &last_gpos_fail_time_us, &gpos_probation_time_us, &status_flags.condition_global_position_valid, &status_changed); check_posvel_validity(true, global_position.evh, evh_threshold, global_position.timestamp, &last_gvel_fail_time_us, &gvel_probation_time_us, &status_flags.condition_global_velocity_valid, &status_changed); } } /* update local position estimate */ bool lpos_updated = false; orb_check(local_position_sub, &lpos_updated); if (lpos_updated) { /* position changed */ orb_copy(ORB_ID(vehicle_local_position), local_position_sub, &local_position); if (run_quality_checks) { check_posvel_validity(local_position.xy_valid, local_position.eph, eph_threshold, local_position.timestamp, &last_lpos_fail_time_us, &lpos_probation_time_us, &status_flags.condition_local_position_valid, &status_changed); check_posvel_validity(local_position.v_xy_valid, local_position.evh, evh_threshold, local_position.timestamp, &last_lvel_fail_time_us, &lvel_probation_time_us, &status_flags.condition_local_velocity_valid, &status_changed); } } /* update attitude estimate */ orb_check(attitude_sub, &updated); if (updated) { /* attitude changed */ orb_copy(ORB_ID(vehicle_attitude), attitude_sub, &attitude); } /* update condition_local_altitude_valid */ check_valid(local_position.timestamp, POSITION_TIMEOUT, local_position.z_valid, &(status_flags.condition_local_altitude_valid), &status_changed); /* Update land detector */ orb_check(land_detector_sub, &updated); if (updated) { orb_copy(ORB_ID(vehicle_land_detected), land_detector_sub, &land_detector); if (was_landed != land_detector.landed) { if (land_detector.landed) { mavlink_and_console_log_info(&mavlink_log_pub, "Landing detected"); } else { mavlink_and_console_log_info(&mavlink_log_pub, "Takeoff detected"); have_taken_off_since_arming = true; // Set all position and velocity test probation durations to takeoff value // This is a larger value to give the vehicle time to complete a failsafe landing // if faulty sensors cause loss of navigation shortly after takeoff. gpos_probation_time_us = POSVEL_PROBATION_TAKEOFF; gvel_probation_time_us = POSVEL_PROBATION_TAKEOFF; lpos_probation_time_us = POSVEL_PROBATION_TAKEOFF; lvel_probation_time_us = POSVEL_PROBATION_TAKEOFF; } } if (was_falling != land_detector.freefall) { if (land_detector.freefall) { mavlink_and_console_log_info(&mavlink_log_pub, "Freefall detected"); } } was_landed = land_detector.landed; was_falling = land_detector.freefall; } /* Update hysteresis time. Use a time of factor 5 longer if we have not taken off yet. */ hrt_abstime timeout_time = disarm_when_landed * 1000000; if (!have_taken_off_since_arming) { timeout_time *= 5; } auto_disarm_hysteresis.set_hysteresis_time_from(false, timeout_time); // Check for auto-disarm if (armed.armed && land_detector.landed && disarm_when_landed > 0) { auto_disarm_hysteresis.set_state_and_update(true); } else { auto_disarm_hysteresis.set_state_and_update(false); } if (auto_disarm_hysteresis.get_state()) { arm_disarm(false, &mavlink_log_pub, "auto disarm on land"); } if (!warning_action_on) { // store the last good main_state when not in an navigation // hold state main_state_before_rtl = internal_state.main_state; } else if (internal_state.main_state != commander_state_s::MAIN_STATE_AUTO_RTL && internal_state.main_state != commander_state_s::MAIN_STATE_AUTO_LOITER && internal_state.main_state != commander_state_s::MAIN_STATE_AUTO_LAND) { // reset flag again when we switched out of it warning_action_on = false; } orb_check(cpuload_sub, &updated); if (updated) { orb_copy(ORB_ID(cpuload), cpuload_sub, &cpuload); } /* update battery status */ orb_check(battery_sub, &updated); if (updated) { orb_copy(ORB_ID(battery_status), battery_sub, &battery); /* only consider battery voltage if system has been running 6s (usb most likely detected) and battery voltage is valid */ if (hrt_absolute_time() > commander_boot_timestamp + 6000000 && battery.voltage_filtered_v > 2.0f * FLT_EPSILON) { /* if battery voltage is getting lower, warn using buzzer, etc. */ if (battery.warning == battery_status_s::BATTERY_WARNING_LOW && !low_battery_voltage_actions_done) { low_battery_voltage_actions_done = true; if (armed.armed) { mavlink_log_critical(&mavlink_log_pub, "LOW BATTERY, RETURN TO LAND ADVISED"); } else { mavlink_log_critical(&mavlink_log_pub, "LOW BATTERY, TAKEOFF DISCOURAGED"); } status_changed = true; } else if (!status_flags.usb_connected && battery.warning == battery_status_s::BATTERY_WARNING_CRITICAL && !critical_battery_voltage_actions_done) { critical_battery_voltage_actions_done = true; if (!armed.armed) { mavlink_log_critical(&mavlink_log_pub, "CRITICAL BATTERY, SHUT SYSTEM DOWN"); } else { if (low_bat_action == 1 || low_bat_action == 3) { // let us send the critical message even if already in RTL if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state)) { warning_action_on = true; mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RETURNING TO LAND"); } else { mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RTL FAILED"); } } else if (low_bat_action == 2) { if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LAND, main_state_prev, &status_flags, &internal_state)) { warning_action_on = true; mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING AT CURRENT POSITION"); } else { mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, LANDING FAILED"); } } else { mavlink_log_emergency(&mavlink_log_pub, "CRITICAL BATTERY, RETURN TO LAUNCH ADVISED!"); } } status_changed = true; } else if (!status_flags.usb_connected && battery.warning == battery_status_s::BATTERY_WARNING_EMERGENCY && !emergency_battery_voltage_actions_done) { emergency_battery_voltage_actions_done = true; if (!armed.armed) { mavlink_log_critical(&mavlink_log_pub, "DANGEROUSLY LOW BATTERY, SHUT SYSTEM DOWN"); usleep(200000); int ret_val = px4_shutdown_request(false, false); if (ret_val) { mavlink_log_critical(&mavlink_log_pub, "SYSTEM DOES NOT SUPPORT SHUTDOWN"); } else { while(1) { usleep(1); } } } else { if (low_bat_action == 2 || low_bat_action == 3) { if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LAND, main_state_prev, &status_flags, &internal_state)) { warning_action_on = true; mavlink_log_emergency(&mavlink_log_pub, "DANGEROUS BATTERY LEVEL, LANDING IMMEDIATELY"); } else { mavlink_log_emergency(&mavlink_log_pub, "DANGEROUS BATTERY LEVEL, LANDING FAILED"); } } else { mavlink_log_emergency(&mavlink_log_pub, "DANGEROUS BATTERY LEVEL, LANDING ADVISED!"); } } status_changed = true; } /* End battery voltage check */ } } /* update subsystem */ orb_check(subsys_sub, &updated); if (updated) { orb_copy(ORB_ID(subsystem_info), subsys_sub, &info); //warnx("subsystem changed: %d\n", (int)info.subsystem_type); /* mark / unmark as present */ if (info.present) { status.onboard_control_sensors_present |= info.subsystem_type; } else { status.onboard_control_sensors_present &= ~info.subsystem_type; } /* mark / unmark as enabled */ if (info.enabled) { status.onboard_control_sensors_enabled |= info.subsystem_type; } else { status.onboard_control_sensors_enabled &= ~info.subsystem_type; } /* mark / unmark as ok */ if (info.ok) { status.onboard_control_sensors_health |= info.subsystem_type; } else { status.onboard_control_sensors_health &= ~info.subsystem_type; } status_changed = true; } /* update position setpoint triplet */ orb_check(pos_sp_triplet_sub, &updated); if (updated) { orb_copy(ORB_ID(position_setpoint_triplet), pos_sp_triplet_sub, &pos_sp_triplet); } /* If in INIT state, try to proceed to STANDBY state */ if (!status_flags.condition_calibration_enabled && status.arming_state == vehicle_status_s::ARMING_STATE_INIT) { arming_ret = arming_state_transition(&status, &battery, &safety, vehicle_status_s::ARMING_STATE_STANDBY, &armed, true /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); if (arming_ret == TRANSITION_CHANGED) { arming_state_changed = true; } else if (arming_ret == TRANSITION_DENIED) { /* do not complain if not allowed into standby */ arming_ret = TRANSITION_NOT_CHANGED; } } /* * Check GPS fix quality. Note that this check augments the position validity * checks and adds an additional level of protection. */ orb_check(gps_sub, &updated); if (updated) { orb_copy(ORB_ID(vehicle_gps_position), gps_sub, &gps_position); } /* Initialize map projection if gps is valid */ if (!map_projection_global_initialized() && (gps_position.eph < eph_threshold) && (gps_position.epv < epv_threshold) && hrt_elapsed_time((hrt_abstime *)&gps_position.timestamp) < 1e6) { /* set reference for global coordinates <--> local coordiantes conversion and map_projection */ globallocalconverter_init((double)gps_position.lat * 1.0e-7, (double)gps_position.lon * 1.0e-7, (float)gps_position.alt * 1.0e-3f, hrt_absolute_time()); } /* check if GPS is ok */ if (!status_flags.circuit_breaker_engaged_gpsfailure_check) { bool gpsIsNoisy = gps_position.noise_per_ms > 0 && gps_position.noise_per_ms < COMMANDER_MAX_GPS_NOISE; //Check if GPS receiver is too noisy while we are disarmed if (!armed.armed && gpsIsNoisy) { if (!status_flags.gps_failure) { mavlink_log_critical(&mavlink_log_pub, "GPS signal noisy"); set_tune_override(TONE_GPS_WARNING_TUNE); //GPS suffers from signal jamming or excessive noise, disable GPS-aided flight status_flags.gps_failure = true; status_changed = true; } } // Check fix type and data freshness if (gps_position.fix_type >= 3 && hrt_elapsed_time(&gps_position.timestamp) < FAILSAFE_DEFAULT_TIMEOUT) { /* handle the case where gps was regained */ if (status_flags.gps_failure && !gpsIsNoisy) { status_flags.gps_failure = false; status_changed = true; if (status_flags.condition_home_position_valid) { mavlink_log_critical(&mavlink_log_pub, "GPS fix regained"); } } } else if (!status_flags.gps_failure) { status_flags.gps_failure = true; status_changed = true; if (status.arming_state == vehicle_status_s::ARMING_STATE_ARMED) { mavlink_log_critical(&mavlink_log_pub, "GPS fix lost"); } } } /* start mission result check */ orb_check(mission_result_sub, &updated); if (updated) { orb_copy(ORB_ID(mission_result), mission_result_sub, &_mission_result); status_flags.condition_auto_mission_available = _mission_result.valid && !_mission_result.finished; if (status.mission_failure != _mission_result.failure) { status.mission_failure = _mission_result.failure; status_changed = true; if (status.mission_failure) { mavlink_log_critical(&mavlink_log_pub, "mission cannot be completed"); } } } /* start geofence result check */ orb_check(geofence_result_sub, &updated); if (updated) { orb_copy(ORB_ID(geofence_result), geofence_result_sub, &geofence_result); } // Geofence actions if (armed.armed && (geofence_result.geofence_action != geofence_result_s::GF_ACTION_NONE)) { static bool geofence_loiter_on = false; static bool geofence_rtl_on = false; // check for geofence violation if (geofence_result.geofence_violated) { static hrt_abstime last_geofence_violation = 0; const hrt_abstime geofence_violation_action_interval = 10000000; // 10 seconds if (hrt_elapsed_time(&last_geofence_violation) > geofence_violation_action_interval) { last_geofence_violation = hrt_absolute_time(); switch (geofence_result.geofence_action) { case (geofence_result_s::GF_ACTION_NONE) : { // do nothing break; } case (geofence_result_s::GF_ACTION_WARN) : { // do nothing, mavlink critical messages are sent by navigator break; } case (geofence_result_s::GF_ACTION_LOITER) : { if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state)) { geofence_loiter_on = true; } break; } case (geofence_result_s::GF_ACTION_RTL) : { if (TRANSITION_CHANGED == main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state)) { geofence_rtl_on = true; } break; } case (geofence_result_s::GF_ACTION_TERMINATE) : { warnx("Flight termination because of geofence"); mavlink_log_critical(&mavlink_log_pub, "Geofence violation: flight termination"); armed.force_failsafe = true; status_changed = true; break; } } } } // reset if no longer in LOITER or if manually switched to LOITER geofence_loiter_on = geofence_loiter_on && (internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_LOITER) && (sp_man.loiter_switch == manual_control_setpoint_s::SWITCH_POS_OFF || sp_man.loiter_switch == manual_control_setpoint_s::SWITCH_POS_NONE); // reset if no longer in RTL or if manually switched to RTL geofence_rtl_on = geofence_rtl_on && (internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_RTL) && (sp_man.return_switch == manual_control_setpoint_s::SWITCH_POS_OFF || sp_man.return_switch == manual_control_setpoint_s::SWITCH_POS_NONE); warning_action_on = warning_action_on || (geofence_loiter_on || geofence_rtl_on); } // revert geofence failsafe transition if sticks are moved and we were previously in a manual mode // but only if not in a low battery handling action if (rc_override != 0 && !critical_battery_voltage_actions_done && (warning_action_on && (main_state_before_rtl == commander_state_s::MAIN_STATE_MANUAL || main_state_before_rtl == commander_state_s::MAIN_STATE_ALTCTL || main_state_before_rtl == commander_state_s::MAIN_STATE_POSCTL || main_state_before_rtl == commander_state_s::MAIN_STATE_ACRO || main_state_before_rtl == commander_state_s::MAIN_STATE_RATTITUDE || main_state_before_rtl == commander_state_s::MAIN_STATE_STAB))) { // transition to previous state if sticks are touched if ((_last_sp_man.timestamp != sp_man.timestamp) && ((fabsf(sp_man.x - _last_sp_man.x) > min_stick_change) || (fabsf(sp_man.y - _last_sp_man.y) > min_stick_change) || (fabsf(sp_man.z - _last_sp_man.z) > min_stick_change) || (fabsf(sp_man.r - _last_sp_man.r) > min_stick_change))) { // revert to position control in any case main_state_transition(&status, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); mavlink_log_critical(&mavlink_log_pub, "Autopilot off, returned control to pilot"); } } // abort landing or auto or loiter if sticks are moved significantly // but only if not in a low battery handling action if (rc_override != 0 && !critical_battery_voltage_actions_done && (internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_LAND || internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_MISSION || internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_LOITER)) { // transition to previous state if sticks are touched if ((_last_sp_man.timestamp != sp_man.timestamp) && ((fabsf(sp_man.x - _last_sp_man.x) > min_stick_change) || (fabsf(sp_man.y - _last_sp_man.y) > min_stick_change) || (fabsf(sp_man.z - _last_sp_man.z) > min_stick_change) || (fabsf(sp_man.r - _last_sp_man.r) > min_stick_change))) { // revert to position control in any case main_state_transition(&status, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); mavlink_log_critical(&mavlink_log_pub, "Autopilot off, returned control to pilot"); } } /* Check for mission flight termination */ if (armed.armed && _mission_result.flight_termination && !status_flags.circuit_breaker_flight_termination_disabled) { armed.force_failsafe = true; status_changed = true; static bool flight_termination_printed = false; if (!flight_termination_printed) { mavlink_log_critical(&mavlink_log_pub, "Geofence violation: flight termination"); flight_termination_printed = true; } if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) { mavlink_log_critical(&mavlink_log_pub, "Flight termination active"); } } /* Only evaluate mission state if home is set, * this prevents false positives for the mission * rejection. Back off 2 seconds to not overlay * home tune. */ if (status_flags.condition_home_position_valid && (hrt_elapsed_time(&_home.timestamp) > 2000000) && _last_mission_instance != _mission_result.instance_count) { if (!_mission_result.valid) { /* the mission is invalid */ tune_mission_fail(true); warnx("mission fail"); } else if (_mission_result.warning) { /* the mission has a warning */ tune_mission_fail(true); warnx("mission warning"); } else { /* the mission is valid */ tune_mission_ok(true); } /* prevent further feedback until the mission changes */ _last_mission_instance = _mission_result.instance_count; } /* RC input check */ if (!status_flags.rc_input_blocked && sp_man.timestamp != 0 && (hrt_absolute_time() < sp_man.timestamp + (uint64_t)(rc_loss_timeout * 1e6f))) { /* handle the case where RC signal was regained */ if (!status_flags.rc_signal_found_once) { status_flags.rc_signal_found_once = true; status_changed = true; } else { if (status.rc_signal_lost) { mavlink_log_info(&mavlink_log_pub, "MANUAL CONTROL REGAINED after %llums", (hrt_absolute_time() - rc_signal_lost_timestamp) / 1000); status_changed = true; } } status.rc_signal_lost = false; const bool in_armed_state = status.arming_state == vehicle_status_s::ARMING_STATE_ARMED || status.arming_state == vehicle_status_s::ARMING_STATE_ARMED_ERROR; const bool arm_button_pressed = arm_switch_is_button == 1 && sp_man.arm_switch == manual_control_setpoint_s::SWITCH_POS_ON; /* DISARM * check if left stick is in lower left position or arm button is pushed or arm switch has transition from arm to disarm * and we are in MANUAL, Rattitude, or AUTO_READY mode or (ASSIST mode and landed) * do it only for rotary wings in manual mode or fixed wing if landed */ const bool stick_in_lower_left = sp_man.r < -STICK_ON_OFF_LIMIT && sp_man.z < 0.1f; const bool arm_switch_to_disarm_transition = arm_switch_is_button == 0 && _last_sp_man_arm_switch == manual_control_setpoint_s::SWITCH_POS_ON && sp_man.arm_switch == manual_control_setpoint_s::SWITCH_POS_OFF; if (in_armed_state && status.rc_input_mode != vehicle_status_s::RC_IN_MODE_OFF && (status.is_rotary_wing || (!status.is_rotary_wing && land_detector.landed)) && (stick_in_lower_left || arm_button_pressed || arm_switch_to_disarm_transition) ) { if (internal_state.main_state != commander_state_s::MAIN_STATE_MANUAL && internal_state.main_state != commander_state_s::MAIN_STATE_ACRO && internal_state.main_state != commander_state_s::MAIN_STATE_STAB && internal_state.main_state != commander_state_s::MAIN_STATE_RATTITUDE && !land_detector.landed) { print_reject_arm("NOT DISARMING: Not in manual mode or landed yet."); } else if ((stick_off_counter == rc_arm_hyst && stick_on_counter < rc_arm_hyst) || arm_switch_to_disarm_transition) { /* disarm to STANDBY if ARMED or to STANDBY_ERROR if ARMED_ERROR */ arming_state_t new_arming_state = (status.arming_state == vehicle_status_s::ARMING_STATE_ARMED ? vehicle_status_s::ARMING_STATE_STANDBY : vehicle_status_s::ARMING_STATE_STANDBY_ERROR); arming_ret = arming_state_transition(&status, &battery, &safety, new_arming_state, &armed, true /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); if (arming_ret == TRANSITION_CHANGED) { arming_state_changed = true; } } stick_off_counter++; /* do not reset the counter when holding the arm button longer than needed */ } else if (!(arm_switch_is_button == 1 && sp_man.arm_switch == manual_control_setpoint_s::SWITCH_POS_ON)) { stick_off_counter = 0; } /* ARM * check if left stick is in lower right position or arm button is pushed or arm switch has transition from disarm to arm * and we're in MANUAL mode */ const bool stick_in_lower_right = (sp_man.r > STICK_ON_OFF_LIMIT && sp_man.z < 0.1f); const bool arm_switch_to_arm_transition = arm_switch_is_button == 0 && _last_sp_man_arm_switch == manual_control_setpoint_s::SWITCH_POS_OFF && sp_man.arm_switch == manual_control_setpoint_s::SWITCH_POS_ON; if (!in_armed_state && status.rc_input_mode != vehicle_status_s::RC_IN_MODE_OFF && (stick_in_lower_right || arm_button_pressed || arm_switch_to_arm_transition) ) { if ((stick_on_counter == rc_arm_hyst && stick_off_counter < rc_arm_hyst) || arm_switch_to_arm_transition) { /* we check outside of the transition function here because the requirement * for being in manual mode only applies to manual arming actions. * the system can be armed in auto if armed via the GCS. */ if ((internal_state.main_state != commander_state_s::MAIN_STATE_MANUAL) && (internal_state.main_state != commander_state_s::MAIN_STATE_ACRO) && (internal_state.main_state != commander_state_s::MAIN_STATE_STAB) && (internal_state.main_state != commander_state_s::MAIN_STATE_ALTCTL) && (internal_state.main_state != commander_state_s::MAIN_STATE_POSCTL) && (internal_state.main_state != commander_state_s::MAIN_STATE_RATTITUDE) ) { print_reject_arm("NOT ARMING: Switch to a manual mode first."); } else if (!status_flags.condition_home_position_valid && geofence_action == geofence_result_s::GF_ACTION_RTL) { print_reject_arm("NOT ARMING: Geofence RTL requires valid home"); } else if (status.arming_state == vehicle_status_s::ARMING_STATE_STANDBY) { arming_ret = arming_state_transition(&status, &battery, &safety, vehicle_status_s::ARMING_STATE_ARMED, &armed, true /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); if (arming_ret == TRANSITION_CHANGED) { arming_state_changed = true; } else { usleep(100000); print_reject_arm("NOT ARMING: Preflight checks failed"); } } } stick_on_counter++; /* do not reset the counter when holding the arm button longer than needed */ } else if (!(arm_switch_is_button == 1 && sp_man.arm_switch == manual_control_setpoint_s::SWITCH_POS_ON)) { stick_on_counter = 0; } _last_sp_man_arm_switch = sp_man.arm_switch; if (arming_ret == TRANSITION_CHANGED) { if (status.arming_state == vehicle_status_s::ARMING_STATE_ARMED) { mavlink_log_info(&mavlink_log_pub, "ARMED by RC"); } else { mavlink_log_info(&mavlink_log_pub, "DISARMED by RC"); } arming_state_changed = true; } else if (arming_ret == TRANSITION_DENIED) { /* * the arming transition can be denied to a number of reasons: * - pre-flight check failed (sensors not ok or not calibrated) * - safety not disabled * - system not in manual mode */ tune_negative(true); } /* evaluate the main state machine according to mode switches */ bool first_rc_eval = (_last_sp_man.timestamp == 0) && (sp_man.timestamp > 0); transition_result_t main_res = set_main_state_rc(&status, &global_position, &local_position, &status_changed); /* store last position lock state */ _last_condition_global_position_valid = status_flags.condition_global_position_valid; /* play tune on mode change only if armed, blink LED always */ if (main_res == TRANSITION_CHANGED || first_rc_eval) { tune_positive(armed.armed); main_state_changed = true; } else if (main_res == TRANSITION_DENIED) { /* DENIED here indicates bug in the commander */ mavlink_log_critical(&mavlink_log_pub, "main state transition denied"); } /* check throttle kill switch */ if (sp_man.kill_switch == manual_control_setpoint_s::SWITCH_POS_ON) { /* set lockdown flag */ if (!armed.manual_lockdown) { mavlink_log_emergency(&mavlink_log_pub, "MANUAL KILL SWITCH ENGAGED"); } armed.manual_lockdown = true; } else if (sp_man.kill_switch == manual_control_setpoint_s::SWITCH_POS_OFF) { if (armed.manual_lockdown) { mavlink_log_emergency(&mavlink_log_pub, "MANUAL KILL SWITCH OFF"); } armed.manual_lockdown = false; } /* no else case: do not change lockdown flag in unconfigured case */ } else { if (!status_flags.rc_input_blocked && !status.rc_signal_lost) { mavlink_log_critical(&mavlink_log_pub, "MANUAL CONTROL LOST (at t=%llums)", hrt_absolute_time() / 1000); status.rc_signal_lost = true; rc_signal_lost_timestamp = sp_man.timestamp; status_changed = true; } } /* data links check */ bool have_link = false; for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) { if (telemetry_last_heartbeat[i] != 0 && hrt_elapsed_time(&telemetry_last_heartbeat[i]) < datalink_loss_timeout * 1e6) { /* handle the case where data link was gained first time or regained, * accept datalink as healthy only after datalink_regain_timeout seconds * */ if (telemetry_lost[i] && hrt_elapsed_time(&telemetry_last_dl_loss[i]) > datalink_regain_timeout * 1e6) { /* report a regain */ if (telemetry_last_dl_loss[i] > 0) { mavlink_and_console_log_info(&mavlink_log_pub, "data link #%i regained", i); } else if (telemetry_last_dl_loss[i] == 0) { /* new link */ } /* got link again or new */ status_flags.condition_system_prearm_error_reported = false; status_changed = true; telemetry_lost[i] = false; have_link = true; } else if (!telemetry_lost[i]) { /* telemetry was healthy also in last iteration * we don't have to check a timeout */ have_link = true; } } else { if (!telemetry_lost[i]) { /* only reset the timestamp to a different time on state change */ telemetry_last_dl_loss[i] = hrt_absolute_time(); mavlink_and_console_log_info(&mavlink_log_pub, "data link #%i lost", i); telemetry_lost[i] = true; } } } if (have_link) { /* handle the case where data link was regained */ if (status.data_link_lost) { status.data_link_lost = false; status_changed = true; } } else { if (!status.data_link_lost) { if (armed.armed) { mavlink_log_critical(&mavlink_log_pub, "ALL DATA LINKS LOST"); } status.data_link_lost = true; status.data_link_lost_counter++; status_changed = true; } } /* handle commands last, as the system needs to be updated to handle them */ orb_check(actuator_controls_sub, &updated); if (updated) { /* got command */ orb_copy(ORB_ID_VEHICLE_ATTITUDE_CONTROLS, actuator_controls_sub, &actuator_controls); /* Check engine failure * only for fixed wing for now */ if (!status_flags.circuit_breaker_engaged_enginefailure_check && status.is_rotary_wing == false && armed.armed && ((actuator_controls.control[3] > ef_throttle_thres && battery.current_a / actuator_controls.control[3] < ef_current2throttle_thres) || (status.engine_failure))) { /* potential failure, measure time */ if (timestamp_engine_healthy > 0 && hrt_elapsed_time(&timestamp_engine_healthy) > ef_time_thres * 1e6 && !status.engine_failure) { status.engine_failure = true; status_changed = true; mavlink_log_critical(&mavlink_log_pub, "Engine Failure"); } } else { /* no failure reset flag */ timestamp_engine_healthy = hrt_absolute_time(); if (status.engine_failure) { status.engine_failure = false; status_changed = true; } } } /* reset main state after takeoff has completed */ /* only switch back to posctl */ if (main_state_prev == commander_state_s::MAIN_STATE_POSCTL) { if (internal_state.main_state == commander_state_s::MAIN_STATE_AUTO_TAKEOFF && _mission_result.finished) { main_state_transition(&status, main_state_prev, main_state_prev, &status_flags, &internal_state); } } /* check if we are disarmed and there is a better mode to wait in */ if (!armed.armed) { /* if there is no radio control but GPS lock the user might want to fly using * just a tablet. Since the RC will force its mode switch setting on connecting * we can as well just wait in a hold mode which enables tablet control. */ if (status.rc_signal_lost && (internal_state.main_state == commander_state_s::MAIN_STATE_MANUAL) && status_flags.condition_home_position_valid) { (void)main_state_transition(&status, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); } } /* handle commands last, as the system needs to be updated to handle them */ orb_check(cmd_sub, &updated); if (updated) { /* got command */ orb_copy(ORB_ID(vehicle_command), cmd_sub, &cmd); /* handle it */ if (handle_command(&status, &safety, &cmd, &armed, &_home, &global_position, &local_position, &attitude, &home_pub, &command_ack_pub, &command_ack, &_roi, &roi_pub, &status_changed)) { status_changed = true; } } /* Check for failure combinations which lead to flight termination */ if (armed.armed && !status_flags.circuit_breaker_flight_termination_disabled) { /* At this point the data link and the gps system have been checked * If we are not in a manual (RC stick controlled mode) * and both failed we want to terminate the flight */ if (internal_state.main_state != commander_state_s::MAIN_STATE_MANUAL && internal_state.main_state != commander_state_s::MAIN_STATE_ACRO && internal_state.main_state != commander_state_s::MAIN_STATE_RATTITUDE && internal_state.main_state != commander_state_s::MAIN_STATE_STAB && internal_state.main_state != commander_state_s::MAIN_STATE_ALTCTL && internal_state.main_state != commander_state_s::MAIN_STATE_POSCTL && ((status.data_link_lost && status_flags.gps_failure) || (status_flags.data_link_lost_cmd && status_flags.gps_failure_cmd))) { armed.force_failsafe = true; status_changed = true; static bool flight_termination_printed = false; if (!flight_termination_printed) { mavlink_log_critical(&mavlink_log_pub, "DL and GPS lost: flight termination"); flight_termination_printed = true; } if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) { mavlink_log_critical(&mavlink_log_pub, "DL and GPS lost: flight termination"); } } /* At this point the rc signal and the gps system have been checked * If we are in manual (controlled with RC): * if both failed we want to terminate the flight */ if ((internal_state.main_state == commander_state_s::MAIN_STATE_ACRO || internal_state.main_state == commander_state_s::MAIN_STATE_RATTITUDE || internal_state.main_state == commander_state_s::MAIN_STATE_MANUAL || internal_state.main_state == commander_state_s::MAIN_STATE_STAB || internal_state.main_state == commander_state_s::MAIN_STATE_ALTCTL || internal_state.main_state == commander_state_s::MAIN_STATE_POSCTL) && ((status.rc_signal_lost && status_flags.gps_failure) || (status_flags.rc_signal_lost_cmd && status_flags.gps_failure_cmd))) { armed.force_failsafe = true; status_changed = true; static bool flight_termination_printed = false; if (!flight_termination_printed) { warnx("Flight termination because of RC signal loss and GPS failure"); flight_termination_printed = true; } if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) { mavlink_log_critical(&mavlink_log_pub, "RC and GPS lost: flight termination"); } } } /* Get current timestamp */ const hrt_abstime now = hrt_absolute_time(); /* First time home position update - but only if disarmed */ if (!status_flags.condition_home_position_valid && !armed.armed) { commander_set_home_position(home_pub, _home, local_position, global_position, attitude); } /* update home position on arming if at least 500 ms from commander start spent to avoid setting home on in-air restart */ else if (((!was_armed && armed.armed) || (was_landed && !land_detector.landed)) && (now > commander_boot_timestamp + INAIR_RESTART_HOLDOFF_INTERVAL)) { commander_set_home_position(home_pub, _home, local_position, global_position, attitude); } was_armed = armed.armed; /* print new state */ if (arming_state_changed) { status_changed = true; arming_state_changed = false; } /* now set navigation state according to failsafe and main state */ bool nav_state_changed = set_nav_state(&status, &armed, &internal_state, &mavlink_log_pub, (link_loss_actions_t)datalink_loss_act, _mission_result.finished, _mission_result.stay_in_failsafe, &status_flags, land_detector.landed, (link_loss_actions_t)rc_loss_act, offboard_loss_act, offboard_loss_rc_act, posctl_nav_loss_act); if (status.failsafe != failsafe_old) { status_changed = true; if (status.failsafe) { mavlink_log_info(&mavlink_log_pub, "Failsafe mode enabled"); } else { mavlink_log_info(&mavlink_log_pub, "Failsafe mode disabled"); } failsafe_old = status.failsafe; } // TODO handle mode changes by commands if (main_state_changed || nav_state_changed) { status_changed = true; main_state_changed = false; } /* publish states (armed, control mode, vehicle status) at least with 5 Hz */ if (counter % (200000 / COMMANDER_MONITORING_INTERVAL) == 0 || status_changed) { set_control_mode(); control_mode.timestamp = now; orb_publish(ORB_ID(vehicle_control_mode), control_mode_pub, &control_mode); status.timestamp = now; orb_publish(ORB_ID(vehicle_status), status_pub, &status); armed.timestamp = now; /* set prearmed state if safety is off, or safety is not present and 5 seconds passed */ if (safety.safety_switch_available) { /* safety is off, go into prearmed */ armed.prearmed = safety.safety_off; } else { /* safety is not present, go into prearmed * (all output drivers should be started / unlocked last in the boot process * when the rest of the system is fully initialized) */ armed.prearmed = (hrt_elapsed_time(&commander_boot_timestamp) > 5 * 1000 * 1000); } orb_publish(ORB_ID(actuator_armed), armed_pub, &armed); } /* play arming and battery warning tunes */ if (!arm_tune_played && armed.armed && (!safety.safety_switch_available || (safety.safety_switch_available && safety.safety_off))) { /* play tune when armed */ set_tune(TONE_ARMING_WARNING_TUNE); arm_tune_played = true; } else if (!status_flags.usb_connected && (status.hil_state != vehicle_status_s::HIL_STATE_ON) && (battery.warning == battery_status_s::BATTERY_WARNING_CRITICAL)) { /* play tune on battery critical */ set_tune(TONE_BATTERY_WARNING_FAST_TUNE); } else if ((status.hil_state != vehicle_status_s::HIL_STATE_ON) && (battery.warning == battery_status_s::BATTERY_WARNING_LOW)) { /* play tune on battery warning */ set_tune(TONE_BATTERY_WARNING_SLOW_TUNE); } else if (status.failsafe) { tune_failsafe(true); } else { set_tune(TONE_STOP_TUNE); } /* reset arm_tune_played when disarmed */ if (!armed.armed || (safety.safety_switch_available && !safety.safety_off)) { //Notify the user that it is safe to approach the vehicle if (arm_tune_played) { tune_neutral(true); } arm_tune_played = false; } /* play sensor failure tunes if we already waited for hotplug sensors to come up and failed */ hotplug_timeout = hrt_elapsed_time(&commander_boot_timestamp) > HOTPLUG_SENS_TIMEOUT; if (!sensor_fail_tune_played && (!status_flags.condition_system_sensors_initialized && hotplug_timeout)) { set_tune_override(TONE_GPS_WARNING_TUNE); sensor_fail_tune_played = true; status_changed = true; } /* update timeout flag */ if(!(hotplug_timeout == status_flags.condition_system_hotplug_timeout)) { status_flags.condition_system_hotplug_timeout = hotplug_timeout; status_changed = true; } counter++; int blink_state = blink_msg_state(); if (blink_state > 0) { /* blinking LED message, don't touch LEDs */ if (blink_state == 2) { /* blinking LED message completed, restore normal state */ control_status_leds(&status, &armed, true, &battery, &cpuload); } } else { /* normal state */ control_status_leds(&status, &armed, status_changed, &battery, &cpuload); } status_changed = false; if (!armed.armed) { /* Reset the flag if disarmed. */ have_taken_off_since_arming = false; } /* publish vehicle_status_flags */ publish_status_flags(vehicle_status_flags_pub); /* publish internal state for logging purposes */ if (commander_state_pub != nullptr) { orb_publish(ORB_ID(commander_state), commander_state_pub, &internal_state); } else { commander_state_pub = orb_advertise(ORB_ID(commander_state), &internal_state); } usleep(COMMANDER_MONITORING_INTERVAL); } /* wait for threads to complete */ ret = pthread_join(commander_low_prio_thread, nullptr); if (ret) { warn("join failed: %d", ret); } rgbled_set_color_and_mode(led_control_s::COLOR_WHITE, led_control_s::MODE_OFF); /* close fds */ led_deinit(); buzzer_deinit(); px4_close(sp_man_sub); px4_close(offboard_control_mode_sub); px4_close(local_position_sub); px4_close(global_position_sub); px4_close(gps_sub); px4_close(sensor_sub); px4_close(safety_sub); px4_close(cmd_sub); px4_close(subsys_sub); px4_close(diff_pres_sub); px4_close(param_changed_sub); px4_close(battery_sub); px4_close(land_detector_sub); thread_running = false; return 0; } void get_circuit_breaker_params() { status_flags.circuit_breaker_engaged_power_check = circuit_breaker_enabled("CBRK_SUPPLY_CHK", CBRK_SUPPLY_CHK_KEY); status_flags.circuit_breaker_engaged_usb_check = circuit_breaker_enabled("CBRK_USB_CHK", CBRK_USB_CHK_KEY); status_flags.circuit_breaker_engaged_airspd_check = circuit_breaker_enabled("CBRK_AIRSPD_CHK", CBRK_AIRSPD_CHK_KEY); status_flags.circuit_breaker_engaged_enginefailure_check = circuit_breaker_enabled("CBRK_ENGINEFAIL", CBRK_ENGINEFAIL_KEY); status_flags.circuit_breaker_engaged_gpsfailure_check = circuit_breaker_enabled("CBRK_GPSFAIL", CBRK_GPSFAIL_KEY); status_flags.circuit_breaker_flight_termination_disabled = circuit_breaker_enabled("CBRK_FLIGHTTERM", CBRK_FLIGHTTERM_KEY); status_flags.circuit_breaker_engaged_posfailure_check = circuit_breaker_enabled("CBRK_VELPOSERR", CBRK_VELPOSERR_KEY); } void check_valid(hrt_abstime timestamp, hrt_abstime timeout, bool valid_in, bool *valid_out, bool *changed) { hrt_abstime t = hrt_absolute_time(); bool valid_new = (t < timestamp + timeout && t > timeout && valid_in); if (*valid_out != valid_new) { *valid_out = valid_new; *changed = true; } } void control_status_leds(vehicle_status_s *status_local, const actuator_armed_s *actuator_armed, bool changed, battery_status_s *battery_local, const cpuload_s *cpuload_local) { static hrt_abstime overload_start = 0; bool overload = (cpuload_local->load > 0.80f) || (cpuload_local->ram_usage > 0.98f); if (overload_start == 0 && overload) { overload_start = hrt_absolute_time(); } else if (!overload) { overload_start = 0; } /* driving rgbled */ if (changed || last_overload != overload) { uint8_t led_mode = led_control_s::MODE_OFF; uint8_t led_color = led_control_s::COLOR_WHITE; bool set_normal_color = false; bool hotplug_timeout = hrt_elapsed_time(&commander_boot_timestamp) > HOTPLUG_SENS_TIMEOUT; int overload_warn_delay = (status_local->arming_state == vehicle_status_s::ARMING_STATE_ARMED) ? 1000 : 250000; /* set mode */ if (overload && ((hrt_absolute_time() - overload_start) > overload_warn_delay)) { led_mode = led_control_s::MODE_BLINK_FAST; led_color = led_control_s::COLOR_PURPLE; } else if (status_local->arming_state == vehicle_status_s::ARMING_STATE_ARMED) { led_mode = led_control_s::MODE_ON; set_normal_color = true; } else if (status_local->arming_state == vehicle_status_s::ARMING_STATE_ARMED_ERROR || (!status_flags.condition_system_sensors_initialized && hotplug_timeout)) { led_mode = led_control_s::MODE_BLINK_FAST; led_color = led_control_s::COLOR_RED; } else if (status_local->arming_state == vehicle_status_s::ARMING_STATE_STANDBY) { led_mode = led_control_s::MODE_BREATHE; set_normal_color = true; } else if (!status_flags.condition_system_sensors_initialized && !hotplug_timeout) { led_mode = led_control_s::MODE_BREATHE; set_normal_color = true; } else if (status_local->arming_state == vehicle_status_s::ARMING_STATE_INIT) { // if in init status it should not be in the error state led_mode = led_control_s::MODE_OFF; } else { // STANDBY_ERROR and other states led_mode = led_control_s::MODE_BLINK_NORMAL; led_color = led_control_s::COLOR_RED; } if (set_normal_color) { /* set color */ if (status.failsafe) { led_color = led_control_s::COLOR_PURPLE; } else if (battery_local->warning == battery_status_s::BATTERY_WARNING_LOW) { led_color = led_control_s::COLOR_AMBER; } else if (battery_local->warning == battery_status_s::BATTERY_WARNING_CRITICAL) { led_color = led_control_s::COLOR_RED; } else { if (status_flags.condition_home_position_valid && status_flags.condition_global_position_valid) { led_color = led_control_s::COLOR_GREEN; } else { led_color = led_control_s::COLOR_BLUE; } } } if (led_mode != led_control_s::MODE_OFF) { rgbled_set_color_and_mode(led_color, led_mode); } } last_overload = overload; #if defined (CONFIG_ARCH_BOARD_PX4FMU_V1) || defined (CONFIG_ARCH_BOARD_PX4FMU_V4) || defined (CONFIG_ARCH_BOARD_CRAZYFLIE) || defined (CONFIG_ARCH_BOARD_AEROFC_V1) || defined (CONFIG_ARCH_BOARD_AEROCORE2) /* this runs at around 20Hz, full cycle is 16 ticks = 10/16Hz */ if (actuator_armed->armed) { if (status.failsafe) { led_off(LED_BLUE); if (leds_counter % 5 == 0) { led_toggle(LED_GREEN); } } else { led_off(LED_GREEN); /* armed, solid */ led_on(LED_BLUE); } } else if (actuator_armed->ready_to_arm) { led_off(LED_BLUE); /* ready to arm, blink at 1Hz */ if (leds_counter % 20 == 0) { led_toggle(LED_GREEN); } } else { led_off(LED_BLUE); /* not ready to arm, blink at 10Hz */ if (leds_counter % 2 == 0) { led_toggle(LED_GREEN); } } #endif /* give system warnings on error LED */ if (overload) { if (leds_counter % 2 == 0) { led_toggle(LED_AMBER); } } else { led_off(LED_AMBER); } leds_counter++; } transition_result_t set_main_state_rc(struct vehicle_status_s *status_local, vehicle_global_position_s *global_position, vehicle_local_position_s *local_position, bool *changed) { /* set main state according to RC switches */ transition_result_t res = TRANSITION_DENIED; // Note: even if status_flags.offboard_control_set_by_command is set // we want to allow rc mode change to take precidence. This is a safety // feature, just in case offboard control goes crazy. /* manual setpoint has not updated, do not re-evaluate it */ if (!(!_last_condition_global_position_valid && status_flags.condition_global_position_valid) && (((_last_sp_man.timestamp != 0) && (_last_sp_man.timestamp == sp_man.timestamp)) || ((_last_sp_man.offboard_switch == sp_man.offboard_switch) && (_last_sp_man.return_switch == sp_man.return_switch) && (_last_sp_man.mode_switch == sp_man.mode_switch) && (_last_sp_man.acro_switch == sp_man.acro_switch) && (_last_sp_man.rattitude_switch == sp_man.rattitude_switch) && (_last_sp_man.posctl_switch == sp_man.posctl_switch) && (_last_sp_man.loiter_switch == sp_man.loiter_switch) && (_last_sp_man.mode_slot == sp_man.mode_slot) && (_last_sp_man.stab_switch == sp_man.stab_switch) && (_last_sp_man.man_switch == sp_man.man_switch)))) { // store the last manual control setpoint set by the pilot in a manual state // if the system now later enters an autonomous state the pilot can move // the sticks to break out of the autonomous state if (!warning_action_on && (internal_state.main_state == commander_state_s::MAIN_STATE_MANUAL || internal_state.main_state == commander_state_s::MAIN_STATE_ALTCTL || internal_state.main_state == commander_state_s::MAIN_STATE_POSCTL || internal_state.main_state == commander_state_s::MAIN_STATE_ACRO || internal_state.main_state == commander_state_s::MAIN_STATE_RATTITUDE || internal_state.main_state == commander_state_s::MAIN_STATE_STAB)) { _last_sp_man.timestamp = sp_man.timestamp; _last_sp_man.x = sp_man.x; _last_sp_man.y = sp_man.y; _last_sp_man.z = sp_man.z; _last_sp_man.r = sp_man.r; } /* no timestamp change or no switch change -> nothing changed */ return TRANSITION_NOT_CHANGED; } _last_sp_man = sp_man; // reset the position and velocity validity calculation to give the best change of being able to select // the desired mode reset_posvel_validity(global_position, local_position, changed); /* offboard switch overrides main switch */ if (sp_man.offboard_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_OFFBOARD, main_state_prev, &status_flags, &internal_state); if (res == TRANSITION_DENIED) { print_reject_mode(status_local, "OFFBOARD"); /* mode rejected, continue to evaluate the main system mode */ } else { /* changed successfully or already in this state */ return res; } } /* RTL switch overrides main switch */ if (sp_man.return_switch == manual_control_setpoint_s::SWITCH_POS_ON) { warnx("RTL switch changed and ON!"); res = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_RTL, main_state_prev, &status_flags, &internal_state); if (res == TRANSITION_DENIED) { print_reject_mode(status_local, "AUTO RTL"); /* fallback to LOITER if home position not set */ res = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); } if (res != TRANSITION_DENIED) { /* changed successfully or already in this state */ return res; } /* if we get here mode was rejected, continue to evaluate the main system mode */ } /* Loiter switch overrides main switch */ if (sp_man.loiter_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); if (res == TRANSITION_DENIED) { print_reject_mode(status_local, "AUTO HOLD"); } else { return res; } } /* we know something has changed - check if we are in mode slot operation */ if (sp_man.mode_slot != manual_control_setpoint_s::MODE_SLOT_NONE) { if (sp_man.mode_slot >= sizeof(_flight_mode_slots) / sizeof(_flight_mode_slots[0])) { warnx("m slot overflow"); return TRANSITION_DENIED; } int new_mode = _flight_mode_slots[sp_man.mode_slot]; if (new_mode < 0) { /* slot is unused */ res = TRANSITION_NOT_CHANGED; } else { res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); /* ensure that the mode selection does not get stuck here */ int maxcount = 5; /* enable the use of break */ /* fallback strategies, give the user the closest mode to what he wanted */ while (res == TRANSITION_DENIED && maxcount > 0) { maxcount--; if (new_mode == commander_state_s::MAIN_STATE_AUTO_MISSION) { /* fall back to loiter */ new_mode = commander_state_s::MAIN_STATE_AUTO_LOITER; print_reject_mode(status_local, "AUTO MISSION"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_AUTO_RTL) { /* fall back to position control */ new_mode = commander_state_s::MAIN_STATE_AUTO_LOITER; print_reject_mode(status_local, "AUTO RTL"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_AUTO_LAND) { /* fall back to position control */ new_mode = commander_state_s::MAIN_STATE_AUTO_LOITER; print_reject_mode(status_local, "AUTO LAND"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_AUTO_TAKEOFF) { /* fall back to position control */ new_mode = commander_state_s::MAIN_STATE_AUTO_LOITER; print_reject_mode(status_local, "AUTO TAKEOFF"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_AUTO_FOLLOW_TARGET) { /* fall back to position control */ new_mode = commander_state_s::MAIN_STATE_AUTO_LOITER; print_reject_mode(status_local, "AUTO FOLLOW"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_AUTO_LOITER) { /* fall back to position control */ new_mode = commander_state_s::MAIN_STATE_POSCTL; print_reject_mode(status_local, "AUTO HOLD"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_POSCTL) { /* fall back to altitude control */ new_mode = commander_state_s::MAIN_STATE_ALTCTL; print_reject_mode(status_local, "POSITION CONTROL"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_ALTCTL) { /* fall back to stabilized */ new_mode = commander_state_s::MAIN_STATE_STAB; print_reject_mode(status_local, "ALTITUDE CONTROL"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } if (new_mode == commander_state_s::MAIN_STATE_STAB) { /* fall back to manual */ new_mode = commander_state_s::MAIN_STATE_MANUAL; print_reject_mode(status_local, "STABILIZED"); res = main_state_transition(status_local, new_mode, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; } } } } return res; } /* offboard and RTL switches off or denied, check main mode switch */ switch (sp_man.mode_switch) { case manual_control_setpoint_s::SWITCH_POS_NONE: res = TRANSITION_NOT_CHANGED; break; case manual_control_setpoint_s::SWITCH_POS_OFF: // MANUAL if (sp_man.stab_switch == manual_control_setpoint_s::SWITCH_POS_NONE && sp_man.man_switch == manual_control_setpoint_s::SWITCH_POS_NONE) { /* * Legacy mode: * Acro switch being used as stabilized switch in FW. */ if (sp_man.acro_switch == manual_control_setpoint_s::SWITCH_POS_ON) { /* manual mode is stabilized already for multirotors, so switch to acro * for any non-manual mode */ if (status.is_rotary_wing && !status.is_vtol) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_ACRO, main_state_prev, &status_flags, &internal_state); } else if (!status.is_rotary_wing) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } else { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } } else if (sp_man.rattitude_switch == manual_control_setpoint_s::SWITCH_POS_ON) { /* Similar to acro transitions for multirotors. FW aircraft don't need a * rattitude mode.*/ if (status.is_rotary_wing) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_RATTITUDE, main_state_prev, &status_flags, &internal_state); } else { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } } else { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } } else { /* New mode: * - Acro is Acro * - Manual is not default anymore when the manaul switch is assigned */ if (sp_man.man_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } else if (sp_man.acro_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_ACRO, main_state_prev, &status_flags, &internal_state); } else if (sp_man.rattitude_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_RATTITUDE, main_state_prev, &status_flags, &internal_state); } else if (sp_man.stab_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } else if (sp_man.man_switch == manual_control_setpoint_s::SWITCH_POS_NONE) { // default to MANUAL when no manual switch is set res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); } else { // default to STAB when the manual switch is assigned (but off) res = main_state_transition(status_local, commander_state_s::MAIN_STATE_STAB, main_state_prev, &status_flags, &internal_state); } } // TRANSITION_DENIED is not possible here break; case manual_control_setpoint_s::SWITCH_POS_MIDDLE: // ASSIST if (sp_man.posctl_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this state } print_reject_mode(status_local, "POSITION CONTROL"); } // fallback to ALTCTL res = main_state_transition(status_local, commander_state_s::MAIN_STATE_ALTCTL, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this mode } if (sp_man.posctl_switch != manual_control_setpoint_s::SWITCH_POS_ON) { print_reject_mode(status_local, "ALTITUDE CONTROL"); } // fallback to MANUAL res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); // TRANSITION_DENIED is not possible here break; case manual_control_setpoint_s::SWITCH_POS_ON: // AUTO res = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_MISSION, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this state } print_reject_mode(status_local, "AUTO MISSION"); // fallback to LOITER if home position not set res = main_state_transition(status_local, commander_state_s::MAIN_STATE_AUTO_LOITER, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this state } // fallback to POSCTL res = main_state_transition(status_local, commander_state_s::MAIN_STATE_POSCTL, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this state } // fallback to ALTCTL res = main_state_transition(status_local, commander_state_s::MAIN_STATE_ALTCTL, main_state_prev, &status_flags, &internal_state); if (res != TRANSITION_DENIED) { break; // changed successfully or already in this state } // fallback to MANUAL res = main_state_transition(status_local, commander_state_s::MAIN_STATE_MANUAL, main_state_prev, &status_flags, &internal_state); // TRANSITION_DENIED is not possible here break; default: break; } return res; } void reset_posvel_validity(vehicle_global_position_s *global_position, vehicle_local_position_s *local_position, bool *changed) { // reset all the check probation times back to the minimum value gpos_probation_time_us = POSVEL_PROBATION_MIN; gvel_probation_time_us = POSVEL_PROBATION_MIN; lpos_probation_time_us = POSVEL_PROBATION_MIN; lvel_probation_time_us = POSVEL_PROBATION_MIN; // recheck validity check_posvel_validity(true, global_position->eph, eph_threshold, global_position->timestamp, &last_gpos_fail_time_us, &gpos_probation_time_us, &status_flags.condition_global_position_valid, changed); check_posvel_validity(true, global_position->evh, evh_threshold, global_position->timestamp, &last_gvel_fail_time_us, &gvel_probation_time_us, &status_flags.condition_global_velocity_valid, changed); check_posvel_validity(local_position->xy_valid, local_position->eph, eph_threshold, local_position->timestamp, &last_lpos_fail_time_us, &lpos_probation_time_us, &status_flags.condition_local_position_valid, changed); check_posvel_validity(local_position->v_xy_valid, local_position->evh, evh_threshold, local_position->timestamp, &last_lvel_fail_time_us, &lvel_probation_time_us, &status_flags.condition_local_velocity_valid, changed); } void check_posvel_validity(bool data_valid, float data_accuracy, float required_accuracy, uint64_t data_timestamp_us, hrt_abstime *last_fail_time_us, int64_t *probation_time_us, bool *valid_state, bool *validity_changed) { bool pos_inaccurate = false; hrt_abstime now = hrt_absolute_time(); // Check accuracy with hysteresis in both test level and time bool pos_status_changed = false; if (*valid_state && ((data_accuracy > required_accuracy * 2.5f) || !data_valid)) { pos_inaccurate = true; pos_status_changed = true; *last_fail_time_us = now; } else if (!*valid_state) { bool level_check_pass = data_valid && data_accuracy < required_accuracy; if (!level_check_pass) { *probation_time_us += (now - *last_fail_time_us) * POSVEL_VALID_PROBATION_FACTOR; *last_fail_time_us = now; } else if (now - *last_fail_time_us > *probation_time_us) { pos_inaccurate = false; pos_status_changed = true; *last_fail_time_us = 0; } } else { *probation_time_us -= (now - *last_fail_time_us); *last_fail_time_us = now; } bool data_stale = (now - data_timestamp_us > POSITION_TIMEOUT); // Set validity if (pos_status_changed) { if (*valid_state && (data_stale || !data_valid || pos_inaccurate)) { *valid_state = false; *validity_changed = true; } else if (!*valid_state && !data_stale && !pos_inaccurate && data_valid) { *valid_state = true; *validity_changed = true; } } // constrain probation times if (land_detector.landed) { *probation_time_us = POSVEL_PROBATION_MIN; } else { if (*probation_time_us < POSVEL_PROBATION_MIN) { *probation_time_us = POSVEL_PROBATION_MIN; } else if (*probation_time_us > POSVEL_PROBATION_MAX) { *probation_time_us = POSVEL_PROBATION_MAX; } } } void set_control_mode() { /* set vehicle_control_mode according to set_navigation_state */ control_mode.flag_armed = armed.armed; control_mode.flag_external_manual_override_ok = (!status.is_rotary_wing && !status.is_vtol); control_mode.flag_system_hil_enabled = status.hil_state == vehicle_status_s::HIL_STATE_ON; control_mode.flag_control_offboard_enabled = false; switch (status.nav_state) { case vehicle_status_s::NAVIGATION_STATE_MANUAL: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = stabilization_required(); control_mode.flag_control_attitude_enabled = stabilization_required(); control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_STAB: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; /* override is not ok in stabilized mode */ control_mode.flag_external_manual_override_ok = false; break; case vehicle_status_s::NAVIGATION_STATE_RATTITUDE: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = true; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_ALTCTL: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = true; control_mode.flag_control_climb_rate_enabled = true; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_POSCTL: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = true; control_mode.flag_control_climb_rate_enabled = true; control_mode.flag_control_position_enabled = !status.in_transition_mode; control_mode.flag_control_velocity_enabled = !status.in_transition_mode; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_AUTO_RTL: case vehicle_status_s::NAVIGATION_STATE_AUTO_RCRECOVER: /* override is not ok for the RTL and recovery mode */ control_mode.flag_external_manual_override_ok = false; /* fallthrough */ case vehicle_status_s::NAVIGATION_STATE_AUTO_FOLLOW_TARGET: case vehicle_status_s::NAVIGATION_STATE_AUTO_RTGS: case vehicle_status_s::NAVIGATION_STATE_AUTO_LAND: case vehicle_status_s::NAVIGATION_STATE_AUTO_LANDENGFAIL: case vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION: case vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER: case vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF: control_mode.flag_control_manual_enabled = false; control_mode.flag_control_auto_enabled = true; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = true; control_mode.flag_control_climb_rate_enabled = true; control_mode.flag_control_position_enabled = !status.in_transition_mode; control_mode.flag_control_velocity_enabled = !status.in_transition_mode; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_AUTO_LANDGPSFAIL: control_mode.flag_control_manual_enabled = false; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = true; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_ACRO: control_mode.flag_control_manual_enabled = true; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = false; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_DESCEND: /* TODO: check if this makes sense */ control_mode.flag_control_manual_enabled = false; control_mode.flag_control_auto_enabled = true; control_mode.flag_control_rates_enabled = true; control_mode.flag_control_attitude_enabled = true; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = true; control_mode.flag_control_termination_enabled = false; break; case vehicle_status_s::NAVIGATION_STATE_TERMINATION: /* disable all controllers on termination */ control_mode.flag_control_manual_enabled = false; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_rates_enabled = false; control_mode.flag_control_attitude_enabled = false; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_position_enabled = false; control_mode.flag_control_velocity_enabled = false; control_mode.flag_control_acceleration_enabled = false; control_mode.flag_control_altitude_enabled = false; control_mode.flag_control_climb_rate_enabled = false; control_mode.flag_control_termination_enabled = true; break; case vehicle_status_s::NAVIGATION_STATE_OFFBOARD: control_mode.flag_control_manual_enabled = false; control_mode.flag_control_auto_enabled = false; control_mode.flag_control_offboard_enabled = true; /* * The control flags depend on what is ignored according to the offboard control mode topic * Inner loop flags (e.g. attitude) also depend on outer loop ignore flags (e.g. position) */ control_mode.flag_control_rates_enabled = !offboard_control_mode.ignore_bodyrate || !offboard_control_mode.ignore_attitude || !offboard_control_mode.ignore_position || !offboard_control_mode.ignore_velocity || !offboard_control_mode.ignore_acceleration_force; control_mode.flag_control_attitude_enabled = !offboard_control_mode.ignore_attitude || !offboard_control_mode.ignore_position || !offboard_control_mode.ignore_velocity || !offboard_control_mode.ignore_acceleration_force; control_mode.flag_control_rattitude_enabled = false; control_mode.flag_control_acceleration_enabled = !offboard_control_mode.ignore_acceleration_force && !status.in_transition_mode; control_mode.flag_control_velocity_enabled = (!offboard_control_mode.ignore_velocity || !offboard_control_mode.ignore_position) && !status.in_transition_mode && !control_mode.flag_control_acceleration_enabled; control_mode.flag_control_climb_rate_enabled = (!offboard_control_mode.ignore_velocity || !offboard_control_mode.ignore_position) && !control_mode.flag_control_acceleration_enabled; control_mode.flag_control_position_enabled = !offboard_control_mode.ignore_position && !status.in_transition_mode && !control_mode.flag_control_acceleration_enabled; control_mode.flag_control_altitude_enabled = (!offboard_control_mode.ignore_velocity || !offboard_control_mode.ignore_position) && !control_mode.flag_control_acceleration_enabled; break; default: break; } } bool stabilization_required() { return (status.is_rotary_wing || // is a rotary wing, or status.vtol_fw_permanent_stab || // is a VTOL in fixed wing mode and stabilisation is on, or (vtol_status.vtol_in_trans_mode && // is currently a VTOL transitioning AND !status.is_rotary_wing)); // is a fixed wing, ie: transitioning back to rotary wing mode } void print_reject_mode(struct vehicle_status_s *status_local, const char *msg) { hrt_abstime t = hrt_absolute_time(); if (t - last_print_mode_reject_time > PRINT_MODE_REJECT_INTERVAL) { last_print_mode_reject_time = t; mavlink_log_critical(&mavlink_log_pub, "REJECT %s", msg); /* only buzz if armed, because else we're driving people nuts indoors they really need to look at the leds as well. */ tune_negative(armed.armed); } } void print_reject_arm(const char *msg) { hrt_abstime t = hrt_absolute_time(); if (t - last_print_mode_reject_time > PRINT_MODE_REJECT_INTERVAL) { last_print_mode_reject_time = t; mavlink_log_critical(&mavlink_log_pub, msg); tune_negative(true); } } void answer_command(struct vehicle_command_s &cmd, unsigned result, orb_advert_t &command_ack_pub, vehicle_command_ack_s &command_ack) { switch (result) { case vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED: tune_positive(true); break; case vehicle_command_s::VEHICLE_CMD_RESULT_DENIED: tune_negative(true); break; case vehicle_command_s::VEHICLE_CMD_RESULT_FAILED: tune_negative(true); break; case vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED: tune_negative(true); break; case vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED: tune_negative(true); break; default: break; } /* publish ACK */ command_ack.command = cmd.command; command_ack.result = result; if (command_ack_pub != nullptr) { orb_publish(ORB_ID(vehicle_command_ack), command_ack_pub, &command_ack); } else { command_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack, vehicle_command_ack_s::ORB_QUEUE_LENGTH); } } void *commander_low_prio_loop(void *arg) { /* Set thread name */ px4_prctl(PR_SET_NAME, "commander_low_prio", px4_getpid()); /* Subscribe to command topic */ int cmd_sub = orb_subscribe(ORB_ID(vehicle_command)); struct vehicle_command_s cmd; memset(&cmd, 0, sizeof(cmd)); /* command ack */ orb_advert_t command_ack_pub = nullptr; struct vehicle_command_ack_s command_ack; memset(&command_ack, 0, sizeof(command_ack)); /* wakeup source(s) */ px4_pollfd_struct_t fds[1]; /* use the gyro to pace output - XXX BROKEN if we are using the L3GD20 */ fds[0].fd = cmd_sub; fds[0].events = POLLIN; while (!thread_should_exit) { /* wait for up to 1000ms for data */ int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 1000); if (pret < 0) { /* this is undesirable but not much we can do - might want to flag unhappy status */ warn("commander: poll error %d, %d", pret, errno); continue; } else if (pret != 0) { /* if we reach here, we have a valid command */ orb_copy(ORB_ID(vehicle_command), cmd_sub, &cmd); /* ignore commands the high-prio loop or the navigator handles */ if (cmd.command == vehicle_command_s::VEHICLE_CMD_DO_SET_MODE || cmd.command == vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM || cmd.command == vehicle_command_s::VEHICLE_CMD_NAV_TAKEOFF || cmd.command == vehicle_command_s::VEHICLE_CMD_DO_SET_SERVO || cmd.command == vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED) { continue; } /* only handle low-priority commands here */ switch (cmd.command) { case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_REBOOT_SHUTDOWN: if (is_safe(&safety, &armed)) { if (((int)(cmd.param1)) == 1) { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); usleep(100000); /* reboot */ px4_shutdown_request(true, false); } else if (((int)(cmd.param1)) == 3) { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); usleep(100000); /* reboot to bootloader */ px4_shutdown_request(true, true); } else { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_DENIED, command_ack_pub, command_ack); } } else { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_DENIED, command_ack_pub, command_ack); } break; case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_CALIBRATION: { int calib_ret = PX4_ERROR; /* try to go to INIT/PREFLIGHT arming state */ if (TRANSITION_DENIED == arming_state_transition(&status, &battery, &safety, vehicle_status_s::ARMING_STATE_INIT, &armed, false /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp))) { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_DENIED, command_ack_pub, command_ack); break; } else { status_flags.condition_calibration_enabled = true; } if ((int)(cmd.param1) == 1) { /* gyro calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_gyro_calibration(&mavlink_log_pub); } else if ((int)(cmd.param1) == vehicle_command_s::PREFLIGHT_CALIBRATION_TEMPERATURE_CALIBRATION || (int)(cmd.param5) == vehicle_command_s::PREFLIGHT_CALIBRATION_TEMPERATURE_CALIBRATION || (int)(cmd.param7) == vehicle_command_s::PREFLIGHT_CALIBRATION_TEMPERATURE_CALIBRATION) { /* temperature calibration: handled in events module */ break; } else if ((int)(cmd.param2) == 1) { /* magnetometer calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_mag_calibration(&mavlink_log_pub); } else if ((int)(cmd.param3) == 1) { /* zero-altitude pressure calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_DENIED, command_ack_pub, command_ack); } else if ((int)(cmd.param4) == 1) { /* RC calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); /* disable RC control input completely */ status_flags.rc_input_blocked = true; calib_ret = OK; mavlink_log_info(&mavlink_log_pub, "CAL: Disabling RC IN"); } else if ((int)(cmd.param4) == 2) { /* RC trim calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_trim_calibration(&mavlink_log_pub); } else if ((int)(cmd.param5) == 1) { /* accelerometer calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_accel_calibration(&mavlink_log_pub); } else if ((int)(cmd.param5) == 2) { // board offset calibration answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_level_calibration(&mavlink_log_pub); } else if ((int)(cmd.param6) == 1 || (int)(cmd.param6) == 2) { // TODO: param6 == 1 is deprecated, but we still accept it for a while (feb 2017) /* airspeed calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_airspeed_calibration(&mavlink_log_pub); } else if ((int)(cmd.param7) == 1) { /* do esc calibration */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); calib_ret = do_esc_calibration(&mavlink_log_pub, &armed); } else if ((int)(cmd.param4) == 0) { /* RC calibration ended - have we been in one worth confirming? */ if (status_flags.rc_input_blocked) { /* enable RC control input */ status_flags.rc_input_blocked = false; mavlink_log_info(&mavlink_log_pub, "CAL: Re-enabling RC IN"); } answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); /* this always succeeds */ calib_ret = OK; } else { answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_UNSUPPORTED, command_ack_pub, command_ack); } status_flags.condition_calibration_enabled = false; if (calib_ret == OK) { tune_positive(true); // Update preflight check status // we do not set the calibration return value based on it because the calibration // might have worked just fine, but the preflight check fails for a different reason, // so this would be prone to false negatives. bool checkAirspeed = false; bool hotplug_timeout = hrt_elapsed_time(&commander_boot_timestamp) > HOTPLUG_SENS_TIMEOUT; /* Perform airspeed check only if circuit breaker is not * engaged and it's not a rotary wing */ if (!status_flags.circuit_breaker_engaged_airspd_check && (!status.is_rotary_wing || status.is_vtol)) { checkAirspeed = true; } status_flags.condition_system_sensors_initialized = Commander::preflightCheck(&mavlink_log_pub, true, true, true, true, checkAirspeed, !(status.rc_input_mode >= vehicle_status_s::RC_IN_MODE_OFF), !arm_without_gps, /* checkDynamic */ true, is_vtol(&status), /* reportFailures */ hotplug_timeout, /* prearm */ false, hrt_elapsed_time(&commander_boot_timestamp)); arming_state_transition(&status, &battery, &safety, vehicle_status_s::ARMING_STATE_STANDBY, &armed, false /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, avionics_power_rail_voltage, arm_without_gps, arm_mission_required, hrt_elapsed_time(&commander_boot_timestamp)); } else { tune_negative(true); } break; } case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_STORAGE: { if (((int)(cmd.param1)) == 0) { int ret = param_load_default(); if (ret == OK) { mavlink_log_info(&mavlink_log_pub, "settings loaded"); answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); } else { mavlink_log_critical(&mavlink_log_pub, "settings load ERROR"); /* convenience as many parts of NuttX use negative errno */ if (ret < 0) { ret = -ret; } if (ret < 1000) { mavlink_log_critical(&mavlink_log_pub, "ERROR: %s", strerror(ret)); } answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_FAILED, command_ack_pub, command_ack); } } else if (((int)(cmd.param1)) == 1) { #ifdef __PX4_QURT // TODO FIXME: on snapdragon the save happens too early when the params // are not set yet. We therefore need to wait some time first. usleep(1000000); #endif int ret = param_save_default(); if (ret == OK) { /* do not spam MAVLink, but provide the answer / green led mechanism */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); } else { mavlink_log_critical(&mavlink_log_pub, "settings save error"); /* convenience as many parts of NuttX use negative errno */ if (ret < 0) { ret = -ret; } if (ret < 1000) { mavlink_log_critical(&mavlink_log_pub, "ERROR: %s", strerror(ret)); } answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_FAILED, command_ack_pub, command_ack); } } else if (((int)(cmd.param1)) == 2) { /* reset parameters and save empty file */ param_reset_all(); /* do not spam MAVLink, but provide the answer / green led mechanism */ mavlink_log_critical(&mavlink_log_pub, "onboard parameters reset"); answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); } break; } case vehicle_command_s::VEHICLE_CMD_START_RX_PAIR: /* just ack, implementation handled in the IO driver */ answer_command(cmd, vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED, command_ack_pub, command_ack); break; default: /* don't answer on unsupported commands, it will be done in main loop */ break; } } } px4_close(cmd_sub); return nullptr; } void publish_status_flags(orb_advert_t &vehicle_status_flags_pub) { struct vehicle_status_flags_s v_flags; memset(&v_flags, 0, sizeof(v_flags)); /* set condition status flags */ if (status_flags.condition_calibration_enabled) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_CALIBRATION_ENABLE_MASK; } if (status_flags.condition_system_sensors_initialized) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_SYSTEM_SENSORS_INITIALIZED_MASK; } if (status_flags.condition_system_prearm_error_reported) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_SYSTEM_PREARM_ERROR_REPORTED_MASK; } if (status_flags.condition_system_hotplug_timeout) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_SYSTEM_HOTPLUG_TIMEOUT_MASK; } if (status_flags.condition_system_returned_to_home) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_SYSTEM_RETURNED_TO_HOME_MASK; } if (status_flags.condition_auto_mission_available) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_AUTO_MISSION_AVAILABLE_MASK; } if (status_flags.condition_global_position_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_GLOBAL_POSITION_VALID_MASK; } if (status_flags.condition_home_position_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_HOME_POSITION_VALID_MASK; } if (status_flags.condition_local_position_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_LOCAL_POSITION_VALID_MASK; } if (status_flags.condition_local_altitude_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_LOCAL_ALTITUDE_VALID_MASK; } if (status_flags.condition_local_altitude_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_LOCAL_ALTITUDE_VALID_MASK; } if (status_flags.condition_airspeed_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_AIRSPEED_VALID_MASK; } if (status_flags.condition_power_input_valid) { v_flags.conditions |= vehicle_status_flags_s::CONDITION_POWER_INPUT_VALID_MASK; } /* set circuit breaker status flags */ if (status_flags.circuit_breaker_engaged_power_check) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_ENGAGED_POWER_CHECK_MASK; } if (status_flags.circuit_breaker_engaged_airspd_check) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_ENGAGED_AIRSPD_CHECK_MASK; } if (status_flags.circuit_breaker_engaged_enginefailure_check) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_ENGAGED_ENGINEFAILURE_CHECK_MASK; } if (status_flags.circuit_breaker_engaged_gpsfailure_check) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_ENGAGED_GPSFAILURE_CHECK_MASK; } if (status_flags.circuit_breaker_flight_termination_disabled) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_FLIGHT_TERMINATION_DISABLED_MASK; } if (status_flags.circuit_breaker_engaged_usb_check) { v_flags.circuit_breakers |= vehicle_status_flags_s::CIRCUIT_BREAKER_ENGAGED_USB_CHECK_MASK; } /* set other status flags */ if (status_flags.usb_connected) { v_flags.other_flags |= vehicle_status_flags_s::USB_CONNECTED_MASK; } if (status_flags.offboard_control_signal_found_once) { v_flags.other_flags |= vehicle_status_flags_s::OFFBOARD_CONTROL_SIGNAL_FOUND_ONCE_MASK; } if (status_flags.offboard_control_signal_lost) { v_flags.other_flags |= vehicle_status_flags_s::OFFBOARD_CONTROL_SIGNAL_LOST_MASK; } if (status_flags.offboard_control_set_by_command) { v_flags.other_flags |= vehicle_status_flags_s::OFFBOARD_CONTROL_SET_BY_COMMAND_MASK; } if (status_flags.offboard_control_loss_timeout) { v_flags.other_flags |= vehicle_status_flags_s::OFFBOARD_CONTROL_LOSS_TIMEOUT_MASK; } if (status_flags.rc_signal_found_once) { v_flags.other_flags |= vehicle_status_flags_s::RC_SIGNAL_FOUND_ONCE_MASK; } if (status_flags.rc_signal_lost_cmd) { v_flags.other_flags |= vehicle_status_flags_s::RC_SIGNAL_LOST_CMD_MASK; } if (status_flags.rc_input_blocked) { v_flags.other_flags |= vehicle_status_flags_s::RC_INPUT_BLOCKED_MASK; } if (status_flags.data_link_lost_cmd) { v_flags.other_flags |= vehicle_status_flags_s::DATA_LINK_LOST_CMD_MASK; } if (status_flags.vtol_transition_failure) { v_flags.other_flags |= vehicle_status_flags_s::VTOL_TRANSITION_FAILURE_MASK; } if (status_flags.vtol_transition_failure_cmd) { v_flags.other_flags |= vehicle_status_flags_s::VTOL_TRANSITION_FAILURE_CMD_MASK; } if (status_flags.gps_failure) { v_flags.other_flags |= vehicle_status_flags_s::GPS_FAILURE_MASK; } if (status_flags.gps_failure_cmd) { v_flags.other_flags |= vehicle_status_flags_s::GPS_FAILURE_CMD_MASK; } if (status_flags.barometer_failure) { v_flags.other_flags |= vehicle_status_flags_s::BAROMETER_FAILURE_MASK; } if (status_flags.ever_had_barometer_data) { v_flags.other_flags |= vehicle_status_flags_s::EVER_HAD_BAROMETER_DATA_MASK; } /* publish vehicle_status_flags */ if (vehicle_status_flags_pub != nullptr) { orb_publish(ORB_ID(vehicle_status_flags), vehicle_status_flags_pub, &v_flags); } else { vehicle_status_flags_pub = orb_advertise(ORB_ID(vehicle_status_flags), &v_flags); } }
; max number .386 .model flat,stdcall .stack 4096 ExitProcess proto,dwExitCode:dword .data val1 DWORD 3 val2 DWORD 13 val3 DWORD 8 val4 DWORD 9 max DWORD ? .code main proc mov eax, val1 mov ebx, val2 mov ecx, val3 mov edx, val4 call MaxOfFour mov max, eax invoke ExitProcess,0 main endp MaxOfFour PROC push eax push ebx push ecx push edx mov ecx, 3 L1: pop eax pop ebx cmp eax, ebx ja small push ebx sub ecx,1 jnz L1 small: push eax sub ecx,1 jnz L1 pop eax ret MaxOfFour ENDP end main
#include "string_list.hpp" namespace node_gdal { StringList::StringList() : list(NULL), strlist(NULL) { } StringList::~StringList() { if(list) delete [] list; if(strlist) delete [] strlist; } int StringList::parse(Local<Value> value) { unsigned int i; if(value->IsNull() || value->IsUndefined()) return 0; if(value->IsArray()) { Local<Array> array = value.As<Array>(); if (array->Length() == 0) return 0; list = new char* [array->Length() + 1]; strlist = new std::string [array->Length()]; for (i = 0; i < array->Length(); ++i) { strlist[i] = *Nan::Utf8String(Nan::Get(array, i).ToLocalChecked()); list[i] = (char*) strlist[i].c_str(); } list[i] = NULL; } else if (value->IsObject()) { Local<Object> obj = value.As<Object>(); Local<Array> keys = Nan::GetOwnPropertyNames(obj).ToLocalChecked(); if(keys->Length() == 0) return 0; list = new char* [keys->Length() + 1]; strlist = new std::string [keys->Length()]; for (i = 0; i < keys->Length(); ++i) { std::string key = *Nan::Utf8String(Nan::Get(keys, i).ToLocalChecked()); std::string val = *Nan::Utf8String(Nan::Get(obj, Nan::Get(keys, i).ToLocalChecked()).ToLocalChecked()); strlist[i] = key+"="+val; list[i] = (char*) strlist[i].c_str(); } list[i] = NULL; } else { Nan::ThrowTypeError("String list must be an array or object"); return 1; } return 0; } } //node_gdal namespace
/********************************************************************** * Copyright (c) 2008-2013, Alliance for Sustainable Energy. * All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA **********************************************************************/ #include <model/WeatherFileDays.hpp> #include <model/WeatherFileDays_Impl.hpp> #include <model/Site.hpp> #include <model/Site_Impl.hpp> #include <utilities/core/Assert.hpp> namespace openstudio { namespace model { namespace detail { WeatherFileDays_Impl::WeatherFileDays_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : SizingPeriod_Impl(idfObject, model, keepHandle) { OS_ASSERT(idfObject.iddObject().type() == WeatherFileDays::iddObjectType()); } WeatherFileDays_Impl::WeatherFileDays_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) : SizingPeriod_Impl(other,model,keepHandle) { OS_ASSERT(other.iddObject().type() == WeatherFileDays::iddObjectType()); } WeatherFileDays_Impl::WeatherFileDays_Impl(const WeatherFileDays_Impl& other, Model_Impl* model, bool keepHandle) : SizingPeriod_Impl(other,model,keepHandle) { } // Get all output variable names that could be associated with this object. const std::vector<std::string>& WeatherFileDays_Impl::outputVariableNames() const { static std::vector<std::string> result; if (result.empty()){ } return result; } IddObjectType WeatherFileDays_Impl::iddObjectType() const { return WeatherFileDays::iddObjectType(); } } // detail /// constructor WeatherFileDays::WeatherFileDays(const Model& model) : SizingPeriod(WeatherFileDays::iddObjectType(),model) { OS_ASSERT(getImpl<detail::WeatherFileDays_Impl>()); } // constructor WeatherFileDays::WeatherFileDays(boost::shared_ptr<detail::WeatherFileDays_Impl> impl) : SizingPeriod(impl) {} IddObjectType WeatherFileDays::iddObjectType() { IddObjectType result(IddObjectType::OS_SizingPeriod_WeatherFileDays); return result; } } // model } // openstudio
<% from pwnlib.shellcraft.amd64.linux import syscall %> <%page args="fd, fd2, flags"/> <%docstring> Invokes the syscall dup3. See 'man 2 dup3' for more information. Arguments: fd(int): fd fd2(int): fd2 flags(int): flags </%docstring> ${syscall('SYS_dup3', fd, fd2, flags)}
; A174474: a(n) = (2*n^2 - 2*n - 3)/8 + 3*(-1)^n*(1-2*n)/8. ; 0,0,-1,3,0,8,3,15,8,24,15,35,24,48,35,63,48,80,63,99,80,120,99,143,120,168,143,195,168,224,195,255,224,288,255,323,288,360,323,399,360,440,399,483,440,528,483,575,528,624,575,675,624,728,675,783,728,840,783,899,840,960,899,1023,960,1088,1023,1155,1088,1224,1155,1295,1224,1368,1295,1443,1368,1520,1443,1599,1520,1680,1599,1763,1680,1848,1763,1935,1848,2024,1935,2115,2024,2208,2115,2303,2208,2400,2303,2499,2400,2600,2499,2703,2600,2808,2703,2915,2808,3024,2915,3135,3024,3248,3135,3363,3248,3480,3363,3599,3480,3720,3599,3843,3720,3968,3843,4095,3968,4224,4095,4355,4224,4488,4355,4623,4488,4760,4623,4899,4760,5040,4899,5183,5040,5328,5183,5475,5328,5624,5475,5775,5624,5928,5775,6083,5928,6240,6083,6399,6240,6560,6399,6723,6560,6888,6723,7055,6888,7224,7055,7395,7224,7568,7395,7743,7568,7920,7743,8099,7920,8280,8099,8463,8280,8648,8463,8835,8648,9024,8835,9215,9024,9408,9215,9603,9408,9800,9603,9999,9800,10200,9999,10403,10200,10608,10403,10815,10608,11024,10815,11235,11024,11448,11235,11663,11448,11880,11663,12099,11880,12320,12099,12543,12320,12768,12543,12995,12768,13224,12995,13455,13224,13688,13455,13923,13688,14160,13923,14399,14160,14640,14399,14883,14640,15128,14883,15375,15128,15624 mov $4,$0 mov $5,$0 mov $0,2 mov $2,1 gcd $4,2 mul $4,2 sub $2,$4 add $2,1 mov $3,$2 trn $2,52 mov $4,2 div $5,2 add $5,$3 lpb $0 div $0,2 sub $0,1 sub $2,$5 sub $4,$2 mul $5,$4 mov $1,$5 lpe
.area _IVT .area _HEADER nop jp 0x0150 ; This is a bitmap of the Nintendo logo which is required for the cartridge ; to boot. The idea was to try to use their trademark to defend their ; licensing scheme. Apparently the courts ultimately decided they could not ; do this. .byte 0xce,0xed,0x66,0x66,0xcc,0x0d,0x00,0x0b,0x03,0x73,0x00,0x83,0x00,0x0c .byte 0x00,0x0d,0x00,0x08,0x11,0x1f,0x88,0x89,0x00,0x0e,0xdc,0xcc,0x6e,0xe6 .byte 0xdd,0xdd,0xd9,0x99,0xbb,0xbb,0x67,0x63,0x6e,0x0e,0xec,0xcc,0xdd,0xdc .byte 0x99,0x9f,0xbb,0xb9,0x33,0x3e .ascii "OPEN SOURCE GB " ; .word 0xccdd,0xaabb .byte 0x00 ; no GBC compatibility .ascii "OS" ; obviously not a licensee .byte 0x00 ; no SGB compatibility .byte 0x00 ; ROM-only cart type .byte 0x00 ; 32kB (non-banked) ROM .byte 0x00 ; no RAM .byte 0x01 ; international rom .byte 0x33 ; "defer to new licensee code" .byte 0x00 ; Version 0 .byte 0xff ; Header checksum (to be patched) .word 0xffff ; Global checksum (to be patched) .globl _init .area _CODE entry: di ld hl, #0xe000 ld sp, hl ei jp _init .area _DATA
// RUN: clang++ -Xclang -verify -Xclang -load -Xclang %shlibdir/libUnusedForLoopVar%shlibext -Xclang -plugin -Xclang unused-for-loop-variable -c %s 2>&1 // Unused for loop variables are are not reported by the plugin, because their // name match: [U|u][N|n][U|u][S|s][E|e][D|d] // expected-no-diagnostics #include <vector> int foo() { int a = 10; std::vector<int> var_b{1, 2, 3}; for (auto unused: var_b) a++; for (auto UNUSED: var_b) a++; return a; }
#include <gtest/gtest.h> #include <fstream> #include <opencv2/highgui.hpp> #include "test_utility.h" #include "reference.h" #include "internal.h" TEST(ScanCostTest, RandomU8) { using disp_type = uchar; const int segmentWidth = 10; const int umax = 1024 / segmentWidth; const int vmax = 333; const int dmax = 128; const auto D = randomMat<disp_type>(umax, vmax, 0, dmax); const auto DR = randomVector<float>(vmax, 0, dmax - 1); const int vhor = vmax / 2; cv::Mat1w labels1, labels2; ref::scanCost(D, dmax, DR, vhor, labels1); sgm::scanCost(D, dmax, DR, vhor, labels2); EXPECT_TRUE(equals(labels1, labels2)); } TEST(ScanCostTest, RandomU16) { using disp_type = ushort; const int segmentWidth = 10; const int umax = 1024 / segmentWidth; const int vmax = 333; const int dmax = 128; const auto D = randomMat<disp_type>(umax, vmax, 0, dmax); const auto DR = randomVector<float>(vmax, 0, dmax - 1); const int vhor = vmax / 2; cv::Mat1w labels1, labels2; ref::scanCost(D, dmax, DR, vhor, labels1); sgm::scanCost(D, dmax, DR, vhor, labels2); EXPECT_TRUE(equals(labels1, labels2)); } TEST(ScanCostTest, FromFile) { const std::string testDataDir(TEST_DATA_DIR); // Load data const cv::Mat1b D = cv::imread(testDataDir + "/disparity_reduced.png"); std::ifstream ifs(testDataDir + "/line.txt"); CV_Assert(!D.empty()); CV_Assert(!ifs.fail()); const int vmax = D.cols; const int dmax = 128; float a, b; ifs >> a >> b; // compute expected road disparity std::vector<float> DR(vmax); for (int v = 0; v < vmax; v++) DR[v] = a * v + b; // horizontal row from which road dispaliry becomes negative const int vhor = cvRound(-b / a); cv::Mat1w labels1, labels2; ref::scanCost(D, dmax, DR, vhor, labels1); sgm::scanCost(D, dmax, DR, vhor, labels2); EXPECT_TRUE(equals(labels1, labels2)); }
add_song: MACRO .\1:: db BANK(\1) dw \1 ; The song bank must be representable with a single byte ASSERT BANK(\1) <= $FF ENDM SECTION "song table", ROMX song_table:: add_song ryukenden add_song wild_pokemon_appear add_song uwu
#include "extensions/filters/http/lua/lua_filter.h" #include <atomic> #include <memory> #include "envoy/http/codes.h" #include "common/buffer/buffer_impl.h" #include "common/common/assert.h" #include "common/common/enum_to_int.h" #include "common/config/datasource.h" #include "common/crypto/utility.h" #include "common/http/message_impl.h" #include "absl/strings/escaping.h" namespace Envoy { namespace Extensions { namespace HttpFilters { namespace Lua { namespace { struct HttpResponseCodeDetailValues { const absl::string_view LuaResponse = "lua_response"; }; using HttpResponseCodeDetails = ConstSingleton<HttpResponseCodeDetailValues>; const std::string DEPRECATED_LUA_NAME = "envoy.lua"; std::atomic<bool>& deprecatedNameLogged() { MUTABLE_CONSTRUCT_ON_FIRST_USE(std::atomic<bool>, false); } // Checks if deprecated metadata names are allowed. On the first check only it will log either // a warning (indicating the name should be updated) or an error (the feature is off and the // name is not allowed). When warning, the deprecated feature stat is incremented. Subsequent // checks do not log since this check is done in potentially high-volume request paths. bool allowDeprecatedMetadataName() { if (!deprecatedNameLogged().exchange(true)) { // Have not logged yet, so use the logging test. return Extensions::Common::Utility::ExtensionNameUtil::allowDeprecatedExtensionName( "http filter", DEPRECATED_LUA_NAME, Extensions::HttpFilters::HttpFilterNames::get().Lua); } // We have logged (or another thread will do so momentarily), so just check whether the // deprecated name is allowed. auto status = Extensions::Common::Utility::ExtensionNameUtil::deprecatedExtensionNameStatus(); return status == Extensions::Common::Utility::ExtensionNameUtil::Status::Warn; } const ProtobufWkt::Struct& getMetadata(Http::StreamFilterCallbacks* callbacks) { if (callbacks->route() == nullptr || callbacks->route()->routeEntry() == nullptr) { return ProtobufWkt::Struct::default_instance(); } const auto& metadata = callbacks->route()->routeEntry()->metadata(); { const auto& filter_it = metadata.filter_metadata().find(HttpFilterNames::get().Lua); if (filter_it != metadata.filter_metadata().end()) { return filter_it->second; } } // TODO(zuercher): Remove this block when deprecated filter names are removed. { const auto& filter_it = metadata.filter_metadata().find(DEPRECATED_LUA_NAME); if (filter_it != metadata.filter_metadata().end()) { // Use the non-throwing check here because this happens at request time. if (allowDeprecatedMetadataName()) { return filter_it->second; } } } return ProtobufWkt::Struct::default_instance(); } // Okay to return non-const reference because this doesn't ever get changed. NoopCallbacks& noopCallbacks() { static NoopCallbacks* callbacks = new NoopCallbacks(); return *callbacks; } void buildHeadersFromTable(Http::HeaderMap& headers, lua_State* state, int table_index) { // Build a header map to make the request. We iterate through the provided table to do this and // check that we are getting strings. lua_pushnil(state); while (lua_next(state, table_index) != 0) { // Uses 'key' (at index -2) and 'value' (at index -1). const char* key = luaL_checkstring(state, -2); // Check if the current value is a table, we iterate through the table and add each element of // it as a header entry value for the current key. if (lua_istable(state, -1)) { lua_pushnil(state); while (lua_next(state, -2) != 0) { const char* value = luaL_checkstring(state, -1); headers.addCopy(Http::LowerCaseString(key), value); lua_pop(state, 1); } } else { const char* value = luaL_checkstring(state, -1); headers.addCopy(Http::LowerCaseString(key), value); } // Removes 'value'; keeps 'key' for next iteration. This is the input for lua_next() so that // it can push the next key/value pair onto the stack. lua_pop(state, 1); } } Http::AsyncClient::Request* makeHttpCall(lua_State* state, Filter& filter, Tracing::Span& parent_span, Http::AsyncClient::Callbacks& callbacks) { const std::string cluster = luaL_checkstring(state, 2); luaL_checktype(state, 3, LUA_TTABLE); size_t body_size; const char* body = luaL_optlstring(state, 4, nullptr, &body_size); int timeout_ms = luaL_checkint(state, 5); if (timeout_ms < 0) { luaL_error(state, "http call timeout must be >= 0"); } if (filter.clusterManager().get(cluster) == nullptr) { luaL_error(state, "http call cluster invalid. Must be configured"); } auto headers = Http::RequestHeaderMapImpl::create(); buildHeadersFromTable(*headers, state, 3); Http::RequestMessagePtr message(new Http::RequestMessageImpl(std::move(headers))); // Check that we were provided certain headers. if (message->headers().Path() == nullptr || message->headers().Method() == nullptr || message->headers().Host() == nullptr) { luaL_error(state, "http call headers must include ':path', ':method', and ':authority'"); } if (body != nullptr) { message->body() = std::make_unique<Buffer::OwnedImpl>(body, body_size); message->headers().setContentLength(body_size); } absl::optional<std::chrono::milliseconds> timeout; if (timeout_ms > 0) { timeout = std::chrono::milliseconds(timeout_ms); } auto options = Http::AsyncClient::RequestOptions().setTimeout(timeout).setParentSpan(parent_span); return filter.clusterManager().httpAsyncClientForCluster(cluster).send(std::move(message), callbacks, options); } } // namespace PerLuaCodeSetup::PerLuaCodeSetup(const std::string& lua_code, ThreadLocal::SlotAllocator& tls) : lua_state_(lua_code, tls) { lua_state_.registerType<Filters::Common::Lua::BufferWrapper>(); lua_state_.registerType<Filters::Common::Lua::MetadataMapWrapper>(); lua_state_.registerType<Filters::Common::Lua::MetadataMapIterator>(); lua_state_.registerType<Filters::Common::Lua::ConnectionWrapper>(); lua_state_.registerType<Filters::Common::Lua::SslConnectionWrapper>(); lua_state_.registerType<HeaderMapWrapper>(); lua_state_.registerType<HeaderMapIterator>(); lua_state_.registerType<StreamInfoWrapper>(); lua_state_.registerType<DynamicMetadataMapWrapper>(); lua_state_.registerType<DynamicMetadataMapIterator>(); lua_state_.registerType<StreamHandleWrapper>(); lua_state_.registerType<PublicKeyWrapper>(); request_function_slot_ = lua_state_.registerGlobal("envoy_on_request"); if (lua_state_.getGlobalRef(request_function_slot_) == LUA_REFNIL) { ENVOY_LOG(info, "envoy_on_request() function not found. Lua filter will not hook requests."); } response_function_slot_ = lua_state_.registerGlobal("envoy_on_response"); if (lua_state_.getGlobalRef(response_function_slot_) == LUA_REFNIL) { ENVOY_LOG(info, "envoy_on_response() function not found. Lua filter will not hook responses."); } } StreamHandleWrapper::StreamHandleWrapper(Filters::Common::Lua::Coroutine& coroutine, Http::HeaderMap& headers, bool end_stream, Filter& filter, FilterCallbacks& callbacks) : coroutine_(coroutine), headers_(headers), end_stream_(end_stream), filter_(filter), callbacks_(callbacks), yield_callback_([this]() { if (state_ == State::Running) { throw Filters::Common::Lua::LuaException("script performed an unexpected yield"); } }) {} Http::FilterHeadersStatus StreamHandleWrapper::start(int function_ref) { // We are on the top of the stack. coroutine_.start(function_ref, 1, yield_callback_); Http::FilterHeadersStatus status = (state_ == State::WaitForBody || state_ == State::HttpCall || state_ == State::Responded) ? Http::FilterHeadersStatus::StopIteration : Http::FilterHeadersStatus::Continue; if (status == Http::FilterHeadersStatus::Continue) { headers_continued_ = true; } return status; } Http::FilterDataStatus StreamHandleWrapper::onData(Buffer::Instance& data, bool end_stream) { ASSERT(!end_stream_); end_stream_ = end_stream; saw_body_ = true; if (state_ == State::WaitForBodyChunk) { ENVOY_LOG(trace, "resuming for next body chunk"); Filters::Common::Lua::LuaDeathRef<Filters::Common::Lua::BufferWrapper> wrapper( Filters::Common::Lua::BufferWrapper::create(coroutine_.luaState(), data), true); state_ = State::Running; coroutine_.resume(1, yield_callback_); } else if (state_ == State::WaitForBody && end_stream_) { ENVOY_LOG(debug, "resuming body due to end stream"); callbacks_.addData(data); state_ = State::Running; coroutine_.resume(luaBody(coroutine_.luaState()), yield_callback_); } else if (state_ == State::WaitForTrailers && end_stream_) { ENVOY_LOG(debug, "resuming nil trailers due to end stream"); state_ = State::Running; coroutine_.resume(0, yield_callback_); } if (state_ == State::HttpCall || state_ == State::WaitForBody) { ENVOY_LOG(trace, "buffering body"); return Http::FilterDataStatus::StopIterationAndBuffer; } else if (state_ == State::Responded) { return Http::FilterDataStatus::StopIterationNoBuffer; } else { headers_continued_ = true; return Http::FilterDataStatus::Continue; } } Http::FilterTrailersStatus StreamHandleWrapper::onTrailers(Http::HeaderMap& trailers) { ASSERT(!end_stream_); end_stream_ = true; trailers_ = &trailers; if (state_ == State::WaitForBodyChunk) { ENVOY_LOG(debug, "resuming nil body chunk due to trailers"); state_ = State::Running; coroutine_.resume(0, yield_callback_); } else if (state_ == State::WaitForBody) { ENVOY_LOG(debug, "resuming body due to trailers"); state_ = State::Running; coroutine_.resume(luaBody(coroutine_.luaState()), yield_callback_); } if (state_ == State::WaitForTrailers) { // Mimic a call to trailers which will push the trailers onto the stack and then resume. state_ = State::Running; coroutine_.resume(luaTrailers(coroutine_.luaState()), yield_callback_); } Http::FilterTrailersStatus status = (state_ == State::HttpCall || state_ == State::Responded) ? Http::FilterTrailersStatus::StopIteration : Http::FilterTrailersStatus::Continue; if (status == Http::FilterTrailersStatus::Continue) { headers_continued_ = true; } return status; } int StreamHandleWrapper::luaRespond(lua_State* state) { ASSERT(state_ == State::Running); if (headers_continued_) { luaL_error(state, "respond() cannot be called if headers have been continued"); } luaL_checktype(state, 2, LUA_TTABLE); size_t body_size; const char* raw_body = luaL_optlstring(state, 3, nullptr, &body_size); auto headers = Http::ResponseHeaderMapImpl::create(); buildHeadersFromTable(*headers, state, 2); uint64_t status; if (!absl::SimpleAtoi(headers->getStatusValue(), &status) || status < 200 || status >= 600) { luaL_error(state, ":status must be between 200-599"); } Buffer::InstancePtr body; if (raw_body != nullptr) { body = std::make_unique<Buffer::OwnedImpl>(raw_body, body_size); headers->setContentLength(body_size); } // Once we respond we treat that as the end of the script even if there is more code. Thus we // yield. callbacks_.respond(std::move(headers), body.get(), state); state_ = State::Responded; return lua_yield(state, 0); } int StreamHandleWrapper::luaHttpCall(lua_State* state) { ASSERT(state_ == State::Running); const int async_flag_index = 6; if (!lua_isnone(state, async_flag_index) && !lua_isboolean(state, async_flag_index)) { luaL_error(state, "http call asynchronous flag must be 'true', 'false', or empty"); } if (lua_toboolean(state, async_flag_index)) { return doAsynchronousHttpCall(state, callbacks_.activeSpan()); } else { return doSynchronousHttpCall(state, callbacks_.activeSpan()); } } int StreamHandleWrapper::doSynchronousHttpCall(lua_State* state, Tracing::Span& span) { http_request_ = makeHttpCall(state, filter_, span, *this); if (http_request_) { state_ = State::HttpCall; return lua_yield(state, 0); } else { // Immediate failure case. The return arguments are already on the stack. ASSERT(lua_gettop(state) >= 2); return 2; } } int StreamHandleWrapper::doAsynchronousHttpCall(lua_State* state, Tracing::Span& span) { makeHttpCall(state, filter_, span, noopCallbacks()); return 0; } void StreamHandleWrapper::onSuccess(const Http::AsyncClient::Request&, Http::ResponseMessagePtr&& response) { ASSERT(state_ == State::HttpCall || state_ == State::Running); ENVOY_LOG(debug, "async HTTP response complete"); http_request_ = nullptr; // We need to build a table with the headers as return param 1. The body will be return param 2. lua_newtable(coroutine_.luaState()); response->headers().iterate([lua_State = coroutine_.luaState()]( const Http::HeaderEntry& header) -> Http::HeaderMap::Iterate { lua_pushlstring(lua_State, header.key().getStringView().data(), header.key().getStringView().length()); lua_pushlstring(lua_State, header.value().getStringView().data(), header.value().getStringView().length()); lua_settable(lua_State, -3); return Http::HeaderMap::Iterate::Continue; }); // TODO(mattklein123): Avoid double copy here. if (response->body() != nullptr) { lua_pushstring(coroutine_.luaState(), response->bodyAsString().c_str()); } else { lua_pushnil(coroutine_.luaState()); } // In the immediate failure case, we are just going to immediately return to the script. We // have already pushed the return arguments onto the stack. if (state_ == State::HttpCall) { state_ = State::Running; markLive(); try { coroutine_.resume(2, yield_callback_); markDead(); } catch (const Filters::Common::Lua::LuaException& e) { filter_.scriptError(e); } if (state_ == State::Running) { headers_continued_ = true; callbacks_.continueIteration(); } } } void StreamHandleWrapper::onFailure(const Http::AsyncClient::Request& request, Http::AsyncClient::FailureReason) { ASSERT(state_ == State::HttpCall || state_ == State::Running); ENVOY_LOG(debug, "async HTTP failure"); // Just fake a basic 503 response. Http::ResponseMessagePtr response_message( new Http::ResponseMessageImpl(Http::createHeaderMap<Http::ResponseHeaderMapImpl>( {{Http::Headers::get().Status, std::to_string(enumToInt(Http::Code::ServiceUnavailable))}}))); response_message->body() = std::make_unique<Buffer::OwnedImpl>("upstream failure"); onSuccess(request, std::move(response_message)); } int StreamHandleWrapper::luaHeaders(lua_State* state) { ASSERT(state_ == State::Running); if (headers_wrapper_.get() != nullptr) { headers_wrapper_.pushStack(); } else { headers_wrapper_.reset(HeaderMapWrapper::create(state, headers_, [this] { // If we are about to do a modifiable header // operation, blow away the route cache. We // could be a little more intelligent about // when we do this so the performance would be // higher, but this is simple and will get the // job done for now. This is a NOP on the // encoder path. if (!headers_continued_) { callbacks_.onHeadersModified(); } return !headers_continued_; }), true); } return 1; } int StreamHandleWrapper::luaBody(lua_State* state) { ASSERT(state_ == State::Running); if (end_stream_) { if (!buffered_body_ && saw_body_) { return luaL_error(state, "cannot call body() after body has been streamed"); } else if (callbacks_.bufferedBody() == nullptr) { ENVOY_LOG(debug, "end stream. no body"); return 0; } else { if (body_wrapper_.get() != nullptr) { body_wrapper_.pushStack(); } else { body_wrapper_.reset( Filters::Common::Lua::BufferWrapper::create(state, *callbacks_.bufferedBody()), true); } return 1; } } else if (saw_body_) { return luaL_error(state, "cannot call body() after body streaming has started"); } else { ENVOY_LOG(debug, "yielding for full body"); state_ = State::WaitForBody; buffered_body_ = true; return lua_yield(state, 0); } } int StreamHandleWrapper::luaBodyChunks(lua_State* state) { ASSERT(state_ == State::Running); if (saw_body_) { luaL_error(state, "cannot call bodyChunks after body processing has begun"); } // We are currently at the top of the stack. Push a closure that has us as the upvalue. lua_pushcclosure(state, static_luaBodyIterator, 1); return 1; } int StreamHandleWrapper::luaBodyIterator(lua_State* state) { ASSERT(state_ == State::Running); if (end_stream_) { ENVOY_LOG(debug, "body complete. no more body chunks"); return 0; } else { ENVOY_LOG(debug, "yielding for next body chunk"); state_ = State::WaitForBodyChunk; return lua_yield(state, 0); } } int StreamHandleWrapper::luaTrailers(lua_State* state) { ASSERT(state_ == State::Running); if (end_stream_ && trailers_ == nullptr) { ENVOY_LOG(debug, "end stream. no trailers"); return 0; } else if (trailers_ != nullptr) { if (trailers_wrapper_.get() != nullptr) { trailers_wrapper_.pushStack(); } else { trailers_wrapper_.reset(HeaderMapWrapper::create(state, *trailers_, []() { return true; }), true); } return 1; } else { ENVOY_LOG(debug, "yielding for trailers"); state_ = State::WaitForTrailers; return lua_yield(state, 0); } } int StreamHandleWrapper::luaMetadata(lua_State* state) { ASSERT(state_ == State::Running); if (metadata_wrapper_.get() != nullptr) { metadata_wrapper_.pushStack(); } else { metadata_wrapper_.reset( Filters::Common::Lua::MetadataMapWrapper::create(state, callbacks_.metadata()), true); } return 1; } int StreamHandleWrapper::luaStreamInfo(lua_State* state) { ASSERT(state_ == State::Running); if (stream_info_wrapper_.get() != nullptr) { stream_info_wrapper_.pushStack(); } else { stream_info_wrapper_.reset(StreamInfoWrapper::create(state, callbacks_.streamInfo()), true); } return 1; } int StreamHandleWrapper::luaConnection(lua_State* state) { ASSERT(state_ == State::Running); if (connection_wrapper_.get() != nullptr) { connection_wrapper_.pushStack(); } else { connection_wrapper_.reset( Filters::Common::Lua::ConnectionWrapper::create(state, callbacks_.connection()), true); } return 1; } int StreamHandleWrapper::luaLogTrace(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::trace, message); return 0; } int StreamHandleWrapper::luaLogDebug(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::debug, message); return 0; } int StreamHandleWrapper::luaLogInfo(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::info, message); return 0; } int StreamHandleWrapper::luaLogWarn(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::warn, message); return 0; } int StreamHandleWrapper::luaLogErr(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::err, message); return 0; } int StreamHandleWrapper::luaLogCritical(lua_State* state) { const char* message = luaL_checkstring(state, 2); filter_.scriptLog(spdlog::level::critical, message); return 0; } int StreamHandleWrapper::luaVerifySignature(lua_State* state) { // Step 1: Get hash function. absl::string_view hash = luaL_checkstring(state, 2); // Step 2: Get the key pointer. auto key = luaL_checkstring(state, 3); auto ptr = public_key_storage_.find(key); if (ptr == public_key_storage_.end()) { luaL_error(state, "invalid public key"); return 0; } // Step 3: Get signature from args. const char* signature = luaL_checkstring(state, 4); int sig_len = luaL_checknumber(state, 5); const std::vector<uint8_t> sig_vec(signature, signature + sig_len); // Step 4: Get clear text from args. const char* clear_text = luaL_checkstring(state, 6); int text_len = luaL_checknumber(state, 7); const std::vector<uint8_t> text_vec(clear_text, clear_text + text_len); // Step 5: Verify signature. auto& crypto_util = Envoy::Common::Crypto::UtilitySingleton::get(); auto output = crypto_util.verifySignature(hash, *ptr->second, sig_vec, text_vec); lua_pushboolean(state, output.result_); if (output.result_) { lua_pushnil(state); } else { lua_pushlstring(state, output.error_message_.data(), output.error_message_.length()); } return 2; } int StreamHandleWrapper::luaImportPublicKey(lua_State* state) { // Get byte array and the length. const char* str = luaL_checkstring(state, 2); int n = luaL_checknumber(state, 3); std::vector<uint8_t> key(str, str + n); if (public_key_wrapper_.get() != nullptr) { public_key_wrapper_.pushStack(); } else { auto& crypto_util = Envoy::Common::Crypto::UtilitySingleton::get(); Envoy::Common::Crypto::CryptoObjectPtr crypto_ptr = crypto_util.importPublicKey(key); auto wrapper = Envoy::Common::Crypto::Access::getTyped<Envoy::Common::Crypto::PublicKeyObject>( *crypto_ptr); EVP_PKEY* pkey = wrapper->getEVP_PKEY(); if (pkey == nullptr) { // TODO(dio): Call luaL_error here instead of failing silently. However, the current behavior // is to return nil (when calling get() to the wrapped object, hence we create a wrapper // initialized by an empty string here) when importing a public key is failed. public_key_wrapper_.reset(PublicKeyWrapper::create(state, EMPTY_STRING), true); } public_key_storage_.insert({std::string(str).substr(0, n), std::move(crypto_ptr)}); public_key_wrapper_.reset(PublicKeyWrapper::create(state, str), true); } return 1; } int StreamHandleWrapper::luaBase64Escape(lua_State* state) { size_t input_size; const char* input = luaL_checklstring(state, 2, &input_size); auto output = absl::Base64Escape(absl::string_view(input, input_size)); lua_pushlstring(state, output.data(), output.length()); return 1; } FilterConfig::FilterConfig(const envoy::extensions::filters::http::lua::v3::Lua& proto_config, ThreadLocal::SlotAllocator& tls, Upstream::ClusterManager& cluster_manager, Api::Api& api) : cluster_manager_(cluster_manager) { auto global_setup_ptr = std::make_unique<PerLuaCodeSetup>(proto_config.inline_code(), tls); if (global_setup_ptr) { per_lua_code_setups_map_[GLOBAL_SCRIPT_NAME] = std::move(global_setup_ptr); } for (const auto& source : proto_config.source_codes()) { const std::string code = Config::DataSource::read(source.second, true, api); auto per_lua_code_setup_ptr = std::make_unique<PerLuaCodeSetup>(code, tls); if (!per_lua_code_setup_ptr) { continue; } per_lua_code_setups_map_[source.first] = std::move(per_lua_code_setup_ptr); } } FilterConfigPerRoute::FilterConfigPerRoute( const envoy::extensions::filters::http::lua::v3::LuaPerRoute& config, Server::Configuration::ServerFactoryContext& context) : main_thread_dispatcher_(context.dispatcher()), disabled_(config.disabled()), name_(config.name()) { if (disabled_ || !name_.empty()) { return; } // Read and parse the inline Lua code defined in the route configuration. const std::string code_str = Config::DataSource::read(config.source_code(), true, context.api()); per_lua_code_setup_ptr_ = std::make_unique<PerLuaCodeSetup>(code_str, context.threadLocal()); } void Filter::onDestroy() { destroyed_ = true; if (request_stream_wrapper_.get()) { request_stream_wrapper_.get()->onReset(); } if (response_stream_wrapper_.get()) { response_stream_wrapper_.get()->onReset(); } } Http::FilterHeadersStatus Filter::doHeaders(StreamHandleRef& handle, Filters::Common::Lua::CoroutinePtr& coroutine, FilterCallbacks& callbacks, int function_ref, PerLuaCodeSetup* setup, Http::HeaderMap& headers, bool end_stream) { if (function_ref == LUA_REFNIL) { return Http::FilterHeadersStatus::Continue; } ASSERT(setup); coroutine = setup->createCoroutine(); handle.reset(StreamHandleWrapper::create(coroutine->luaState(), *coroutine, headers, end_stream, *this, callbacks), true); Http::FilterHeadersStatus status = Http::FilterHeadersStatus::Continue; try { status = handle.get()->start(function_ref); handle.markDead(); } catch (const Filters::Common::Lua::LuaException& e) { scriptError(e); } return status; } Http::FilterDataStatus Filter::doData(StreamHandleRef& handle, Buffer::Instance& data, bool end_stream) { Http::FilterDataStatus status = Http::FilterDataStatus::Continue; if (handle.get() != nullptr) { try { handle.markLive(); status = handle.get()->onData(data, end_stream); handle.markDead(); } catch (const Filters::Common::Lua::LuaException& e) { scriptError(e); } } return status; } Http::FilterTrailersStatus Filter::doTrailers(StreamHandleRef& handle, Http::HeaderMap& trailers) { Http::FilterTrailersStatus status = Http::FilterTrailersStatus::Continue; if (handle.get() != nullptr) { try { handle.markLive(); status = handle.get()->onTrailers(trailers); handle.markDead(); } catch (const Filters::Common::Lua::LuaException& e) { scriptError(e); } } return status; } void Filter::scriptError(const Filters::Common::Lua::LuaException& e) { scriptLog(spdlog::level::err, e.what()); request_stream_wrapper_.reset(); response_stream_wrapper_.reset(); } void Filter::scriptLog(spdlog::level::level_enum level, const char* message) { switch (level) { case spdlog::level::trace: ENVOY_LOG(trace, "script log: {}", message); return; case spdlog::level::debug: ENVOY_LOG(debug, "script log: {}", message); return; case spdlog::level::info: ENVOY_LOG(info, "script log: {}", message); return; case spdlog::level::warn: ENVOY_LOG(warn, "script log: {}", message); return; case spdlog::level::err: ENVOY_LOG(error, "script log: {}", message); return; case spdlog::level::critical: ENVOY_LOG(critical, "script log: {}", message); return; case spdlog::level::off: NOT_IMPLEMENTED_GCOVR_EXCL_LINE; return; case spdlog::level::n_levels: NOT_REACHED_GCOVR_EXCL_LINE; } } void Filter::DecoderCallbacks::respond(Http::ResponseHeaderMapPtr&& headers, Buffer::Instance* body, lua_State*) { callbacks_->encodeHeaders(std::move(headers), body == nullptr, HttpResponseCodeDetails::get().LuaResponse); if (body && !parent_.destroyed_) { callbacks_->encodeData(*body, true); } } const ProtobufWkt::Struct& Filter::DecoderCallbacks::metadata() const { return getMetadata(callbacks_); } void Filter::EncoderCallbacks::respond(Http::ResponseHeaderMapPtr&&, Buffer::Instance*, lua_State* state) { // TODO(mattklein123): Support response in response path if nothing has been continued // yet. luaL_error(state, "respond not currently supported in the response path"); } const ProtobufWkt::Struct& Filter::EncoderCallbacks::metadata() const { return getMetadata(callbacks_); } } // namespace Lua } // namespace HttpFilters } // namespace Extensions } // namespace Envoy
; =============================================================== ; --------------------------------------------------------------- ; Error handling and debugging modules ; 2016-2017, Vladikcomper ; --------------------------------------------------------------- ; Error handler functions and calls ; --------------------------------------------------------------- ; --------------------------------------------------------------- ; Error handler control flags ; --------------------------------------------------------------- ; Screen appearence flags _eh_address_error equ $01 ; use for address and bus errors only (tells error handler to display additional "Address" field) _eh_show_sr_usp equ $02 ; displays SR and USP registers content on error screen ; Advanced execution flags ; WARNING! For experts only, DO NOT USES them unless you know what you're doing _eh_return equ $20 _eh_enter_console equ $40 _eh_align_offset equ $80 ; --------------------------------------------------------------- ; Errors vector table ; --------------------------------------------------------------- ; Default screen configuration _eh_default equ 0 ;_eh_show_sr_usp ; --------------------------------------------------------------- BusError: __ErrorMessage "BUS ERROR", _eh_default|_eh_address_error AddressError: __ErrorMessage "ADDRESS ERROR", _eh_default|_eh_address_error IllegalInstr: __ErrorMessage "ILLEGAL INSTRUCTION", _eh_default ZeroDivide: __ErrorMessage "ZERO DIVIDE", _eh_default ChkInstr: __ErrorMessage "CHK INSTRUCTION", _eh_default TrapvInstr: __ErrorMessage "TRAPV INSTRUCTION", _eh_default PrivilegeViol: __ErrorMessage "PRIVILEGE VIOLATION", _eh_default Trace: __ErrorMessage "TRACE", _eh_default Line1010Emu: __ErrorMessage "LINE 1010 EMULATOR", _eh_default Line1111Emu: __ErrorMessage "LINE 1111 EMULATOR", _eh_default ErrorExcept: __ErrorMessage "ERROR EXCEPTION", _eh_default ErrorTrap: __ErrorMessage "ERROR TRAP", _eh_default ; --------------------------------------------------------------- ; Import error handler global functions ; --------------------------------------------------------------- ErrorHandler.__global__error_InitConsole equ ErrorHandler+$146 ErrorHandler.__global__errorhandler_SetupVDP equ ErrorHandler+$234 ErrorHandler.__global__console_LoadPalette equ ErrorHandler+$A1C ErrorHandler.__global__console_SetPosAsXY_stack equ ErrorHandler+$A58 ErrorHandler.__global__console_SetPosAsXY equ ErrorHandler+$A5E ErrorHandler.__global__console_GetPosAsXY equ ErrorHandler+$A8A ErrorHandler.__global__console_StartNewLine equ ErrorHandler+$AAC ErrorHandler.__global__console_SetBasePattern equ ErrorHandler+$AD4 ErrorHandler.__global__console_SetWidth equ ErrorHandler+$AE8 ErrorHandler.__global__console_WriteLine_withpattern equ ErrorHandler+$AFE ErrorHandler.__global__console_WriteLine equ ErrorHandler+$B00 ErrorHandler.__global__console_Write equ ErrorHandler+$B04 ErrorHandler.__global__console_WriteLine_formatted equ ErrorHandler+$BB0 ErrorHandler.__global__console_Write_formatted equ ErrorHandler+$BB4 ; --------------------------------------------------------------- ; Error handler external functions (compiled only when used) ; --------------------------------------------------------------- if ref(ErrorHandler.__extern_scrollconsole) ErrorHandler.__extern__scrollconsole: endc if ref(ErrorHandler.__extern__console_only) ErrorHandler.__extern__console_only: dc.l $46FC2700, $4FEFFFF2, $48E7FFFE, $47EF003C jsr ErrorHandler.__global__errorhandler_SetupVDP(pc) jsr ErrorHandler.__global__error_InitConsole(pc) dc.l $4CDF7FFF, $487A0008, $2F2F0012, $4E7560FE endc if ref(ErrorHandler.__extern__vsync) ErrorHandler.__extern__vsync: dc.l $41F900C0, $000444D0, $6BFC44D0, $6AFC4E75 endc ; --------------------------------------------------------------- ; Include error handler binary module ; --------------------------------------------------------------- ErrorHandler: incbin "error/ErrorHandler.bin" ; --------------------------------------------------------------- ; WARNING! ; DO NOT put any data from now on! DO NOT use ROM padding! ; Symbol data should be appended here after ROM is compiled ; by ConvSym utility, otherwise debugger modules won't be able ; to resolve symbol names. ; ---------------------------------------------------------------
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cc/layers/surface_layer_impl.h" #include "cc/debug/debug_colors.h" #include "cc/layers/quad_sink.h" #include "cc/quads/surface_draw_quad.h" namespace cc { SurfaceLayerImpl::SurfaceLayerImpl(LayerTreeImpl* tree_impl, int id) : LayerImpl(tree_impl, id), surface_id_(0) {} SurfaceLayerImpl::~SurfaceLayerImpl() {} scoped_ptr<LayerImpl> SurfaceLayerImpl::CreateLayerImpl( LayerTreeImpl* tree_impl) { return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); } void SurfaceLayerImpl::SetSurfaceId(int surface_id) { if (surface_id_ == surface_id) return; surface_id_ = surface_id; NoteLayerPropertyChanged(); } void SurfaceLayerImpl::PushPropertiesTo(LayerImpl* layer) { LayerImpl::PushPropertiesTo(layer); SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); layer_impl->SetSurfaceId(surface_id_); } void SurfaceLayerImpl::AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) { SharedQuadState* shared_quad_state = quad_sink->UseSharedQuadState(CreateSharedQuadState()); AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); if (!surface_id_) return; scoped_ptr<SurfaceDrawQuad> quad = SurfaceDrawQuad::Create(); gfx::Rect quad_rect(content_bounds()); gfx::Rect visible_quad_rect(quad_rect); quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, surface_id_); quad_sink->MaybeAppend(quad.PassAs<DrawQuad>()); } void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const { *color = DebugColors::SurfaceLayerBorderColor(); *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); } void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const { LayerImpl::AsValueInto(dict); dict->SetInteger("surface_id", surface_id_); } const char* SurfaceLayerImpl::LayerTypeAsString() const { return "cc::SurfaceLayerImpl"; } } // namespace cc
.data dx: .word -1:1 .word 0:1 .word 1:1 .word 0:1 dy: .word 0:1 .word 1:1 .word 0:1 .word -1:1 mat: .space 640 mark: .space 640 .macro readInt(%x) li $v0, 5 syscall move %x, $v0 .end_macro .macro getOffset(%des, %i, %j) sll %des, %i, 4 add %des, %des, %j sll %des, %des, 2 .end_macro .macro getElem(%e, %mat, %i, %j) getOffset(%e, %i, %j) lw %e, %mat(%e) .end_macro .macro setElem(%e, %mat, %i, %j) push($t0) getOffset($t0, %i, %j) sw %e, %mat($t0) pop($t0) .end_macro .macro push(%x) sw %x, 0($sp) addi $sp, $sp, -4 .end_macro .macro pop(%x) addi $sp, $sp, 4 lw %x, 0($sp) .end_macro .macro dfs(%x, %y) push($t0) push($ra) push($a1) push($a0) move $a0, %x move $a1, %y jal dfs pop($a0) pop($a1) pop($ra) pop($t0) .end_macro .text main: readInt($s0) #n -> $s0, m -> $s1, ans -> $s2 readInt($s1) li $t0, 1 for_1_begin: bgt $t0, $s0, for_1_end li $t1, 1 for_2_begin: bgt $t1, $s1, for_2_end readInt($v0) xori $v0, $v0, 1 setElem($v0, mat, $t0, $t1) addi $t1, $t1, 1 j for_2_begin for_2_end: addi $t0, $t0, 1 j for_1_begin for_1_end: readInt($t0) #x0 -> $t0, y0 -> $t1, x1 -> $s3, y1 -> %s4 readInt($t1) readInt($s3) readInt($s4) dfs($t0, $t1) move $a0, $s2 li $v0, 1 syscall li $v0, 10 syscall dfs: bne $a0, $s3, if_1_end #if (x == x1 && y == y1) bne $a1, $s4, if_1_end addi $s2, $s2, 1 jr $ra if_1_end: li $t0, 1 setElem($t0, mark, $a0, $a1) #mark[x][y] = 1 li $t0, 0 for_3_begin: beq $t0, 4, for_3_end sll $t1, $t0, 2 #xx = x + dx[i] -> $t1 lw $t1, dx($t1) add $t1, $t1, $a0 sll $t2, $t0, 2 #yy = y + dy[i] -> $t2 lw $t2, dy($t2) add $t2, $t2, $a1 getElem($t3, mark, $t1, $t2) #if (!mark[xx][yy] && mat[xx][yy]) getElem($t4, mat, $t1, $t2) bne $t3, $zero, if_2_end beq $t4, $zero, if_2_end dfs($t1, $t2) if_2_end: addi $t0, $t0, 1 j for_3_begin for_3_end: setElem($zero, mark, $a0, $a1) #mark[x][y] = 0 jr $ra
INCLUDE "graphics/grafix.inc" SECTION code_clib PUBLIC undrawb PUBLIC _undrawb EXTERN w_pixeladdress ; EXTERN l_cmp ; ; $Id: undrawb.asm,v 1.6 2016-10-13 06:32:03 stefano Exp $ ; ; *********************************************************************** ; ; drawbox Timex hires version ; .undrawb ._undrawb push ix ;save callers ld ix,2 add ix,sp ld l,(ix+8) ld h,(ix+9); x ld a,1 cp h jr c,undrawb_exit ld e,(ix+6); y ld a,maxy cp e jr c,undrawb_exit ; left vertical call pixel_addr call vertical ; right vertical line ld l,(ix+8) ld h,(ix+9); x ld c,(ix+4) ld b,(ix+5); width add hl,bc ld a,1 cp h jr c,next ld e,(ix+6) call pixel_addr call vertical .next ; upper horizontal line ld l,(ix+8) ld h,(ix+9) ; x ld e,(ix+6) ; y call pixel_addr call horizontal ; bottom horizontal line ld l,(ix+8) ld h,(ix+9) ; x ld e,(ix+6) ; y ld a,(ix+2);height add e ld e,a pop af call pixel_addr .horizontal ld c,(ix+4) ld b,(ix+5) ; width .loop3 ld a,(de) and (hl) ld (de),a call incx jr c,undrawb_exit ld a,b or c ret z dec bc jr loop3 .undrawb_exit pop ix ;restore callers ret ; (hl) mask ; de - screen address .incx rrc (hl) ccf ret nc bit 5,d jr nz,first set 5,d or a ret .first res 5,d inc e ld a,e and $1f ret nz scf ret .incy inc d ld a,d and $07 ret nz ld a,d sub $08 ld d,a ld a,e add a,$20 ld e,a ret nc ld a,d add a,$08 ld d,a and 95 cp $58 ccf ret .pixel_addr ld d,0 call w_pixeladdress ld b,a ld a,1 jr z,getout; pixel is at bit 0... .loop1 rlca djnz loop1 .getout xor 255 ld (PIXEL),a ld hl,PIXEL ret .vertical ; vertical line ld b,(ix+2) ; height .loop2 ld a,(de) and (hl) ld (de),a call incy ret c djnz loop2 ret SECTION bss_clib .PIXEL DEFB 0
#include<bits/stdc++.h> using namespace std; #define ll long long int namespace fenwick { ll bit[2000001],n; ll get(ll ind) { ll res=0; while(ind>=1) { res+=bit[ind]; ind-=ind&-ind; } return res; } void upd(ll ind,ll val) { while(ind<=n) { bit[ind]+=val; ind+=ind&-ind; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,q; cin>>n>>q; vector<ll>v(n); fenwick::n=n+1; for(int i=0;i<n;i++) { cin>>v[i]; } for(int i=0;i<q;i++) { ll t; cin>>t; if(t==1) { ll a,b,val; cin>>a>>b>>val; fenwick::upd(a,val); fenwick::upd(b+1,-val); } else { ll pos; cin>>pos; cout<<(v[pos-1]+fenwick::get(pos))<<endl; } } return 0; }
; A205633: Expansion of f(x^3, x^7) in powers of x where f() is Ramanujan's two-variable theta function. ; 1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 mul $0,5 add $0,1 mov $2,3 lpb $0 sub $0,$2 add $2,2 lpe sub $0,1 bin $1,$0 mov $0,$1
include "src/sound/apparition_stalk_the_night/channel1.asm" include "src/sound/apparition_stalk_the_night/channel2.asm" include "src/sound/apparition_stalk_the_night/channel3.asm" include "src/sound/apparition_stalk_the_night/channel4.asm" RumiaTheme:: db $100 - $8E db %100 dw musicChan1RumiaTheme dw musicChan2RumiaTheme dw musicChan3RumiaTheme dw musicChan4RumiaTheme
; A010726: Period 2: repeat (6,10). ; 6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10,6,10 mod $0,2 mov $1,$0 mul $1,4 add $1,6
; A004216: a(n) = floor(log_10(n)). ; 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 add $0,1 log $0,10 mov $1,$0
; A169479: Number of reduced words of length n in Coxeter group on 34 generators S_i with relations (S_i)^2 = (S_i S_j)^33 = I. ; 1,34,1122,37026,1221858,40321314,1330603362,43909910946,1449027061218,47817893020194,1577990469666402,52073685498991266,1718431621466711778,56708243508401488674,1871372035777249126242,61755277180649221165986 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,33 lpe mov $0,$2 div $0,33
section .text ;push all registers except rax %macro pushState 0 push rbx push rcx push rdx push rbp push rdi push rsi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 %endmacro ;pop all registers except rax %macro popState 0 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rsi pop rdi pop rbp pop rdx pop rcx pop rbx %endmacro ;Macro to adjust register for a standard sys_call, because we want in the first argument ;the sys_call number ; rdi -> rsi, rsi->rdx, rdx -> rcx, %macro adjust_to_sys_call 0 mov r8, rcx mov rcx,rdx mov rdx,rsi mov rsi,rdi %endmacro ;--------------------------SYS_CALLS FUNCTIONS--------------------------------; GLOBAL sys_read_call sys_read_call: pushState adjust_to_sys_call ;sys_call read is call number 0 mov rdi,0 int 80h popState ret GLOBAL sys_write_call sys_write_call: pushState adjust_to_sys_call ;sys_call write is call number 1 mov rdi,1 int 80h popState ret GLOBAL sys_put_char_call sys_put_char_call: pushState adjust_to_sys_call ;sys_call put char is call number 2 mov rdi,2 int 80h popState ret GLOBAL sys_print_action_call sys_print_action_call: pushState adjust_to_sys_call ;sys_call print action is call number 3 mov rdi,3 int 80h popState ret GLOBAL sys_print_number_call sys_print_number_call: pushState adjust_to_sys_call ;sys_print_number is call number 4 mov rdi,4 int 80h popState ret GLOBAL sys_change_sound_call sys_change_sound_call: pushState adjust_to_sys_call ;sys_change_sound is call number 5 mov rdi,5 int 80h popState ret GLOBAL sys_put_char_fixed_call sys_put_char_fixed_call: pushState adjust_to_sys_call ;sys_call put char fixed is call number 6 mov rdi,6 int 80h popState ret GLOBAL sys_get_ticks_call sys_get_ticks_call: pushState adjust_to_sys_call ;sys_call get_ticks is call number 10 mov rdi, 10 int 80h popState ret GLOBAL sys_get_last_in_call sys_get_last_in_call: pushState adjust_to_sys_call ;sys_call get last in is call number 11 mov rdi,11 int 80h popState ret GLOBAL sys_get_clock_call sys_get_clock_call: pushState adjust_to_sys_call ;sys_call get_clock is call number 12. mov rdi, 12 int 80h popState ret GLOBAL sys_screen sys_screen: pushState adjust_to_sys_call ;sys call sys_screen is call number 20 mov rdi,20 int 80h popState ret GLOBAL sys_get_memory sys_get_memory: pushState adjust_to_sys_call ;sys call sys_get_memory is call number 45 mov rdi,45 int 80h popState ret GLOBAL sys_mem_free sys_mem_free: pushState adjust_to_sys_call ;sys call sys_mem_free is call number 46 mov rdi,46 int 80h popState ret GLOBAL sys_create_process sys_create_process: pushState adjust_to_sys_call ;sys call sys_create_process is call number 47 mov rdi,47 int 80h popState ret GLOBAL sys_run_process sys_run_process: pushState adjust_to_sys_call ;sys call sys_run_process is call 48 mov rdi, 48 int 80h popState ret GLOBAL sys_kill_process sys_kill_process: pushState adjust_to_sys_call ;sys call sys_kill_process is call 49 mov rdi,49 int 80h popState ret GLOBAL sys_get_pid sys_get_pid: pushState adjust_to_sys_call ;sys call sys_get_pid is call 50 mov rdi,50 int 80h popState ret GLOBAL sys_print_running_procs sys_print_running_procs: pushState adjust_to_sys_call ;sys_print_running_procs is call 51 mov rdi, 51 int 80h popState ret GLOBAL sys_set_priority sys_set_priority: pushState adjust_to_sys_call ;sys_set_priority is call 52 mov rdi, 52 int 80h popState ret GLOBAL sys_set_state sys_set_state: pushState adjust_to_sys_call ;sys_set_state is call 53 mov rdi, 53 int 80h popState ret GLOBAL sys_create_process_params sys_create_process_params: pushState adjust_to_sys_call ;sys_create_process_params is call 54 mov rdi, 54 int 80h popState ret GLOBAL sys_set_stdin sys_set_stdin: pushState adjust_to_sys_call mov rdi, 55 int 80h popState ret GLOBAL sys_set_stdout sys_set_stdout: pushState adjust_to_sys_call mov rdi, 56 int 80h popState ret GLOBAL sys_get_stdin sys_get_stdin: pushState adjust_to_sys_call mov rdi, 57 int 80h popState ret GLOBAL sys_get_stdout sys_get_stdout: pushState adjust_to_sys_call mov rdi, 58 int 80h popState ret GLOBAL sys_create_semaphore sys_create_semaphore: pushState adjust_to_sys_call ;sys call sys_create_semaphore is call 60 mov rdi,60 int 80h popState ret GLOBAL sys_sem_close sys_sem_close: pushState adjust_to_sys_call ;sys call sys_sem_close is call 61 mov rdi,61 int 80h popState ret GLOBAL sys_sem_post sys_sem_post: pushState adjust_to_sys_call ;sys call sys_sem_post is call 62 mov rdi,62 int 80h popState ret GLOBAL sys_sem_wait sys_sem_wait: pushState adjust_to_sys_call ;sys call sys_sem_wait is call 63 mov rdi,63 int 80h popState ret GLOBAL sys_print_sems sys_print_sems: pushState adjust_to_sys_call ;sys call sys_print_sems is call 64 mov rdi,64 int 80h popState ret GLOBAL sys_open_pipe sys_open_pipe: pushState adjust_to_sys_call ;sys call sys_open_pipe is call 75 mov rdi,75 int 80h popState ret GLOBAL sys_close_pipe sys_close_pipe: pushState adjust_to_sys_call ;sys call sys_close_pipe is call 76 mov rdi,76 int 80h popState ret GLOBAL sys_write_pipe sys_write_pipe: pushState adjust_to_sys_call ;sys call sys_write_pipe is call 77 mov rdi,77 int 80h popState ret GLOBAL sys_read_pipe sys_read_pipe: pushState adjust_to_sys_call ;sys call sys_read_pipe is call 78 mov rdi,78 int 80h popState ret GLOBAL sys_print_pipe sys_print_pipe: pushState adjust_to_sys_call ;sys call sys_print_pipe is call 79 mov rdi,79 int 80h popState ret GLOBAL testchoi testchoi: pushState adjust_to_sys_call mov rdi, 120 int 80h popState ret GLOBAL sys_print_mem sys_print_mem: pushState adjust_to_sys_call mov rdi,150 int 80h popState ret
; A016234: Expansion of 1/((1-x)(1-5x)(1-9x)). ; Submitted by Jamie Morken(s1) ; 1,15,166,1650,15631,144585,1320796,11984820,108351661,977606355,8810664226,79357013190,714518294491,6432190529325,57897344158456,521114244398760,4690218934452121,42212924084385495,379921085131051486,3419313608037373530,30773941681625912551,276966071181080966865,2492697620861967471316,22434293488918901089500,201908715906076079043781,1817178815683714557585435,16354611203798580249225946,147191510147412968397818670,1324723637892845446354293811,11922512973866252671058273205 mov $2,1 lpb $0 sub $0,1 add $1,$2 mul $1,5 mul $2,9 add $2,1 lpe add $1,$2 mov $0,$1
#include <KrautPluginPCH.h> #include <Core/Assets/AssetFileHeader.h> #include <KrautPlugin/Resources/KrautTreeResource.h> #include <RendererCore/Material/MaterialResource.h> #include <RendererCore/Meshes/MeshResource.h> #include <RendererCore/Meshes/MeshResourceDescriptor.h> #include <RendererCore/Textures/Texture2DResource.h> #ifdef BUILDSYSTEM_ENABLE_ZSTD_SUPPORT # include <Foundation/IO/CompressedStreamZstd.h> #endif // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezKrautTreeResource, 1, ezRTTIDefaultAllocator<ezKrautTreeResource>); EZ_END_DYNAMIC_REFLECTED_TYPE; EZ_RESOURCE_IMPLEMENT_COMMON_CODE(ezKrautTreeResource); // clang-format on ezKrautTreeResource::ezKrautTreeResource() : ezResource(DoUpdate::OnAnyThread, 1) { m_Details.m_Bounds.SetInvalid(); } ezResourceLoadDesc ezKrautTreeResource::UnloadData(Unload WhatToUnload) { ezResourceLoadDesc res; res.m_State = GetLoadingState(); res.m_uiQualityLevelsDiscardable = GetNumQualityLevelsDiscardable(); res.m_uiQualityLevelsLoadable = GetNumQualityLevelsLoadable(); // we currently can only unload the entire KrautTree // if (WhatToUnload == Unload::AllQualityLevels) { res.m_uiQualityLevelsDiscardable = 0; res.m_uiQualityLevelsLoadable = 0; res.m_State = ezResourceState::Unloaded; } return res; } ezResourceLoadDesc ezKrautTreeResource::UpdateContent(ezStreamReader* Stream) { ezKrautTreeResourceDescriptor desc; ezResourceLoadDesc res; res.m_uiQualityLevelsDiscardable = 0; res.m_uiQualityLevelsLoadable = 0; if (Stream == nullptr) { res.m_State = ezResourceState::LoadedResourceMissing; return res; } // skip the absolute file path data that the standard file reader writes into the stream { ezString sAbsFilePath; (*Stream) >> sAbsFilePath; } ezAssetFileHeader AssetHash; AssetHash.Read(*Stream); if (desc.Load(*Stream).Failed()) { res.m_State = ezResourceState::LoadedResourceMissing; return res; } return CreateResource(std::move(desc)); } void ezKrautTreeResource::UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) { // TODO out_NewMemoryUsage.m_uiMemoryCPU = sizeof(*this); out_NewMemoryUsage.m_uiMemoryGPU = 0; } EZ_RESOURCE_IMPLEMENT_CREATEABLE(ezKrautTreeResource, ezKrautTreeResourceDescriptor) { m_TreeLODs.Clear(); m_Details = descriptor.m_Details; ezHybridArray<ezMaterialResourceHandle, 16> allMaterials; ezStringBuilder sMatName; for (const auto& mat : descriptor.m_Materials) { ezUInt32 uiTexHash = static_cast<ezUInt32>(mat.m_MaterialType); uiTexHash = ezHashingUtils::xxHash32(&mat.m_VariationColor, sizeof(mat.m_VariationColor), uiTexHash); uiTexHash = ezHashingUtils::xxHash32(mat.m_sDiffuseTexture.GetData(), mat.m_sDiffuseTexture.GetElementCount(), uiTexHash); uiTexHash = ezHashingUtils::xxHash32(mat.m_sNormalMapTexture.GetData(), mat.m_sNormalMapTexture.GetElementCount(), uiTexHash); sMatName.Format("KrautMaterial_{0}", uiTexHash); auto hMaterial = ezResourceManager::GetExistingResource<ezMaterialResource>(sMatName); if (!hMaterial.IsValid()) { ezMaterialResourceDescriptor md; switch (mat.m_MaterialType) { case ezKrautMaterialType::Branch: md.m_hBaseMaterial = ezResourceManager::LoadResource<ezMaterialResource>("Kraut/Branch.ezMaterial"); break; case ezKrautMaterialType::Frond: md.m_hBaseMaterial = ezResourceManager::LoadResource<ezMaterialResource>("Kraut/Frond.ezMaterial"); break; case ezKrautMaterialType::Leaf: md.m_hBaseMaterial = ezResourceManager::LoadResource<ezMaterialResource>("Kraut/Leaf.ezMaterial"); break; case ezKrautMaterialType::StaticImpostor: md.m_hBaseMaterial = ezResourceManager::LoadResource<ezMaterialResource>("Kraut/StaticImpostor.ezMaterial"); break; case ezKrautMaterialType::BillboardImpostor: md.m_hBaseMaterial = ezResourceManager::LoadResource<ezMaterialResource>("Kraut/BillboardImpostor.ezMaterial"); break; case ezKrautMaterialType::None: EZ_ASSERT_NOT_IMPLEMENTED; break; } auto& m1 = md.m_Texture2DBindings.ExpandAndGetRef(); m1.m_Name.Assign("BaseTexture"); m1.m_Value = ezResourceManager::LoadResource<ezTexture2DResource>(mat.m_sDiffuseTexture); auto& m2 = md.m_Texture2DBindings.ExpandAndGetRef(); m2.m_Name.Assign("NormalTexture"); m2.m_Value = ezResourceManager::LoadResource<ezTexture2DResource>(mat.m_sNormalMapTexture); auto& p1 = md.m_Parameters.ExpandAndGetRef(); p1.m_Name.Assign("BaseColor"); p1.m_Value = mat.m_VariationColor; hMaterial = ezResourceManager::CreateResource<ezMaterialResource>(sMatName, std::move(md), mat.m_sDiffuseTexture); } allMaterials.PushBack(hMaterial); } ezStringBuilder sResName, sResDesc; for (ezUInt32 lodIdx = 0; lodIdx < descriptor.m_Lods.GetCount(); ++lodIdx) { const auto& lodSrc = descriptor.m_Lods[lodIdx]; auto& lodDst = m_TreeLODs.ExpandAndGetRef(); lodDst.m_LodType = lodSrc.m_LodType; lodDst.m_fMinLodDistance = lodSrc.m_fMinLodDistance; lodDst.m_fMaxLodDistance = lodSrc.m_fMaxLodDistance; ezMeshResourceDescriptor md; auto& buffer = md.MeshBufferDesc(); const ezUInt32 uiNumVertices = lodSrc.m_Vertices.GetCount(); const ezUInt32 uiNumTriangles = lodSrc.m_Triangles.GetCount(); const ezUInt32 uiSubMeshes = lodSrc.m_SubMeshes.GetCount(); buffer.AddStream(ezGALVertexAttributeSemantic::Position, ezGALResourceFormat::XYZFloat); buffer.AddStream(ezGALVertexAttributeSemantic::TexCoord0, ezGALResourceFormat::XYFloat); buffer.AddStream(ezGALVertexAttributeSemantic::TexCoord1, ezGALResourceFormat::XYFloat); buffer.AddStream(ezGALVertexAttributeSemantic::Normal, ezGALResourceFormat::XYZFloat); buffer.AddStream(ezGALVertexAttributeSemantic::Tangent, ezGALResourceFormat::XYZFloat); buffer.AddStream(ezGALVertexAttributeSemantic::Color0, ezGALResourceFormat::RGBAUByteNormalized); buffer.AllocateStreams(uiNumVertices, ezGALPrimitiveTopology::Triangles, uiNumTriangles); for (ezUInt32 v = 0; v < uiNumVertices; ++v) { const auto& vtx = lodSrc.m_Vertices[v]; buffer.SetVertexData<ezVec3>(0, v, vtx.m_vPosition); buffer.SetVertexData<ezVec2>(1, v, ezVec2(vtx.m_vTexCoord.x, vtx.m_vTexCoord.y)); buffer.SetVertexData<ezVec2>(2, v, ezVec2(vtx.m_vTexCoord.z, vtx.m_fAmbientOcclusion)); buffer.SetVertexData<ezVec3>(3, v, vtx.m_vNormal); buffer.SetVertexData<ezVec3>(4, v, vtx.m_vTangent); buffer.SetVertexData<ezColorGammaUB>(5, v, vtx.m_VariationColor); } for (ezUInt32 t = 0; t < uiNumTriangles; ++t) { const auto& tri = lodSrc.m_Triangles[t]; buffer.SetTriangleIndices(t, tri.m_uiVertexIndex[0], tri.m_uiVertexIndex[1], tri.m_uiVertexIndex[2]); } for (ezUInt32 sm = 0; sm < uiSubMeshes; ++sm) { const auto& subMesh = lodSrc.m_SubMeshes[sm]; md.AddSubMesh(subMesh.m_uiNumTriangles, subMesh.m_uiFirstTriangle, subMesh.m_uiMaterialIndex); } md.ComputeBounds(); for (ezUInt32 mat = 0; mat < descriptor.m_Materials.GetCount(); ++mat) { md.SetMaterial(mat, allMaterials[mat].GetResourceID()); } sResName.Format("{0}_{1}_LOD{2}", GetResourceID(), GetCurrentResourceChangeCounter(), lodIdx); sResDesc.Format("{0}_{1}_LOD{2}", GetResourceDescription(), GetCurrentResourceChangeCounter(), lodIdx); lodDst.m_hMesh = ezResourceManager::GetExistingResource<ezMeshResource>(sResName); if (!lodDst.m_hMesh.IsValid()) { lodDst.m_hMesh = ezResourceManager::CreateResource<ezMeshResource>(sResName, std::move(md), sResDesc); } } ezResourceLoadDesc res; res.m_uiQualityLevelsDiscardable = 0; res.m_uiQualityLevelsLoadable = 0; res.m_State = ezResourceState::Loaded; return res; } ////////////////////////////////////////////////////////////////////////// void ezKrautTreeResourceDescriptor::Save(ezStreamWriter& stream0) const { ezUInt8 uiVersion = 12; stream0 << uiVersion; ezUInt8 uiCompressionMode = 0; #ifdef BUILDSYSTEM_ENABLE_ZSTD_SUPPORT uiCompressionMode = 1; ezCompressedStreamWriterZstd stream(&stream0, ezCompressedStreamWriterZstd::Compression::Average); #else ezStreamWriter& stream = stream0; #endif stream0 << uiCompressionMode; const ezUInt8 uiNumLods = m_Lods.GetCount(); stream << uiNumLods; for (ezUInt8 lodIdx = 0; lodIdx < uiNumLods; ++lodIdx) { const auto& lod = m_Lods[lodIdx]; stream << static_cast<ezUInt8>(lod.m_LodType); stream << lod.m_fMinLodDistance; stream << lod.m_fMaxLodDistance; stream << lod.m_Vertices.GetCount(); stream << lod.m_Triangles.GetCount(); stream << lod.m_SubMeshes.GetCount(); for (const auto& vtx : lod.m_Vertices) { stream << vtx.m_vPosition; stream << vtx.m_vTexCoord; stream << vtx.m_vNormal; stream << vtx.m_vTangent; stream << vtx.m_VariationColor; stream << vtx.m_fAmbientOcclusion; } for (const auto& tri : lod.m_Triangles) { stream << tri.m_uiVertexIndex[0]; stream << tri.m_uiVertexIndex[1]; stream << tri.m_uiVertexIndex[2]; } for (const auto& sm : lod.m_SubMeshes) { stream << sm.m_uiFirstTriangle; stream << sm.m_uiNumTriangles; stream << sm.m_uiMaterialIndex; } } const ezUInt8 uiNumMats = m_Materials.GetCount(); stream << uiNumMats; for (const auto& mat : m_Materials) { stream << static_cast<ezUInt8>(mat.m_MaterialType); stream << mat.m_sDiffuseTexture; stream << mat.m_sNormalMapTexture; stream << mat.m_VariationColor; } stream << m_Details.m_Bounds; stream << m_Details.m_vLeafCenter; stream << m_Details.m_fStaticColliderRadius; stream << m_Details.m_sSurfaceResource; #ifdef BUILDSYSTEM_ENABLE_ZSTD_SUPPORT stream.FinishCompressedStream(); ezLog::Dev("Compressed Kraut tree data from {0} KB to {1} KB ({2}%%)", ezArgF((float)stream.GetUncompressedSize() / 1024.0f, 1), ezArgF((float)stream.GetCompressedSize() / 1024.0f, 1), ezArgF(100.0f * stream.GetCompressedSize() / stream.GetUncompressedSize(), 1)); #endif } ezResult ezKrautTreeResourceDescriptor::Load(ezStreamReader& stream0) { ezUInt8 uiVersion = 0; stream0 >> uiVersion; if (uiVersion != 12) return EZ_FAILURE; ezUInt8 uiCompressionMode = 0; stream0 >> uiCompressionMode; ezStreamReader* pCompressor = &stream0; #ifdef BUILDSYSTEM_ENABLE_ZSTD_SUPPORT ezCompressedStreamReaderZstd decompressorZstd; #endif switch (uiCompressionMode) { case 0: break; case 1: #ifdef BUILDSYSTEM_ENABLE_ZSTD_SUPPORT decompressorZstd.SetInputStream(&stream0); pCompressor = &decompressorZstd; break; #else ezLog::Error("Kraut tree is compressed with zstandard, but support for this compressor is not compiled in."); return EZ_FAILURE; #endif default: ezLog::Error("Kraut tree is compressed with an unknown algorithm."); return EZ_FAILURE; } ezStreamReader& stream = *pCompressor; ezUInt8 uiNumLods = 0; stream >> uiNumLods; for (ezUInt8 lodIdx = 0; lodIdx < uiNumLods; ++lodIdx) { auto& lod = m_Lods.ExpandAndGetRef(); ezUInt8 lodType; stream >> lodType; lod.m_LodType = static_cast<ezKrautLodType>(lodType); stream >> lod.m_fMinLodDistance; stream >> lod.m_fMaxLodDistance; ezUInt32 numVertices, numTriangles, numSubMeshes; stream >> numVertices; stream >> numTriangles; stream >> numSubMeshes; lod.m_Vertices.SetCountUninitialized(numVertices); lod.m_Triangles.SetCountUninitialized(numTriangles); lod.m_SubMeshes.SetCount(numSubMeshes); // initialize this one because of the material handle for (auto& vtx : lod.m_Vertices) { stream >> vtx.m_vPosition; stream >> vtx.m_vTexCoord; stream >> vtx.m_vNormal; stream >> vtx.m_vTangent; stream >> vtx.m_VariationColor; stream >> vtx.m_fAmbientOcclusion; } for (auto& tri : lod.m_Triangles) { stream >> tri.m_uiVertexIndex[0]; stream >> tri.m_uiVertexIndex[1]; stream >> tri.m_uiVertexIndex[2]; } for (auto& sm : lod.m_SubMeshes) { stream >> sm.m_uiFirstTriangle; stream >> sm.m_uiNumTriangles; stream >> sm.m_uiMaterialIndex; } } ezUInt8 uiNumMats = 0; ; stream >> uiNumMats; m_Materials.SetCount(uiNumMats); for (auto& mat : m_Materials) { ezUInt8 matType = 0; stream >> matType; mat.m_MaterialType = static_cast<ezKrautMaterialType>(matType); stream >> mat.m_sDiffuseTexture; stream >> mat.m_sNormalMapTexture; stream >> mat.m_VariationColor; } stream >> m_Details.m_Bounds; stream >> m_Details.m_vLeafCenter; stream >> m_Details.m_fStaticColliderRadius; stream >> m_Details.m_sSurfaceResource; return EZ_SUCCESS; }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2015 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; gf_4vect_mad_sse(len, vec, vec_i, mul_array, src, dest); ;;; %include "reg_sizes.asm" %define PS 8 %ifidn __OUTPUT_FORMAT__, win64 %define arg0 rcx %define arg0.w ecx %define arg1 rdx %define arg2 r8 %define arg3 r9 %define arg4 r12 %define arg5 r15 %define tmp r11 %define tmp2 r10 %define tmp3 r13 %define return rax %define return.w eax %define stack_size 16*10 + 3*8 %define arg(x) [rsp + stack_size + PS + PS*x] %define func(x) proc_frame x %macro FUNC_SAVE 0 sub rsp, stack_size movdqa [rsp+16*0],xmm6 movdqa [rsp+16*1],xmm7 movdqa [rsp+16*2],xmm8 movdqa [rsp+16*3],xmm9 movdqa [rsp+16*4],xmm10 movdqa [rsp+16*5],xmm11 movdqa [rsp+16*6],xmm12 movdqa [rsp+16*7],xmm13 movdqa [rsp+16*8],xmm14 movdqa [rsp+16*9],xmm15 save_reg r12, 10*16 + 0*8 save_reg r13, 10*16 + 1*8 save_reg r15, 10*16 + 2*8 end_prolog mov arg4, arg(4) mov arg5, arg(5) %endmacro %macro FUNC_RESTORE 0 movdqa xmm6, [rsp+16*0] movdqa xmm7, [rsp+16*1] movdqa xmm8, [rsp+16*2] movdqa xmm9, [rsp+16*3] movdqa xmm10, [rsp+16*4] movdqa xmm11, [rsp+16*5] movdqa xmm12, [rsp+16*6] movdqa xmm13, [rsp+16*7] movdqa xmm14, [rsp+16*8] movdqa xmm15, [rsp+16*9] mov r12, [rsp + 10*16 + 0*8] mov r13, [rsp + 10*16 + 1*8] mov r15, [rsp + 10*16 + 2*8] add rsp, stack_size %endmacro %elifidn __OUTPUT_FORMAT__, elf64 %define arg0 rdi %define arg0.w edi %define arg1 rsi %define arg2 rdx %define arg3 rcx %define arg4 r8 %define arg5 r9 %define tmp r11 %define tmp2 r10 %define tmp3 r12 %define return rax %define return.w eax %define func(x) x: %macro FUNC_SAVE 0 push r12 %endmacro %macro FUNC_RESTORE 0 pop r12 %endmacro %endif ;;; gf_4vect_mad_sse(len, vec, vec_i, mul_array, src, dest) %define len arg0 %define len.w arg0.w %define vec arg1 %define vec_i arg2 %define mul_array arg3 %define src arg4 %define dest1 arg5 %define pos return %define pos.w return.w %define dest2 mul_array %define dest3 tmp2 %define dest4 vec_i %ifndef EC_ALIGNED_ADDR ;;; Use Un-aligned load/store %define XLDR movdqu %define XSTR movdqu %else ;;; Use Non-temporal load/stor %ifdef NO_NT_LDST %define XLDR movdqa %define XSTR movdqa %else %define XLDR movntdqa %define XSTR movntdq %endif %endif default rel [bits 64] section .text %define xmask0f xmm15 %define xgft3_hi xmm14 %define xgft4_hi xmm13 %define xgft4_lo xmm12 %define x0 xmm0 %define xtmpa xmm1 %define xtmph1 xmm2 %define xtmpl1 xmm3 %define xtmph2 xmm4 %define xtmpl2 xmm5 %define xtmph3 xmm6 %define xtmpl3 xmm7 %define xtmph4 xmm8 %define xtmpl4 xmm9 %define xd1 xmm10 %define xd2 xmm11 %define xd3 xtmph1 %define xd4 xtmpl1 align 16 global gf_4vect_mad_sse:function func(gf_4vect_mad_sse) FUNC_SAVE sub len, 16 jl .return_fail xor pos, pos movdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte mov tmp, vec sal vec_i, 5 ;Multiply by 32 lea tmp3, [mul_array + vec_i] sal tmp, 6 ;Multiply by 64 movdqu xgft3_hi, [tmp3+tmp+16] ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0} sal vec, 5 ;Multiply by 32 add tmp, vec movdqu xgft4_lo, [tmp3+tmp] ;Load array Dx{00}, Dx{01}, Dx{02}, ... movdqu xgft4_hi, [tmp3+tmp+16] ; " Dx{00}, Dx{10}, Dx{20}, ... , Dx{f0} mov dest2, [dest1+PS] ; reuse mul_array mov dest3, [dest1+2*PS] mov dest4, [dest1+3*PS] ; reuse vec_i mov dest1, [dest1] .loop16: XLDR x0, [src+pos] ;Get next source vector movdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0} movdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ... movdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0} movdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ... movdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ... movdqa xtmph3, xgft3_hi movdqa xtmpl4, xgft4_lo movdqa xtmph4, xgft4_hi XLDR xd1, [dest1+pos] ;Get next dest vector XLDR xd2, [dest2+pos] ;Get next dest vector movdqa xtmpa, x0 ;Keep unshifted copy of src psraw x0, 4 ;Shift to put high nibble into bits 4-0 pand x0, xmask0f ;Mask high src nibble in bits 4-0 pand xtmpa, xmask0f ;Mask low src nibble in bits 4-0 ; dest1 pshufb xtmph1, x0 ;Lookup mul table of high nibble pshufb xtmpl1, xtmpa ;Lookup mul table of low nibble pxor xtmph1, xtmpl1 ;GF add high and low partials pxor xd1, xtmph1 XLDR xd3, [dest3+pos] ;Reuse xtmph1, Get next dest vector XLDR xd4, [dest4+pos] ;Reuse xtmpl1, Get next dest vector ; dest2 pshufb xtmph2, x0 ;Lookup mul table of high nibble pshufb xtmpl2, xtmpa ;Lookup mul table of low nibble pxor xtmph2, xtmpl2 ;GF add high and low partials pxor xd2, xtmph2 ; dest3 pshufb xtmph3, x0 ;Lookup mul table of high nibble pshufb xtmpl3, xtmpa ;Lookup mul table of low nibble pxor xtmph3, xtmpl3 ;GF add high and low partials pxor xd3, xtmph3 ; dest4 pshufb xtmph4, x0 ;Lookup mul table of high nibble pshufb xtmpl4, xtmpa ;Lookup mul table of low nibble pxor xtmph4, xtmpl4 ;GF add high and low partials pxor xd4, xtmph4 XSTR [dest1+pos], xd1 ;Store result XSTR [dest2+pos], xd2 ;Store result XSTR [dest3+pos], xd3 ;Store result XSTR [dest4+pos], xd4 ;Store result add pos, 16 ;Loop on 16 bytes at a time cmp pos, len jle .loop16 lea tmp, [len + 16] cmp pos, tmp je .return_pass .lessthan16: ;; Tail len ;; Do one more overlap pass mov tmp, len ;Overlapped offset length-16 XLDR x0, [src+tmp] ;Get next source vector movdqu xtmph1, [tmp3+16] ; " Ax{00}, Ax{10}, Ax{20}, ... , Ax{f0} movdqu xtmpl1, [tmp3] ;Load array Ax{00}, Ax{01}, Ax{02}, ... movdqu xtmph2, [tmp3+vec+16] ; " Bx{00}, Bx{10}, Bx{20}, ... , Bx{f0} movdqu xtmpl2, [tmp3+vec] ;Load array Bx{00}, Bx{01}, Bx{02}, ... movdqu xtmpl3, [tmp3+2*vec] ;Load array Cx{00}, Cx{01}, Cx{02}, ... XLDR xd1, [dest1+tmp] ;Get next dest vector XLDR xd2, [dest2+tmp] ;Get next dest vector XLDR xtmph4, [dest3+tmp] ;Reuse xtmph1. Get next dest vector sub len, pos movdqa xtmpl4, [constip16] ;Load const of i + 16 pinsrb xtmph3, len.w, 15 pshufb xtmph3, xmask0f ;Broadcast len to all bytes pcmpgtb xtmph3, xtmpl4 XLDR xtmpl4, [dest4+tmp] ;Get next dest vector movdqa xtmpa, x0 ;Keep unshifted copy of src psraw x0, 4 ;Shift to put high nibble into bits 4-0 pand x0, xmask0f ;Mask high src nibble in bits 4-0 pand xtmpa, xmask0f ;Mask low src nibble in bits 4-0 ; dest1 pshufb xtmph1, x0 ;Lookup mul table of high nibble pshufb xtmpl1, xtmpa ;Lookup mul table of low nibble pxor xtmph1, xtmpl1 ;GF add high and low partials pand xtmph1, xtmph3 pxor xd1, xtmph1 ; dest2 pshufb xtmph2, x0 ;Lookup mul table of high nibble pshufb xtmpl2, xtmpa ;Lookup mul table of low nibble pxor xtmph2, xtmpl2 ;GF add high and low partials pand xtmph2, xtmph3 pxor xd2, xtmph2 ; dest3 pshufb xgft3_hi, x0 ;Lookup mul table of high nibble pshufb xtmpl3, xtmpa ;Lookup mul table of low nibble pxor xgft3_hi, xtmpl3 ;GF add high and low partials pand xgft3_hi, xtmph3 pxor xtmph4, xgft3_hi ; dest4 pshufb xgft4_hi, x0 ;Lookup mul table of high nibble pshufb xgft4_lo, xtmpa ;Lookup mul table of low nibble pxor xgft4_hi, xgft4_lo ;GF add high and low partials pand xgft4_hi, xtmph3 pxor xtmpl4, xgft4_hi XSTR [dest1+tmp], xd1 ;Store result XSTR [dest2+tmp], xd2 ;Store result XSTR [dest3+tmp], xtmph4 ;Store result XSTR [dest4+tmp], xtmpl4 ;Store result .return_pass: FUNC_RESTORE mov return, 0 ret .return_fail: FUNC_RESTORE mov return, 1 ret endproc_frame section .data align 16 mask0f: ddq 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f constip16: ddq 0xf0f1f2f3f4f5f6f7f8f9fafbfcfdfeff ;;; func core, ver, snum slversion gf_4vect_mad_sse, 00, 01, 0209
icl '../os/symbols.asm' org BOOTADDR lda #0 sta ROS7 lda #2 ldx #OS_SET_VIDEO_MODE jsr OS_CALL mwa DISPLAY_START VRAM_TO_RAM jsr lib_vram_to_ram ldy #0 copy: lda message, y cmp #255 beq stop sta (RAM_TO_VRAM), y iny bne copy stop: jmp stop message: .by "Hello world!!!!", 255 icl '../os/stdlib.asm'
; A112063: Positive integers i for which A112049(i) == 3. ; 11,12,23,36,47,48,71,72,83,96,107,108,131,132,143,156,167,168,191,192,203,216,227,228,251,252,263,276,287,288,311,312,323,336,347,348,371,372,383,396,407,408,431,432,443,456,467,468,491,492,503,516,527 lpb $0 mov $2,$0 sub $2,1 cal $2,112133 ; First differences of A112063. sub $0,1 add $1,$2 lpe add $1,11
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r14 push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x36d1, %r10 nop dec %r14 mov $0x6162636465666768, %r12 movq %r12, %xmm0 movups %xmm0, (%r10) nop and %r11, %r11 lea addresses_WC_ht+0xdf1d, %rsi lea addresses_WC_ht+0x13d01, %rdi nop nop nop inc %rbx mov $91, %rcx rep movsq nop nop nop nop nop sub %rsi, %rsi lea addresses_WC_ht+0x31b1, %rbx nop nop mfence movl $0x61626364, (%rbx) sub %r12, %r12 lea addresses_WT_ht+0x1e081, %r12 nop and $15594, %rcx mov (%r12), %ebx cmp %rbx, %rbx lea addresses_WT_ht+0xc3b1, %r10 nop nop cmp %r14, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 movups %xmm3, (%r10) nop and %rdi, %rdi lea addresses_WT_ht+0xf3b1, %r11 nop nop inc %rdi mov $0x6162636465666768, %r12 movq %r12, (%r11) sub %rbx, %rbx lea addresses_A_ht+0xdfb1, %rsi lea addresses_normal_ht+0x147b1, %rdi nop nop nop nop sub $13485, %r11 mov $14, %rcx rep movsq nop nop nop sub %r12, %r12 lea addresses_normal_ht+0xfd86, %rsi lea addresses_WC_ht+0x11531, %rdi inc %r11 mov $98, %rcx rep movsq nop nop nop inc %rdi lea addresses_A_ht+0xccb1, %rbx clflush (%rbx) nop dec %r11 movl $0x61626364, (%rbx) nop nop xor %r11, %r11 lea addresses_D_ht+0x19f71, %rsi nop nop nop dec %rcx movw $0x6162, (%rsi) nop nop nop nop sub $54870, %r11 lea addresses_WC_ht+0xf221, %rsi lea addresses_WT_ht+0x15eb1, %rdi clflush (%rdi) nop xor %r10, %r10 mov $88, %rcx rep movsb nop nop nop cmp $1601, %rsi lea addresses_A_ht+0x6f59, %rsi lea addresses_A_ht+0x103b1, %rdi nop nop nop xor $34075, %r10 mov $99, %rcx rep movsw nop and $32297, %rsi lea addresses_normal_ht+0x13b31, %rsi lea addresses_WC_ht+0x4fb1, %rdi nop nop nop nop add $4868, %r12 mov $78, %rcx rep movsl nop nop nop nop cmp %r11, %r11 pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r8 push %rcx push %rdx push %rsi // Faulty Load lea addresses_US+0x1bbb1, %rdx clflush (%rdx) nop xor %r11, %r11 mov (%rdx), %si lea oracles, %r13 and $0xff, %rsi shlq $12, %rsi mov (%r13,%rsi,1), %rsi pop %rsi pop %rdx pop %rcx pop %r8 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16}} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}} {'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 0, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D_ht', 'AVXalign': True, 'size': 2}} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "SoftMP3" #include <utils/Log.h> #include "SoftMP3.h" #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaDefs.h> #include "include/pvmp3decoder_api.h" namespace android { template<class T> static void InitOMXParams(T *params) { params->nSize = sizeof(T); params->nVersion.s.nVersionMajor = 1; params->nVersion.s.nVersionMinor = 0; params->nVersion.s.nRevision = 0; params->nVersion.s.nStep = 0; } SoftMP3::SoftMP3( const char *name, const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData, OMX_COMPONENTTYPE **component) : SimpleSoftOMXComponent(name, callbacks, appData, component), mConfig(new tPVMP3DecoderExternal), mDecoderBuf(NULL), mAnchorTimeUs(0), mNumFramesOutput(0), mNumChannels(2), mSamplingRate(44100), mSignalledError(false), mSawInputEos(false), mSignalledOutputEos(false), mOutputPortSettingsChange(NONE) { initPorts(); initDecoder(); } SoftMP3::~SoftMP3() { if (mDecoderBuf != NULL) { free(mDecoderBuf); mDecoderBuf = NULL; } delete mConfig; mConfig = NULL; } void SoftMP3::initPorts() { OMX_PARAM_PORTDEFINITIONTYPE def; InitOMXParams(&def); def.nPortIndex = 0; def.eDir = OMX_DirInput; def.nBufferCountMin = kNumBuffers; def.nBufferCountActual = def.nBufferCountMin; def.nBufferSize = 8192; def.bEnabled = OMX_TRUE; def.bPopulated = OMX_FALSE; def.eDomain = OMX_PortDomainAudio; def.bBuffersContiguous = OMX_FALSE; def.nBufferAlignment = 1; def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_MPEG); def.format.audio.pNativeRender = NULL; def.format.audio.bFlagErrorConcealment = OMX_FALSE; def.format.audio.eEncoding = OMX_AUDIO_CodingMP3; addPort(def); def.nPortIndex = 1; def.eDir = OMX_DirOutput; def.nBufferCountMin = kNumBuffers; def.nBufferCountActual = def.nBufferCountMin; def.nBufferSize = kOutputBufferSize; def.bEnabled = OMX_TRUE; def.bPopulated = OMX_FALSE; def.eDomain = OMX_PortDomainAudio; def.bBuffersContiguous = OMX_FALSE; def.nBufferAlignment = 2; def.format.audio.cMIMEType = const_cast<char *>("audio/raw"); def.format.audio.pNativeRender = NULL; def.format.audio.bFlagErrorConcealment = OMX_FALSE; def.format.audio.eEncoding = OMX_AUDIO_CodingPCM; addPort(def); } void SoftMP3::initDecoder() { mConfig->equalizerType = flat; mConfig->crcEnabled = false; uint32_t memRequirements = pvmp3_decoderMemRequirements(); mDecoderBuf = malloc(memRequirements); pvmp3_InitDecoder(mConfig, mDecoderBuf); mIsFirst = true; } void *SoftMP3::memsetSafe(OMX_BUFFERHEADERTYPE *outHeader, int c, size_t len) { if (len > outHeader->nAllocLen) { ALOGE("memset buffer too small: got %u, expected %zu", outHeader->nAllocLen, len); android_errorWriteLog(0x534e4554, "29422022"); notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); mSignalledError = true; return NULL; } return memset(outHeader->pBuffer, c, len); } OMX_ERRORTYPE SoftMP3::internalGetParameter( OMX_INDEXTYPE index, OMX_PTR params) { switch (index) { case OMX_IndexParamAudioPcm: { OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams = (OMX_AUDIO_PARAM_PCMMODETYPE *)params; if (!isValidOMXParam(pcmParams)) { return OMX_ErrorBadParameter; } if (pcmParams->nPortIndex > 1) { return OMX_ErrorUndefined; } pcmParams->eNumData = OMX_NumericalDataSigned; pcmParams->eEndian = OMX_EndianBig; pcmParams->bInterleaved = OMX_TRUE; pcmParams->nBitPerSample = 16; pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear; pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF; pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF; pcmParams->nChannels = mNumChannels; pcmParams->nSamplingRate = mSamplingRate; return OMX_ErrorNone; } case OMX_IndexParamAudioMp3: { OMX_AUDIO_PARAM_MP3TYPE *mp3Params = (OMX_AUDIO_PARAM_MP3TYPE *)params; if (!isValidOMXParam(mp3Params)) { return OMX_ErrorBadParameter; } if (mp3Params->nPortIndex > 1) { return OMX_ErrorUndefined; } mp3Params->nChannels = mNumChannels; mp3Params->nBitRate = 0 /* unknown */; mp3Params->nSampleRate = mSamplingRate; // other fields are encoder-only return OMX_ErrorNone; } default: return SimpleSoftOMXComponent::internalGetParameter(index, params); } } OMX_ERRORTYPE SoftMP3::internalSetParameter( OMX_INDEXTYPE index, const OMX_PTR params) { switch (index) { case OMX_IndexParamStandardComponentRole: { const OMX_PARAM_COMPONENTROLETYPE *roleParams = (const OMX_PARAM_COMPONENTROLETYPE *)params; if (!isValidOMXParam(roleParams)) { return OMX_ErrorBadParameter; } if (strncmp((const char *)roleParams->cRole, "audio_decoder.mp3", OMX_MAX_STRINGNAME_SIZE - 1)) { return OMX_ErrorUndefined; } return OMX_ErrorNone; } case OMX_IndexParamAudioPcm: { const OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams = (const OMX_AUDIO_PARAM_PCMMODETYPE *)params; if (!isValidOMXParam(pcmParams)) { return OMX_ErrorBadParameter; } if (pcmParams->nPortIndex != 1) { return OMX_ErrorUndefined; } mNumChannels = pcmParams->nChannels; mSamplingRate = pcmParams->nSamplingRate; return OMX_ErrorNone; } default: return SimpleSoftOMXComponent::internalSetParameter(index, params); } } void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { if (mSignalledError || mOutputPortSettingsChange != NONE) { return; } List<BufferInfo *> &inQueue = getPortQueue(0); List<BufferInfo *> &outQueue = getPortQueue(1); while ((!inQueue.empty() || (mSawInputEos && !mSignalledOutputEos)) && !outQueue.empty()) { BufferInfo *inInfo = NULL; OMX_BUFFERHEADERTYPE *inHeader = NULL; if (!inQueue.empty()) { inInfo = *inQueue.begin(); inHeader = inInfo->mHeader; } BufferInfo *outInfo = *outQueue.begin(); OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; outHeader->nFlags = 0; if (inHeader) { if (inHeader->nOffset == 0 && inHeader->nFilledLen) { mAnchorTimeUs = inHeader->nTimeStamp; mNumFramesOutput = 0; } if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { mSawInputEos = true; } mConfig->pInputBuffer = inHeader->pBuffer + inHeader->nOffset; mConfig->inputBufferCurrentLength = inHeader->nFilledLen; } else { mConfig->pInputBuffer = NULL; mConfig->inputBufferCurrentLength = 0; } mConfig->inputBufferMaxLength = 0; mConfig->inputBufferUsedLength = 0; mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); if ((int32)outHeader->nAllocLen < mConfig->outputFrameSize) { ALOGE("input buffer too small: got %u, expected %u", outHeader->nAllocLen, mConfig->outputFrameSize); android_errorWriteLog(0x534e4554, "27793371"); notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); mSignalledError = true; return; } mConfig->pOutputBuffer = reinterpret_cast<int16_t *>(outHeader->pBuffer); ERROR_CODE decoderErr; if ((decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf)) != NO_DECODING_ERROR) { ALOGV("mp3 decoder returned error %d", decoderErr); if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR && decoderErr != SIDE_INFO_ERROR) { ALOGE("mp3 decoder returned error %d", decoderErr); notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL); mSignalledError = true; return; } if (mConfig->outputFrameSize == 0) { mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); } if (decoderErr == NO_ENOUGH_MAIN_DATA_ERROR && mSawInputEos) { if (!mIsFirst) { // pad the end of the stream with 529 samples, since that many samples // were trimmed off the beginning when decoding started outHeader->nOffset = 0; outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); if (!memsetSafe(outHeader, 0, outHeader->nFilledLen)) { return; } } outHeader->nFlags = OMX_BUFFERFLAG_EOS; mSignalledOutputEos = true; } else { // This is recoverable, just ignore the current frame and // play silence instead. // TODO: should we skip silence (and consume input data) // if mIsFirst is true as we may not have a valid // mConfig->samplingRate and mConfig->num_channels? ALOGV_IF(mIsFirst, "insufficient data for first frame, sending silence"); if (!memsetSafe(outHeader, 0, mConfig->outputFrameSize * sizeof(int16_t))) { return; } if (inHeader) { mConfig->inputBufferUsedLength = inHeader->nFilledLen; } } } else if (mConfig->samplingRate != mSamplingRate || mConfig->num_channels != mNumChannels) { mSamplingRate = mConfig->samplingRate; mNumChannels = mConfig->num_channels; notify(OMX_EventPortSettingsChanged, 1, 0, NULL); mOutputPortSettingsChange = AWAITING_DISABLED; return; } if (mIsFirst) { mIsFirst = false; // The decoder delay is 529 samples, so trim that many samples off // the start of the first output buffer. This essentially makes this // decoder have zero delay, which the rest of the pipeline assumes. outHeader->nOffset = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset; } else if (!mSignalledOutputEos) { outHeader->nOffset = 0; outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t); } outHeader->nTimeStamp = mAnchorTimeUs + (mNumFramesOutput * 1000000ll) / mSamplingRate; if (inHeader) { CHECK_GE(inHeader->nFilledLen, mConfig->inputBufferUsedLength); inHeader->nOffset += mConfig->inputBufferUsedLength; inHeader->nFilledLen -= mConfig->inputBufferUsedLength; if (inHeader->nFilledLen == 0) { inInfo->mOwnedByUs = false; inQueue.erase(inQueue.begin()); inInfo = NULL; notifyEmptyBufferDone(inHeader); inHeader = NULL; } } mNumFramesOutput += mConfig->outputFrameSize / mNumChannels; outInfo->mOwnedByUs = false; outQueue.erase(outQueue.begin()); outInfo = NULL; notifyFillBufferDone(outHeader); outHeader = NULL; } } void SoftMP3::onPortFlushCompleted(OMX_U32 portIndex) { if (portIndex == 0) { // Make sure that the next buffer output does not still // depend on fragments from the last one decoded. pvmp3_InitDecoder(mConfig, mDecoderBuf); mIsFirst = true; mSignalledError = false; mSawInputEos = false; mSignalledOutputEos = false; } } void SoftMP3::onPortEnableCompleted(OMX_U32 portIndex, bool enabled) { if (portIndex != 1) { return; } switch (mOutputPortSettingsChange) { case NONE: break; case AWAITING_DISABLED: { CHECK(!enabled); mOutputPortSettingsChange = AWAITING_ENABLED; break; } default: { CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED); CHECK(enabled); mOutputPortSettingsChange = NONE; break; } } } void SoftMP3::onReset() { pvmp3_InitDecoder(mConfig, mDecoderBuf); mIsFirst = true; mSignalledError = false; mSawInputEos = false; mSignalledOutputEos = false; mOutputPortSettingsChange = NONE; } } // namespace android android::SoftOMXComponent *createSoftOMXComponent( const char *name, const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData, OMX_COMPONENTTYPE **component) { return new android::SoftMP3(name, callbacks, appData, component); }
.size 8000 .text@100 jp lbegin .data@143 80 .text@150 lbegin: xor a, a ldff(26), a ld a, 80 ldff(26), a ld a, 77 ldff(24), a ld a, 11 ldff(25), a ld a, 80 ldff(11), a ld a, 80 ldff(12), a ld a, c0 ldff(13), a ld a, 87 ldff(14), a ld b, 81 lwaitpos: dec b jrnz lwaitpos ld a, 80 lmodulate: xor a, 40 ldff(12), a ld b, a ld a, 80 ldff(14), a ld a, b ld b, 20 lwaitperiod: dec b jrnz lwaitperiod jr lmodulate