感染艾滋病有什么症状| 化疗之后吃什么好| 什么是耳石症| 临幕是什么意思| 直辖市市长是什么级别| 知了猴什么时候结束| 梦见办酒席是什么意思| 湿疹什么样子| 不作为是什么意思| ag什么意思| 狮子座是什么星座| 藠头是什么菜| 月亮什么颜色| 吃什么补铁快| 喘不上气是什么原因| 红参适合什么人吃| 香油是什么油| 因果关系是什么意思| 胸围110是什么罩杯| whatsapp是什么| 盍是什么意思| 甲状腺球蛋白抗体低说明什么| 1975属什么生肖| 什么是烂桃花| 化石是什么| 脑供血不足什么症状| 羊水穿刺是查什么的| 人为什么要呼吸| 小叶增生是什么症状| 颈椎病头晕吃什么药| 绞股蓝有什么功效| 梦见老公出轨预示什么| 孟德是什么意思| 小野猫是什么意思| bq是什么意思| 办理港澳通行证需要带什么证件| 人做梦是什么原因| 吃什么补记忆力最快| 僵尸是什么意思| 火箭是干什么用的| ppb是什么单位| 仿制药是什么意思| 子宫下垂吃什么药| 乳房边缘一按就疼是什么原因| 孟德是什么意思| 胃火吃什么中成药| 吃什么长胖| 公元500年是什么朝代| 九二共识是什么| 170是什么尺码| 阴囊潮湿吃什么中成药| 鸡腿炖什么好吃| 1935年属什么生肖| 精神病的前兆是什么| 肛门痒痒的是什么原因| 快闪是什么意思| od值是什么| 看见蝙蝠有什么预兆| 南京有什么好玩的| 1978年五行属什么| 山楂和什么一起泡水喝| 什么瓜不能吃| 海豹油有什么作用| 掉头发缺什么维生素| 胃酸烧心吃什么药| 喝酒吃头孢有什么反应| 肠胀气是什么原因引起的| 什么是孝| 口臭睡觉流口水什么原因| 亥时属什么生肖| 双侧肋膈角锐利是什么意思| 谷氨酸钠是什么添加剂| 开天门是什么意思| 白酒优级和一级有什么区别| 壁虎为什么是五毒之一| 半身不遂是什么原因引起的| 神经性耳鸣有什么症状| 二尖瓣轻度反流是什么意思| 胸围85是什么罩杯| 多普勒超声检查是什么| 双职工是什么意思| 什么是碳水化合物食物| 老是想吐是什么原因| 黑枸杞泡水是什么颜色| 健忘是什么意思| 痛点是什么意思| 皮肤发黄是什么原因| 什么原因导致心肌缺血| 梦见一条小蛇是什么意思| 低血糖吃什么| 沉香手串有什么好处| 甲钴胺治疗什么病| 乌龟肠胃炎用什么药| 肚脐眼下面是什么部位| 斯德哥尔摩是什么意思| 北京的市花是什么花| 多彩的什么| 退化是什么意思| 什么叫多动症| 什么叫代孕| 痒是什么原因引起的| 回眸一笑百媚生什么意思| Ecmo医学上是什么意思| 膈应人是什么意思| 麦冬有什么作用| 火是什么意思| 胎盘低置状态是什么意思| 玉米须加什么治痛风| 小孩子包皮挂什么科| 什么是靶向治疗| 下午一点到三点是什么时辰| 经期适合什么运动| 太阳像什么的比喻句| 鼻子里面痒是什么原因| 尿精是什么原因造成的| 藏青色是什么颜色| 甲状腺结节是什么| 十一月一日是什么星座| 窦性心律左室高电压什么意思| 肠炎有什么表现| 清华大学是什么级别| 乐加是什么药| 2009年是什么生肖年| 为什么会有同性恋| 血浆蛋白是什么| 看心理医生挂什么科| 威图手机为什么那么贵| 霍光和卫子夫什么关系| 伤疤好了变黑了是什么原因| 七月四号是什么星座| 喉咙干痒咳嗽吃什么药| 维c不能和什么一起吃| 平安顺遂什么意思| 2026年是什么命| 预防脑出血吃什么药| 数字五行属什么| 名字五行属什么| 九月二十二是什么星座| 622是什么星座| b族维生素什么时候吃效果最好| 手淫过度有什么症状| 36什么意思| 无创是检查什么| 初中老师需要什么学历| 牛顿三大定律是什么| 心电图伪差是什么意思| 玮是什么意思| 什么牛什么毛| 大便潜血弱阳性是什么原因| 七月七日是什么节日| 右手中指痛什么预兆| 离婚要什么手续和证件| 席梦思床垫什么牌子好| 今天是什么生肖日| 扎巴依是什么意思| 肝功能查什么| 知了吃什么食物| 1981年是什么年| 什么叫窝沟封闭| 肠胃不好适合喝什么茶| 三尖瓣反流是什么意思| 忆苦思甜下一句是什么| 胎儿宫内窘迫是什么意思| viscose是什么面料| 孩子老是流鼻血是什么原因| 丿是什么字| 三千烦恼丝什么意思| 2月15日是什么星座| 尊巴是什么| 窦性早搏是什么意思| 天使长什么样| 衪是什么意思| 君子兰什么季节开花| 摸摸头是什么意思| 燕窝什么时候吃最好| 举贤不避亲什么意思| 月经期间喝酒有什么危害| 不疑有他什么意思| 梦见打仗是什么意思| 异地结婚登记需要什么证件| 小孩智力发育迟缓挂什么科| 2010属什么生肖| qcy是什么牌子| 柏拉图之恋是什么意思| 细菌性阴道炎用什么药效果好| 层出不穷什么意思| 妇科假丝酵母菌是什么病| 吗丁啉是什么药| 市长是什么级别| 病毒四项检查都有什么| 爬坡是什么意思| 热疹症状该用什么药膏| 治前列腺炎吃什么药效果最好| 脚起水泡是什么原因| 胃胀嗳气吃什么药最有效| 社保是什么| 流产是什么意思| 墨镜偏光是什么意思| 嫦娥奔月是什么节日| 曹操叫什么| 七六年属什么| 什么叫三无产品| 什么眉头| 脚后跟痛是什么问题| 三联和四联有什么区别| 什么东西越洗越脏答案| 春天有什么花开| 甲状腺球蛋白抗体高是什么意思| 陈宝国的儿子叫什么| 螺旋杆菌有什么症状| 吃什么长头发快| 眼睛有点模糊是什么原因| 厌氧菌感染用什么药| 嘴角生疮是什么原因| 二氧化碳高是什么原因| 什么牌子的洗衣机最好| 吃榴莲对妇科病有什么好处| 谷草谷丙偏高是什么原因| 暮春是什么时候| 腿肿吃什么药消肿最快最有效| 荞麦枕头有什么好处| 吃靶向药不能吃什么| 妇科彩超主要检查什么| 飞是什么结构| 起死回生是什么生肖| 什么的爱| 有迹可循什么意思| 肝早期硬化身体有什么症状| 津是什么意思| 全能教是什么| 脚底板疼是什么原因| 氯雷他定什么时候吃| 廊坊有什么好玩的地方| 点痦子去医院挂什么科| 什么是肝炎| 猫吐是什么原因| 梦游为什么不能叫醒| co是什么气体| 一丝不苟是什么生肖| 卵磷脂什么牌子好| 科颜氏属于什么档次| 程门立雪什么意思| 长江学者是什么级别| 十月十七是什么星座| 王者风范是什么意思| 魔芋是什么东西做的| 什么孩子命里有文曲星| 男生为什么会晨勃| 给老人过生日送什么礼物好| 海澜之家属于什么档次| 下体痒是什么原因| 高血压吃什么水果好| 恒源祥属于什么档次| 五月十三是什么星座| 三月份是什么星座| 拉黑一个人意味着什么| 吃鸡蛋有什么好处| 心烦意乱吃什么药| 陈皮的功效与作用主要治什么病| 脑供血不足吃什么药最好| 高血压三级是什么意思| 瑄五行属什么| 停电了打什么电话| s代表什么意思| 百度Jump to content

