General Category > LisaList2

TCP for MacWorks

<< < (5/5)

D.Finni:

--- Quote from: stepleton on February 20, 2021, 09:13:42 pm ---
--- Quote from: D.Finni on February 20, 2021, 06:29:06 pm ---Good to know. Maybe we can figure out a protocol for transporting this metadata too. The Macintosh has MacBinary and BinHex formats.
--- End quote ---

For what it's worth (and for your consideration) there's been a single-file container format for a while :)

It's that tar-based format I mentioned just above. I call it a ".lar" file in the README for my file download program, and there are no prizes for guessing what the L stands for.
--- End quote ---
Unless anyone has any objections, I suppose this is the way to go. I certainly don't want to invent another format if there's already a good one around.



--- Quote from: rayarachelian on February 20, 2021, 09:01:19 pm ---Will dig again, the question isn't around calling conventions, that's easy enough to sort out. It's about mapping the routines in the LOS Manual to the exact A-Line routines, which are actually addresses in kernel-space, that's what that A-Line trampoline thing really is: a generic jump mechanism. ie. which A-Line is open, which is create, which is close, which is read, etc. And are those stable across LOS releases?

--- End quote ---
Ah, ok now I understand what you're after. The Lisa documentation is awfully tight-lipped about it, from my review of it last evening. I'm not totally sure that LOS uses A-line traps. I should admit that it's just my assumption based on so many similarities between Macintosh and Lisa architecture. On Macintosh, the trap dispatch table is located at $400 in RAM.

D.Finni:

--- Quote from: stepleton on February 20, 2021, 08:05:41 am ---The Lisa's format for text files is a little weird --- it's faintly block oriented (files are always sized in multiples of 1K, IIRC), and it uses run-length encoding for runs of spaces. I'm still trying to track down where I saw the format documented (the documentation calls it the "One World Text File Format" or something like that),

--- End quote ---

I attached that text file to this post.

rayarachelian:

--- Quote from: D.Finni on February 21, 2021, 10:06:29 am ---Ah, ok now I understand what you're after. The Lisa documentation is awfully tight-lipped about it, from my review of it last evening. I'm not totally sure that LOS uses A-line traps. I should admit that it's just my assumption based on so many similarities between Macintosh and Lisa architecture. On Macintosh, the trap dispatch table is located at $400 in RAM.

--- End quote ---

Yeah the LOS manual just shows you the pascal procedure names, so I'd need to compile code with the pascal compiler, even though I'm just after the assembly side of things, and then analyze the generated code and actual A-Line calls.

Yeah, they're not the same as in A-Line traps in Classic Mac OS (<10.0). On the Mac, the A-Line traps aren't addresses and they have fixed meanings. When you call a specific one in System 0.9, say A0000, it has the the same function as in System 6.0.8 and even in 7.5 or 9.2. And this is what allows for portable code.

In LOS, the A-Line trap is an address into the kernel code, and you can potentially pass anything there, even things that don't belong at all - hence, it's a supervisor trampoline. So it has the potential of changing between versions, further, it's undocumented.

For example, in Solaris 2.6 on SPARC, the open syscall is exactly the same trap as in Solaris 10 SPARC, so the ABI (Application Binary Interface) makes it 100% portable. (Linux on i386 didn't do this, and so you'd need a bevy of libc binaries to have backwards compatibility with previous releases, not sure about x86_64.)

Back to LOS, as long as you can figure out the address of your code in context 0 (and AFAIK context zero maps all RAM), your process can run in supervisor mode.

I suspect that if you're after this, you can ask the MMU mapping for your running segment by using something like this: (this is just a sample off the top of my head, not an actual tested implementation, probably is very wrong in some ways, but it's a skeleton)


--- Code: ---getsupervisor:
      LEA shellcode,A0
      MOVE.L A0,D0
      AND #00ffffff,D0
      MOVE.L D0,(saveaddress); save this address for later
      LSR D0,#17  ; d0 now has the segment number of the shellcode
      ; some call here to get mmu register for physical address
      MOVE.L (saveaddress),D0
      ADD A0,D0 ; assuming A0 contains the physical address offset of the segment, add our saved value to it
      AND.L #$00FFFFFF,D0
      ORI.L #$A00000,D0
      LEA trampoline
      MOVE.L D0,(trampoline)
      NOP ; insert some NOPs since we're doing self modifying code here and don't want whatever
      NOP ; pipeline cache our CPU may have from preventing this from working properly
      NOP
      NOP
trampoline: DB.L #$A0000000
      RTS
...
shellcode: evil code to "Same thing we do every night Pinky, try and take over the world!"
... and now we're in supervisor mode.
     RTE

--- End code ---

Some shifting, and then a read of the MMU register for your current code by calling the right call to give you back the physical address. (Basically shifting it by 9 would give you the segment number and to this you'd add the physical address, and then the offset you got from LEA PC+X,A0).

Then, since context zero (which runs as supervisor) has a very fixed, predictable memory map, you can calculate which address it would match there for your shellcode, and then invoke the A-Line trap for that address (with some self-modifying code to write that address in the A-Line opcode) and you've got supervisor access to the whole of LOS.

Also, on the Mac the A-Line traps are only 16 bits, where on the Lisa they're 32 bits because they're actually addresses (and the high by of 'A?' is a throwaway, so actually 24 bits of address range, but stored as 32 bits worth of opcodes).

D.Finni:
Beta testers are continuing to find new bugs. I think it's logical to hold off a native Lisa port until the code is debugged.

Navigation

[0] Message Index

[*] Previous page

Go to full version