Commit graph

50 commits

Author SHA1 Message Date
cinap_lenrek 8b817fd6c0 pc/devarch: use m->cpumhz instead of recalculatin it 2021-02-20 13:08:59 +01:00
cinap_lenrek a05bab362f pc, pc64: add minimal HPET driver to measure LAPIC and TSC frequencies
This adds the new function pointer PCArch.clockinit(),
which is a timer dependent initialization routine.
It also takes over the job of guesscpuhz(). This way, the
architecture ident code can switch between different
timers (i8253, HPET and XEN timer).
2021-01-17 21:21:12 +01:00
cinap_lenrek 8efbd243e1 pc, pc64: cleanup cpuidentify() and some comments 2020-12-08 16:58:41 +01:00
cinap_lenrek b2ffb6ccc5 pc, pc64: add *nomtrr= kernel parameter 2020-12-08 16:34:36 +01:00
Sigrid 66b6185845 amd64, vmx: support avx/avx2 for host/guest; use *noavx= in plan9.ini to disable 2020-12-06 18:48:32 +01:00
cinap_lenrek 1d93a5628a pc, pc64, xen: rewrite interrupt handling code
This implements proper intrdisable() support for all
interrupt controllers.

For enable, (*arch->intrassign)(Vctl*) fills in the
Vctl.enable and Vctl.disable pointers with the
appropriate routines and returns the assigned
vector number.

Once the Vctl struct has been linked to its vector
chain, Vctl.enable(Vctl*, shared) gets called with a
flag if the vector has been already enabled (shared).

This order is important here as enabling the interrupt
on the controller before we have linked the chain can
cause spurious interrupts, expecially on mp system
where the interrupt can target a different cpu than
the caller of intrenable().

The intrdisable() case is the other way around.
We first disable the interrupt on the controller
and after that unlink the Vctl from the chain.
On a multiprocessor, the xfree() of the Vctl struct
is delayed to avoid freeing it while it is still
in use by another cpu.

The xen port now also uses pc/irq.c which has been
made generic enougth to handle xen's irq scheme.
Also, archgeneric is now a separate file to avoid
pulling in dependencies from the 8259 interrupt
controller code.
2020-11-29 17:43:22 +01:00
cinap_lenrek 0ba91ae22a pc, pc64: allocate i/o port space for unassigned pci bars, move ioalloc() to port/iomap.c
With some newer UEFI firmware, not all pci bars get
programmed and we have to assign them ourselfs.

This was already done for memory bars. This change
adds the same for i/o port space, by providing a
ioreservewin() function which can be used to allocate
port space within the parent pci-pci bridge window.

Also, the pci code now allocates the pci config
space i/o ports 0xCF8/0xCFC so userspace needs to
use devpnp to access pci config space now. (see
latest realemu change).

Also, this moves the ioalloc()/iofree() code out
of devarch into port/iomap.c as it can be shared
with the ppc mtx kernel.
2020-11-03 20:46:09 +01:00
cinap_lenrek 4f85115526 kernel: massive pci code rewrite
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-09-13 20:33:17 +02:00
cinap_lenrek 93f6ce24f4 pc, pc64: use 64-bit physical addresses for ISAConf.port 2020-06-06 14:52:16 +02:00
cinap_lenrek 30bf1c45ca pc, xen: make PAT support optional (for xen) 2020-05-31 14:32:19 +02:00
cinap_lenrek b86bb35c7d pc, pc64: do page attribute table (PAT) init early in cpuidentify()
the page attribute table was initialized in mmuinit(), which is
too late for bootscreen(). So now we check for PAT support and
insert the write-combine entry early in cpuidentify().

this might have been the cause of some slow EFI framebuffers on
machines with overlapping or insufficient MTRR entries.
2020-05-22 23:58:24 +02:00
cinap_lenrek 1e773c97e7 pc64: implement NX bit discovery, map kernel mappings no-execute 2019-08-27 03:55:12 +02:00
mischief 79e24f5ee5 pc: devarch: recognize AMD Ryzen model 2019-04-13 23:08:26 -07:00
cinap_lenrek b591ee195b devarch: reading msr 0xffffffff 2018-09-09 01:53:53 +02:00
cinap_lenrek ba7b07d51a devarch: restrict i/o port access to 64K, disallow msr 32-bit wrap arround (thanks aiju) 2018-09-09 01:41:35 +02:00
cinap_lenrek 97a2e35a0c devarch: fix /dev/msr (thanks joe9, aiju)
the end condition port < offset+n could never become
false when offset truncated to 32 bit signed port is
negative. change the condition variables to unsigned
int.

msr's are not byte addressible, so advance reads by
one instead of 8.
2018-09-08 22:24:36 +02:00
aiju 6b0de3de8e pc: fix ugly and partially broken switch() statement 2018-07-11 15:12:24 +01:00
aiju 3a77c01f43 pc kernel: get rid of ugly and partially broken cpuid macros 2018-07-11 14:50:22 +01:00
cinap_lenrek 330e7ef39b kernel: don't tokenize inplace in isaconfig() to make /dev/reboot work 2017-09-27 13:59:55 +02:00
aiju 773be02aa1 kernel: add support for hardware watchpoints 2017-06-12 19:03:07 +00:00
mischief 319a9cc905 pc, pc64: bump Qmax in devarch
my x301 and t420 run out of archfiles with *acpi= while trying to add
hdacmd from audiohda.
2017-03-01 02:43:14 -08:00
cinap_lenrek 9278b94623 pc/pc64: get rid of timerset(0) case, was used with "i8253set off" ctl 2017-01-22 21:12:38 +01:00
cinap_lenrek 0a5f81a442 kernel: switch to fast portable chacha based seed-once random number generator 2016-08-27 20:42:31 +02:00
cinap_lenrek 63f9a4fda3 pc/pc64: bring up ap's one after another, use idlehands() while waiting for thunderbirdsarego
when testing in qemu, launching each ap became slower and slower
because all the ap's where spinning in syncclock() waiting for
cpu0 to update its mach0->tscticks, which happens only much later
after all cpu's have been started up.