向魂斗罗进军 探秘《绝世唐门》特色魂师修炼系统

From Wikipedia, the free encyclopedia
Cosmos
Screenshot of an OS made with Cosmos, AuraOS, presenting a GUI creation possibility
DeveloperCosmos Project
Written inC#, X#
Working stateActive
Source modelOpen source
Latest releaseRelease 20221121 / 21 November 2022; 2 years ago (2025-08-07)
Repositorygithub.com/CosmosOS
Available inEnglish
Supported platformsx86
Kernel typeMonolithic
LicenseBSD
Official websitewww.gocosmos.org
百度 但是在我看来,这更是一条“民生渠”,一条“幸福渠”,一条可以见证一位共产党员坚定信仰和伟大情怀的“信仰渠”。

C# Open Source Managed Operating System (Cosmos) is a toolkit for building GUI and command-line based operating systems, written mostly in the programming language C# and small amounts of a high-level assembly language named X#. Cosmos is a backronym,[1] in that the acronym was chosen before the meaning. It is open-source software released under a BSD license.

As of 2022, Cosmos encompasses an ahead-of-time (AOT) compiler named IL2CPU to translate Common Intermediate Language (CIL) into native instructions. Cosmos compiles user-made programs and associated libraries using IL2CPU to create a bootable native executable that can run independently. The resulting output can be booted from a USB flash drive, CD-ROM, over a network via Preboot Execution Environment (PXE), or inside a virtual machine. Recent releases also allow deploying to certain x86 embedded devices over Universal Serial Bus (USB). While C# is the primary language used by developers (both on the backend and by end users of Cosmos), many CLI languages can be used, provided they compile to pure CIL without the use of Platform Invocation Services (P/Invokes). Cosmos is mainly intended for use with .NET.

