Presentation is loading. Please wait.

Presentation is loading. Please wait.

創用 CC BOS & Network Driver Practice Ben Wei (A system creator) JULUOSDev 星系主題.

Similar presentations


Presentation on theme: "創用 CC BOS & Network Driver Practice Ben Wei (A system creator) JULUOSDev 星系主題."— Presentation transcript:

1 創用 CC BOS & Network Driver Practice Ben Wei (A system creator) JULUOSDev 星系主題

2 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 2

3 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 3

4 創用 CC Bos 簡介 4

5 創用 CC Architecture 5 CU RU Kernel E100 i82559ER PCI Func PCI Func Timer Kernel Kthread (Bshell) Mem lspci net Network Driver

6 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 6

7 創用 CC lspci OSDev.org “here I can find Programming Info on PCI?”“here I can find Programming Info on PCI?” –sysInLong: 讀取 pci 表內容 –sysOutLong: 寫入 pci 設備命令及資料 7

8 創用 CC MIT OSE x86.h uint32_t inl(int port) __asm __volatile("inl %w1,%0" : "=a" (data) : "d" (port)); void outl(int port, uint32_t data) __asm __volatile("outl %0,%w1" : : "a" (data), "d" (port)); 8

9 創用 CC inl/outl NASM ;uint32_t _intl(int port) _inl: mov edx, [esp+4] mov eax, 0 in eax, dx ret ;void _outl(int port, uint32_t data) _outl: mov edx, [esp+4] ; port mov eax, [esp+8] ; data out dx, eax ret 9

10 創用 CC PCI Config Read pciConfigRead(uint32_t bus, uint32_t slot, uint32_t func, uin32_t offset) address = (uint32_t)((bus << 16) | (slot << 11) | (func << 8) | (offset & 0xfc) | ((uint32_t)1<<31)); outl(0xCF8, address); data = (uint32_t)(intl(0xCFC); 10

11 創用 CC Ethernet Controller Info 00:18.0 Vendor:8086, devid:1029, class:0200h(Ethernet Controller),r9,t0,irq11 11

12 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 12

13 創用 CC E100_attach 啟用流程 啟用後,這時便用使用到 io region 1: 0xc040 ,長度為 64 位元組,參考 Intel 8255982559 需要將 e100 做軟體重置 –e100_reset() Disable CSR 中斷 DMA Rings – 傳送的緩衝區 Control Block List (CBL): cbl_init() – 接收用的緩衝區 Receive Frame Area (RFA): rfa_init() 13

14 創用 CC PCI enable e100 func pci_func_enable(pci_pdata_t f) pci_conf_write(f, PCI_COMMAND_STATUS_REG, PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE); 執行結果 PCI function 00:18.0 (8086:1209) enabled 14

15 創用 CC E100 Reset void e100_reset() { outl(e100.addr_base[E100_IO] + CSR_PORT, PORT_SW_RESET); delay(10); } 15

16 創用 CC Tricky delay() __inline void delay(int i) { while(--i >=0) { inb(0x84); } 16

17 創用 CC Disable e100 interrupt r = e100_exec_cmd(CSR_INT, 1); printf("e100 CSR_INT ret=%d\n", r); e100_exec_cmd (int csr_comp, uint8_t cmd) outb(nic.io_base + csr_comp, cmd); do { scb_command = inb(nic.io_base + CSR_COMMAND); } while (scb_command != 0 && --retry > 0); return retry > 0; 17

18 創用 CC DMA Rings Control Block Control Block List (CBL) Receive Frame Area (RFA) 18

19 創用 CC Control Block (CB) ControlStatus Link Command Specific Data 19 ControlStatus Link TBD ARRAY ADDR TBD CountTHRSTCB Byte Count Data Transmit Control Block (TCB)

20 創用 CC DMA Rings for TCBs 20 ControlStatus Link 0XFFFFFFFF 00xE0Size Packet Data ControlStatus Link 0XFFFFFFFF 00xE0Size Packet Data ControlStatus Link 0XFFFFFFFF 00xE0Size Packet Data

21 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 21

22 創用 CC transmit & receive Send Packet data (transmit & receive) int e100_transmit (const char *data, uint16_t len) Receive packet data int e100_receive (char *data) 22

23 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 23

24 創用 CC 24

25 創用 CC Demo - recap bos$ net PCI function 00:18.0 (8086:1209) enabled mem region 0: 4096 bytes at 0xf2020000 io region 1: 64 bytes at 0xc040 cbl avail = 9, wait = 1, slot = 0x420000, irq=11 rfa avail = 10, wait = 0, slot = 0x420050 25

26 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 26

27 創用 CC Issues 原使用 e100 設備序號,並不生效;後來研究 OSE 資料後, 發現必須在 qemu 參數中設定,之後再使用設備序號 1209 來啟用 e100(i82559er) ,如此才能正確執行在 qemu 環境 。 系統在開發的過程中,偶遇到無法正常開機,這時 GIT 便 可派上用場,來縮小問題發生的範圍。 27

28 創用 CC Agenda BOS 簡介 lspci e100_attach Transmit & Receive Demo Issues Qemu OSE 28

29 創用 CC 編繹 Qemu OSE 版本 $ configure --disable-sdl –prefix=/usr/local/qemuose $ --target-list=i386-softmmu $ make $ sudo make install 另外在 Bos v0.21 中執行 Qemu 時,將檢查 /usr/local/qemuose ,若存在則直接使用。 29

30 創用 CC Qemu 參數 參數 qemu -fda "../bos.img" -net user -net nic,model=i82559er MIT OSE 參數 ( 只在 qemu 0.12.5-6.828 中支援) -debug-e100 -pcap 30

31 創用 CC 結論 PCI 資訊的存取 啟用 e100 網路卡 設定並使用 DMA Rings 更好的偵錯方式來進行網卡開發 相關遇到問題的經驗分享 31

32 創用 CC 32

33 創用 CC JuluOSDev 議程 有興趣一起開發 Juluos 的朋友們,請加入到 juluosdev group at google ,參與開發議程討論,位置詳見 Julu.staros.mobi 公告。 33

34 創用 CC 34

35 創用 CC Glossary of Abbreviations CB Control Block CBL Command Block List CSR Control/Status Registers CU Command Unit RFA Receive Frame Area RFD Receive Frame Descriptor RU Receive Unit SCB System Control Block TCB Transmit Command Block 35

36 創用 CC 參考資料及延伸閱讀 MIT OSE –MIT OSE Lab6MIT OSE Lab6 –MIT OSE ToolsMIT OSE Tools Intel 82559 NASM x86 Quick Reference OSDev.org –Where can I find programming info on PCI?Where can I find programming info on PCI? –Differences Between AT&T and Intel assembler formatsDifferences Between AT&T and Intel assembler formats 36


Download ppt "創用 CC BOS & Network Driver Practice Ben Wei (A system creator) JULUOSDev 星系主題."

Similar presentations


Ads by Google