├── .gitignore ├── AUTHORS ├── LICENSE ├── README.md ├── apps ├── Makerules ├── date.c ├── rdate.c └── timeserver.c ├── build └── README.md ├── compile ├── Makefile ├── arch │ ├── README │ ├── arm │ │ └── platformVars │ ├── mips │ │ ├── ld.script │ │ └── platformVars │ └── x86 │ │ └── platformVars ├── data │ ├── Makerules │ ├── mytar.tar │ ├── mytar.tar.o │ ├── pcap-bigmips.c │ ├── testarp.pcap │ ├── testarp.pcap.o │ ├── testarp.txt │ ├── testip.pcap │ ├── testip.pcap.o │ ├── testip.txt │ ├── testnetif.pcap │ ├── testnetif.pcap.o │ ├── testnetif.txt │ ├── testraw.pcap │ ├── testraw.pcap.o │ ├── testraw.txt │ ├── testsnoop.pcap │ ├── testsnoop.pcap.o │ ├── testsnoop.txt │ ├── testudp.pcap │ ├── testudp.pcap.o │ └── testudp.txt └── platforms │ ├── arm-qemu │ ├── ld.script │ ├── platformVars │ └── xinu.conf │ ├── arm-rpi │ ├── ld.script │ ├── platformVars │ └── xinu.conf │ ├── e2100l │ ├── ld.script │ ├── platformVars │ └── xinu.conf │ ├── mipsel-qemu │ ├── platformVars │ └── xinu.conf │ ├── wl330ge │ ├── platformVars │ └── xinu.conf │ ├── wrt160nl │ ├── platformVars │ └── xinu.conf │ ├── wrt54gl │ ├── platformVars │ └── xinu.conf │ └── x86 │ ├── ld.script │ ├── platformVars │ └── xinu.conf ├── device ├── drive │ └── rpi_SDcard │ │ ├── Makerules │ │ ├── rpi-sdcard.h │ │ ├── rpi_sdcard_Init.c │ │ └── rpi_sdcard_Install.c ├── ethernet │ ├── Makerules │ ├── colon2mac.c │ ├── etherClose.c │ ├── etherControl.c │ ├── etherInit.c │ ├── etherRead.c │ ├── etherStat.c │ ├── lan78xx │ │ ├── Makerules │ │ ├── lan78xx.c │ │ ├── lan78xx.h │ │ ├── lan78xx_Init.c │ │ ├── lan78xx_Install.c │ │ ├── lan78xx_Interrupt.c │ │ ├── lan78xx_Open.c │ │ └── lan78xx_Write.c │ ├── smsc9512 │ │ ├── Makerules │ │ ├── smsc9512.c │ │ ├── smsc9512.h │ │ ├── smsc9512Interrupt.c │ │ ├── smsc9512Open.c │ │ ├── smsc9512Write.c │ │ ├── smsc9512_Init.c │ │ └── smsc9512_Install.c │ └── vlanStat.c ├── ethloop │ ├── Makerules │ ├── ethloopClose.c │ ├── ethloopControl.c │ ├── ethloopInit.c │ ├── ethloopOpen.c │ ├── ethloopRead.c │ ├── ethloopWrite.c │ └── ethloop_Install.c ├── framebuffer_rpi │ ├── Makerules │ ├── drawShapes.c │ ├── fbPutc.c │ ├── fbWrite.c │ ├── font8x12.h │ ├── font9x16.h │ ├── framebuffer_Install.c │ ├── screenInit.c │ └── trig.c ├── gpio │ ├── Makerules │ ├── gpioInit.c │ └── rpi_gpio │ │ ├── Makerules │ │ ├── rpi_gpio.h │ │ ├── rpi_gpioHwGet.c │ │ ├── rpi_gpioHwInit.c │ │ ├── rpi_gpioHwSet.c │ │ ├── rpi_gpioHwSetMode.c │ │ └── rpi_gpio_Install.c ├── http │ ├── Makerules │ ├── httpAlloc.c │ ├── httpCleanPrompts.c │ ├── httpClose.c │ ├── httpConfigPage.c │ ├── httpControl.c │ ├── httpErrorResponse.c │ ├── httpFlushWBuffer.c │ ├── httpFree.c │ ├── httpGetc.c │ ├── httpHtmlBegin.c │ ├── httpInit.c │ ├── httpOpen.c │ ├── httpPutc.c │ ├── httpRead.c │ ├── httpReadHdrs.c │ ├── httpReadRqst.c │ ├── httpServer.c │ ├── httpValidations.c │ └── httpWrite.c ├── loopback │ ├── Makerules │ ├── loopbackClose.c │ ├── loopbackControl.c │ ├── loopbackGetc.c │ ├── loopbackInit.c │ ├── loopbackOpen.c │ ├── loopbackPutc.c │ ├── loopbackRead.c │ ├── loopbackWrite.c │ └── loopback_Install.c ├── null │ ├── Makerules │ └── null_Install.c ├── raw │ ├── Makerules │ ├── rawClose.c │ ├── rawControl.c │ ├── rawDemux.c │ ├── rawInit.c │ ├── rawOpen.c │ ├── rawRead.c │ ├── rawRecv.c │ ├── rawSend.c │ ├── rawWrite.c │ └── raw_Install.c ├── rtp │ ├── Makerules │ ├── rtpAlloc.c │ ├── rtpClose.c │ ├── rtpFreebuf.c │ ├── rtpGetbuf.c │ ├── rtpInit.c │ ├── rtpOpen.c │ ├── rtpRead.c │ ├── rtpRecv.c │ ├── rtpSend.c │ └── rtpWrite.c ├── tcp │ ├── Makerules │ ├── tcpAlloc.c │ ├── tcpChksum.c │ ├── tcpClose.c │ ├── tcpControl.c │ ├── tcpDemux.c │ ├── tcpFree.c │ ├── tcpGetc.c │ ├── tcpInit.c │ ├── tcpOpen.c │ ├── tcpOpenActive.c │ ├── tcpPutc.c │ ├── tcpRead.c │ ├── tcpRecv.c │ ├── tcpRecvAck.c │ ├── tcpRecvData.c │ ├── tcpRecvListen.c │ ├── tcpRecvOpts.c │ ├── tcpRecvOther.c │ ├── tcpRecvRtt.c │ ├── tcpRecvSynsent.c │ ├── tcpRecvValid.c │ ├── tcpSend.c │ ├── tcpSendAck.c │ ├── tcpSendData.c │ ├── tcpSendPersist.c │ ├── tcpSendRst.c │ ├── tcpSendRxt.c │ ├── tcpSendSyn.c │ ├── tcpSendWindow.c │ ├── tcpSeqdiff.c │ ├── tcpSetup.c │ ├── tcpStat.c │ ├── tcpTimer.c │ ├── tcpTimerPurge.c │ ├── tcpTimerRemain.c │ ├── tcpTimerSched.c │ ├── tcpTimerTrigger.c │ ├── tcpWrite.c │ └── tcp_Install.c ├── telnet │ ├── Makerules │ ├── telnetAlloc.c │ ├── telnetClose.c │ ├── telnetControl.c │ ├── telnetFlush.c │ ├── telnetGetc.c │ ├── telnetInit.c │ ├── telnetOpen.c │ ├── telnetPutc.c │ ├── telnetRead.c │ ├── telnetServer.c │ ├── telnetWrite.c │ └── telnet_Install.c ├── tty │ ├── Makerules │ ├── ttyClose.c │ ├── ttyControl.c │ ├── ttyGetc.c │ ├── ttyInit.c │ ├── ttyOpen.c │ ├── ttyPutc.c │ ├── ttyRead.c │ ├── ttyWrite.c │ └── tty_Install.c ├── uart │ ├── Makerules │ ├── kgetc.c │ ├── kprintf.c │ ├── kputc.c │ ├── ns16550 │ │ ├── Makerules │ │ ├── ns16550.h │ │ ├── ns16550_Install.c │ │ ├── ns16550_SetCommState.c │ │ ├── ns16550_uartHwStat.c │ │ ├── ns16550_uartInterrupt.c │ │ └── ns16550_uartKickTx.c │ ├── pl011 │ │ ├── Makerules │ │ ├── pl011.h │ │ ├── pl011_Install.c │ │ ├── pl011_SetCommState.c │ │ ├── pl011_uartHwStat.c │ │ ├── pl011_uartInterrupt.c │ │ └── pl011_uartKickTx.c │ ├── uartControl.c │ ├── uartGet.c │ ├── uartGetCommState.c │ ├── uartInit.c │ ├── uartPut.c │ ├── uartRead.c │ ├── uartSetCommState.c │ ├── uartStat.c │ └── uartWrite.c ├── udp │ ├── Makerules │ ├── udpAlloc.c │ ├── udpChksum.c │ ├── udpClose.c │ ├── udpControl.c │ ├── udpDemux.c │ ├── udpFreebuf.c │ ├── udpGetbuf.c │ ├── udpInit.c │ ├── udpOpen.c │ ├── udpRead.c │ ├── udpRecv.c │ ├── udpSend.c │ ├── udpWrite.c │ └── udp_Install.c ├── usb │ ├── Makerules │ ├── dwc2000 │ │ ├── Makerules │ │ ├── usb_dwc_hcd.c │ │ └── usb_dwc_regs.h │ ├── usbcore.c │ ├── usbdebug.c │ └── usbhub.c └── usbkbd │ ├── Makerules │ ├── usbKbdBindDevice.c │ ├── usbKbdControl.c │ ├── usbKbdGetc.c │ ├── usbKbdInit.c │ ├── usbKbdInterrupt.c │ ├── usbKbdRead.c │ ├── usbKbdUnbindDevice.c │ └── usbKbd_Install.c ├── docs ├── Getting-Started.rst ├── Introduction.rst ├── Makefile ├── README ├── arm │ ├── ARM-Interrupt-Handling.rst │ ├── ARM-Preemptive-Multitasking.rst │ ├── ARM-qemu.rst │ ├── index.rst │ └── rpi │ │ ├── BCM2835-Interrupt-Controller.rst │ │ ├── BCM2835-Memory-Barriers.rst │ │ ├── BCM2835-System-Timer.rst │ │ ├── BCM2835.rst │ │ ├── Raspberry-Pi-Interrupt-Handling.rst │ │ ├── Raspberry-Pi.rst │ │ ├── RaspberryPi.jpg │ │ ├── SMSC-LAN9512.rst │ │ ├── Synopsys-USB-Controller.rst │ │ ├── XinuPi.rst │ │ └── index.rst ├── conf.py ├── development │ ├── Build-System.rst │ ├── Documentation.rst │ ├── Git-Repository.rst │ ├── Kernel-Normal-Form.rst │ ├── Porting.rst │ ├── Systems-Laboratory.rst │ ├── Trace.rst │ ├── XINU-Summer2011.png │ └── index.rst ├── features │ ├── Mailboxes.rst │ ├── Memory-Management.rst │ ├── Message-Passing.rst │ ├── Preemptive-Multitasking.rst │ ├── Shell.rst │ ├── Standard-Library.rst │ ├── TTY-Driver.rst │ ├── TtyDriver.png │ ├── USB-Keyboard-Driver.rst │ ├── USB.rst │ ├── index.rst │ └── networking │ │ ├── ARP.rst │ │ ├── DHCP.rst │ │ ├── ICMP.rst │ │ ├── Networking-Stack.rst │ │ ├── Routing.rst │ │ ├── TCP.rst │ │ ├── TFTP.rst │ │ ├── UDP.rst │ │ ├── XINUNetStack-Print.jpeg │ │ ├── XINUNetStack-Screen.jpeg │ │ ├── XINUNetStack.pdf │ │ └── index.rst ├── index.rst ├── make.bat ├── mips │ ├── Common-Firmware-Environment.rst │ ├── EJTAG-ID-Codes-and-Implementation-Registers.rst │ ├── EJTAG.rst │ ├── Exception-and-Interrupt-Handling.rst │ ├── Flash-Driver.rst │ ├── Flash-Memory.rst │ ├── General-Purpose-Input-Output.rst │ ├── HOWTO-Backup-Router.rst │ ├── HOWTO-Connect-to-Modified-Router.rst │ ├── HOWTO-Install-OpenWRT.rst │ ├── HOWTO-Modify-the-ASUS-Hardware.rst │ ├── HOWTO-Modify-the-Linksys-Hardware.rst │ ├── HOWTO-Recover-Router.rst │ ├── Memory.rst │ ├── Mips-console.rst │ ├── Mipsel-qemu.rst │ ├── Processor.rst │ ├── Serial-Adapter-Diagrams.rst │ ├── Startup.rst │ ├── Switch-Driver.rst │ ├── TRX-Header.rst │ ├── UART-Driver.rst │ ├── WRT54GL.rst │ ├── images │ │ ├── Attach_Back.jpg │ │ ├── Attach_Front.jpg │ │ ├── Baytech.png │ │ ├── BaytechWiring.png │ │ ├── Complete.jpg │ │ ├── Complete_transceiver_board.jpg │ │ ├── Completed_transceiver.jpg │ │ ├── DB9M.png │ │ ├── DB9_serial_port_wiring.jpg │ │ ├── Drilled_front.jpg │ │ ├── Front.jpg │ │ ├── Front_sticker.jpg │ │ ├── Impcode.png │ │ ├── JTAGunbuffered.png │ │ ├── NullModem.png │ │ ├── Opening-linksys.jpg │ │ ├── Serial.jpg │ │ ├── Serial_Port_Connection.jpg │ │ ├── Serial_ports_diagram.jpg │ │ ├── Serial_ports_done.jpg │ │ ├── Serial_ports_done1.jpg │ │ ├── Te_jtag_cable.png │ │ ├── Tranceiver_attached.jpg │ │ ├── Transceiver_board.jpg │ │ ├── Transceiver_schematic.jpg │ │ ├── Transceiver_schematic_wl-330gE.jpg │ │ ├── UartAsyncDriver.png │ │ ├── Wiggler.png │ │ ├── Wrt54gl-layout.jpg │ │ └── Xinu-Wiggler.png │ └── index.rst ├── projects │ ├── Curses.rst │ ├── WinX.rst │ ├── WinXinu-Installation.rst │ ├── WinXinu.rst │ ├── XinuPhone.rst │ ├── Xinuphone-schematic-page1.png │ ├── Xinuphone-schematic-page2.png │ ├── Xinuphone-system.jpg │ ├── Xipx.rst │ └── index.rst ├── teaching │ ├── Adding-Monitors-To-Xinu.rst │ ├── Compiler-Construction-With-Embedded-Xinu.rst │ ├── HOWTO-Build-Backend-Pool.rst │ ├── HOWTO-Deploy-Xinu.rst │ ├── Laboratory.rst │ ├── Networking-With-Xinu.rst │ ├── Student-Built-Xinu.rst │ ├── Student-Extended-Xinu.rst │ ├── Xinu-Helper-Class.rst │ ├── assignments │ │ ├── ARP.rst │ │ ├── Asynchronous-Device-Driver.rst │ │ ├── Basic-Networking---Ping.rst │ │ ├── C-Basics.rst │ │ ├── C-Structs-and-Pointers.rst │ │ ├── Context-Switch-and-Non-Preemptive-Scheduling.rst │ │ ├── DHCP-Implementation.rst │ │ ├── Delta-Queues.rst │ │ ├── Heap-Memory.rst │ │ ├── IP-ICMP-ARP-Applications.rst │ │ ├── IP-ICMP.rst │ │ ├── Instruction-Selection.rst │ │ ├── LL-SC.rst │ │ ├── Networking-Applications.rst │ │ ├── Networking-Standards.rst │ │ ├── Packet-Demultiplexing.rst │ │ ├── Parser.rst │ │ ├── Preemption-and-Synchronization.rst │ │ ├── Priority-Scheduling-and-Preemption.rst │ │ ├── Priority-Scheduling-and-Process-Termination.rst │ │ ├── Scanner.rst │ │ ├── Semantic-Analysis.rst │ │ ├── Synchronization-and-Interprocess-Communication.rst │ │ ├── Synchronous-Serial-Driver.rst │ │ ├── TCP-Implementation.rst │ │ ├── Translation.rst │ │ ├── UDP-Implementation.rst │ │ ├── Ultra-Tiny-File-System.rst │ │ └── index.rst │ └── index.rst └── xinusource.py ├── include ├── arm.h ├── arp.h ├── backplane.h ├── bufpool.h ├── clock.h ├── compiler.h ├── conf.h ├── ctype.h ├── date.h ├── debug.h ├── device.h ├── dhcpc.h ├── dsp.h ├── endianness.h ├── ether.h ├── ethernet.h ├── ethloop.h ├── flash.h ├── framebuffer.h ├── gpio.h ├── http.h ├── icmp.h ├── ipv4.h ├── kbdmon.h ├── kernel.h ├── kexec.h ├── limits.h ├── loopback.h ├── mailbox.h ├── memory.h ├── mips.h ├── monitor.h ├── netemu.h ├── network.h ├── null.h ├── nvram.h ├── pcap.h ├── platform.h ├── queue.h ├── raw.h ├── route.h ├── rtp.h ├── safemem.h ├── sbchipc.h ├── sbconfig.h ├── sdmc.h ├── semaphore.h ├── shell.h ├── snoop.h ├── spi.h ├── stdarg.h ├── stdbool.h ├── stddef.h ├── stdint.h ├── stdio.h ├── stdlib.h ├── string.h ├── syscall.h ├── tar.h ├── tcp.h ├── telnet.h ├── testsuite.h ├── tftp.h ├── thread.h ├── tlb.h ├── tty.h ├── uart.h ├── udp.h ├── usb_core_driver.h ├── usb_hcdi.h ├── usb_hub_defs.h ├── usb_hub_driver.h ├── usb_std_defs.h ├── usb_subsystem.h ├── usb_util.h ├── usbkbd.h ├── version.h ├── vlan.h ├── watchdog.h └── xinu.h ├── lib ├── Makerules ├── libdsp │ ├── Makefile │ ├── linear2ulaw.c │ └── ulaw2linear.c └── libxc │ ├── Makefile │ ├── abs.c │ ├── atoi.c │ ├── atol.c │ ├── bzero.c │ ├── ctype_.c │ ├── doprnt.c │ ├── doscan.c │ ├── fgetc.c │ ├── fgets.c │ ├── fprintf.c │ ├── fputc.c │ ├── fputs.c │ ├── free.c │ ├── fscanf.c │ ├── labs.c │ ├── malloc.c │ ├── memchr.c │ ├── memcmp.c │ ├── memcpy.c │ ├── memset.c │ ├── printf.c │ ├── qsort.c │ ├── rand.c │ ├── sprintf.c │ ├── sscanf.c │ ├── strchr.c │ ├── strcmp.c │ ├── strcpy.c │ ├── strlcpy.c │ ├── strlen.c │ ├── strncat.c │ ├── strncmp.c │ ├── strncpy.c │ ├── strnlen.c │ ├── strrchr.c │ └── strstr.c ├── mailbox ├── Makerules ├── mailboxAlloc.c ├── mailboxCount.c ├── mailboxFree.c ├── mailboxInit.c ├── mailboxReceive.c └── mailboxSend.c ├── mem ├── Makerules ├── free.c ├── malloc.c ├── memRegionAlloc.c ├── memRegionClear.c ├── memRegionInit.c ├── memRegionInsert.c ├── memRegionReclaim.c ├── memRegionRemove.c ├── memRegionSplit.c ├── memRegionTransfer.c ├── memRegionValid.c ├── safeInit.c ├── safeKmapInit.c ├── safeMap.c ├── safeMapRange.c ├── safeUnmap.c ├── safeUnmapRange.c ├── tlbInit.c ├── tlbMiss.S └── tlbMissHandler.c ├── network ├── Makerules ├── arp │ ├── Makerules │ ├── arpAlloc.c │ ├── arpDaemon.c │ ├── arpFree.c │ ├── arpGetEntry.c │ ├── arpInit.c │ ├── arpLookup.c │ ├── arpNotify.c │ ├── arpRecv.c │ ├── arpSendReply.c │ └── arpSendRqst.c ├── dhcpc │ ├── Makerules │ ├── dhcp.h │ ├── dhcpClient.c │ ├── dhcpRecvReply.c │ └── dhcpSendRequest.c ├── emulate │ ├── Makerules │ ├── emuCorrupt.c │ ├── emuDelay.c │ ├── emuDrop.c │ ├── emuDuplicate.c │ ├── emuReorder.c │ └── netemu.c ├── icmp │ ├── Makerules │ ├── icmpDaemon.c │ ├── icmpDestUnreach.c │ ├── icmpEchoReply.c │ ├── icmpEchoRequest.c │ ├── icmpInit.c │ ├── icmpRecv.c │ ├── icmpRedirect.c │ ├── icmpSend.c │ └── icmpTimeExceeded.c ├── ipv4 │ ├── Makerules │ ├── dot2ipv4.c │ ├── ipv4Recv.c │ ├── ipv4RecvDemux.c │ ├── ipv4RecvValid.c │ ├── ipv4Send.c │ └── ipv4SendFrag.c ├── net │ ├── Makerules │ ├── netChksum.c │ ├── netDown.c │ ├── netFreebuf.c │ ├── netGetbuf.c │ ├── netInit.c │ ├── netLookup.c │ ├── netRecv.c │ ├── netSend.c │ └── netUp.c ├── netaddr │ ├── Makerules │ ├── netaddrequal.c │ ├── netaddrhost.c │ ├── netaddrmask.c │ └── netaddrsprintf.c ├── route │ ├── Makerules │ ├── rtAdd.c │ ├── rtAlloc.c │ ├── rtClear.c │ ├── rtDaemon.c │ ├── rtDefault.c │ ├── rtInit.c │ ├── rtLookup.c │ ├── rtRecv.c │ ├── rtRemove.c │ └── rtSend.c ├── snoop │ ├── Makerules │ ├── snoopCapture.c │ ├── snoopClose.c │ ├── snoopFilter.c │ ├── snoopOpen.c │ ├── snoopPrint.c │ ├── snoopPrintArp.c │ ├── snoopPrintEthernet.c │ ├── snoopPrintIpv4.c │ ├── snoopPrintTcp.c │ ├── snoopPrintUdp.c │ ├── snoopRead.c │ ├── snoopdhcp.c │ ├── snoopdns.c │ └── snoopicmp.c └── tftp │ ├── Makerules │ ├── tftpGet.c │ ├── tftpGetIntoBuffer.c │ ├── tftpRecvPackets.c │ ├── tftpSendACK.c │ └── tftpSendRRQ.c ├── shell ├── Makerules ├── getopt.c ├── lexan.c ├── shell.c ├── xsh_arp.c ├── xsh_clear.c ├── xsh_date.c ├── xsh_dumptlb.c ├── xsh_ethstat.c ├── xsh_exit.c ├── xsh_flashstat.c ├── xsh_gpiostat.c ├── xsh_help.c ├── xsh_kexec.c ├── xsh_kill.c ├── xsh_led.c ├── xsh_memdump.c ├── xsh_memstat.c ├── xsh_nc.c ├── xsh_netdown.c ├── xsh_netemu.c ├── xsh_netstat.c ├── xsh_netup.c ├── xsh_nvram.c ├── xsh_ping.c ├── xsh_pktgen.c ├── xsh_ps.c ├── xsh_rdate.c ├── xsh_reset.c ├── xsh_route.c ├── xsh_rtpstat.c ├── xsh_sleep.c ├── xsh_snoop.c ├── xsh_tar.c ├── xsh_tcpstat.c ├── xsh_telnet.c ├── xsh_telnetserver.c ├── xsh_test.c ├── xsh_testsuite.c ├── xsh_timeserver.c ├── xsh_turtle.c ├── xsh_uartstat.c ├── xsh_udpstat.c ├── xsh_usbinfo.c ├── xsh_user.c ├── xsh_vlanstat.c ├── xsh_voip.c └── xsh_xweb.c ├── system ├── Makerules ├── arch │ ├── README │ ├── arm │ │ ├── ctxsw.S │ │ ├── halt.S │ │ ├── intutils.S │ │ ├── irq_handler.S │ │ ├── memory_barrier.S │ │ ├── pause.S │ │ └── setupStack.c │ └── mips │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── debugbreak.S │ │ ├── debugret.S │ │ ├── exception.c │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── setupStack.c │ │ ├── start.S │ │ ├── syscall_dispatch.c │ │ └── syscall_entry.S ├── bufpool.c ├── chprio.c ├── clkhandler.c ├── close.c ├── conf.c ├── control.c ├── create.c ├── debug.c ├── getc.c ├── getdev.c ├── getitem.c ├── getprio.c ├── gettid.c ├── initialize.c ├── insert.c ├── insertd.c ├── ioerr.c ├── ionull.c ├── kill.c ├── lock.c ├── main.c ├── mdelay.c ├── memfree.c ├── memget.c ├── minijava.c ├── moncount.c ├── moncreate.c ├── monfree.c ├── open.c ├── platforms │ ├── arm-qemu │ │ ├── Makerules │ │ ├── clkinit.c │ │ ├── ctxsw.S │ │ ├── halt.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── irq_handler.S │ │ ├── memory_barrier.S │ │ ├── pause.S │ │ ├── pl190.c │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ ├── sp804.c │ │ └── start.S │ ├── arm-rpi │ │ ├── CriticalSection.c │ │ ├── CriticalSection.h │ │ ├── Makerules │ │ ├── ctxsw.S │ │ ├── dispatch │ │ ├── dispatch.c │ │ ├── halt.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── irq_handler.S │ │ ├── kexec.c │ │ ├── memory_barrier.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── rpi-mailbox.c │ │ ├── rpi-mailbox.h │ │ ├── rpi-platform.h │ │ ├── rpi-timer.c │ │ ├── setupStack.c │ │ ├── start.S │ │ └── watchdog.c │ ├── e2100l │ │ ├── Makerules │ │ ├── ar9130.h │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── dispatch.c │ │ ├── exception.c │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ └── start.S │ ├── mipsel-qemu │ │ ├── Makerules │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── dispatch.c │ │ ├── exception.c │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── pic8259.h │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ ├── start.S │ │ ├── syscall_dispatch.c │ │ └── syscall_entry.S │ ├── wl330ge │ │ ├── Makerules │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── debugbreak.S │ │ ├── debugret.S │ │ ├── dispatch.c │ │ ├── exception.c │ │ ├── flash.h │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ ├── start.S │ │ ├── syscall_dispatch.c │ │ └── syscall_entry.S │ ├── wrt160nl │ │ ├── Makerules │ │ ├── ar9130.h │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── dispatch.c │ │ ├── exception.c │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ └── start.S │ ├── wrt54gl │ │ ├── Makerules │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── debugbreak.S │ │ ├── debugret.S │ │ ├── dispatch.c │ │ ├── exception.c │ │ ├── halt.S │ │ ├── intdispatch.S │ │ ├── interrupt.h │ │ ├── intutils.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── setupStack.c │ │ ├── start.S │ │ ├── syscall_dispatch.c │ │ └── syscall_entry.S │ └── x86 │ │ ├── Makerules │ │ ├── asm-i386 │ │ ├── asm.h │ │ ├── icu.h │ │ └── xint.S │ │ ├── clkinit.c │ │ ├── clkupdate.S │ │ ├── ctxsw.S │ │ ├── dispatch.c │ │ ├── evec.c │ │ ├── halt.S │ │ ├── interrupt.h │ │ ├── intr.S │ │ ├── parport.S │ │ ├── pause.S │ │ ├── platforminit.c │ │ ├── segment.c │ │ ├── segment.h │ │ ├── setupStack.c │ │ ├── start.S │ │ ├── startup.S │ │ └── xtrap.c ├── putc.c ├── queinit.c ├── queue.c ├── read.c ├── ready.c ├── receive.c ├── recvclr.c ├── recvtime.c ├── resched.c ├── resume.c ├── seek.c ├── semcount.c ├── semcreate.c ├── semfree.c ├── send.c ├── signal.c ├── signaln.c ├── sleep.c ├── stkget.c ├── suspend.c ├── tar.c ├── udelay.c ├── unistd.c ├── unlock.c ├── unsleep.c ├── userret.c ├── wait.c ├── wakeup.c ├── write.c ├── xdone.c └── yield.c └── test ├── Makerules ├── test_arp.c ├── test_bigargs.c ├── test_bufpool.c ├── test_deltaQueue.c ├── test_ether.c ├── test_ethloop.c ├── test_ip.c ├── test_libCtype.c ├── test_libLimits.c ├── test_libStdio.c ├── test_libStdlib.c ├── test_libString.c ├── test_mailbox.c ├── test_memory.c ├── test_messagePass.c ├── test_netaddr.c ├── test_netif.c ├── test_nvram.c ├── test_preempt.c ├── test_procQueue.c ├── test_raw.c ├── test_recursion.c ├── test_schedule.c ├── test_semaphore.c ├── test_semaphore2.c ├── test_semaphore3.c ├── test_semaphore4.c ├── test_snoop.c ├── test_stub.c ├── test_system.c ├── test_tlb.c ├── test_ttydriver.c ├── test_udp.c ├── test_umemory.c └── testhelper.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | 4 | # Dependency files 5 | *.d 6 | 7 | # Libraries 8 | *.lib 9 | *.a 10 | 11 | # Shared objects (inc. Windows DLLs) 12 | *.dll 13 | *.so 14 | *.so.* 15 | *.dylib 16 | 17 | # Executables 18 | *.exe 19 | *.out 20 | *.app 21 | 22 | # Binary Images 23 | *.elf 24 | *.boot 25 | *.bin 26 | *.img 27 | *.map 28 | 29 | # Xinu build files 30 | compile/config/config 31 | compile/config/y.tab.h 32 | compile/config/parse.c 33 | compile/version 34 | compile/vn 35 | include/conf.h 36 | system/conf.c 37 | -------------------------------------------------------------------------------- /apps/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = apps 5 | 6 | # Source files for this component 7 | C_FILES = date.c rdate.c timeserver.c 8 | 9 | S_FILES = 10 | 11 | # Add the files to the compile source path 12 | DIR = ${TOPDIR}/${COMP} 13 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 14 | -------------------------------------------------------------------------------- /build/README.md: -------------------------------------------------------------------------------- 1 | #Build files from compile process end in this directory .. it must exist .. the reason for this file# -------------------------------------------------------------------------------- /compile/arch/README: -------------------------------------------------------------------------------- 1 | The purpose of this directory is explained in ../README.porting. 2 | -------------------------------------------------------------------------------- /compile/arch/arm/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile definitions for Embedded Xinu shared between all supported ARM 3 | # platforms. 4 | # 5 | 6 | TEMPLATE_ARCH := arm 7 | 8 | # Architecture root and prefix (ignored if user overrides COMPILER_ROOT from the 9 | # toplevel Makefile). 10 | ARCH_ROOT := D:/GCC/gcc-arm-none-eabi-8/bin/ 11 | ARCH_PREFIX := arm-none-eabi- 12 | 13 | # Flag for producing GDB debug information. 14 | BUGFLAG := -gstabs+ 15 | 16 | # Objcopy flags, used for including data files in the resulting binary. 17 | OCFLAGS := -I binary -O elf32-littlearm -B arm 18 | 19 | # Add a way to test for any ARM platform in C code. 20 | DEFS += -D_XINU_ARCH_ARM_ 21 | 22 | # Default built target. For ARM we just translate the kernel into a raw binary. 23 | $(BOOTIMAGE): xinu.elf 24 | $(OBJCOPY) -O binary $^ $@ 25 | -------------------------------------------------------------------------------- /compile/arch/x86/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile definitions for Embedded Xinu shared between all supported x86 3 | # platforms. 4 | # 5 | 6 | TEMPLATE_ARCH := x86 7 | 8 | # Architecture root and prefix (ignored if user overrides COMPILER_ROOT from the 9 | # toplevel Makefile). 10 | ARCH_ROOT := 11 | ARCH_PREFIX := 12 | 13 | # Flag for producing GDB debug information. 14 | BUGFLAG := -gstabs+ 15 | 16 | # Objcopy flags, used for including data files in the resulting binary. 17 | OCFLAGS := -I binary -O elf32-i386 -B i386 18 | 19 | # Add a way to test for any x86 platform in C code. 20 | DEFS += -D_XINU_ARCH_X86_ 21 | 22 | $(BOOTIMAGE): xinu.elf 23 | $(OBJCOPY) -O binary $^ $@ 24 | -------------------------------------------------------------------------------- /compile/data/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to include data in the data/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = data 5 | 6 | # pcap files 7 | PCAP_FILES = testarp.pcap testip.pcap testnetif.pcap testraw.pcap testsnoop.pcap testudp.pcap 8 | 9 | # tar files 10 | TAR_FILES = mytar.tar 11 | 12 | # Muster all the needed files together 13 | FILES = ${PCAP_FILES} ${TAR_FILES} 14 | 15 | # Add the files to the compile source path 16 | DIR = ${COMP} 17 | DATA_SRC += ${FILES:%=${DIR}/%} 18 | -------------------------------------------------------------------------------- /compile/data/mytar.tar.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/mytar.tar.o -------------------------------------------------------------------------------- /compile/data/testarp.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testarp.pcap -------------------------------------------------------------------------------- /compile/data/testarp.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testarp.pcap.o -------------------------------------------------------------------------------- /compile/data/testip.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testip.pcap -------------------------------------------------------------------------------- /compile/data/testip.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testip.pcap.o -------------------------------------------------------------------------------- /compile/data/testnetif.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testnetif.pcap -------------------------------------------------------------------------------- /compile/data/testnetif.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testnetif.pcap.o -------------------------------------------------------------------------------- /compile/data/testnetif.txt: -------------------------------------------------------------------------------- 1 | AABBCCDDEEAA 2 | AABBCCDDEEFF 3 | 0806 4 | 0001 5 | 0800 6 | 06 7 | 04 8 | 0002 9 | AABBCCDDEEFF 10 | C0A80106 11 | AABBCCDDEEAA 12 | C0A80101 13 | -------------------------------------------------------------------------------- /compile/data/testraw.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testraw.pcap -------------------------------------------------------------------------------- /compile/data/testraw.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testraw.pcap.o -------------------------------------------------------------------------------- /compile/data/testraw.txt: -------------------------------------------------------------------------------- 1 | # (1) ICMP request 192.168.1.1 > 192.168.1.6 2 | AABBCCDD 3 | EEFFAABB 4 | CCDDEEAA 5 | 08004500 6 | 001C0000 7 | 00004001 8 | F789C0A8 9 | 0101C0A8 10 | 01060800 11 | F7FE0000 12 | 0001 13 | 14 | # (2) ARP Reply 192.168.1.1 > 192.168.1.6 15 | AABBCCDDEEFF 16 | AABBCCDDEEAA 17 | 0806 18 | 0001 19 | 0800 20 | 06 21 | 04 22 | 0002 23 | AABBCCDDEEAA 24 | C0A80101 25 | AABBCCDDEEFF 26 | C0A80106 27 | 28 | # (3) ICMP request 192.168.1.6 > 192.168.1.1 29 | AABBCCDD 30 | EEAAAABB 31 | CCDDEEFF 32 | 08004500 33 | 001C0000 34 | 00004001 35 | F789C0A8 36 | 0106C0A8 37 | 01010800 38 | F7FF0000 39 | 0000 40 | -------------------------------------------------------------------------------- /compile/data/testsnoop.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testsnoop.pcap -------------------------------------------------------------------------------- /compile/data/testsnoop.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testsnoop.pcap.o -------------------------------------------------------------------------------- /compile/data/testudp.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testudp.pcap -------------------------------------------------------------------------------- /compile/data/testudp.pcap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/compile/data/testudp.pcap.o -------------------------------------------------------------------------------- /compile/platforms/mipsel-qemu/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Platform-specific Makefile definitions for the Mipsel QEMU port of Embedded 3 | # Xinu. 4 | # 5 | 6 | PLATFORM_NAME := MIPSel QEMU 7 | 8 | # Include default mipsel definitions 9 | MIPS_ENDIANNESS := little 10 | MIPS_REVISION := 1 11 | include arch/mips/platformVars 12 | 13 | # Embedded Xinu components to build into kernel image 14 | APPCOMPS := apps \ 15 | mailbox \ 16 | shell \ 17 | test 18 | 19 | # Embedded Xinu device drivers to build into the kernel image 20 | DEVICES := loopback \ 21 | tty \ 22 | uart-ns16550 23 | -------------------------------------------------------------------------------- /compile/platforms/wl330ge/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Platform-specific Makefile definitions for the ASUS WL-330gE port of Embedded 3 | # Xinu. 4 | # 5 | 6 | PLATFORM_NAME := ASUS WL-330gE 7 | 8 | # Include default mipsel definitions 9 | MIPS_ENDIANNESS := little 10 | MIPS_REVISION := 1 11 | include arch/mips/platformVars 12 | 13 | # Embedded Xinu components to build into kernel image 14 | APPCOMPS := apps \ 15 | mailbox \ 16 | network \ 17 | shell \ 18 | test 19 | 20 | # Embedded Xinu device drivers to build into the kernel image 21 | DEVICES := bcm4713 \ 22 | bcmbus \ 23 | ethloop \ 24 | flash \ 25 | http \ 26 | loopback \ 27 | raw \ 28 | tcp \ 29 | telnet \ 30 | tty \ 31 | uart-ns16550 \ 32 | udp 33 | 34 | # Extra defines 35 | DEFS += -DFLASH_ASUS 36 | -------------------------------------------------------------------------------- /compile/platforms/wrt54gl/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Platform-specific Makefile definitions for the Linksys WRT54GL port of 3 | # Embedded Xinu. 4 | # 5 | 6 | PLATFORM_NAME := Linksys WRT54GL Wireless Router 7 | 8 | # Include default mipsel definitions 9 | MIPS_ENDIANNESS := little 10 | MIPS_REVISION := 1 11 | include arch/mips/platformVars 12 | 13 | # Embedded Xinu components to build into kernel image 14 | APPCOMPS := apps \ 15 | mailbox \ 16 | network \ 17 | shell \ 18 | test 19 | 20 | # Embedded Xinu device drivers to build into the kernel image 21 | DEVICES := bcm4713 \ 22 | bcmbus \ 23 | ethloop \ 24 | flash \ 25 | http \ 26 | loopback \ 27 | raw \ 28 | tcp \ 29 | telnet \ 30 | tty \ 31 | uart-ns16550 \ 32 | udp 33 | -------------------------------------------------------------------------------- /compile/platforms/x86/platformVars: -------------------------------------------------------------------------------- 1 | # 2 | # Platform-specific Makefile definitions for the x86 port of Embedded Xinu. 3 | # 4 | 5 | # Include default x86 definitions 6 | include arch/x86/platformVars 7 | 8 | PLATFORM_NAME := Intel x86 9 | 10 | # Add flags to compile 32 bit code 11 | CFLAGS += -m32 12 | ASFLAGS += --32 13 | 14 | # Add a define so we can test for x86 in C code if absolutely needed 15 | DEFS += -D_XINU_PLATFORM_X86_ 16 | 17 | # Embedded Xinu components to build into the kernel image 18 | APPCOMPS := apps mailbox shell test 19 | 20 | # Embedded Xinu device drivers to build into the kernel image 21 | DEVICES := loopback tty uart-x86 22 | -------------------------------------------------------------------------------- /device/drive/rpi_SDcard/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/drive/rpi_SDcard 5 | 6 | # Source files for this component 7 | C_FILES = rpi_sdcard_Init.c \ 8 | rpi_sdcard_Install.c 9 | 10 | S_FILES = 11 | 12 | # Add the files to the compile source path 13 | DIR = ${TOPDIR}/${COMP} 14 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 15 | -------------------------------------------------------------------------------- /device/drive/rpi_SDcard/rpi-sdcard.h: -------------------------------------------------------------------------------- 1 | #ifndef RPI_SDCARD_H 2 | #define RPI_SDCARD_H 3 | 4 | #include 5 | 6 | #define SD_OK 0 7 | #define SD_ERROR 1 8 | #define SD_TIMEOUT 2 9 | #define SD_BUSY 3 10 | #define SD_NO_RESP 5 11 | #define SD_ERROR_RESET 6 12 | #define SD_ERROR_CLOCK 7 13 | #define SD_ERROR_VOLTAGE 8 14 | #define SD_ERROR_APP_CMD 9 15 | #define SD_CARD_CHANGED 10 16 | #define SD_CARD_ABSENT 11 17 | #define SD_CARD_REINSERTED 12 18 | 19 | #define SD_READ_BLOCKS 0 20 | #define SD_WRITE_BLOCKS 1 21 | 22 | int sdInit(); 23 | int sdInitCard(); 24 | int sdReadSingleBlock (uintptr_t address, uint8_t* buffer ); 25 | int sdWriteSingleBlock (uintptr_t address, uint8_t* buffer ); 26 | int sdTransferBlocks( uint32_t blockaddr, uint32_t num, uint8_t* buffer, bool write ); 27 | int sdClearBlocks( uintptr_t address, int num ); 28 | 29 | #endif // RPI_SDCARD_H 30 | -------------------------------------------------------------------------------- /device/drive/rpi_SDcard/rpi_sdcard_Init.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rpi_sdcard_init.c 3 | * 4 | * Initialization for the Raspbeery Pi SD controller. 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2013, 2018. All rights reserved. */ 7 | 8 | #include 9 | #include 10 | #include "rpi-sdcard.h" 11 | 12 | 13 | struct sdmcblk sdmctab[NSDDEV]; 14 | 15 | /*------------------------------------------------------------------------ 16 | * sdmcinit - initialize the SD memory card device 17 | *------------------------------------------------------------------------ 18 | */ 19 | xinu_devcall sdmcinit( struct dentry *devptr ) 20 | { 21 | 22 | 23 | return OK; 24 | } 25 | -------------------------------------------------------------------------------- /device/drive/rpi_SDcard/rpi_sdcard_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rpi_sdcard_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "rpi-sdcard.h" 11 | 12 | 13 | struct sdmcblk sdmctab[NSDDEV]; 14 | 15 | xinu_devcall rpi_sdcard_Install (const char* sdmcdevname, unsigned int sdmcctrlnum, uintptr_t addr) 16 | { 17 | /* Set the actual data on the gpio tab */ 18 | struct sdmcblk *sdmcptr; 19 | sdmcptr = &sdmctab[sdmcctrlnum].ctrl; // Pointer to gpio pin control device entry 20 | sdmcptr->reg_data = addr; // Hold the address to GPIO registers 21 | sdmcptr->name =sdmcdevname; // Hold the device name 22 | 23 | return sdmcctrlnum; 24 | } -------------------------------------------------------------------------------- /device/ethernet/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/ethernet 5 | 6 | # Source files for this component 7 | C_FILES = \ 8 | colon2mac.c \ 9 | etherInit.c \ 10 | etherClose.c \ 11 | etherControl.c \ 12 | etherRead.c \ 13 | etherStat.c \ 14 | vlanStat.c 15 | # etherInterrupt.c \ 16 | # etherOpen.c \ 17 | # etherWrite.c \ 18 | 19 | S_FILES = 20 | 21 | # Add the files to the compile source path 22 | DIR = ${TOPDIR}/${COMP} 23 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 24 | -------------------------------------------------------------------------------- /device/ethernet/etherClose.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file etherClose.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /* Implementation of etherClose() see details of this function in ether.h. */ 10 | xinu_devcall etherClose (device *devptr) 11 | { 12 | /* TODO: need to handle canceling all the outstanding USB requests, etc. */ 13 | return SYSERR; 14 | } 15 | -------------------------------------------------------------------------------- /device/ethernet/lan78xx/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/ethernet/lan78xx 5 | 6 | # Source files for this component 7 | C_FILES = \ 8 | lan78xx.c \ 9 | lan78xx_Init.c \ 10 | lan78xx_Open.c \ 11 | lan78xx_Write.c \ 12 | lan78xx_Interrupt.c \ 13 | lan78xx_Install.c 14 | 15 | S_FILES = 16 | 17 | # Add the files to the compile source path 18 | DIR = ${TOPDIR}/${COMP} 19 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 20 | -------------------------------------------------------------------------------- /device/ethernet/smsc9512/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/ethernet/smsc9512 5 | 6 | # Source files for this component 7 | C_FILES = \ 8 | smsc9512_Init.c \ 9 | smsc9512Interrupt.c \ 10 | smsc9512Open.c \ 11 | smsc9512Write.c \ 12 | smsc9512.c \ 13 | smsc9512_Install.c 14 | 15 | S_FILES = 16 | 17 | # Add the files to the compile source path 18 | DIR = ${TOPDIR}/${COMP} 19 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 20 | -------------------------------------------------------------------------------- /device/ethernet/vlanStat.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file vlanStat.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int vlanStat(void) 11 | { 12 | fprintf(stderr, "ERROR: VLANs not supported by this driver.\n"); 13 | return SYSERR; 14 | } 15 | -------------------------------------------------------------------------------- /device/ethloop/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/ethloop 5 | 6 | # Source files for this component 7 | C_FILES = ethloopClose.c ethloopControl.c ethloopOpen.c ethloopWrite.c ethloopRead.c ethloopInit.c ethloop_Install.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/ethloop/ethloopInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ethloopInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct ethloop elooptab[NETHLOOP] = { 0 }; 13 | 14 | /** 15 | * @ingroup ethloop 16 | * 17 | * Initialize ethloop device 18 | * @param devptr 19 | * @return OK on open 20 | */ 21 | xinu_devcall ethloopInit (device *devptr) 22 | { 23 | struct ethloop *elpptr; 24 | 25 | elpptr = &elooptab[devptr->minor]; 26 | //bzero(elpptr, sizeof(struct ethloop)); /* cant do that install has set function ptrs */ 27 | elpptr->state = ELOOP_STATE_FREE; 28 | 29 | return OK; 30 | } 31 | -------------------------------------------------------------------------------- /device/ethloop/ethloop_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ethloop_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall ethloop_Install (unsigned int DevTabNum, const char* devname, unsigned int eloopNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = eloopNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = ethloopInit; 16 | devtab[DevTabNum].open = ethloopOpen; 17 | devtab[DevTabNum].close = ethloopClose; 18 | devtab[DevTabNum].read = ethloopRead; 19 | devtab[DevTabNum].write = ethloopWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = 0; 22 | devtab[DevTabNum].putc = 0; 23 | devtab[DevTabNum].control = ethloopControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | elooptab[eloopNum].dev = &devtab[DevTabNum]; 29 | return DevTabNum; 30 | } -------------------------------------------------------------------------------- /device/framebuffer_rpi/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/framebuffer_rpi 5 | 6 | # Source files for this component 7 | S_FILES = 8 | C_FILES = screenInit.c drawShapes.c fbPutc.c fbWrite.c trig.c framebuffer_Install.c 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/framebuffer_rpi/font8x12.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/device/framebuffer_rpi/font8x12.h -------------------------------------------------------------------------------- /device/gpio/Makerules: -------------------------------------------------------------------------------- 1 | 2 | # Name of this component (the directory this file is stored in) 3 | COMP = device/gpio 4 | 5 | # Source files for this component 6 | C_FILES = gpioInit.c 7 | 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/gpio/rpi_gpio/Makerules: -------------------------------------------------------------------------------- 1 | 2 | # Name of this component (the directory this file is stored in) 3 | COMP = device/gpio/rpi_gpio 4 | 5 | # Source files for this component 6 | C_FILES = rpi_gpioHwInit.c rpi_gpioHwSet.c rpi_gpioHwGet.c rpi_gpioHwSetMode.c rpi_gpio_Install.c 7 | 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/gpio/rpi_gpio/rpi_gpioHwInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rpi-gpioHwInit.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 20018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | int rpi_gpiHwInit (struct pinctrl_dev *pctldev, void* config) 12 | { 13 | 14 | return OK; 15 | } 16 | -------------------------------------------------------------------------------- /device/http/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/http 5 | 6 | # Source files for this component 7 | DEV_FILES = httpClose.c httpControl.c \ 8 | httpGetc.c httpInit.c httpOpen.c httpPutc.c \ 9 | httpRead.c httpWrite.c 10 | HELP_FILES = httpAlloc.c httpCleanPrompts.c httpConfigPage.c \ 11 | httpErrorResponse.c \ 12 | httpFlushWBuffer.c httpFree.c \ 13 | httpHtmlBegin.c httpReadRqst.c \ 14 | httpReadHdrs.c httpValidations.c 15 | SERVER_FILES = httpServer.c 16 | 17 | S_FILES = 18 | 19 | C_FILES = ${DEV_FILES} ${HELP_FILES} ${SERVER_FILES} 20 | 21 | # Add the files to the compile source path 22 | DIR = ${TOPDIR}/${COMP} 23 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 24 | -------------------------------------------------------------------------------- /device/http/httpAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file httpAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | /** 14 | * Allocate an available http device. 15 | * @return device number for a http device, SYSERR if none are free 16 | */ 17 | int httpAlloc(void) 18 | { 19 | irqmask ps; 20 | int i; 21 | 22 | ps = disable(); 23 | for (i = 0; i < NHTTP; ++i) 24 | { 25 | if (HTTP_STATE_FREE == httptab[i].state) 26 | { 27 | httptab[i].state = HTTP_STATE_ALLOC; 28 | restore(ps); 29 | return i + HTTP0; 30 | } 31 | } 32 | restore(ps); 33 | 34 | return SYSERR; 35 | } 36 | -------------------------------------------------------------------------------- /device/http/httpFlushWBuffer.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file httpFlushWBuffer.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * Flush the intermediate write buffer out to underlying device. 12 | * @param devptr HTTP device that has the buffer to flush 13 | */ 14 | void httpFlushWBuffer(device *devptr) 15 | { 16 | /* Set the flush flag */ 17 | httpControl(devptr, HTTP_CTRL_SET_FLAG, HTTP_FLAG_FLUSHWOUT, NULL); 18 | 19 | /* Write a zero length buf, write will flush because of set flag */ 20 | httpWrite(devptr, NULL, 0); 21 | 22 | /* Clear the flush flag */ 23 | httpControl(devptr, HTTP_CTRL_CLR_FLAG, HTTP_FLAG_FLUSHWOUT, NULL); 24 | } 25 | -------------------------------------------------------------------------------- /device/http/httpFree.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file httpFree.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * Free an allocated HTTP device. 14 | * @param devptr pointer to HTTP device 15 | * @return OK if HTTP is freed properly, otherwise SYSERR 16 | */ 17 | int httpFree(device *devptr) 18 | { 19 | irqmask im; 20 | 21 | im = disable(); 22 | httptab[devptr->minor].state = HTTP_STATE_FREE; 23 | restore(im); 24 | 25 | /* Signal the counter for HTTP threads */ 26 | signal(maxhttp); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /device/http/httpGetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file httpGetc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * Read a single character from a HTTP. 12 | * @param devptr HTTP device table entry 13 | * @return character read from HTTP, or result if invalid read return 14 | */ 15 | devcall httpGetc(device *devptr) 16 | { 17 | char ch; 18 | int result = NULL; 19 | 20 | result = httpRead(devptr, &ch, 1); 21 | 22 | if (1 != result) 23 | { 24 | return result; 25 | } 26 | 27 | return ch; 28 | } 29 | -------------------------------------------------------------------------------- /device/loopback/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the device/tty/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/loopback 5 | 6 | # Source files for this component 7 | C_FILES = loopbackGetc.c loopbackClose.c loopbackOpen.c loopbackPutc.c loopbackWrite.c loopbackRead.c loopbackControl.c loopbackInit.c loopback_Install.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/loopback/loopbackClose.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file loopbackClose.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup loopback 15 | * 16 | * Close a loopback device. 17 | * @param devptr loopback device table entry 18 | * @return OK if loopback is closed properly, otherwise SYSERR 19 | */ 20 | xinu_devcall loopbackClose (device *devptr) 21 | { 22 | struct loopback *lbkptr; 23 | 24 | lbkptr = &looptab[devptr->minor]; 25 | 26 | ENTER_KERNEL_CRITICAL_SECTION(); 27 | if (LOOP_STATE_ALLOC != lbkptr->state) 28 | { 29 | EXIT_KERNEL_CRITICAL_SECTION(); 30 | return SYSERR; 31 | } 32 | 33 | /* free the semaphore */ 34 | semfree(lbkptr->sem); 35 | lbkptr->state = LOOP_STATE_FREE; 36 | 37 | EXIT_KERNEL_CRITICAL_SECTION(); 38 | return OK; 39 | } 40 | -------------------------------------------------------------------------------- /device/loopback/loopbackInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file loopbackInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct loopback looptab[NLOOPBACK] = { 0 }; 13 | 14 | /** 15 | * @ingroup loopback 16 | * 17 | * Initialize loopback device 18 | * @param devptr 19 | * @return OK on open 20 | */ 21 | xinu_devcall loopbackInit(device *devptr) 22 | { 23 | struct loopback *lbkptr; 24 | 25 | lbkptr = &looptab[devptr->minor]; 26 | lbkptr->state = LOOP_STATE_FREE; 27 | lbkptr->index = 0; 28 | 29 | return OK; 30 | } 31 | -------------------------------------------------------------------------------- /device/null/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/null 5 | 6 | # Source files for this component 7 | S_FILES = 8 | C_FILES = null_Install.c 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/null/null_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file null_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | xinu_devcall null_Install (unsigned int DevTabNum, const char* devname) 10 | { 11 | devtab[DevTabNum].num = DevTabNum; 12 | devtab[DevTabNum].minor = 0; 13 | devtab[DevTabNum].name = (char*)devname; 14 | devtab[DevTabNum].init = 0; 15 | devtab[DevTabNum].open = 0; 16 | devtab[DevTabNum].close = 0; 17 | devtab[DevTabNum].read = 0; 18 | devtab[DevTabNum].write = 0; 19 | devtab[DevTabNum].seek = 0; 20 | devtab[DevTabNum].getc = 0; 21 | devtab[DevTabNum].putc = 0; 22 | devtab[DevTabNum].control = 0; 23 | devtab[DevTabNum].csr = 0; 24 | devtab[DevTabNum].intr = 0; 25 | devtab[DevTabNum].irq = 0; 26 | 27 | return DevTabNum; 28 | } -------------------------------------------------------------------------------- /device/raw/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/raw 5 | 6 | # Source files for this component 7 | C_FILES = rawClose.c rawControl.c rawDemux.c rawInit.c rawOpen.c rawRead.c rawRecv.c rawSend.c rawWrite.c raw_Install.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/raw/rawInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rawInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct raw rawtab[NRAW]; 13 | 14 | /** 15 | * @ingroup raw 16 | * 17 | * Initialize raw socket structures. 18 | * @param devptr RAW device table entry 19 | * @return OK if device is initialized 20 | */ 21 | xinu_devcall rawInit(device *devptr) 22 | { 23 | struct raw *rawptr; 24 | 25 | rawptr = &rawtab[devptr->minor]; 26 | bzero(rawptr, sizeof(struct raw)); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /device/raw/rawWrite.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rawWrite.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup raw 13 | * 14 | * Write a packet to a raw socket. 15 | * @param devptr pointer to RAW device 16 | * @param buf buffer to write 17 | * @param len size of the buffer 18 | * @return number of octets written, SYSERR if error occurred 19 | */ 20 | xinu_devcall rawWrite(device *devptr, const void *buf, unsigned int len) 21 | { 22 | struct raw *rawptr; 23 | 24 | rawptr = &rawtab[devptr->minor]; 25 | return rawSend(rawptr, buf, len); 26 | } 27 | -------------------------------------------------------------------------------- /device/raw/raw_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file null_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall raw_Install (unsigned int DevTabNum, const char* devname, unsigned int rawNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = rawNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = rawInit; 16 | devtab[DevTabNum].open = rawOpen; 17 | devtab[DevTabNum].close = rawClose; 18 | devtab[DevTabNum].read = rawRead; 19 | devtab[DevTabNum].write = rawWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = 0; 22 | devtab[DevTabNum].putc = 0; 23 | devtab[DevTabNum].control = rawControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | rawtab[rawNum].dev = &devtab[DevTabNum]; 29 | return DevTabNum; 30 | } -------------------------------------------------------------------------------- /device/rtp/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/rtp 5 | 6 | # Source files for this component 7 | C_FILES = rtpAlloc.c rtpClose.c rtpFreebuf.c rtpGetbuf.c rtpInit.c rtpOpen.c rtpRead.c rtpRecv.c rtpSend.c rtpWrite.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/rtp/rtpAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtpAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * Allocate an available rtp device. 14 | * @return device number for a rtp device, SYSERR if none are free 15 | */ 16 | ushort rtpAlloc(void) 17 | { 18 | irqmask im; 19 | int i; 20 | 21 | im = disable(); 22 | for (i = 0; i < NRTP; i++) 23 | { 24 | if (RTP_FREE == rtptab[i].state) 25 | { 26 | rtptab[i].state = RTP_ALLOC; 27 | restore(im); 28 | return i + RTP0; 29 | } 30 | } 31 | restore(im); 32 | 33 | return SYSERR; 34 | } 35 | -------------------------------------------------------------------------------- /device/rtp/rtpFreebuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtpFreebuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | syscall rtpFreebuf(struct rtpPkt *rtppkt) 13 | { 14 | return buffree(rtppkt); 15 | } 16 | -------------------------------------------------------------------------------- /device/rtp/rtpGetbuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtpGetbuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct rtpPkt *rtpGetbuf(struct rtp *rtpptr) 14 | { 15 | struct rtpPkt *rtppkt = NULL; 16 | 17 | rtppkt = bufget(rtpptr->inPool); 18 | if (SYSERR == (int)rtppkt) 19 | { 20 | return (struct rtpPkt *)SYSERR; 21 | } 22 | 23 | bzero(rtppkt, NET_MAX_PKTLEN); 24 | 25 | return rtppkt; 26 | } 27 | -------------------------------------------------------------------------------- /device/rtp/rtpInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtpInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct rtp rtptab[NRTP]; 14 | 15 | /** 16 | * Set aside some space for a RTP device to be opened on 17 | * @param devptr UDP device table entry 18 | * @return OK 19 | */ 20 | devcall rtpInit(device *devptr) 21 | { 22 | struct rtp *rtpptr; 23 | 24 | rtpptr = &rtptab[devptr->minor]; 25 | bzero(rtpptr, sizeof(struct rtp)); 26 | 27 | return OK; 28 | } 29 | -------------------------------------------------------------------------------- /device/tcp/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/tcp 5 | 6 | # Source files for this component 7 | C_FILES = tcpAlloc.c tcpChksum.c tcpClose.c tcpControl.c \ 8 | tcpDemux.c tcpFree.c tcpGetc.c tcpInit.c tcpOpen.c \ 9 | tcpOpenActive.c tcpPutc.c tcpRead.c \ 10 | tcpRecvAck.c tcpRecv.c tcpRecvData.c tcpRecvListen.c \ 11 | tcpRecvOpts.c tcpRecvOther.c tcpRecvRtt.c \ 12 | tcpRecvSynsent.c tcpRecvValid.c tcpSendAck.c tcpSend.c \ 13 | tcpSendData.c tcpSendPersist.c tcpSendRst.c tcpSendRxt.c \ 14 | tcpSendSyn.c tcpSendWindow.c tcpSeqdiff.c tcpSetup.c tcpStat.c \ 15 | tcpTimer.c tcpTimerPurge.c tcpTimerRemain.c tcpTimerSched.c \ 16 | tcpTimerTrigger.c tcpWrite.c tcp_Install.c 17 | 18 | S_FILES = 19 | 20 | # Add the files to the compile source path 21 | DIR = ${TOPDIR}/${COMP} 22 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 23 | -------------------------------------------------------------------------------- /device/tcp/tcpAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup tcp 13 | * 14 | * Allocate an available tcp device. 15 | * @return device number for a tcp device, SYSERR if none are free 16 | */ 17 | unsigned short tcpAlloc(void) 18 | { 19 | int i; 20 | 21 | for (i = 0; i < NTCP; i++) 22 | { 23 | wait(tcptab[i].mutex); 24 | if (TCP_FREE == tcptab[i].devstate) 25 | { 26 | tcptab[i].devstate = TCP_ALLOC; 27 | signal(tcptab[i].mutex); 28 | return i + TCP0; 29 | } 30 | signal(tcptab[i].mutex); 31 | } 32 | return SYSERR; 33 | } 34 | -------------------------------------------------------------------------------- /device/tcp/tcpGetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpGetc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup tcp 13 | * 14 | * Read into a single octet from TCP. 15 | * @param devptr TCP device table entry 16 | * @return character read from TCP 17 | */ 18 | xinu_devcall tcpGetc(device *devptr) 19 | { 20 | unsigned char ch; 21 | int result = 0; 22 | 23 | result = tcpRead(devptr, &ch, 1); 24 | 25 | if (result != 1) 26 | { 27 | return result; 28 | } 29 | 30 | return ch; 31 | } 32 | -------------------------------------------------------------------------------- /device/tcp/tcpInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct tcb tcptab[NTCP]; 13 | 14 | /** 15 | * @ingroup tcp 16 | * 17 | * Initialize TCP structures. 18 | * @param devptr tcp device table entry 19 | * @return OK if device is initialized 20 | */ 21 | xinu_devcall tcpInit(device *devptr) 22 | { 23 | struct tcb *tcbptr; 24 | 25 | tcbptr = &tcptab[devptr->minor]; 26 | bzero(tcbptr, sizeof(struct tcb)); 27 | tcbptr->state = TCP_CLOSED; 28 | tcbptr->devstate = TCP_FREE; 29 | tcbptr->mutex = semcreate(1); 30 | if (SYSERR == (int)tcbptr->mutex) 31 | { 32 | return SYSERR; 33 | } 34 | 35 | return OK; 36 | } 37 | -------------------------------------------------------------------------------- /device/tcp/tcpOpenActive.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpOpenActive.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup tcp 12 | * 13 | * Actively opens a TCP connection. 14 | * @param tcbptr TCB for connection 15 | * @return OK if tcp is opened properly, otherwise SYSERR 16 | * @pre-condition TCB mutex is already held 17 | * @post-condition TCB mutex is still held 18 | */ 19 | xinu_devcall tcpOpenActive(struct tcb *tcbptr) 20 | { 21 | /* Verify connection is fully specified */ 22 | if ((NULL == tcbptr->remotept) || (NULL == tcbptr->remoteip.type) 23 | || (NULL == tcbptr->localip.type)) 24 | { 25 | return TCP_ERR_NOSPEC; 26 | } 27 | 28 | if (SYSERR == tcpSendSyn(tcbptr)) 29 | { 30 | return SYSERR; 31 | } 32 | 33 | tcbptr->state = TCP_SYNSENT; 34 | 35 | return OK; 36 | } 37 | -------------------------------------------------------------------------------- /device/tcp/tcpPutc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpPutc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup tcp 12 | * 13 | * Write a single octet to send via TCP. 14 | * 15 | * @param devptr 16 | * TCP device table entry 17 | * 18 | * @param ch 19 | * character to output 20 | * 21 | * @return 22 | * @p ch as an unsigned char cast to an @c int on success; @c 23 | * SYSERR on failure. 24 | */ 25 | xinu_devcall tcpPutc(device *devptr, char ch) 26 | { 27 | int ret; 28 | 29 | ret = tcpWrite(devptr, &ch, 1); 30 | if (ret == 1) 31 | { 32 | return (unsigned char)ch; 33 | } 34 | else 35 | { 36 | return SYSERR; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /device/tcp/tcpSendAck.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpSendAck.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup tcp 12 | * 13 | * Sends an ACK packet to ackowledge all received data for a TCP connection. 14 | * @param tcpptr pointer to the transmission control block for connection 15 | * @pre-condition TCB mutex is already held 16 | * @post-condition TCB mutex is still held 17 | */ 18 | int tcpSendAck(struct tcb *tcbptr) 19 | { 20 | tcbptr->sndflg &= ~TCP_FLG_SNDACK; 21 | return tcpSend(tcbptr, TCP_CTRL_ACK, tcbptr->sndnxt, 22 | tcbptr->rcvnxt, 0, 0); 23 | } 24 | -------------------------------------------------------------------------------- /device/tcp/tcpSeqdiff.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpSeqdiff.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup tcp 12 | * 13 | * Calculates the difference between two sequence numbers. 14 | * @param first sequence number that occurs first 15 | * @param second sequence number that occurs second 16 | * @return difference between two sequence numbers 17 | */ 18 | tcpseq tcpSeqdiff(tcpseq first, tcpseq second) 19 | { 20 | /* if (first <= second) 21 | { return (second-first); } 22 | else 23 | { return ((TCP_MAXSEQ - first) + second); }*/ 24 | 25 | if ((first < (TCP_MAXSEQ / 2)) && (second > (TCP_MAXSEQ / 2))) 26 | { 27 | return ((TCP_MAXSEQ - first) + second); 28 | } 29 | 30 | if ((second < (TCP_MAXSEQ / 2)) && (first > (TCP_MAXSEQ / 2))) 31 | { 32 | return ((TCP_MAXSEQ - first) + second); 33 | } 34 | 35 | return first - second; 36 | } 37 | -------------------------------------------------------------------------------- /device/tcp/tcpTimerRemain.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpTimerRemain.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup tcp 13 | * 14 | * Determine time reamining for a TCP timer event for a particular TCB. 15 | * @param tcbptr TCB to which event corresponds 16 | * @param type type of timer event 17 | * @return time remaining for event, 0 if no event exists 18 | */ 19 | int tcpTimerRemain(struct tcb *tcbptr, unsigned char type) 20 | { 21 | struct tcpEvent *cur = NULL; 22 | int time = 0; 23 | 24 | wait(tcpmutex); 25 | cur = tcptimertab[TCP_EVT_HEAD].next; 26 | while (cur != NULL) 27 | { 28 | time += cur->remain; 29 | if ((cur->tcbptr == tcbptr) && (cur->type == type)) 30 | { 31 | signal(tcpmutex); 32 | return time; 33 | } 34 | cur = cur->next; 35 | } 36 | signal(tcpmutex); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /device/tcp/tcpTimerTrigger.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tcpTimerTrigger.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup tcp 13 | * 14 | * Processes TCP timer events. 15 | * @param evtptr timer event to process 16 | */ 17 | void tcpTimerTrigger(unsigned char type, struct tcb *tcbptr) 18 | { 19 | switch (type) 20 | { 21 | case TCP_EVT_TIMEWT: 22 | wait(tcbptr->mutex); 23 | tcpFree(tcbptr); 24 | return; 25 | case TCP_EVT_RXT: 26 | tcpSendRxt(tcbptr); 27 | return; 28 | case TCP_EVT_PERSIST: 29 | tcpSendPersist(tcbptr); 30 | return; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /device/tcp/tcp_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file null_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall tcp_Install (unsigned int DevTabNum, const char* devname, unsigned int tcpNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = tcpNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = tcpInit; 16 | devtab[DevTabNum].open = tcpOpen; 17 | devtab[DevTabNum].close = tcpClose; 18 | devtab[DevTabNum].read = tcpRead; 19 | devtab[DevTabNum].write = tcpWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = tcpGetc; 22 | devtab[DevTabNum].putc = tcpPutc; 23 | devtab[DevTabNum].control = tcpControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | return DevTabNum; 29 | } -------------------------------------------------------------------------------- /device/telnet/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/telnet 5 | 6 | # Source files for this component 7 | C_FILES = telnetAlloc.c telnetClose.c telnetControl.c telnetFlush.c \ 8 | telnetGetc.c \ 9 | telnetInit.c telnetOpen.c telnetPutc.c telnetRead.c \ 10 | telnetServer.c telnetWrite.c telnet_Install.c 11 | S_FILES = 12 | 13 | # Add the files to the compile source path 14 | DIR = ${TOPDIR}/${COMP} 15 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 16 | -------------------------------------------------------------------------------- /device/telnet/telnetAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnetAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup telnet 15 | * 16 | * Allocate an available telnet device. 17 | * @return device number for a telnet device, SYSERR if none are free 18 | */ 19 | int telnetAlloc(void) 20 | { 21 | int i; 22 | 23 | ENTER_KERNEL_CRITICAL_SECTION(); 24 | for (i = 0; i < NTELNET; ++i) 25 | { 26 | if (TELNET_STATE_FREE == telnettab[i].state) 27 | { 28 | telnettab[i].state = TELNET_STATE_ALLOC; 29 | EXIT_KERNEL_CRITICAL_SECTION(); 30 | return i + TELNET0; 31 | } 32 | } 33 | EXIT_KERNEL_CRITICAL_SECTION(); 34 | 35 | return SYSERR; 36 | } 37 | -------------------------------------------------------------------------------- /device/telnet/telnetClose.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnetClose.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup telnet 14 | * 15 | * Close a TELNET device. 16 | * @param devptr TELNET device table entry 17 | * @return OK if TELNET is closed properly, otherwise SYSERR 18 | */ 19 | xinu_devcall telnetClose(device *devptr) 20 | { 21 | struct telnet *tntptr; 22 | 23 | tntptr = &telnettab[devptr->minor]; 24 | bzero(tntptr, sizeof(struct telnet)); 25 | tntptr->state = TELNET_STATE_FREE; 26 | return OK; 27 | } 28 | -------------------------------------------------------------------------------- /device/telnet/telnetGetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnetGetc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup telnet 13 | * 14 | * Read a single character from TELNET. 15 | * @param devptr TELNET device table entry 16 | * @return character read from TELNET, or EOF 17 | */ 18 | xinu_devcall telnetGetc(device *devptr) 19 | { 20 | char ch; 21 | int result = NULL; 22 | 23 | result = telnetRead(devptr, &ch, 1); 24 | 25 | if (1 != result) 26 | { 27 | return result; 28 | } 29 | 30 | return ch; 31 | } 32 | -------------------------------------------------------------------------------- /device/telnet/telnetInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnetInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct telnet telnettab[NTELNET]; 13 | 14 | /** 15 | * @ingroup telnet 16 | * 17 | * Initialize TELNET structures. 18 | * @param devptr TELNET device table entry 19 | * @return OK if device is initialized 20 | */ 21 | xinu_devcall telnetInit(device *devptr) 22 | { 23 | struct telnet *tntptr; 24 | 25 | tntptr = &telnettab[devptr->minor]; 26 | bzero(tntptr, sizeof(struct telnet)); 27 | if (0 == devptr->minor) 28 | { 29 | tntptr->killswitch = semcreate(0); 30 | } 31 | else 32 | { 33 | tntptr->killswitch = telnettab[0].killswitch; 34 | } 35 | 36 | return OK; 37 | } 38 | -------------------------------------------------------------------------------- /device/telnet/telnetPutc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnetPutc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup telnet 12 | * 13 | * Write a single character to TELNET. 14 | * 15 | * @param devptr 16 | * TELNET device table entry 17 | * @param ch 18 | * character to output 19 | * 20 | * @return 21 | * @p ch as an unsigned char cast to an @c int on success; @c 22 | * SYSERR on failure. 23 | */ 24 | xinu_devcall telnetPutc(device *devptr, char ch) 25 | { 26 | int ret; 27 | 28 | ret = telnetWrite(devptr, &ch, 1); 29 | if (ret == 1) 30 | { 31 | return (unsigned char)ch; 32 | } 33 | else 34 | { 35 | return SYSERR; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /device/telnet/telnet_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file telnet_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall telnet_Install (unsigned int DevTabNum, const char* devname, unsigned int telnetNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = telnetNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = telnetInit; 16 | devtab[DevTabNum].open = telnetOpen; 17 | devtab[DevTabNum].close = telnetClose; 18 | devtab[DevTabNum].read = telnetRead; 19 | devtab[DevTabNum].write = telnetWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = telnetGetc; 22 | devtab[DevTabNum].putc = telnetPutc; 23 | devtab[DevTabNum].control = telnetControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | return DevTabNum; 29 | } -------------------------------------------------------------------------------- /device/tty/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the device/tty/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/tty 5 | 6 | # Source files for this component 7 | C_FILES = ttyControl.c ttyOpen.c ttyRead.c ttyClose.c ttyGetc.c ttyInit.c ttyPutc.c ttyWrite.c tty_Install.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/tty/ttyClose.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ttyClose.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup tty 15 | * 16 | * Close a TTY device. 17 | * @param devptr TTY device table entry 18 | * @return OK if TTY is closed properly, otherwise SYSERR 19 | */ 20 | xinu_devcall ttyClose(device *devptr) 21 | { 22 | struct tty *ttyptr; 23 | 24 | ENTER_KERNEL_CRITICAL_SECTION(); 25 | /* Setup and error check pointers to structures */ 26 | ttyptr = &ttytab[devptr->minor]; 27 | bzero(ttyptr, sizeof(struct tty)); /* Clear TTY structure. */ 28 | EXIT_KERNEL_CRITICAL_SECTION(); 29 | return OK; 30 | } 31 | -------------------------------------------------------------------------------- /device/tty/ttyGetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ttyGetc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup tty 14 | * 15 | * Read a single character from a TTY. 16 | * @param devptr TTY device table entry 17 | * @return character read from TTY, or EOF 18 | */ 19 | xinu_devcall ttyGetc(device *devptr) 20 | { 21 | unsigned char ch; 22 | int result = NULL; 23 | 24 | result = ttyRead(devptr, &ch, 1); 25 | 26 | if (1 != result) 27 | { 28 | return result; 29 | } 30 | 31 | return ch; 32 | } 33 | -------------------------------------------------------------------------------- /device/tty/ttyInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ttyInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct tty ttytab[NTTY]; 13 | 14 | /** 15 | * @ingroup tty 16 | * 17 | * Initialize TTY structures. 18 | * @param devptr TTY device table entry 19 | * @return OK if device is initialized 20 | */ 21 | xinu_devcall ttyInit(device *devptr) 22 | { 23 | struct tty *ttyptr; 24 | 25 | ttyptr = &ttytab[devptr->minor]; 26 | bzero(ttyptr, sizeof(struct tty)); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /device/tty/ttyWrite.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ttyWrite.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup tty 13 | * 14 | * Write a buffer to a tty 15 | * @param devptr TTY device table entry 16 | * @param buf buffer of characters to output 17 | * @param len size of the buffer 18 | * @return count of characters output 19 | */ 20 | xinu_devcall ttyWrite(device *devptr, const void *buf, unsigned int len) 21 | { 22 | unsigned char ch = 0; 23 | unsigned int count = 0; 24 | unsigned char *buffer = (unsigned char*)buf; 25 | 26 | /* Write all characters in buffer */ 27 | while (count < len) 28 | { 29 | ch = *buffer++; 30 | if (SYSERR == ttyPutc(devptr, ch)) 31 | { 32 | return SYSERR; 33 | } 34 | count++; 35 | } 36 | 37 | return count; 38 | } 39 | -------------------------------------------------------------------------------- /device/tty/tty_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file null_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall tty_Install (unsigned int DevTabNum, const char* devname, unsigned int ttyNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = ttyNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = ttyInit; 16 | devtab[DevTabNum].open = ttyOpen; 17 | devtab[DevTabNum].close = ttyClose; 18 | devtab[DevTabNum].read = ttyRead; 19 | devtab[DevTabNum].write = ttyWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = ttyGetc; 22 | devtab[DevTabNum].putc = ttyPutc; 23 | devtab[DevTabNum].control = ttyControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | ttytab[ttyNum].phw = &devtab[DevTabNum]; 29 | 30 | return DevTabNum; 31 | } -------------------------------------------------------------------------------- /device/uart/Makerules: -------------------------------------------------------------------------------- 1 | 2 | # Name of this component (the directory this file is stored in) 3 | COMP = device/uart 4 | 5 | # Source files for this component 6 | C_FILES = uartGet.c \ 7 | uartPut.c \ 8 | uartControl.c \ 9 | uartInit.c \ 10 | uartRead.c \ 11 | uartWrite.c \ 12 | uartStat.c \ 13 | uartGetCommState.c \ 14 | uartSetCommState.c \ 15 | kputc.c \ 16 | kgetc.c \ 17 | kprintf.c 18 | 19 | S_FILES = 20 | 21 | # Add the files to the compile source path 22 | DIR = ${TOPDIR}/${COMP} 23 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 24 | -------------------------------------------------------------------------------- /device/uart/kgetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kgetc.c 3 | */ 4 | 5 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | xinu_syscall kgetc(void) 12 | { 13 | if (devtab[SERIAL0].getc) 14 | { 15 | return (devtab[SERIAL0].getc(&devtab[SERIAL0])); 16 | } 17 | return SYSERR; 18 | } -------------------------------------------------------------------------------- /device/uart/kputc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kputc.c 3 | */ 4 | 5 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | xinu_syscall kputc (char ch) 12 | { 13 | if (devtab[SERIAL0].putc) 14 | { 15 | return (devtab[SERIAL0].putc(&devtab[SERIAL0], ch)); 16 | } 17 | return SYSERR; 18 | } -------------------------------------------------------------------------------- /device/uart/ns16550/Makerules: -------------------------------------------------------------------------------- 1 | 2 | # Name of this component (the directory this file is stored in) 3 | COMP = device/uart/ns16550 4 | 5 | # Source files for this component 6 | C_FILES = ns16550_uartKickTx.c \ 7 | ns16550_uartHwStat.c \ 8 | ns16550_uartInterrupt.c \ 9 | ns16550_SetCommState.c\ 10 | ns16550_Install.c 11 | S_FILES = 12 | 13 | # Add the files to the compile source path 14 | DIR = ${TOPDIR}/${COMP} 15 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 16 | -------------------------------------------------------------------------------- /device/uart/ns16550/ns16550.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/device/uart/ns16550/ns16550.h -------------------------------------------------------------------------------- /device/uart/ns16550/ns16550_uartKickTx.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uartHwPutc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include "ns16550.h" 8 | 9 | void ns16550_uartKickTx (struct uart *uartptr) 10 | { 11 | volatile struct ns16550_uart_csreg *regptr = (volatile struct ns16550_uart_csreg*)(uintptr_t)(uartptr->csr); 12 | 13 | uartptr->oidle = 1; // We are no longer idle 14 | if (uartptr->csr) regptr->IER.TXEI = 1; 15 | } 16 | -------------------------------------------------------------------------------- /device/uart/pl011/Makerules: -------------------------------------------------------------------------------- 1 | 2 | # Name of this component (the directory this file is stored in) 3 | COMP = device/uart/pl011 4 | 5 | # Source files for this component 6 | C_FILES = pl011_uartKickTx.c \ 7 | pl011_uartHwStat.c \ 8 | pl011_uartInterrupt.c \ 9 | pl011_SetCommState.c \ 10 | pl011_Install.c 11 | S_FILES = 12 | 13 | # Add the files to the compile source path 14 | DIR = ${TOPDIR}/${COMP} 15 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 16 | -------------------------------------------------------------------------------- /device/uart/pl011/pl011_uartKickTx.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uartHwPutc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include "pl011.h" 10 | 11 | #define PL011_UART_IMSC_TXIM (1 << 5) // Transmit interrupt mask 12 | 13 | void pl011_uartKickTx (struct uart * uartptr) 14 | { 15 | volatile struct PL011UARTRegisters* PL011UART; 16 | PL011UART = (volatile struct PL011UARTRegisters*)(uartptr->csr); // Pointer to registers 17 | 18 | if (PL011UART->RIS.TXRIS == 0) // Interrupt not already on 19 | { 20 | ENTER_KERNEL_CRITICAL_SECTION(); 21 | 22 | uartptr->oidle = 1; 23 | PL011UART->IMSC.TXIM = 1; 24 | 25 | PL011UART->DR.DATA = uartptr->out[uartptr->ostart]; 26 | uartptr->ostart += 1; 27 | if (uartptr->ostart >= UART_OBLEN) uartptr->ostart = 0; 28 | uartptr->ocount--; 29 | uartptr->cout += 1; 30 | signaln(uartptr->osema, 1); 31 | 32 | EXIT_KERNEL_CRITICAL_SECTION(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /device/uart/uartGet.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uartGetc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup uartgeneric 12 | * 13 | * Read a single character from a UART. 14 | * 15 | * @param devptr 16 | * Pointer to the device table entry for a UART. 17 | * 18 | * @return 19 | * On success, returns the character read as an unsigned char 20 | * cast to an int. On read error, invalid device, or end-of 21 | * file, returns SYSERR. 22 | */ 23 | xinu_devcall uartGetc(device *devptr) 24 | { 25 | unsigned char ch; 26 | int retval; 27 | 28 | retval = uartRead(devptr, &ch, 1); 29 | if (retval == 1) 30 | { 31 | return ch; 32 | } 33 | else 34 | { 35 | return SYSERR; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /device/uart/uartPut.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uartPutc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup uartgeneric 12 | * 13 | * Write a single character to a UART. 14 | * 15 | * @param devptr 16 | * Pointer to the device table entry for a UART. 17 | * @param ch 18 | * The character to write. 19 | * 20 | * @return 21 | * On success, returns the character written as an unsigned 22 | * char cast to an @c int. On failure, returns SYSERR. 23 | */ 24 | xinu_devcall uartPutc(device *devptr, char ch) 25 | { 26 | int retval; 27 | 28 | retval = uartWrite(devptr, &ch, 1); 29 | if (retval == 1) 30 | { 31 | return (unsigned char)ch; 32 | } 33 | else 34 | { 35 | return SYSERR; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /device/udp/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/udp 5 | 6 | # Source files for this component 7 | C_FILES = udpAlloc.c udpChksum.c udpClose.c udpControl.c udpDemux.c udpFreebuf.c udpGetbuf.c udpInit.c udpOpen.c udpRead.c udpRecv.c udpSend.c udpWrite.c udp_Install.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/udp/udpAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file udpAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup udpexternal 13 | * 14 | * Allocate an available UDP device. 15 | * 16 | * @return 17 | * Device number for a UDP device, or ::SYSERR if none are free. 18 | */ 19 | unsigned short udpAlloc(void) 20 | { 21 | int i; 22 | 23 | ENTER_KERNEL_CRITICAL_SECTION(); 24 | for (i = 0; i < NUDP; i++) 25 | { 26 | if (UDP_FREE == udptab[i].state) 27 | { 28 | udptab[i].state = UDP_ALLOC; 29 | EXIT_KERNEL_CRITICAL_SECTION(); 30 | return i + UDP0; 31 | } 32 | } 33 | EXIT_KERNEL_CRITICAL_SECTION(); 34 | 35 | return SYSERR; 36 | } 37 | -------------------------------------------------------------------------------- /device/udp/udpFreebuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file udpFreebuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup udpinternal 14 | */ 15 | xinu_syscall udpFreebuf(struct udpPkt *udppkt) 16 | { 17 | return buffree(udppkt); 18 | } 19 | -------------------------------------------------------------------------------- /device/udp/udpGetbuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file udpGetbuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup udpinternal 15 | */ 16 | struct udpPkt *udpGetbuf(struct udp *udpptr) 17 | { 18 | struct udpPkt *udppkt = NULL; 19 | 20 | udppkt = bufget(udpptr->inPool); 21 | if (SYSERR == (int)udppkt) 22 | { 23 | return (struct udpPkt *)SYSERR; 24 | } 25 | 26 | bzero(udppkt, NET_MAX_PKTLEN); 27 | 28 | return udppkt; 29 | } 30 | -------------------------------------------------------------------------------- /device/udp/udpInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file udpInit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct udp udptab[NUDP]; 13 | 14 | /** 15 | * @ingroup udpexternal 16 | * 17 | * Set aside some space for a UDP device to be opened on 18 | * @param devptr UDP device table entry 19 | * @return OK 20 | */ 21 | xinu_devcall udpInit(device *devptr) 22 | { 23 | struct udp *udpptr; 24 | 25 | udpptr = &udptab[devptr->minor]; 26 | bzero(udpptr, sizeof(struct udp)); 27 | 28 | return OK; 29 | } 30 | -------------------------------------------------------------------------------- /device/udp/udp_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file udp_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | xinu_devcall udp_Install (unsigned int DevTabNum, const char* devname, unsigned int udpNum) 11 | { 12 | devtab[DevTabNum].num = DevTabNum; 13 | devtab[DevTabNum].minor = udpNum; 14 | devtab[DevTabNum].name = (char*)devname; 15 | devtab[DevTabNum].init = udpInit; 16 | devtab[DevTabNum].open = udpOpen; 17 | devtab[DevTabNum].close = udpClose; 18 | devtab[DevTabNum].read = udpRead; 19 | devtab[DevTabNum].write = udpWrite; 20 | devtab[DevTabNum].seek = 0; 21 | devtab[DevTabNum].getc = 0; 22 | devtab[DevTabNum].putc = 0; 23 | devtab[DevTabNum].control = udpControl; 24 | devtab[DevTabNum].csr = 0; 25 | devtab[DevTabNum].intr = 0; 26 | devtab[DevTabNum].irq = 0; 27 | 28 | udptab[udpNum].dev = &devtab[DevTabNum]; 29 | return DevTabNum; 30 | } -------------------------------------------------------------------------------- /device/usb/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the device/usb/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/usb 5 | 6 | # Source files for this component 7 | C_FILES = usbcore.c usbhub.c usbdebug.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/usb/dwc2000/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the device/usb/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/usb/dwc2000 5 | 6 | # Source files for this component 7 | C_FILES = usb_dwc_hcd.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /device/usbkbd/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the device/usbkbd/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = device/usbkbd 5 | 6 | # Source files for this component 7 | C_FILES = usbKbdBindDevice.c\ 8 | usbKbdControl.c \ 9 | usbKbdGetc.c \ 10 | usbKbdInit.c \ 11 | usbKbdInterrupt.c \ 12 | usbKbdRead.c \ 13 | usbKbdUnbindDevice.c \ 14 | usbKbd_Install.c 15 | S_FILES = 16 | 17 | # Add the files to the compile source path 18 | DIR = ${TOPDIR}/${COMP} 19 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 20 | -------------------------------------------------------------------------------- /device/usbkbd/usbKbdGetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usbKbdGetc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * Read a single character from a USB keyboard. 11 | * 12 | * @param devptr 13 | * Pointer to the device table entry for a USB keyboard. 14 | * 15 | * @return 16 | * On success, returns the character read as an unsigned char 17 | * cast to an int. If keyboard has not been initialized or is 18 | * in non-blocking mode and no data is available, returns ::SYSERR. 19 | */ 20 | xinu_devcall usbKbdGetc(device *devptr) 21 | { 22 | unsigned char ch; 23 | int retval; 24 | 25 | retval = usbKbdRead(devptr, &ch, 1); 26 | if (retval == 1) 27 | { 28 | return ch; 29 | } 30 | else 31 | { 32 | return SYSERR; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /device/usbkbd/usbKbdUnbindDevice.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usbUnbindDevice.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * Function called by the USB subsystem when a keyboard bound with 11 | * usbKbdBindDevice() has been detached. 12 | */ 13 | void usbKbdUnbindDevice(struct usb_device *dev) 14 | { 15 | struct usbkbd *kbd; 16 | 17 | USBKBD_TRACE("USB keyboard disconnected (%s %s: address %u)", 18 | dev->manufacturer, dev->product, dev->address); 19 | kbd = dev->driver_private; 20 | kbd->attached = FALSE; 21 | } 22 | -------------------------------------------------------------------------------- /device/usbkbd/usbKbd_Install.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usbKbd_Install.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | xinu_devcall usbKbd_Install (unsigned int DevTabNum, const char* devname, unsigned int kbdnum) 12 | { 13 | devtab[DevTabNum].num = DevTabNum; 14 | devtab[DevTabNum].minor = kbdnum; 15 | devtab[DevTabNum].name = (char*)devname; 16 | devtab[DevTabNum].init = usbKbdInit; 17 | devtab[DevTabNum].open = 0; 18 | devtab[DevTabNum].close = 0; 19 | devtab[DevTabNum].read = usbKbdRead; 20 | devtab[DevTabNum].write = 0; 21 | devtab[DevTabNum].seek = 0; 22 | devtab[DevTabNum].getc = usbKbdGetc; 23 | devtab[DevTabNum].putc = 0; 24 | devtab[DevTabNum].control = usbKbdControl; 25 | devtab[DevTabNum].csr = 0; 26 | devtab[DevTabNum].intr = 0; 27 | devtab[DevTabNum].irq = 0; 28 | 29 | return DevTabNum; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | See ./development/Documentation.rst for information about the Embedded 2 | Xinu documentation itself. 3 | -------------------------------------------------------------------------------- /docs/arm/index.rst: -------------------------------------------------------------------------------- 1 | ARM ports (including Raspberry Pi) 2 | ================================== 3 | 4 | .. toctree:: 5 | :glob: 6 | :maxdepth: 2 7 | 8 | * 9 | rpi/index 10 | -------------------------------------------------------------------------------- /docs/arm/rpi/Raspberry-Pi-Interrupt-Handling.rst: -------------------------------------------------------------------------------- 1 | Interrupt handling (Raspberry Pi) 2 | ================================= 3 | 4 | Interrupt handling on the :doc:`Raspberry-Pi` is concerned with all 5 | software and hardware used to configure and process 6 | :wikipedia:`interrupts`. An example of an interrupt that can be 7 | enabled on the :doc:`Raspberry-Pi` is that from the 8 | :doc:`BCM2835-System-Timer`, which is used in :doc:`XinuPi` to 9 | implement :doc:`preemptive multitasking 10 | `. Interrupt handling on the 11 | :doc:`Raspberry-Pi` consists of two complementary parts: 12 | 13 | - :doc:`/arm/ARM-Interrupt-Handling` 14 | - :doc:`BCM2835-Interrupt-Controller` 15 | -------------------------------------------------------------------------------- /docs/arm/rpi/RaspberryPi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/arm/rpi/RaspberryPi.jpg -------------------------------------------------------------------------------- /docs/arm/rpi/index.rst: -------------------------------------------------------------------------------- 1 | Raspberry Pi port 2 | ================= 3 | 4 | .. toctree:: 5 | :glob: 6 | 7 | * 8 | -------------------------------------------------------------------------------- /docs/development/XINU-Summer2011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/development/XINU-Summer2011.png -------------------------------------------------------------------------------- /docs/development/index.rst: -------------------------------------------------------------------------------- 1 | Development 2 | =========== 3 | 4 | .. toctree:: 5 | :glob: 6 | :maxdepth: 2 7 | 8 | Git-Repository 9 | Kernel-Normal-Form 10 | Trace 11 | Build-System 12 | Porting 13 | Documentation 14 | * 15 | -------------------------------------------------------------------------------- /docs/features/TtyDriver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/features/TtyDriver.png -------------------------------------------------------------------------------- /docs/features/index.rst: -------------------------------------------------------------------------------- 1 | Components and Features (platform independent) 2 | ============================================== 3 | 4 | This is the documentation for major :doc:`Embedded Xinu 5 | ` components and features relevant to multiple 6 | platforms. Platform-specific documentation can be found in 7 | :doc:`/mips/index` and :doc:`/arm/index`. 8 | 9 | .. toctree:: 10 | :glob: 11 | :maxdepth: 2 12 | 13 | Preemptive-Multitasking 14 | Shell 15 | TTY-Driver 16 | Memory-Management 17 | Message-Passing 18 | Mailboxes 19 | Standard-Library 20 | networking/index 21 | USB 22 | USB-Keyboard-Driver 23 | * 24 | -------------------------------------------------------------------------------- /docs/features/networking/ICMP.rst: -------------------------------------------------------------------------------- 1 | ICMP 2 | ==== 3 | 4 | As part of its :doc:`Networking subsystem `, XINU supports 5 | the **Internet Control Message Protocol** (**ICMP**). The support can 6 | be found in the :source:`network/icmp/` directory. This module 7 | features an ICMP daemon that runs on start up and responds to ICMP 8 | echo requests(pings). The module implements the function 9 | :source:`icmpEchoRequest() `, which is 10 | used by the **ping** :doc:`shell command ` to send 11 | ICMP echo requests to the specified IPv4 address. 12 | 13 | Note that order to either send or reply to ICMP echo packets, the 14 | network interface needs to be brought up (e.g. by using the **netup** 15 | at the shell). 16 | 17 | Resources 18 | --------- 19 | 20 | - :rfc:`792` 21 | -------------------------------------------------------------------------------- /docs/features/networking/XINUNetStack-Print.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/features/networking/XINUNetStack-Print.jpeg -------------------------------------------------------------------------------- /docs/features/networking/XINUNetStack-Screen.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/features/networking/XINUNetStack-Screen.jpeg -------------------------------------------------------------------------------- /docs/features/networking/XINUNetStack.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/features/networking/XINUNetStack.pdf -------------------------------------------------------------------------------- /docs/features/networking/index.rst: -------------------------------------------------------------------------------- 1 | Networking 2 | ========== 3 | 4 | This is the documentation for |EX|'s networking subsystem, including 5 | the files under :source:`network/` as well as certain protocols 6 | implemented as device drivers (e.g. :source:`device/tcp/` and 7 | :source:`device/udp/`). 8 | 9 | .. toctree:: 10 | :glob: 11 | :maxdepth: 2 12 | 13 | Networking-Stack 14 | ARP 15 | Routing 16 | ICMP 17 | TCP 18 | UDP 19 | DHCP 20 | TFTP 21 | * 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. _contents: 2 | 3 | Embedded Xinu documentation contents 4 | ==================================== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | :glob: 9 | 10 | Introduction 11 | Getting-Started 12 | features/index 13 | mips/index 14 | arm/index 15 | teaching/index 16 | projects/index 17 | development/index 18 | -------------------------------------------------------------------------------- /docs/mips/Mipsel-qemu.rst: -------------------------------------------------------------------------------- 1 | mipsel-qemu 2 | =========== 3 | 4 | |EX| has been ported to the MIPSel (little-endian MIPS) virtual 5 | environment provided by `QEMU `__. This provides an 6 | easy way to run a basic Embedded Xinu environment on a RISC 7 | architecture without devoting "real" hardware. 8 | 9 | Building 10 | -------- 11 | 12 | :ref:`Compile Embedded Xinu ` with 13 | ``PLATFORM=mipsel-qemu``. Note that this requires a :ref:`cross 14 | compiler ` targeting little-endian MIPS ("mipsel"). 15 | This will produce the file ``xinu.boot`` in the ``compile/`` 16 | directory. 17 | 18 | Running 19 | ------- 20 | 21 | :: 22 | 23 | $ qemu-system-mipsel -M mips -m 16M -kernel xinu.boot -nographic 24 | 25 | Notes 26 | ----- 27 | 28 | The ``mipsel-qemu`` platform does not yet support networking. 29 | -------------------------------------------------------------------------------- /docs/mips/Startup.rst: -------------------------------------------------------------------------------- 1 | Startup 2 | ======= 3 | 4 | .. raw:: mediawiki 5 | 6 | {{Historical}} 7 | 8 | CFE Jettison 9 | ------------ 10 | 11 | CFE begins executing code at 0x80001000. It passes a firmware handler, 12 | firmware entry point, and an entry point seal. The firmware entry point 13 | handler points to an address in the middle of the heap space (confirmed 14 | once to point to 0x803029FC, which may or may not be a deterministic 15 | address). 16 | 17 | Cache Flush 18 | ----------- 19 | 20 | The L1 instruction and data caches are intialized and flushed. 21 | -------------------------------------------------------------------------------- /docs/mips/WRT54GL.rst: -------------------------------------------------------------------------------- 1 | WRT54GL 2 | ======= 3 | 4 | This page lists details about the `Linksys `__ 5 | WRT54GL device. 6 | 7 | Hardware Info 8 | ------------- 9 | 10 | As reported by OpenWRT 11 | ~~~~~~~~~~~~~~~~~~~~~~ 12 | 13 | - **eth0**: Broadcom 47xx 10/100BaseT Ethernet 14 | - **eth1**: Broadcom BCM4320 802.11 Wireless Controller 3.90.37.0 15 | 16 | See also 17 | -------- 18 | 19 | - WRT54G 20 | 21 | -------------------------------------------------------------------------------- /docs/mips/images/Attach_Back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Attach_Back.jpg -------------------------------------------------------------------------------- /docs/mips/images/Attach_Front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Attach_Front.jpg -------------------------------------------------------------------------------- /docs/mips/images/Baytech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Baytech.png -------------------------------------------------------------------------------- /docs/mips/images/BaytechWiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/BaytechWiring.png -------------------------------------------------------------------------------- /docs/mips/images/Complete.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Complete.jpg -------------------------------------------------------------------------------- /docs/mips/images/Complete_transceiver_board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Complete_transceiver_board.jpg -------------------------------------------------------------------------------- /docs/mips/images/Completed_transceiver.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Completed_transceiver.jpg -------------------------------------------------------------------------------- /docs/mips/images/DB9M.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/DB9M.png -------------------------------------------------------------------------------- /docs/mips/images/DB9_serial_port_wiring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/DB9_serial_port_wiring.jpg -------------------------------------------------------------------------------- /docs/mips/images/Drilled_front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Drilled_front.jpg -------------------------------------------------------------------------------- /docs/mips/images/Front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Front.jpg -------------------------------------------------------------------------------- /docs/mips/images/Front_sticker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Front_sticker.jpg -------------------------------------------------------------------------------- /docs/mips/images/Impcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Impcode.png -------------------------------------------------------------------------------- /docs/mips/images/JTAGunbuffered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/JTAGunbuffered.png -------------------------------------------------------------------------------- /docs/mips/images/NullModem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/NullModem.png -------------------------------------------------------------------------------- /docs/mips/images/Opening-linksys.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Opening-linksys.jpg -------------------------------------------------------------------------------- /docs/mips/images/Serial.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Serial.jpg -------------------------------------------------------------------------------- /docs/mips/images/Serial_Port_Connection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Serial_Port_Connection.jpg -------------------------------------------------------------------------------- /docs/mips/images/Serial_ports_diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Serial_ports_diagram.jpg -------------------------------------------------------------------------------- /docs/mips/images/Serial_ports_done.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Serial_ports_done.jpg -------------------------------------------------------------------------------- /docs/mips/images/Serial_ports_done1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Serial_ports_done1.jpg -------------------------------------------------------------------------------- /docs/mips/images/Te_jtag_cable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Te_jtag_cable.png -------------------------------------------------------------------------------- /docs/mips/images/Tranceiver_attached.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Tranceiver_attached.jpg -------------------------------------------------------------------------------- /docs/mips/images/Transceiver_board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Transceiver_board.jpg -------------------------------------------------------------------------------- /docs/mips/images/Transceiver_schematic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Transceiver_schematic.jpg -------------------------------------------------------------------------------- /docs/mips/images/Transceiver_schematic_wl-330gE.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Transceiver_schematic_wl-330gE.jpg -------------------------------------------------------------------------------- /docs/mips/images/UartAsyncDriver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/UartAsyncDriver.png -------------------------------------------------------------------------------- /docs/mips/images/Wiggler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Wiggler.png -------------------------------------------------------------------------------- /docs/mips/images/Wrt54gl-layout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Wrt54gl-layout.jpg -------------------------------------------------------------------------------- /docs/mips/images/Xinu-Wiggler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/mips/images/Xinu-Wiggler.png -------------------------------------------------------------------------------- /docs/mips/index.rst: -------------------------------------------------------------------------------- 1 | MIPS ports (including Linksys routers) 2 | ====================================== 3 | 4 | .. toctree:: 5 | :glob: 6 | 7 | * 8 | -------------------------------------------------------------------------------- /docs/projects/Xinuphone-schematic-page1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/projects/Xinuphone-schematic-page1.png -------------------------------------------------------------------------------- /docs/projects/Xinuphone-schematic-page2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/projects/Xinuphone-schematic-page2.png -------------------------------------------------------------------------------- /docs/projects/Xinuphone-system.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/docs/projects/Xinuphone-system.jpg -------------------------------------------------------------------------------- /docs/projects/index.rst: -------------------------------------------------------------------------------- 1 | Projects 2 | ======== 3 | 4 | These are some of the student projects that have used Embedded Xinu. 5 | For some, the contribution is included in the official Embedded Xinu 6 | distribution itself. 7 | 8 | .. toctree:: 9 | :glob: 10 | :maxdepth: 2 11 | 12 | * 13 | -------------------------------------------------------------------------------- /docs/teaching/assignments/Instruction-Selection.rst: -------------------------------------------------------------------------------- 1 | Assignment: Instruction Selection 2 | ================================= 3 | 4 | Overview 5 | -------- 6 | 7 | In this project students implement a translator that takes the 8 | Intermediate Representation (IR) output from the translation in 9 | :doc:`Project 5 ` and converts it into MIPS assembly 10 | language with an infinite pool of temporaries. 11 | 12 | Notes 13 | ----- 14 | 15 | No changes are required for our `modified 16 | MiniJava `__ 17 | language or to target a Xinu backend provided that the compiler follows 18 | standard MIPS calling conventions. 19 | -------------------------------------------------------------------------------- /docs/teaching/assignments/Scanner.rst: -------------------------------------------------------------------------------- 1 | Assignment: Scanner 2 | =================== 3 | 4 | Overview 5 | -------- 6 | 7 | In this project students build the first step of a full compiler by 8 | implementing a Scanner for our `Concurrent 9 | MiniJava `__ 10 | language. 11 | 12 | Notes 13 | ----- 14 | 15 | Our `modifications to 16 | MiniJava `__ 17 | require the addition of the *Xinu*, *Thread*, and *run* reserved words. 18 | -------------------------------------------------------------------------------- /docs/teaching/assignments/index.rst: -------------------------------------------------------------------------------- 1 | Assignments 2 | =========== 3 | 4 | .. toctree:: 5 | :glob: 6 | :hidden: 7 | 8 | * 9 | -------------------------------------------------------------------------------- /include/backplane.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file backplane.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #ifndef _BACKPLANE_H__ 8 | #define _BACKPLANE_H__ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | xinu_devcall backplaneInit(device *); 15 | int backplaneCoreUp(volatile struct backplaneConfig *); 16 | int backplaneReset(volatile struct backplaneConfig *); 17 | int backplaneCoreDisable(volatile struct backplaneConfig *); 18 | 19 | #endif /* _BACKPLANE_H_ */ 20 | -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file debug.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #ifndef _DEBUG_H_ 8 | #define _DEBUG_H_ 9 | 10 | #include 11 | 12 | #define DEBUG_ASCII 0x01 13 | #define DEBUG_HEX 0x02 14 | 15 | void hexdump (void *buffer, unsigned long length, bool text); 16 | void debugbreak(void); 17 | void debugret(void); 18 | 19 | #endif /* _DEBGU_H_ */ 20 | -------------------------------------------------------------------------------- /include/device.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file device.h 3 | * 4 | * Contains all definitions relating to the Xinu device subsystem. 5 | * 6 | */ 7 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 8 | 9 | /* Device table declarations */ 10 | #ifndef _DEVICE_H_ 11 | #define _DEVICE_H_ 12 | 13 | #include 14 | #include 15 | 16 | /** 17 | * Check that device id is between 0 and NDEVS. 18 | * 19 | * @param f id number to test 20 | */ 21 | #define isbaddev(f) ( !(0 <= (f) && (f) < NDEVS) ) 22 | 23 | /* Standard driver functions */ 24 | xinu_devcall open (int, ...); 25 | xinu_devcall close (int); 26 | xinu_devcall read (int, void *, unsigned int); 27 | xinu_devcall write (int, const void *, unsigned int); 28 | xinu_devcall getc (int); 29 | xinu_devcall putc (int, char); 30 | xinu_devcall seek (int, unsigned int); 31 | xinu_devcall control(int, int, long, long); 32 | xinu_syscall getdev(const char *); 33 | 34 | #endif /* _DEVICE_H_ */ 35 | -------------------------------------------------------------------------------- /include/dhcpc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dhcpc.h 3 | * 4 | * DHCP client interface 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2013, 2018. All rights reserved. */ 7 | 8 | #ifndef _DHCPC_H_ 9 | #define _DHCPC_H_ 10 | 11 | #include 12 | #include 13 | 14 | /** DHCP transfer data */ 15 | struct dhcpData 16 | { 17 | /* DHCP client output */ 18 | struct netaddr ip; 19 | struct netaddr gateway; 20 | struct netaddr mask; 21 | char bootfile[128]; 22 | struct netaddr next_server; 23 | 24 | /* DHCP client internal variables */ 25 | int state; 26 | unsigned int cxid; 27 | unsigned int starttime; 28 | int recvStatus; 29 | unsigned short discoverSecs; 30 | unsigned int offeredIpv4Addr; 31 | unsigned int clientIpv4Addr; 32 | unsigned int serverIpv4Addr; 33 | unsigned char clientHwAddr[ETH_ADDR_LEN]; 34 | unsigned char serverHwAddr[ETH_ADDR_LEN]; 35 | }; 36 | 37 | xinu_syscall dhcpClient(int descrp, unsigned int timeout, struct dhcpData *data); 38 | 39 | #endif /* _DHCPC_H_ */ 40 | -------------------------------------------------------------------------------- /include/dsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dsp.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #ifndef _DSP_H_ 8 | #define _DSP_H_ 9 | 10 | unsigned char linear2ulaw(int); 11 | int ulaw2linear(unsigned char); 12 | 13 | #endif /* _DSP_H_ */ 14 | -------------------------------------------------------------------------------- /include/kbdmon.h: -------------------------------------------------------------------------------- 1 | /* Dummy header */ 2 | -------------------------------------------------------------------------------- /include/kexec.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file kexec.h 3 | * 4 | * Kernel execute: transfer control to a new kernel. This is intended to be 5 | * used to allow Xinu to act as a bootloader, e.g. so that a new Xinu kernel can 6 | * be executed without rebooting the hardware. 7 | * 8 | * This is a platform-dependent system call and may not be available on a given 9 | * platform. Furthermore, the new kernel must be valid to execute on the given 10 | * platform. This may include being linked to run at a certain address. 11 | */ 12 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 13 | 14 | #ifndef _KEXEC_H_ 15 | #define _KEXEC_H_ 16 | 17 | #include 18 | 19 | xinu_syscall kexec(const void *kernel, unsigned int size); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/netemu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file netemu.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #ifndef _NETEMU_H_ 8 | #define _NETEMU_H_ 9 | 10 | #include 11 | 12 | xinu_syscall netemu(struct packet *pkt); 13 | xinu_syscall emuCorrupt(struct packet *pkt); 14 | xinu_syscall emuDelay(struct packet *pkt); 15 | xinu_syscall emuDrop(struct packet *pkt); 16 | xinu_syscall emuDuplicate(struct packet *pkt); 17 | xinu_syscall emuReorder(struct packet *pkt); 18 | #endif /* _NETEMU_H_ */ 19 | -------------------------------------------------------------------------------- /include/null.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file null.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | 8 | /* File automatically included by xinu.conf system for null device */ 9 | -------------------------------------------------------------------------------- /include/stdarg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stdarg.h 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #ifndef _STDARG_H_ 8 | #define _STDARG_H_ 9 | 10 | /* GCC-specific varargs */ 11 | typedef __builtin_va_list va_list; 12 | 13 | #define va_copy(dst, src) __builtin_va_copy(dst, src) 14 | #define va_start(last, va) __builtin_va_start(last, va) 15 | #define va_arg(va, type) __builtin_va_arg(va, type) 16 | #define va_end(va) __builtin_va_end(va) 17 | 18 | #endif /* _STDARG_H_ */ 19 | -------------------------------------------------------------------------------- /include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | #ifndef __cplusplus 5 | 6 | #define bool _Bool 7 | #define true 1 8 | #define false 0 9 | 10 | #else /* __cplusplus */ 11 | 12 | /* Supporting in C++ is a GCC extension. */ 13 | #define _Bool bool 14 | #define bool bool 15 | #define false false 16 | #define true true 17 | 18 | #endif /* __cplusplus */ 19 | 20 | /* Signal that all the definitions are present. */ 21 | #define __bool_true_false_are_defined 1 22 | 23 | #endif /* stdbool.h */ 24 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file string.h 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #ifndef _STRING_H_ 7 | #define _STRING_H_ 8 | 9 | #include 10 | 11 | void *memchr(const void *s, int c, size_t n); 12 | int memcmp(const void *s1, const void *s2, size_t n); 13 | void *memcpy(void *dest, const void *src, size_t n); 14 | void *memset(void *s, int c, size_t n); 15 | 16 | char *strchr(const char *s, int c); 17 | int strcmp(const char *s1, const char *s2); 18 | char *strcpy(char *dest, const char *src); 19 | size_t strlcpy(char *dest, const char *src, size_t destsize); 20 | size_t strlen(const char *s); 21 | char *strncat(char *dest, const char *src, size_t n); 22 | int strncmp(const char *s1, const char *s2, size_t n); 23 | char *strncpy(char *dest, const char *src, size_t n); 24 | size_t strnlen(const char *s, size_t maxlen); 25 | char *strrchr(const char *s, int c); 26 | char *strstr(const char *haystack, const char *needle); 27 | 28 | #endif /* _STRING_H_ */ 29 | -------------------------------------------------------------------------------- /include/usb_hub_driver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usb_hub_driver.h 3 | * @ingroup usbhub 4 | * 5 | * Interface to the USB hub driver. This is intended to be used only by the USB 6 | * core driver. 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 9 | 10 | #ifndef _USB_HUB_DRIVER_H_ 11 | #define _USB_HUB_DRIVER_H_ 12 | 13 | #include 14 | #include 15 | 16 | void usb_hub_for_device_in_tree(struct usb_device *dev, 17 | usb_status_t (*callback)(struct usb_device *)); 18 | 19 | extern const struct usb_device_driver usb_hub_driver; 20 | 21 | #endif /* _USB_HUB_DRIVER_H_ */ 22 | -------------------------------------------------------------------------------- /include/usb_subsystem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file usb_subsystem.h 3 | * @ingroup usb 4 | * 5 | * Interface to the USB (Universal Serial Bus) subsystem from other operating 6 | * system code. 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2013,2018. All rights reserved. */ 9 | 10 | #ifndef _USB_SUBSSYSTEM_H_ 11 | #define _USB_SUBSSYSTEM_H_ 12 | 13 | #include 14 | 15 | xinu_syscall usbinit(void); 16 | xinu_syscall usbinfo(void); 17 | 18 | /* Must be provided by platform implementation in say platforminit.c*/ 19 | xinu_syscall usbpoweron(void); 20 | xinu_syscall usbpoweroff(void); 21 | 22 | #endif /* _USB_SUBSSYSTEM_H_ */ 23 | -------------------------------------------------------------------------------- /include/version.h: -------------------------------------------------------------------------------- 1 | #define REVISION 0 2 | #define VERSION "2.0" -------------------------------------------------------------------------------- /include/watchdog.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file watchdog.h 3 | * 4 | * Interface to the system watchdog timer. This is a platform-dependent feature 5 | * and may not be available on some platforms. 6 | */ 7 | /* Embedded Xinu, Copyright (C) 2013, 2018. All rights reserved. */ 8 | 9 | #ifndef _WATCHDOG_H_ 10 | #define _WATCHDOG_H_ 11 | 12 | #include 13 | 14 | xinu_syscall watchdogset (unsigned int msecs); 15 | 16 | #endif /* _WATCHDOG_H_ */ 17 | -------------------------------------------------------------------------------- /lib/libdsp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make Xinu's digital signal processing library 3 | # 4 | 5 | # Name of this library 6 | LIBNAME := libdsp 7 | 8 | # C files to compile (.c) 9 | CFILES := linear2ulaw.c ulaw2linear.c 10 | 11 | # Assembly files to compile (.S) 12 | SFILES := 13 | 14 | # Directory in which to place the output library, and 15 | # location of common Makerules 16 | LIBDIR := .. 17 | 18 | include $(LIBDIR)/Makerules 19 | -------------------------------------------------------------------------------- /lib/libxc/abs.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file abs.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Calculates the absolute value of an integer. 12 | * 13 | * @param j 14 | * The integer to get the absolute value of. 15 | * 16 | * @return 17 | * The absolute value of @p j. As a special case, if @p j is @c INT_MIN, 18 | * the return value will be undefined because @c -INT_MIN cannot be 19 | * represented in an @c int. 20 | */ 21 | int abs(int j) 22 | { 23 | if (j < 0) 24 | { 25 | j = -j; 26 | } 27 | 28 | return j; 29 | } 30 | -------------------------------------------------------------------------------- /lib/libxc/atoi.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file atoi.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Converts the initial portion of an ASCII null-terminated string into an 12 | * integer. Leading whitespace is skipped and an optional + or 13 | * - character is allowed to indicate sign. Parsing otherwise 14 | * stops once the first nondigit character is encountered. If no digits have 15 | * been encountered at that point, 0 shall be returned. 16 | * 17 | * @param nptr 18 | * Pointer to the string to convert. 19 | * 20 | * @return 21 | * The resulting integer. 22 | */ 23 | int atoi(const char *nptr) 24 | { 25 | return atol(nptr); 26 | } 27 | -------------------------------------------------------------------------------- /lib/libxc/atol.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file atol.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Converts the initial portion of an ASCII null-terminated string into a long 13 | * integer. Leading whitespace is skipped and an optional + or 14 | * - character is allowed to indicate sign. Parsing otherwise 15 | * stops once the first nondigit character is encountered. If no digits have 16 | * been encountered at that point, 0 shall be returned. 17 | * 18 | * @param nptr 19 | * Pointer to the string to convert. 20 | * 21 | * @return 22 | * The resulting long integer. 23 | */ 24 | long atol(const char *nptr) 25 | { 26 | long n = 0; 27 | sscanf(nptr, "%ld", &n); 28 | return n; 29 | } 30 | -------------------------------------------------------------------------------- /lib/libxc/bzero.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bzero.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Zeroes a block of memory. 13 | * 14 | * @param s 15 | * Pointer to the start of the block of memory to zero. 16 | * @param n 17 | * Length of the block of memory, in bytes. 18 | */ 19 | void bzero(void *s, size_t n) 20 | { 21 | memset(s, 0, n); 22 | } 23 | -------------------------------------------------------------------------------- /lib/libxc/fgetc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fgetc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Reads a character from a device. 13 | * 14 | * @param dev 15 | * Index of device from which to read the character. 16 | * 17 | * @return 18 | * On success, returns the character read as an unsigned char 19 | * cast to an @c int. On read error, invalid device, or end-of file, 20 | * returns @c EOF. 21 | */ 22 | int fgetc(int dev) 23 | { 24 | int c; 25 | 26 | c = getc(dev); 27 | 28 | if (c == SYSERR || c == EOF) 29 | { 30 | return EOF; 31 | } 32 | else 33 | { 34 | return (int)(unsigned char)c; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/libxc/fprintf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fprintf.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Writes a formatted message to the specified device. 13 | * 14 | * @param dev 15 | * Index of the device to write to. 16 | * @param format 17 | * The format string. Not all standard conversion specifications are 18 | * supported by this implementation. See _doprnt() for a description of 19 | * supported conversion specifications. 20 | * @param ... 21 | * Arguments matching those in the format string. 22 | * 23 | * @return 24 | * On success, returns the number of characters written. On write error, 25 | * returns a negative value. 26 | */ 27 | int fprintf(int dev, const char *format, ...) 28 | { 29 | va_list ap; 30 | int ret; 31 | 32 | va_start(ap, format); 33 | ret = _doprnt(format, ap, fputc, dev); 34 | va_end(ap); 35 | return ret; 36 | } 37 | -------------------------------------------------------------------------------- /lib/libxc/fputc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fputc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Writes one character to a device. 13 | * 14 | * @param c 15 | * The character to write. 16 | * @param dev 17 | * Index of the device to which to write the character. 18 | * 19 | * @return 20 | * On success, returns the character written as an unsigned 21 | * char cast to an @c int. On write error or invalid device, 22 | * returns @c EOF. 23 | */ 24 | int fputc(int c, int dev) 25 | { 26 | int ret; 27 | 28 | ret = putc(dev, c); 29 | if (ret == SYSERR || ret == EOF) 30 | { 31 | return EOF; 32 | } 33 | else 34 | { 35 | return (int)(unsigned char)ret; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/libxc/fputs.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fputs.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Writes a null-terminated string to a device. 12 | * 13 | * @param s 14 | * The null terminated string to write. 15 | * @param dev 16 | * The device to write the string to. 17 | * 18 | * @return 19 | * A non-negative number on success, or @c EOF on error. 20 | */ 21 | int fputs(const char *s, int dev) 22 | { 23 | for (; *s; s++) 24 | { 25 | if (fputc(*s, dev) == EOF) 26 | { 27 | return EOF; 28 | } 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /lib/libxc/free.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file free.c 3 | * This file is deprecated in favor of mem/free.c and the user heap 4 | * allocator. However, it remains here for backup purposes. 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 7 | 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup libxc 13 | * 14 | * Attempt to free a block of memory based on malloc() accounting information 15 | * stored in preceding two words. 16 | * 17 | * @param ptr 18 | * A pointer to the memory block to free. 19 | */ 20 | void free(void *ptr) 21 | { 22 | struct memblock *block; 23 | 24 | /* block points at the memblock we want to free */ 25 | block = (struct memblock *)ptr; 26 | 27 | /* back up to accounting information */ 28 | block--; 29 | 30 | /* don't memfree if we fail basic checks */ 31 | if (block->next != block) 32 | { 33 | return; 34 | } 35 | 36 | memfree(block, block->length); 37 | } 38 | -------------------------------------------------------------------------------- /lib/libxc/labs.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file labs.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Calculates the absolute value of a long integer. 12 | * 13 | * @param j 14 | * The long integer to get the absolute value of. 15 | * 16 | * @return 17 | * The absolute value of @p j. As a special case, if @p j is @c LONG_MIN, 18 | * the return value will be undefined because @c -LONG_MIN cannot be 19 | * represented in a @c long. 20 | */ 21 | long labs(long j) 22 | { 23 | if (j < 0) 24 | { 25 | j = -j; 26 | } 27 | 28 | return j; 29 | } 30 | -------------------------------------------------------------------------------- /lib/libxc/memcmp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memcmp.c 3 | */ 4 | 5 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Compares two memory regions of a specified length. 13 | * 14 | * @param s1 15 | * Pointer to the first memory location. 16 | * @param s2 17 | * Pointer to the second memory location. 18 | * @param n 19 | * Length, in bytes, to compare. 20 | * 21 | * @return 22 | * A negative value, 0, or a positive value if the @p s1 region of memory 23 | * is less than, equal to, or greater than the @p s2 region of memory, 24 | * respectively. 25 | */ 26 | int memcmp(const void *s1, const void *s2, size_t n) 27 | { 28 | const unsigned char *p1 = s1, *p2 = s2; 29 | size_t i; 30 | 31 | for (i = 0; i < n; i++) 32 | { 33 | if (p1[i] != p2[i]) 34 | { 35 | return (int)p1[i] - (int)p2[i]; 36 | } 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /lib/libxc/memcpy.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memcpy.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Copy the specified number of bytes of memory to another location. The memory 12 | * locations must not overlap. 13 | * 14 | * @param dest 15 | * Pointer to the destination memory. 16 | * @param src 17 | * Pointer to the source memory. 18 | * @param n 19 | * The amount of data (in bytes) to copy. 20 | * 21 | * @return 22 | * @p dest 23 | */ 24 | void *memcpy(void *dest, const void *src, size_t n) 25 | { 26 | unsigned char *dest_p = dest; 27 | const unsigned char *src_p = src; 28 | size_t i; 29 | 30 | for (i = 0; i < n; i++) 31 | { 32 | dest_p[i] = src_p[i]; 33 | } 34 | 35 | return dest; 36 | } 37 | -------------------------------------------------------------------------------- /lib/libxc/memset.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memset.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Fills a region of memory with a byte. 12 | * 13 | * @param s 14 | * pointer to the memory to place byte into 15 | * @param c 16 | * byte to place 17 | * @param n 18 | * length of region to fill, in bytes 19 | * 20 | * @return 21 | * @p s 22 | */ 23 | void *memset(void *s, int c, size_t n) 24 | { 25 | unsigned char *p = s; 26 | unsigned char byte = c; 27 | size_t i; 28 | 29 | for (i = 0; i < n; i++) 30 | { 31 | p[i] = byte; 32 | } 33 | return s; 34 | } 35 | -------------------------------------------------------------------------------- /lib/libxc/printf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file printf.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Print a formatted message to standard output. 13 | * 14 | * @param format 15 | * The format string. Not all standard format specifiers are supported by 16 | * this implementation. See _doprnt() for a description of supported 17 | * conversion specifications. 18 | * @param ... 19 | * Arguments matching those in the format string. 20 | * 21 | * @return 22 | * On success, returns the number of characters written. On write error, 23 | * returns a negative value. 24 | */ 25 | int printf(const char *format, ...) 26 | { 27 | va_list ap; 28 | int ret; 29 | 30 | va_start(ap, format); 31 | ret = _doprnt(format, ap, fputc, stdout); 32 | va_end(ap); 33 | 34 | return ret; 35 | } 36 | -------------------------------------------------------------------------------- /lib/libxc/rand.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rand.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | static unsigned int seed = 1; 9 | 10 | /** 11 | * @ingroup libxc 12 | * 13 | * Sets the random seed that will be used in future calls to rand(). 14 | * 15 | * @param x 16 | * the random seed to set 17 | */ 18 | void srand(unsigned int x) 19 | { 20 | seed = x; 21 | } 22 | 23 | /** 24 | * @ingroup libxc 25 | * 26 | * Generates a pseudorandom integer in the range [0, RAND_MAX]. 27 | * Beware: this is not re-entrant. 28 | * 29 | * @return the random integer 30 | */ 31 | int rand(void) 32 | { 33 | /* This uses a linear congruential generator. The seed retains a 32-bit 34 | * state, but for the actual random numbers returned we take just some of 35 | * the upper bits, which are more random than the lower bits. */ 36 | seed = (seed * 1103515245) + 12345; 37 | return (seed >> 16) % (RAND_MAX + 1); 38 | } 39 | -------------------------------------------------------------------------------- /lib/libxc/strchr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strchr.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Returns a pointer to the first location in a null-terminated string at which 13 | * a particular character appears. 14 | * 15 | * @param s 16 | * The string to search. 17 | * @param c 18 | * The character to locate. 19 | * 20 | * @return 21 | * The pointer in the string, or @c NULL if the character was not found. 22 | */ 23 | char *strchr(const char *s, int c) 24 | { 25 | char ch = c; 26 | do 27 | { 28 | if (*s == ch) 29 | { 30 | return (char*)s; /* Cast away const. */ 31 | } 32 | } while (*s++); 33 | return NULL; 34 | } 35 | -------------------------------------------------------------------------------- /lib/libxc/strcmp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strcmp.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Compare two null-terminated strings. 12 | * 13 | * @param s1 14 | * Pointer to the first string. 15 | * @param s2 16 | * Pointer to the second string. 17 | * 18 | * @return 19 | * A negative value, 0, or a positive value if the @p s1 string is less 20 | * than, equal to, or greater than the @p s2 string, respectively. 21 | */ 22 | int strcmp(const char *s1, const char *s2) 23 | { 24 | while (*s1 == *s2 && *s1 != '\0') 25 | { 26 | s1++; 27 | s2++; 28 | } 29 | 30 | return (int)(unsigned char)*s1 - (int)(unsigned char)*s2; 31 | } 32 | -------------------------------------------------------------------------------- /lib/libxc/strcpy.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strcpy.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Copies a a null-terminated string to the specified location. The source and 12 | * destination strings may not overlap. 13 | * 14 | * @param dest 15 | * Pointer to the memory to which to copy the string. It must have room 16 | * for at least the number of characters in the @p src string, including 17 | * the null terminator. 18 | * @param src 19 | * Pointer to the string to copy. 20 | * 21 | * @return 22 | * A pointer to @p dest. 23 | */ 24 | char *strcpy(char *dest, const char *src) 25 | { 26 | char *dest_save = dest; 27 | while ((*dest++ = *src++) != '\0'); 28 | return dest_save; 29 | } 30 | -------------------------------------------------------------------------------- /lib/libxc/strlen.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strlen.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Calculates the length of a null-terminated string. 12 | * 13 | * @param s 14 | * String to calculate the length of. 15 | * 16 | * @return 17 | * Length of the string in bytes, not including the null terminator. 18 | */ 19 | size_t strlen(const char *s) 20 | { 21 | size_t n = 0; 22 | 23 | while (s[n] != '\0') 24 | { 25 | n++; 26 | } 27 | return n; 28 | } 29 | -------------------------------------------------------------------------------- /lib/libxc/strncmp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strncmp.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | 8 | /** 9 | * @ingroup libxc 10 | * 11 | * Compare two null-terminated strings, examining at most the specified number 12 | * of bytes. 13 | * 14 | * @param s1 15 | * Pointer to the first string. 16 | * @param s2 17 | * Pointer to the second string. 18 | * @param n 19 | * Maximum number of bytes to compare before returning 0. 20 | * 21 | * @return 22 | * A negative value, 0, or a positive value if the @p s1 string is less 23 | * than, equal to, or greater than the @p s2 string, respectively. 24 | */ 25 | int strncmp(const char *s1, const char *s2, size_t n) 26 | { 27 | size_t i; 28 | 29 | for (i = 0; i < n; i++) 30 | { 31 | if (s1[i] == '\0' || s1[i] != s2[i]) 32 | { 33 | return (int)(unsigned char)s1[i] - (int)(unsigned char)s2[i]; 34 | } 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /lib/libxc/strnlen.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strnlen.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Returns the length of a null-terminated string, but not more than the 13 | * specified length. 14 | * 15 | * @param s 16 | * String to calculate the length of. 17 | * 18 | * @param maxlen 19 | * Maximum length to return. 20 | * 21 | * @return 22 | * Length of the string up to but not including the null terminator, or @p 23 | * maxlen if the string is longer than @p maxlen bytes. 24 | */ 25 | size_t strnlen(const char *s, size_t maxlen) 26 | { 27 | size_t n = 0; 28 | 29 | while (s[n] != '\0' && n < maxlen) 30 | { 31 | n++; 32 | } 33 | return n; 34 | } 35 | -------------------------------------------------------------------------------- /lib/libxc/strrchr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strrchr.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup libxc 11 | * 12 | * Returns a pointer to the last location in a null-terminated string at which a 13 | * particular character appears. 14 | * 15 | * @param s 16 | * The string to search. 17 | * @param c 18 | * The character to locate. 19 | * 20 | * @return 21 | * The pointer in the string, or @c NULL if the character was not found. 22 | */ 23 | char *strrchr(const char *s, int c) 24 | { 25 | char *r = NULL; 26 | char ch = c; 27 | 28 | do 29 | { 30 | if (*s == ch) 31 | { 32 | r = (char *)s; /* Cast away const. */ 33 | } 34 | } while (*s++); 35 | 36 | return r; 37 | } 38 | -------------------------------------------------------------------------------- /lib/libxc/strstr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file strstr.c 3 | */ 4 | 5 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup libxc 12 | * 13 | * Returns a pointer to the first location in a null-terminated string at which 14 | * a particular substring appears. 15 | * 16 | * @param haystack 17 | * The string to search. 18 | * @param needle 19 | * The string to locate. 20 | * 21 | * @return 22 | * The pointer in the string, or @c NULL if the string was not found. 23 | */ 24 | char *strstr(const char *haystack, const char *needle) 25 | { 26 | size_t needle_len = strlen(needle); 27 | for (; *haystack != '\0'; haystack++) 28 | { 29 | if (strncmp(haystack, needle, needle_len) == 0) 30 | { 31 | return (char*)haystack; /* Cast away const. */ 32 | } 33 | } 34 | return NULL; 35 | } 36 | -------------------------------------------------------------------------------- /mailbox/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the mailbox/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = mailbox 5 | 6 | # Source files for this component 7 | C_FILES = mailboxAlloc.c mailboxCount.c mailboxFree.c mailboxInit.c mailboxReceive.c mailboxSend.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /mailbox/mailboxInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mailboxInit.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | struct mbox mboxtab[NMAILBOX]; 10 | semaphore mboxtabsem; 11 | 12 | /** 13 | * @ingroup mailbox 14 | * 15 | * Initialize mailbox structures. 16 | * 17 | * @return 18 | * ::OK if all mailboxes were initialized successfully, otherwise ::SYSERR. 19 | */ 20 | xinu_syscall mailboxInit(void) 21 | { 22 | unsigned int i; 23 | 24 | /* set all mailbox states to MAILBOX_FREE */ 25 | for (i = 0; i < NMAILBOX; i++) 26 | { 27 | mboxtab[i].state = MAILBOX_FREE; 28 | } 29 | 30 | mboxtabsem = semcreate(1); 31 | if (SYSERR == mboxtabsem) 32 | { 33 | return SYSERR; 34 | } 35 | 36 | return OK; 37 | } 38 | -------------------------------------------------------------------------------- /mem/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the mem/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = mem 5 | 6 | # Region Allocator files 7 | ALLOC_FILES = memRegionInit.c memRegionClear.c memRegionInsert.c memRegionRemove.c memRegionSplit.c memRegionValid.c memRegionTransfer.c memRegionAlloc.c memRegionReclaim.c 8 | 9 | # User Allocator files 10 | USER_FILES = malloc.c free.c 11 | 12 | # Memory Protection files 13 | SAFEMEM_FILES = safeInit.c safeMap.c safeMapRange.c safeUnmap.c safeUnmapRange.c safeKmapInit.c 14 | 15 | # TLB Handler files 16 | TLB_FILES = tlbInit.c tlbMiss.S tlbMissHandler.c 17 | 18 | FILES = ${ALLOC_FILES} ${USER_FILES} ${SAFEMEM_FILES} ${TLB_FILES} 19 | 20 | # Add the files to the compile source path 21 | DIR = ${TOPDIR}/${COMP} 22 | COMP_SRC += ${FILES:%=${DIR}/%} 23 | -------------------------------------------------------------------------------- /mem/memRegionClear.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memRegionClear.c 3 | * Clear (initialize) a memory region to safe default values. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | /** 11 | * Clear all the values of a given memory region to "safe" defaults. 12 | * @param region region of memory to clear. 13 | */ 14 | void memRegionClear(struct memregion *region) 15 | { 16 | region->prev = (struct memregion *)SYSERR; 17 | region->next = (struct memregion *)SYSERR; 18 | region->start = NULL; 19 | region->length = 0; 20 | region->thread_id = 0; 21 | } 22 | -------------------------------------------------------------------------------- /mem/memRegionTransfer.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memRegionTransfer.c 3 | * Transfer a memory region to a new thread. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | /** 11 | * Transfer a memory region from the owning thread to a new thread. 12 | * @param start beginning address of memory region. 13 | * @param tid thread id to transfer region to. 14 | */ 15 | void memRegionTransfer(void *start, tid_typ tid) 16 | { 17 | struct memregion *region; 18 | 19 | region = memRegionValid(start); 20 | if (SYSERR == (int)region) 21 | { 22 | return; 23 | } 24 | 25 | region->thread_id = tid; 26 | } 27 | -------------------------------------------------------------------------------- /mem/memRegionValid.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file memRegionValid.c 3 | * Determine if and address is within an allocated region. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | /** 11 | * Determine if the address in memory is in an allocated memory region. 12 | * @param start address of memory to check. 13 | * @return memory region belonging to start, SYSERR if not found. 14 | */ 15 | struct memregion *memRegionValid(void *start) 16 | { 17 | struct memregion *region; 18 | start = (void *)truncpage(start); 19 | 20 | /* check allocated regions */ 21 | region = regalloclist; 22 | while (((int)region != SYSERR) && (region->start != start)) 23 | { 24 | region = region->next; 25 | } 26 | 27 | return region; 28 | } 29 | -------------------------------------------------------------------------------- /mem/safeMapRange.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file safeMapRange.c 3 | * Map a range of pages to a page table. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | /** 11 | * Map a range of pages to a page table starting at start, ending at 12 | * start+length. 13 | * @param start beginning page address to map. 14 | * @param length length of memory range to map. 15 | * @param attr attributes to apply to page table entries. 16 | * @return non-zero value on failure. 17 | */ 18 | int safeMapRange(void *start, uint length, short attr) 19 | { 20 | uint addr, end; 21 | int result; 22 | 23 | length = roundpage(length); 24 | addr = (uint)truncpage(start); 25 | end = addr + length; 26 | 27 | for (; addr < end; addr += PAGE_SIZE) 28 | { 29 | if ((result = safeMap((void *)addr, attr)) != 0) 30 | { 31 | return result; 32 | } 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /mem/safeUnmapRange.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file safeUnmapRange.c 3 | * Remove a range of pages from page table. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | /** 11 | * Remove a range of pages from a page table starting at start and ending 12 | * after length bytes. 13 | * @param start beginning page address to remove. 14 | * @param length number of bytes to unmap for. 15 | * @return non-zero value on failure. 16 | */ 17 | int safeUnmapRange(void *start, uint length) 18 | { 19 | uint addr, end; 20 | int result; 21 | 22 | length = roundpage(length); 23 | addr = (uint)truncpage(start); 24 | end = addr + length; 25 | 26 | for (; addr < end; addr += PAGE_SIZE) 27 | { 28 | if ((result = safeUnmap((void *)addr)) != 0) 29 | { 30 | return result; 31 | } 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /mem/tlbInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tlbInit.c 3 | * Initialize the Translation lookaside buffer. 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | interrupt tlbMiss(void); 14 | interrupt tlbMissLong(void); 15 | 16 | /** 17 | * Initialize the TLB. This function is called at startup. Installs 18 | * handler for both TLB load and store operations in normal exceptionVector 19 | * table, also copies the handler to the quick tlbMiss memory 0x80000000. 20 | */ 21 | void tlbInit(void) 22 | { 23 | /* Register slow TLB exception handler (KSEG2 and USEG misses) */ 24 | exceptionVector[EXC_TLBS] = (void *)tlbMissLong; 25 | exceptionVector[EXC_TLBL] = (void *)tlbMissLong; 26 | 27 | /* install the quick handler (for USEG mappings) */ 28 | safecopy(TLB_EXC_START, tlbMiss, TLB_EXC_LENGTH); 29 | } 30 | -------------------------------------------------------------------------------- /network/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build devices within this directory 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network 5 | 6 | # Name of networking modules to include in the built system 7 | NETWORKING = arp dhcpc emulate icmp ipv4 net netaddr route snoop tftp 8 | 9 | DIR = ${TOPDIR}/${COMP} 10 | include ${NETWORKING:%=${DIR}/%/Makerules} 11 | -------------------------------------------------------------------------------- /network/arp/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/arp 5 | 6 | # Source files for this component 7 | C_FILES = arpAlloc.c arpDaemon.c arpGetEntry.c arpFree.c arpInit.c arpLookup.c arpNotify.c arpRecv.c arpSendReply.c arpSendRqst.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /network/arp/arpDaemon.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file arpDaemon.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup arp 13 | * 14 | * ARP daemon to manage the ARP table. 15 | */ 16 | thread arpDaemon(void) 17 | { 18 | struct packet *pkt = NULL; 19 | 20 | while (TRUE) 21 | { 22 | pkt = (struct packet *)mailboxReceive(arpqueue); 23 | ARP_TRACE("Daemon received ARP packet"); 24 | if (SYSERR == (int)pkt) 25 | { 26 | continue; 27 | } 28 | 29 | arpSendReply(pkt); 30 | 31 | /* Free buffer for the packet */ 32 | if (SYSERR == netFreebuf(pkt)) 33 | { 34 | ARP_TRACE("Failed to free packet buffer"); 35 | continue; 36 | } 37 | } 38 | 39 | return OK; 40 | } 41 | -------------------------------------------------------------------------------- /network/dhcpc/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/dhcpc 5 | 6 | # Source files for this component 7 | C_FILES = dhcpClient.c dhcpRecvReply.c dhcpSendRequest.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /network/emulate/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/emulate 5 | 6 | # Source files for this component 7 | C_FILES = emuCorrupt.c emuDelay.c emuDrop.c emuDuplicate.c emuReorder.c netemu.c 8 | 9 | S_FILES = 10 | 11 | # Add the files to the compile source path 12 | DIR = ${TOPDIR}/${COMP} 13 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 14 | -------------------------------------------------------------------------------- /network/emulate/emuCorrupt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file emuCorrupt.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup netemu 14 | * 15 | * Corrupts packets as specified by user 16 | * @param pkt pointer to the incoming packet 17 | * @return OK if packet was processed succesfully, otherwise SYSERR 18 | */ 19 | xinu_syscall emuCorrupt(struct packet *pkt) 20 | { 21 | 22 | return rtRecv(pkt); 23 | } 24 | -------------------------------------------------------------------------------- /network/emulate/emuDelay.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file emuDelay.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup netemu 15 | * 16 | * Delay packets as specified by user 17 | * @param pkt pointer to the incoming packet 18 | * @return OK if packet was processed succesfully, otherwise SYSERR 19 | */ 20 | xinu_syscall emuDelay(struct packet *pkt) 21 | { 22 | /* 23 | short delayTime = 100; 24 | short delayPercent = 100; 25 | 26 | if ((rand() % 100) < delayPercent) 27 | { 28 | sleep(delayTime); 29 | } 30 | */ 31 | return emuDuplicate(pkt); 32 | } 33 | -------------------------------------------------------------------------------- /network/emulate/emuDrop.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file emuDrop.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /** 17 | * @ingroup netemu 18 | * 19 | * Drop packets based on user settings 20 | * @param pkt pointer to the incoming packet 21 | * @return OK if packet was processed succesfully, otherwise SYSERR 22 | */ 23 | xinu_syscall emuDrop(struct packet *pkt) 24 | { 25 | /* TODO: make this user specifiable */ 26 | short dropPercent = 0; 27 | 28 | /* drop packet when random value < percent to drop */ 29 | if ((rand() % 100) < dropPercent) 30 | { 31 | RT_TRACE("Dropped by Emulator: %d\n"); 32 | netFreebuf(pkt); 33 | return OK; 34 | } 35 | 36 | return emuDelay(pkt); 37 | } 38 | -------------------------------------------------------------------------------- /network/emulate/emuDuplicate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file emuDuplicate.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | //int test(struct packet *pkt, int dupes); 13 | /** 14 | * @ingroup netemu 15 | * 16 | * Duplicate packets as specified by user 17 | * @param pkt pointer to the incoming packet 18 | * @return OK if packet was processed succesfully, otherwise SYSERR 19 | */ 20 | xinu_syscall emuDuplicate(struct packet *pkt) 21 | { 22 | /* 23 | short dupePercent = 100; 24 | int dupes = 2; 25 | 26 | if ((rand() % 100) < dupePercent) 27 | { 28 | return test(pkt, dupes); 29 | } 30 | */ 31 | return emuReorder(pkt); 32 | } 33 | 34 | /* 35 | syscall test(struct packet *pkt, int dupes) 36 | { 37 | if (dupes == 1) 38 | { 39 | return emuReorder(pkt); 40 | } 41 | 42 | return (emuReorder(pkt) | test(pkt, dupes - 1)); 43 | }*/ 44 | -------------------------------------------------------------------------------- /network/emulate/emuReorder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file emuReorder.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup netemu 13 | * 14 | * Reorder packets as specified by the user 15 | * @param pkt pointer to the incoming packet 16 | * @return OK if packet was processed succesfully, otherwise SYSERR 17 | */ 18 | xinu_syscall emuReorder(struct packet *pkt) 19 | { 20 | 21 | return emuCorrupt(pkt); 22 | } 23 | -------------------------------------------------------------------------------- /network/emulate/netemu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @file netemu.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup netemu 13 | * 14 | * Process a packet through the network emulator 15 | * @param pkt pointer to the incoming packet 16 | * @return OK if packet was processed succesfully, otherwise SYSERR 17 | */ 18 | xinu_syscall netemu(struct packet *pkt) 19 | { 20 | 21 | return emuDrop(pkt); 22 | } 23 | -------------------------------------------------------------------------------- /network/icmp/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/icmp 5 | 6 | # Source files for this component 7 | C_FILES = icmpDestUnreach.c icmpEchoReply.c icmpEchoRequest.c icmpInit.c icmpRecv.c icmpRedirect.c icmpSend.c icmpTimeExceeded.c icmpDaemon.c 8 | 9 | S_FILES = 10 | 11 | # Add the files to the compile source path 12 | DIR = ${TOPDIR}/${COMP} 13 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 14 | -------------------------------------------------------------------------------- /network/icmp/icmpInit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file icmpInit.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | mailbox icmpqueue; 13 | struct icmpEchoQueue echotab[NPINGQUEUE]; 14 | 15 | /** 16 | * @ingroup icmp 17 | * 18 | * Initializes ICMP daemon. 19 | * @return OK if initialization is successful, otherwise SYSERR 20 | */ 21 | xinu_syscall icmpInit(void) 22 | { 23 | int i; 24 | 25 | /* Initialize ICMP queue */ 26 | icmpqueue = mailboxAlloc(ICMP_NQUEUE); 27 | if (SYSERR == icmpqueue) 28 | { 29 | return SYSERR; 30 | } 31 | 32 | bzero(echotab, sizeof(echotab)); 33 | for (i = 0; i < NPINGQUEUE; i++) 34 | { 35 | echotab[i].tid = BADTID; 36 | } 37 | 38 | /* Spawn icmpDaemon thread */ 39 | ready(create 40 | ((void *)icmpDaemon, ICMP_THR_STK, ICMP_THR_PRIO, "icmpDaemon", 41 | 0)); 42 | 43 | return OK; 44 | } 45 | -------------------------------------------------------------------------------- /network/ipv4/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the network/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/ipv4 5 | 6 | # Source files for this component 7 | 8 | # Important network components 9 | C_FILES = dot2ipv4.c ipv4Recv.c ipv4RecvDemux.c ipv4RecvValid.c ipv4Send.c ipv4SendFrag.c 10 | S_FILES = 11 | 12 | # Add the files to the compile source path 13 | DIR = ${TOPDIR}/${COMP} 14 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 15 | -------------------------------------------------------------------------------- /network/net/Makerules: -------------------------------------------------------------------------------- 1 | #This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/net 5 | 6 | # Source files for this component 7 | C_FILES = netChksum.c netDown.c netFreebuf.c netGetbuf.c netInit.c netLookup.c netRecv.c netSend.c netUp.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /network/net/netChksum.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file netChksum.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup network 12 | */ 13 | unsigned short netChksum(void *data, unsigned int len) 14 | { 15 | unsigned int sum; 16 | unsigned short *ptr; 17 | 18 | /* Add data to sum */ 19 | ptr = (unsigned short *)data; 20 | sum = 0; 21 | while (len > 1) 22 | { 23 | sum += *ptr; 24 | ptr++; 25 | len -= 2; 26 | } 27 | 28 | /* Add left-over byte, if any */ 29 | if (len > 0) 30 | { 31 | sum += net2hs(*((unsigned char *)ptr) << 8); 32 | } 33 | 34 | /* Fold 32-bit sum into 16 bits */ 35 | while (sum >> 16) 36 | { 37 | sum = (sum >> 16) + (sum & 0xFFFF); 38 | } 39 | 40 | return (~sum); 41 | } 42 | -------------------------------------------------------------------------------- /network/net/netFreebuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * file netGetbuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup network 13 | * 14 | * Frees a buffer for storing a packet. 15 | * @return OK if successful, SYSERR if an error occured 16 | */ 17 | xinu_syscall netFreebuf(struct packet *pkt) 18 | { 19 | return buffree(pkt); 20 | } 21 | -------------------------------------------------------------------------------- /network/net/netGetbuf.c: -------------------------------------------------------------------------------- 1 | /** 2 | * file netGetbuf.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup network 14 | * 15 | * Provides a buffer for storing a packet. 16 | * @return pointer to a packet buffer, SYSERR if an error occured 17 | */ 18 | struct packet *netGetbuf(void) 19 | { 20 | struct packet *pkt = NULL; /**< pointer to packet */ 21 | 22 | /* Obtain a buffer for the packet */ 23 | pkt = bufget(netpool); 24 | if (SYSERR == (int)pkt) 25 | { 26 | return (struct packet *)SYSERR; 27 | } 28 | 29 | bzero(pkt, sizeof(struct packet) + NET_MAX_PKTLEN); 30 | 31 | /* Initialize packet buffer */ 32 | pkt->nif = NULL; 33 | pkt->len = 0; 34 | /* Initialize curr to point to end of buffer */ 35 | pkt->curr = pkt->data + NET_MAX_PKTLEN; 36 | 37 | return pkt; 38 | } 39 | -------------------------------------------------------------------------------- /network/net/netLookup.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file netLookup.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup network 13 | * 14 | * Lookup a network interface, given an underlying device. 15 | * @param devnum device number to find netif for. 16 | * @return network interface, NULL if none exists 17 | */ 18 | struct netif *netLookup(int devnum) 19 | { 20 | #if NNETIF 21 | for (int i = 0; i < NNETIF; i++) 22 | { 23 | /* Check if network interface is allocated and device matches */ 24 | if ((NET_ALLOC == netiftab[i].state) 25 | && (netiftab[i].dev == devnum)) 26 | { 27 | return &netiftab[i]; 28 | } 29 | } 30 | #endif 31 | return NULL; 32 | } 33 | -------------------------------------------------------------------------------- /network/netaddr/Makerules: -------------------------------------------------------------------------------- 1 | #This Makefile contains rules to build this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/netaddr 5 | 6 | # Source files for this component 7 | C_FILES = netaddrequal.c netaddrhost.c netaddrmask.c netaddrsprintf.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /network/netaddr/netaddrequal.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file netaddrequal.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup network 12 | * 13 | * Compare two network addresses 14 | * @param a first network address 15 | * @param b second network address 16 | * @return ::TRUE if addresses are the same, otherwise ::FALSE. 17 | */ 18 | bool netaddrequal(const struct netaddr *a, const struct netaddr *b) 19 | { 20 | return (a->type == b->type && 21 | a->len == b->len && 22 | 0 == memcmp(a->addr, b->addr, a->len)); 23 | } 24 | -------------------------------------------------------------------------------- /network/route/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/route 5 | 6 | # Source files for this component 7 | C_FILES = rtAdd.c rtAlloc.c rtClear.c rtDaemon.c rtDefault.c rtInit.c rtLookup.c rtRecv.c rtRemove.c rtSend.c 8 | S_FILES = 9 | 10 | # Add the files to the compile source path 11 | DIR = ${TOPDIR}/${COMP} 12 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 13 | -------------------------------------------------------------------------------- /network/route/rtAlloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtAlloc.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup route 13 | * 14 | * Allocates an entry from the route table. 15 | * @return entry in route table, NULL if all used, SYSERR if error occurs 16 | */ 17 | struct rtEntry *rtAlloc(void) 18 | { 19 | 20 | RT_TRACE("Allocating route entry"); 21 | 22 | ENTER_KERNEL_CRITICAL_SECTION(); 23 | for (int i = 0; i < RT_NENTRY; i++) 24 | { 25 | /* If entry is free, return entry */ 26 | if (RT_FREE == rttab[i].state) 27 | { 28 | rttab[i].state = RT_PEND; 29 | RT_TRACE("Free entry %d", i); 30 | EXIT_KERNEL_CRITICAL_SECTION(); 31 | return &rttab[i]; 32 | } 33 | } 34 | 35 | EXIT_KERNEL_CRITICAL_SECTION(); 36 | RT_TRACE("No free entry"); 37 | return NULL; 38 | } 39 | -------------------------------------------------------------------------------- /network/route/rtClear.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtClear.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup route 14 | * 15 | * Removes all entries for a network interface from the routing table. 16 | * @param nif network interface 17 | * @return OK if entries are removed successfully, otherwise SYSERR 18 | */ 19 | xinu_syscall rtClear(struct netif *nif) 20 | { 21 | int i; 22 | 23 | /* Error check pointers */ 24 | if (NULL == nif) 25 | { 26 | return SYSERR; 27 | } 28 | 29 | ENTER_KERNEL_CRITICAL_SECTION(); 30 | for (i = 0; i < RT_NENTRY; i++) 31 | { 32 | if ((RT_USED == rttab[i].state) && (nif == rttab[i].nif)) 33 | { 34 | rttab[i].state = RT_FREE; 35 | rttab[i].nif = NULL; 36 | } 37 | } 38 | EXIT_KERNEL_CRITICAL_SECTION(); 39 | return OK; 40 | } 41 | -------------------------------------------------------------------------------- /network/route/rtDaemon.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtDaemon.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @ingroup route 15 | * 16 | * Route dameon to route packets 17 | */ 18 | thread rtDaemon(void) 19 | { 20 | struct packet *pkt = NULL; 21 | 22 | while (TRUE) 23 | { 24 | pkt = (struct packet *)mailboxReceive(rtqueue); 25 | RT_TRACE("Daemon received packet"); 26 | if (SYSERR == (int)pkt) 27 | { 28 | RT_TRACE("Daemon received packet has an error"); 29 | continue; 30 | } 31 | 32 | rtSend(pkt); 33 | if (SYSERR == netFreebuf(pkt)) 34 | { 35 | RT_TRACE("Failed to free packet buffer"); 36 | continue; 37 | } 38 | } 39 | 40 | return OK; 41 | } 42 | -------------------------------------------------------------------------------- /network/route/rtRemove.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rtRemove.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @ingroup route 14 | * 15 | * Removes any entry based on its destination. 16 | * @param dst destination IP address 17 | * @return OK if the entry is removed successfully, otherwise SYSERR 18 | */ 19 | xinu_syscall rtRemove(const struct netaddr *dst) 20 | { 21 | int i; 22 | 23 | /* Error check pointers */ 24 | if (NULL == dst) 25 | { 26 | return SYSERR; 27 | } 28 | 29 | ENTER_KERNEL_CRITICAL_SECTION(); 30 | for (i = 0; i < RT_NENTRY; i++) 31 | { 32 | if ((RT_USED == rttab[i].state) 33 | && netaddrequal(dst, &rttab[i].dst)) 34 | { 35 | rttab[i].state = RT_FREE; 36 | rttab[i].nif = NULL; 37 | } 38 | } 39 | EXIT_KERNEL_CRITICAL_SECTION(); 40 | return OK; 41 | } 42 | -------------------------------------------------------------------------------- /network/snoop/Makerules: -------------------------------------------------------------------------------- 1 | #This Makefile contains rules to build files in the net/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/snoop 5 | 6 | # Source files for this component 7 | 8 | # Important network components 9 | C_FILES = snoopCapture.c snoopClose.c snoopFilter.c snoopOpen.c snoopPrint.c snoopPrintArp.c snoopPrintEthernet.c snoopPrintIpv4.c snoopPrintTcp.c snoopPrintUdp.c snoopRead.c 10 | S_FILES = 11 | 12 | # Add the files to the compile source path 13 | DIR = ${TOPDIR}/${COMP} 14 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 15 | -------------------------------------------------------------------------------- /network/snoop/snoopRead.c: -------------------------------------------------------------------------------- 1 | /* @file snoopRead.c 2 | * 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup snoop 11 | * 12 | * Returns a packet captured from a network interface. 13 | * @return a packet if read was successful, otherwise SYSERR 14 | */ 15 | struct packet *snoopRead(struct snoop *cap) 16 | { 17 | struct packet *pkt; 18 | 19 | /* Error check pointers */ 20 | if (NULL == cap) 21 | { 22 | return (struct packet *)SYSERR; 23 | } 24 | 25 | pkt = (struct packet *)mailboxReceive(cap->queue); 26 | if ((SYSERR == (int)pkt) || (NULL == pkt)) 27 | { 28 | return (struct packet *)SYSERR; 29 | } 30 | 31 | return pkt; 32 | } 33 | -------------------------------------------------------------------------------- /network/tftp/Makerules: -------------------------------------------------------------------------------- 1 | #This Makefile contains rules to build files in the net/tftp directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = network/tftp 5 | 6 | # Source files for this component 7 | 8 | # Important network components 9 | C_FILES = tftpGet.c tftpGetIntoBuffer.c tftpRecvPackets.c tftpSendACK.c tftpSendRRQ.c 10 | S_FILES = 11 | 12 | # Add the files to the compile source path 13 | DIR = ${TOPDIR}/${COMP} 14 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 15 | -------------------------------------------------------------------------------- /shell/xsh_netemu.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file xsh_netemu.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup shell 13 | * 14 | * Shell command (netemu). Allows user to set network emulator options. 15 | * @param nargs number of arguments 16 | * @param args array of arguments 17 | * @return non-zero value on error 18 | */ 19 | shellcmd xsh_netemu(int nargs, char *args[]) 20 | { 21 | srand(getRdate("192.168.6.10")); 22 | return 0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /shell/xsh_test.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file xsh_test.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | 11 | /** 12 | * @ingroup shell 13 | * 14 | * Shell command (test) provides a mechanism for testing Xinu features. The 15 | * action and output varies depending on the feature currently being tested. 16 | * This is not meant to serve as a permanent shell command for a particular 17 | * action. 18 | * @param nargs number of arguments 19 | * @param args array of arguments 20 | * @return non-zero value on error 21 | */ 22 | shellcmd xsh_test(int nargs, char *args[]) 23 | { 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /system/arch/README: -------------------------------------------------------------------------------- 1 | This directory contains CPU-architecture-specific code. 2 | 3 | Note that a CPU architecture may be shared among one or more 4 | Embedded Xinu "platforms" (see ../platforms/ ). 5 | -------------------------------------------------------------------------------- /system/arch/arm/halt.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file halt.S 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | .globl halt 7 | 8 | #include 9 | 10 | /** 11 | * @fn void halt(void) 12 | * 13 | * Halt the system by sending the processor into an infinite loop. 14 | */ 15 | halt: 16 | .func halt 17 | 18 | _loop: 19 | /* Disable IRQs and FIQs. */ 20 | msr cpsr_c, #ARM_I_BIT | ARM_F_BIT 21 | 22 | /* Wait for interrupt. */ 23 | wfi 24 | 25 | /* Shouldn't be necessary, but repeat just in case. */ 26 | b _loop 27 | .endfunc 28 | -------------------------------------------------------------------------------- /system/arch/arm/pause.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pause.S 3 | * Platform-dependent code for idling the processor. 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 6 | 7 | .globl pause 8 | 9 | pause: 10 | .func pause 11 | wfi /* ARM "wait for interrupt" instruction. */ 12 | mov pc, lr 13 | .endfunc 14 | -------------------------------------------------------------------------------- /system/arch/mips/debugbreak.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file debugbreak.S 3 | * Give access to the assembly debug breakpoint command that drops 4 | * straight into debug mode. 5 | */ 6 | 7 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 8 | 9 | #include 10 | 11 | .text 12 | .align 4 13 | .set mips32 14 | 15 | /** 16 | * @fn debugbreak 17 | * 18 | * Inserts breakpoint and drops into debug mode. 19 | * Stores return address to DEPC register and jumps 20 | * back to it if processor returns from breakpoint. 21 | */ 22 | .globl debugbreak 23 | debugbreak: 24 | .set noreorder 25 | sdbbp 26 | nop 27 | jr ra 28 | nop 29 | .set reorder 30 | -------------------------------------------------------------------------------- /system/arch/mips/halt.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file halt.S 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 5 | 6 | #include 7 | 8 | .globl halt 9 | 10 | /** 11 | * @fn void halt(void) 12 | * 13 | * Essentially this is a busy wait, however the opcode 'wait' puts the 14 | * processor in a powersave state (which can be awoken for arbitrary 15 | * reasons) 16 | */ 17 | halt: 18 | .func halt 19 | wait 20 | j halt 21 | .endfunc 22 | 23 | -------------------------------------------------------------------------------- /system/arch/mips/pause.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pause.S 3 | * Platform-dependent code for idling the processor 4 | * 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 7 | 8 | #include 9 | 10 | .globl pause 11 | 12 | /** 13 | * @fn void pause(void) 14 | * 15 | * Enter some kind of powerdown state (if it exists) that suspends 16 | * execution until an interrupt is detected. 17 | */ 18 | pause: 19 | .func pause 20 | wait 21 | jr ra 22 | .endfunc 23 | 24 | -------------------------------------------------------------------------------- /system/chprio.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file chprio.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup threads 12 | * 13 | * Change the scheduling priority of a thread 14 | * @param tid target thread 15 | * @param newprio new priority 16 | * @return old priority of thread 17 | */ 18 | xinu_syscall chprio(tid_typ tid, int newprio) 19 | { 20 | register struct thrent *thrptr; /* thread control block */ 21 | irqmask im; 22 | int oldprio; 23 | 24 | im = disable(); 25 | if (isbadtid(tid)) 26 | { 27 | restore(im); 28 | return SYSERR; 29 | } 30 | thrptr = &thrtab[tid]; 31 | oldprio = thrptr->prio; 32 | thrptr->prio = newprio; 33 | restore(im); 34 | return oldprio; 35 | } 36 | -------------------------------------------------------------------------------- /system/conf.c: -------------------------------------------------------------------------------- 1 | /* conf.c (GENERATED FILE; DO NOT EDIT) */ 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* device independent I/O switch */ 21 | 22 | device devtab[NDEVS] = { 0 }; 23 | -------------------------------------------------------------------------------- /system/getdev.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file getdev.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup devcalls 13 | * 14 | * Translates a device name into a device number. 15 | * 16 | * @param dev 17 | * Name of the device. 18 | * 19 | * @return 20 | * The number of the device, or ::SYSERR if the device was not found. 21 | */ 22 | xinu_syscall getdev (const char *dev) 23 | { 24 | for (int devnum = 0; devnum < NDEVS; devnum++) 25 | { 26 | if (0 == strncmp(dev, devtab[devnum].name, DEVMAXNAME)) 27 | { 28 | return devnum; 29 | } 30 | } 31 | 32 | return SYSERR; 33 | } 34 | -------------------------------------------------------------------------------- /system/gettid.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gettid.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup threads 11 | * 12 | * Get the thread id of currently executing thread. 13 | * @return thread id of the currently running thread 14 | */ 15 | tid_typ gettid(void) 16 | { 17 | return thrcurrent; 18 | } 19 | -------------------------------------------------------------------------------- /system/ioerr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ioerr.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup devcalls 11 | * 12 | * Unconditionally return an error (used for "error" entries in devtab). 13 | * 14 | * @return ::SYSERR 15 | */ 16 | xinu_devcall ioerr (void) 17 | { 18 | return SYSERR; 19 | } 20 | -------------------------------------------------------------------------------- /system/ionull.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ionull.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup devcalls 11 | * 12 | * Do nothing (use for irrelevant entries in devtab). 13 | * 14 | * @return ::OK 15 | */ 16 | xinu_devcall ionull(void) 17 | { 18 | return OK; 19 | } 20 | -------------------------------------------------------------------------------- /system/mdelay.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mdelay.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #if RTCLOCK == TRUE 7 | #include 8 | 9 | /** 10 | * @ingroup timer 11 | * 12 | * Busy-waits for a number of milliseconds. 13 | * Only use this function if absolutely necessary. Normally you should call 14 | * sleep() so that other threads can use the processor immediately. 15 | * 16 | * @param ms 17 | * Number of milliseconds to wait for. 18 | */ 19 | void mdelay (unsigned long ms) 20 | { 21 | while (ms--) 22 | { 23 | udelay(1000); 24 | } 25 | } 26 | 27 | #endif /* RTCLOCK */ 28 | -------------------------------------------------------------------------------- /system/moncount.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file moncount.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup monitors 11 | * 12 | * Retrieve the count of a monitor --- that is, the number of times it has been 13 | * locked by the owning thread, or 0 if no thread currently owns the monitor. 14 | * 15 | * This function performs no locking. The caller must temporarily disable 16 | * interrupts if the specified monitor could potentially be freed, locked, or 17 | * unlocked concurrently. 18 | * 19 | * @param mon 20 | * The monitor to retrieve the count of. 21 | * 22 | * @return 23 | * If @p mon specified a valid, allocated monitor, its count is returned. 24 | * Otherwise, ::SYSERR is returned. 25 | */ 26 | xinu_syscall moncount (monitor mon) 27 | { 28 | if (isbadmon(mon)) 29 | { 30 | return SYSERR; 31 | } 32 | 33 | return (montab[mon].count); 34 | } 35 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/Makerules: -------------------------------------------------------------------------------- 1 | # Rules to build files in this directory 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/arm-qemu 5 | 6 | # Source files for this component 7 | S_FILES = start.S \ 8 | ctxsw.S \ 9 | halt.S \ 10 | intutils.S \ 11 | irq_handler.S \ 12 | memory_barrier.S \ 13 | pause.S 14 | 15 | C_FILES = clkinit.c \ 16 | platforminit.c \ 17 | pl190.c \ 18 | setupStack.c \ 19 | sp804.c 20 | 21 | # Add the files to the compile source path 22 | DIR = ${TOPDIR}/${COMP} 23 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 24 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt handling. 5 | */ 6 | /* Embedded Xinu, Copyright (C) 2009, 2013. All rights reserved. */ 7 | 8 | #ifndef _INTERRUPT_H_ 9 | #define _INTERRUPT_H_ 10 | 11 | #include 12 | 13 | typedef interrupt (*interrupt_handler_t)(void); 14 | 15 | extern interrupt_handler_t interruptVector[]; 16 | 17 | typedef unsigned long irqmask; /**< machine status for disable/restore */ 18 | 19 | 20 | void enable(void); 21 | irqmask disable(void); 22 | irqmask restore(irqmask); 23 | void enable_irq(irqmask); 24 | void disable_irq(irqmask); 25 | 26 | #endif /* _INTERRUPT_H_ */ 27 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/irq_handler.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/memory_barrier.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-qemu/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/arm-rpi/CriticalSection.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "CriticalSection.h" 5 | 6 | static bool inCrit = true; 7 | static uint32_t intmask = 0; 8 | 9 | extern uint32_t disable(void); // In assembler file system/arch/arm/intutils.S 10 | extern void restore(uint32_t mask); // In assembler file system/arch/arm/intutils.S 11 | 12 | void ENTER_KERNEL_CRITICAL_SECTION (void) 13 | { 14 | if (inCrit == false) { 15 | kprintf("Aborting .. ENTER_KERNEL_CRITICAL_SECTION called twice without leaving \n"); 16 | while (1) {} 17 | } 18 | intmask = disable(); 19 | inCrit = true; 20 | } 21 | 22 | void EXIT_KERNEL_CRITICAL_SECTION (void) 23 | { 24 | if (inCrit == false) { 25 | kprintf("Aborting .. EXIT_KERNEL_CRITICAL_SECTION called twice without entering \n"); 26 | while (1) {} 27 | } 28 | restore(intmask); 29 | } -------------------------------------------------------------------------------- /system/platforms/arm-rpi/CriticalSection.h: -------------------------------------------------------------------------------- 1 | #ifndef _CRITICAL_SECTION_H_ 2 | #define _CRITICAL_DECTION_H_ 3 | 4 | 5 | void ENTER_KERNEL_CRITICAL_SECTION (void); 6 | 7 | void EXIT_KERNEL_CRITICAL_SECTION (void); 8 | 9 | #endif /* _CRITICAL_SECTION_H_ */ 10 | -------------------------------------------------------------------------------- /system/platforms/arm-rpi/Makerules: -------------------------------------------------------------------------------- 1 | # Rules to build files in this directory 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/arm-rpi 5 | 6 | # Source files for this component 7 | S_FILES = start.S \ 8 | ctxsw.S \ 9 | halt.S \ 10 | intutils.S \ 11 | irq_handler.S \ 12 | memory_barrier.S \ 13 | pause.S 14 | 15 | C_FILES = setupStack.c \ 16 | rpi-mailbox.c \ 17 | rpi-timer.c \ 18 | dispatch.c \ 19 | kexec.c \ 20 | platforminit.c \ 21 | watchdog.c \ 22 | CriticalSection.c 23 | 24 | # Add the files to the compile source path 25 | DIR = ${TOPDIR}/${COMP} 26 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 27 | -------------------------------------------------------------------------------- /system/platforms/arm-rpi/dispatch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LdB-ECM/Xinu/9e1d598ad8fd7c509f35d306ec70522cdbfa62fb/system/platforms/arm-rpi/dispatch -------------------------------------------------------------------------------- /system/platforms/arm-rpi/halt.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file halt.S 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 5 | 6 | .globl halt 7 | 8 | #include 9 | 10 | /** 11 | * @fn void halt(void) 12 | * 13 | * Halt the system by sending the processor into an infinite loop. 14 | */ 15 | halt: 16 | .func halt 17 | 18 | _loop: 19 | /* Disable IRQs and FIQs. */ 20 | msr cpsr_c, #ARM_I_BIT | ARM_F_BIT 21 | 22 | /* Wait for interrupt. */ 23 | wfi 24 | 25 | /* Shouldn't be necessary, but repeat just in case. */ 26 | b _loop 27 | .endfunc 28 | -------------------------------------------------------------------------------- /system/platforms/arm-rpi/pause.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pause.S 3 | * Platform-dependent code for idling the processor. 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2013. All rights reserved. */ 6 | 7 | .globl pause 8 | 9 | pause: 10 | .func pause 11 | wfi /* ARM "wait for interrupt" instruction. */ 12 | mov pc, lr 13 | .endfunc 14 | -------------------------------------------------------------------------------- /system/platforms/e2100l/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/e2100l 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intutils.S intdispatch.S halt.S 18 | C_FILES += dispatch.c exception.c clkinit.c 19 | 20 | # Add the files to the compile source path 21 | DIR = ${TOPDIR}/${COMP} 22 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 23 | -------------------------------------------------------------------------------- /system/platforms/e2100l/ar9130.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ar9130.h 3 | * 4 | * Constants and declarations associated with the Atheros 9130 5 | * wireless System On A Chip. 6 | * 7 | */ 8 | 9 | #define RST_MISC_INTERRUPT_MASK 0xB8060014 10 | #define RST_MISC_INTERRUPT_STATUS 0xB8060010 11 | 12 | #define RST_MISC_IRQ_TIMER (1 << 0) 13 | #define RST_MISC_IRQ_ERROR (1 << 1) 14 | #define RST_MISC_IRQ_GPIO (1 << 2) 15 | #define RST_MISC_IRQ_UART (1 << 3) 16 | #define RST_MISC_IRQ_WATCHDOG (1 << 4) 17 | #define RST_MISC_IRQ_PERF (1 << 5) 18 | #define RST_MISC_IRQ_MBOX (1 << 7) 19 | #define RST_MISC_IRQ_MASK 0x00FF 20 | -------------------------------------------------------------------------------- /system/platforms/e2100l/clkupdate.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/intdispatch.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt and exception 5 | * processing. 6 | */ 7 | /* Embedded Xinu, Copyright (C) 2008. All rights reserved. */ 8 | 9 | #ifndef _INTERRUPT_H_ 10 | #define _INTERRUPT_H_ 11 | 12 | #include 13 | 14 | /** Address of interrupt request handler. */ 15 | #define IRQ_ADDR 0x80000180 16 | /** Address of Xinu-defined trap (exception) vector. */ 17 | #define TRAPVEC_ADDR 0x80001000 18 | /** Address of Xinu-defined interrupt request vector. */ 19 | #define IRQVEC_ADDR 0x80001080 20 | /** Address of end of Xinu-defined interrupt tables. */ 21 | #define IRQVEC_END 0x800010C0 22 | 23 | #ifndef __ASSEMBLER__ 24 | void enable_irq(irqmask); 25 | void disable_irq(irqmask); 26 | #endif 27 | 28 | #endif /* _INTERRUPT_H_ */ 29 | -------------------------------------------------------------------------------- /system/platforms/e2100l/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/e2100l/start.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/mipsel-qemu 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intutils.S intdispatch.S halt.S 18 | C_FILES += dispatch.c exception.c clkinit.c 19 | 20 | # Files for system calls 21 | S_FILES += syscall_entry.S 22 | C_FILES += syscall_dispatch.c 23 | 24 | # Add the files to the compile source path 25 | DIR = ${TOPDIR}/${COMP} 26 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 27 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/clkupdate.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/intdispatch.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt and exception 5 | * processing. 6 | * 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 9 | 10 | #ifndef _INTERRUPT_H_ 11 | #define _INTERRUPT_H_ 12 | 13 | #include 14 | 15 | /** Address of interrupt request handler. */ 16 | #define IRQ_ADDR 0x80000180 17 | /** Address of Xinu-defined trap (exception) vector. */ 18 | #define TRAPVEC_ADDR 0x80000200 19 | /** Address of Xinu-defined interrupt request vector. */ 20 | #define IRQVEC_ADDR 0x80000280 21 | /** Address of end of Xinu-defined interrupt tables. */ 22 | #define IRQVEC_END 0x800002E0 23 | 24 | #ifndef __ASSEMBLER__ 25 | void enable_irq(irqmask); 26 | void disable_irq(irqmask); 27 | #endif 28 | 29 | #endif /* _INTERRUPT_H_ */ 30 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/pic8259.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pic8259.h 3 | * 4 | * PC-style i8259 programmable interrupt controller. 5 | * 6 | */ 7 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 8 | 9 | #ifndef _PIC8259_H_ 10 | #define _PIC8259_H_ 11 | 12 | #ifdef PIC8259 13 | 14 | #define PIC_MASTER PIC8259 15 | #define PIC_MASTER_IMR (PIC_MASTER + 1) 16 | #define PIC_SLAVE (PIC_MASTER + 0x80) 17 | #define PIC_SLAVE_IMR (PIC_SLAVE + 1) 18 | #define PIC_MASTER_ELCR (PIC_MASTER + 0x4B0) 19 | #define PIC_SLAVE_ELCR (PIC_MASTER + 0x4B1) 20 | 21 | #endif /* PIC8259 */ 22 | 23 | /* PIC function prototypes */ 24 | 25 | #endif /* _PIC8259_H_ */ 26 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/start.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/syscall_dispatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/mipsel-qemu/syscall_entry.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/wl330ge 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intutils.S intdispatch.S halt.S 18 | C_FILES += dispatch.c exception.c clkinit.c 19 | 20 | # Files for JTAG debugging 21 | S_FILES += debugbreak.S debugret.S 22 | 23 | # Files for system calls 24 | S_FILES += syscall_entry.S 25 | C_FILES += syscall_dispatch.c 26 | 27 | # Add the files to the compile source path 28 | DIR = ${TOPDIR}/${COMP} 29 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 30 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/clkupdate.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/debugbreak.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/debugret.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/intdispatch.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt and exception 5 | * processing. 6 | * 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 9 | 10 | #ifndef _INTERRUPT_H_ 11 | #define _INTERRUPT_H_ 12 | 13 | #include 14 | 15 | /** Address of interrupt request handler. */ 16 | #define IRQ_ADDR 0x80000180 17 | /** Address of Xinu-defined trap (exception) vector. */ 18 | #define TRAPVEC_ADDR 0x80000200 19 | /** Address of Xinu-defined interrupt request vector. */ 20 | #define IRQVEC_ADDR 0x80000280 21 | /** Address of end of Xinu-defined interrupt tables. */ 22 | #define IRQVEC_END 0x800002A0 23 | 24 | #ifndef __ASSEMBLER__ 25 | #define enable_irq enable_cpuirq 26 | #define disable_irq disable_cpuirq 27 | #endif 28 | 29 | #endif /* _INTERRUPT_H_ */ 30 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/start.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/syscall_dispatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wl330ge/syscall_entry.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/wrt160nl 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intutils.S intdispatch.S halt.S 18 | C_FILES += dispatch.c exception.c clkinit.c 19 | 20 | # Add the files to the compile source path 21 | DIR = ${TOPDIR}/${COMP} 22 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 23 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/ar9130.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ar9130.h 3 | * 4 | * Constants and declarations associated with the Atheros 9130 5 | * wireless System On A Chip. 6 | * 7 | */ 8 | 9 | #define RST_MISC_INTERRUPT_MASK 0xB8060014 10 | #define RST_MISC_INTERRUPT_STATUS 0xB8060010 11 | 12 | #define RST_MISC_IRQ_TIMER (1 << 0) 13 | #define RST_MISC_IRQ_ERROR (1 << 1) 14 | #define RST_MISC_IRQ_GPIO (1 << 2) 15 | #define RST_MISC_IRQ_UART (1 << 3) 16 | #define RST_MISC_IRQ_WATCHDOG (1 << 4) 17 | #define RST_MISC_IRQ_PERF (1 << 5) 18 | #define RST_MISC_IRQ_MBOX (1 << 7) 19 | #define RST_MISC_IRQ_MASK 0x00FF 20 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/clkupdate.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/intdispatch.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt and exception 5 | * processing. 6 | * 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2008. All rights reserved. */ 9 | 10 | #ifndef _INTERRUPT_H_ 11 | #define _INTERRUPT_H_ 12 | 13 | #include 14 | 15 | /** Address of interrupt request handler. */ 16 | #define IRQ_ADDR 0x80000180 17 | /** Address of Xinu-defined trap (exception) vector. */ 18 | #define TRAPVEC_ADDR 0x80001000 19 | /** Address of Xinu-defined interrupt request vector. */ 20 | #define IRQVEC_ADDR 0x80001080 21 | /** Address of end of Xinu-defined interrupt tables. */ 22 | #define IRQVEC_END 0x800010C0 23 | 24 | #ifndef __ASSEMBLER__ 25 | void enable_irq(irqmask); 26 | void disable_irq(irqmask); 27 | #endif 28 | 29 | #endif /* _INTERRUPT_H_ */ 30 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/platforminit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file platforminit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | extern ulong cpuid; /* Processor id */ 15 | 16 | extern struct platform platform; /* Platform specific configuration */ 17 | 18 | /** 19 | * Determines and stores all platform specific information. 20 | * @return OK if everything is determined successfully 21 | */ 22 | int platforminit(void) 23 | { 24 | strncpy(platform.family, "MIPS 24K", PLT_STRMAX); 25 | strncpy(platform.name, "Linksys WRT160NL", PLT_STRMAX); 26 | platform.maxaddr = (void *)(KSEG0_BASE | MAXADDR_WRT160NL); 27 | platform.clkfreq = CLKFREQ_WRT160NL; 28 | platform.uart_dll = (CLKFREQ_WRT160NL / 16) / UART_BAUD; 29 | return OK; 30 | } 31 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt160nl/start.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in this directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/wrt54gl 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intutils.S intdispatch.S halt.S 18 | C_FILES += dispatch.c exception.c clkinit.c 19 | 20 | # Files for JTAG debugging 21 | S_FILES += debugbreak.S debugret.S 22 | 23 | # Files for system calls 24 | S_FILES += syscall_entry.S 25 | C_FILES += syscall_dispatch.c 26 | 27 | # Add the files to the compile source path 28 | DIR = ${TOPDIR}/${COMP} 29 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 30 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/clkupdate.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/ctxsw.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/debugbreak.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/debugret.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/exception.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/halt.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/intdispatch.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/interrupt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interrupt.h 3 | * 4 | * Constants and declarations associated with interrupt and exception 5 | * processing. 6 | * 7 | */ 8 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 9 | 10 | #ifndef _INTERRUPT_H_ 11 | #define _INTERRUPT_H_ 12 | 13 | #include 14 | 15 | /** Address of interrupt request handler. */ 16 | #define IRQ_ADDR 0x80000180 17 | /** Address of Xinu-defined trap (exception) vector. */ 18 | #define TRAPVEC_ADDR 0x80000200 19 | /** Address of Xinu-defined interrupt request vector. */ 20 | #define IRQVEC_ADDR 0x80000280 21 | /** Address of end of Xinu-defined interrupt tables. */ 22 | #define IRQVEC_END 0x800002A0 23 | 24 | #ifndef __ASSEMBLER__ 25 | #define enable_irq enable_cpuirq 26 | #define disable_irq disable_cpuirq 27 | #endif 28 | 29 | #endif /* _INTERRUPT_H_ */ 30 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/intutils.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/pause.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/platforminit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file platforminit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | extern ulong cpuid; /* Processor id */ 15 | 16 | extern struct platform platform; /* Platform specific configuration */ 17 | 18 | /** 19 | * Determines and stores all platform specific information. 20 | * @return OK if everything is determined successfully 21 | */ 22 | int platforminit(void) 23 | { 24 | strlcpy(platform.family, "Broadcom 3302", PLT_STRMAX); 25 | strlcpy(platform.name, "Linksys WRT54GL", PLT_STRMAX); 26 | platform.maxaddr = (void *)(KSEG0_BASE | MAXADDR_WRT54GL); 27 | platform.minaddr = (void *)KSEG0_BASE; 28 | platform.clkfreq = CLKFREQ_WRT54GL; 29 | platform.uart_dll = UART_DLL_WRT54GL; 30 | return OK; 31 | } 32 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/setupStack.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/start.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/syscall_dispatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/wrt54gl/syscall_entry.S: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /system/platforms/x86/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the system/platforms/x86 directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = system/platforms/x86 5 | 6 | # Source files for this component 7 | 8 | # Important system components 9 | S_FILES = start.S startup.S pause.S 10 | C_FILES = platforminit.c 11 | 12 | # Files for process control 13 | S_FILES += ctxsw.S 14 | C_FILES += setupStack.c 15 | 16 | # Files for preemption and interrupts 17 | S_FILES += clkupdate.S intr.S halt.S 18 | C_FILES += xtrap.c clkinit.c 19 | 20 | # Files specific to Intel x86 21 | S_FILES += parport.S 22 | C_FILES += segment.c evec.c dispatch.c 23 | 24 | # Add the files to the compile source path 25 | DIR = ${TOPDIR}/${COMP} 26 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 27 | -------------------------------------------------------------------------------- /system/platforms/x86/asm-i386/icu.h: -------------------------------------------------------------------------------- 1 | /* icu.h */ 2 | 3 | #define ICU1 0x20 /* address of primary interrupt control unit */ 4 | #define ICU2 0xA0 /* address of slave interrupt control unit */ 5 | 6 | #define OCR1 ICU1 /* Operation Command Register for ICU1 */ 7 | #define OCR2 ICU2 /* Operation Command Register for ICU2 */ 8 | #define IMR1 (ICU1+1) /* Interrupt Mask Register for ICU1 */ 9 | #define IMR2 (ICU2+1) /* Interrupt Mask Register for ICU2 */ 10 | 11 | #define EOI 0x20 /* end-of-interrupt signal */ 12 | -------------------------------------------------------------------------------- /system/platforms/x86/clkupdate.S: -------------------------------------------------------------------------------- 1 | /* clockupdate.s - clock_update */ 2 | 3 | #include 4 | 5 | .text 6 | .globl clkupdate 7 | clkupdate: 8 | movb $EOI, %al /* write end-of-interrupt signal */ 9 | outb %al, $OCR1 /* to interrupt control unit */ 10 | ret 11 | 12 | 13 | .globl clockIRQ 14 | clockIRQ: 15 | cli 16 | pushal 17 | call clkhandler 18 | popal 19 | sti 20 | iret 21 | -------------------------------------------------------------------------------- /system/platforms/x86/dispatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern void clockintr(void); 6 | extern void xtrap(int, int *); 7 | 8 | interrupt (*exctab[NID])(void); 9 | 10 | void dispatch(int exc_num, int *stack_ptr) 11 | { 12 | if ( exctab[exc_num] != NULL ) 13 | { 14 | /* execute handler */ 15 | (*exctab[exc_num])(); 16 | } 17 | else 18 | { 19 | xtrap(exc_num, stack_ptr); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /system/platforms/x86/halt.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file halt.s 3 | * 4 | */ 5 | /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 6 | 7 | .text 8 | .align 4 9 | .globl halt 10 | 11 | /** 12 | * @fn void halt(void) 13 | * 14 | * Essentially this is a busy wait, however the opcode 'hlt' puts the 15 | * processor in a powersave state (which can be awoken for arbitrary 16 | * reasons) 17 | */ 18 | halt: 19 | hlt 20 | jmp halt 21 | -------------------------------------------------------------------------------- /system/platforms/x86/parport.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | .data 4 | PARPORT: .string "Parallel Port: 0x%08x\r\n" 5 | 6 | .text 7 | .globl parport 8 | parport: 9 | cli 10 | pushal 11 | 12 | /* send end-of-interrupt signal */ 13 | movb $EOI, %al 14 | outb %al, $OCR1 15 | 16 | popal 17 | sti 18 | iret 19 | -------------------------------------------------------------------------------- /system/platforms/x86/pause.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pause.S 3 | * Platform-dependent code for idling the processor 4 | * 5 | */ 6 | /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 7 | 8 | .text 9 | .align 4 10 | .globl pause 11 | 12 | /** 13 | * @fn void pause(void) 14 | * 15 | * Enter some kind of powerdown state (if it exists) that suspends 16 | * execution until an interrupt is detected. 17 | */ 18 | pause: 19 | call enable 20 | hlt 21 | ret 22 | 23 | -------------------------------------------------------------------------------- /system/platforms/x86/start.S: -------------------------------------------------------------------------------- 1 | /** 2 | * @file start.S 3 | * 4 | */ 5 | /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 6 | 7 | .text 8 | .align 4 9 | .globl _start 10 | .extern startup 11 | .extern _end 12 | 13 | _start: 14 | /* disable any interrupts from coming in */ 15 | cli 16 | 17 | movl $_end, %eax # set stack pointer to 64k after end of image 18 | addl $64*1024, %eax 19 | decl %eax # 16-byte align stack pointer 20 | shrl $0x04, %eax 21 | shll $0x04, %eax 22 | movl %eax, %esp # set stack pointer 23 | 24 | jmp startup 25 | -------------------------------------------------------------------------------- /system/putc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file putc.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2013, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | 9 | /** 10 | * @ingroup devcalls 11 | * 12 | * Write one character to a device. 13 | * 14 | * @param descrp 15 | * Index of device to which to write the character. 16 | * @param ch 17 | * character to write 18 | * 19 | * @return 20 | * On success, returns the character written as an unsigned 21 | * char cast to an @c int. On bad device descripter, returns @c 22 | * ::SYSERR. On other failure, returns ::SYSERR or ::EOF depending on the 23 | * specific device driver it calls. 24 | */ 25 | xinu_devcall putc (int descrp, char ch) 26 | { 27 | device *devptr; 28 | if (!isbaddev(descrp)) 29 | { 30 | devptr = (device *)&devtab[descrp]; 31 | if (devptr && devptr->putc) 32 | { 33 | return ((*devptr->putc) (devptr, ch)); 34 | } 35 | } 36 | return SYSERR; 37 | } 38 | -------------------------------------------------------------------------------- /system/queinit.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file queinit.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup threads 11 | * 12 | * Initialize a new queue in the global thread queue table 13 | * @return newly allocated queue ID or SYSERR 14 | */ 15 | qid_typ queinit (void) 16 | { 17 | static int nextqid = NTHREAD; 18 | 19 | /**< next available quetab entry */ 20 | qid_typ q; 21 | 22 | if (nextqid > NQENT) 23 | { 24 | return SYSERR; 25 | } 26 | q = nextqid; 27 | nextqid += 2; 28 | quetab[quehead(q)].next = quetail(q); 29 | quetab[quehead(q)].prev = EMPTY; 30 | quetab[quehead(q)].key = MAXKEY; 31 | quetab[quetail(q)].next = EMPTY; 32 | quetab[quetail(q)].prev = quehead(q); 33 | quetab[quetail(q)].key = MINKEY; 34 | return q; 35 | } 36 | -------------------------------------------------------------------------------- /system/receive.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file receive.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup threads 13 | * 14 | * receive - wait for a message and return it 15 | * @return message 16 | */ 17 | xinu_message receive(void) 18 | { 19 | struct thrent *thrptr; 20 | xinu_message msg; 21 | 22 | ENTER_KERNEL_CRITICAL_SECTION(); 23 | thrptr = &thrtab[thrcurrent]; 24 | if (FALSE == thrptr->hasmsg) 25 | { /* if no message, wait for one */ 26 | thrptr->state = THRRECV; 27 | EXIT_KERNEL_CRITICAL_SECTION(); 28 | resched(); 29 | ENTER_KERNEL_CRITICAL_SECTION(); 30 | } 31 | msg = thrptr->msg; /* retrieve message */ 32 | thrptr->hasmsg = FALSE; /* reset message flag */ 33 | EXIT_KERNEL_CRITICAL_SECTION(); 34 | return msg; 35 | } 36 | -------------------------------------------------------------------------------- /system/recvclr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file recvclr.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /** 12 | * @ingroup threads 13 | * 14 | * Clear messages, return waiting message (if any) 15 | * @return msg if available, NOMSG if no message 16 | */ 17 | xinu_message recvclr (void) 18 | { 19 | struct thrent *thrptr; 20 | xinu_message msg; 21 | 22 | ENTER_KERNEL_CRITICAL_SECTION(); 23 | thrptr = &thrtab[thrcurrent]; 24 | if (thrptr->hasmsg) 25 | { 26 | msg = thrptr->msg; 27 | } /* retrieve message */ 28 | else 29 | { 30 | msg = NOMSG; 31 | } 32 | thrptr->hasmsg = FALSE; /* reset message flag */ 33 | EXIT_KERNEL_CRITICAL_SECTION(); 34 | return msg; 35 | } 36 | -------------------------------------------------------------------------------- /system/seek.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file seek.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * XXX: This function apparently isn't used anywhere currently. 12 | * 13 | * position a device (very common special case of control) 14 | * @param descrp definition of device on which to seek 15 | * @param pos requested position to seek 16 | * @return function to seek on device on success, SYSERR on failure 17 | */ 18 | xinu_devcall seek (int descrp, unsigned int pos) 19 | { 20 | xinu_devcall result = SYSERR; 21 | device *devptr; 22 | if (!isbaddev(descrp)) 23 | { 24 | devptr = (device *)&devtab[descrp]; 25 | if (devptr && devptr->seek) 26 | { 27 | return ((*devptr->seek) (devptr, pos)); 28 | } 29 | } 30 | return result; 31 | } 32 | -------------------------------------------------------------------------------- /system/semcount.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file semcount.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup semaphores 12 | * 13 | * Retrieve a semaphore's count. 14 | * 15 | * @param sem 16 | * Semaphore to get the count of. 17 | * 18 | * @return 19 | * On success, returns the semaphore's count; otherwise returns ::SYSERR. 20 | * This function can only fail if @p sem did not specify a valid semaphore. 21 | */ 22 | xinu_syscall semcount (semaphore sem) 23 | { 24 | if (isbadsem(sem)) 25 | { 26 | return SYSERR; 27 | } 28 | 29 | return (semtab[sem].count); 30 | } 31 | -------------------------------------------------------------------------------- /system/unistd.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file unistd.c 3 | */ 4 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | xinu_syscall getnum(void) 13 | { 14 | int i = 0, c = 0; 15 | 16 | control(CONSOLE, TTY_CTRL_SET_IFLAG, TTY_ECHO, 0); 17 | fprintf(CONSOLE, "? "); 18 | 19 | c = getchar(); 20 | while (('\n' != c) && ('\r' != c) && (!iseof(c))) 21 | { 22 | if (('0' <= c) && ('9' >= c)) 23 | { 24 | i = i * 10 + c - '0'; 25 | } 26 | 27 | c = getchar(); 28 | } 29 | 30 | if (EOF == c) 31 | return c; 32 | 33 | return i; 34 | } 35 | 36 | xinu_syscall printnum (int i) 37 | { 38 | return fprintf(CONSOLE, "%d\n", i); 39 | } 40 | -------------------------------------------------------------------------------- /system/userret.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file userret.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | 9 | /** 10 | * @ingroup threads 11 | * 12 | * Entered when a thread exits by return. 13 | */ 14 | void userret(void) 15 | { 16 | kill(gettid()); 17 | } 18 | -------------------------------------------------------------------------------- /system/wakeup.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wakeup.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009, 2018. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #if RTCLOCK == TRUE 13 | 14 | /** 15 | * @ingroup threads 16 | * 17 | * Wakeup and ready all threads that have no more time to sleep 18 | */ 19 | void wakeup (void) 20 | { 21 | while (nonempty(sleepq) && (firstkey(sleepq) <= 0)) 22 | { 23 | ready(dequeue(sleepq)); 24 | } 25 | 26 | resched(); 27 | } 28 | 29 | #endif /* RTCLOCK */ 30 | -------------------------------------------------------------------------------- /system/xdone.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file xdone.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | extern void halt(void); 11 | 12 | /** 13 | * @ingroup misc 14 | * 15 | * Print system completion message as last thread exits. 16 | */ 17 | void xdone(void) 18 | { 19 | kprintf("\r\n\r\nAll user processes have completed.\r\n\r\n"); 20 | #ifdef GPIO_BASE 21 | gpioLEDOff(GPIO_LED_CISCOWHT); 22 | #endif /* GPIO_BASE */ 23 | disable(); 24 | halt(); 25 | } 26 | -------------------------------------------------------------------------------- /system/yield.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file yield.c 3 | * 4 | */ 5 | /* Embedded Xinu, Copyright (C) 2009. All rights reserved. */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | * @ingroup threads 12 | * 13 | * Yield processor. 14 | * @return OK when the thread is context switched back 15 | */ 16 | xinu_syscall yield (void) 17 | { 18 | resched(); 19 | return OK; 20 | } 21 | -------------------------------------------------------------------------------- /test/Makerules: -------------------------------------------------------------------------------- 1 | # This Makefile contains rules to build files in the test/ directory. 2 | 3 | # Name of this component (the directory this file is stored in) 4 | COMP = test 5 | 6 | # Source files for this component 7 | C_FILES = testhelper.c test_arp.c test_mailbox.c test_semaphore3.c test_bigargs.c test_memory.c test_semaphore4.c test_bufpool.c test_messagePass.c test_semaphore.c test_deltaQueue.c test_netaddr.c test_snoop.c test_ether.c test_netif.c test_ethloop.c test_nvram.c test_system.c test_ip.c test_preempt.c test_tlb.c test_libCtype.c test_procQueue.c test_ttydriver.c test_libLimits.c test_raw.c test_udp.c test_libStdio.c test_recursion.c test_umemory.c test_libStdlib.c test_schedule.c test_libString.c test_semaphore2.c 8 | 9 | 10 | S_FILES = 11 | 12 | # Add the files to the compile source path 13 | DIR = ${TOPDIR}/${COMP} 14 | COMP_SRC += ${S_FILES:%=${DIR}/%} ${C_FILES:%=${DIR}/%} 15 | -------------------------------------------------------------------------------- /test/test_preempt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | thread spin(void) 8 | { 9 | volatile int n = 1; 10 | 11 | while (n != 0) 12 | { 13 | } 14 | 15 | return OK; 16 | } 17 | 18 | thread test_preempt(bool verbose) 19 | { 20 | /* the failif macro depends on 'passed' and 'verbose' vars */ 21 | bool passed = TRUE; 22 | tid_typ thrspin; 23 | 24 | /* This is the first "subtest" of this suite */ 25 | thrspin = 26 | create(spin, INITSTK, thrtab[thrcurrent].prio, "test_spin", 0); 27 | 28 | /* Make spin ... spin */ 29 | ready(thrspin); 30 | resched(); 31 | /* If this next line runs, we're good */ 32 | kill(thrspin); 33 | 34 | /* always print out the overall tests status */ 35 | if (passed) 36 | { 37 | testPass(TRUE, ""); 38 | } 39 | else 40 | { 41 | testFail(TRUE, ""); 42 | } 43 | 44 | return OK; 45 | } 46 | -------------------------------------------------------------------------------- /test/test_stub.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /** 6 | * Example of a test program for the Xinu testsuite. Beyond this file you 7 | * must add an entry to the testtab in testhelper.c and a prototype in 8 | * testsuite.h. 9 | */ 10 | thread test_stub(bool verbose) 11 | { 12 | /* the failif macro depends on 'passed' and 'verbose' vars */ 13 | bool passed = TRUE; 14 | 15 | /* This is the first "subtest" of this suite */ 16 | testPrint(verbose, "subtest one"); 17 | test = ionull(); 18 | failif((test != OK), "ionull not OK"); 19 | 20 | /* This is the second "subtest" of this suite */ 21 | testPrint(verbose, "subtest two"); 22 | value = ioerr(); 23 | failif((value != SYSERR), "ioerr not SYSERR"); 24 | 25 | /* always print out the overall tests status */ 26 | if (passed) 27 | { 28 | testPass(TRUE, ""); 29 | } 30 | else 31 | { 32 | testFail(TRUE, ""); 33 | } 34 | 35 | return OK; 36 | } 37 | --------------------------------------------------------------------------------