mirror of
https://github.com/sheumann/NetDisk.git
synced 2024-11-16 22:05:16 +00:00
Add basic infrastructure for an installable GS/OS driver.
Currently, this can install the DIBs from the driver, but no driver calls are implemented.
This commit is contained in:
parent
cb236fbeb3
commit
ff538de39c
10
Makefile
10
Makefile
@ -4,7 +4,7 @@ CFLAGS = -w-1 -O-1
|
||||
HTTPTEST_OBJS = httptest.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a
|
||||
HTTPTEST_PROG = httptest
|
||||
|
||||
NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a
|
||||
NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.a strcasecmp.a tcpconnection.a urlparser.a driver.a installdriver.a asmglue.a
|
||||
# NETDISKINIT_RSRC =
|
||||
NETDISKINIT_PROG = NetDiskInit
|
||||
|
||||
@ -12,6 +12,8 @@ NETDISKINIT_PROG = NetDiskInit
|
||||
# NETDISKCDEV_RSRC =
|
||||
# NETDISKCDEV_CDEV =
|
||||
|
||||
MACROS = asmglue.macros
|
||||
|
||||
PROGS = $(HTTPTEST_PROG) $(NETDISKINIT_PROG)
|
||||
|
||||
.PHONY: default
|
||||
@ -24,6 +26,12 @@ $(NETDISKINIT_PROG): $(NETDISKINIT_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
iix chtyp -tpif $@
|
||||
|
||||
%.macros: %.asm
|
||||
iix macgen $< $@ 13/ORCAInclude/m16.= < /dev/null > /dev/null
|
||||
|
||||
.PHONY: macros
|
||||
macros: $(MACROS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(PROGS) *.a *.o *.root *.A *.O *.ROOT
|
||||
|
53
asmglue.asm
Normal file
53
asmglue.asm
Normal file
@ -0,0 +1,53 @@
|
||||
case on
|
||||
mcopy asmglue.macros
|
||||
|
||||
ROMIN gequ $E0C081
|
||||
LCBANK1 gequ $E0C08B
|
||||
LCBANK2 gequ $E0C083
|
||||
STATEREG gequ $E0C068
|
||||
|
||||
ForceLCBank1 start
|
||||
short i,m
|
||||
lda >STATEREG ;get original state reg.
|
||||
tax
|
||||
lda >LCBANK1 ;force LC bank 1
|
||||
lda >LCBANK1
|
||||
long i,m
|
||||
txa
|
||||
rtl
|
||||
end
|
||||
|
||||
ForceLCBank2 start
|
||||
short i,m
|
||||
lda >STATEREG ;get original state reg.
|
||||
tax
|
||||
lda >LCBANK2 ;force LC bank 2
|
||||
lda >LCBANK2
|
||||
long i,m
|
||||
txa
|
||||
rtl
|
||||
end
|
||||
|
||||
ForceRomIn start
|
||||
short i,m
|
||||
lda >STATEREG ;get original state reg.
|
||||
tax
|
||||
lda >ROMIN ;force ROM in to Language Card space
|
||||
lda >ROMIN
|
||||
long i,m
|
||||
txa
|
||||
rtl
|
||||
end
|
||||
|
||||
RestoreStateReg start
|
||||
short m
|
||||
plx
|
||||
pla
|
||||
ply
|
||||
pha
|
||||
phx
|
||||
tya
|
||||
sta >STATEREG
|
||||
long m
|
||||
rtl
|
||||
end
|
18
asmglue.h
Normal file
18
asmglue.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef ASMGLUE_H
|
||||
#define ASMGLUE_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
extern Word ForceLCBank1(void);
|
||||
extern Word ForceLCBank2(void);
|
||||
extern Word ForceRomIn(void);
|
||||
extern void RestoreStateReg(Word);
|
||||
|
||||
void IncBusyFlag(void) inline(0, 0xE10064);
|
||||
void DecBusyFlag(void) inline(0, 0xE10068);
|
||||
|
||||
#define OS_KIND (*(Byte*)0xE100BC)
|
||||
#define KIND_P8 0x00
|
||||
#define KIND_GSOS 0x01
|
||||
|
||||
#endif
|
37
driver.c
Normal file
37
driver.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "driver.h"
|
||||
#include "version.h"
|
||||
|
||||
struct DIB dibs[NDIBS] = {0};
|
||||
struct DIBList dibList = {NDIBS};
|
||||
|
||||
void *gsosDP = (void*)0x00BD00; /* GS/OS direct page ptr */
|
||||
|
||||
static asm dummy(void) {
|
||||
rtl
|
||||
}
|
||||
|
||||
void InitDIBs(void) {
|
||||
for (unsigned i = 0; i < NDIBS; i++) {
|
||||
dibs[i].linkPtr = (i < NDIBS-1) ? &dibs[i+1] : NULL;
|
||||
dibs[i].entryPtr = dummy; // TODO driver entry point
|
||||
/* speed-independent, block device, read allowed, removable */
|
||||
dibs[i].characteristics = 0x03A4;
|
||||
dibs[i].blockCount = 0;
|
||||
|
||||
int nameLen = sprintf(dibs[i].devName + 1, "NETDISK%u", i+1);
|
||||
dibs[i].devName[0] = nameLen;
|
||||
for (unsigned j = nameLen + 1; j < sizeof(dibs[i].devName); j++) {
|
||||
dibs[i].devName[j] = ' ';
|
||||
}
|
||||
|
||||
dibs[i].slotNum = 0x8003;
|
||||
dibs[i].unitNum = i+1;
|
||||
dibs[i].version = DRIVER_VERSION;
|
||||
dibs[i].deviceID = DEVICE_GENERIC_FLOPPY_DRIVE;
|
||||
|
||||
dibList.dibPointers[i] = &dibs[i];
|
||||
}
|
||||
|
||||
}
|
38
driver.h
Normal file
38
driver.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef DRIVER_H
|
||||
#define DRIVER_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#define DEVICE_GENERIC_FLOPPY_DRIVE 0x0013
|
||||
|
||||
#define NDIBS 16
|
||||
|
||||
struct DIB {
|
||||
void *linkPtr;
|
||||
void *entryPtr;
|
||||
Word characteristics;
|
||||
LongWord blockCount;
|
||||
char devName[32];
|
||||
Word slotNum;
|
||||
Word unitNum;
|
||||
Word version;
|
||||
Word deviceID;
|
||||
Word headlink;
|
||||
Word forwardLink;
|
||||
void *extendedDIBPtr;
|
||||
Word DIBDevNum;
|
||||
};
|
||||
|
||||
struct DIBList {
|
||||
LongWord count;
|
||||
struct DIB *dibPointers[NDIBS];
|
||||
};
|
||||
|
||||
extern struct DIB dibs[NDIBS];
|
||||
extern struct DIBList dibList;
|
||||
|
||||
extern void *gsosDP;
|
||||
|
||||
void InitDIBs(void);
|
||||
|
||||
#endif
|
3
http.c
3
http.c
@ -15,6 +15,7 @@
|
||||
#include "tcpconnection.h"
|
||||
#include "strcasecmp.h"
|
||||
#include "seturl.h"
|
||||
#include "version.h"
|
||||
|
||||
#define buffTypePointer 0x0000 /* For TCPIPReadTCP() */
|
||||
#define buffTypeHandle 0x0001
|
||||
@ -54,7 +55,7 @@ Boolean BuildHTTPRequest(Session *sess, char *resourceStr) {
|
||||
sizeNeeded = snprintf(sess->httpRequest, sizeNeeded,
|
||||
"GET /%s HTTP/1.1\r\n"
|
||||
"Host: %s\r\n"
|
||||
"User-Agent: GS-NetDisk/1.0a1\r\n"
|
||||
"User-Agent: GS-NetDisk/" USER_AGENT_VERSION "\r\n"
|
||||
"Accept-Encoding: identity\r\n"
|
||||
//"Accept: */*\r\n" /* default, but some clients send explicitly */
|
||||
//"Connection: Keep-Alive\r\n" /* same */
|
||||
|
43
installdriver.asm
Normal file
43
installdriver.asm
Normal file
@ -0,0 +1,43 @@
|
||||
case on
|
||||
|
||||
GSOSBusy gequ $E100BE
|
||||
|
||||
INSTALL_DRIVER gequ $01FCA8
|
||||
|
||||
dummy private
|
||||
end
|
||||
|
||||
* Adapted from procedure shown in Brutal Deluxe GS/OS Internals book
|
||||
InstallDriver start
|
||||
phb ; set data bank to $E1 (to access GSOSBusy)
|
||||
pea $E1E1
|
||||
plb
|
||||
plb
|
||||
|
||||
lda #$8000 ; check and set GS/OS busy flag
|
||||
tsb |GSOSBusy
|
||||
bne exit ; bail out if GS/OS is busy
|
||||
|
||||
phd
|
||||
lda >gsosDP ; set DP to GS/OS direct page
|
||||
tcd ; (should be unnecessary for INSTALL_DRIVER)
|
||||
|
||||
jsl ForceLCBank1 ; force in language card bank 1
|
||||
pha ; save old state reg
|
||||
|
||||
ldx #dibList
|
||||
ldy #^dibList
|
||||
jsl INSTALL_DRIVER ; install the driver
|
||||
tcd ; save INSTALL_DRIVER result
|
||||
|
||||
jsl RestoreStateReg ; restore old state reg
|
||||
|
||||
lda #$8000 ; clear GS/OS busy flag
|
||||
trb |GSOSBusy
|
||||
|
||||
tdc ; return INSTALL_DRIVER result
|
||||
pld ; restore direct page
|
||||
|
||||
exit plb
|
||||
rtl
|
||||
end
|
12
installdriver.h
Normal file
12
installdriver.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef INSTALLDRIVER_H
|
||||
#define INSTALLDRIVER_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/*
|
||||
* Install our driver.
|
||||
* Returns 0 if successful, non-zero error code if not.
|
||||
*/
|
||||
Word InstallDriver(void);
|
||||
|
||||
#endif
|
@ -4,9 +4,13 @@
|
||||
#include <locator.h>
|
||||
#include <misctool.h>
|
||||
#include <tcpip.h>
|
||||
#include <memory.h>
|
||||
#include <orca.h>
|
||||
#include "driver.h"
|
||||
#include "installdriver.h"
|
||||
#include "version.h"
|
||||
|
||||
const char bootInfoString[] = "NetDisk v1.0a1";
|
||||
const char bootInfoString[] = "NetDisk " BOOT_INFO_VERSION;
|
||||
|
||||
Word *unloadFlagPtr;
|
||||
|
||||
@ -16,14 +20,27 @@ static void setUnloadFlag(void) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
for (int i = 1; i < 256; i++) {
|
||||
UnloadOneTool(i); // event mgr
|
||||
}
|
||||
|
||||
/*
|
||||
* Load Marinetti.
|
||||
* We may get an error if the TCPIP init isn't loaded yet, but we ignore it.
|
||||
* The tool stub is still loaded in that case, which is enough for now.
|
||||
*/
|
||||
LoadOneTool(54, 0x0200);
|
||||
//if (toolerror() && toolerror() != terrINITNOTFOUND)
|
||||
// goto error;
|
||||
if (toolerror() && toolerror() != terrINITNOTFOUND)
|
||||
goto error;
|
||||
|
||||
/* Initialize the DIBs for our driver */
|
||||
InitDIBs();
|
||||
|
||||
/* Install our driver */
|
||||
if (InstallDriver() != 0) {
|
||||
UnloadOneTool(54);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* We're not going to error out, so show boot info. */
|
||||
ShowBootInfo(bootInfoString, NULL);
|
||||
@ -37,9 +54,7 @@ int main(void) {
|
||||
* yet when this init loads).
|
||||
*/
|
||||
SetDefaultTPT();
|
||||
|
||||
// TODO install driver
|
||||
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
|
Loading…
Reference in New Issue
Block a user