Sakura-IT / SonnetAmiga

Reimplementation of WarpOS supporting Sonnet Crescendo 7200 and other PowerPC PCI cards (mirror of CVS development repository).
MIT License
39 stars 3 forks source link

Translate most/all parts of the library to C code #48

Closed DvdBoon closed 9 months ago

DvdBoon commented 5 years ago

I have started to remake the library into C for easy of maintenance and as a learning project.

Current concerns:

1) Uses Elbox NDK 2) Library copies itself to other part in RAM (PC relative/Reloc in C?) 3) PPC functions are currently in some PowerOpen ABI which does not seem the same to the VBCC output (StormASM uses r13 as a user stack pointer and vbcc uses r1 for everything. 4) The PPC does not interrupt tasks that are currently inside list functions (due to missing Enable()/Disable() functions in WarpOS). Not sure how to implement this in C, Now a check is done on memory range. But functions within C can be rearranged by the linker.

rkujawa commented 5 years ago
  1. Is the whole NDK needed, or headers only? Header files are legally considered “public interfaces” and cannot be copyrighted. This was proved in courts multiple times. Elbox may not agree with this interpretation, so if you have any contact with them, it may be a better idea to ask for permission, for inclusion of required header files in the project. If they refuse, I can rewrite header files based on asm definitions that we currently use (we actually have all the necessary data for this purpose). I was never granted access to the NDK, so that could not be considered a breach of any legal agreement. The question is how much do you want to risk them cutting off contact.
  2. Is that a problem?
  3. I remember vbcc PowerPC backend has -poweropen switch but last time I tested, it didn't work right (don't remember the details). Only could try to asking Frank to fix it.
  4. I'm sure it would be reasonable to still include some very low level functions as assembly called from C. Maybe this is one of these cases?
rkujawa commented 5 years ago

Btw. do you need a separate repo for this?

DvdBoon commented 5 years ago

Regarding 2:

I have had some trouble to let vbcc output small code for 68k which means it is using reloc32 which means i cannot just move the code to another place. I am talking to Frank atm through EAB.

Come to think of it...I think I only need to move PPC code...

A separate Repo would be nice but I am nowhere near something workable yet. I am planning to do the 68k part first and then still link in the PPC asm stuff if possible, then do the ppc setup stuff and then the ppc functions. 68k is at 10-15% done or so.

DvdBoon commented 5 years ago

@rkujawa The header files are not downloadable, right? Like that the OS3 NDK is also 'hidden'?

rkujawa commented 5 years ago

The Elbox pci.library headers are not freely downloadable. Maybe it is worth trying to ask them for permission to include it in the project.

I am quite sure I remember someone already reverse engineered the headers in the past, though quick googling now does not bring up any results.

Maybe we could just rewrite pci_lib.fd into pci_lib.h and be done with this (dunno how much more is there in the NDK version).

DvdBoon commented 5 years ago

@rkujawa I have the NDK but I did not sign an NDA but lets no go there.

What I was saying is that we use the header files so it all compiles, but that ppl cannot access those header files from this git (so they are hidden from the user). You place the needed files together with the OS3 NDK. Is that an idea?

rkujawa commented 5 years ago

I see, that is an option, after all we do not expose these files to external world, they are only available to build system. That is fine with me.

DvdBoon commented 5 years ago

Currently, the 68k part is at 20%. Build system has been set up to currently use the ppc objects from SonnetAmiga. Will also be replaced later by c code.

68k code now sets up K1/M1 and jumps to ppc setup code from SonnetAmiga. Upon return the library exits gracefully.. All the early initialization stuff is ready (which mediator, which gfx card, which north bridge, error messages, resident structure) resulting in a library that can be opened correctly.

Currently missing are setting up the library base/functions, the functions themselves, system patches, interrupt code, supporting tasks.

Looks like concerns 2 and 4 are solved. Code is using small code/data models and stuff is copied using the seglist pointers.

MastaTabs commented 4 years ago

this sounds nice, should make it easier porting it to arm ;)

DvdBoon commented 4 years ago

@MastaTabs

See https://github.com/Sakura-IT/PowerPCAmiga for progress.

DvdBoon commented 9 months ago

Done