summaryrefslogtreecommitdiff
path: root/sys/src/9/port
AgeCommit message (Collapse)Author
2023-05-01usbxhci: add some robustness checkscinap_lenrek
Add some checks in the interrupt handler to ensure that the slot and ring referred to by the event have been initialized. Also add a check in ctlrcmd() just in case we mess up the recovery and someone issues a ctlrcmd() after a failed xhciinit().
2023-05-01usbxhci: fix command ring wrap crashcinap_lenrek
When a ring wraps around, we need to program a wrap around td with the base address. To get the base, we need to call Ctlr.dmaaddr() and we used the slot->ctlr pointer to get to it. But the command ring has no slot associated to it so we would crash as soon as we tried to submit more than 256 controller commands. The solution is to put a ctlr pointer into the Ring structure, which also allows us to simplify resetring() and waittd() as they now can get the controller implicitely thru the ring pointer.
2023-04-24portmkfile: cleanup dependencies for wifi.$O and etheriwl.$Ocinap_lenrek
2023-04-24sdnvme: remove unused mptr argument to qcmd()cinap_lenrek
2023-04-19imx8: make etheriwl work on MNT Reform, move it to port/ (thanks cinap); ↵Sigrid Solveig Haflínudóttir
tested with 6205
2023-04-08kernel: Clear secrets on rebootcinap_lenrek
The idea is that when we reboot, we zero out memory written by processes that have the private flag set (such as factotum and keyfs), and also clear the secrmem pool, which contains TLS keys and the state of the random number generator. This is so the newly booted kernel or firmware will not find these secret keys in memory.
2023-03-07sys/src/9/port/sysproc.c: add spim magicadventuresin9
2023-02-17devproc: Fix a double-free reading note file (thanks Josiah Frentsos)cinap_lenrek
Oversight, was using free() instead of freenote(), which handles the refcounting for gorup notes.
2023-01-15sdmmc: implement boot partition access for emmccinap_lenrek
We expose the boot partitions as separate units, such as sdM0 is the user data partition and sdM1 is the first boot partition and sdM2 is the second boot partition. On access, we automatically switch the BOOT_PARTITOIN_ACCESS bits in the EXT_CSD. Also, the units ctl file contains "boot enabled" or "boot disabled" if that unit is the active or inactive boot partition.
2023-01-15devsd: fix wrong range check for subunit numbercinap_lenrek
2023-01-06devdraw: coding style (from drawterm)cinap_lenrek
2023-01-05devusb: provide usb hub device number instead of address in /dev/usb/ctlcinap_lenrek
The hub address is only usefull for the host controller driver, while userspace really cares about the device number.
2023-01-01mouse: Make /dev/mousein readable to get mouse status without blockingcinap_lenrek
There is currently no way to get the current mouse position and button states without blocking.
2022-12-30sdmmc: switch argument must be integercinap_lenrek
2022-12-29sdmmc: actually implement mmc supportcinap_lenrek
- pass the correct ocr value for SEND_OP_COND (advertise Hcs and 3.3v) - disambiguate SEND_RELATIVE_ADDRESS/SET_RELATIVE_ADDRESS - detect the MMC version from CSD structure - detect the capacity according to spec for MMC - implement SWITCH command to set highspeed frequency and bus width - rename Ctlr to Card (thats really what we keep track of here)
2022-12-27sdmmc: new interface for SDiocinap_lenrek
We want to support the internal emmc device on the reform, which has a different initialization sequence from SDcard. The problem is, all mmc controller drivers where using the command index to derive the command properties. The command index's interpretation depends on the command set. And MMC has different commands then SD. Also, there are the APP_CMD escaped commands which drivers then tried to recover the state... All of this is total nonsense... The controller drivers should not care and the command properties should be maintained by port/sdmmc.c. So we pass the command as a struct SDiocmd, which has all the properties (command index, response type, data transfer mode... and even a string for debugging). The controller just converts this into register values and just executes the commands. Next, the controller drivers shouldnt snoop on the commands and then try to apply bus and frequency switching on their own. This is now made explicit by having SDio.bus(io, width, speed) function.
2022-12-25devsrv: Various fixes.cinap_lenrek
Make global variables static to avoid symbol clashes. Order Link fields more compactly for 64-bit archs. Add a common freelink() function for freeing Boards and Srvs. Chain all Boards in a circular doubly-linked list, so srvrename() can actually change the owners of *all* the boards instead of just the root. We cannot use recursion here as that could potentially blow the kernel stack. srvname() was also only processing the root. Instead, we add a srvname field to Chan and set it to the original path of the srv file that was used to post the channel. Call openmode() at the beginning of srvopen(). The reason is if omode has invalid bits it can error and leave stuff in a inconsistent state. Prevent srvwstat() to rename a file to "clone", it is reserved. Get rid of "lease expired" error message, just use Eshutdown.
2022-12-12bootrc: let /boot/boot run in a more natural namespacecinap_lenrek
Mount /fd, /proc, /srv and /shr in initcode and open /dev/cons instead of #c/cons. This way, /boot/boot could theoretically be a rc-script and there is less reliance on magic device characters.
2022-12-12devsrv: fix recusrion deadlock on removecinap_lenrek
Need to close the channel outside of srvlk, otherwise risk deadlock when recursing.
2022-12-11sdmmc: multiple controller supportcinap_lenrek
remove the global sdio struct and add a addmmcio() function for drivers to register their controllers. there is a SDio.aux pointer now where controller drivers can stash a pointer to their private data. SDio.init() also can signal that it wants to be called again for more controllers by returning > 0 (see pc/pmmc.c). this is in preparation for supporting the internal mmc device in the mnt-reform which is hooked up to usdhc1.
2022-12-04kernel: free exec temporary stack segment under seglockcinap_lenrek
On error, we must free the temporary stack segment while holding up->seglock.
2022-12-03usbxhci: cleanupcinap_lenrek
2022-12-03devbridge: simplify ethermultiwrite()cinap_lenrek
2022-12-03usbxhci: split usbxhci in portable and pci / soc specific driverscinap_lenrek
For the reform kernel, we used to have a slightly modified copy of port/usbxhci.c as the controller was implemented in soc specific registers and requires some rocket science initialization. Instead, we want to have a common generic xhci driver (usbxhci) and separate drivers that deal with the specific implementation such as usbxhcipci and usbxhciimx.
2022-12-03kernel: fix devsrv compilation on arm32Jacob Moody
2022-12-02kernel: private srv boardsJacob Moody
2022-11-12usbxhci: wait for reset to complete before continuing initializationMichael Forney
The xhci spec says that the HCRST bit is cleared once the reset is complete, and that no operational or runtime registers shall be written while the bit is set. Waiting for the reset to complete fixes initialization of some host controllers, such as the ASMedia ASM1142, which otherwise enter an endless init-recover loop. Also, add a comment about the reason for the 1ms delay. This appears to work around a system hang bug in intel chipsets through the 400 series (see errata 15 in [0]). [0] https://cdrdv2-public.intel.com/620856/620856-009.pdf
2022-10-23sdnvme: fix missing unlock() in submit queue full casecinap_lenrek
when we have more processors than submit queues, the submit queues are shared between some processors and hence we have to acquire its lock. in the case of the submit queue being full, we have to unlock it again before retrying otherwise we have a deadlock. sorry :(
2022-10-21kernel: fix freeb() for custom poolscinap_lenrek
Some ethernet drivers like ethervt6105M maintain a custom pool of Blocks using Block.free callback. To maintain that Block.list pointer is nil when reused, we have to clear it before returning it to the custom pool as the custom pool code is not aware of it. Also, poison Block.list pointer before free().
2022-09-259/port: revert timer wheel change, breaks pi4 boot, needs more time ↵cinap_lenrek
investigating
2022-09-25devpci: provide a #$ device for PCI config accesscinap_lenrek
We want to provide userspace PCI config space access on platforms that have PCI, but do not have ISA bus. For this, provide a stripped down version of devpnp, wiht only the pci support that can then be used by pi4 (bcm64) and reform (imx8) kernels.
2022-09-249/port: reimplement timers to use timer wheelOri Bernstein
when many processes go to sleep, our old timer would slow to a crawl; this new implementation does not.
2022-09-18sdnvme: avoid "empty if body" warningcinap_lenrek
dmaflush() is a no-op macro on amd64, so wrap all calls into {} braces to avoid the compiler warning.
2022-09-18usbxhci: eliminate "set but not used" warningcinap_lenrek
2022-09-17devip: do tcp mss clamping when forwarding packetscinap_lenrek
when forwarding packets (gating), unconditionally check tcp-syn packets for the mss-size option and reduce it to fit the mtu of the outgoing interface. this is done by exporting a new tcpmssclamp() function from ip/tcp.c that takes an ip packet and its buffer size and the effective mtu of the interface and adjusts the mss value of tcp syn options. this function is now also used by devbridge, enforcing a tcp mss below the tunnel mtu.
2022-09-03kernel: half NERR, refcount Note's to avoid excessive allocations for ↵cinap_lenrek
postnotepg() Half NERR stack to 32. When posing a note to a large group, avoid allocating Notes for each individual process, but post the reference instread. factor out process interruption into procinterrupt(). Avoid allocation of notes in alarmkproc, just posting the same note to everyone.
2022-08-26sdnvme: correct mode/serial/firmware string lengthsSigrid Solveig Haflínudóttir
2022-08-18devvga: fix race condition between writes to vgactlqwx
to reproduce: for(i in `{seq 10}) echo softscreen off >/dev/vgactl
2022-08-17kernel: allocate notes in heapcinap_lenrek
de-bloat the proc structure by allocating notes with on the heap instead of embedding them in the proc structure. This saves around 640 bytes per process.
2022-08-17kernel: simplify notify() adding common popnote() functioncinap_lenrek
Handlin notes is common for all architectures except how the note has to be pushed on the user stack. This change adds a popnote() function that returns only the note string or nil if the process should not be notified (no notes or user notes hold off). Popnote() also handles common errors like notify during note handling or missing note handler and will suicide the process in that case.
2022-08-15mkdevc: fix dtracy-disabled builds (thanks ori)Sigrid Solveig Haflínudóttir
2022-08-13dtracy: make timer probes run in interrupt contextOri Bernstein
When probing a timer, we were running in our own kproc, and not in an interrupt context, which meant that we didn't have any access to anything worth sampling, so we didn't give any data back. This moves the probe to the hzclock interrupt, and returns the pc in the probe.
2025-05-14kernel: get rid of Proc.kstackglenda
The kernel stack is now above the Proc structure, so the explicit kstack pointer can be eliminated.
2022-08-129: compute available kernel pages using sizeof(Proc*)Ori Bernstein
procs come from the dynamic pools, so we don't need to remove the memory used by possible procs from the total available.
2022-08-109/port: allow kiloprocs -- allocate procs lazilyOri Bernstein
Treallocate the small data structures around procs eagerly, but use malloc to allocate the large proc data structures when we need them, which allows us to scale to many more procs. There are still many scalability bottlenecks, so we only crank up the nproc limit by a little bit this time around, and crank it up more as we optimize more.
2022-08-09kernel: use 64 bits for mountidsglenda
We dont expose this anymore, wrapping these would be bad. Just send more bits.
2022-07-31usb: fix ehci isochronous "in" split transactionscinap_lenrek
For "in" transactions, the "Total Bytes to Transfer" field in the siTD is decremented by the controller by the actual transfer size, so what remains in the field is the residue number of bytes. Also, handle restart when we get a zero byte read on a isochronous "in" endpoint in devusb itself (removing the restart code for xhci drivers). This fixes audio recording with a usb1.1 audio device connected to ehci controller.
2022-07-30bind, mount: stop returning mount idOri Bernstein
The mount ID is a sequence number in a 32 bit integer, which means that it can't be unique. This is largely harmless, because there is no way to use the mount id, beyond checking if it's negative. However, there's no overflow check, so the mount ID can wrap negative, which will break error checks on mount calls. Because it's useless, let's just stop returning it.
2022-07-25sysproc: raise limit on #! lines, and allow quoted argsOri Bernstein
Our #! line length is very short, and the naïve quoting makes it difficult to pass more complicated arguments to the programs being run. This is fine for simple interpreters, but it's often useful to pass arguments to more complicated interpreters like auth/box or awk. This change raises the limit, but also switches to tokenizing via tokenize(2), rather than hand rolled whitespace splitting. The limits chosen are arbitrary, but they leave approximately 3 KiB of stack space on 386, and 13k on amd64. This is a lot of stack used, but it should leave enough for fairly deep devtab chan stacks.
2022-07-03imx8: pcie and nvme supportcinap_lenrek