Cosmos does not aim to become a full operating system, but rather a toolkit to allow other developers to simply and easily build their own operating systems using .NET. It also functions as an abstraction layer, hiding much of the inner workings of the hardware from the eventual developer.

Older versions of Cosmos were released in Milestones, with the last being Milestone 5 (released August 2010). More recently, the project switched to simply naming new releases after the latest commit number.

Releases of Cosmos are divided into two types: the Userkit, and the Devkit. The Userkit is a pre-packaged release that is updated irregularly, as new and improved features are added. Userkits are generally considered stable, but do not include recent changes and may lack features. The Devkits, which refers to the source code of Cosmos, are usually stable but may have some bugs. They can be acquired on GitHub and must be built manually.[1] Git is used for source control management.

Most work on Cosmos is currently aimed at improving debugger functionality and Microsoft Visual Studio integration. Kernel work is focused on implementing file systems, memory management, and developing a reliable network interface. Limine serves as the project's bootloader; in older versions of the toolkit, GRUB was used instead.[2]

Origin

[edit]

The idea for Cosmos was created by Chad Hower and was initially co-developed by Hower and Matthijs ter Woord. Over time, Cosmos has been maintained and improved by many other individuals.

Developing with Cosmos

[edit]

Cosmos has many facilities to improve the experience of developing operating systems, and is designed to make the process as fast and painless as possible. Knowledge of assembly language is not required to use Cosmos.

Visual Studio integration

[edit]

A key feature of Cosmos, which separates it from other operating systems of its type, is its tight integration with Microsoft Visual Studio. Code can be written, compiled, debugged, and run entirely through Visual Studio, with only a few keypresses. Cosmos no longer supports Visual Studio 2015, Visual Studio 2017, or Visual Studio 2019, only supporting Visual Studio 2022.

Debugging

[edit]

Cosmos can be seamlessly debugged through Visual Studio when running over PXE or in a virtual machine. Many standard debugging features are present, such as breakpoints, tracing, and logging. Also, debugging can be done via serial cables, if running on physical hardware. When running in VMWare, Cosmos supports stepping and breakpoints, even while an operating system is running.

Running

[edit]

Cosmos uses virtualisation to help speed development by allowing developers to test their operating systems without having to restart their computers as often. By default, VMware Player is used, due to its ease of use in terms of integration with the project. Other virtualisation environments are supported as well, such as Bochs and Hyper-V. An ISO disk image may also be generated that can be burned to a USB flash drive, CD-ROM, or similar media.

PXE booting is also supported, allowing for remote machines to run Cosmos over a network connection.

IDE support

[edit]

Cosmos does not strictly require Visual Studio. Projects can be created by running the command below, given you have the template installed:

dotnet new cosmosCSKernel -n MyCOSMOSProject

