Sun Dec 13 04:47:46 2009 UTC ()
Pullup from matt-nb5-mips64.

For each syscall, add a flag for the return value or an argument indicating
that it is a 64-bit argument.  Also include the number of 64-bit arguments.
In theory this could get most of the code in compat/netbsd32/netbsd32_netbsd.c
but not at the moment due to multiply defined structures.


(matt)
diff -r1.91 -r1.92 src/sys/kern/makesyscalls.sh
diff -r1.237 -r1.238 src/sys/sys/systm.h

cvs diff -r1.91 -r1.92 src/sys/kern/makesyscalls.sh (expand / switch to unified diff)

--- src/sys/kern/makesyscalls.sh 2009/11/26 17:23:48 1.91
+++ src/sys/kern/makesyscalls.sh 2009/12/13 04:47:45 1.92
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /bin/sh - 1#! /bin/sh -
2# $NetBSD: makesyscalls.sh,v 1.91 2009/11/26 17:23:48 pooka Exp $ 2# $NetBSD: makesyscalls.sh,v 1.92 2009/12/13 04:47:45 matt Exp $
3# 3#
4# Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou 4# Copyright (c) 1994, 1996, 2000 Christopher G. Demetriou
5# All rights reserved. 5# All rights reserved.
6# 6#
7# Redistribution and use in source and binary forms, with or without 7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions 8# modification, are permitted provided that the following conditions
9# are met: 9# are met:
10# 1. Redistributions of source code must retain the above copyright 10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer. 11# notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright 12# 2. Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the 13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution. 14# documentation and/or other materials provided with the distribution.
15# 3. All advertising materials mentioning features or use of this software 15# 3. All advertising materials mentioning features or use of this software
@@ -430,26 +430,32 @@ function parseline() { @@ -430,26 +430,32 @@ function parseline() {
430 if (rumpable == 1 && fbase == "pipe") { 430 if (rumpable == 1 && fbase == "pipe") {
431 rumpable = 0; 431 rumpable = 0;
432 rumphaspipe = 1; 432 rumphaspipe = 1;
433 } 433 }
434 434
435 funcstdname=fprefix "_" fbase 435 funcstdname=fprefix "_" fbase
436 if (fcompat != "") { 436 if (fcompat != "") {
437 funcname=fprefix "___" fbase "" fcompat 437 funcname=fprefix "___" fbase "" fcompat
438 wantrename=1 438 wantrename=1
439 } else { 439 } else {
440 funcname=funcstdname 440 funcname=funcstdname
441 wantrename=0 441 wantrename=0
442 } 442 }
 443 if (returntype == "quad_t" || returntype == "off_t") {
 444 if (sycall_flags == "0")
 445 sycall_flags = "SYCALL_RET_64";
 446 else
 447 sycall_flags = "SYCALL_RET_64 | " sycall_flags;
 448 }
443 449
444 if (funcalias == "") { 450 if (funcalias == "") {
445 funcalias=funcname 451 funcalias=funcname
446 sub(/^([^_]+_)*sys_/, "", funcalias) 452 sub(/^([^_]+_)*sys_/, "", funcalias)
447 } 453 }
448 f++ 454 f++
449 455
450 if ($f != "(") 456 if ($f != "(")
451 parserr($f, "(") 457 parserr($f, "(")
452 f++ 458 f++
453 459
454 argc=0; 460 argc=0;
455 argalign=0; 461 argalign=0;
@@ -463,26 +469,27 @@ function parseline() { @@ -463,26 +469,27 @@ function parseline() {
463 } 469 }
464 470
465 # some system calls (open() and fcntl()) can accept a variable 471 # some system calls (open() and fcntl()) can accept a variable
466 # number of arguments. If syscalls accept a variable number of 472 # number of arguments. If syscalls accept a variable number of
467 # arguments, they must still have arguments specified for 473 # arguments, they must still have arguments specified for
468 # the remaining argument "positions," because of the way the 474 # the remaining argument "positions," because of the way the
469 # kernel system call argument handling works. 475 # kernel system call argument handling works.
470 # 476 #
471 # Indirect system calls, e.g. syscall(), are exceptions to this 477 # Indirect system calls, e.g. syscall(), are exceptions to this
472 # rule, since they are handled entirely by machine-dependent code 478 # rule, since they are handled entirely by machine-dependent code
473 # and do not need argument structures built. 479 # and do not need argument structures built.
474 480
475 isvarargs = 0; 481 isvarargs = 0;
 482 args64 = 0;
476 while (f <= end) { 483 while (f <= end) {
477 if ($f == "...") { 484 if ($f == "...") {
478 f++; 485 f++;
479 isvarargs = 1; 486 isvarargs = 1;
480 varargc = argc; 487 varargc = argc;
481 continue; 488 continue;
482 } 489 }
483 argc++ 490 argc++
484 argtype[argc]="" 491 argtype[argc]=""
485 oldf="" 492 oldf=""
486 while (f < end && $(f+1) != ",") { 493 while (f < end && $(f+1) != ",") {
487 if (argtype[argc] != "" && oldf != "*") 494 if (argtype[argc] != "" && oldf != "*")
488 argtype[argc] = argtype[argc]" "; 495 argtype[argc] = argtype[argc]" ";
@@ -491,29 +498,38 @@ function parseline() { @@ -491,29 +498,38 @@ function parseline() {
491 f++ 498 f++
492 } 499 }
493 if (argtype[argc] == "") 500 if (argtype[argc] == "")
494 parserr($f, "argument definition") 501 parserr($f, "argument definition")
495 if (argtype[argc] == "off_t" \ 502 if (argtype[argc] == "off_t" \
496 || argtype[argc] == "dev_t" \ 503 || argtype[argc] == "dev_t" \
497 || argtype[argc] == "time_t") { 504 || argtype[argc] == "time_t") {
498 if ((argalign % 2) != 0 && sysalign && 505 if ((argalign % 2) != 0 && sysalign &&
499 funcname != "sys_posix_fadvise") # XXX for now 506 funcname != "sys_posix_fadvise") # XXX for now
500 parserr($f, "a padding argument") 507 parserr($f, "a padding argument")
501 } else { 508 } else {
502 argalign++; 509 argalign++;
503 } 510 }
 511 if (argtype[argc] == "quad_t" || argtype[argc] == "off_t") {
 512 if (sycall_flags == "0")
 513 sycall_flags = "SYCALL_ARG"argc-1"_64";
 514 else
 515 sycall_flags = "SYCALL_ARG"argc-1"_64 | " sycall_flags;
 516 args64++;
 517 }
504 argname[argc]=$f; 518 argname[argc]=$f;
505 f += 2; # skip name, and any comma 519 f += 2; # skip name, and any comma
506 } 520 }
 521 if (args64 > 0)
 522 sycall_flags = "SYCALL_NARGS64_VAL("args64") | " sycall_flags;
507 # must see another argument after varargs notice. 523 # must see another argument after varargs notice.
508 if (isvarargs) { 524 if (isvarargs) {
509 if (argc == varargc) 525 if (argc == varargc)
510 parserr($f, "argument definition") 526 parserr($f, "argument definition")
511 } else 527 } else
512 varargc = argc; 528 varargc = argc;
513} 529}
514 530
515function printproto(wrap) { 531function printproto(wrap) {
516 printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias, 532 printf("/* syscall: \"%s%s\" ret: \"%s\" args:", wrap, funcalias,
517 returntype) > sysnumhdr 533 returntype) > sysnumhdr
518 for (i = 1; i <= varargc; i++) 534 for (i = 1; i <= varargc; i++)
519 printf(" \"%s\"", argtype[i]) > sysnumhdr 535 printf(" \"%s\"", argtype[i]) > sysnumhdr

cvs diff -r1.237 -r1.238 src/sys/sys/systm.h (expand / switch to unified diff)

--- src/sys/sys/systm.h 2009/11/03 05:23:28 1.237
+++ src/sys/sys/systm.h 2009/12/13 04:47:45 1.238
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: systm.h,v 1.237 2009/11/03 05:23:28 dyoung Exp $ */ 1/* $NetBSD: systm.h,v 1.238 2009/12/13 04:47:45 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1982, 1988, 1991, 1993 4 * Copyright (c) 1982, 1988, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -118,27 +118,42 @@ extern struct sysent { /* system call t @@ -118,27 +118,42 @@ extern struct sysent { /* system call t
118 short sy_argsize; /* total size of arguments */ 118 short sy_argsize; /* total size of arguments */
119 int sy_flags; /* flags. see below */ 119 int sy_flags; /* flags. see below */
120 sy_call_t *sy_call; /* implementing function */ 120 sy_call_t *sy_call; /* implementing function */
121} sysent[]; 121} sysent[];
122extern int nsysent; 122extern int nsysent;
123#if BYTE_ORDER == BIG_ENDIAN 123#if BYTE_ORDER == BIG_ENDIAN
124#define SCARG(p,k) ((p)->k.be.datum) /* get arg from args pointer */ 124#define SCARG(p,k) ((p)->k.be.datum) /* get arg from args pointer */
125#elif BYTE_ORDER == LITTLE_ENDIAN 125#elif BYTE_ORDER == LITTLE_ENDIAN
126#define SCARG(p,k) ((p)->k.le.datum) /* get arg from args pointer */ 126#define SCARG(p,k) ((p)->k.le.datum) /* get arg from args pointer */
127#else 127#else
128#error "what byte order is this machine?" 128#error "what byte order is this machine?"
129#endif 129#endif
130 130
131#define SYCALL_INDIRECT 0x0002 /* indirect (ie syscall() or __syscall()) */ 131#define SYCALL_INDIRECT 0x0000002 /* indirect (ie syscall() or __syscall()) */
 132#define SYCALL_NARGS64_MASK 0x000f000 /* count of 64bit args */
 133#define SYCALL_RET_64 0x0010000 /* retval is a 64bit integer value */
 134#define SYCALL_ARG0_64 0x0020000
 135#define SYCALL_ARG1_64 0x0040000
 136#define SYCALL_ARG2_64 0x0080000
 137#define SYCALL_ARG3_64 0x0100000
 138#define SYCALL_ARG4_64 0x0200000
 139#define SYCALL_ARG5_64 0x0400000
 140#define SYCALL_ARG6_64 0x0800000
 141#define SYCALL_ARG7_64 0x1000000
 142#define SYCALL_RET_64_P(sy) ((sy)->sy_flags & SYCALL_RET_64)
 143#define SYCALL_ARG_64_P(sy, n) ((sy)->sy_flags & (SYCALL_ARG0_64 << (n)))
 144#define SYCALL_ARG_64_MASK(sy) (((sy)->sy_flags >> 17) & 0xff)
 145#define SYCALL_NARGS64(sy) (((sy)->sy_flags >> 12) & 0x0f)
 146#define SYCALL_NARGS64_VAL(n) ((n) << 12)
132 147
133extern int boothowto; /* reboot flags, from console subsystem */ 148extern int boothowto; /* reboot flags, from console subsystem */
134#define bootverbose (boothowto & AB_VERBOSE) 149#define bootverbose (boothowto & AB_VERBOSE)
135#define bootquiet (boothowto & AB_QUIET) 150#define bootquiet (boothowto & AB_QUIET)
136 151
137extern void (*v_putc)(int); /* Virtual console putc routine */ 152extern void (*v_putc)(int); /* Virtual console putc routine */
138 153
139/* 154/*
140 * General function declarations. 155 * General function declarations.
141 */ 156 */
142void voidop(void); 157void voidop(void);
143int nullop(void *); 158int nullop(void *);
144int enodev(void); 159int enodev(void);