z88dk forums

z80 Development Kit

You are not logged in.

#1 2012-03-16 08:40:44

siggi
Well known member
Registered: 2007-07-26
Posts: 159

[z88dk-dev] Add ZX81 network support (ZeddyNet) to z88dk?

Some of you may have already heard, that I ported a subset of Spectranet to the ZX81: a socket library for socket communication and a ZeddyNet library for file handling (TNFS file system).

Of course that libraries need additional hardware to run with a ZX81: ram at address range 8-16K and a network card with a W5100 network chip.
Do you think it would     nevertheless make sense to add this libs to z88dk as "standard feature"?

Of course then some adaptions would have to be made, e. g. to map standard file functions to ZeddyNet functions or to remap file mode flags defined within C to file mode flags used in ZeddyNet (and Spectranet and POSIX).

Here are the functions currently avaliable in ZeddyNet:

Code:

/// TNFS Definitions ///

// Definitions for things returned by stat

// Bitmasks for the filemode field.
// These are defined by POSIX as a 16 bit octal value.
#define S_IFMT            0xF000
#define S_IFSOCK        0xC000
#define S_IFLNK            0xA000
#define S_IFREG            0x8000
#define S_IFBLK            0x6000
#define S_IFDIR            0x4000
#define S_IFCHR            0x2000
#define S_IFIFO            0x1000
#define S_ISUID            0x0800
#define S_ISGID            0x0400
#define S_ISVTX            0x0200
#define S_IRWXU            0x01C0
#define S_IRUSR            0x0100
#define S_IWUSR            0x0080
#define S_IXUSR            0x0040
#define S_IRGRP            0x0020
#define S_IWGRP            0x0010
#define S_IXGRP            0x0008
#define S_IROTH            0x0004
#define S_IWOTH            0x0002
#define S_IXOTH            0x0001

// Stat structure offsets
/*
File mode    - 2 bytes: file permissions - little endian byte order
uid            - 2 bytes: Numeric UID of owner
gid            - 2 bytes: Numeric GID of owner
size        - 4 bytes: Unsigned 32 bit little endian size of file in bytes
atime        - 4 bytes: Access time in seconds since the epoch, little end.
mtime        - 4 bytes: Modification time in seconds since the epoch,
little endian
ctime        - 4 bytes: Time of last status change, as above.
uidstring    - 0 or more bytes: Null terminated user id string
gidstring    - 0 or more bytes: Null terminated group id string
*/

#define STAT_MODE         0x00
#define STAT_UID        0x02
#define STAT_GID        0x04
#define STAT_SIZE        0x06
#define STAT_ATIME        0x0A
#define STAT_MTIME        0x0E
#define STAT_CTIME        0x12
#define STAT_STRINGS    0x16


// file open flags
/*
The flags are:

O_RDONLY    0x0001    Open read only
O_WRONLY    0x0002    Open write only
O_RDWR        0x0003    Open read/write

O_APPEND    0x0008    Append to the file, if it exists (write only)
O_CREAT        0x0100    Create the file if it doesn't exist (write only)
O_TRUNC        0x0200    Truncate the file on open for writing
O_EXCL        0x0400    With O_CREAT, returns an error if the file exists


*/

// flags
#define TNFS_O_RDONLY    0x0001
#define TNFS_O_WRONLY    0x0002
#define TNFS_O_RDWR        0x0003

#define TNFS_O_APPEND    0x0008
#define TNFS_O_CREAT    0x0100
#define TNFS_O_TRUNC    0x0200
#define TNFS_O_EXCL        0x0400

// mode: see above for "stat"

// lseek operators
/*
The seek types are defined as follows:
0x00        SEEK_SET - Go to an absolute position in the file
0x01        SEEK_CUR - Go to a relative offset from the current position
0x02        SEEK_END - Seek to EOF
*/

#define TNFS_SEEK_SET    0x00
#define TNFS_SEEK_CUR    0x01
#define TNFS_SEEK_END    0x02