now we wait for each cpu to do its timer callibration and
manually update our tscticks while we wait and each cpu will
not spin but halt while waiting for active.thunderbirdsarego.
this reduces the system load and noise for timer callibration
and makes the mp startup linear with regard to the number of
cores.
2016-01-11 06:47:52 +01:00
cinap_lenrek 0bdfa3699d pc: check Sse (bit 25) in cpuiddx before enabling fxsr in cr4 (fixes crash on the pentium II) 2015-07-16 08:51:06 +02:00
cinap_lenrek f4c6dad8e1 pc, pc64: include PCArch.id in #P/archctl simplify #P/ioalloc read handler 2014-12-22 09:33:35 +01:00
cinap_lenrek 7523131e78 pc, pc64: untangle acpireset() from mpshutdown()
mpshutdown() used to call acpireset() making it impossible to build
a kernel without archacpi. now, mpshutdown() is a helper function
that only shuts down the application processors that gets used from
mpreset() and acpireset().

the generic machine reset code in exported by devarch's archreset()
function that is called by mpreset() and from acpireset() as a fallback.
so the code duplication that was in mpshutdown() is avoided.
2014-12-19 23:34:43 +01:00
cinap_lenrek 476a47b15c pc, pc64: cleanup devarch
- shorten cpuidprnt so it doesnt have to break line
- addarchfile: complain when running out of entries
- fix range check in rmemrw() (harmless)
- use nil instead of 0 for pointers
2014-12-17 22:49:51 +01:00
cinap_lenrek 25a9cc3adb pc, pc64: untangle embedded controller (ec) dependency from devarch 2014-12-13 06:23:23 +01:00
cinap_lenrek bcb67353c1 pc, pc64: provide access to embedded controller with #P/ec file 2014-11-10 00:04:37 +01:00
cinap_lenrek e81e1a4aed pc, pc64: make mtrr() callable from interrupt context and before mpinit
to make it possible to mark the bootscreen framebuffer
as write combining in early initialization, mtrr() is
changed not not to error() but to return an error string.

as bootscreen() is used before multiprocessor initialization,
we have to synchronize the mtrr's for every processor as
it comes online. for this, a new mtrrsync() function is
provided that is called from cpuidentify() if mtrr support
is indicated.

the boot processor runs mtrrsync() which snarfs the
registers. later, mtrrsync() is run again from the
application processors which apply the values from the
boot processor.

checkmtrr() from mp.c was removed as its task is also
done by mtrrsync() now.
2014-10-21 06:03:03 +02:00
cinap_lenrek 3a6a754051 pc, pc64: initial machine check architecture support 2014-07-09 22:45:51 +02:00
cinap_lenrek 3dc82dc04b pc64: fix ulongs for address of devarchs realmodemem file 2014-05-26 00:45:10 +02:00
cinap_lenrek a9155014c0 pc, pc64: handle sse simd exceptions 2014-05-11 05:59:10 +02:00
cinap_lenrek 6a55790197 pc/pc64: move common code to pc/devarch.c 2014-02-03 06:24:31 +01:00
cinap_lenrek 28ad4e6616 pc kernel: split mpstartap() and squidboy into separate file... stuff for amd64 2014-02-01 10:23:17 +01:00
jpathy 81b7451972 sse kernel support (sources) 2013-05-22 23:47:05 +05:30
cinap_lenrek 9e7ecc41d5 devproc buffer overflow, strncpy
in devproc status read handler the p->status, p->text and p->user
could overflow the local statbuf buffer as they where copied into
it with code like: memmove(statbuf+someoff, p->text, strlen(p->text)).
now using readstr() which will truncate if the string is too long.

make strncpy() usage consistent, make sure results are always null
terminated.
2012-10-01 02:52:05 +02:00
cinap_lenrek e91301a401 rdmsr/wrmsr become tryrdmsr/trywrmsr, we can should check for trap 2012-08-31 16:48:33 +02:00
cinap_lenrek 7fdf820589 pckernel: use constants instead of hardcoding cpuid bits in various places 2012-08-17 04:03:51 +02:00
cinap_lenrek aa015b1c4f kernel: use monitor/mwait instruction on pc multiprocessor for idlehands 2012-05-04 11:02:11 +02:00
cinap_lenrek 656762ae98 cardbus io reservation 2012-05-01 03:35:15 +02:00
cinap_lenrek bf3476d661 kernel: fix inproper use of malloc/smalloc 2011-12-12 16:55:26 +01:00
cinap_lenrek 563437cb6d remove realmode and e820 code from kernel 2011-11-05 06:19:52 +01:00
aiju 03d71535ec reading from/writing to non-existant MSRs via /dev/msr no longer crashes the system 2011-07-19 15:42:00 +02:00
aiju 4d4fc2ca34 moved /dev/mordor to devcons 2011-04-16 14:15:01 +02:00
aiju 6ca93675ed added /dev/mordor 2011-04-15 21:47:11 +02:00
aiju 68d6b0808b added geode driver 2011-04-15 20:29:46 +02:00
Taru Karttunen a9060cc06b Import sources from 2011-03-30 iso image - lib 2011-03-30 19:35:09 +03:00
Taru Karttunen e5888a1ffd Import sources from 2011-03-30 iso image 2011-03-30 15:46:40 +03:00