Code can be written in other editors and IDEs, such as JetBrains Rider, Visual Studio Code, Neovim and GNU Nano. One downside of this is that debugging may be difficult without the Visual Studio debugger. COSMOS will also not automatically launch your virtualisation software on build. If you would like to use QEMU, for instance, you can run this command after build:

qemu-system-x86_64 -cdrom ./bin/Debug/net6.0/MyCOSMOSProject.iso

Compile process

[edit]

IL2CPU

[edit]

To compile .NET CIL into assembly language, Cosmos developers created an ahead-of-time compiler named IL2CPU, designed to parse CIL and output x86 opcodes. (IL To CPU) is an AOT compiler that is written using a Common Intermediate Language compliant language (C#). It translates Common Intermediate Language to machine code.

X#

[edit]

X# is a low-level programming language designed for the x86 processor architecture as part of Cosmos operating system. It aims to simplify operating system development by incorporating C-like language syntax to assembly language. Initially, X# was used for debugging services in Cosmos. The X# compiler is an open source command-line interface (console) program that parses code lines into tokens, compares them with patterns, and translates matched patterns to intel syntax x86 assembly, typically for the YASM assembler. Early versions of X# operated mostly 1:1 with assembly code, but this is no longer the case.[clarification needed]

Syntax

[edit]

The syntax of X# is straightforward but stricter compared to C.

Comments

[edit]

X# supports only single-line comments in the C++ style, starting with - //.

Constants

[edit]

X# allows the definition of named constants declared outside functions. Numeric constants are defined similarly to C++; for example:

const i = 0

. Referencing them elsewhere requires a # before the name; for example: - "#i".

  • String constant use single quotes (''). To include a single quote in a string constant, use a backslash (e.g.,'I\'m so happy'). X# strings are null terminated.
  • Hexadecimal constants are prefixed with a dollar sign ($), followed by the constant. ($B8000).
  • Decimal constants are not prefixed but cannot start with 0.
  • Binary and octal constants aren't supported yet.

Labels

[edit]

Labels in X# function similarly to labels in other assembly languages. The goto mnemonic is used to jump to a label instead of the conventional jump or jmp mnemonic.

CodeLabel1:
    goto CodeLabel2:

Namespaces

[edit]

X# program files must start with a namespace directive. X# lacks a namespace hierarchy, so the current namespace changes with each directive until the file ends. Variables or constants in different namespaces can have the same name, as the namespace is prefixed to the member's name in the assembly output. Namespaces cannot reference each other except through low-level operations.

namespace FIRST
// Everything variable or constant name will be prefixed with FIRST and an underscore. Hence the true full name of the below variable
// is FIRST_aVar.
var aVar

namespace SECOND
// It's not a problem to name another variable aVar. Its true name is SECOND_aVar.
var aVar

namespace FIRST
// This code is now back to the FIRST namespace until the file ends.

Functions

[edit]

All X# executive code should be placed in functions defined by the 'function' keyword. Unlike C, X# does not support any formal parameter declaration in the header of the functions, so the conventional parentheses after the function name are omitted. Because line-fixed patterns are specified in syntax implemented in code parser, the opening curly bracket can't be placed on the next line, unlike in many other C-style languages.

function xSharpFunction {
    // function code
}

Because X# is a low-level language, there are no stack frames inserted, so by default, the return EIP address should be on the top of the stack. X# function calls do contain arguments enclosed in parentheses, unlike in function headers. Arguments passed to functions can be registers, addresses, or constants. These arguments are pushed onto the stack in reverse order. Note that the stack on x86 platforms cannot push or pop one-byte registers.

function xSharpFunction {
    EAX = $10
    anotherFunction(EAX);
    return
}

function anotherFunction {
    //function code
}

The return keyword returns execution to the return EIP address saved in the stack.

Arithmetic and bitwise operations

[edit]

X# can work with three low-level data structures: the registers, the stack and the memory, on different ports. The registers are the base of all normal operations for X#. A register can be copied to another by writing DST = SRC as opposed to mov or load/store instructions. Registers can be incremented or decremented just as easily. Arithmetic operations (add, subtract, multiply, divide) are written as dest op src where src is a constant, variable, or register, and dest is both an operand and the location where the result is stored.

Examples of assignment and arithmetic operations are shown below.

ESI = 12345              // assign 12345 to ESI
EDX = #constantForEDX    // assign #ConstantForEDX to EDX
EAX = EBX                // move EBX to EAX              => mov eax, ebx
EAX--                    // decrement EAX                => dec eax
EAX++                    // increment EAX                => inc eax
EAX + 2                  // add 2 to eax                 => add eax, 2
EAX - $80                // subtract 0x80 from eax       => sub eax, 0x80
BX * CX                  // multiply BX by CX            => mul cx      -- division, multiplication and modulo should preserve registers
CX / BX                  // divide CX by BX              => div bx
CX mod BX                // remainder of CX/BX to BX     => div bx

Register shifting and rolling is similar to C.

DX << 10  // shift left by 10 bits
CX >> 8   // shift right by 8 bits
EAX <~ 6  // rotate left by 6 bits
EAX ~> 4  // rotate right by 4 bits

Other bitwise operations are similar to arithmetic operations.

DL & $08     // perform bitwise AND on DL with 0x08 and store the result in DL
CX | 1       // set the lowest bit of CX to 1 (make it odd)
EAX = ~ECX   // perform bitwise NOT on ECX and store the result in EAX
EAX ^ EAX    // erase EAX by XORing it with itself

Stack

[edit]

Stack manipulation in X# is performed using + and - prefixes, where + pushes a register, value, constant or all registers onto the stack and - pops a value to some register. All constants are pushed on stack as double words, unless stated otherwise (pushing single bytes is not supported).

+ESI                   // push esi
-EDI                   // pop into edi
+All                   // save all registers   => pushad
-All                   // load all registers   => popad
+$1badboo2             // push 0x1badboo2 on the stack
+$cafe as word         //          \/
+$babe as word         // push 0xcafebabe
+#VideoMemory          // push value of constant VideoMemory

Variables

[edit]

Variables are defined within namespaces using the var keyword. Arrays are defined by specifying the type and size. Variables and arrays are zeroed by default. To reference a variable's value, use a dot ('.'), and to reference its address, use @.

namespace XSharpVariables
var zeroVar                      // variable will be assigned zero
var myVar1 = $f000beef           // variable will be assigned 0xf000beef
var someString = 'Hello XSharp!' // variable will be assigned 'Hello XSharp!\0',
var buffer byte[1024]            // variable of size 1024 bytes will be assigned 1024 zero bytes
...
EAX = .myVar1                    // moves value of myVar1 (0xf000beef) to EAX
ESI = @.someString               // moves address of someString to ESI
CL = .someString                 // moves first character of someString ('H') to CL
.zeroVar = EAX                   // assigns zeroVar to value of EAX

X# can access an address with a specified offset using square brackets:

var someString = 'Hello XSharp!' //variable will be assigned to 'Hello XSharp!\0'
...
ESI = @.someString       // load address of someString to ESI
CL = 'B'                 // set CL to 'B' (rewrite 'H' on the start)
CH = ESI[1]              // move second character ('E') from string to CH
ESI[4] = $00             // end string
//Value of someString will be 'Bell' (or 'Bell\0 XSharp!\0')

Comparison

[edit]

There are two ways to compare values in X#: pure comparison and if-comparison.

  • Pure comparison leaves the result in FLAGS, which can be used in native assembly or with the if keyword without specifying comparison members.
  • If comparison directly compares two members after an if keyword.

Here are two ways of writing a (slow) X# string length (strlen)function:

// Method 1: using pure comparison
function strlen {
    ESI = ESP[4] // get pointer to string passed as first argument
    ECX ^ ECX    // clear ECX
Loop:
    AL = ESI[ECX]// get next character
    AL ?= 0      // is it 0? save to FLAGS
    if = return  // if ZF is set, return
    ECX++        // else increment ECX
    goto Loop    // loop...

//Way 2: using if
function strlen {
    ESI = ESP[4]    // get pointer to string passed as first argument
    ECX ^ ECX       // clear ECX
Loop:
    AL = ESI[ECX]
    if AL = 0 return// AL = 0? return
    ECX++
    goto Loop       // loop....
}

There are six available comparison operators: < > = <= >= !=. These operators can be used in both comparisons and loops. Note that there's also a bitwise AND operator which tests bits:

AL ?& $80      // test AL MSB
if = return    // if ZF is 0, test instruction resulted in 0 and MSB is not set.

Writing Cosmos code

[edit]

An operating system built with Cosmos is developed in a similar fashion to any .NET C# console program. Additional references are made in the start of the program which give access to the Cosmos libraries.

User Kit and Visual Studio

[edit]

The Cosmos User Kit is a part of Cosmos designed to make Cosmos easier to use for developers using Microsoft Visual Studio. When installed, the user kit adds a new project type to Visual Studio, called a Cosmos Project. This is a modified version of a console application, with the Cosmos compiler and bootup stub code already added.

Compiling a project

[edit]

Once the code is complete, it may be compiled using Roslyn, the .NET compiler, either via Microsoft Visual Studio or the .NET command-line tools (dotnet).

This converts the application from the original source code (C# or otherwise) into Common Intermediate Language (CIL), the native intermediate language of .NET.

The build process then invokes the IL2CPU compiler which systematically scans through all of the application's CIL code (excluding the Cosmos compiler code), converting it into assembly language for the selected processor architecture. As of 2022, only the x86 architecture is supported. Next, Cosmos invokes the selected assembler to convert this assembly language code into native central processing unit (CPU) opcode. Finally, the desired output option is activated, be it starting a virtual machine, starting a PXE engine, or producing an ISO disk image file.

Debug options

[edit]

Cosmos offers several options as to how to deploy the resulting OS and how to debug the output.

Virtualization

[edit]
The default Cosmos template as seen in QEMU.

Cosmos allows users to boot the operating system in an emulated environment using a virtual machine. This lets developers test the system on their own computer without having to reboot, giving the advantages of not requiring extra hardware or that developers exit their integrated development environment (IDE). VMware is the primary virtualisation method, however others are supported such as QEMU and Hyper-V.

Disk images

[edit]

This option writes the operating system to a disk image (ISO image) file, which can be loaded into some emulators (such as Bochs, QEMU or more commonly VMware) or written to a USB flash drive and booted on physical hardware.

PXE network boot

[edit]

This option allows the operating system to boot on physical hardware. The data is sent via a local area network (LAN) to the client machine. This requires two computers: one as the client machine (on which the OS is booted) and one as the server (usually the development machine). It also requires a network connecting the two computers, a client machine with a network card, and a Basic Input/Output System (BIOS) that can boot with PXE. As of 2022, debugging over a network is no longer supported.

See also

[edit]

References

[edit]
  1. ^ a b Cosmos website: project repository at GitHub
  2. ^ "Change bootloader to Limine · Pull Request #2521 · CosmosOS/Cosmos · GitHub". GitHub.
[edit]

News coverage

[edit]
孕育是什么意思 升阳举陷是什么意思 点痦子去医院挂什么科 柏油是什么 肠胃炎发烧吃什么药
95年的属什么生肖 肾的主要功能是什么 香榧是什么 疝气吃什么药效果好 吃二甲双胍为什么会瘦
托帕石是什么宝石 女生自慰是什么感觉 hpv52阳性有什么症状 阳痿吃什么药效果好 人才辈出是什么意思
党的执政理念是什么 白茶有什么功效 喝什么解酒最快最有效 叶公好龙是什么故事 尿糖阴性什么意思
大肠杆菌感染吃什么药hcv8jop0ns1r.cn 胆固醇偏高吃什么好hcv8jop5ns1r.cn 月经崩漏吃什么止血hcv8jop2ns0r.cn saa是什么意思hcv8jop4ns0r.cn 毛豆有什么营养价值hcv9jop1ns6r.cn
忍者神龟是什么意思hcv8jop8ns9r.cn 内火旺是什么原因hcv8jop8ns7r.cn 形态是什么意思hcv7jop6ns1r.cn l代表什么hcv8jop6ns1r.cn 恢复伤口吃什么好得快hcv9jop7ns1r.cn
稀字五行属什么hcv9jop6ns1r.cn 猩红热是什么hcv7jop4ns5r.cn 圆寂什么意思hcv7jop5ns2r.cn 起床气是什么意思hcv8jop6ns9r.cn 圆脸适合什么发型好看hcv8jop5ns5r.cn
测尿酸挂什么科hcv7jop5ns0r.cn 两面人是什么意思wzqsfys.com 唯女子与小人难养也是什么意思96micro.com 什么水果对胃好hcv9jop1ns4r.cn 布病是什么症状hcv8jop6ns3r.cn
百度