A question about OPEN

Anything QL Software or Programming Related.
Martin_Head
Aurora
Posts: 846
Joined: Tue Dec 17, 2013 1:17 pm

A question about OPEN

Post by Martin_Head »

I'm working on a directory device driver project that needs to know the job ID of of the caller when the the drivers OPEN routine is called.

When the open routine is entered, the channel definition block does not yet have CH_OWNER at $08 set. I assume this gets done by the operating system after the open routine has finished.

Does anyone know of a way of finding out the callers job ID while you are in the open routine?


User avatar
pjw
QL Wafer Drive
Posts: 1280
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Post by pjw »

On entry to the ioa.open call the job ID could very well be in d1. I know it doesnt say so in the documentation, but that could just be an omission..


Per
dont be happy. worry
- ?
User avatar
Peter
QL Wafer Drive
Posts: 1948
Joined: Sat Jan 22, 2011 8:47 am

Re: A question about OPEN

Post by Peter »

Hi Martin,
I use the "get system information" trap for that.
Peter

Code: Select all

MT.INF      equ     0
            moveq   #MT.INF,d0
            trap    #1              ; Get current job ID in d1


Martin_Head
Aurora
Posts: 846
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Post by Martin_Head »

pjw wrote:On entry to the ioa.open call the job ID could very well be in d1. I know it doesnt say so in the documentation, but that could just be an omission..
I had a look in the SMSQ/E sources and it looks like D1 should be the job ID. A quick look in Minerva and JS, also looks like D1 should be the job ID. But I have not had a chance to actually try it yet.


User avatar
pjw
QL Wafer Drive
Posts: 1280
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Post by pjw »

It would seem like a lost opportunity otherwise, as the job ID is required to call the open routine.. Either way, it would be good to get confirmation as, if correct, this should be nailed into the documentation.


Per
dont be happy. worry
- ?
User avatar
janbredenbeek
Super Gold Card
Posts: 628
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands

Re: A question about OPEN

Post by janbredenbeek »

Martin_Head wrote:I had a look in the SMSQ/E sources and it looks like D1 should be the job ID. A quick look in Minerva and JS, also looks like D1 should be the job ID. But I have not had a chance to actually try it yet.
I don't know why you need a job id for a system-level I/O open, but if you need the id of the current job (which may not be the same as the one given in D1), you can find it by picking up SV_JBPNT(A6), subtracting SV_JBBAS(A6) from it and dividing this by 4 which gives the low word of the job id. The high word (job tag) can be found by picking up JB_TAG from the current job's header. Something like:

Code: Select all

	move.l 	$64(a6),a0	; current job's header
	move.w 	$10(a0),d1	; job tag
	swap 	d1			; goes to high word in D1
	sub.l		$68(a6),a0	; offset of table entry
	move.w	a0,d1		; goes to low word in D1
	lsr.w		#2,d1		; divide by 4
Jan.


User avatar
NormanDunbar
Forum Moderator
Posts: 2249
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: A question about OPEN

Post by NormanDunbar »

Am I missing something here? I wouldn't be surprised, it happens. ;)

Over at http://qdosmsq.dunbar-it.co.uk/doku.php ... rap_2:open I see that D1 has to be the job id for the owner of the file being opened. You can pass -1 to have the current job own the file.

I assume, always a bad idea, that the owning job id is needed to allow tidying up if the job dies, or is killed, or simply finishes, without closing its open files.

Now, what am I missing, I wonder....

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Martin_Head
Aurora
Posts: 846
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Post by Martin_Head »

pjw wrote:It would seem like a lost opportunity otherwise, as the job ID is required to call the open routine.. Either way, it would be good to get confirmation as, if correct, this should be nailed into the documentation.
I tried it in QPC2, and D1 is not the job ID.

I expected that 'smsq\ioa\open_asm' was the open routine. But I think 'smsq\ioa\opfl_asm' may be. Not too sure as the code in QPC2 does not exactly match my (rather old) copy of the SMSQ/E sources, but it was the closest I could find.

I forgot to consider in my question that the calling job may be opening the channel for another job.

But I think for the moment that I may use the MT_INF method. It's not ideal but will do for testing.


Martin_Head
Aurora
Posts: 846
Joined: Tue Dec 17, 2013 1:17 pm

Re: A question about OPEN

Post by Martin_Head »

janbredenbeek wrote:I don't know why you need a job id for a system-level I/O open,
The job contains a pointer to a string, which I want the open routine to add to the supplied file name.

I am tinkering with a file system that supports long file names, but maintains compatibility with the operating system and existing software by adding a path to the start of the file name that is 'invisible' to the system and programs.


User avatar
pjw
QL Wafer Drive
Posts: 1280
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: A question about OPEN

Post by pjw »

Do you mean sort of "anchoring" a virtual device off some point in the file system, like QPC's DOS device? In theory, I think something like that could work.

Are you aware of QVFS by HPR? His device driver doesnt use the directory device driver system (at least not directly). Its years since I played with it, so cant really remember what the issues are - ie why I dont use it today.


Per
dont be happy. worry
- ?
Post Reply