/* file system handling */
extern int __LIB__ __CALLEE__ setmountpoint_tnfs(int mount_point);
extern int __LIB__ __CALLEE__ getmountpointstate_tnfs(int mount_point);
extern int __LIB__ __CALLEE__ mount_tnfs (int mount_point, char * hostname, char * mount_source, char * username, char * password);
extern int __LIB__ __CALLEE__ umount_tnfs(int mount_point);

/* BASIC load/save handling */
extern int __LIB__ __CALLEE__ load_file_tnfs(int mount_point, char * fname, unsigned int address);
extern int __LIB__ __CALLEE__ save_file_tnfs(int mount_point, char * fname, unsigned int address, unsigned int length);

/* directory handling */
extern int __LIB__ __CALLEE__ open_dir_tnfs(int mount_point, char * fname);
extern int __LIB__ __CALLEE__ read_dir_tnfs(int dir_handle, char * buffer);
extern int __LIB__ __CALLEE__ close_dir_tnfs(int dir_handle);
extern int __LIB__ __CALLEE__ change_dir_tnfs(int mount_point, char * fname);
extern int __LIB__ __CALLEE__ make_dir_tnfs(int mount_point, char * fname);
extern int __LIB__ __CALLEE__ remove_dir_tnfs(int mount_point, char * fname);
extern int __LIB__ __CALLEE__ get_current_dir_tnfs(int mount_point, char * buffer);

/* file manipulation */
extern int __LIB__ __CALLEE__ file_stat_tnfs(int mount_point, char * fname, char * buffer);
extern int __LIB__ __CALLEE__ file_rename_tnfs(int mount_point, char * old_name, char * new_name);
extern int __LIB__ __CALLEE__ file_delete_tnfs(int mount_point, char * fname);
extern int __LIB__ __CALLEE__ file_chmod_tnfs(int mount_point, char * fname, int mode);

/* file handling */
extern int __LIB__ __CALLEE__ open_file_tnfs(int mount_point, char * fname, unsigned int flags, unsigned int mode);
extern int __LIB__ __CALLEE__ close_file_tnfs(int fd);
extern int __LIB__ __CALLEE__ read_file_tnfs(int fd, char * buffer, unsigned int size);
extern int __LIB__ __CALLEE__ write_file_tnfs(int fd, char * buffer, unsigned int size);
extern int __LIB__ __CALLEE__ lseek_file_tnfs(long position, int fd, unsigned int op);

Siggi



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure


My ZX81 web-server, compiled with Z88DK V1.7:
http://zx81-siggi.endoftheinternet.org/index.html smile
Online since 2007 ...

Offline

 

#2 2012-03-26 08:59:45

alvin
Administrator
Registered: 2007-07-16
Posts: 338

Re: [z88dk-dev] Add ZX81 network support (ZeddyNet) to z88dk?

Of course that libraries need additional hardware to run with a ZX81: ram at address range 8-16K and a network card with a W5100 network chip.
Do you think it would     nevertheless make sense to add this libs to z88dk as "standard feature"?

Well I do but I would prefer to separate the POSIX / BSD standard part from the actual device specific code, with the device code available as a plug in driver.  Stay tuned smile



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure

Offline

 

#3 2012-03-26 11:46:41

siggi
Well known member
Registered: 2007-07-26
Posts: 159

Re: [z88dk-dev] Add ZX81 network support (ZeddyNet) to z88dk?

The POSIX definitions are necessary for all *file operations*, because at the "end of the ethernet connection" a TNFS fileserver (e. g. running on a PC) expects them. So it makes no sense to separate them from file function definitions (for TNFS file systems).

Only the pure socket communication routines does not need/use this definitions.

Siggi



------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure


My ZX81 web-server, compiled with Z88DK V1.7:
http://zx81-siggi.endoftheinternet.org/index.html smile
Online since 2007 ...

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson