1 / 19

PMON 基础知识培训

PMON 基础知识培训. 主要内容安排. 编译系统介绍 PMON 执行流程讲解 调试手段 获取使用帮助. 编译环境. 配置文件 : conf/files conf/GENERIC_ALL Targets/Bonito/conf files.Bonito Bonito Makefile.Bonito 选择模块 修改 files.* 增加新文件 修改 Bonito 选择需要编译的内容. 编译环境 ( 续 ). $(TOPDIR)/tools/pmoncfg 根据配置文件生成 Makefile 配置与编译

neveah
Download Presentation

PMON 基础知识培训

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PMON 基础知识培训

  2. 主要内容安排 • 编译系统介绍 • PMON执行流程讲解 • 调试手段 • 获取使用帮助

  3. 编译环境 • 配置文件: • conf/files • conf/GENERIC_ALL • Targets/Bonito/conf • files.Bonito • Bonito • Makefile.Bonito • 选择模块 • 修改files.* 增加新文件 • 修改Bonito 选择需要编译的内容

  4. 编译环境(续) • $(TOPDIR)/tools/pmoncfg • 根据配置文件生成Makefile • 配置与编译 • cd Targes/Bonito/conf • pmoncfg Bonito • cd Targets/Bonito/compile/Bonito && make • 或者 cd zloader && make tgt=rom • 有时候需要在make 的时候执行make clean

  5. 编译系统(续) • 配置文件Bonito • option <DEFINE>,增加宏定义,如option BONITOEL 将在生成的Makefile中定义BONITOEL • select <module>, 选择需要编译的模块,如select mod_framebuffer • 模块定义文件(files.*) • 设备相关,如files.pci, files.ata • 通用模块,conf/files

  6. 模块定义文件 • define <modname>增加一个模块定义 • define usbus { } • define ether • device 增加设备定义 • usb: disk • attach <dev> at <bus> 设备挂载在何种总线之上 • attach usb at usbbus

  7. 模块定义文件(续) • file <path to file> [modname] • 定义文件属于何种模块,选择模块时将编译该文件 • 如file sys/dev/pci/if_fxp.c fxp 定义了Intel eppro100 网卡驱动模块 • 模块的依赖 • 例如rtl8139属于PCI设备,依赖于PCI模块;作为网络设备,又依赖于网络协议模块 • device rtl: ether, ifnet • attach rtl at pci

  8. 添加USB模块举例 • Conf/files • define usbbus {} • device usb: disk • attach usb at usbbus • file sys/dev/usb/usb.c mod_usb • ……… • files.pci • device uhci:usbbus • attach uhci at pci • device ohci: usbbus • attach ohci at pci

  9. 添加USB模块举例(续) • 选择USB 模块(配置文件Bonito) • ohci0 at pci? dev ? function ? • usb0 at usbbus ? • usb0 at usbbus ? • select mod_usb • select mod_usb_storage • select mod_usb_ohci • select mod_usb_kbd • select mod_usb_uhci

  10. 龙芯启动过程 • 和其他mips处理器一样 • 上电复位后,执行的第一条指令地址为0xbfc00000, 这是我们BIOS eprom的地址 • 两个执行阶段 • Rom 执行 • 执行必要初始化:内存控制器设置,代码数据拷贝到内存,建立堆栈等等,准备内存执行阶段的条件 • 需要注意:所有变量不可写 • 内存执行

  11. 最初始的代码Start.S • 北桥初始设置 • 南桥初始化 • SMB 控制器(读取内存SPD信息需要) • SuperIO初始化 • 串口地址设置,使能 • RTC,键盘控制器使能 • 串口初始化 • 调试打印PRINTSTR (….)

  12. Start.S(续) • 内存控制器设置 • 通过I2C或者SMB读取内存参数:大小,tcol,trow等时序参数 • 由config寄存器计算cache参数 • Cacheline,cache size,godson_init_cache清除cache中随机数据 • 拷贝数据,代码段到内存,准备进入内存执行

  13. C 代码执行 • Targets/Bonito/Bonito/tgt_machdep.c • 入口函数 initmips • ConfigEntry ConfigTable • 配置打印输出:串口ns16550,vgacon,fbcon • 计算CPU频率: • 根据RTC和CPU count寄存器 • 利用RTC可以设定一段时间,看count在这段时间内增加了多少(count的频率是总线频率一半) • tgt_devinit • _pci_businit: 北桥寄存器设置,总线扫描

  14. 北桥pci 地址空间设置 • 在Bonito北桥中有3个64M的pci mem空间。 • 256M~256M+3*64M.是CPU访问PCI mem的地址空间 • 北桥中PCIMAP寄存器控制3个PCI mem窗口在整个PCI memory Space上的映射。在PMON中设置为0x2040,也就是使用0~192M的PCI memory空间。具体可以看Targets/Bonito/pci/pci_machdep.c中的_pci_hwinit函数

  15. Pci总线扫描 • 北桥初始化(主要是建立设备可用的地址空间)之后,就开始PCI总线扫描。 • _pci_scan_dev • 通过pci配置访问确定连接了设备 • 算法,树的深度遍历(对于龙芯系统,只有一个pci桥,树的深度为2)

  16. Pci设备初始化驱动加载 • tgt_devconfig • _pci_devinit:使能设备的IO与mem空间 • configure(),加载设备驱动 • 对于找到的每一个设备,查找相应的设备驱动。这是一个递归的过程。比如找到一个USB控制器,加载了控制器驱动之后,控制器驱动最后会扫描USB总线, 并加载usb设备(usb storage,kbd)的驱动。

  17. 设置例外处理 • 将例外处理代码拷贝到例外入口,设置sr的BEV。 • 打印出提示符,处理输入命令

  18. 调试手段 • PMON调试 • 在start.S中可以使用下列打印语句 PRINTSTR,Stringserial,hexserial,tgt_putchar • 对于硬件调试人员,用的较多的命令有 • m 访问某个地址 • pcicfg可以访问pci设备的配置空间 • pciscan 可以打印设备的地址分配情况。

  19. 获取使用帮助 • 在提示符下输入h,可以输出所有可用命令的简单说明 • 输入h <cmd>,可以获得该命令的详细帮助。

More Related