L4RE学习笔记——服务介绍

1.服务概述:

 Sigma0,theRootPager

Sigma0L4Re的第一个非常有用的task,用于处理root taskmoe)的缺页异常。它可以认为是内核的一部分,尽管它运行在非特权模式。

 

Moe,theRootTask

MoeL4的根任务,负责bootstrap the system,并且为上层应用提供基本的资源管理,包括:

Memory:以动态分配((L4Re::Mem_alloc, L4::Factory)和数据空间((L4Re::Dataspace)方式

Cpu:以调度(L4::Scheduler)方式

Virtual memory managementL4Re::Rm

 

Moe还进一步实现了L4Re的名字空间(L4Re::Namespace,比如提供了一个只读的目录用于存放所有的multi-bootmodules

为了启动系统,Moe启动了一个ELF程序——init进程。Init进程通常就是“Ned”,它可以访问moe管理的所有资源和sigma0提供的接口。

 

Ned,theDefaultInitProcess

为了让root task免于复杂脚本引擎,同时避免启动过程中特定的依赖(这些依赖可能造成死锁),真正系统的启动和配置由一个外部的task来管理——init进程(Ned)。

系统配置通过lua脚本。

 

Io,thePlatformandDeviceResourceManager

因为Fiasco.OC所有的外设管理都在用户态,所以有必要将特定于平台和外设的资源集中管理起来。这就是IO的工作。它提供接口抽象来逐层迭代访问硬件设备资源,同时可以传递访问权限给其他应用。

 

OtherServers

以下的服务包,位于L4Re的顶层环境中:

 

Rtc,the Real-Time Clock Server

fb-drv,the Low-Level Graphics Driver(可以跑VESA

Uvmm,the virtual machine monitor

Mag,the GUI Multiplexer

Cons,the Console Multiplexer

 

2.1  Moe,theRoot-Task

Moe提供L4Re抽象对象的一些默认实现:data spaceL4Re::Dataspace)、region map(L4Re::Rm)memory allocator(L4Re:Mem_alloc,L4Re:Factory)name space(L4Re::Namespace)

 

Moe由以下子系统构成:

Name-Space Provider — 提供名字空间的实例

BootFS — 提供启动过程中load文件的访问

Log Subsystem Log

Scheduler Subsystem —调度

Memory Allocator, Generic Factory — 内存分配

 

Dataspace可以分配任意大小,分配粒度为机器页大小(L4_PAGESIZE)。

 

Name-Space Provider

Moe单独创建一个名字空间给BootFS,即“rom”目录。

BootFS提供一个针对启动过程中加载文件的名字空间(rom),这些文件可以链接进boot image或者通过bootloaderGRUB)加载。

rom目录是L4Re::Namespace对象,而里面的每个文件则是L4Re::Dataspace对象

默认所有的文件都是在namaspace——rom中可见和只读的。文件还可以提供一个参数“:rw”来标记modules是可读写的。这样moe会将其放在另一个namespace——rwfs

modules.list中的写法示例:

module somemodule : rw

 

Command-LineOptions

moe[--debug=<flags>][--init=<binary>][--l4re-dbg=<flags>][--ldr-flags=<flags>][--<initoptions>]

--debug=<debug flags>

info, warn, boot, server, loader, exceptions,and ns (or all

--init=<init process>

可以重写默认的init进程(rom/ned

--l4re-dbg=<debug flags>

Flag--debug,区别:此处为initflag--debugmoe

--ldr-flags=<loader flags>

pre_alloc,all_segs_cow, pinned_segs

-- <init options>

通过--”加空格传入的参数会直接传递到init进程

 

2.2 Ned,the Init Process

 

Lua Bindings for L4Re

Ned提供对L4Re抽象的各种绑定,它们位于L4包中(require L4”)

 

几个常量

Proto={

Dataspace=0x4000,

Namespace=0x4001,

Goos=0x4003,

Mem_alloc=0x4004,

Rm=0x4005,

Event=0x4006,

Inhibitor=0x4007,

Sigma0=-6,

Log=-13,

Scheduler=-14,

Factory=-15,

Vm=-16,

Dma_space=-17,

Irq_sender=-18,

Irq_muxer=-19,

Semaphore=-20,

Iommu=-22,

Ipc_gate=0,

}

 

Dbg={

Info=1,

Warn=2,

Boot=4,

Server=0x10,

Exceptions=0x20,

Cmd_line=0x40,

Loader=0x80,

Name_space=0x400,

All=0xffffffff,

}

 

Ldr_flags={

eager_map=0x1,--L4RE_AUX_LDR_FLAG_EAGER_MAP

all_segs_cow=0x2,--L4RE_AUX_LDR_FLAG_ALL_SEGS_COW

pinned_segs=0x4,--L4RE_AUX_LDR_FLAG_PINNED_SEGS

}

 

Ned启动一个新task是通过L4.loader,这个类提供三个选项:

new_channel():返回一个新的IPC gate

start()startv():启动一个新的进程,并返回进程对象

 

Ned同样可以带命令行参数

[--interactive|-i][--cmdcap|-cCAP][--noexit][--execute|-eSTATEMENT]<luascript>[options passed to lua script]

 

2.3 Io,the Io Server

Io的配置包含两个部分:硬件的描述;虚拟总线的描述。

一个基于PCI的例图:

 

一个io配置文件的示例

--vim:ft=lua

--Example configuration for io

--Configure two platform devices to be known to io

Io.Dt.add_children(Io.system_bus(),function()

--create a new hardware device called"FOODEVICE"

FOODEVICE=Io.Hw.Device(function()

--set the compatibility IDs for this device

--a client tries to match against these IDs and configures

--itself accordingly

--the list should be sorted from specific to less specific IDs

compatible={"dev-foo,mmio","dev-foo"};

--set thehidproperty of the device,the hid can also be used

--as a compatible ID when matching clients

Property.hid="dev-foo,Example";

--note:names for resources are truncated to 4 letters and a client

--can determine the name from the ID field of a l4vbus_resource_t

--add two resourcesirq0andreg0to the device

Resource.irq0=Io.Res.irq(17);

Resource.reg0=Io.Res.mmio(0x6f000000,0x6f007fff);

end);

--create a new hardware device called "BARDEVICE"

BARDEVICE=Io.Hw.Device(function()

--set the compatibility IDs for this device

--a client tries to match against these IDs and configures

--itself accordingly

--the list should be sorted from specific to lesss pecific IDs

compatible={"dev-bar,mmio","dev-bar"};

--set thehidproperty of the device,the hid can also be used

--as a compatible ID when matching clients

Property.hid="dev-bar,Example";

--Specify that this device is able to use direct memory access(DMA).

--This is needed to allow clients to gain access to DMA addresses

--used by this device to directly access memory.

Property.flags=Io.Hw_device_DF_dma_supported;

--note:names for resources are truncated to 4 letters and a client

--can determine the name from the ID field of a l4vbus_resource_t

--add three resourcesirq0,irq1,andreg0to the device

Resource.irq0=Io.Res.irq(19);

Resource.irq1=Io.Res.irq(20);

Resource.reg0=Io.Res.mmio(0x6f100000,0x6f100fff);

end);

end);

Io.add_vbusses

{

--Create a virtual bus for a client and give access to FOODEVICE

client1=Io.Vi.System_bus(function()

dev=wrap(Io.system_bus():match("FOODEVICE"));

end);

--Create a virtual bus for another client and give it access to BARDEVICE

client2=Io.Vi.System_bus(function()

dev=wrap(Io.system_bus():match("BARDEVICE"));

end);

}

每个设备支持一个compatible’属性,它是一个字符串(跟linuxdts类似)。客户端根据这个属性进行匹配。其他的设备成员根据其类型来分别处理:资源(io.Res),资源名限制在4个字符,存储在l4vbus_resource_tID域;设备,会作为当前设备的一个子节点;其他的类型则被认为是设备的属性来配置设备驱动。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值