參考資訊:
https://zhuanlan.zhihu.com/p/597577575
https://studies.ac.upc.edu/doctorat/ENGRAP/VxWorks-device-drivers.htm
https://forums.windriver.com/t/vxworks-software-development-kit-sdk/43
https://mail.prz-rzeszow.pl/~ssamolej/vxworks/vxworks_kernel_programmers_guide_6.6.pdf
https://d13321s3lxgewa.cloudfront.net/downloads/wrsdk-vxworks7-docs/2309/README_qemu.html
https://learning.windriver.com/path/vxworks7-essentials-workbench-and-tools/vxworks-kernel-shell
main.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iosLib.h> static int drvNum = 0; static DEV_HDR hdr = {0}; int myProbe(void) { drvNum = iosDrvInstall(NULL, NULL, NULL, NULL, NULL, NULL, NULL); iosDevAdd(&hdr, "/dev/hello", drvNum); printf("Hello, world!\n"); return OK; }
編譯
$ wr-cc main.c -o hello -dkm
執行
-> ld < hello -> moduleShow MODULE NAME MODULE ID GROUP # SEGMENT ADDRESSES --------------------------- -------------------- ------- ------------------------- hello 0x00ffff800006720500 1 0xffffffff8c5a6000 (TEXT) 0xffffffff8c5a7000 (DATA) 0xffffffff8c5a7030 (BSS) -> myProbe Hello, world! -> devs drv refs name 22 [ 5] /dev/hello 13 [ 5] /dev/random 13 [ 5] /dev/urandom 12 [ 5] /dev/zero 11 [ 5] /fifos 16 [ 5] /host.host 14 [ 5] /input/event 0 [ 7] /null 5 [ 5] /ram 10 [ 5] /ram0 9 [ 5] /romfs 3 [ 5] /shm 10 [ 5] /tmp 2 [ 7] /ttyS0 value = 0 = 0x0 -> unld "hello"