22 November 2023, 00:14 | #1 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,647
|
Challenge: AmigaOS command to start executables.
This is the second step in my vision, if you don't see it please bare with me, if you do, try to support as free time allows.
Please see this thread, which was met with a mix of responses. Also please ignore that thread and all of AmigaOS history. Please accept for the moment that it's necessary now to create a very decent such command. It's not necessary for it to replace commands like run or execute. Spec: it should read a file with the e flag set, parse relevant hunks, use ROM routines to alloc and reloc them, and execute the code hunk, supporting Amiga hardware with ROM 1.3-3.1 as if the user typed the name of the executable file in CLI from boot with no S-S (not Shell or replacements at this time). Ideas are appreciated in any language, and the resulting binary will be a command (executable file) written in Assembly, and an open source, complying with CC0 1.0 or other suitable license fit for free distribution. Whatever you think of this vision, I personally offer it as a challenge and ask that if you don't see the reason, don't question it or discourage contributions with 'why' questions. Everyone already knows Amigas can execute files, you have missed the point. Last edited by Photon; 22 November 2023 at 00:43. |
22 November 2023, 09:26 | #2 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Let's say i have a program that just calls SystemTagList from dos.library. It will really do as if the user typed the name of the executable in cli (provided you tell me where to fetch the file name).
If we put aside the fact it's v36+, would it do what you want or not ? If not, what would be wrong then ? |
22 November 2023, 15:29 | #3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
Even under 1.3, the "Execute()" call of the dos.library exists and can do that. It should just have a ZERO input file handle, and the command name as first argument. The only drawback is that it needs the "Run" command to be present (in 1.2) or at least resident (with the 1.3 SetPatch active).
Side remark: It is quite funny that Execute() depends on Run in 1.3, but Run depends on System() (which is a cousin of Execute()) from 2.0 onwards. |
23 November 2023, 02:55 | #4 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,698
|
Quote:
|
|
23 November 2023, 07:46 | #5 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,340
|
can you use LoadSeg?
What about overlayed files? |
23 November 2023, 09:02 | #6 | |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
Quote:
According to your requirements, every AmigaDOS binary file should be loadable and executable, regardless of which operating system it was originally intended to be loaded and run on. This requirement includes the need to provide for a runtime environment, because just loading and relocating the code, then jumping to the first executable location in the file is not sufficient. The CLI commands of Kickstart 1.x require a specific, at the time (1985-1989) undocumented set of data structures and register configurations which, so it happens, also involved undocumented parts of the dos.library. Never mind them being undocumented at the time, those part of dos.library were deprecated and largely removed in Kickstart 2.x, thus rendering these old CLI commands prone to crash instead of exiting safely. So, in order to fulfill your requirements, there would have to be not just a reimplementation of the load file loader code (that's the easy part, but it's a bit tedious, to be honest) but also of the underpinnings of the environment in which the program would have to run according to the rules of dos.library in Kickstart 1.x. This is doable, too, but quite tedious, to be honest. The good news is that the Kickstart 1.x dos.library is, according to what I could find out, only about 17 KBytes in size and already contains a complete, working binary file loader (that supports overlays) with a documented API which could be tweaked to offer the functionality present in Kickstart 2.x but absent in Kickstart 1.x (you don't need all of what's in those 17 KBytes). Making this work according to your goals and requirements is doable and would not include any extra work to implement everything from scratch. Last edited by Olaf Barthel; 23 November 2023 at 09:10. |
|
23 November 2023, 23:48 | #7 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
Quote:
The other way around is course even harder: Making 2.x commands workable under 1.x as this requires more or less the entire system. |
|
23 November 2023, 23:52 | #8 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,064
|
I'm not sure preventing them from crashing due to incompatible OS calls etc is part of the challenge? I'm pretty sure the spec was "just start them running, what happens after that doesn't matter"
Edit: To be specific. |
24 November 2023, 00:31 | #9 | |||||
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,647
|
An executable file on AmigaOS is one that has its executable flag set and consists of hunks like other well-formed Amiga files.
The goal is to not require files from any WB disk or any existing WB installation, to run such a program that is well-formed. The challenge is met if an executable file formed by non-special hunks like code, data, and BSS, the code snippet allocates, relocates, and executes it as AmigaOS 1.3 and possibly up, would. If the machine running it has Execute in ROM, the goal is achieved. For the others we would have to do hunk parsing and LoadSeg, using what's left in ROM. I welcome your input let's quote everyone and clarify. Quote:
Quote:
Quote:
See above. Executable files can have different hunk types to these 3, but the 3 are enough to satisfy the challenge. Quirks such as BSS being automatically cleared or not have no bearing. Quote:
This project is important and also as far from "me" as you could possibly get. But as answer: no, this is not the goal. The solution should parse the hunks and start execution, if the file is well-formed, no questions asked. But the actual code executed would itself have to be compatible with whatever versions it wants to support. I.e. if the command allocates, relocates, and executes the file correctly, it is the same as for every such executable file for AmigaOS. The hunk contents (code or data structures) may have their own minimum spec and dependencies that are not at all present, and fail spectacularly or gracefully, and the goal is still met. I.e. just as a program made for AGA and 3.1 could be run by this command on OCS and 3.1, so it could with the Execute command, and neither command should be blamed for being run on a non-AGA machine. Quote:
If the code consists of 68k logic and usage of libraries and structures present in Kickstart 1.3-3.1, it's normal, system-friendly code that guidelines desire from any Amiga application. |
|||||
24 November 2023, 01:42 | #10 |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 587
|
I'm reminded of amitools here. Link to related code on Github, to be clear not saying it fits the requirements, just technically similar although it has a restrictive license.
|
24 November 2023, 08:35 | #11 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,351
|
Quote:
I mean, it could be specified as command line : Code:
runit someprogram Code:
echo "someprogram" >xx runit Code:
dc.b "someprogram",0 Quote:
Alternatively, you could just use the system() call from some C library. |
||
24 November 2023, 08:52 | #12 | |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
Quote:
The job you are asking for has been basically done and dusted in 1988 already, at least the really hard part. It can be found on the Amiga Developer CD 2.1 under "Reference/DevCon/Washington_1988/DevCon88.3/AutoBoot", the contents of which I am attaching below in a zip archive file. The relevant portion of this is the "loadseg.asm" file, which is designed to go into a mass storage disk controller (MFM/RLL/SCSI/IDE) boot ROM for the purpose of loading a file system from the Rigid Disk Block used by the autoboot feature introduced in Kickstart 1.3. If memory serves, the "loadseg.asm" code is what went into the A590 boot ROM and subsequently became the dos.library/LoadSeg implementation of dos.library V36-V40. This is the good stuff (but not necessarily the best stuff). If I remember correctly, "loadseg.asm" is preset to read the executable from a file on disk (it makes use of dos.library/Read), but this read function can be changed to retrieve this data from anywhere, e.g. from the file system block chain of the Rigid Disk Block. This code was released by Commodore for the purpose of developers to adopt and make use of it, because that whole loading, processing and relocating business is not for the faint of heart. The only thing it's missing is a cache flush operation on the 68020 and beyond, but I reckon that could be easily added with a minimum of fuss. Speaking of fuss, the support for the modern Kickstart 2.x hunk types would have to be added as well. But now I'm so demotivated I would gladly leave the challenge of making all of this work to much keener minds than mine. Last edited by Olaf Barthel; 24 November 2023 at 09:02. |
|
24 November 2023, 08:54 | #13 |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
That 'C' library likely calls either dos.library/Execute or dos.library/SystemTagList anyway. Not much to be gained here
|
24 November 2023, 08:55 | #14 | |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
Quote:
|
|
24 November 2023, 17:51 | #15 | ||||||||||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
Quote:
So please tell me - what is it that this is not the right soluion. Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Code:
Execute("C:List",0,Output()) Quote:
Quote:
Quote:
Your desired code is a one-liner (plus opening the dos.library), and I provided the solution above, so can we close this topic? |
||||||||||
24 November 2023, 18:33 | #16 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,050
|
Does that solution fully clear all BSS hunks, so that the exe behaves the same on all KS versions?
|
24 November 2023, 18:51 | #17 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
About which compatibility problem do we talk here? Is there a 1.3 program that has such a hunk where this causes trouble? Do you plan to run >2.x programs on 1.3? This won't work anyhow. Do you plan a bugfix for 1.3? That was done with 2.04 already.
IOWs, what kind of problem shall be solved here? Bugfixing 1.3? Done, it's an existing product. Loading 2.x programs? Won't work for reasons completely outside the loader. |
24 November 2023, 19:13 | #18 |
Registered User
Join Date: May 2023
Location: Norwich
Posts: 422
|
|
25 November 2023, 00:16 | #19 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
I am not 100% sure that I understand what you need, but here is a "system" command that I used to avoid having anything like c:run available (as stated in http://amigadev.elowar.com/read/ADCD.../node015E.html for 1.3)
It's a wrapper for "SYSTEM0 execute command from disk. From Sozobon C distribution. Copyright © 1988 by Ralph Babel." |
25 November 2023, 09:44 | #20 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,292
|
This is again something different. This assembler function overloads the currently running process with another segment and executes a loaded segment within the context of the current process. This is what the dos.library function RunCommand() does from 2.04 onwards.
Execute() does all that as well, though also creates a new shell, and performs the loading and execution within that new shell, i.e. a new process. Execute() thus has the full syntax of the shell available, including input/output redirection or alias substitution. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Execute() do not works under 1.3 | TCH | Coders. General | 14 | 22 November 2019 22:20 |
Execute file without using execute | VoltureX | support.Apps | 3 | 01 December 2011 09:59 |
I can't execute installer | paulo_becas | support.Apps | 5 | 01 March 2010 10:02 |
Execute a script | frikilokooo | project.ClassicWB | 6 | 20 November 2007 11:36 |
AmigaOne News: AmigaOS 4.0 Replacement CDs | Paul | News | 0 | 12 January 2005 12:17 |
|
|