-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for GOARCH=mips64 #8
Conversation
Saving, restoring context and switching to the ISR goroutine (cpu0.gh) seems to work so far. Only syscalls and interrupts are handled so far. See TODOs for next steps.
The COMPARE register was only used because of a bug in MAME which doesn't exist anymore in newer versions. Moreover this implementation could result in a deadlock because the scheduler also sets this register.
Don't call the scheduler and enable exceptions in the user handler, it might call the scheduler.
This commit breaks external interrupt handling. Will be fixed in the next one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR7 "Fixes from n64 branch" can be probably removed because this one contains the
same fixes.
src/cmd/link/internal/ld/deadcode.go
Outdated
first, last = 1, 5 | ||
// runtime.unhandledExternalInterrupt is also a handler. | ||
// Must be called somewhere in the code, otherwise it | ||
// gets removed without error and relocs point to 0x0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you add the "runtime.unhandledExternalInterrupt" to the names here to avoid this "calling somewhere" need? Maybe it's not enough but it's definitely handled somehow for the two other architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it as you recommended. Not sure about the other GOARCHs. It's probably safe because it is called in externalInterruptHandler anyways, but while I was implementing this I ran into this error so I added the comment.
noosNumStackOrders = 3 | ||
noosHeapAddrBits = 23 // enough for 8 MiB K210 SRAM | ||
noosLogHeapArenaBytes = 17 // 128 KiB | ||
noosArenaBaseOffset = 0x0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does TLB is configured to start RAM at 0x0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I found bugs in
meminit
. -
I thought a bit the concept of the default timer and think that we should stay with stopped time until proper timer is initialized (see comments).
src/runtime/mem_noos.go
Outdated
// the non-DMA memory, properly align the arena | ||
arenaSize := freeSize - uintptr(pallocInFree) | ||
arenaSize &= ^(uintptr(heapArenaBytes) - 1) | ||
arenaStart := freeEnd - arenaSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look good to me.
You should probably start from: arenaStart = freeStart + pallocInFree
and next align the arenaStart
address up to uintptr(heapArenaBytes)-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have another look.
Before clearing the memory via uncached access, all cache must be invalidated before. Otherwise a cache writeback could happen after clearing the memory.
The implementation of softwareInterruptHandler can't support nesting, as it must call the scheduler.
Regarding the TODO comment: Yes, newwork is set by another CPU. Doesn't matter at the moment, since only one core is supported.
This allows other archs to implement these in Go instead of assembly.
I removed these commits from this branch. I think it's worth having the eventual merge only contain mips64 related changes. To get mips64 support on the same level as the other archs, support for setprivlevel syscall and noostest need to be added. Anything else that I missed? |
Hmm... I'm unsure. It will come out in the wash. Just merged this PR locally and want to test it against emulated linux/mips64. I did some research and it looks like there is no easy to find any big-endian MIPS64 Linux distro that may run on Qemu. I ended up building the
|
Some files in this PR have no standard Go copyright header. Please add it.
MMIO intrinsics came to my mind but they are just optimization. Should have their own PR. |
Go tests pass on linux/mips64. |
Follow up to #6
Changes since last push:
Tested with latest n64 module
(cd8534ed58561a61701f3305f5ea2644b795eb31)(c0dccb15ff67961f321c5ebeae119359c9e33521)