Commit Graph

103 Commits (master)

Author SHA1 Message Date
cinap_lenrek b7e67e9e36 kernel: page counts a ulong, not usize 2021-07-25 14:03:12 +00:00
cinap_lenrek c0d4498ab8 kernel: clean up Mach structure
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-04-25 17:41:34 +02:00
cinap_lenrek 9f54c28317 bcm: try ATAGS/DTB pointer from R2 on entry 2021-04-25 17:36:11 +02:00
cinap_lenrek be782ef435 bcm: change color chan to RGB24 (thanks p.kosyh)
p.kosyh writes:

Hello!  I finally bought rpi4 4Gb specially for 9front. It seems,
that default bpp of framebuffer is 16.  I changed it to 24 (via
cmdline.txt and config.txt) and found, that rendering is much faster!
(May be due removing overheads in 16->24 conversions?)

But on rpi4 r and b channels are swapped.  So, i changed BGR24 to
RGB24 in bcm/screen.c and now it works fine!
2021-02-28 13:31:49 +01:00
cinap_lenrek efcfdd23d7 bcm64: get inbound and outbound pci window base address from device tree
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).
2021-02-06 13:47:45 +01:00
cinap_lenrek 29f60cace1 kernel: avoid palloc lock during mmurelease()
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-22 16:29:55 +01:00
cinap_lenrek 932995bb27 kernel: update procsave() comment, we'r not holding up->rlock anymore 2020-12-21 14:41:10 +01:00
cinap_lenrek e4ce6aadac kernel: handle tos and per process pcycle counters in port/
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-12-20 22:34:41 +01:00
cinap_lenrek bd23963c8f bcm64: fix usb xhci controller on pi4 8GB variant (thanks richard miller)
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-07-02 21:04:01 +02:00
cinap_lenrek 759656ad4c bcm, bcm64: dancing to the drum of the linux clowns for device tree memory size detection (thanks kenji)
looks like linux changed the device tree names for
the memory node:

4b17654f51 (diff-ac03c9402b807c11d42edc9e8d03dfc7)

this fixes the memory size detection with latest firmware
on raspberry pi4-b (4GB) for kenji.
2020-04-22 19:57:25 +02:00
cinap_lenrek 1fe3143e4c kernel: cleanup the software mouse cursor mess
The swcursor used a 32x32 image for saving/restoring
screen contents for no reason.

Add a doflush argument to swcursorhide(), so that
disabling software cursor with a double buffered
softscreen is properly hidden. The doflush parameter
should be set to 0 in all other cases as swcursordraw()
will flushes both (current and previours) locations.

Make sure swcursorinit() and swcursorhide() clear the
visibility flag, even when gscreen is nil.

Remove the cursor locking and just do everything within
the drawlock. All cursor functions such as curson(),
cursoff() and setcursor() will be called drawlock
locked. This also means &cursor can be read.

Fix devmouse cursor reads and writes. We now have the
global cursor variable that is only modified under
the drawlock. So copy under drawlock.

Move the pc software cursor implementation into vgasoft
driver, so screen.c does not need to handle it as
a special case.

Remove unused functions such as drawhasclients().
2020-04-10 17:12:51 +02:00
cinap_lenrek 30cbaa5c48 kernel: remove scheddump() comment for delay() in */fns.h 2020-04-04 16:50:37 +02:00
Roberto E. Vargas Caballero 5f7a6b7ea3 bcm: change ARGB32 to XRGB32 for framebuffer to avoid slow drawing 2020-02-09 21:39:17 +01:00
cinap_lenrek 77a7e3f8fc kernel: cleanup makefile for $CONF.$O target 2020-02-02 20:46:58 +01:00
cinap_lenrek 8d51e7fa1a kernel: implement portable userinit() and simplify process creation
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.
2020-01-26 19:01:36 +01:00
cinap_lenrek f48f1a324a bcm: use extended small pages so XN bit can work
the change to support no-execute bits broke the original
raspberry pi1, as it uses backwards compatible page table
format.

to use the XN bit, subpage AP bits have to be disabled
using the XP bit in CP15 Control Register c1 Bit 23.
2019-12-04 22:02:51 +01:00
cinap_lenrek 82d04a4e63 bcm: fix software cursor avoidance for loadimage() case (thanks bitmapper) 2019-10-27 23:51:11 +01:00
cinap_lenrek 2149600d12 kernel: catch execution read fault on SG_NOEXEC segment
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-27 03:47:18 +02:00
cinap_lenrek 128ea44a89 kernel: expose no execute bit to portable mmu code as SG_NOEXEC / PTENOEXEC, 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-26 22:34:38 +02:00
cinap_lenrek 51cfe763a4 emmc: 50MHz highspeed support (from richard miller) 2019-08-25 20:02:53 +02:00
cinap_lenrek bcf988aff1 bcm64: deal with discontinuous memory regions, avoid virtual memory 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-23 21:39:20 +02:00
cinap_lenrek e6d22570a8 bcm: invalidate cache on Fbinfo after firmware completion 2019-08-22 02:54:06 +02:00
cinap_lenrek aca0293f0b bcm: flush out early boot messages on uart and screen initialization
make early boot messages available by writing out
kmesg.buf after uart and screen initialization.
2019-08-22 02:52:21 +02:00
cinap_lenrek b4cb19235e bcm: set XN bits for kernel device mappings 2019-08-21 18:28:01 +02:00
cinap_lenrek 3fc8d1bdae bcm64: add driver for emmc2 controller 2019-08-18 18:50:24 +02:00
cinap_lenrek bc8c31dbd5 bcm: fix typo in gpio.c on unused AFedge0 constant 2019-08-16 19:35:46 +02:00
cinap_lenrek 05f9a66fd4 bcm, bcm64: add vcore support for raspberry pi 3 GPIO expander 2019-07-28 11:39:57 +02:00
cinap_lenrek 8630bd35a6 bcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup
according to the following linux change, BCM2711 uses a different
method for changing pullup/down mode:

