summaryrefslogtreecommitdiff
path: root/sys/src/9/bcm64
AgeCommit message (Collapse)Author
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-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.
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-07-18kernel: consistently add devbridge and netdevmedium to kernel configscinap_lenrek
2022-01-16kernel: make Page.txtflush into an arraycinap_lenrek
To avoid a MAXMACH limit of 32 and make txtflush into an array for the bitmap. Provide portable macros for testing and clearing the bits: needtxtflush(), donetxtflush(). On pc/pc64, define inittxtflush()/settxtflush() as no-op macros, avoiding the storage overhead of the txtflush array alltogether.
2021-12-13devssl, cpu, import, oexportfs: deleteOri Bernstein
SSL is implemented by devssl. It's extremely obsolete by now, and is not used anywhere but cpu, import, and oexportfs. This change strips out the devssl bits, but does not (yet) remove the code from libsec.
2021-11-26kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TBcinap_lenrek
This makes vmap()/vunmap() take a vlong size argument, and change the type of Pci.mem[].size to vlong as well. Even if vmap() wont support large mappings, it is nice to get the original unruncated value for error checking. pc64 needs a bigger VMAP window, as system76 pangolin puts the framebuffer at a physical address > 512GB.
2021-11-07bcm64/sdhc: add *emmc2bus kernel parameter to set dma dram bus addresscinap_lenrek
On the raspberry pi 4, depending on the chip revision, the emmc2 controller has different dram bus address window, so make it configurable.
2021-10-11kernel: move waserror() macro to port/portfns.hcinap_lenrek
2021-07-25bcm64: make the kernel use virtual timer counter register for cycles()cinap_lenrek
2021-07-25kernel: page counts a ulong, not usizecinap_lenrek
2021-07-23arm64: use generic timer virtual counter for cycles()cinap_lenrek
We used to use performance cycle counter for cycles(), but it is kind of useless in userspace as each core has its own counter and hence not comparable between cores. Also, the cycle counter stops counting when the cores are idle. Most callers expect cycles() to return a high resolution timestamp instead, so do the best we can do here and enable the userspace generic timer virtual counter.
2021-04-25kernel: clean up Mach structurecinap_lenrek
Remove unused fields and factor common fields into a new PMach struct in port/portdat.h. The fields machno, splpc and proc are not moved to PMach as they are part of the known offsets from assembly (l.s).
2021-03-01devpccard, pci: fix pccard support and handle pci expansion romscinap_lenrek
let pci.c deal with the special cardbus controller bar0 and expansion roms. handle apic interrupt routing for devices behind a cardbus slot. do not free the pcidev on card removal, as the drivers most certanly are not prepared to handle this yet. instead, we provide a pcidevfree() function that just unlinks the device from pcilist and the parent bridge.
2021-02-06bcm64: get inbound and outbound pci window base address from device treecinap_lenrek
On the pi400, the xhci reset firmware mailbox request assumes that the pci windows match the ones specified in the device tree. The inbound window (pcidmawin) also varies now depending on the amount of memory installed. It is all pretty ridiculous, as the firmware could as well just read the pci controllers hardware register to determine the window configuration and the os could keep a nice simple 1:1 mapping (with pci dma addresses == physical addresses).
2020-12-22kernel: avoid palloc lock during mmurelease()cinap_lenrek
Previously, mmurelease() was always called with palloc spinlock held. This is unneccesary for some mmurelease() implementations as they wont release pages to the palloc pool. This change removes pagechainhead() and pagechaindone() and replaces them with just freepages() call, which aquires the palloc lock internally as needed. freepages() avoids holding the palloc lock while walking the linked list of pages, avoding some lock contention.
2020-12-20kernel: handle tos and per process pcycle counters in port/cinap_lenrek
we might as well handle the per process cycle counter in the portable part instead of duplicating the code in every arch and have inconsistent implementations. we now have a portable kenter() and kexit() function, that is ment to be used in trap/syscall from user, which updates the counters. some kernels missed initializing Mach.cyclefreq.
2020-11-21kernel: add portable pcimsienable()/pcimsidisable(), disable MSI/MSI-X on ↵cinap_lenrek
pcidisable()/pcireset() This avoids some duplication in the pci support code and allows pcireset() to diable MSI and MSI-X interrupts when disabling or reseting a device.
2020-09-13kernel: massive pci code rewritecinap_lenrek
The new pci code is moved to port/pci.[hc] and shared by all ports. Each port has its own PCI controller implementation, providing the pcicfgrw*() functions for low level pci config space access. The locking for pcicfgrw*() is now done by the caller (only port/pci.c). Device drivers now need to include "../port/pci.h" in addition to "io.h". The new code now checks bridge windows and membars, while enumerating the bus, giving the pc driver a chance to re-assign them. This is needed because some UEFI implementations fail to assign the bars for some devices, so we need to do it outselfs. (See pcireservemem()). While working on this, it was discovered that the pci code assimed the smallest I/O bar size is 16 (pcibarsize()), which is wrong. I/O bars can be as small as 4 bytes. Bit 1 in an I/O bar is also reserved and should be masked off, making the port mask: port = bar & ~3;
2020-07-03bcm64: increase maximum segment size to 8GBcinap_lenrek
make it possible for one process to use all of physical memory.
2020-07-02bcm64: handle 8GB of physical memory for raspberry pi4cinap_lenrek
widen and move the KMAP window to a new address so we can handle the 8GB of physical memory of the new raspberry pi4. the new memory map on pi4 uses the following 4 banks: 0x000000000 0x03e600000 0x040000000 0x0fc000000 <- soc.dramsize (only < 4GB) 0x100000000 0x180000000 0x180000000 0x200000000
2020-07-02bcm64: fix usb xhci controller on pi4 8GB variant (thanks richard miller)cinap_lenrek
On the 8GB variant of the raspberry pi 4, the eeprom chip for the xhci controller is missing and instead loaded from sdram (by the gpu firmware). for this, the gpu firmware needs to be notified of the xhci controllers pci bus address (after reset) that was assigned by our pci enumeration code.
2020-06-06bcm64: bring pci code in line with the pc/pc64cinap_lenrek
2020-06-06bcm64: use uvlong for ISAConf.portcinap_lenrek
2020-06-06bcm64: use 64-bit uvlong physical address in vmap()cinap_lenrek
2020-05-07bcm64: fix kernels cmpswap() functioncinap_lenrek
spectacular bug. cmpswap() had a sign extension bug using sign extending MOV to load the old compare value and LDXRW using zero extension while the CMP instruction compared 64 bit registers. this caused cmpswap with negative old value always to fail. interestingly, libc's version of this function was fine.
2020-02-02kernel: cleanup makefile for $CONF.$O targetcinap_lenrek
2020-01-26kernel: implement portable userinit() and simplify process creationcinap_lenrek
replace machine specific userinit() by a portable implemntation that uses kproc() to create the first process. the initcode text is mapped using kmap(), so there is no need for machine specific tmpmap() functions. initcode stack preparation should be done in init0() where the stack is mapped and can be accessed directly. replacing the machine specific userinit() allows some big simplifications as sysrfork() and kproc() are now the only callers of newproc() and we can avoid initializing fields that we know are being initialized by these callers. rename autogenerated init.h and reboot.h headers. the initcode[] and rebootcode[] blobs are now in *.i files and hex generation was moved to portmkfile. the machine specific mkfile only needs to specify how to build rebootcode.out and initcode.out.
2019-09-15bcm64: add addarchfile() prototype to fns.h (for qeed)cinap_lenrek
2019-09-14bcm64: enter page tables in mmutop *AFTER* switching asid in mmuswitch()cinap_lenrek
there was a small window between modifying mmutop and switching the asid where the core could bring in the new entries under the old asid into the tlb due to speculation / prefetching. this change moves the entering of the page tables into mmutop after setttbr() to prevent this scenario. due to us switching to the resereved asid 0 on procsave()->putasid(), the only asid that could have potentially been poisoned would be asid 0 which does not have any user mappings. so this did not show any noticable effect.
2019-09-02bcm64: enable devgpio in kernel configuration (thanks qeed)cinap_lenrek
2019-08-27kernel: catch execution read fault on SG_NOEXEC segmentcinap_lenrek
fault() now has an additional pc argument that is used to detect fault on a non-executable segment. that is, we check on read fault if the segment has the SG_NOEXEC attribute and the program counter is within faulting page.
2019-08-26kernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, ↵cinap_lenrek
add PTECACHED bits a portable SG_NOEXEC segment attribute was added to allow non-executable (physical) segments. which will set the PTENOEXEC bits for putmmu(). in the future, this can be used to make non-executable stack / bss segments. the SG_DEVICE attribute was added to distinguish between mmio regions and uncached memory. only matterns on arm64. on arm, theres the issue that PTEUNCACHED would have no bits set when using the hardware bit definitions. this is the reason bcm, kw, teg2 and omap kernels use arteficial PTE constants. on zynq, the XN bit was used as a hack to give PTEUNCACHED a non-zero value and when the bit is clear then cache attributes where added to the pte. to fix this, PTECACHED constant was added. the portable mmu code in fault.c will now explicitely set PTECACHED bits for cached memory and PTEUNCACHED for uncached memory. that way the hardware bit definitions can be used everywhere.
2019-08-25emmc: 50MHz highspeed support (from richard miller)cinap_lenrek
2019-08-25bcm64: replace emmc2 driver with richard millers sdhc drivercinap_lenrek
the new driver supports 50MHz highspeed bus mode and uses ADMA instead of SDMA.
2019-08-23bcm64: deal with discontinuous memory regions, avoid virtual memory ↵cinap_lenrek
aliasing, implement vmap() proper on the 2GB and 4GB raspberry pi 4 variants, there are two memory regions for ram: [0x00000000..0x3e600000) [0x40000000..0xfc000000) the framebuffer is somewhere at the end of the first GB of memory. to handle these, we append the region base and limit of the second region to *maxmem= like: *maxmem=0x3e600000 0x40000000 0xfc000000 the mmu code has been changed to have non-existing ram unmapped and mmukmap() now uses small 64K pages instead of 512GB pages to avoid aliasing (framebuffer). the VIRTPCI mapping has been removed as we now have a proper vmap() implementation which assigns vritual addresses automatically.
2019-08-19bcm64: do not use OTP_BOOTMODE_REG to determine OSC frequency (thanks ↵cinap_lenrek
richard miller) the register does not seem to be accessible on the Rpi 3b. so instead hardcode oscfreq in the Soc structure.
2019-08-18bcm64: add support for more than 1GB of ram (untested)cinap_lenrek
this adds a 4GB KMAP window into the kernel address space so we can access all physical ram on raspberry pi 4 for user pages. note that kernel memory above KZERO is still limited to 1GB because of DMA restrictions.
2019-08-18bcm64: add driver for emmc2 controllercinap_lenrek
2019-08-16bcm64: poll gisb arbiter for asynchronous bus errorscinap_lenrek
2019-08-16ethergenet: remove debuggingcinap_lenrek
the hangs where caused by missing NX bits on the mmio mappings, so the debug code is not needed anymore.
2019-08-16bcm64: set XN bits for kernel device mappingscinap_lenrek
2019-07-28bcm, bcm64: add vcore support for raspberry pi 3 GPIO expandercinap_lenrek
2019-07-27bcm64: fix wrong prescaler for generic timer on rpi4cinap_lenrek
the raspberry pi 4 uses 54 instead of 19.2 MHz crystal. detect which frequency is used by reading OTP bootmode register: https://www.raspberrypi.org/documentation/hardware/raspberrypi/otpbits.md Bit 1: sets the oscillator frequency to 19.2MHz
2019-07-25ethergenet: fix flow control negotiationcinap_lenrek
2019-07-25bcm64: add config for raspberry pi 4cinap_lenrek
2019-07-25bcm64: work in progress genet ethernet driver for raspberry pi 4cinap_lenrek