From owner-freebsd-emulation@FreeBSD.ORG Thu Apr 27 21:48:29 2006 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 47EEE16A402 for ; Thu, 27 Apr 2006 21:48:29 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail2.ambrisko.com (mail2.ambrisko.com [64.174.51.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id E207343D48 for ; Thu, 27 Apr 2006 21:48:28 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by mail2.ambrisko.com with ESMTP; 27 Apr 2006 14:47:38 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.12.11/8.12.11) with ESMTP id k3RLmSEf041070 for ; Thu, 27 Apr 2006 14:48:28 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.12.11/8.12.11/Submit) id k3RLmSOm041069 for freebsd-emulation@FreeBSD.ORG; Thu, 27 Apr 2006 14:48:28 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200604272148.k3RLmSOm041069@ambrisko.com> To: freebsd-emulation@FreeBSD.ORG Date: Thu, 27 Apr 2006 14:48:28 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Cc: Subject: Linux emulation enhancement to emulate device nodes and some SCSI stuff X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Apr 2006 21:48:29 -0000 To get the LSI RAID SAS to work under Linux emulation we need to emulate more of Linux type stuff. I've put patches up at: http://www.ambrisko.com/doug/linux.patches I've added back the proc/devices to the emulator although really emulated since with devfs are majors are not as Linux app's expect. So I've used a "linux_ioctl_handle" type paradigm to add a new "linux_device_handle" thing. Each entry is of type: struct linux_device_handler { char *bsd_driver_name; char *linux_driver_name; char *bsd_device_name; char *linux_device_name; int linux_major; int linux_minor; int linux_char_device; }; An example of usage is: static struct linux_device_handler mfi_device_handler = { "mfi", "megaraid_sas", "mfi0", "megaraid_sas_ioctl_node", -1, 0, 1}; SYSINIT (mfi_register2, SI_SUB_KLD, SI_ORDER_MIDDLE, linux_device_register_handler, &mfi_device_handler); SYSUNINIT(mfi_unregister2, SI_SUB_KLD, SI_ORDER_MIDDLE, linux_device_unregister_handler, &mfi_device_handler); The -1 major means allocate dynamically. This then shows up in proc/devices as: Character devices: 1 null 200 megaraid_sas_ioctl_node Block devices: I needed a entry to /dev/null so I created a static entry for that. In the new proc/sys there is a class & devices tree. The devices tree runs the PCI space sort-of like Linux and builds a tree. The class/scsi_host links into that tree. It only fills in things for PCI storage classes and fills in the "proc_name" for the driver if known like: %cat class/scsi_host/host0/proc_name megaraid_sas %ls -l class/scsi_host/host0 total 0 lr--r--r-- 1 root wheel 0 Apr 27 15:07 device -> ../../../devices/pci0000:03/0001:00.0/0002:0e.0/host0 -r--r--r-- 1 root wheel 0 Apr 27 15:07 proc_name %ls -l devices/pci0000:03/0001:00.0/0002:0e.0 total 0 dr-xr-xr-x 1 root wheel 0 Apr 27 15:07 host0 % I had to add code to linux_stat stuff to intercept and return the expected major/minor number if a device_handler was defined. With this and some changes to mfi(4) driver I can run the Linux MegaCli binary from LSI on FreeBSD. Please let me know how this patch looks. Note this is following the Linux 2.6 style. Doug A.