abcfd09286 (diff-cf078559c38543ac72c5db99323e236d)

gpiomeminit() was broken, using virtual address for the gpio physseg
instead of the physical one.

cleanup the code, avoid repetition by declaring static u32int *regs
variable. make local variable names consistent.
2019-07-27 20:00:53 +02:00
cinap_lenrek 1717368f64 bcm, bcm64: clean dma destination buffer before issuing dma in case of non cache-line-size aligned buffer 2019-07-25 13:55:17 +02:00
cinap_lenrek 811b80cae1 bcm, bcm64: make irq.$O optional and add intrdisable(), use intrenable()
the raspberry pi 4 has a new interrupt controller and
pci support, so get rid of intrenable() macro and
properly make intrenable function with tbdf argument.
2019-07-25 08:58:58 +02:00
cinap_lenrek 5a0c2e2d17 bcm, bcm64: add dmaflush() function and make virtio size and virtual address configurable in Soc.virtio and Soc.iosize 2019-07-25 08:41:37 +02:00
cinap_lenrek 4983adfa2c bcm, bcm64: add support for device tree parameter passing
the new raspberry pi 4 firmware for arm64 seems to have
broken atag support. so we now parse the device tree
structure to get the bootargs and memory configuration.
2019-07-25 08:19:12 +02:00
cinap_lenrek 4d96bacd35 bcm, kw, omap, teg2: implement setregisters() 2019-06-20 13:17:36 +02:00
cinap_lenrek c881e33e8e bcm, bcm64: fix cache operations for dma and emmc
always clean AND invalidate caches before dma read,
never just invalidate as the buffer might not be
aligned to cache lines...

we have to invalidate caches again *AFTER* the dma
read has completed. the processor can bring in data
speculatively into the cache while the dma in in
flight.
2019-05-19 16:54:50 +02:00
cinap_lenrek adf96a529e bcm: add cache invalidate before accessing prop buffer 2019-05-13 19:21:14 +02:00
cinap_lenrek 3b36daa2bb bcm, bcm64: preserve memsize across reboots, avoid trashing atags while parsing cmdline
we override atag memory on reboot, so preserve
the memsize learned from atag as *maxmem plan9
variable. the global memsize variable is not
needed anymore.

avoid trashing the following atag when zero
terminating the cmdline string.

zero memory after plan9.ini variables.
2019-05-13 19:12:41 +02:00
cinap_lenrek 75d44bc306 bcm: make sure fiq is on enabled on cpu0 2019-05-05 14:04:27 +02:00
cinap_lenrek 4d96c40a47 usbdwc: enable Slowbuilkin workarround, improve split transaction timing, handle erroring sleep(), debugging
i'v been seeing the error condition described above in the
Slowbulkin comment. so i'm enabling the work arround which
seems to fix the lockup.

in the split transaction case where we want to start the
transaction at frame start, acquire the ctlr lock *before*
checking if we are in the right frame number. so the start
will happen atomically. checking the software ctlr->sofchan
instead of checking the interrupt mask register seems to
be quicker.

setting the haint mask bit for the chan under ctlr lock
in chanio() instead of chanwait() avoids needing to acquire
the ctlr lock twice.

mask wakechan bits with busychan bitmap in interrupt handlers
so we will not try to wake up released chans by accident.

sleep() and tsleep() might get interrupted so we have to
release the split qlock in the split transaction case and
in all cases, make sure to halt the channel before release.

add some common debug functions to dump channel and controller
registers.
2019-05-05 13:34:02 +02:00
cinap_lenrek 1a7c224b3e bcm: don't call nil on PADDR() in dmaaddr(), return busdram dummy address 2019-05-03 22:53:09 +02:00
cinap_lenrek eb4bd4aa3e bcm: move fiq saved pc adjust into lexception.s so it can be shared with arm64 2019-05-03 22:02:07 +02:00
cinap_lenrek 3ca395a36c uartpl011: dont touch line control while uart is enabled 2019-05-03 21:34:20 +02:00
cinap_lenrek 810aed76a5 bcm: move CONFADDR parsing into bootargs.c, simplify initcode start() args handling 2019-04-11 19:10:47 +02:00
cinap_lenrek 6aff58df75 bcm: don't use PADDR() to convert bus address to physical in vcore 2019-04-11 17:12:20 +02:00
cinap_lenrek 9ae99fb5ad kernel: get rid of KSTKSIZE alias for KSTACK 2019-04-11 14:05:23 +02:00
cinap_lenrek 37d36fdd7f kernel: get rid of PTR2UINT() and UINT2PTR() macros 2019-04-11 13:51:38 +02:00
cinap_lenrek 753fa51b77 bcm: dont assume PHYSDRAM 0 in dmaaddr(), fix dmaioaddr() 2019-04-11 13:49:41 +02:00
cinap_lenrek 6a3a3d69c6 bcm: add pl011 uart driver
the raspi has two uarts, the pl011 and the mini. only one
can be used at a time due to pin muxing. the bcm kernel
uses the mini by default.
2019-04-11 13:21:06 +02:00
cinap_lenrek fe34e52d19 bcm: move okay() from uartmini.c to devarch.c 2019-04-10 15:06:56 +02:00
cinap_lenrek f00aa6b92a bcm: add irq.c to mkfile 2019-04-10 15:06:24 +02:00
cinap_lenrek 55a3964517 bcm: move interrupt handling out of trap.c into irq.c 2019-04-10 15:04:59 +02:00