mirror of
https://github.com/A2osX/A2osX.git
synced 2024-12-26 11:30:07 +00:00
Kernel 0.92
This commit is contained in:
parent
eafaf97d9d
commit
ae9035b88f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -111,7 +111,7 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
|
||||
|
||||
lda #K.DNSCACHE.SIZE
|
||||
>STA.G EntryCount
|
||||
|
||||
|
||||
.1 lda (ZPPTR1)
|
||||
beq .2
|
||||
|
||||
|
386
BIN/HTTPGET.S.txt
Normal file
386
BIN/HTTPGET.S.txt
Normal file
@ -0,0 +1,386 @@
|
||||
NEW
|
||||
PREFIX
|
||||
AUTO 4,1
|
||||
.LIST OFF
|
||||
.OP 65C02
|
||||
.OR $2000
|
||||
.TF BIN/HTTPGET
|
||||
*--------------------------------------
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/ETH.I
|
||||
.INB INC/LIBTCPIP.I
|
||||
.INB INC/NET.HTTP.I
|
||||
*--------------------------------------
|
||||
RESP.BUFSIZE .EQ 1024
|
||||
TIMEOUT.MAX .EQ 100 10 sec.
|
||||
*--------------------------------------
|
||||
ZPIPCfgPtr .EQ ZPBIN
|
||||
ZPHostPtr .EQ ZPBIN+2
|
||||
ZPPtr .EQ ZPBIN+4
|
||||
ZPBufPtr .EQ ZPBIN+6
|
||||
ZPBufLen .EQ ZPBIN+8
|
||||
*--------------------------------------
|
||||
* File Header (16 Bytes)
|
||||
*--------------------------------------
|
||||
CS.START cld
|
||||
jmp (.1,x)
|
||||
.DA #$61 6502,Level 1 (65c02)
|
||||
.DA #1 BIN Layout Version 1
|
||||
.DA #S.PS.F.EVENT S.PS.F
|
||||
.DA #0
|
||||
.DA CS.END-CS.START Code Length To Relocate
|
||||
.DA DS.END-DS.START Data Segment to Allocate
|
||||
.DA #16 SS
|
||||
.DA #10 ZP
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
.1 .DA CS.INIT
|
||||
.DA CS.RUN
|
||||
.DA CS.DOEVENT
|
||||
.DA CS.QUIT
|
||||
L.LIBTCPIP .DA LIBTCPIP
|
||||
L.SA.LOCAL .DA SA.LOCAL
|
||||
L.SA.REMOTE .DA SA.REMOTE
|
||||
L.SA.REMOTE.AD .DA SA.REMOTE+S.SOCKADDR.ADDR
|
||||
L.MSG.IPKO .DA MSG.IPKO
|
||||
L.MSG.USAGE .DA MSG.USAGE
|
||||
L.MSG.UNKNOWN .DA MSG.UNKNOWN
|
||||
L.MSG.HOSTOK .DA MSG.HOSTOK
|
||||
L.MSG.SKTKO .DA MSG.SKTKO
|
||||
L.MSG.SKTOK .DA MSG.SKTOK
|
||||
L.MSG.SKTERR .DA MSG.SKTERR
|
||||
L.MSG.IOERR .DA MSG.IOERR
|
||||
L.HTTP.GET1 .DA HTTP.GET1
|
||||
L.HTTP.GET2 .DA HTTP.GET2
|
||||
L.HTTP.GET3 .DA HTTP.GET3
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
CS.INIT >LDYA L.LIBTCPIP
|
||||
>SYSCALL LoadLib
|
||||
bcs .9
|
||||
sta hLIBTCPIP
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
|
||||
>STYA ZPIPCfgPtr
|
||||
|
||||
lda (ZPIPCfgPtr) Configured ?
|
||||
bmi CS.RUN.IPOK
|
||||
|
||||
>LDYA L.MSG.IPKO
|
||||
>SYSCALL puts
|
||||
lda #E.SYN
|
||||
sec
|
||||
rts
|
||||
|
||||
CS.RUN.IPOK ldy #S.IPCFG.IP+3
|
||||
ldx #3
|
||||
|
||||
.1 lda (ZPIPCfgPtr),y
|
||||
sta SA.LOCAL+S.SOCKADDR.ADDR,x
|
||||
dey
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
>INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
bcs .9
|
||||
|
||||
>STYA ZPHostPtr
|
||||
jsr Init.Timeout
|
||||
|
||||
.2 >PUSHW L.SA.REMOTE.AD
|
||||
|
||||
>PUSHW ZPHostPtr
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
|
||||
bcc CS.RUN.HOSTOK
|
||||
>SLEEP
|
||||
jsr Wait.Timeout
|
||||
bcc .2
|
||||
|
||||
>PUSHW ZPHostPtr
|
||||
>PUSHBI 2
|
||||
>LDYA L.MSG.UNKNOWN
|
||||
>SYSCALL printf
|
||||
bra CS.RUN.ESYN
|
||||
|
||||
.9 >PUSHBI 0
|
||||
>LDYA L.MSG.USAGE
|
||||
>SYSCALL printf
|
||||
|
||||
CS.RUN.ESYN lda #E.SYN
|
||||
sec
|
||||
CS.RUN.RTS rts
|
||||
|
||||
CS.RUN.HOSTOK >INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
bcc .10
|
||||
jmp CS.RUN.PORTOK
|
||||
|
||||
.10 >STYA ZPPtr
|
||||
lda (ZPPtr)
|
||||
cmp #'-'
|
||||
beq .1
|
||||
|
||||
>LDYA ZPPtr
|
||||
>SYSCALL atoi
|
||||
bcs CS.RUN.RTS
|
||||
>STYA SA.REMOTE+S.SOCKADDR.PORT
|
||||
|
||||
>INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
bcs .8
|
||||
|
||||
>STYA ZPPtr
|
||||
lda (ZPPtr)
|
||||
cmp #'-'
|
||||
bne CS.RUN.ESYN
|
||||
|
||||
.1 ldy #1
|
||||
lda (ZPPtr),y
|
||||
cmp #'U'
|
||||
bne .2
|
||||
|
||||
>INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
.9 bcs CS.RUN.ESYN
|
||||
|
||||
>STYA ZPBufPtr
|
||||
>SYSCALL strlen
|
||||
>STYA ZPBufLen
|
||||
.8 bra CS.RUN.PORTOK
|
||||
|
||||
.2 cmp #'F'
|
||||
bne CS.RUN.ESYN
|
||||
>INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
bcs CS.RUN.RTS
|
||||
>SYSCALL LoadTxtFile
|
||||
bcs .9
|
||||
>STYA ZPBufLen
|
||||
txa
|
||||
>STA.G hReqBuf
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPBufPtr
|
||||
|
||||
CS.RUN.PORTOK >PUSHW ZPHostPtr
|
||||
>PUSHW SA.REMOTE+S.SOCKADDR.PORT
|
||||
|
||||
ldx #3
|
||||
|
||||
.1 >PUSHB SA.REMOTE+S.SOCKADDR.ADDR,x
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
>PUSHBI 8
|
||||
>LDYA L.MSG.HOSTOK
|
||||
>SYSCALL printf
|
||||
|
||||
CS.RUN.OPENSKT >PUSHBI 0 no protocol
|
||||
lda #S.SOCKET.T.STREAM
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
|
||||
bcs .9
|
||||
|
||||
>STA.G hSocket
|
||||
pha
|
||||
>PUSHW L.SA.LOCAL
|
||||
pla
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
|
||||
bcc .2
|
||||
|
||||
.9 >LDYA L.MSG.SKTKO
|
||||
>SYSCALL puts
|
||||
lda #E.SYN
|
||||
sec
|
||||
rts
|
||||
|
||||
.2 >PUSHW L.SA.REMOTE
|
||||
>LDA.G hSocket
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
|
||||
bcs .9
|
||||
|
||||
>LDYA L.MSG.SKTOK
|
||||
>SYSCALL puts
|
||||
|
||||
>LDYAI RESP.BUFSIZE
|
||||
>SYSCALL getmem
|
||||
bcs .9
|
||||
>STYA ZPBufPtr
|
||||
txa
|
||||
>STA.G hRespBuf
|
||||
|
||||
CS.RUN.GET jsr Init.Timeout
|
||||
|
||||
jsr CS.RUN.REQUEST
|
||||
bcs .99
|
||||
|
||||
.1 >SLEEP
|
||||
|
||||
>PUSHWI RESP.BUFSIZE
|
||||
>PUSHW ZPBufPtr
|
||||
>LDA.G hSocket
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Read
|
||||
bcc .2
|
||||
|
||||
tay
|
||||
bne CS.RUN.SKTERR
|
||||
|
||||
>SLEEP no response
|
||||
jsr Wait.Timeout
|
||||
bcc .1
|
||||
jmp CS.RUN.IOERR
|
||||
|
||||
.2 >PUSHYA len
|
||||
>PUSHW ZPBufPtr
|
||||
ldy #S.PS.hStdOut
|
||||
lda (pPs),y
|
||||
>SYSCALL fwrite
|
||||
bcs .99
|
||||
|
||||
bra .1
|
||||
|
||||
.9 lda #0
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
CS.RUN.SKTERR pha
|
||||
>PUSHA
|
||||
>PUSHBI 1
|
||||
>LDYA L.MSG.SKTERR
|
||||
>SYSCALL printf
|
||||
pla
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.IOERR pha
|
||||
>PUSHA
|
||||
>PUSHBI 1
|
||||
>LDYA L.MSG.IOERR
|
||||
>SYSCALL printf
|
||||
pla
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.REQUEST >PUSHWI HTTP.GET1.LEN
|
||||
>PUSHW L.HTTP.GET1
|
||||
jsr .8
|
||||
bcs .99
|
||||
|
||||
>PUSHW ZPBufLen
|
||||
>PUSHW ZPBufPtr
|
||||
jsr .8
|
||||
bcs .9
|
||||
|
||||
>PUSHWI HTTP.GET2.LEN
|
||||
>PUSHW L.HTTP.GET2
|
||||
jsr .8
|
||||
.99 bcs .9
|
||||
|
||||
>LDYA ZPHostPtr
|
||||
>SYSCALL strlen
|
||||
>PUSHYA
|
||||
>PUSHW ZPHostPtr
|
||||
jsr .8
|
||||
bcs .9
|
||||
|
||||
>PUSHWI HTTP.GET3.LEN
|
||||
>PUSHW L.HTTP.GET3
|
||||
|
||||
.8 >LDA.G hSocket
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Write
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.DOEVENT lda (pEvent)
|
||||
bpl .9 is it a TIMER event?
|
||||
|
||||
>LDA.G TimeOut
|
||||
beq .9
|
||||
|
||||
dec
|
||||
sta (pData),y
|
||||
|
||||
.9 sec do not discard TIMER event
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.QUIT >LDA.G hSocket
|
||||
beq .1
|
||||
|
||||
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
|
||||
|
||||
.1 >LDA.G hReqBuf
|
||||
beq .2
|
||||
|
||||
>SYSCALL freemem
|
||||
|
||||
.2 >LDA.G hRespBuf
|
||||
beq .3
|
||||
|
||||
>SYSCALL freemem
|
||||
|
||||
.3 lda hLIBTCPIP
|
||||
beq .8
|
||||
>SYSCALL UnloadLib
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
Init.Timeout lda #TIMEOUT.MAX
|
||||
>STA.G TimeOut
|
||||
rts
|
||||
*--------------------------------------
|
||||
Wait.TimeOut sec
|
||||
>LDA.G TimeOut
|
||||
beq .9
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.END
|
||||
LIBTCPIP .AZ "libtcpip"
|
||||
hLIBTCPIP .BS 1
|
||||
MSG.IPKO .AZ "TCP/IP Not Loaded/Configured."
|
||||
MSG.USAGE .AS "Usage : HTTPGET <ip|host> [port]\r\n"
|
||||
.AS " -U Url\r\n"
|
||||
.AZ " -F UrlFile\r\n"
|
||||
MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
|
||||
MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d:%D (%s)..."
|
||||
MSG.SKTKO .AZ "Failed to Open Socket."
|
||||
MSG.SKTOK .AZ "Connected."
|
||||
MSG.SKTERR .AZ "Socket Error : $%h\r\n"
|
||||
MSG.IOERR .AZ "I/O Error : $%h\r\n"
|
||||
*--------------------------------------
|
||||
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
|
||||
.BS 1
|
||||
.BS 4 S.SOCKADDR.ADDR
|
||||
.BS 2 S.SOCKADDR.PORT
|
||||
*--------------------------------------
|
||||
SA.REMOTE .DA #AF.INET S.SOCKADDR.AF
|
||||
.BS 1
|
||||
.BS 4 S.SOCKADDR.ADDR
|
||||
.DA TCP.PORT.HTTP
|
||||
*--------------------------------------
|
||||
HTTP.GET1 .AZ "GET /"
|
||||
HTTP.GET1.LEN .EQ *-HTTP.GET1
|
||||
HTTP.GET2 .AS " HTTP/1.1\r\n"
|
||||
.AS "User-Agent: A2osX.HTTPGET\r\n"
|
||||
.AZ "Host: "
|
||||
HTTP.GET2.LEN .EQ *-HTTP.GET2
|
||||
HTTP.GET3 .AZ "\r\n"
|
||||
HTTP.GET3.LEN .EQ *-HTTP.GET3
|
||||
*--------------------------------------
|
||||
.DUMMY
|
||||
.OR 0
|
||||
DS.START
|
||||
ArgIndex .BS 1
|
||||
hReqBuf .BS 1
|
||||
hRespBuf .BS 1
|
||||
hSocket .BS 1
|
||||
TimeOut .BS 1
|
||||
DS.END
|
||||
.ED
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/BIN/HTTPGET.S
|
||||
ASM
|
@ -150,6 +150,7 @@ CS.RUN.FILE >LDYAI FILEBUF.SIZE
|
||||
>LIBCALL hLIBCRYPT,LIBCRYPT.MD5Finalize
|
||||
|
||||
CS.RUN.PRINT >LEA.G MD5Buf
|
||||
>SYSCALL strlwr
|
||||
>SYSCALL puts
|
||||
|
||||
lda #0
|
||||
|
@ -77,18 +77,14 @@ Cmd.Exec jsr CMD.StkGet IF,WHILE,FOR ?
|
||||
>SYSCALL printf
|
||||
rts
|
||||
|
||||
.4 >SLEEP Suspend this PID
|
||||
.4 >SLEEP Suspend this PID
|
||||
|
||||
ldy #S.PS.RC
|
||||
ldy #S.PS.RC CPID will update S.PS.RC
|
||||
lda (pPs),y
|
||||
bne .99
|
||||
|
||||
.8 clc
|
||||
.9 rts
|
||||
|
||||
.99 sec
|
||||
rts
|
||||
|
||||
.80 tax
|
||||
jmp (J.CMD.INT,x)
|
||||
*--------------------------------------
|
||||
|
@ -410,7 +410,9 @@ CS.RUN.LOOP.END ldy #S.PS.RC
|
||||
CS.RUN.LOOP.8 >LDA.G bExit
|
||||
beq CS.RUN.LOOP.80
|
||||
|
||||
lda #0
|
||||
ldy #S.PS.RC
|
||||
lda (pPs),y
|
||||
|
||||
sec
|
||||
CS.RUN.LOOP.RTS rts
|
||||
|
||||
|
8
INC/NET.HTTP.I.txt
Normal file
8
INC/NET.HTTP.I.txt
Normal file
@ -0,0 +1,8 @@
|
||||
NEW
|
||||
PREFIX
|
||||
AUTO 4,1
|
||||
*--------------------------------------
|
||||
TCP.PORT.HTTP .EQ 80
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE INC/NET.HTTP.I
|
@ -59,4 +59,4 @@ TELOPT.NEWENVIRON .EQ 39 New - Environment variables
|
||||
TELOPT.EXOPL .EQ 255 extended-options-list
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.BUILD/INC/NET.TELNET.I
|
||||
SAVE INC/NET.TELNET.I
|
||||
|
@ -24,7 +24,7 @@ CS.START cld
|
||||
jmp (.1,x)
|
||||
.DA #$61 6502,Level 1 (65c02)
|
||||
.DA #1 BIN Layout Version 1
|
||||
.DA #S.PS.F.EVENT
|
||||
.DA #0 S.PS.F.EVENT
|
||||
.DA #0
|
||||
.DA CS.END-CS.START Code Size (without Constants)
|
||||
.DA DS.END-DS.START Data SegmentSize
|
||||
@ -41,7 +41,8 @@ CS.START cld
|
||||
L.MSG.CTRLR .DA MSG.CTRLR
|
||||
L.MSG.ETCINIT .DA MSG.ETCINIT
|
||||
L.BINSHELL .DA BINSHELL
|
||||
L.ETCINIT .DA ETCINIT
|
||||
L.ETCINIT .DA ETCINIT
|
||||
L.MSG.RUNNING .DA MSG.RUNNING
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
* Called once at process creation
|
||||
@ -83,6 +84,15 @@ CS.RUN ldy #S.PS.PID
|
||||
|
||||
>SLEEP
|
||||
|
||||
>LDYA L.MSG.RUNNING
|
||||
>SYSCALL puts
|
||||
|
||||
ldy #S.PS.F.HOLD
|
||||
ora (pPS),y
|
||||
sta (pPS),y
|
||||
|
||||
>SLEEP
|
||||
|
||||
lda #0
|
||||
sec
|
||||
rts
|
||||
@ -107,10 +117,12 @@ CS.END
|
||||
*--------------------------------------
|
||||
* Initialized DATA
|
||||
*--------------------------------------
|
||||
MSG.CTRLR .AZ "Ctrl-R Pressed, entering ROOT mode..."
|
||||
MSG.ETCINIT .AS "Executing ETC/INIT Script:"
|
||||
MSG.CTRLR .AZ "INITD:Ctrl-R Pressed, entering ROOT mode..."
|
||||
MSG.ETCINIT .AS "INITD:Executing ETC/INIT Script:"
|
||||
ETCINIT .AZ "${ROOT}ETC/INIT"
|
||||
BINSHELL .AZ "${ROOT}BIN/SHELL"
|
||||
MSG.RUNNING .AZ "INITD:Running..."
|
||||
MSH.SHUTDOWN .AZ "INITD:Shutting down..."
|
||||
*--------------------------------------
|
||||
* Per Process DATA segement (0 filled before INIT)
|
||||
*--------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user