From: Juan Perez-Sanchez <lithoxs@gmail.com>
To: linux-8086 <linux-8086@vger.kernel.org>
Subject: [PATCH] Changes to reduce warnings using ia16-unknown-elks-gcc
Date: Tue, 2 Jun 2015 00:10:10 -0500 [thread overview]
Message-ID: <CAD6VGubCsua=nTM7YENH38_2JcJm7OE5FYfDngGfQH5=TD2_rg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
Hi,
Attached is a patch to:
-Reduce warnings using ia16-unknown-elks-gcc
-Elimination of inline assembly within several C functions.
-Fixed prototypes of several functions.
-Simplifyed file arch/i86/drivers/char/bell.c.
Code and data size was unchanged.
Juan
[-- Attachment #2: elks-3y.patch --]
[-- Type: text/x-patch, Size: 9475 bytes --]
diff -Nur elks.orig/arch/i86/drivers/char/bell.c elks/arch/i86/drivers/char/bell.c
--- elks.orig/arch/i86/drivers/char/bell.c 2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/drivers/char/bell.c 2015-06-01 14:18:29.000000000 -0500
@@ -8,39 +8,30 @@
#include <arch/io.h>
+#define BELL_FREQUENCY 800
+#define BELL_PERIOD (1193181/BELL_FREQUENCY)
+#define BELL_PERIOD_L (BELL_PERIOD & 0xFF)
+#define BELL_PERIOD_H (BELL_PERIOD / 256)
+#define SPEAKER_PORT (0x61)
+#define TIMER2_PORT (0x42)
+#define TIMER_CONTROL_PORT (0x43)
+
/*
* Turn PC speaker on at specified frequency.
*/
-static void sound(unsigned freq)
+static void sound(void)
{
- int es;
-#ifndef S_SPLINT_S
-#asm
- mov bx, [bp+.sound.freq] ! frequency
- mov ax, #$34dd
- mov dx, #$0012
- cmp dx, bx
- jnb none
- div bx
- mov bx, ax
- in al, $61
- test al, #3
- jne j1
- or al, #3
- out $61, al
-
-j1:
- mov al, #$b6
- out $43, al
- mov al, bl
- out $42, al
- mov al, bh
- out $42, al
-
-none:
-
-#endasm
-#endif
+ asm(\
+ "\tin al,0x61\n" \
+ "\tor al,#3\n" \
+ "\tout 0x61,al\n" \
+ "\tmov al,#0xB6\n" \
+ "\tout 0x43,al\n" \
+ "\tmov al,#0xD3\n" \
+ "\tout 0x42,al\n" \
+ "\tmov al,#0x05\n" \
+ "\tout 0x42,al\n" \
+ );
}
/*
@@ -48,13 +39,11 @@
*/
static void nosound(void)
{
-#ifndef S_SPLINT_S
-#asm
- in al, $61
- and al, #$fc
- out $61, al
-#endasm
-#endif
+ asm(\
+ "\tin al,0x61\n" \
+ "\tand al,#0xFC\n" \
+ "\tout 0x61,al\n" \
+ );
}
/*
@@ -64,8 +53,8 @@
{
register char *pi = (char *) 60000U;
- sound(800);
- while (--pi)
+ sound();
+ while (--pi)
/* Do nothing */ ;
nosound();
}
diff -Nur elks.orig/arch/i86/drivers/char/ntty.c elks/arch/i86/drivers/char/ntty.c
--- elks.orig/arch/i86/drivers/char/ntty.c 2015-06-01 18:34:18.000000000 -0500
+++ elks/arch/i86/drivers/char/ntty.c 2015-06-01 14:18:29.000000000 -0500
@@ -101,7 +101,7 @@
err = otty->ops->open(otty);
if (err)
return err;
- if (otty->pgrp == NULL && currentp->session == currentp->pid
+ if (otty->pgrp == 0 && currentp->session == currentp->pid
&& currentp->tty == NULL) {
otty->pgrp = currentp->pgrp;
currentp->tty = otty;
diff -Nur elks.orig/arch/i86/kernel/asm-offsets.c elks/arch/i86/kernel/asm-offsets.c
--- elks.orig/arch/i86/kernel/asm-offsets.c 2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/kernel/asm-offsets.c 2015-06-01 14:18:29.000000000 -0500
@@ -7,7 +7,8 @@
#ifdef __WATCOMC__
#define offsetof(__typ,__id) ((size_t)((char *)&(((__typ*)0)->__id) - (char *)0))
#else
-#include <stddef.h>
+#define offsetof(s,m) (size_t)&(((s *)0)->m)
+/*#include <stddef.h>*/
#endif
#endif
diff -Nur elks.orig/arch/i86/kernel/mkentry.sh elks/arch/i86/kernel/mkentry.sh
--- elks.orig/arch/i86/kernel/mkentry.sh 2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/kernel/mkentry.sh 2015-06-01 17:10:13.000000000 -0500
@@ -69,7 +69,7 @@
if( depends_on[callno] != "" )
{
- if( callno <= maxstd )
+ if( callno < maxstd )
{
str = "\t.word _no_syscall";
printf "#else\n%-25s ! %3d - %s\n", str, callno, assigned_to[callno]
@@ -90,10 +90,11 @@
.text
.globl _syscall
+ .globl _no_syscall
_syscall:
cmp ax,#((sys_call_table_end - sys_call_table)/2)
- ja _nsyscall
+ ja _no_syscall
! look up address and jump to function
mov bx,ax
add bx,ax ! multiply by 2
@@ -101,8 +102,9 @@
! All unimplemented calls
-_nsyscall:
- br _no_syscall
+_no_syscall:
+ mov ax,#-38
+ ret
#endasm
#endif
diff -Nur elks.orig/arch/i86/kernel/printreg.c elks/arch/i86/kernel/printreg.c
--- elks.orig/arch/i86/kernel/printreg.c 2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/kernel/printreg.c 2015-06-01 14:18:29.000000000 -0500
@@ -43,19 +43,10 @@
pop ss
pop bp
ret
-#endasm
-#endif
-void printsp(void)
-{
-#ifndef S_SPLINT_S
-#asm
-
- .data
-msg: .ascii "SP=%x:%x\n"
- .byte 0
+ .globl _printsp
- .text
+_printsp:
push sp
push ss
push #msg
@@ -65,6 +56,9 @@
pop ax
ret
+ .data
+msg: .ascii "SP=%x:%x\n"
+ .byte 0
+
#endasm
#endif
-}
diff -Nur elks.orig/arch/i86/kernel/syscall.dat elks/arch/i86/kernel/syscall.dat
--- elks.orig/arch/i86/kernel/syscall.dat 2015-04-26 11:39:15.000000000 -0500
+++ elks/arch/i86/kernel/syscall.dat 2015-06-01 18:57:31.000000000 -0500
@@ -60,7 +60,7 @@
mkdir +39 2
rmdir +40 1
dup +41 1 . There is a fcntl lib function too.
-pipe +42 1
+pipe +42 1 = CONFIG_PIPE
times 43 2 * 2nd arg is pointer for long ret val.
profil 44 4 @
dup2 +45 2
@@ -81,18 +81,18 @@
umask +60 1
settimeofday +61 2
gettimeofday +62 2
-select +63 5 . 5 paramaters is possible
+select +63 5 . 5 paramaters is possible
readdir +64 3 *
insmod 65 1 - Removed support for modules
fchown +66 3
-dlload +67 2
+dlload +67 2 - Removed support for dynamic libraries
setsid +68 0
-socket +69 3
-bind +70 3
-listen +71 2
-accept +72 3
-connect +73 3
-knlvsn +74 1 = CONFIG_SYS_VERSION
+socket +69 3 = CONFIG_SOCKET
+bind +70 3 = CONFIG_SOCKET
+listen +71 2 = CONFIG_SOCKET
+accept +72 3 = CONFIG_SOCKET
+connect +73 3 = CONFIG_SOCKET
+knlvsn +74 1 = CONFIG_SYS_VERSION
#
# Name No Args Flag&comment
#
diff -Nur elks.orig/arch/i86/kernel/system.c elks/arch/i86/kernel/system.c
--- elks.orig/arch/i86/kernel/system.c 2015-06-01 18:34:28.000000000 -0500
+++ elks/arch/i86/kernel/system.c 2015-06-01 17:23:05.000000000 -0500
@@ -12,21 +12,6 @@
extern long int basmem;
#endif
-/* Stubs for functions needed elsewhere */
-
-void hard_reset_now(void)
-{
-#ifndef S_SPLINT_S
-#asm
- mov ax,#0x40 ! No memory check on reboot
- mov ds, ax
- mov [0x72],#0x1234
- jmp #0xffff:0
-
-#endasm
-#endif
-}
-
void setup_arch(seg_t *start, seg_t *end)
{
#ifdef CONFIG_COMPAQ_FAST
@@ -49,7 +34,7 @@
#ifndef CONFIG_ARCH_SIBO
- *end = (seg_t)(setupw(0x2a) << 6 - RAM_REDUCE);
+ *end = (seg_t)((setupw(0x2a) << 6) - RAM_REDUCE);
/* XXX plac: free root ram disk */
@@ -70,42 +55,18 @@
}
+/* Stubs for functions needed elsewhere */
+
#ifndef S_SPLINT_S
#asm
+ export _hard_reset_now
- export _sys_dlload
-
-_sys_dlload:
-
-#ifndef CONFIG_SOCKET
+_hard_reset_now:
- export _sys_socket
-
-_sys_socket:
-
- export _sys_bind
-
-_sys_bind:
-
- export _sys_listen
-
-_sys_listen:
-
- export _sys_accept
-
-_sys_accept:
-
- export _sys_connect
-
-_sys_connect:
-
-#endif
-
- export _no_syscall
-
-_no_syscall:
- mov ax,#-38
- ret
+ mov ax,#0x40 ! No memory check on reboot
+ mov ds, ax
+ mov [0x72],#0x1234
+ jmp #0xffff:0
#endasm
#endif
diff -Nur elks.orig/fs/minix/dir.c elks/fs/minix/dir.c
--- elks.orig/fs/minix/dir.c 2015-06-01 18:34:09.000000000 -0500
+++ elks/fs/minix/dir.c 2015-06-01 14:18:29.000000000 -0500
@@ -16,7 +16,7 @@
#include <arch/segment.h>
-static size_t minix_dir_read(struct inode *inode, struct file *filp, char *buf, int count)
+static size_t minix_dir_read(struct inode *inode,struct file *filp,char *buf,size_t count)
{
return -EISDIR;
}
diff -Nur elks.orig/fs/pipe.c elks/fs/pipe.c
--- elks.orig/fs/pipe.c 2015-04-26 11:39:15.000000000 -0500
+++ elks/fs/pipe.c 2015-06-01 17:43:02.000000000 -0500
@@ -407,11 +407,4 @@
return verified_memcpy_tofs(filedes, fd, 2 * sizeof(int));
}
-#else
-
-int sys_pipe(unsigned int *filedes)
-{
- return -ENOSYS;
-}
-
#endif
diff -Nur elks.orig/include/arch/io.h elks/include/arch/io.h
--- elks.orig/include/arch/io.h 2015-06-01 18:34:28.000000000 -0500
+++ elks/include/arch/io.h 2015-06-01 14:18:29.000000000 -0500
@@ -1,6 +1,8 @@
#ifndef LX86_ARCH_IO_H
#define LX86_ARCH_IO_H
+extern void bell(void);
+
#ifdef __BCC__
extern void outb(unsigned char, void *);
extern void outb_p(unsigned char, void *);
@@ -12,8 +14,55 @@
extern unsigned short int inw(void *);
extern unsigned short int inw_p(void *);
+#endif
+
+#ifdef __ia16__
+#define outb(value,port) \
+__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port))
+
+
+#define inb(port) ({ \
+unsigned char _v; \
+__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \
+_v; \
+})
+
+#define outw(value,port) \
+__asm__ ("outw %%ax,%%dx"::"a" (value),"d" (port))
+
+
+#define inw(port) ({ \
+unsigned char _v; \
+__asm__ volatile ("inw %%dx,%%ax":"=a" (_v):"d" (port)); \
+_v; \
+})
+
+#define outb_p(value,port) \
+__asm__ volatile ("outb %%al,%%dx\n" \
+ "outb %%al,$0x80\n" \
+ ::"a" (value),"d" (port))
+
+#define inb_p(port) ({ \
+unsigned char _v; \
+__asm__ volatile ("inb %%dx,%%al\n" \
+ "outb %%al,$0x80\n" \
+ :"=a" (_v):"d" (port)); \
+_v; \
+})
+
+#define outw_p(value,port) \
+__asm__ volatile ("outw %%ax,%%dx\n" \
+ "outb %%al,$0x80\n" \
+ ::"a" (value),"d" (port))
+
+#define inw_p(port) ({ \
+unsigned char _v; \
+__asm__ volatile ("inw %%dx,%%ax\n" \
+ "outb %%al,$0x80\n" \
+ :"=a" (_v):"d" (port)); \
+_v; \
+})
-extern void bell(void);
#endif
#ifdef __WATCOMC__
diff -Nur elks.orig/include/linuxmt/fs.h elks/include/linuxmt/fs.h
--- elks.orig/include/linuxmt/fs.h 2015-06-01 18:34:18.000000000 -0500
+++ elks/include/linuxmt/fs.h 2015-06-01 14:18:29.000000000 -0500
@@ -303,8 +303,8 @@
struct file_operations {
loff_t (*lseek) ();
- size_t (*read) ();
- size_t (*write) ();
+ size_t (*read)(struct inode *,struct file *,char *,size_t);
+ size_t (*write)(struct inode *,struct file *,char *,size_t);
int (*readdir) ();
int (*select) ();
int (*ioctl) ();
next reply other threads:[~2015-06-02 5:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-02 5:10 Juan Perez-Sanchez [this message]
2015-06-02 15:10 ` [PATCH] Changes to reduce warnings using ia16-unknown-elks-gcc Juan Perez-Sanchez
2015-06-13 14:25 ` Jody Bruchon
2015-06-13 14:53 ` Jody Bruchon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAD6VGubCsua=nTM7YENH38_2JcJm7OE5FYfDngGfQH5=TD2_rg@mail.gmail.com' \
--to=lithoxs@gmail.com \
--cc=linux-8086@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).