code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
/*
* (c) 2015 CenturyLink. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.centurylink.cloud.sdk.policy.services.dsl;
import com.centurylink.cloud.sdk.policy.services.client.AutoscalePolicyClient;
import com.centurylink.cloud.sdk.policy.services.client.domain.autoscale.SetAutoscalePolicyRequest;
import com.centurylink.cloud.sdk.policy.services.client.domain.autoscale.AutoscalePolicyMetadata;
import com.centurylink.cloud.sdk.policy.services.dsl.domain.autoscale.filter.AutoscalePolicyFilter;
import com.centurylink.cloud.sdk.policy.services.dsl.domain.autoscale.refs.AutoscalePolicy;
import com.centurylink.cloud.sdk.base.services.dsl.domain.queue.OperationFuture;
import com.centurylink.cloud.sdk.base.services.dsl.domain.queue.job.future.JobFuture;
import com.centurylink.cloud.sdk.base.services.dsl.domain.queue.job.future.NoWaitingJobFuture;
import com.centurylink.cloud.sdk.base.services.dsl.domain.queue.job.future.ParallelJobsFuture;
import com.centurylink.cloud.sdk.core.services.QueryService;
import com.centurylink.cloud.sdk.server.services.dsl.ServerService;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.filters.ServerFilter;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.refs.Server;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
import static com.centurylink.cloud.sdk.core.function.Predicates.alwaysTrue;
import static com.centurylink.cloud.sdk.core.function.Predicates.combine;
import static com.centurylink.cloud.sdk.core.function.Predicates.in;
import static com.centurylink.cloud.sdk.core.preconditions.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;
public class AutoscalePolicyService implements QueryService<AutoscalePolicy, AutoscalePolicyFilter, AutoscalePolicyMetadata> {
private final AutoscalePolicyClient autoscalePolicyClient;
private final ServerService serverService;
public AutoscalePolicyService(AutoscalePolicyClient autoscalePolicyClient, ServerService serverService) {
this.autoscalePolicyClient = autoscalePolicyClient;
this.serverService = serverService;
}
/**
* {@inheritDoc}
*/
@Override
public Stream<AutoscalePolicyMetadata> findLazy(AutoscalePolicyFilter filter) {
checkNotNull(filter, "Filter must be not a null");
return autoscalePolicyClient
.getAutoscalePolicies()
.stream()
.filter(filter.getPredicate())
.filter(
filter.getIds().size() > 0 ?
combine(AutoscalePolicyMetadata::getId, in(filter.getIds())) :
alwaysTrue()
);
}
/**
* Set autoscale policy on server
*
* @param autoscalePolicy autoscale policy
* @param server server
* @return OperationFuture wrapper for autoscalePolicy
*/
public OperationFuture<Server> setAutoscalePolicyOnServer(AutoscalePolicy autoscalePolicy, Server server) {
autoscalePolicyClient.setAutoscalePolicyOnServer(
serverService
.findByRef(server)
.getId(),
new SetAutoscalePolicyRequest()
.id(
findByRef(autoscalePolicy).getId()
)
);
return new OperationFuture<>(server, new NoWaitingJobFuture());
}
/**
* set autoscale policy on servers
*
* @param autoscalePolicy autoscale policy
* @param serverList server list
* @return OperationFuture wrapper for server list
*/
public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
List<Server> serverList
) {
List<JobFuture> jobs = serverList
.stream()
.map(server -> setAutoscalePolicyOnServer(autoscalePolicy, server).jobFuture())
.collect(toList());
return
new OperationFuture<>(
serverList,
new ParallelJobsFuture(jobs)
);
}
/**
* set autoscale policy on servers
*
* @param autoscalePolicy autoscale policy
* @param servers servers
* @return OperationFuture wrapper for servers
*/
public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
Server... servers
) {
return setAutoscalePolicyOnServer(autoscalePolicy, Arrays.asList(servers));
}
/**
* set autoscale policy on filtered servers
*
* @param autoscalePolicy autoscale policy
* @param serverFilter server filter
* @return OperationFuture wrapper for servers
*/
public OperationFuture<List<Server>> setAutoscalePolicyOnServer(
AutoscalePolicy autoscalePolicy,
ServerFilter serverFilter
) {
return
setAutoscalePolicyOnServer(
autoscalePolicy,
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
/**
* get autoscale policy on server
*
* @param server server
* @return AutoscalePolicyMetadata
*/
public AutoscalePolicyMetadata getAutoscalePolicyOnServer(Server server) {
return
autoscalePolicyClient
.getAutoscalePolicyOnServer(
serverService
.findByRef(server)
.getId()
);
}
/**
* remove autoscale policy on server
*
* @param server server
* @return OperationFuture wrapper for server
*/
public OperationFuture<Server> removeAutoscalePolicyOnServer(Server server) {
autoscalePolicyClient
.removeAutoscalePolicyOnServer(
serverService.findByRef(server).getId()
);
return new OperationFuture<>(server, new NoWaitingJobFuture());
}
/**
* remove autoscale policy on servers
*
* @param serverList server list
* @return OperationFuture wrapper for server list
*/
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(List<Server> serverList) {
List<JobFuture> jobs = serverList
.stream()
.map(server -> removeAutoscalePolicyOnServer(server).jobFuture())
.collect(toList());
return
new OperationFuture<>(
serverList,
new ParallelJobsFuture(jobs)
);
}
/**
* remove autoscale policy on servers
*
* @param servers servers
* @return OperationFuture wrapper for servers
*/
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(Server... servers) {
return removeAutoscalePolicyOnServer(Arrays.asList(servers));
}
/**
* remove autoscale policy on filtered servers
*
* @param serverFilter server filter
* @return OperationFuture wrapper for servers
*/
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(ServerFilter serverFilter) {
return
removeAutoscalePolicyOnServer(
serverService
.findLazy(serverFilter)
.map(serverMetadata -> Server.refById(serverMetadata.getId()))
.collect(toList())
);
}
}
| CenturyLinkCloud/clc-java-sdk | sdk/src/main/java/com/centurylink/cloud/sdk/policy/services/dsl/AutoscalePolicyService.java | Java | apache-2.0 | 8,024 | [
30522,
1013,
1008,
1008,
1006,
1039,
1007,
2325,
2301,
13767,
1012,
2035,
2916,
9235,
30524,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
1008,
2017,
2089,
6855,
1037,
6100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
'use strict';
angular.module('donetexampleApp')
.service('ParseLinks', function () {
this.parse = function (header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
// Split parts by comma
var parts = header.split(',');
var links = {};
// Parse each part into a named link
angular.forEach(parts, function (p) {
var section = p.split(';');
if (section.length != 2) {
throw new Error("section could not be split on ';'");
}
var url = section[0].replace(/<(.*)>/, '$1').trim();
var queryString = {};
url.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
var page = queryString['page'];
if( angular.isString(page) ) {
page = parseInt(page);
}
var name = section[1].replace(/rel="(.*)"/, '$1').trim();
links[name] = page;
});
return links;
}
});
| CyberCastle/DoNetExample | DoNetExample.Gui/scripts/components/util/parse-links.service.js | JavaScript | apache-2.0 | 1,252 | [
30522,
1005,
2224,
9384,
1005,
1025,
16108,
1012,
11336,
1006,
1005,
2589,
2618,
18684,
23344,
29098,
1005,
1007,
1012,
2326,
1006,
1005,
11968,
11246,
19839,
2015,
1005,
1010,
3853,
1006,
1007,
1063,
2023,
1012,
11968,
3366,
1027,
3853,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* Copyright (c) 2009 Andrey Loskutov.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributor: Andrey Loskutov - initial API and implementation
*******************************************************************************/
package de.loskutov.anyedit.actions.replace;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.Writer;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
import de.loskutov.anyedit.AnyEditToolsPlugin;
import de.loskutov.anyedit.IAnyEditConstants;
import de.loskutov.anyedit.compare.ContentWrapper;
import de.loskutov.anyedit.ui.editor.AbstractEditor;
import de.loskutov.anyedit.util.EclipseUtils;
/**
* @author Andrey
*/
public abstract class ReplaceWithAction extends AbstractHandler implements IObjectActionDelegate {
protected ContentWrapper selectedContent;
protected AbstractEditor editor;
public ReplaceWithAction() {
super();
editor = new AbstractEditor(null);
}
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
Action dummyAction = new Action(){
@Override
public String getId() {
return event.getCommand().getId();
}
};
setActivePart(dummyAction, activePart);
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
selectionChanged(dummyAction, currentSelection);
if(dummyAction.isEnabled()) {
run(dummyAction);
}
return null;
}
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
if (targetPart instanceof IEditorPart) {
editor = new AbstractEditor((IEditorPart) targetPart);
} else {
editor = new AbstractEditor(null);
}
}
@Override
public void run(IAction action) {
InputStream stream = createInputStream();
if (stream == null) {
return;
}
replace(stream);
}
private void replace(InputStream stream) {
if(selectedContent == null || !selectedContent.isModifiable()){
return;
}
IDocument document = editor.getDocument();
if (!editor.isDisposed() && document != null) {
// replace selection only
String text = getChangedCompareText(stream);
ITextSelection selection = editor.getSelection();
if (selection == null || selection.getLength() == 0) {
document.set(text);
} else {
try {
document.replace(selection.getOffset(), selection.getLength(), text);
} catch (BadLocationException e) {
AnyEditToolsPlugin.logError("Can't update text in editor", e);
}
}
return;
}
replace(selectedContent, stream);
}
private String getChangedCompareText(InputStream stream) {
StringWriter sw = new StringWriter();
copyStreamToWriter(stream, sw);
return sw.toString();
}
private void replace(ContentWrapper content, InputStream stream) {
IFile file = content.getIFile();
if (file == null || file.getLocation() == null) {
saveExternalFile(content, stream);
return;
}
try {
if (!file.exists()) {
file.create(stream, true, new NullProgressMonitor());
} else {
ITextFileBuffer buffer = EclipseUtils.getBuffer(file);
try {
if (AnyEditToolsPlugin.getDefault().getPreferenceStore().getBoolean(
IAnyEditConstants.SAVE_DIRTY_BUFFER)) {
if (buffer != null && buffer.isDirty()) {
buffer.commit(new NullProgressMonitor(), false);
}
}
if (buffer != null) {
buffer.validateState(new NullProgressMonitor(),
AnyEditToolsPlugin.getShell());
}
} finally {
EclipseUtils.disconnectBuffer(buffer);
}
file.setContents(stream, true, true, new NullProgressMonitor());
}
} catch (CoreException e) {
AnyEditToolsPlugin.errorDialog("Can't replace file content: " + file, e);
} finally {
try {
stream.close();
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
}
}
private void copyStreamToWriter(InputStream stream, Writer writer){
InputStreamReader in = null;
try {
in = new InputStreamReader(stream, editor.computeEncoding());
BufferedReader br = new BufferedReader(in);
int i;
while ((i = br.read()) != -1) {
writer.write(i);
}
writer.flush();
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error during reading/writing streams", e);
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Failed to close stream", e);
}
}
}
private void saveExternalFile(ContentWrapper content, InputStream stream) {
File file2 = null;
IFile iFile = content.getIFile();
if (iFile != null) {
file2 = new File(iFile.getFullPath().toOSString());
} else {
file2 = content.getFile();
}
if (!file2.exists()) {
try {
file2.createNewFile();
} catch (IOException e) {
AnyEditToolsPlugin.errorDialog("Can't create file: " + file2, e);
return;
}
}
boolean canWrite = file2.canWrite();
if (!canWrite) {
AnyEditToolsPlugin.errorDialog("File is read-only: " + file2);
return;
}
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(file2));
copyStreamToWriter(stream, bw);
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error on saving to file: " + file2, e);
return;
} finally {
try {
if(bw != null) {
bw.close();
}
} catch (IOException e) {
AnyEditToolsPlugin.logError("Error on saving to file: " + file2, e);
}
}
if (iFile != null) {
try {
iFile.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
} catch (CoreException e) {
AnyEditToolsPlugin.logError("Failed to refresh file: " + iFile, e);
}
}
}
abstract protected InputStream createInputStream();
@Override
public void selectionChanged(IAction action, ISelection selection) {
if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
if(!editor.isDisposed()){
selectedContent = ContentWrapper.create(editor);
}
action.setEnabled(selectedContent != null);
return;
}
IStructuredSelection sSelection = (IStructuredSelection) selection;
Object firstElement = sSelection.getFirstElement();
if(!editor.isDisposed()) {
selectedContent = ContentWrapper.create(editor);
} else {
selectedContent = ContentWrapper.create(firstElement);
}
action.setEnabled(selectedContent != null && sSelection.size() == 1);
}
}
| iloveeclipse/anyedittools | AnyEditTools/src/de/loskutov/anyedit/actions/replace/ReplaceWithAction.java | Java | epl-1.0 | 9,434 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdlib.h>
#include <libintl.h>
#include <locale.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "gdm-a11y-preferences-dialog.h"
int
main (int argc, char *argv[])
{
GtkWidget *dialog;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
setlocale (LC_ALL, "");
gtk_init (&argc, &argv);
dialog = gdm_a11y_preferences_dialog_new ();
/*gtk_widget_set_size_request (dialog, 480, 128);*/
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return 0;
}
| gcampax/gdm | gui/simple-greeter/test-a11y-preferences.c | C | gpl-2.0 | 1,618 | [
30522,
1013,
1008,
1011,
1008,
1011,
5549,
1024,
1039,
1025,
21628,
1011,
9381,
1024,
1022,
1025,
27427,
4765,
1011,
21628,
2015,
1011,
5549,
1024,
9152,
2140,
1025,
1039,
1011,
3937,
1011,
16396,
1024,
1022,
1011,
1008,
1011,
1008,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit;
namespace MR.AspNetCore.Jobs.Server
{
public class InfiniteRetryProcessorTest
{
[Fact]
public async Task Process_ThrowingProcessingCanceledException_Returns()
{
// Arrange
var services = new ServiceCollection();
services.AddLogging();
var loggerFactory = services.BuildServiceProvider().GetService<ILoggerFactory>();
var inner = new ThrowsProcessingCanceledExceptionProcessor();
var p = new InfiniteRetryProcessor(inner, loggerFactory);
var context = new ProcessingContext();
// Act
await p.ProcessAsync(context);
}
private class ThrowsProcessingCanceledExceptionProcessor : IProcessor
{
public Task ProcessAsync(ProcessingContext context)
{
throw new OperationCanceledException();
}
}
}
}
| mrahhal/MR.AspNetCore.Jobs | test/MR.AspNetCore.Jobs.Tests/Server/InfiniteRetryProcessorTest.cs | C# | mit | 891 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
7513,
1012,
14305,
1012,
24394,
2378,
20614,
3258,
1025,
2478,
7513,
1012,
14305,
1012,
15899,
1025,
2478,
15990,
3490,
2102,
1025,
3415,
15327,
2720,
1012,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2015-2016 USEF Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package energy.usef.core.service.helper;
import energy.usef.core.controller.DefaultIncomingMessageController;
import energy.usef.core.controller.IncomingMessageController;
import energy.usef.core.controller.factory.IncomingControllerClassFactory;
import energy.usef.core.data.xml.bean.message.Message;
import energy.usef.core.exception.BusinessException;
import energy.usef.core.service.business.error.MessageControllerError;
import energy.usef.core.util.XMLUtil;
import java.util.Iterator;
import javax.ejb.Stateless;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This service is designed to route incoming XML messages to corresponding controllers for processing.
*/
@Stateless
public class DispatcherHelperService {
private static final Logger LOGGER = LoggerFactory.getLogger(DispatcherHelperService.class);
@Inject
private BeanManager beanManager;
@Inject
private DefaultIncomingMessageController defaultIncomingMessageController;
/**
* The method routes an incoming message to a corresponding controller and invokes a required action.
*
* @param xml xml message
* @throws BusinessException
*/
public void dispatch(String xml) throws BusinessException {
// transform
Object xmlObject = XMLUtil.xmlToMessage(xml);
if (!(xmlObject instanceof Message)) {
throw new BusinessException(MessageControllerError.XML_NOT_CONVERTED_TO_OBJECT);
}
process(xml, (Message) xmlObject);
}
private void process(String xml, Message message) throws BusinessException {
IncomingMessageController<Message> controller = null;
Class<?> controllerClass = IncomingControllerClassFactory.getControllerClass(message.getClass());
controller = getController(controllerClass);
if (controller == null) {
LOGGER.error("No controller is found for the message of type: {}, default controller will be used", message.getClass());
controller = defaultIncomingMessageController;
}
// process the message
controller.execute(xml, message);
}
@SuppressWarnings("unchecked")
private IncomingMessageController<Message> getController(Class<?> clazz) {
if (clazz == null) {
return null;
}
Iterator<Bean<?>> iterator = beanManager.getBeans(clazz).iterator();
if (iterator.hasNext()) {
Bean<?> bean = iterator.next();
CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
return (IncomingMessageController<Message>) beanManager.getReference(bean, clazz, creationalContext);
}
return null;
}
}
| USEF-Foundation/ri.usef.energy | usef-build/usef-core/usef-core-transport/src/main/java/energy/usef/core/service/helper/DispatcherHelperService.java | Java | apache-2.0 | 3,493 | [
30522,
1013,
1008,
1008,
9385,
2325,
1011,
2355,
2224,
2546,
3192,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.6.0_27) on Sat Nov 09 18:04:29 IRST 2013 -->
<title>Uses of Interface org.nise.ux.asl.face.ServiceResponserFactory (Abstract Service Library)</title>
<meta name="date" content="2013-11-09">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Interface org.nise.ux.asl.face.ServiceResponserFactory (Abstract Service Library)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>PREV</li>
<li>NEXT</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/nise/ux/asl/face//class-useServiceResponserFactory.html" target="_top">FRAMES</a></li>
<li><a href="ServiceResponserFactory.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Interface org.nise.ux.asl.face.ServiceResponserFactory" class="title">Uses of Interface<br>org.nise.ux.asl.face.ServiceResponserFactory</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#org.nise.ux.asl.run">org.nise.ux.asl.run</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="org.nise.ux.asl.run">
<!-- -->
</a>
<h3>Uses of <a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a> in <a href="../../../../../../org/nise/ux/asl/run/package-summary.html">org.nise.ux.asl.run</a></h3>
<table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing constructors, and an explanation">
<caption><span>Constructors in <a href="../../../../../../org/nise/ux/asl/run/package-summary.html">org.nise.ux.asl.run</a> with parameters of type <a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colLast"><code><strong><a href="../../../../../../org/nise/ux/asl/run/ASLServer.html#ASLServer(org.nise.ux.asl.face.ServiceResponserFactory, java.lang.reflect.Type)">ASLServer</a></strong>(<a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>,<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">R</a>> serviceResponserFactory,
java.lang.reflect.Type requestPackageType)</code>
<div class="block">Creates an instance without profiling system and using default <a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face"><code>InputAnalyzer</code></a></div>
</td>
</tr>
<tr class="rowColor">
<td class="colLast"><code><strong><a href="../../../../../../org/nise/ux/asl/run/ASLServer.html#ASLServer(org.nise.ux.asl.face.ServiceResponserFactory, java.lang.reflect.Type, org.nise.ux.asl.face.ClientInfoProfilerFactory)">ASLServer</a></strong>(<a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>,<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">R</a>> serviceResponserFactory,
java.lang.reflect.Type requestPackageType,
<a href="../../../../../../org/nise/ux/asl/face/ClientInfoProfilerFactory.html" title="interface in org.nise.ux.asl.face">ClientInfoProfilerFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>> clientInfoProfilerFactory)</code>
<div class="block">Creates an instance with profiling system and using default <a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face"><code>InputAnalyzer</code></a></div>
</td>
</tr>
<tr class="altColor">
<td class="colLast"><code><strong><a href="../../../../../../org/nise/ux/asl/run/ASLServer.html#ASLServer(org.nise.ux.asl.face.ServiceResponserFactory, java.lang.reflect.Type, org.nise.ux.asl.face.ClientInfoProfilerFactory, org.nise.ux.asl.face.InputAnalyzer)">ASLServer</a></strong>(<a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>,<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">R</a>> serviceResponserFactory,
java.lang.reflect.Type requestPackageType,
<a href="../../../../../../org/nise/ux/asl/face/ClientInfoProfilerFactory.html" title="interface in org.nise.ux.asl.face">ClientInfoProfilerFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>> clientInfoProfilerFactory,
<a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face">InputAnalyzer</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>> inputAnalyzer)</code>
<div class="block">Creates an instance with profiling system and using given <a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face"><code>InputAnalyzer</code></a></div>
</td>
</tr>
<tr class="rowColor">
<td class="colLast"><code><strong><a href="../../../../../../org/nise/ux/asl/run/ASLServer.html#ASLServer(org.nise.ux.asl.face.ServiceResponserFactory, java.lang.reflect.Type, org.nise.ux.asl.face.InputAnalyzer)">ASLServer</a></strong>(<a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">ServiceResponserFactory</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>,<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">R</a>> serviceResponserFactory,
java.lang.reflect.Type requestPackageType,
<a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face">InputAnalyzer</a><<a href="../../../../../../org/nise/ux/asl/run/ASLServer.html" title="type parameter in ASLServer">D</a>> inputAnalyzer)</code>
<div class="block">Creates an instance without profiling system and using given <a href="../../../../../../org/nise/ux/asl/face/InputAnalyzer.html" title="interface in org.nise.ux.asl.face"><code>InputAnalyzer</code></a></div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../org/nise/ux/asl/face/ServiceResponserFactory.html" title="interface in org.nise.ux.asl.face">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>PREV</li>
<li>NEXT</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/nise/ux/asl/face//class-useServiceResponserFactory.html" target="_top">FRAMES</a></li>
<li><a href="ServiceResponserFactory.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>
<i>This library is a work of NISE organization User-eXperience team.</i>
</small></p>
</body>
</html>
| yeuser/java-libs | abstract-service-library/dist/abstract-service-library-0.5.2/api/org/nise/ux/asl/face/class-use/ServiceResponserFactory.html | HTML | apache-2.0 | 11,021 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
define(
[
'underscore',
'backbone',
'lib/localizer'
],
function (_, Backbone, Localizer) {
'use strict';
/**
* Base class for views that provides common rendering, model presentation, DOM assignment,
* subview tracking, and tear-down.
*
* @class BaseView
*
* @constructor
*
* @param {Object} options configuration options passed along to Backbone.View
*/
var BaseView = Backbone.View.extend({
constructor: function (options) {
this.subviews = [];
Backbone.View.call(this, options);
},
/**
* Gets context from model's attributes. Can be overridden to provide custom context for template.
*
* @method getContext
* @return {Object} context
*/
getContext: function () {
var context;
if (this.model) {
context = this.model.attributes;
} else {
context = {};
}
return context;
},
/**
* Localizes English input text.
*
* @method localize
* @return {String} localized text
*/
localize: function (text) {
return Localizer.localize(text);
},
/**
* Renders by combining template and context and inserting into the associated element.
*
* @method render
* @return {BaseView} this
* @chainable
*/
render: function () {
this.destroySubviews();
var context = this.getContext();
var self = this;
context.l = function () {
return function (text, render) {
return render(self.localize(text));
};
};
this.$el.html(this.template(context));
this.afterRender();
return this;
},
/**
* Called after render completes. Provides easy access to custom rendering for subclasses
* without having to override render.
*
* @method afterRender
*/
afterRender: function () {
// Implement in subclasses
},
/**
* Renders local collection using the provided view and inserts into the provided selector.
*
* @method renderCollection
* @param {Backbone.View} ItemView view for rendering each item in the collection
* @param {String} selector jQuery selector to insert the collected elements
*/
renderCollection: function (ItemView, selector) {
var els = this.collection.collect(function (item) {
return this.trackSubview(new ItemView({ model: item })).render().el;
}.bind(this));
this.$(selector).append(els);
},
/**
* Assigns view to a selector.
*
* @method assign
* @param {Backbone.View} view to assign
* @param {String} selector jQuery selector for the element to be assigned
* @return {BaseView} this
*/
assign: function (view, selector) {
view.setElement(this.$(selector));
view.render();
},
/**
* Destroys view by stopping Backbone event listeners, disabling jQuery events, and destroying
* subviews.
*
* @method destroy
*/
destroy: function () {
if (this.beforeDestroy) {
this.beforeDestroy();
}
this.stopListening();
this.destroySubviews();
this.$el.off();
},
/**
* Keeps track of a subview so that it can later be destroyed.
*
* @method trackSubview
* @param {BaseView} view to track
* @return {BaseView} tracked view
*/
trackSubview: function (view) {
if (!_.contains(this.subviews, view)) {
this.subviews.push(view);
}
return view;
},
/**
* Destroys all subviews.
*
* @method destroySubviews
*/
destroySubviews: function () {
_.invoke(this.subviews, 'destroy');
this.subviews = [];
}
});
return BaseView;
}
);
| mozilla/chronicle | app/scripts/views/base.js | JavaScript | mpl-2.0 | 4,193 | [
30522,
1013,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1008,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1012,
2065,
1037,
6100,
1997,
1996,
6131,
2140,
2001,
2025,
5500,
2007,
2023,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>zsearch-trees: 21 s 🏆</title>
<link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
<link href="../../../../../bootstrap.min.css" rel="stylesheet">
<link href="../../../../../bootstrap-custom.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="../../../../../moment.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../..">clean / released</a></li>
<li class="active"><a href="">8.5.2 / zsearch-trees - 8.5.0</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
zsearch-trees
<small>
8.5.0
<span class="label label-success">21 s 🏆</span>
</small>
</h1>
<p>📅 <em><script>document.write(moment("2022-01-25 22:42:58 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2022-01-25 22:42:58 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-num base Num library distributed with the OCaml compiler
base-threads base
base-unix base
camlp5 7.14 Preprocessor-pretty-printer of OCaml
conf-findutils 1 Virtual package relying on findutils
conf-perl 2 Virtual package relying on perl
coq 8.5.2 Formal proof management system
num 0 The Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.04.2 The OCaml compiler (virtual package)
ocaml-base-compiler 4.04.2 Official 4.04.2 release
ocaml-config 1 OCaml Switch Configuration
# opam file:
opam-version: "2.0"
maintainer: "matej.kosik@inria.fr"
homepage: "https://github.com/coq-contribs/zsearch-trees"
license: "LGPL 2"
build: [make "-j%{jobs}%"]
install: [make "install"]
remove: ["rm" "-R" "%{lib}%/coq/user-contrib/ZSearchTrees"]
depends: [
"ocaml"
"coq" {>= "8.5" & < "8.6~"}
]
tags: [ "keyword:binary search trees" "category:Computer Science/Data Types and Data Structures" "category:Miscellaneous/Extracted Programs/Data structures" ]
authors: [ "Pierre Castéran <>" ]
bug-reports: "https://github.com/coq-contribs/zsearch-trees/issues"
dev-repo: "git+https://github.com/coq-contribs/zsearch-trees.git"
synopsis: "Binary Search Trees"
description:
"Algorithms for collecting, searching, inserting and deleting elements in binary search trees on nat"
flags: light-uninstall
url {
src: "https://github.com/coq-contribs/zsearch-trees/archive/v8.5.0.tar.gz"
checksum: "md5=240c8def307d3b064cf50e65bb2cb625"
}
</pre>
<h2>Lint</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Dry install 🏜️</h2>
<p>Dry install with the current Coq version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam install -y --show-action coq-zsearch-trees.8.5.0 coq.8.5.2</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam list; echo; ulimit -Sv 4000000; timeout 4h opam install -y --deps-only coq-zsearch-trees.8.5.0 coq.8.5.2</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>12 s</dd>
</dl>
<h2>Install 🚀</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam list; echo; ulimit -Sv 16000000; timeout 4h opam install -y -v coq-zsearch-trees.8.5.0 coq.8.5.2</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>21 s</dd>
</dl>
<h2>Installation size</h2>
<p>Total: 334 K</p>
<ul>
<li>194 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/search_tree.vo</code></li>
<li>87 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/search_tree.glob</code></li>
<li>29 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/search_tree.v</code></li>
<li>22 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/extraction.vo</code></li>
<li>1 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/extraction.v</code></li>
<li>1 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/ZSearchTrees/extraction.glob</code></li>
</ul>
<h2>Uninstall 🧹</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam remove -y coq-zsearch-trees.8.5.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.04.2-2.0.5/released/8.5.2/zsearch-trees/8.5.0.html | HTML | mit | 7,448 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
418... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* MessagePack for C
*
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @defgroup msgpack MessagePack C
* @{
* @}
*/
#include "msgpack/object.h"
#include "msgpack/zone.h"
#include "msgpack/pack.h"
#include "msgpack/unpack.h"
#include "msgpack/sbuffer.h"
#include "msgpack/vrefbuffer.h"
#include "msgpack/version.h"
| nobu-k/msgpack-c | src/msgpack.h | C | apache-2.0 | 916 | [
30522,
1013,
1008,
1008,
4471,
23947,
2005,
1039,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
2268,
6519,
27225,
12914,
6517,
4710,
14228,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../libc/constant.POSIX_FADV_WILLNEED.html">
</head>
<body>
<p>Redirecting to <a href="../../../libc/constant.POSIX_FADV_WILLNEED.html">../../../libc/constant.POSIX_FADV_WILLNEED.html</a>...</p>
<script>location.replace("../../../libc/constant.POSIX_FADV_WILLNEED.html" + location.search + location.hash);</script>
</body>
</html> | malept/guardhaus | main/libc/unix/linux_like/constant.POSIX_FADV_WILLNEED.html | HTML | mit | 429 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
25416,
21898,
1000,
4180,
1027,
1000,
1014,
1025,
24471,
2140,
1027,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
:- module(
jwt_enc,
[
jwt_enc/4 % +Header, +Payload, ?Key, -Token
]
).
/** <module> JSON Web Tokens (JWT): Encoding
@author Wouter Beek
@version 2015/06
*/
:- use_module(library(apply)).
:- use_module(library(base64)).
:- use_module(library(sha)).
:- use_module(library(jwt/jwt_util)).
%! jwt_enc(+Header:dict, +Payload:dict, ?Key, -Token:atom) is det.
jwt_enc(Header0, Payload0, Key, Token):-
header_claims(Header0, Header),
payload_claims(Payload0, Payload),
maplist(atom_json_dict, [HeaderDec,PayloadDec], [Header,Payload]),
maplist(base64url, [HeaderDec,PayloadDec], [HeaderEnc,PayloadEnc]),
atomic_list_concat([HeaderEnc,PayloadEnc], ., SignWith),
create_signature(Header, SignWith, Key, SignatureEnc),
atomic_list_concat([SignWith,SignatureEnc], ., Token).
%! create_signature(+Header:dict, +SignWith:atom, ?Key:dict, -Signature:atom) is det.
create_signature(Header, _, _, ''):-
Header.alg == "none", !.
create_signature(Header, SignWith, Key, SignatureEnc):- !,
hmac_algorithm_name(Header.alg, Alg), !,
interpret_key(Header, Key, Secret),
hmac_sha(Secret, SignWith, Hash, [algorithm(Alg)]),
atom_codes(SignatureDec, Hash),
base64url(SignatureDec, SignatureEnc).
%! header_claims(+Old:dict, -New:dict) is det.
header_claims(Old, New):-
dict_add_default(Old, typ, "JWT", New).
%! payload_claims(+Old:dict, -New:dict) is det.
payload_claims(Old, New):-
dict_add_default(Old, iss, "SWI-Prolog", Tmp),
get_time(Now0),
Now is floor(Now0),
dict_add_default(Tmp, iat, Now, New).
| wouterbeek/plJwt | prolog/jwt/jwt_enc.pl | Perl | mit | 1,547 | [
30522,
1024,
1011,
11336,
1006,
1046,
26677,
1035,
4372,
2278,
1010,
1031,
1046,
26677,
1035,
4372,
2278,
1013,
1018,
1003,
1009,
20346,
1010,
1009,
18093,
1010,
1029,
3145,
1010,
1011,
19204,
1033,
1007,
1012,
1013,
1008,
1008,
1026,
11336... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import templateUrl from './image.html';
import controller from './image-controller';
export default {
name: 'image',
url: '/:image',
templateUrl,
controller,
controllerAs: 'image',
resolve: {
image: ['$http', '$stateParams', function($http, $stateParams){
const config = {
method: 'GET',
url: 'api/images/'+$stateParams.image,
params: {metadata: true}
};
return $http(config);
}]
}
};
| tamaracha/wbt-framework | src/main/author/images/image/index.js | JavaScript | mit | 449 | [
30522,
12324,
23561,
3126,
2140,
2013,
1005,
1012,
1013,
3746,
1012,
16129,
1005,
1025,
12324,
11486,
2013,
1005,
1012,
1013,
3746,
1011,
11486,
1005,
1025,
9167,
12398,
1063,
2171,
1024,
1005,
3746,
1005,
1010,
24471,
2140,
1024,
1005,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# What is this?
A script and data for a bot that automatically generates and posts the daily/weekly threads to /r/gamedev, as well as stickies and flairs them as appropriate.
# How does it work?
It automatically schedules posts, one post type per `/threads` folder. It determines which thread to post by first looking at `/threads/[thread]/once.yaml` and seeing if a thread is scheduled. If no specific thread is scheduled, it grabs the top thread from the `threads/[thread]/posts.yaml` queue (and moves it to the bottom), combines that threads `variables` with the default `variables` from `/threads/[thread]/config.yaml` and passes them into `/threads/[thread]/format.md` and the title, and then posts it to reddit.
`format.md` and title variables are gathered from `internal.yaml`, `posts.yaml > [selected] > variables`, and `conf.yaml`. With the priority in that order. The variables are used replace the `%{name}` counterparts in `format.yaml` and `conf.yaml`'s title.
# Contributing (post titles, bonus question, formatting, etc)
Modify the appropriate file (probably `posts.yaml`) and submit a pull request, or [message /r/gamedev](https://www.reddit.com/message/compose?to=%2Fr%2Fgamedev), or [fill out this form](https://docs.google.com/forms/d/1ce7sbdm-D_PJy3WC5FAbpZ6KprBKW4OcSL0hLxUvoQE/viewform).
(Optional) Run `validate.rb` before submitting to confirm all your changes are good to go.
## Base Text (`format.md`)
Edit `format.md` as though it were a reddit post, with the exception that %{variable} will be replaced with their counterpart from the merger of `internal.yaml`, `[selected post] > variables`, and `conf.yaml` (with priority in that order).
```yaml
# Standard Variables:
%{today} - the current date YYYY-MM-DD
%{counter} - the current post number
%{tagline} - the (sub)title of the post
%{question} - question to appear at the end of the post
%{extra} - bonus text to be included at the end of the post
```
## Regular posts (`posts.yaml`)
When no specific post is scheduled through `once.yaml`, the top post is selected from `posts.yaml` and moved to the bottom of `posts.yaml`.
```yaml
# Example posts.yaml entry
- variables:
tagline: "Text to be included in the title"
question: "Question to be included at the end" # optional
bonus: "Text to be included after the end" # optional
```
## Scheduled posts (`once.yaml`)
Specially scheduled posts. All entries should include one of `on_counter`, `after_date`, or `before_date`. Optionally they may include `keep: true` and `again: true` to move the entry to `posts.yaml` and keep the scheduling in `once.yaml`, respectively.
```yaml
# Posted when the %{counter} reaches 50 and discarded (moved to once-used.yaml)
- on_counter: 50
variables:
tagline: "Text to be included in the title"
question: "Question to be included at the end" # optional
bonus: "Text to be included after the end" # optional
# Posted in the week after '04/01' and then kept (moved to the end of posts.yaml)
- after_date: '04/01'
keep: true # this keeps the post (moves it to posts.yaml when we're done)
variables:
tagline: nothing nothing
question: nothing nothing nothing
bonus: |+ # Include multiple lines of text in this fashion
line1
line2
line4
# Posted in the week before '04/01' and is used again (is kept in once.yaml and not moved)
- before_date: '04/01'
again: true
variables:
tagline: April Fools
question: Something something pranks.
bonus: |+ # Include multiple lines of text in this fashion
just literally paragraphs of text
not even kidding
```
# TODO
* Testing
* All.
* The.
* Things.
* *(except posts.yaml)*
| r-gamedev/weekly-posts | README.md | Markdown | mit | 3,708 | [
30522,
1001,
2054,
2003,
2023,
1029,
1037,
5896,
1998,
2951,
2005,
1037,
28516,
2008,
8073,
19421,
1998,
8466,
1996,
3679,
1013,
4882,
16457,
2000,
1013,
1054,
1013,
2208,
24844,
1010,
2004,
2092,
2004,
6293,
3111,
1998,
22012,
2015,
2068,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* Copyright (c) 2013 Christian Wiwie.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Christian Wiwie - initial API and implementation
******************************************************************************/
/**
*
*/
package de.clusteval.data.statistics;
import java.io.File;
import de.clusteval.framework.RLibraryRequirement;
import de.clusteval.framework.repository.RegisterException;
import de.clusteval.framework.repository.Repository;
/**
* @author Christian Wiwie
*
*/
@RLibraryRequirement(requiredRLibraries = {"igraph"})
public class ClusteringCoefficientRDataStatistic
extends
DoubleValueDataStatistic {
/*
* (non-Javadoc)
*
* @see utils.Statistic#getAlias()
*/
@Override
public String getAlias() {
return "Clustering Coefficient (R)";
}
/**
* @param repository
* @param register
* @param changeDate
* @param absPath
* @throws RegisterException
*
*/
public ClusteringCoefficientRDataStatistic(final Repository repository,
final boolean register, final long changeDate, final File absPath)
throws RegisterException {
super(repository, register, changeDate, absPath, 0.0);
}
/**
* @param repository
* @param register
* @param changeDate
* @param absPath
* @param value
* @throws RegisterException
*/
public ClusteringCoefficientRDataStatistic(final Repository repository,
final boolean register, final long changeDate, final File absPath,
final double value) throws RegisterException {
super(repository, register, changeDate, absPath, value);
}
/**
* The copy constructor for this statistic.
*
* @param other
* The object to clone.
* @throws RegisterException
*/
public ClusteringCoefficientRDataStatistic(
final ClusteringCoefficientRDataStatistic other)
throws RegisterException {
super(other);
}
/*
* (non-Javadoc)
*
* @see data.statistics.DataStatistic#requiresGoldStandard()
*/
@Override
public boolean requiresGoldStandard() {
return false;
}
}
| deric/clusteval-parent | clusteval-packages/src/main/java/de/clusteval/data/statistics/ClusteringCoefficientRDataStatistic.java | Java | gpl-3.0 | 2,303 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"74943310","logradouro":"Rua Jardim de Al\u00e1","bairro":"Jardim Buriti Sereno","cidade":"Aparecida de Goi\u00e2nia","uf":"GO","estado":"Goi\u00e1s"});
| lfreneda/cepdb | api/v1/74943310.jsonp.js | JavaScript | cc0-1.0 | 166 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6356,
2683,
23777,
21486,
2692,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
15723,
22172,
2139,
2632,
1032,
1057,
8889,
2063,
2487,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package sodium
// #cgo pkg-config: libsodium
// #include <stdlib.h>
// #include <sodium.h>
import "C"
func RuntimeHasNeon() bool {
return C.sodium_runtime_has_neon() != 0
}
func RuntimeHasSse2() bool {
return C.sodium_runtime_has_sse2() != 0
}
func RuntimeHasSse3() bool {
return C.sodium_runtime_has_sse3() != 0
}
| GoKillers/libsodium-go | sodium/runtime.go | GO | isc | 322 | [
30522,
7427,
13365,
1013,
1013,
1001,
1039,
3995,
1052,
2243,
2290,
1011,
9530,
8873,
30524,
2078,
1006,
1007,
22017,
2140,
1063,
2709,
1039,
1012,
13365,
1035,
2448,
7292,
1035,
2038,
1035,
16231,
1006,
1007,
999,
1027,
1014,
1065,
4569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2014 The Async HBase Authors. All rights reserved.
* This file is part of Async HBase.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the StumbleUpon nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.hbase.async;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
import java.nio.charset.Charset;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.hbase.async.HBaseClient.ZKClient;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.socket.SocketChannel;
import org.jboss.netty.channel.socket.SocketChannelConfig;
import org.jboss.netty.channel.socket.nio.NioClientBossPool;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.channel.socket.nio.NioWorkerPool;
import org.jboss.netty.util.HashedWheelTimer;
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.TimerTask;
import org.junit.Before;
import org.junit.Ignore;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.reflect.Whitebox;
import com.stumbleupon.async.Deferred;
@PrepareForTest({ HBaseClient.class, RegionClient.class, HBaseRpc.class,
GetRequest.class, RegionInfo.class, NioClientSocketChannelFactory.class,
Executors.class, HashedWheelTimer.class, NioClientBossPool.class,
NioWorkerPool.class })
@Ignore // ignore for test runners
public class BaseTestHBaseClient {
protected static final Charset CHARSET = Charset.forName("ASCII");
protected static final byte[] COMMA = { ',' };
protected static final byte[] TIMESTAMP = "1234567890".getBytes();
protected static final byte[] INFO = getStatic("INFO");
protected static final byte[] REGIONINFO = getStatic("REGIONINFO");
protected static final byte[] SERVER = getStatic("SERVER");
protected static final byte[] TABLE = { 't', 'a', 'b', 'l', 'e' };
protected static final byte[] KEY = { 'k', 'e', 'y' };
protected static final byte[] KEY2 = { 'k', 'e', 'y', '2' };
protected static final byte[] FAMILY = { 'f' };
protected static final byte[] QUALIFIER = { 'q', 'u', 'a', 'l' };
protected static final byte[] VALUE = { 'v', 'a', 'l', 'u', 'e' };
protected static final byte[] EMPTY_ARRAY = new byte[0];
protected static final KeyValue KV = new KeyValue(KEY, FAMILY, QUALIFIER, VALUE);
protected static final RegionInfo meta = mkregion(".META.", ".META.,,1234567890");
protected static final RegionInfo region = mkregion("table", "table,,1234567890");
protected static final int RS_PORT = 50511;
protected static final String ROOT_IP = "192.168.0.1";
protected static final String META_IP = "192.168.0.2";
protected static final String REGION_CLIENT_IP = "192.168.0.3";
protected static String MOCK_RS_CLIENT_NAME = "Mock RegionClient";
protected static String MOCK_ROOT_CLIENT_NAME = "Mock RootClient";
protected static String MOCK_META_CLIENT_NAME = "Mock MetaClient";
protected HBaseClient client = null;
/** Extracted from {@link #client}. */
protected ConcurrentSkipListMap<byte[], RegionInfo> regions_cache;
/** Extracted from {@link #client}. */
protected ConcurrentHashMap<RegionInfo, RegionClient> region2client;
/** Extracted from {@link #client}. */
protected ConcurrentHashMap<RegionClient, ArrayList<RegionInfo>> client2regions;
/** Extracted from {@link #client}. */
protected ConcurrentSkipListMap<byte[], ArrayList<HBaseRpc>> got_nsre;
/** Extracted from {@link #client}. */
protected HashMap<String, RegionClient> ip2client;
/** Extracted from {@link #client}. */
protected Counter num_nsre_rpcs;
/** Fake client supposedly connected to -ROOT-. */
protected RegionClient rootclient;
/** Fake client supposedly connected to .META.. */
protected RegionClient metaclient;
/** Fake client supposedly connected to our fake test table. */
protected RegionClient regionclient;
/** Each new region client is dumped here */
protected List<RegionClient> region_clients = new ArrayList<RegionClient>();
/** Fake Zookeeper client */
protected ZKClient zkclient;
/** Fake channel factory */
protected NioClientSocketChannelFactory channel_factory;
/** Fake channel returned from the factory */
protected SocketChannel chan;
/** Fake timer for testing */
protected FakeTimer timer;
@Before
public void before() throws Exception {
region_clients.clear();
rootclient = mock(RegionClient.class);
when(rootclient.toString()).thenReturn(MOCK_ROOT_CLIENT_NAME);
metaclient = mock(RegionClient.class);
when(metaclient.toString()).thenReturn(MOCK_META_CLIENT_NAME);
regionclient = mock(RegionClient.class);
when(regionclient.toString()).thenReturn(MOCK_RS_CLIENT_NAME);
zkclient = mock(ZKClient.class);
channel_factory = mock(NioClientSocketChannelFactory.class);
chan = mock(SocketChannel.class);
timer = new FakeTimer();
when(zkclient.getDeferredRoot()).thenReturn(new Deferred<Object>());
PowerMockito.mockStatic(Executors.class);
PowerMockito.when(Executors.defaultThreadFactory())
.thenReturn(mock(ThreadFactory.class));
PowerMockito.when(Executors.newCachedThreadPool())
.thenReturn(mock(ExecutorService.class));
PowerMockito.whenNew(NioClientSocketChannelFactory.class).withAnyArguments()
.thenReturn(channel_factory);
PowerMockito.whenNew(HashedWheelTimer.class).withAnyArguments()
.thenReturn(timer);
PowerMockito.whenNew(NioClientBossPool.class).withAnyArguments()
.thenReturn(mock(NioClientBossPool.class));
PowerMockito.whenNew(NioWorkerPool.class).withAnyArguments()
.thenReturn(mock(NioWorkerPool.class));
client = PowerMockito.spy(new HBaseClient("test-quorum-spec"));
Whitebox.setInternalState(client, "zkclient", zkclient);
Whitebox.setInternalState(client, "rootregion", rootclient);
Whitebox.setInternalState(client, "jitter_percent", 0);
regions_cache = Whitebox.getInternalState(client, "regions_cache");
region2client = Whitebox.getInternalState(client, "region2client");
client2regions = Whitebox.getInternalState(client, "client2regions");
got_nsre = Whitebox.getInternalState(client, "got_nsre");
ip2client = Whitebox.getInternalState(client, "ip2client");
injectRegionInCache(meta, metaclient, META_IP + ":" + RS_PORT);
injectRegionInCache(region, regionclient, REGION_CLIENT_IP + ":" + RS_PORT);
when(channel_factory.newChannel(any(ChannelPipeline.class)))
.thenReturn(chan);
when(chan.getConfig()).thenReturn(mock(SocketChannelConfig.class));
when(rootclient.toString()).thenReturn("Mock RootClient");
PowerMockito.doAnswer(new Answer<RegionClient>(){
@Override
public RegionClient answer(InvocationOnMock invocation) throws Throwable {
final Object[] args = invocation.getArguments();
final String endpoint = (String)args[0] + ":" + (Integer)args[1];
final RegionClient rc = mock(RegionClient.class);
when(rc.getRemoteAddress()).thenReturn(endpoint);
client2regions.put(rc, new ArrayList<RegionInfo>());
region_clients.add(rc);
return rc;
}
}).when(client, "newClient", anyString(), anyInt());
}
/**
* Injects an entry in the local caches of the client.
*/
protected void injectRegionInCache(final RegionInfo region,
final RegionClient client,
final String ip) {
regions_cache.put(region.name(), region);
region2client.put(region, client);
ArrayList<RegionInfo> regions = client2regions.get(client);
if (regions == null) {
regions = new ArrayList<RegionInfo>(1);
client2regions.put(client, regions);
}
regions.add(region);
ip2client.put(ip, client);
}
// ----------------- //
// Helper functions. //
// ----------------- //
protected void clearCaches(){
regions_cache.clear();
region2client.clear();
client2regions.clear();
}
protected static <T> T getStatic(final String fieldname) {
return Whitebox.getInternalState(HBaseClient.class, fieldname);
}
/**
* Creates a fake {@code .META.} row.
* The row contains a single entry for all keys of {@link #TABLE}.
*/
protected static ArrayList<KeyValue> metaRow() {
return metaRow(HBaseClient.EMPTY_ARRAY, HBaseClient.EMPTY_ARRAY);
}
/**
* Creates a fake {@code .META.} row.
* The row contains a single entry for {@link #TABLE}.
* @param start_key The start key of the region in this entry.
* @param stop_key The stop key of the region in this entry.
*/
protected static ArrayList<KeyValue> metaRow(final byte[] start_key,
final byte[] stop_key) {
final ArrayList<KeyValue> row = new ArrayList<KeyValue>(2);
row.add(metaRegionInfo(start_key, stop_key, false, false, TABLE));
row.add(new KeyValue(region.name(), INFO, SERVER, "localhost:54321".getBytes()));
return row;
}
protected static KeyValue metaRegionInfo( final byte[] start_key,
final byte[] stop_key, final boolean offline, final boolean splitting,
final byte[] table) {
final byte[] name = concat(table, COMMA, start_key, COMMA, TIMESTAMP);
final byte is_splitting = (byte) (splitting ? 1 : 0);
final byte[] regioninfo = concat(
new byte[] {
0, // version
(byte) stop_key.length, // vint: stop key length
},
stop_key,
offline ? new byte[] { 1 } : new byte[] { 0 }, // boolean: offline
Bytes.fromLong(name.hashCode()), // long: region ID (make it random)
new byte[] { (byte) name.length }, // vint: region name length
name, // region name
new byte[] {
is_splitting, // boolean: splitting
(byte) start_key.length, // vint: start key length
},
start_key
);
return new KeyValue(region.name(), INFO, REGIONINFO, regioninfo);
}
protected static RegionInfo mkregion(final String table, final String name) {
return new RegionInfo(table.getBytes(), name.getBytes(),
HBaseClient.EMPTY_ARRAY);
}
protected static byte[] anyBytes() {
return any(byte[].class);
}
/** Concatenates byte arrays together. */
protected static byte[] concat(final byte[]... arrays) {
int len = 0;
for (final byte[] array : arrays) {
len += array.length;
}
final byte[] result = new byte[len];
len = 0;
for (final byte[] array : arrays) {
System.arraycopy(array, 0, result, len, array.length);
len += array.length;
}
return result;
}
/** Creates a new Deferred that's already called back. */
protected static <T> Answer<Deferred<T>> newDeferred(final T result) {
return new Answer<Deferred<T>>() {
public Deferred<T> answer(final InvocationOnMock invocation) {
return Deferred.fromResult(result);
}
};
}
/**
* A fake {@link Timer} implementation that fires up tasks immediately.
* Tasks are called immediately from the current thread and a history of the
* various tasks is logged.
*/
static final class FakeTimer extends HashedWheelTimer {
final List<Map.Entry<TimerTask, Long>> tasks =
new ArrayList<Map.Entry<TimerTask, Long>>();
final ArrayList<Timeout> timeouts = new ArrayList<Timeout>();
boolean run = true;
@Override
public Timeout newTimeout(final TimerTask task,
final long delay,
final TimeUnit unit) {
try {
tasks.add(new AbstractMap.SimpleEntry<TimerTask, Long>(task, delay));
if (run) {
task.run(null); // Argument never used in this code base.
}
final Timeout timeout = mock(Timeout.class);
timeouts.add(timeout);
return timeout; // Return value never used in this code base.
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Timer task failed: " + task, e);
}
}
@Override
public Set<Timeout> stop() {
run = false;
return new HashSet<Timeout>(timeouts);
}
}
/**
* A fake {@link org.jboss.netty.util.Timer} implementation.
* Instead of executing the task it will store that task in a internal state
* and provides a function to start the execution of the stored task.
* This implementation thus allows the flexibility of simulating the
* things that will be going on during the time out period of a TimerTask.
* This was mainly return to simulate the timeout period for
* alreadyNSREdRegion test, where the region will be in the NSREd mode only
* during this timeout period, which was difficult to simulate using the
* above {@link FakeTimer} implementation, as we don't get back the control
* during the timeout period
*
* Here it will hold at most two Tasks. We have two tasks here because when
* one is being executed, it may call for newTimeOut for another task.
*/
static final class FakeTaskTimer extends HashedWheelTimer {
protected TimerTask newPausedTask = null;
protected TimerTask pausedTask = null;
@Override
public synchronized Timeout newTimeout(final TimerTask task,
final long delay,
final TimeUnit unit) {
if (pausedTask == null) {
pausedTask = task;
} else if (newPausedTask == null) {
newPausedTask = task;
} else {
throw new IllegalStateException("Cannot Pause Two Timer Tasks");
}
return null;
}
@Override
public Set<Timeout> stop() {
return null;
}
public boolean continuePausedTask() {
if (pausedTask == null) {
return false;
}
try {
if (newPausedTask != null) {
throw new IllegalStateException("Cannot be in this state");
}
pausedTask.run(null); // Argument never used in this code base
pausedTask = newPausedTask;
newPausedTask = null;
return true;
} catch (Exception e) {
throw new RuntimeException("Timer task failed: " + pausedTask, e);
}
}
}
/**
* Generate and return a mocked HBase RPC for testing purposes with a valid
* Deferred that can be called on execution.
* @param deferred A deferred to watch for results
* @return The RPC to pass through unit tests.
*/
protected HBaseRpc getMockHBaseRpc(final Deferred<Object> deferred) {
final HBaseRpc rpc = mock(HBaseRpc.class);
rpc.attempt = 0;
when(rpc.getDeferred()).thenReturn(deferred);
when(rpc.toString()).thenReturn("MockRPC");
PowerMockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
if (deferred != null) {
deferred.callback(invocation.getArguments()[0]);
} else {
System.out.println("Deferred was null!!");
}
return null;
}
}).when(rpc).callback(Object.class);
return rpc;
}
}
| manolama/asynchbase | test/BaseTestHBaseClient.java | Java | bsd-3-clause | 17,282 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2297,
1996,
2004,
6038,
2278,
1044,
15058,
6048,
1012,
2035,
2916,
9235,
1012,
1008,
2023,
5371,
2003,
2112,
1997,
2004,
6038,
2278,
1044,
15058,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kata.LoanPrediction.CSharp.Common.Helpers;
using Kata.LoanPrediction.CSharp.Common.Models;
namespace Kata.LoanPrediction.CSharp.MVC.Application
{
/// <summary>
/// Helper methods for Razor views.
/// </summary>
public class RazorViewHelpers
{
/// <summary>
/// Combines a view title and a base site title safely.
/// The view title can safely be null or empty.
/// </summary>
/// <param name="viewTitle"></param>
/// <param name="titleJoiner"></param>
/// <param name="baseTitle"></param>
/// <returns></returns>
public static string CombineTitle(string viewTitle, string titleJoiner, string baseTitle)
{
string result = baseTitle;
if(!string.IsNullOrEmpty(viewTitle))
{
result = viewTitle + titleJoiner + result;
}
return (result);
}
/// <summary>
/// Formats a date for output.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatDate(DateTime target)
{
string result = target.ToString(Constants.DISPLAY_DATE_FORMAT);
return (result);
}
/// <summary>
/// Formats a date for output.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatDate(DateTime? target)
{
if (!target.HasValue) return ("~");
return (FormatDate(target.Value));
}
/// <summary>
/// Formats a date for use by combodate.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatDateForCombodate(DateTime target)
{
string result = target.ToString(Constants.COMBODATE_DATE_FORMAT);
return (result);
}
/// <summary>
/// Formats a number as currency for output.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatCurrency(double target)
{
string result = target.ToString("c");
return (result);
}
/// <summary>
/// Formats a number as currency.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatCurrency(double? target)
{
if (!target.HasValue) return ("~");
return (FormatCurrency(target.Value));
}
/// <summary>
/// Formats an interest rate.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatInterestRate(double target)
{
string result = string.Format("{0:N2}%", target);
return (result);
}
/// <summary>
/// Formats a day for output.
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string FormatDay(int? target)
{
if (!target.HasValue) return ("~");
return (target.Value.ToString());
}
/// <summary>
/// Formats a transaction type for output.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static string FormatTransactionType(TransactionType type)
{
return(EnumerationHelpers.GetDescription(type));
}
}
}
| retroburst/Kata | C#/Kata.LoanPrediction.CSharp/Kata.LoanPrediction.CSharp.MVC/Application/RazorViewHelpers.cs | C# | mit | 3,742 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
29354,
1012,
5414,
28139,
29201,
3258,
1012,
20116... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright 2005-2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package io.fabric8.commands;
import io.fabric8.api.FabricService;
import io.fabric8.api.RuntimeProperties;
import io.fabric8.api.scr.ValidatingReference;
import io.fabric8.boot.commands.support.AbstractCommandComponent;
import io.fabric8.boot.commands.support.ContainerCompleter;
import org.apache.felix.gogo.commands.Action;
import org.apache.felix.gogo.commands.basic.AbstractCommand;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.service.command.Function;
@Component(immediate = true)
@Service({ Function.class, AbstractCommand.class })
@org.apache.felix.scr.annotations.Properties({
@Property(name = "osgi.command.scope", value = ContainerInfo.SCOPE_VALUE),
@Property(name = "osgi.command.function", value = ContainerInfo.FUNCTION_VALUE)
})
public class ContainerInfo extends AbstractCommandComponent {
public static final String SCOPE_VALUE = "fabric";
public static final String FUNCTION_VALUE = "container-info";
public static final String DESCRIPTION = "Displays information about the containers";
@Reference(referenceInterface = FabricService.class)
private final ValidatingReference<FabricService> fabricService = new ValidatingReference<FabricService>();
@Reference(referenceInterface = RuntimeProperties.class)
private final ValidatingReference<RuntimeProperties> runtimeProperties = new ValidatingReference<RuntimeProperties>();
// Completers
@Reference(referenceInterface = ContainerCompleter.class, bind = "bindContainerCompleter", unbind = "unbindContainerCompleter")
private ContainerCompleter containerCompleter; // dummy field
@Activate
void activate() {
activateComponent();
}
@Deactivate
void deactivate() {
deactivateComponent();
}
@Override
public Action createNewAction() {
assertValid();
return new ContainerInfoAction(fabricService.get(), runtimeProperties.get());
}
void bindFabricService(FabricService fabricService) {
this.fabricService.bind(fabricService);
}
void unbindFabricService(FabricService fabricService) {
this.fabricService.unbind(fabricService);
}
void bindRuntimeProperties(RuntimeProperties runtimeProperties) {
this.runtimeProperties.bind(runtimeProperties);
}
void unbindRuntimeProperties(RuntimeProperties runtimeProperties) {
this.runtimeProperties.unbind(runtimeProperties);
}
void bindContainerCompleter(ContainerCompleter completer) {
bindCompleter(completer);
}
void unbindContainerCompleter(ContainerCompleter completer) {
unbindCompleter(completer);
}
}
| hekonsek/fabric8 | sandbox/fabric/fabric-commands/src/main/java/io/fabric8/commands/ContainerInfo.java | Java | apache-2.0 | 3,562 | [
30522,
1013,
1008,
1008,
1008,
9385,
2384,
1011,
2297,
2417,
6045,
1010,
4297,
1012,
1008,
1008,
2417,
6045,
15943,
2023,
5371,
2000,
2017,
2104,
1996,
15895,
6105,
1010,
2544,
1008,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
define(['backbone', 'marionette', 'mustache', 'jquery', 'text!templates/ctrldialog.html'],
function(Backbone, Marionette, Mustache, $, template) {
return Marionette.ItemView.extend({
initialize: function(options) {
if (!options.icon_name) {
options.icon_name = 'bird';
}
this.model = new Backbone.Model( options );
this.render();
},
template: function(serialized_model) {
return Mustache.render(template, serialized_model);
},
ui: {
'ok': '.btn-ok',
'cancel': '.btn-cancel',
'dialog': '.dialog',
'close': '.dialog-close'
},
events: {
'tap @ui.ok': 'onOk',
'tap @ui.cancel': 'onCancel',
'tap @ui.close': 'onCancel'
},
onOk: function(ev) {
this.trigger('ok');
this.destroy();
},
onCancel: function(ev) {
this.trigger('cancel');
this.destroy();
},
onRender: function() {
$('body').append(this.$el);
this.ui.dialog.css({
'marginTop': 0 - this.ui.dialog.height()/2
});
this.ui.dialog.addClass('bounceInDown animated');
},
onDestory: function() {
this.$el.remove();
this.model.destroy();
},
className: 'dialogContainer'
});
}); | yoniji/ApeRulerDemo | app/modules/ctrls/CtrlDialogView.js | JavaScript | mit | 1,645 | [
30522,
9375,
1006,
1031,
1005,
21505,
1005,
1010,
1005,
10115,
7585,
1005,
1010,
1005,
28786,
1005,
1010,
1005,
1046,
4226,
2854,
1005,
1010,
1005,
3793,
999,
23561,
2015,
1013,
14931,
12190,
27184,
8649,
1012,
16129,
1005,
1033,
1010,
3853... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
// import org.apache.commons.cli.*;
class Dumper {
private static FileOutputStream fstream;
public Dumper(String filename) {
try {
fstream = new FileOutputStream(filename);
} catch (FileNotFoundException ex) {
Logger.getLogger(Dumper.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* Dump byte array to a file
*
* @param dump byte array
* @param filename
*/
static void dump(byte[] dump, String filename) {
if (dump == null) {
return;
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filename);
} catch (FileNotFoundException ex) {
Logger.getLogger(ST_decrypt.class.getName()).log(Level.SEVERE, null, ex);
}
try {
fos.write(dump, 0, dump.length);
fos.flush();
fos.close();
} catch (IOException ex) {
Logger.getLogger(ST_decrypt.class.getName()).log(Level.SEVERE, null, ex);
}
}
void append(byte[] b) {
try {
fstream.write(b);
} catch (IOException ex) {
Logger.getLogger(Dumper.class.getName()).log(Level.SEVERE, null, ex);
}
}
void close() {
try {
fstream.close();
} catch (IOException ex) {
Logger.getLogger(Dumper.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
class Crypto {
private static int d(final int n) {
final long n2 = n & 0xFFFFFFFFL;
return (int) ((n2 & 0x7F7F7F7FL) << 1 ^ ((n2 & 0xFFFFFFFF80808080L) >> 7) * 27L);
}
private static int a(final int n, final int n2) {
final long n3 = n & 0xFFFFFFFFL;
return (int) (n3 >> n2 * 8 | n3 << 32 - n2 * 8);
}
static int polynom2(int n) {
final int d3;
final int d2;
final int d = d(d2 = d(d3 = d(n)));
n ^= d;
return d3 ^ (d2 ^ d ^ a(d3 ^ n, 3) ^ a(d2 ^ n, 2) ^ a(n, 1));
}
static int polynom(int n) {
return (d(n) ^ a(n ^ d(n), 3) ^ a(n, 2) ^ a(n, 1));
}
}
public class ST_decrypt {
/**
* Encrypt or decrypt input file
*/
private static boolean encrypt;
private static String encryptionKey;
private static Dumper dumper;
public static void main(String[] args) {
// CommandLineParser parser = new DefaultParser();
// Options options = new Options();
// String help = "st_decrypt.jar [-e] -k <key> -i <input> -o <output>";
// options.addOption("k", "key", true, "encryption key");
// options.addOption("e", "encrypt", false, "encrypt binary");
// options.addOption("i", "input", true, "input file");
// options.addOption("o", "output", true, "output file");
// HelpFormatter formatter = new HelpFormatter();
// CommandLine opts = null;
// try {
// opts = parser.parse(options, args);
// if (opts.hasOption("key")
// && opts.hasOption("input")
// && opts.hasOption("output")) {
// encryptionKey = opts.getOptionValue("key");
// } else {
// formatter.printHelp(help, options);
// System.exit(1);
// }
// encrypt = opts.hasOption("encrypt");
// } catch (ParseException exp) {
// System.out.println(exp.getMessage());
// formatter.printHelp(help, options);
// System.exit(1);
// }
// String output = "/home/jonathan/stm_jig/usb_sniff/f2_5_dec_java.bin";
// String input = "/home/jonathan/stm_jig/usb_sniff/f2_5.bin";
// String output = "/home/jonathan/stm_jig/usb_sniff/16_encrypted";
// String input = "/home/jonathan/stm_jig/usb_sniff/16_unencrypted";
// String output = "/home/jonathan/stm_jig/usb_sniff/f2_5_dec_java_enc.bin";
// String input = "/home/jonathan/stm_jig/usb_sniff/f2_5_dec_java.bin";
// encryptionKey = "I am a key, wawawa";
// // encryptionKey = unHex("496CDB76964E46637CC0237ED87B6B7F");
// // encryptionKey = unHex("E757D2F9F122DEB3FB883ECC1AF4C688");
// // encryptionKey = unHex("8DBDA2460CD8069682D3E9BB755B7FB9");
// encryptionKey = unHex("5F4946053BD9896E8F4CE917A6D2F21A");
// encrypt=true;
encryptionKey = "best performance";
int dataLength = 30720;//(int)getFileLen("/home/jonathan/stm_jig/provisioning-jig/fw_update/fw_upgrade/f2_1.bin");
byte[] fw = new byte[dataLength];
byte[] key = new byte[16];//encryptionKey.getBytes();
byte[] data = new byte[dataLength];// {0xF7, 0x72, 0x44, 0xB3, 0xFC, 0x86, 0xE0, 0xDC, 0x20, 0xE1, 0x74, 0x2D, 0x3A, 0x29, 0x0B, 0xD2};
str_to_arr(encryptionKey, key);
readFileIntoArr(System.getProperty("user.dir") + "/f2_1.bin", data);
decrypt(data, fw, key, dataLength);
System.out.println(dataLength);
System.out.println(toHexStr(fw).length());
// Write out the decrypted fw for debugging
String outf = "fw_decrypted.bin";
dumper = new Dumper(outf);
dumper.dump(fw, outf);
dumper.close();
// fw now contains our decrypted firmware
// Make a key from the first 4 and last 12 bytes returned by f308
encryptionKey = "I am key, wawawa";
byte[] newKey = new byte[16];
byte[] f308 = new byte[16];
str_to_arr(encryptionKey, key);
readFileIntoArr("f303_bytes_4_12.bin", f308);
encrypt(f308, newKey, key, 16);
System.out.print("Using key: ");
System.out.println(toHexStr(newKey));
System.out.print("From bytes: ");
System.out.println(toHexStr(f308));
byte[] enc_fw = new byte[dataLength];
encrypt(fw, enc_fw, newKey, dataLength);
// System.out.println(toHexStr(enc_fw));
// Now for real
String outfile = "fw_re_encrypted.bin";
dumper = new Dumper(outfile);
dumper.dump(enc_fw, outfile);
dumper.close();
byte[] a = new byte[16];
byte[] ans = new byte[16];
str_to_arr(unHex("ffffffffffffffffffffffffd32700a5"), a);
encrypt(a, ans, newKey, 16);
System.out.println("Final 16 bytes: " + toHexStr(ans));
outfile = "version_thingee_16.bin";
dumper = new Dumper(outfile);
dumper.dump(ans, outfile);
dumper.close();
// dumper = new Dumper(output);
// dump_fw(input);
// dumper.close();
// System.out.println("Done!");
}
// ***************** MY Code functions ***************** JW
static void readFileIntoArr(String file, byte[] data){
FileInputStream fis = null;
try {
File f = new File(file);
fis = new FileInputStream(f);
} catch (Exception ex) {
System.out.print(file);
System.out.println("Invalid file name");
System.exit(1);
}
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(fis)) {
long len = getFileLen(file);
bufferedInputStream.read(data);
} catch (IOException ex) {
Logger.getLogger(ST_decrypt.class.getName()).log(Level.SEVERE, null, ex);
}
}
static String toHexStr(byte[] B){
StringBuilder str = new StringBuilder();
for(int i = 0; i < B.length; i++){
str.append(String.format("%02x", B[i]));
}
return str.toString();
}
static String unHex(String arg) {
String str = "";
for(int i=0;i<arg.length();i+=2)
{
String s = arg.substring(i, (i + 2));
int decimal = Integer.parseInt(s, 16);
str = str + (char) decimal;
}
return str;
}
// *******************************************************
static long getFileLen(String file) {
long n2 = 0L;
FileInputStream fis = null;
try {
File f = new File(file);
fis = new FileInputStream(f);
} catch (Exception ex) {
}
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(fis);
while (true) {
int read;
try {
read = bufferedInputStream.read();
} catch (IOException ex) {
System.out.println("Failure opening file");
read = -1;
}
if (read == -1) {
break;
}
++n2;
}
bufferedInputStream.close();
} catch (IOException ex3) {
System.out.println("Failure getting firmware data");
}
return n2;
}
/**
*
* @param array firmware byte array
* @param n length
* @param n2 ??
* @return
*/
static long encodeAndWrite(final byte[] array, long n, final int n2) {
long a = 0L;
final byte[] array2 = new byte[4 * ((array.length + 3) / 4)]; // Clever hack to get multiple of fourwith padding
final byte[] array3 = new byte[16];
str_to_arr(encryptionKey, array3);
if (encrypt) {
encrypt(array, array2, array3, array.length);
} else {
decrypt(array, array2, array3, array.length);
}
/* Send chunk of data to device */
dumper.append(array2);
return a;
}
static long writeFirmware(final BufferedInputStream bufferedInputStream, final long n) {
long a = 0L;
final byte[] array = new byte[3072];
long n4 = 0L;
try {
while (n4 < n && a == 0L) {
final long n5;
if ((n5 = bufferedInputStream.read(array)) != -1L) {
encodeAndWrite(array, n4 + 134234112L, 3072);
n4 += n5;
}
}
} catch (IOException ex) {
System.out.println("Failure reading file: " + ex.getMessage());
System.exit(1);
}
return a;
}
static void dump_fw(String file) {
FileInputStream fis = null;
try {
File f = new File(file);
fis = new FileInputStream(f);
} catch (Exception ex) {
System.out.println("Invalid file name");
System.exit(1);
}
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(fis)) {
long len = getFileLen(file);
writeFirmware(bufferedInputStream, len);
} catch (IOException ex) {
Logger.getLogger(ST_decrypt.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static int pack_u32(final int n, final int n2, final int n3, final int n4) {
return (n << 24 & 0xFF000000) + (n2 << 16 & 0xFF0000) + (n3 << 8 & 0xFF00) + (n4 & 0xFF);
}
private static int u32(final int n) {
return n >>> 24;
}
private static int u16(final int n) {
return n >> 16 & 0xFF;
}
private static int u8(final int n) {
return n >> 8 & 0xFF;
}
/**
* Converts the key from String to byte array
*
* @param s input string
* @param array destination array
*/
public static void str_to_arr(final String s, final byte[] array) {
final char[] charArray = s.toCharArray();
for (int i = 0; i < 16; ++i) {
array[i] = (byte) charArray[i];
}
}
private static void key_decode(final byte[] array, final int[] array2) { // core.a.a(byte[], byte[])
final int[] array3 = new int[4];
for (int i = 0; i < 4; ++i) {
array2[i] = (array3[i] = ByteBuffer.wrap(array).order(ByteOrder.LITTLE_ENDIAN).getInt(4 * i));
}
for (int j = 0; j < 10;) {
array3[0] ^= (int) (pack_u32(aes_x[u16(array3[3])], aes_x[u8(array3[3])], aes_x[array3[3] & 0xFF], aes_x[u32(array3[3])]) ^ rcon[j++]);
array3[1] ^= array3[0];
array3[2] ^= array3[1];
array3[3] ^= array3[2];
System.arraycopy(array3, 0, array2, 4 * j, 4);
}
}
/**
* Encrypt firmware file
*/
static void encrypt(final byte[] src, final byte[] dest, byte[] key, int len) {
final byte[] array3 = new byte[16];
int n = 0;
key_decode(key, mystery_key);
while (len > 0) {
key = null;
int n2;
if (len >= 16) {
key = Arrays.copyOfRange(src, n, n + 16);
n2 = 16;
} else if ((n2 = len) > 0) {
final byte[] array4 = new byte[16];
for (int j = 0; j < len; ++j) {
array4[j] = src[n + j];
}
for (int k = len; k < 16; ++k) {
array4[k] = (byte) Double.doubleToLongBits(Math.random());
}
key = array4;
}
if (len > 0) {
final int[] a = mystery_key;
final int[] tmp = new int[4];
int n3 = 10;
int n4 = 0;
for (int l = 0; l < 4; ++l) {
tmp[l] = (ByteBuffer.wrap(key).order(ByteOrder.LITTLE_ENDIAN).getInt(4 * l) ^ a[l + 0]);
}
n4 += 4;
do {
final int a2 = pack_u32(aes_x[u32(tmp[0])], aes_x[u16(tmp[1])], aes_x[u8(tmp[2])], aes_x[tmp[3] & 0xFF]);
final int a3 = pack_u32(aes_x[u32(tmp[1])], aes_x[u16(tmp[2])], aes_x[u8(tmp[3])], aes_x[tmp[0] & 0xFF]);
final int a4 = pack_u32(aes_x[u32(tmp[2])], aes_x[u16(tmp[3])], aes_x[u8(tmp[0])], aes_x[tmp[1] & 0xFF]);
final int a5 = pack_u32(aes_x[u32(tmp[3])], aes_x[u16(tmp[0])], aes_x[u8(tmp[1])], aes_x[tmp[2] & 0xFF]);
tmp[0] = (Crypto.polynom(a2) ^ a[n4]);
tmp[1] = (Crypto.polynom(a3) ^ a[n4 + 1]);
tmp[2] = (Crypto.polynom(a4) ^ a[n4 + 2]);
tmp[3] = (Crypto.polynom(a5) ^ a[n4 + 3]);
n4 += 4;
} while (--n3 != 1);
final int a6 = pack_u32(aes_x[u32(tmp[0])], aes_x[u16(tmp[1])], aes_x[u8(tmp[2])], aes_x[tmp[3] & 0xFF]);
final int a7 = pack_u32(aes_x[u32(tmp[1])], aes_x[u16(tmp[2])], aes_x[u8(tmp[3])], aes_x[tmp[0] & 0xFF]);
final int a8 = pack_u32(aes_x[u32(tmp[2])], aes_x[u16(tmp[3])], aes_x[u8(tmp[0])], aes_x[tmp[1] & 0xFF]);
final int a9 = pack_u32(aes_x[u32(tmp[3])], aes_x[u16(tmp[0])], aes_x[u8(tmp[1])], aes_x[tmp[2] & 0xFF]);
final int n5 = a6 ^ a[n4];
final int n6 = a7 ^ a[n4 + 1];
final int n7 = a8 ^ a[n4 + 2];
final int n8 = a9 ^ a[n4 + 3];
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(n5);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(4, n6);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(8, n7);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(12, n8);
}
for (int i = 0; i < 16; ++i) {
dest[n + i] = array3[i];
}
len -= n2;
n += n2;
}
}
/**
* Decrypt firmware file
*
* @param src firmware file
* @param dest destination array
* @param key key
* @param len array.length
*/
static void decrypt(final byte[] src, final byte[] dest, byte[] key, int len) {
final byte[] array3 = new byte[16];
int n = 0;
key_decode(key, mystery_key);
while (len > 0) {
key = null;
int n2;
if (len >= 16) {
key = Arrays.copyOfRange(src, n, n + 16);
n2 = 16;
} else if ((n2 = len) > 0) {
final byte[] array4 = new byte[16];
for (int j = 0; j < len; ++j) {
array4[j] = src[n + j];
}
for (int k = len; k < 16; ++k) {
array4[k] = (byte) Double.doubleToLongBits(Math.random());
}
key = array4;
}
if (len > 0) {
final int[] a = mystery_key;
final int[] tmp = new int[4];
int n3 = 10;
int n4 = 40;
for (int l = 0; l < 4; ++l) {
tmp[l] = (ByteBuffer.wrap(key).order(ByteOrder.LITTLE_ENDIAN).getInt(4 * l) ^ a[l + 40]);
}
n4 -= 8;
do {
final int n5 = pack_u32(aes_y[u32(tmp[0])], aes_y[u16(tmp[3])], aes_y[u8(tmp[2])], aes_y[tmp[1] & 0xFF]) ^ a[n4 + 4];
final int n6 = pack_u32(aes_y[u32(tmp[1])], aes_y[u16(tmp[0])], aes_y[u8(tmp[3])], aes_y[tmp[2] & 0xFF]) ^ a[n4 + 5];
final int n7 = pack_u32(aes_y[u32(tmp[2])], aes_y[u16(tmp[1])], aes_y[u8(tmp[0])], aes_y[tmp[3] & 0xFF]) ^ a[n4 + 6];
final int n8 = pack_u32(aes_y[u32(tmp[3])], aes_y[u16(tmp[2])], aes_y[u8(tmp[1])], aes_y[tmp[0] & 0xFF]) ^ a[n4 + 7];
tmp[0] = Crypto.polynom2(n5);
tmp[1] = Crypto.polynom2(n6);
tmp[2] = Crypto.polynom2(n7);
tmp[3] = Crypto.polynom2(n8);
n4 -= 4;
} while (--n3 != 1);
final int n9 = pack_u32(aes_y[u32(tmp[0])], aes_y[u16(tmp[3])], aes_y[u8(tmp[2])], aes_y[tmp[1] & 0xFF]) ^ a[n4 + 4];
final int n10 = pack_u32(aes_y[u32(tmp[1])], aes_y[u16(tmp[0])], aes_y[u8(tmp[3])], aes_y[tmp[2] & 0xFF]) ^ a[n4 + 5];
final int n11 = pack_u32(aes_y[u32(tmp[2])], aes_y[u16(tmp[1])], aes_y[u8(tmp[0])], aes_y[tmp[3] & 0xFF]) ^ a[n4 + 6];
final int n12 = pack_u32(aes_y[u32(tmp[3])], aes_y[u16(tmp[2])], aes_y[u8(tmp[1])], aes_y[tmp[0] & 0xFF]) ^ a[n4 + 7];
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(n9);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(4, n10);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(8, n11);
ByteBuffer.wrap(array3).order(ByteOrder.LITTLE_ENDIAN).putInt(12, n12);
}
for (int i = 0; i < n2; ++i) {
dest[n + i] = array3[i];
}
len -= n2;
n += n2;
}
}
static int[] mystery_key = new int[44];
static int[] aes_x = {
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B,
0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26,
0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2,
0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED,
0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F,
0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC,
0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14,
0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D,
0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F,
0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11,
0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F,
0xB0, 0x54, 0xBB, 0x16
};
static int[] aes_y = {
0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E,
0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32,
0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49,
0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50,
0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05,
0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41,
0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8,
0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B,
0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59,
0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D,
0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63,
0x55, 0x21, 0x0C, 0x7D
};
static long[] rcon = {
0x01000000L, 0x02000000L, 0x04000000L, 0x08000000L, 0x10000000L,
0x20000000L, 0x40000000L, 0xFFFFFFFF80000000L, 0x1B000000L, 0x36000000L
};
}
| UCT-White-Lab/provisioning-jig | fw_update/ST_decrypt.java | Java | mit | 22,664 | [
30522,
12324,
9262,
1012,
22834,
1012,
17698,
2098,
2378,
18780,
21422,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
2378,
18780,
21422,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
17048,
14876,
8630... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2019 The MMapper Authors
#include "abstractparser.h"
#include <map>
#include <memory>
#include <optional>
#include <ostream>
#include <sstream>
#include <vector>
#include "../configuration/configuration.h"
#include "../display/InfoMarkSelection.h"
#include "../expandoracommon/room.h"
#include "../global/TextUtils.h"
#include "../mapdata/DoorFlags.h"
#include "../mapdata/ExitDirection.h"
#include "../mapdata/ExitFlags.h"
#include "../mapdata/customaction.h"
#include "../mapdata/enums.h"
#include "../mapdata/infomark.h"
#include "../mapdata/mapdata.h"
#include "../mapdata/mmapper2room.h"
#include "../syntax/SyntaxArgs.h"
#include "../syntax/TreeParser.h"
#include "AbstractParser-Commands.h"
#include "AbstractParser-Utils.h"
NODISCARD static const char *getTypeName(const InfoMarkTypeEnum type)
{
#define CASE(UPPER, s) \
do { \
case InfoMarkTypeEnum::UPPER: \
return s; \
} while (false)
switch (type) {
CASE(TEXT, "text");
CASE(LINE, "line");
CASE(ARROW, "arrow");
}
return "unknown";
#undef CASE
}
class NODISCARD ArgMarkClass final : public syntax::IArgument
{
private:
syntax::MatchResult virt_match(const syntax::ParserInput &input,
syntax::IMatchErrorLogger *) const override;
std::ostream &virt_to_stream(std::ostream &os) const override;
};
syntax::MatchResult ArgMarkClass::virt_match(const syntax::ParserInput &input,
syntax::IMatchErrorLogger *logger) const
{
if (input.empty())
return syntax::MatchResult::failure(input);
const auto arg = toLowerLatin1(input.front());
StringView sv(arg);
for (const auto &clazz : ::enums::getAllInfoMarkClasses()) {
const auto &command = getParserCommandName(clazz);
if (!command.matches(sv))
continue;
return syntax::MatchResult::success(1, input, Value(clazz));
}
if (logger) {
std::ostringstream os;
for (const auto &clazz : ::enums::getAllInfoMarkClasses())
os << getParserCommandName(clazz).getCommand() << " ";
logger->logError("input was not a valid mark class: " + os.str());
}
return syntax::MatchResult::failure(input);
}
std::ostream &ArgMarkClass::virt_to_stream(std::ostream &os) const
{
return os << "<class>";
}
void AbstractParser::parseMark(StringView input)
{
using namespace ::syntax;
static const auto abb = syntax::abbrevToken;
auto getPositionCoordinate = [this]() -> Coordinate {
// get scaled coordinates of room center.
static_assert(INFOMARK_SCALE % 2 == 0);
const Coordinate halfRoomOffset{INFOMARK_SCALE / 2, INFOMARK_SCALE / 2, 0};
// do not scale the z-coordinate! only x,y should get scaled.
const Coordinate pos = m_mapData.getPosition();
Coordinate c{pos.x * INFOMARK_SCALE, pos.y * INFOMARK_SCALE, pos.z};
c += halfRoomOffset;
return c;
};
auto getInfoMarkSelection = [this](const Coordinate &c) -> std::shared_ptr<InfoMarkSelection> {
// the scaling + offset operation looks like `A*x + b` where A is a 3x3
// transformation matrix and b,x are 3-vectors
// A = [[INFOMARK_SCALE/2, 0 0]
// [0, INFOMARK_SCALE/2, 0]
// [0, 0, 1]]
// b = halfRoomOffset
// x = m_mapData->getPosition()
//
// c = A*x + b
static_assert(INFOMARK_SCALE % 5 == 0);
static constexpr auto INFOMARK_ROOM_RADIUS = INFOMARK_SCALE / 2;
const auto lo = c + Coordinate{-INFOMARK_ROOM_RADIUS, -INFOMARK_ROOM_RADIUS, 0};
const auto hi = c + Coordinate{+INFOMARK_ROOM_RADIUS, +INFOMARK_ROOM_RADIUS, 0};
return InfoMarkSelection::alloc(m_mapData, lo, hi);
};
auto listMark = Accept(
[getPositionCoordinate, getInfoMarkSelection](User &user, const Pair * /*args*/) {
auto &os = user.getOstream();
auto printCoordinate = [&os](const Coordinate c) {
os << "(" << c.x << ", " << c.y << ", " << c.z << ")";
};
const Coordinate c = getPositionCoordinate();
os << "Marks near coordinate ";
printCoordinate(c);
os << std::endl;
int n = 0;
std::shared_ptr<InfoMarkSelection> is = getInfoMarkSelection(c);
for (const auto &mark : *is) {
if (n != 0)
os << std::endl;
os << "\x1b[32m" << ++n << "\x1b[0m: " << getTypeName(mark->getType()) << std::endl;
os << " angle: " << mark->getRotationAngle() << std::endl;
os << " class: " << getParserCommandName(mark->getClass()).getCommand()
<< std::endl;
if (mark->getType() == InfoMarkTypeEnum::TEXT)
os << " text: " << mark->getText().getStdString() << std::endl;
else {
os << " pos1: ";
printCoordinate(mark->getPosition1());
os << std::endl;
os << " pos2: ";
printCoordinate(mark->getPosition2());
os << std::endl;
}
}
},
"list marks");
auto listSyntax = buildSyntax(abb("list"), listMark);
auto removeMark = Accept(
[this, getPositionCoordinate, getInfoMarkSelection](User &user, const Pair *args) {
auto &os = user.getOstream();
const auto v = getAnyVectorReversed(args);
if constexpr (IS_DEBUG_BUILD) {
const auto &set = v[0].getString();
assert(set == "remove");
}
const Coordinate c = getPositionCoordinate();
std::shared_ptr<InfoMarkSelection> is = getInfoMarkSelection(c);
const auto index = static_cast<size_t>(v[1].getInt() - 1);
assert(index >= 0);
if (index >= is->size())
throw std::runtime_error("unable to select mark");
// delete the infomark
const auto &mark = is->at(index);
m_mapData.removeMarker(mark);
emit sig_infoMarksChanged();
send_ok(os);
},
"remove mark");
auto removeSyntax = buildSyntax(abb("remove"),
TokenMatcher::alloc_copy<ArgInt>(ArgInt::withMin(1)),
removeMark);
auto addRoomMark = Accept(
[this, getPositionCoordinate](User &user, const Pair *const args) {
auto &os = user.getOstream();
const auto v = getAnyVectorReversed(args);
if constexpr (IS_DEBUG_BUILD) {
const auto &set = v[0].getString();
assert(set == "add");
}
const std::string text = concatenate_unquoted(v[1].getVector());
if (text.empty()) {
os << "What do you want to set the mark to?\n";
return;
}
// create a text infomark above this room
const Coordinate c = getPositionCoordinate();
auto mark = InfoMark::alloc(m_mapData);
mark->setType(InfoMarkTypeEnum::TEXT);
mark->setText(InfoMarkText{text});
mark->setClass(InfoMarkClassEnum::COMMENT);
mark->setPosition1(c);
m_mapData.addMarker(mark);
emit sig_infoMarksChanged();
send_ok(os);
},
"add mark");
auto addSyntax = buildSyntax(abb("add"), TokenMatcher::alloc<ArgRest>(), addRoomMark);
auto modifyText = Accept(
[this, getPositionCoordinate, getInfoMarkSelection](User &user, const Pair *const args) {
auto &os = user.getOstream();
const auto v = getAnyVectorReversed(args);
if constexpr (IS_DEBUG_BUILD) {
const auto &set = v[0].getString();
assert(set == "set");
const auto &text = v[2].getString();
assert(text == "text");
}
const Coordinate c = getPositionCoordinate();
std::shared_ptr<InfoMarkSelection> is = getInfoMarkSelection(c);
const auto index = static_cast<size_t>(v[1].getInt() - 1);
assert(index >= 0);
if (index >= is->size())
throw std::runtime_error("unable to select mark");
const auto &mark = is->at(index);
if (mark->getType() != InfoMarkTypeEnum::TEXT)
throw std::runtime_error("unable to set text to this mark");
// update text of the first existing text infomark in this room
const std::string text = concatenate_unquoted(v[3].getVector());
if (text.empty()) {
os << "What do you want to set the mark's text to?\n";
return;
}
mark->setText(InfoMarkText{text});
emit sig_infoMarksChanged();
send_ok(os);
},
"modify mark text");
auto modifyClass = Accept(
[this, getPositionCoordinate, getInfoMarkSelection](User &user, const Pair *const args) {
auto &os = user.getOstream();
const auto v = getAnyVectorReversed(args);
if constexpr (IS_DEBUG_BUILD) {
const auto &set = v[0].getString();
assert(set == "set");
const auto &clazz = v[2].getString();
assert(clazz == "class");
}
const Coordinate c = getPositionCoordinate();
std::shared_ptr<InfoMarkSelection> is = getInfoMarkSelection(c);
const auto index = static_cast<size_t>(v[1].getInt() - 1);
assert(index >= 0);
if (index >= is->size())
throw std::runtime_error("unable to select mark");
const auto clazz = v[3].getInfoMarkClass();
const auto &mark = is->at(index);
mark->setClass(clazz);
emit sig_infoMarksChanged();
send_ok(os);
},
"modify mark class");
auto modifyAngle = Accept(
[this, getPositionCoordinate, getInfoMarkSelection](User &user, const Pair *const args) {
auto &os = user.getOstream();
const auto v = getAnyVectorReversed(args);
if constexpr (IS_DEBUG_BUILD) {
const auto &set = v[0].getString();
assert(set == "set");
const auto &angle = v[2].getString();
assert(angle == "angle");
}
const Coordinate c = getPositionCoordinate();
std::shared_ptr<InfoMarkSelection> is = getInfoMarkSelection(c);
const auto index = static_cast<size_t>(v[1].getInt() - 1);
assert(index >= 0);
if (index >= is->size())
throw std::runtime_error("unable to select mark");
const auto &mark = is->at(index);
if (mark->getType() != InfoMarkTypeEnum::TEXT)
throw std::runtime_error("unable to set angle to this mark");
const auto angle = v[3].getInt();
mark->setRotationAngle(angle);
emit sig_infoMarksChanged();
send_ok(os);
},
"modify mark angle");
// REVISIT: Does it make sense to allow user to change the type to arrow or line? What about position?
auto setSyntax
= buildSyntax(abb("set"),
TokenMatcher::alloc_copy<ArgInt>(ArgInt::withMin(1)),
buildSyntax(abb("angle"),
TokenMatcher::alloc_copy<ArgInt>(ArgInt::withMinMax(0, 360)),
modifyAngle),
buildSyntax(abb("class"), TokenMatcher::alloc<ArgMarkClass>(), modifyClass),
buildSyntax(abb("text"), TokenMatcher::alloc<ArgRest>(), modifyText));
auto markSyntax = buildSyntax(addSyntax, listSyntax, removeSyntax, setSyntax);
eval("mark", markSyntax, input);
}
| MUME/MMapper | src/parser/AbstractParser-Mark.cpp | C++ | gpl-2.0 | 12,204 | [
30522,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1016,
1012,
1014,
1011,
2030,
1011,
2101,
1013,
1013,
9385,
1006,
1039,
1007,
10476,
1996,
21021,
18620,
6048,
1001,
2421,
1000,
10061,
19362,
804... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 1995-2012, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
* Version 2, June 1991 (in the distribution as file licence.html,
* and also available at http://gate.ac.uk/gate/licence.html).
*
* HepTag was originally written by Mark Hepple, this version contains
* modifications by Valentin Tablan and Niraj Aswani.
*
* $Id: Rule_PREVTAG.java 15333 2012-02-07 13:18:33Z ian_roberts $
*/
package hepple.postag.rules;
import hepple.postag.*;
/**
* Title: HepTag
* Description: Mark Hepple's POS tagger
* Copyright: Copyright (c) 2001
* Company: University of Sheffield
* @author Mark Hepple
* @version 1.0
*/
public class Rule_PREVTAG extends Rule {
public Rule_PREVTAG() {
}
public boolean checkContext(POSTagger tagger) {
return (tagger.lexBuff[2][0].equals(context[0]));
}
} | liuhongchao/GATE_Developer_7.0 | src/hepple/postag/rules/Rule_PREVTAG.java | Java | lgpl-3.0 | 1,057 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2786,
1011,
2262,
1010,
1996,
2118,
1997,
8533,
1012,
2156,
1996,
5371,
1008,
9385,
1012,
19067,
2102,
1999,
1996,
4007,
2030,
2012,
30524,
1008,
2023,
5371,
2003,
2112,
1997,
4796,
1006,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var jazz = require("../lib/jazz");
var fs = require("fs");
var data = fs.readFileSync(__dirname + "/foreach_object.jazz", "utf8");
var template = jazz.compile(data);
template.eval({"doc": {
"title": "First",
"content": "Some content"
}}, function(data) { console.log(data); });
| shinetech/jazz | examples/foreach_object.js | JavaScript | mit | 288 | [
30522,
13075,
4166,
1027,
5478,
1006,
1000,
1012,
1012,
1013,
5622,
2497,
1013,
4166,
1000,
1007,
1025,
13075,
1042,
2015,
1027,
5478,
1006,
1000,
1042,
2015,
1000,
1007,
1025,
13075,
2951,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
deps_config := \
lib/Kconfig \
drivers/crypto/Kconfig \
crypto/async_tx/Kconfig \
crypto/Kconfig \
security/integrity/ima/Kconfig \
security/tomoyo/Kconfig \
security/smack/Kconfig \
security/selinux/Kconfig \
security/Kconfig \
lib/Kconfig.kmemcheck \
lib/Kconfig.kgdb \
samples/Kconfig \
kernel/trace/Kconfig \
mm/Kconfig.debug \
lib/Kconfig.debug \
arch/arm/Kconfig.debug \
fs/dlm/Kconfig \
fs/nls/Kconfig \
fs/partitions/Kconfig \
fs/9p/Kconfig \
fs/afs/Kconfig \
fs/coda/Kconfig \
fs/ncpfs/Kconfig \
fs/cifs/Kconfig \
fs/ceph/Kconfig \
fs/smbfs/Kconfig \
net/sunrpc/Kconfig \
fs/nfsd/Kconfig \
fs/nfs/Kconfig \
fs/exofs/Kconfig \
fs/ufs/Kconfig \
fs/sysv/Kconfig \
fs/romfs/Kconfig \
fs/qnx4/Kconfig \
fs/hpfs/Kconfig \
fs/omfs/Kconfig \
fs/minix/Kconfig \
fs/freevxfs/Kconfig \
fs/squashfs/Kconfig \
fs/cramfs/Kconfig \
fs/logfs/Kconfig \
fs/ubifs/Kconfig \
fs/jffs2/Kconfig \
fs/yaffs2/Kconfig \
fs/efs/Kconfig \
fs/bfs/Kconfig \
fs/befs/Kconfig \
fs/hfsplus/Kconfig \
fs/hfs/Kconfig \
fs/ecryptfs/Kconfig \
fs/affs/Kconfig \
fs/adfs/Kconfig \
fs/configfs/Kconfig \
fs/sysfs/Kconfig \
fs/proc/Kconfig \
fs/ntfs/Kconfig \
fs/fat/Kconfig \
fs/udf/Kconfig \
fs/isofs/Kconfig \
fs/cachefiles/Kconfig \
fs/fscache/Kconfig \
fs/fuse/Kconfig \
fs/autofs4/Kconfig \
fs/autofs/Kconfig \
fs/quota/Kconfig \
fs/notify/inotify/Kconfig \
fs/notify/dnotify/Kconfig \
fs/notify/Kconfig \
fs/nilfs2/Kconfig \
fs/btrfs/Kconfig \
fs/ocfs2/Kconfig \
fs/gfs2/Kconfig \
fs/xfs/Kconfig \
fs/jfs/Kconfig \
fs/reiserfs/Kconfig \
fs/jbd2/Kconfig \
fs/jbd/Kconfig \
fs/ext4/Kconfig \
fs/ext3/Kconfig \
fs/ext2/Kconfig \
fs/Kconfig \
drivers/btport/Kconfig \
drivers/platform/x86/Kconfig \
drivers/platform/Kconfig \
drivers/staging/msm/Kconfig \
drivers/staging/mrst-touchscreen/Kconfig \
drivers/staging/xgifb/Kconfig \
drivers/staging/adis16255/Kconfig \
drivers/staging/ti-st/Kconfig \
drivers/staging/cxt1e1/Kconfig \
drivers/staging/crystalhd/Kconfig \
drivers/staging/dt3155v4l/Kconfig \
drivers/staging/dt3155/Kconfig \
drivers/staging/sm7xx/Kconfig \
drivers/staging/samsung-laptop/Kconfig \
drivers/staging/batman-adv/Kconfig \
drivers/staging/wlags49_h25/Kconfig \
drivers/staging/wlags49_h2/Kconfig \
drivers/staging/ramzswap/Kconfig \
drivers/staging/iio/trigger/Kconfig \
drivers/staging/iio/light/Kconfig \
drivers/staging/iio/imu/Kconfig \
drivers/staging/iio/gyro/Kconfig \
drivers/staging/iio/adc/Kconfig \
drivers/staging/iio/accel/Kconfig \
drivers/staging/iio/Kconfig \
drivers/staging/sep/Kconfig \
drivers/staging/memrar/Kconfig \
drivers/staging/rar_register/Kconfig \
drivers/staging/vme/boards/Kconfig \
drivers/staging/vme/devices/Kconfig \
drivers/staging/vme/bridges/Kconfig \
drivers/staging/vme/Kconfig \
drivers/staging/hv/Kconfig \
drivers/staging/udlfb/Kconfig \
drivers/staging/vt6656/Kconfig \
drivers/staging/vt6655/Kconfig \
drivers/staging/quatech_usb2/Kconfig \
drivers/staging/serqt_usb2/Kconfig \
drivers/staging/octeon/Kconfig \
drivers/gpu/drm/nouveau/Kconfig \
drivers/gpu/drm/vmwgfx/Kconfig \
drivers/staging/line6/Kconfig \
drivers/staging/phison/Kconfig \
drivers/staging/pohmelfs/Kconfig \
drivers/staging/dream/camera/Kconfig \
drivers/staging/dream/Kconfig \
drivers/staging/android/Kconfig \
drivers/staging/frontier/Kconfig \
drivers/staging/rtl8192e/Kconfig \
drivers/staging/rtl8192u/Kconfig \
drivers/staging/rtl8192su/Kconfig \
drivers/staging/rtl8187se/Kconfig \
drivers/staging/panel/Kconfig \
drivers/staging/asus_oled/Kconfig \
drivers/staging/comedi/Kconfig \
drivers/staging/rt2870/Kconfig \
drivers/staging/rt2860/Kconfig \
drivers/staging/otus/Kconfig \
drivers/staging/echo/Kconfig \
drivers/staging/wlan-ng/Kconfig \
drivers/staging/winbond/Kconfig \
drivers/staging/usbip/Kconfig \
drivers/staging/tm6000/Kconfig \
drivers/staging/cx25821/Kconfig \
drivers/staging/go7007/Kconfig \
drivers/staging/slicoss/Kconfig \
drivers/staging/et131x/Kconfig \
drivers/staging/Kconfig \
drivers/xen/Kconfig \
drivers/vlynq/Kconfig \
drivers/uio/Kconfig \
drivers/auxdisplay/Kconfig \
drivers/dca/Kconfig \
drivers/dma/Kconfig \
drivers/rtc/Kconfig \
drivers/edac/Kconfig \
drivers/infiniband/ulp/iser/Kconfig \
drivers/infiniband/ulp/srp/Kconfig \
drivers/infiniband/ulp/ipoib/Kconfig \
drivers/infiniband/hw/nes/Kconfig \
drivers/infiniband/hw/mlx4/Kconfig \
drivers/infiniband/hw/cxgb4/Kconfig \
drivers/infiniband/hw/cxgb3/Kconfig \
drivers/infiniband/hw/amso1100/Kconfig \
drivers/infiniband/hw/ehca/Kconfig \
drivers/infiniband/hw/qib/Kconfig \
drivers/infiniband/hw/ipath/Kconfig \
drivers/infiniband/hw/mthca/Kconfig \
drivers/infiniband/Kconfig \
drivers/accessibility/Kconfig \
drivers/switch/Kconfig \
drivers/leds/Kconfig \
drivers/memstick/host/Kconfig \
drivers/memstick/core/Kconfig \
drivers/memstick/Kconfig \
drivers/mmc/host/Kconfig \
drivers/mmc/card/Kconfig \
drivers/mmc/core/Kconfig \
drivers/mmc/Kconfig \
drivers/uwb/Kconfig \
drivers/usb/function/Kconfig \
drivers/usb/otg/Kconfig \
drivers/usb/gadget/Kconfig \
drivers/usb/atm/Kconfig \
drivers/usb/misc/sisusbvga/Kconfig \
drivers/usb/misc/Kconfig \
drivers/usb/serial/Kconfig \
drivers/usb/image/Kconfig \
drivers/usb/storage/Kconfig \
drivers/usb/class/Kconfig \
drivers/usb/musb/Kconfig \
drivers/usb/host/Kconfig \
drivers/usb/wusbcore/Kconfig \
drivers/usb/mon/Kconfig \
drivers/usb/core/Kconfig \
drivers/usb/Kconfig \
drivers/hid/usbhid/Kconfig \
drivers/hid/Kconfig \
sound/oss/Kconfig \
sound/soc/codecs/Kconfig \
sound/soc/msm/Kconfig \
sound/soc/txx9/Kconfig \
sound/soc/sh/Kconfig \
sound/soc/s6000/Kconfig \
sound/soc/s3c24xx/Kconfig \
sound/soc/pxa/Kconfig \
sound/soc/omap/Kconfig \
sound/soc/imx/Kconfig \
sound/soc/fsl/Kconfig \
sound/soc/davinci/Kconfig \
sound/soc/blackfin/Kconfig \
sound/soc/au1x/Kconfig \
sound/soc/atmel/Kconfig \
sound/soc/Kconfig \
sound/parisc/Kconfig \
sound/sparc/Kconfig \
sound/pcmcia/Kconfig \
sound/usb/Kconfig \
sound/sh/Kconfig \
sound/mips/Kconfig \
sound/spi/Kconfig \
sound/atmel/Kconfig \
sound/arm/Kconfig \
sound/aoa/soundbus/Kconfig \
sound/aoa/codecs/Kconfig \
sound/aoa/fabrics/Kconfig \
sound/aoa/Kconfig \
sound/ppc/Kconfig \
sound/pci/hda/Kconfig \
sound/pci/Kconfig \
sound/isa/Kconfig \
sound/drivers/Kconfig \
sound/core/seq/Kconfig \
sound/core/Kconfig \
sound/oss/dmasound/Kconfig \
sound/Kconfig \
drivers/video/logo/Kconfig \
drivers/video/console/Kconfig \
drivers/video/display/Kconfig \
drivers/video/backlight/Kconfig \
drivers/video/omap2/displays/Kconfig \
drivers/video/omap2/omapfb/Kconfig \
drivers/video/omap2/dss/Kconfig \
drivers/video/omap2/Kconfig \
drivers/video/omap/Kconfig \
drivers/video/msm/vidc/Kconfig \
drivers/video/msm/Kconfig \
drivers/video/msm_8x60/sii9234/Kconfig \
drivers/video/msm_8x60/vidc/Kconfig \
drivers/video/msm_8x60/Kconfig \
drivers/video/geode/Kconfig \
drivers/gpu/drm/radeon/Kconfig \
drivers/gpu/drm/Kconfig \
drivers/gpu/vga/Kconfig \
drivers/char/agp/Kconfig \
drivers/video/Kconfig \
drivers/media/dvb/frontends/Kconfig \
drivers/media/dvb/ngene/Kconfig \
drivers/media/dvb/mantis/Kconfig \
drivers/media/dvb/pt1/Kconfig \
drivers/media/dvb/firewire/Kconfig \
drivers/media/dvb/dm1105/Kconfig \
drivers/media/dvb/pluto2/Kconfig \
drivers/media/dvb/bt8xx/Kconfig \
drivers/media/dvb/b2c2/Kconfig \
drivers/media/dvb/siano/Kconfig \
drivers/media/dvb/ttusb-dec/Kconfig \
drivers/media/dvb/ttusb-budget/Kconfig \
drivers/media/dvb/dvb-usb/Kconfig \
drivers/media/dvb/ttpci/Kconfig \
drivers/media/dvb/Kconfig \
drivers/media/radio/si470x/Kconfig \
drivers/media/radio/Kconfig \
drivers/media/video/msm/Kconfig \
drivers/media/video/pwc/Kconfig \
drivers/media/video/zc0301/Kconfig \
drivers/media/video/sn9c102/Kconfig \
drivers/media/video/et61x251/Kconfig \
drivers/media/video/usbvideo/Kconfig \
drivers/media/video/usbvision/Kconfig \
drivers/media/video/cx231xx/Kconfig \
drivers/media/video/tlg2300/Kconfig \
drivers/media/video/em28xx/Kconfig \
drivers/media/video/hdpvr/Kconfig \
drivers/media/video/pvrusb2/Kconfig \
drivers/media/video/gspca/gl860/Kconfig \
drivers/media/video/gspca/stv06xx/Kconfig \
drivers/media/video/gspca/m5602/Kconfig \
drivers/media/video/gspca/Kconfig \
drivers/media/video/uvc/Kconfig \
drivers/media/video/saa7164/Kconfig \
drivers/media/video/cx18/Kconfig \
drivers/media/video/ivtv/Kconfig \
drivers/media/video/au0828/Kconfig \
drivers/media/video/cx23885/Kconfig \
drivers/media/video/cx88/Kconfig \
drivers/media/video/saa7134/Kconfig \
drivers/media/video/zoran/Kconfig \
drivers/media/video/cpia2/Kconfig \
drivers/media/video/bt8xx/Kconfig \
drivers/media/video/omap/Kconfig \
drivers/media/video/cx25840/Kconfig \
drivers/media/video/Kconfig \
drivers/media/common/tuners/Kconfig \
drivers/media/IR/keymaps/Kconfig \
drivers/media/IR/Kconfig \
drivers/media/common/Kconfig \
drivers/media/Kconfig \
drivers/regulator/Kconfig \
drivers/mfd/Kconfig \
drivers/ssb/Kconfig \
drivers/watchdog/Kconfig \
drivers/thermal/Kconfig \
drivers/hwmon/Kconfig \
drivers/power/Kconfig \
drivers/w1/slaves/Kconfig \
drivers/w1/masters/Kconfig \
drivers/w1/Kconfig \
drivers/gpio/Kconfig \
drivers/pps/clients/Kconfig \
drivers/pps/Kconfig \
drivers/spi/Kconfig \
drivers/i2c/chips/Kconfig \
drivers/i2c/busses/Kconfig \
drivers/i2c/algos/Kconfig \
drivers/i2c/Kconfig \
drivers/s390/char/Kconfig \
drivers/char/tpm/Kconfig \
drivers/char/pcmcia/Kconfig \
drivers/char/hw_random/Kconfig \
drivers/char/ipmi/Kconfig \
drivers/char/diag/Kconfig \
drivers/serial/Kconfig \
drivers/char/Kconfig \
drivers/input/gameport/Kconfig \
drivers/input/serio/Kconfig \
drivers/input/opticaljoystick/Kconfig \
drivers/input/misc/Kconfig \
drivers/input/touchscreen/Kconfig \
drivers/input/tablet/Kconfig \
drivers/input/joystick/iforce/Kconfig \
drivers/input/joystick/Kconfig \
drivers/input/mouse/Kconfig \
drivers/input/keyboard/Kconfig \
drivers/input/Kconfig \
drivers/telephony/Kconfig \
drivers/isdn/hardware/mISDN/Kconfig \
drivers/isdn/mISDN/Kconfig \
drivers/isdn/hysdn/Kconfig \
drivers/isdn/gigaset/Kconfig \
drivers/isdn/hardware/eicon/Kconfig \
drivers/isdn/hardware/avm/Kconfig \
drivers/isdn/hardware/Kconfig \
drivers/isdn/capi/Kconfig \
drivers/isdn/act2000/Kconfig \
drivers/isdn/sc/Kconfig \
drivers/isdn/pcbit/Kconfig \
drivers/isdn/icn/Kconfig \
drivers/isdn/hisax/Kconfig \
drivers/isdn/i4l/Kconfig \
drivers/isdn/Kconfig \
drivers/net/caif/Kconfig \
drivers/s390/net/Kconfig \
drivers/ieee802154/Kconfig \
drivers/atm/Kconfig \
drivers/net/wan/Kconfig \
drivers/net/pcmcia/Kconfig \
drivers/net/usb/Kconfig \
drivers/net/wimax/SQN/Kconfig \
drivers/net/wimax/i2400m/Kconfig \
drivers/net/wimax/Kconfig \
drivers/net/wireless/bcm4330/Kconfig \
drivers/net/wireless/bcm4329_CES/Kconfig \
drivers/net/wireless/bcm4329_248/Kconfig \
drivers/net/wireless/bcm4329_204/Kconfig \
drivers/net/wireless/zd1211rw/Kconfig \
drivers/net/wireless/wl12xx/Kconfig \
drivers/net/wireless/rt2x00/Kconfig \
drivers/net/wireless/p54/Kconfig \
drivers/net/wireless/orinoco/Kconfig \
drivers/net/wireless/libertas/Kconfig \
drivers/net/wireless/iwmc3200wifi/Kconfig \
drivers/net/wireless/iwlwifi/Kconfig \
drivers/net/wireless/ipw2x00/Kconfig \
drivers/net/wireless/hostap/Kconfig \
drivers/net/wireless/b43legacy/Kconfig \
drivers/net/wireless/b43/Kconfig \
drivers/net/wireless/ath/ar9170/Kconfig \
drivers/net/wireless/ath/ath9k/Kconfig \
drivers/net/wireless/ath/ath5k/Kconfig \
drivers/net/wireless/ath/Kconfig \
drivers/net/wireless/rtl818x/Kconfig \
drivers/net/wireless/Kconfig \
drivers/net/tokenring/Kconfig \
drivers/net/benet/Kconfig \
drivers/net/sfc/Kconfig \
drivers/net/stmmac/Kconfig \
drivers/net/ixp2000/Kconfig \
drivers/net/octeon/Kconfig \
drivers/net/fs_enet/Kconfig \
drivers/net/ibm_newemac/Kconfig \
drivers/net/tulip/Kconfig \
drivers/net/arm/Kconfig \
drivers/net/phy/Kconfig \
drivers/net/arcnet/Kconfig \
drivers/net/Kconfig \
drivers/macintosh/Kconfig \
drivers/message/i2o/Kconfig \
drivers/ieee1394/Kconfig \
drivers/firewire/Kconfig \
drivers/message/fusion/Kconfig \
drivers/md/Kconfig \
drivers/ata/Kconfig \
drivers/scsi/osd/Kconfig \
drivers/scsi/device_handler/Kconfig \
drivers/scsi/pcmcia/Kconfig \
drivers/scsi/arm/Kconfig \
drivers/scsi/qla4xxx/Kconfig \
drivers/scsi/qla2xxx/Kconfig \
drivers/scsi/mpt2sas/Kconfig \
drivers/scsi/megaraid/Kconfig.megaraid \
drivers/scsi/mvsas/Kconfig \
drivers/scsi/aic94xx/Kconfig \
drivers/scsi/aic7xxx/Kconfig.aic79xx \
drivers/scsi/aic7xxx/Kconfig.aic7xxx \
drivers/scsi/be2iscsi/Kconfig \
drivers/scsi/bnx2i/Kconfig \
drivers/scsi/cxgb3i/Kconfig \
drivers/scsi/libsas/Kconfig \
drivers/scsi/Kconfig \
drivers/ide/Kconfig \
drivers/misc/mpu3050/Kconfig \
drivers/misc/video_core/720p/Kconfig \
drivers/misc/iwmc3200top/Kconfig \
drivers/misc/cb710/Kconfig \
drivers/misc/eeprom/Kconfig \
drivers/misc/c2port/Kconfig \
drivers/misc/Kconfig \
drivers/s390/block/Kconfig \
drivers/block/drbd/Kconfig \
drivers/block/paride/Kconfig \
drivers/block/Kconfig \
drivers/pnp/pnpacpi/Kconfig \
drivers/pnp/pnpbios/Kconfig \
drivers/pnp/isapnp/Kconfig \
drivers/pnp/Kconfig \
drivers/parport/Kconfig \
drivers/of/Kconfig \
drivers/mtd/ubi/Kconfig.debug \
drivers/mtd/ubi/Kconfig \
drivers/mtd/lpddr/Kconfig \
drivers/mtd/onenand/Kconfig \
drivers/mtd/nand/Kconfig \
drivers/mtd/devices/Kconfig \
drivers/mtd/maps/Kconfig \
drivers/mtd/chips/Kconfig \
drivers/mtd/Kconfig \
drivers/connector/Kconfig \
drivers/base/Kconfig \
drivers/Kconfig \
net/caif/Kconfig \
net/9p/Kconfig \
net/rfkill/Kconfig \
net/wimax/Kconfig \
net/mac80211/Kconfig \
net/wireless/Kconfig \
net/rxrpc/Kconfig \
drivers/bluetooth/Kconfig \
net/bluetooth/hidbrcm/Kconfig \
net/bluetooth/hidp/Kconfig \
net/bluetooth/cmtp/Kconfig \
net/bluetooth/bnep/Kconfig \
net/bluetooth/rfcomm/Kconfig \
net/bluetooth/Kconfig \
drivers/net/irda/Kconfig \
net/irda/ircomm/Kconfig \
net/irda/irnet/Kconfig \
net/irda/irlan/Kconfig \
net/irda/Kconfig \
drivers/net/can/usb/Kconfig \
drivers/net/can/sja1000/Kconfig \
drivers/net/can/mscan/Kconfig \
drivers/net/can/Kconfig \
net/can/Kconfig \
drivers/net/hamradio/Kconfig \
net/ax25/Kconfig \
net/dcb/Kconfig \
net/sched/Kconfig \
net/ieee802154/Kconfig \
net/phonet/Kconfig \
net/wanrouter/Kconfig \
net/econet/Kconfig \
net/lapb/Kconfig \
net/x25/Kconfig \
drivers/net/appletalk/Kconfig \
net/ipx/Kconfig \
net/llc/Kconfig \
net/decnet/Kconfig \
net/8021q/Kconfig \
net/dsa/Kconfig \
net/bridge/Kconfig \
net/802/Kconfig \
net/l2tp/Kconfig \
net/atm/Kconfig \
net/tipc/Kconfig \
net/rds/Kconfig \
net/sctp/Kconfig \
net/dccp/ccids/Kconfig \
net/dccp/Kconfig \
net/bridge/netfilter/Kconfig \
net/decnet/netfilter/Kconfig \
net/ipv6/netfilter/Kconfig \
net/ipv4/netfilter/Kconfig \
net/netfilter/ipvs/Kconfig \
net/netfilter/Kconfig \
net/netlabel/Kconfig \
net/ipv6/Kconfig \
net/ipv4/Kconfig \
net/iucv/Kconfig \
net/xfrm/Kconfig \
net/unix/Kconfig \
net/packet/Kconfig \
net/Kconfig \
kernel/power/Kconfig \
fs/Kconfig.binfmt \
drivers/cpuidle/Kconfig \
drivers/cpufreq/Kconfig \
mm/Kconfig \
kernel/Kconfig.preempt \
kernel/time/Kconfig \
drivers/pcmcia/Kconfig \
drivers/pci/Kconfig \
arch/arm/common/Kconfig \
arch/arm/Kconfig-nommu \
arch/arm/mm/Kconfig \
arch/arm/mach-w90x900/Kconfig \
arch/arm/mach-vexpress/Kconfig \
arch/arm/mach-versatile/Kconfig \
arch/arm/mach-ux500/Kconfig \
arch/arm/mach-u300/Kconfig \
arch/arm/plat-stmp3xxx/Kconfig \
arch/arm/mach-shmobile/Kconfig \
arch/arm/mach-s5pv210/Kconfig \
arch/arm/mach-s5pc100/Kconfig \
arch/arm/mach-s5p6442/Kconfig \
arch/arm/mach-s5p6440/Kconfig \
arch/arm/mach-s3c64xx/Kconfig \
arch/arm/mach-s3c2443/Kconfig \
arch/arm/mach-s3c2440/Kconfig \
arch/arm/mach-s3c2416/Kconfig \
arch/arm/mach-s3c2412/Kconfig \
arch/arm/mach-s3c2410/Kconfig \
arch/arm/mach-s3c2400/Kconfig \
arch/arm/mach-spear6xx/Kconfig600 \
arch/arm/mach-spear6xx/Kconfig \
arch/arm/mach-spear3xx/Kconfig320 \
arch/arm/mach-spear3xx/Kconfig310 \
arch/arm/mach-spear3xx/Kconfig300 \
arch/arm/mach-spear3xx/Kconfig \
arch/arm/plat-spear/Kconfig \
arch/arm/plat-s5p/Kconfig \
arch/arm/plat-s3c24xx/Kconfig \
arch/arm/plat-samsung/Kconfig \
arch/arm/mach-sa1100/Kconfig \
arch/arm/mach-realview/Kconfig \
arch/arm/mach-mmp/Kconfig \
arch/arm/plat-pxa/Kconfig \
arch/arm/mach-pxa/Kconfig \
arch/arm/mach-orion5x/Kconfig \
arch/arm/mach-omap2/Kconfig \
arch/arm/mach-omap1/Kconfig \
arch/arm/plat-omap/Kconfig \
arch/arm/mach-nuc93x/Kconfig \
arch/arm/mach-ns9xxx/Kconfig \
arch/arm/plat-nomadik/Kconfig \
arch/arm/mach-nomadik/Kconfig \
arch/arm/mach-netx/Kconfig \
arch/arm/mach-mx5/Kconfig \
arch/arm/mach-mxc91231/Kconfig \
arch/arm/mach-mx25/Kconfig \
arch/arm/mach-mx3/Kconfig \
arch/arm/mach-mx2/Kconfig \
arch/arm/mach-mx1/Kconfig \
arch/arm/plat-mxc/Kconfig \
arch/arm/mach-mv78xx0/Kconfig \
arch/arm/mach-msm/Kconfig \
arch/arm/mach-loki/Kconfig \
arch/arm/mach-lh7a40x/Kconfig \
arch/arm/mach-ks8695/Kconfig \
arch/arm/mach-kirkwood/Kconfig \
arch/arm/mach-ixp23xx/Kconfig \
arch/arm/mach-ixp2000/Kconfig \
arch/arm/mach-ixp4xx/Kconfig \
arch/arm/mach-iop13xx/Kconfig \
arch/arm/mach-iop33x/Kconfig \
arch/arm/mach-iop32x/Kconfig \
arch/arm/mach-integrator/Kconfig \
arch/arm/mach-h720x/Kconfig \
arch/arm/mach-gemini/Kconfig \
arch/arm/mach-footbridge/Kconfig \
arch/arm/mach-ep93xx/Kconfig \
arch/arm/mach-dove/Kconfig \
arch/arm/mach-davinci/Kconfig \
arch/arm/mach-cns3xxx/Kconfig \
arch/arm/mach-clps711x/Kconfig \
arch/arm/mach-bcmring/Kconfig \
arch/arm/mach-at91/Kconfig \
arch/arm/mach-aaec2000/Kconfig \
kernel/Kconfig.freezer \
kernel/Kconfig.locks \
block/Kconfig.iosched \
block/Kconfig \
kernel/gcov/Kconfig \
arch/Kconfig \
usr/Kconfig \
init/Kconfig \
arch/arm/Kconfig
include/config/auto.conf: \
$(deps_config)
ifneq "$(KERNELVERSION)" "2.6.35.13"
include/config/auto.conf: FORCE
endif
ifneq "$(ARCH)" "arm"
include/config/auto.conf: FORCE
endif
$(deps_config): ;
| wujiku/superstar-kernel-shooter-2.3.4gb | include/config/auto.conf.cmd | Batchfile | gpl-2.0 | 18,365 | [
30522,
2139,
4523,
1035,
9530,
8873,
2290,
1024,
1027,
1032,
5622,
2497,
1013,
21117,
2239,
8873,
2290,
1032,
6853,
1013,
19888,
2080,
1013,
21117,
2239,
8873,
2290,
1032,
19888,
2080,
1013,
2004,
6038,
2278,
1035,
19067,
1013,
21117,
2239,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package eu.stamp_project.dspot.common.configuration.options;
import eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder;
import eu.stamp_project.dspot.common.automaticbuilder.gradle.GradleAutomaticBuilder;
import eu.stamp_project.dspot.common.automaticbuilder.maven.MavenAutomaticBuilder;
import eu.stamp_project.dspot.common.configuration.UserInput;
/**
* Created by Benjamin DANGLOT
* benjamin.danglot@inria.fr
* on 03/10/19
*/
public enum AutomaticBuilderEnum {
Maven() {
@Override
public AutomaticBuilder getAutomaticBuilder(UserInput configuration) {
return new MavenAutomaticBuilder(configuration);
}
},
Gradle() {
@Override
public AutomaticBuilder getAutomaticBuilder(UserInput configuration) {
return new GradleAutomaticBuilder(configuration);
}
};
public abstract AutomaticBuilder getAutomaticBuilder(UserInput configuration);
}
| STAMP-project/dspot | dspot/src/main/java/eu/stamp_project/dspot/common/configuration/options/AutomaticBuilderEnum.java | Java | lgpl-3.0 | 951 | [
30522,
7427,
7327,
1012,
11359,
1035,
2622,
1012,
16233,
11008,
1012,
2691,
1012,
9563,
1012,
7047,
1025,
12324,
7327,
1012,
11359,
1035,
2622,
1012,
16233,
11008,
1012,
2691,
1012,
6882,
8569,
23891,
2099,
1012,
6882,
8569,
23891,
2099,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
\feladat{2}{
Számítsuk ki egy $10\,\textrm{cm}$ hosszú, $10^{-4}\,\textrm{m}^2$ keresztmetszetű alumínium rúd ellenállását! Az alumínium fajlagos ellenállása $2,7 \cdot 10^{-8}\,\Omega\textrm{m}$.
}{}{}
\ifdefined\megoldas
Megoldás:
Az ellenállás
\al{
R
=\rho_\text{Al}\frac{l}{A}
=2,7 \cdot 10^{-8}\,\me{\Omega m}\frac{10\me{cm}}{10^{-4}\me{m^2}}
=2,7\cdot 10^{-5}\me{\Omega}\;.
}
\fi | vidagy/FizikaA2E | 07/02fel.tex | TeX | apache-2.0 | 422 | [
30522,
1032,
10768,
27266,
4017,
1063,
1016,
1065,
1063,
1055,
20722,
12762,
6968,
11382,
1041,
6292,
1002,
2184,
1032,
1010,
1032,
3793,
10867,
1063,
4642,
1065,
1002,
7570,
4757,
9759,
1010,
1002,
2184,
1034,
1063,
1011,
1018,
1065,
1032,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package gradebookdata;
/**
* Represents one row of the course table in the GradeBook database
*
* @author Eric Carlton
*
*/
public class Course {
private String name;
private int weight;
private int ID;
/**
* Create a course with all fields filled
*
* @param name
* name of course
* @param weight
* credit hours ( or weight ) of course
* @param ID
* course_ID in course table
*/
public Course(String name, int weight, int ID) {
this.name = name;
this.weight = weight;
this.ID = ID;
}
/**
* Create a generic course
*/
public Course() {
this("no name", 0, -1);
}
public String getName() {
return name;
}
public Integer getWeight() {
return weight;
}
public Integer getID() {
return ID;
}
/**
* Returns a string formatted as:
* course_name
* course_weight hour(s)
*/
@Override
public String toString() {
String result = name + "\n" + weight;
if (weight == 1)
result = result + " hour";
else
result = result + " hours";
return result;
}
}
| Eric-Carlton/GradeBook | GradeBook/src/gradebookdata/Course.java | Java | mit | 1,062 | [
30522,
7427,
3694,
8654,
2850,
2696,
1025,
1013,
1008,
1008,
1008,
5836,
2028,
5216,
1997,
1996,
2607,
2795,
1999,
1996,
3694,
8654,
7809,
1008,
1008,
1030,
3166,
4388,
12989,
1008,
1008,
1013,
2270,
2465,
2607,
1063,
2797,
5164,
2171,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//simple GUI for the Matching program
package compare;
//importing requird libraries
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class FilePicker extends JPanel {
//declaring required variables
private String textFieldLabel;
private String buttonLabel;
private JLabel label;
public static JTextField textField;
private JButton browseButton;
private JFileChooser fileChooser;
public static String fileName, outputDestination, filePath;
private int mode;
public static final int MODE_OPEN = 1;
public static final int MODE_SAVE = 2;
public static JLabel categoryLabel;
//Constructor for the UI
public FilePicker(String textFieldLabel, String buttonLabel) {
this.textFieldLabel = textFieldLabel;
this.buttonLabel = buttonLabel;
fileChooser = new JFileChooser();
label = new JLabel(textFieldLabel);
textField = new JTextField(30);
browseButton = new JButton(buttonLabel);
browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
browseButtonActionPerformed(evt);
}
});
add(label);
add(textField);
add(browseButton);
}
//browse button click event
private void browseButtonActionPerformed(ActionEvent evt) {
if (mode == MODE_OPEN) {
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
textField.setText(fileChooser.getSelectedFile().getAbsolutePath());
}
} else if (mode == MODE_SAVE) {
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
textField.setText(fileChooser.getSelectedFile().getAbsolutePath());
}
}
this.filePath = getSelectedFilePath();
}
//adding required filter for browsing files
public void addFileTypeFilter(String extension, String description) {
FileTypeFilter filter = new FileTypeFilter(extension, description);
fileChooser.addChoosableFileFilter(filter);
}
//browsing mode
public void setMode(int mode) {
this.mode = mode;
}
//get file path of the selected file
public static String getSelectedFilePath() {
return textField.getText();
}
//get the file Chooser
public JFileChooser getFileChooser() {
return this.fileChooser;
}
}
| nowshad-sust/ImageMatching-RGB | src/compare/FilePicker.java | Java | apache-2.0 | 2,982 | [
30522,
1013,
1013,
3722,
26458,
2005,
1996,
9844,
2565,
7427,
12826,
1025,
1013,
1013,
12324,
2075,
2128,
15549,
4103,
8860,
12324,
9262,
1012,
22091,
2102,
1012,
3675,
8485,
5833,
1025,
12324,
9262,
1012,
22091,
2102,
1012,
4834,
8485,
583... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
////////////////////////////////////////////////////////////
// Copyright (c) 2011 - 2012 Hiairrassary Victor
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
////////////////////////////////////////////////////////////
#ifndef PLASTIC_CONSOLEVIEW_HPP
#define PLASTIC_CONSOLEVIEW_HPP
#include <string>
namespace plt
{
/////////////////////////////////////////////////////////////////
///
/////////////////////////////////////////////////////////////////
class ConsoleView
{
public:
// Destructeur
virtual ~ConsoleView();
// Fonction appelée lors de la mise à jour de la console
virtual void update() = 0;
// Fonction appelée lors de l'affichage de la console
virtual void draw() const = 0;
// Fonction appelée lors de l'activation / désactivation de la console
virtual void show(bool visible) = 0;
// Fonction appelée après l'appel à une commande
virtual void commandCalled(const std::string &result) = 0;
// Fonction appelée à chaque changement de la ligne courante
virtual void textChanged(const std::string &newText) = 0;
// Fonction appelée en cas d'erreur
virtual void error(const std::string &message) = 0;
};
} // namespace plt
#endif // PLASTIC_CONSOLEVIEW_HPP
////////////////////////////////////////////////////////////
/// \class plt::ConsoleView
///
///
////////////////////////////////////////////////////////////
| projetpeip-montp2/badger | console/ConsoleView.hpp | C++ | bsd-3-clause | 3,079 | [
30522,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{% extends "layout.html" %}
{% block page_title %} Add medication {% endblock %}
{% block head %}
{% include "includes/head.html" %}
{% include "includes/scripts.html" %}
{% endblock %}
{% block after_header %}
{{ banner.input() }}
{% endblock %}
{% block content %}
<main id="content" role="main" tabindex="-1">
<div class="grid-row" id="FEP8">
<div class="column-two-thirds">
<h1 class="heading-large">Your <span class="currentCondition"></span> medication</h1>
<p>Tell us about your current <span class="currentCondition"></span> medication, as well as medication that you have now stopped taking</p>
<div class="form-group medication">
<div id="medication" class="medication">
</div>
</div>
<div class="form-group">
<a class="bold-small" id="add" href="javascript:goInvisible('/epilepsy/medication/add')">Add more medication</a>
</div>
<div class="form-group" id="question">
<input id="continue" name="continue" class="button" type="button" value="I have finished providing medication" onclick="validate()">
</div>
</div>
{% include "includes/widgets/need-help.html" %}
</div>
</main>
{% endblock %}
{% block body_end %}
<script type="text/javascript">
$('.currentCondition').html(getCurrentConditionName());
// If no medication added yet, show different messages
var medicationList = [];
var orderedMedicationList = [];
var medicationTable = "";
generateMedicationTable();
function validate() {
var question = "Provide details of your " + getCurrentConditionName() + " medication";
var medicationPlayback = "<div class='medication'><div class='grid-row'><p>Medication</p></div>";
var currentMedicationTotal = 0;
orderedMedicationList.forEach(function(medication, index, array) {
medicationPlayback += "<div class='grid-row'>";
medicationPlayback += "<div class='column-half'><p><strong>" + medication.name + "</strong></p></div>";
medicationPlayback += "<div class='column-half'><p>" + moment(medication.start).format("DD/MM/YYYY") + " – " + (medication.end !== undefined ? moment(medication.end).format('DD/MM/YYYY') : "Current") + "</p></div>";
medicationPlayback += "</div>";
if (medication.end === undefined) {
++currentMedicationTotal;
}
});
medicationPlayback += "</div>";
addResponse("FEP", "8", question, orderedMedicationList, medicationPlayback, '/epilepsy/medication/your-medication');
if (currentMedicationTotal > 0) {
go('/epilepsy/confused-drowsy');
} else {
go('/epilepsy/regular-check-ups');
}
}
function generateMedicationTable() {
medicationTable = "";
try {
medicationList = responses["FEP"]["8"].response;
orderedMedicationList = _(medicationList).chain().sortBy(function(medication) { return medication.start; }).sortBy(function(medication) { return medication.end; }).reverse().value();
orderedMedicationList.forEach(function(medication, index) {
medicationTable += '<div class="grid-row"><div class="column-third"><p class="bold-xsmall">' + medication.name + '</p></div><div class="column-third"><p class="font-xsmall">' + moment(medication.start).format('DD/MM/YYYY') + ' – ' + (medication.end !== undefined ? moment(medication.end).format('DD/MM/YYYY') : "Current") + '</p></div><div class="column-third"><p class="bold-xsmall"><a href="javascript:change(' + index + ')">Change <a href="javascript:remove(' + index + ')">Remove</a></p></div></div>'
});
$('#medication').html(medicationTable);
if (orderedMedicationList.length === 0) {
$('#add').html('Add medication');
$('#continue').val('I have never taken ' + getCurrentConditionName() + ' medication');
}
} catch (err) {
$('#add').html('Add medication');
$('#continue').val('I have never taken ' + getCurrentConditionName() + ' medication');
}
}
function remove(index) {
if (confirm('Are you sure want to remove this medication?')) {
orderedMedicationList.splice(index, 1);
addResponse("FEP", "8", question, orderedMedicationList, "List", '/epilepsy/medication/your-medication'); // Make sure ordering changes are saved
generateMedicationTable();
}
}
function change(index) {
addResponse("FEP", "8", question, orderedMedicationList, "List", '/epilepsy/medication/your-medication'); // Make sure ordering changes are saved for correct index
goInvisible('/epilepsy/medication/edit?change=' + index);
}
</script>
{% endblock %} | wayneddgu/fit2drive-ux | app/views/epilepsy/medication/your-medication.html | HTML | mit | 5,267 | [
30522,
1063,
1003,
8908,
1000,
9621,
1012,
16129,
1000,
1003,
1065,
1063,
1003,
3796,
3931,
30524,
1065,
1063,
1003,
2421,
1000,
2950,
1013,
2132,
1012,
16129,
1000,
1003,
1065,
1063,
1003,
2421,
1000,
2950,
1013,
14546,
1012,
16129,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*
* =========================================================================================================
*
* This software consists of voluntary contributions made by many individuals on behalf of the
* Apache Software Foundation. For more information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <webmaster@buession.com> |
* | Copyright @ 2013-2018 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.core.mcrypt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
/**
* RSA 加密对象
*
* @author Yong.Teng
*/
class RSAMcrypt extends AbstractMcrypt {
private static Cipher cipher = null;
private final static Logger logger = LoggerFactory.getLogger(RSAMcrypt.class);
public RSAMcrypt(){
super(Algo.RSA);
initCipher();
}
/**
* @param provider
* 信息摘要对象的提供者
*/
public RSAMcrypt(final Provider provider){
super(Algo.RSA, provider);
initCipher();
}
/**
* @param characterEncoding
* 字符编码
*/
public RSAMcrypt(final String characterEncoding){
super(Algo.RSA, characterEncoding);
initCipher();
}
/**
* @param charset
* 字符编码
*/
public RSAMcrypt(final Charset charset){
super(Algo.RSA, charset);
initCipher();
}
/**
* @param characterEncoding
* 字符编码
* @param provider
* 信息摘要对象的提供者
*/
public RSAMcrypt(final String characterEncoding, final Provider provider){
this(characterEncoding, null, provider);
}
/**
* @param charset
* 字符编码
* @param provider
* 信息摘要对象的提供者
*/
public RSAMcrypt(final Charset charset, final Provider provider){
this(charset, null, provider);
}
/**
* @param characterEncoding
* 字符编码
* @param salt
* 加密密钥
*/
public RSAMcrypt(final String characterEncoding, final String salt){
this(characterEncoding, salt, null);
}
/**
* @param charset
* 字符编码
* @param salt
* 加密密钥
*/
public RSAMcrypt(final Charset charset, final String salt){
this(charset, salt, null);
}
/**
* @param characterEncoding
* 字符编码
* @param salt
* 加密密钥
* @param provider
* 信息摘要对象的提供者
*/
public RSAMcrypt(final String characterEncoding, final String salt, final Provider provider){
super(Algo.RSA, characterEncoding, salt, provider);
initCipher();
}
/**
* @param charset
* 字符编码
* @param salt
* 加密密钥
* @param provider
* 信息摘要对象的提供者
*/
public RSAMcrypt(final Charset charset, final String salt, final Provider provider){
super(Algo.RSA, charset, salt, provider);
initCipher();
}
/**
* 对象加密
*
* @param object
* 需要加密的字符串
*
* @return 加密后的字符串
*/
@Override
public String encode(final Object object){
Key key = getKey();
if(key == null){
return null;
}
byte[] result = encode(key, ParseUtils.object2Byte(object));
logger.debug("RSAMcrypt encode string <{}> by algo <RSA>, salt <{}>", object, getSalt());
return result == null ? null : ParseUtils.byte2Hex(result);
}
/**
* 字符串解密
* 该方法需要提供信息摘要算法支持双向解密才可用
*
* @param cs
* 要被解密的 char 值序列
*
* @return 解密后的字符串
*/
@Override
public String decode(final CharSequence cs){
Key key = getKey();
if(key == null){
return null;
}
byte[] result = decode(key, ParseUtils.hex2Byte(cs.toString()));
logger.debug("RSAMcrypt decode string <{}> by algo <RSA>, salt <{}>", cs, getSalt());
return result == null ? null : new String(result);
}
private final static Cipher initCipher(){
if(cipher == null){
try{
cipher = Cipher.getInstance(Algo.RSA.getName());
}catch(NoSuchAlgorithmException e){
logger.error(e.getMessage());
}catch(NoSuchPaddingException e){
logger.error(e.getMessage());
}
}
return cipher;
}
private final SecretKeyFactory getSecretKeyFactory() throws NoSuchAlgorithmException{
Provider provider = getProvider();
return provider == null ? SecretKeyFactory.getInstance(Algo.RSA.getName()) : SecretKeyFactory.getInstance
(Algo.RSA.getName(), provider);
}
private final Key getKey(){
String salt = getSalt();
if(salt == null){
salt = "";
}
int saltLength = salt.length();
if(saltLength < 16){
for(int i = 1; i <= 16 - saltLength; i++){
salt += " ";
}
}else if(saltLength < 24){
for(int i = 1; i <= 24 - saltLength; i++){
salt += " ";
}
}else if(saltLength < 32){
for(int i = 1; i <= 32 - saltLength; i++){
salt += " ";
}
}else if(saltLength > 32){
salt = salt.substring(0, 31);
}
return new SecretKeySpec(salt.getBytes(getCharset()), Algo.RSA.name());// 转换为RSA专用密钥
}
private final byte[] encode(final Key key, final byte[] data){
if(data == null){
throw new IllegalArgumentException("RSAMcrypt encode object could not be null");
}
try{
cipher.init(Cipher.ENCRYPT_MODE, key);// 初始化为加密模式的密码器
return cipher.doFinal(data);
}catch(InvalidKeyException e){
logger.error(e.getMessage());
}catch(IllegalBlockSizeException e){
logger.error(e.getMessage());
}catch(BadPaddingException e){
logger.error(e.getMessage());
}
return null;
}
private final byte[] decode(final Key key, final byte[] data){
if(data == null){
throw new IllegalArgumentException("RSAMcrypt decode object could not be null");
}
try{
cipher.init(Cipher.DECRYPT_MODE, key);// 初始化为解密模式的密码器
return cipher.doFinal(data); // 明文
}catch(InvalidKeyException e){
logger.error(e.getMessage());
}catch(IllegalBlockSizeException e){
logger.error(e.getMessage());
}catch(BadPaddingException e){
logger.error(e.getMessage());
}
return null;
}
}
| eduosi/buessionframework | buession-core/src/main/java/com/buession/core/mcrypt/RSAMcrypt.java | Java | apache-2.0 | 8,555 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
12130,
6105,
10540,
1012,
1008,
2156,
1996,
5060,
5371,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
1012,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.rizal.lovins.smartkasir.activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.rizal.lovins.smartkasir.R;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
LocationManager mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Location location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
sydney = new LatLng(location.getLatitude(), location.getLongitude());
}
mMap.addMarker(new MarkerOptions().position(sydney).title("Current Position"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
} | RizalLovins/LovinsSmartKasir | app/src/main/java/com/rizal/lovins/smartkasir/activity/MapsActivity.java | Java | apache-2.0 | 3,259 | [
30522,
7427,
4012,
1012,
30524,
4590,
1025,
12324,
11924,
1012,
9808,
1012,
14012,
1025,
12324,
11924,
1012,
2490,
1012,
1058,
2549,
1012,
10439,
1012,
4023,
9006,
4502,
2102,
1025,
12324,
11924,
1012,
2490,
1012,
1058,
2549,
1012,
10439,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'support/doubled_classes'
module RSpec
module Mocks
RSpec.describe 'An instance double with the doubled class loaded' do
include_context "with isolated configuration"
before do
RSpec::Mocks.configuration.verify_doubled_constant_names = true
end
it 'only allows instance methods that exist to be stubbed' do
o = instance_double('LoadedClass', :defined_instance_method => 1)
expect(o.defined_instance_method).to eq(1)
prevents(/does not implement the instance method/) { allow(o).to receive(:undefined_instance_method) }
prevents(/does not implement the instance method/) { allow(o).to receive(:defined_class_method) }
end
it 'only allows instance methods that exist to be expected' do
o = instance_double('LoadedClass')
expect(o).to receive(:defined_instance_method)
o.defined_instance_method
prevents { expect(o).to receive(:undefined_instance_method) }
prevents { expect(o).to receive(:defined_class_method) }
prevents { expect(o).to receive(:undefined_instance_method) }
prevents { expect(o).to receive(:defined_class_method) }
end
USE_CLASS_DOUBLE_MSG = "Perhaps you meant to use `class_double`"
it "suggests using `class_double` when a class method is stubbed" do
o = instance_double("LoadedClass")
prevents(a_string_including(USE_CLASS_DOUBLE_MSG)) { allow(o).to receive(:defined_class_method) }
end
it "doesn't suggest `class_double` when a non-class method is stubbed" do
o = instance_double("LoadedClass")
prevents(a_string_excluding(USE_CLASS_DOUBLE_MSG)) { allow(o).to receive(:undefined_class_method) }
end
it 'allows `send` to be stubbed if it is defined on the class' do
o = instance_double('LoadedClass')
allow(o).to receive(:send).and_return("received")
expect(o.send(:msg)).to eq("received")
end
it 'gives a descriptive error message for NoMethodError' do
o = instance_double("LoadedClass")
expect {
o.defined_private_method
}.to raise_error(NoMethodError,
a_string_including("InstanceDouble(LoadedClass)"))
end
it 'does not allow dynamic methods to be expected' do
# This isn't possible at the moment since an instance of the class
# would be required for the verification, and we only have the
# class itself.
#
# This spec exists as "negative" documentation of the absence of a
# feature, to highlight the asymmetry from class doubles (that do
# support this behaviour).
prevents {
instance_double('LoadedClass', :dynamic_instance_method => 1)
}
end
it 'checks the arity of stubbed methods' do
o = instance_double('LoadedClass')
prevents {
expect(o).to receive(:defined_instance_method).with(:a)
}
reset o
end
it 'checks that stubbed methods are invoked with the correct arity' do
o = instance_double('LoadedClass', :defined_instance_method => 25)
expect {
o.defined_instance_method(:a)
}.to raise_error(ArgumentError,
"Wrong number of arguments. Expected 0, got 1.")
end
if required_kw_args_supported?
it 'allows keyword arguments' do
o = instance_double('LoadedClass', :kw_args_method => true)
expect(o.kw_args_method(1, :required_arg => 'something')).to eq(true)
end
context 'for a method that only accepts keyword args' do
it 'allows hash matchers like `hash_including` to be used in place of the keywords arg hash' do
o = instance_double('LoadedClass')
expect(o).to receive(:kw_args_method).
with(1, hash_including(:required_arg => 1))
o.kw_args_method(1, :required_arg => 1)
end
it 'allows anything matcher to be used in place of the keywords arg hash' do
o = instance_double('LoadedClass')
expect(o).to receive(:kw_args_method).with(1, anything)
o.kw_args_method(1, :required_arg => 1)
end
it 'still checks positional arguments when matchers used for keyword args' do
o = instance_double('LoadedClass')
prevents(/Expected 1, got 3/) {
expect(o).to receive(:kw_args_method).
with(1, 2, 3, hash_including(:required_arg => 1))
}
reset o
end
it 'does not allow matchers to be used in an actual method call' do
o = instance_double('LoadedClass')
matcher = hash_including(:required_arg => 1)
allow(o).to receive(:kw_args_method).with(1, matcher)
expect {
o.kw_args_method(1, matcher)
}.to raise_error(ArgumentError)
end
end
context 'for a method that accepts a mix of optional keyword and positional args' do
it 'allows hash matchers like `hash_including` to be used in place of the keywords arg hash' do
o = instance_double('LoadedClass')
expect(o).to receive(:mixed_args_method).with(1, 2, hash_including(:optional_arg_1 => 1))
o.mixed_args_method(1, 2, :optional_arg_1 => 1)
end
end
it 'checks that stubbed methods with required keyword args are ' +
'invoked with the required arguments' do
o = instance_double('LoadedClass', :kw_args_method => true)
expect {
o.kw_args_method(:optional_arg => 'something')
}.to raise_error(ArgumentError)
end
end
it 'validates `with` args against the method signature when stubbing a method' do
dbl = instance_double(LoadedClass)
prevents(/Wrong number of arguments. Expected 2, got 3./) {
allow(dbl).to receive(:instance_method_with_two_args).with(3, :foo, :args)
}
end
it 'allows class to be specified by constant' do
o = instance_double(LoadedClass, :defined_instance_method => 1)
expect(o.defined_instance_method).to eq(1)
end
context "when the class const has been previously stubbed" do
before { class_double(LoadedClass).as_stubbed_const }
it "uses the original class to verify against for `instance_double('LoadedClass')`" do
o = instance_double("LoadedClass")
allow(o).to receive(:defined_instance_method)
prevents { allow(o).to receive(:undefined_method) }
end
it "uses the original class to verify against for `instance_double(LoadedClass)`" do
o = instance_double(LoadedClass)
allow(o).to receive(:defined_instance_method)
prevents { allow(o).to receive(:undefined_method) }
end
end
context "when given a class that has an overriden `#name` method" do
it "properly verifies" do
o = instance_double(LoadedClassWithOverridenName)
allow(o).to receive(:defined_instance_method)
prevents { allow(o).to receive(:undefined_method) }
end
end
context 'for null objects' do
let(:obj) { instance_double('LoadedClass').as_null_object }
it 'only allows defined methods' do
expect(obj.defined_instance_method).to eq(obj)
prevents { obj.undefined_method }
prevents { obj.send(:undefined_method) }
prevents { obj.__send__(:undefined_method) }
end
it 'verifies arguments' do
expect {
obj.defined_instance_method(:too, :many, :args)
}.to raise_error(ArgumentError, "Wrong number of arguments. Expected 0, got 3.")
end
it "includes the double's name in a private method error" do
expect {
obj.rand
}.to raise_error(NoMethodError, a_string_including("private", "InstanceDouble(LoadedClass)"))
end
it 'reports what public messages it responds to accurately' do
expect(obj.respond_to?(:defined_instance_method)).to be true
expect(obj.respond_to?(:defined_instance_method, true)).to be true
expect(obj.respond_to?(:defined_instance_method, false)).to be true
expect(obj.respond_to?(:undefined_method)).to be false
expect(obj.respond_to?(:undefined_method, true)).to be false
expect(obj.respond_to?(:undefined_method, false)).to be false
end
it 'reports that it responds to defined private methods when the appropriate arg is passed' do
expect(obj.respond_to?(:defined_private_method)).to be false
expect(obj.respond_to?(:defined_private_method, true)).to be true
expect(obj.respond_to?(:defined_private_method, false)).to be false
end
if RUBY_VERSION.to_f < 2.0 # respond_to?(:protected_method) changed behavior in Ruby 2.0.
it 'reports that it responds to protected methods' do
expect(obj.respond_to?(:defined_protected_method)).to be true
expect(obj.respond_to?(:defined_protected_method, true)).to be true
expect(obj.respond_to?(:defined_protected_method, false)).to be true
end
else
it 'reports that it responds to protected methods when the appropriate arg is passed' do
expect(obj.respond_to?(:defined_protected_method)).to be false
expect(obj.respond_to?(:defined_protected_method, true)).to be true
expect(obj.respond_to?(:defined_protected_method, false)).to be false
end
end
end
end
end
end
| ducthanh/rspec-mocks | spec/rspec/mocks/verifying_doubles/instance_double_with_class_loaded_spec.rb | Ruby | mit | 9,728 | [
30522,
5478,
1005,
2490,
1013,
11515,
1035,
4280,
1005,
11336,
12667,
5051,
2278,
11336,
12934,
2015,
12667,
5051,
2278,
1012,
6235,
1005,
2019,
6013,
3313,
2007,
1996,
11515,
2465,
8209,
1005,
2079,
2421,
1035,
6123,
1000,
2007,
7275,
9563... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var Parameter = require("../src/Parameter");
var OT = require("./FRP");
var glow = require("./glow");
__export(require("./types"));
var DEBUG = false;
/**
* Each frame an animation is provided a CanvasTick. The tick exposes access to the local animation time, the
* time delta between the previous frame (dt) and the drawing context. Animators typically use the drawing context
* directly, and pass the clock onto any time varying parameters.
*/
var CanvasTick = (function (_super) {
__extends(CanvasTick, _super);
function CanvasTick(clock, dt, ctx, events, previous) {
_super.call(this, clock, dt, previous);
this.clock = clock;
this.dt = dt;
this.ctx = ctx;
this.events = events;
this.previous = previous;
}
CanvasTick.prototype.copy = function () {
return new CanvasTick(this.clock, this.dt, this.ctx, this.events, this.previous);
};
CanvasTick.prototype.save = function () {
var cp = _super.prototype.save.call(this);
cp.ctx.save();
return cp;
};
CanvasTick.prototype.restore = function () {
var cp = _super.prototype.restore.call(this);
cp.ctx.restore();
return cp;
};
return CanvasTick;
})(OT.BaseTick);
exports.CanvasTick = CanvasTick;
var Animation = (function (_super) {
__extends(Animation, _super);
function Animation(attach) {
_super.call(this, attach);
this.attach = attach;
}
/**
* subclasses should override this to create another animation of the same type
* @param attach
*/
Animation.prototype.create = function (attach) {
if (attach === void 0) { attach = function (nop) { return nop; }; }
return new Animation(attach);
};
/**
* Affect this with an effect to create combined animation.
* Debug messages are inserted around the effect (e.g. a mutation to the canvas).
* You can expose time varying or constant parameters to the inner effect using the optional params.
*/
Animation.prototype.loggedAffect = function (label, effectBuilder, param1, param2, param3, param4, param5, param6, param7, param8) {
if (DEBUG)
console.log(label + ": build");
return this.affect(function () {
if (DEBUG)
console.log(label + ": attach");
var effect = effectBuilder();
return function (tick, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
if (DEBUG) {
var elements = [];
if (arg1)
elements.push(arg1 + "");
if (arg2)
elements.push(arg2 + "");
if (arg3)
elements.push(arg3 + "");
if (arg4)
elements.push(arg4 + "");
if (arg5)
elements.push(arg5 + "");
if (arg6)
elements.push(arg6 + "");
if (arg7)
elements.push(arg7 + "");
if (arg8)
elements.push(arg8 + "");
console.log(label + ": tick (" + elements.join(",") + ")");
}
effect(tick, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
};
}, (param1 ? Parameter.from(param1) : undefined), (param2 ? Parameter.from(param2) : undefined), (param3 ? Parameter.from(param3) : undefined), (param4 ? Parameter.from(param4) : undefined), (param5 ? Parameter.from(param5) : undefined), (param6 ? Parameter.from(param6) : undefined), (param7 ? Parameter.from(param7) : undefined), (param8 ? Parameter.from(param8) : undefined));
};
Animation.prototype.velocity = function (velocity) {
if (DEBUG)
console.log("velocity: build");
return this.affect(function () {
if (DEBUG)
console.log("velocity: attach");
var pos = [0.0, 0.0];
return function (tick, velocity) {
if (DEBUG)
console.log("velocity: tick", velocity, pos);
tick.ctx.transform(1, 0, 0, 1, pos[0], pos[1]);
pos[0] += velocity[0] * tick.dt;
pos[1] += velocity[1] * tick.dt;
};
}, Parameter.from(velocity));
};
Animation.prototype.tween_linear = function (from, to, time) {
return this.affect(function () {
var t = 0;
if (DEBUG)
console.log("tween: init");
return function (tick, from, to, time) {
t = t + tick.dt;
if (t > time)
t = time;
var x = from[0] + (to[0] - from[0]) * t / time;
var y = from[1] + (to[1] - from[1]) * t / time;
if (DEBUG)
console.log("tween: tick", x, y, t);
tick.ctx.transform(1, 0, 0, 1, x, y);
};
}, Parameter.from(from), Parameter.from(to), Parameter.from(time));
};
Animation.prototype.glow = function (decay) {
if (decay === void 0) { decay = 0.1; }
return glow.glow(this, decay);
};
// Canvas API
/**
* Dynamic chainable wrapper for strokeStyle in the canvas API.
*/
Animation.prototype.strokeStyle = function (color) {
return this.loggedAffect("strokeStyle", function () { return function (tick, color) {
return tick.ctx.strokeStyle = color;
}; }, color);
};
/**
* Dynamic chainable wrapper for fillStyle in the canvas API.
*/
Animation.prototype.fillStyle = function (color) {
return this.loggedAffect("fillStyle", function () { return function (tick, color) {
return tick.ctx.fillStyle = color;
}; }, color);
};
/**
* Dynamic chainable wrapper for shadowColor in the canvas API.
*/
Animation.prototype.shadowColor = function (color) {
return this.loggedAffect("shadowColor", function () { return function (tick, color) {
return tick.ctx.shadowColor = color;
}; }, color);
};
/**
* Dynamic chainable wrapper for shadowBlur in the canvas API.
*/
Animation.prototype.shadowBlur = function (level) {
return this.loggedAffect("shadowBlur", function () { return function (tick, level) {
return tick.ctx.shadowBlur = level;
}; }, level);
};
/**
* Dynamic chainable wrapper for shadowOffsetX and shadowOffsetY in the canvas API.
*/
Animation.prototype.shadowOffset = function (xy) {
return this.loggedAffect("shadowOffset", function () { return function (tick, xy) {
tick.ctx.shadowOffsetX = xy[0];
tick.ctx.shadowOffsetY = xy[1];
}; }, xy);
};
/**
* Dynamic chainable wrapper for lineCap in the canvas API.
*/
Animation.prototype.lineCap = function (style) {
return this.loggedAffect("lineCap", function () { return function (tick, arg) {
return tick.ctx.lineCap = arg;
}; }, style);
};
/**
* Dynamic chainable wrapper for lineJoin in the canvas API.
*/
Animation.prototype.lineJoin = function (style) {
return this.loggedAffect("lineJoin", function () { return function (tick, arg) {
return tick.ctx.lineJoin = arg;
}; }, style);
};
/**
* Dynamic chainable wrapper for lineWidth in the canvas API.
*/
Animation.prototype.lineWidth = function (width) {
return this.loggedAffect("lineWidth", function () { return function (tick, arg) {
return tick.ctx.lineWidth = arg;
}; }, width);
};
/**
* Dynamic chainable wrapper for miterLimit in the canvas API.
*/
Animation.prototype.miterLimit = function (limit) {
return this.loggedAffect("miterLimit", function () { return function (tick, arg) {
return tick.ctx.miterLimit = arg;
}; }, limit);
};
/**
* Dynamic chainable wrapper for rect in the canvas API.
*/
Animation.prototype.rect = function (xy, width_height) {
return this.loggedAffect("rect", function () { return function (tick, xy, width_height) {
return tick.ctx.rect(xy[0], xy[1], width_height[0], width_height[1]);
}; }, xy, width_height);
};
/**
* Dynamic chainable wrapper for fillRect in the canvas API.
*/
Animation.prototype.fillRect = function (xy, width_height) {
return this.loggedAffect("fillRect", function () { return function (tick, xy, width_height) {
return tick.ctx.fillRect(xy[0], xy[1], width_height[0], width_height[1]);
}; }, xy, width_height);
};
/**
* Dynamic chainable wrapper for strokeRect in the canvas API.
*/
Animation.prototype.strokeRect = function (xy, width_height) {
return this.loggedAffect("strokeRect", function () { return function (tick, xy, width_height) {
return tick.ctx.strokeRect(xy[0], xy[1], width_height[0], width_height[1]);
}; }, xy, width_height);
};
/**
* Dynamic chainable wrapper for clearRect in the canvas API.
*/
Animation.prototype.clearRect = function (xy, width_height) {
return this.loggedAffect("clearRect", function () { return function (tick, xy, width_height) {
return tick.ctx.clearRect(xy[0], xy[1], width_height[0], width_height[1]);
}; }, xy, width_height);
};
/**
* Encloses the inner animation with a beginpath() and endpath() from the canvas API.
*
* This returns a path object which events can be subscribed to
*/
Animation.prototype.withinPath = function (inner) {
return this.pipe(new PathAnimation(function (upstream) {
if (DEBUG)
console.log("withinPath: attach");
var beginPathBeforeInner = upstream.tapOnNext(function (tick) { return tick.ctx.beginPath(); });
return inner.attach(beginPathBeforeInner).tapOnNext(function (tick) { return tick.ctx.closePath(); });
}));
};
/**
* Dynamic chainable wrapper for fill in the canvas API.
*/
Animation.prototype.closePath = function () {
return this.loggedAffect("closePath", function () { return function (tick) {
return tick.ctx.closePath();
}; });
};
/**
* Dynamic chainable wrapper for fill in the canvas API.
*/
Animation.prototype.beginPath = function () {
return this.loggedAffect("beginPath", function () { return function (tick) {
return tick.ctx.beginPath();
}; });
};
/**
* Dynamic chainable wrapper for fill in the canvas API.
*/
Animation.prototype.fill = function () {
return this.loggedAffect("fill", function () { return function (tick) {
return tick.ctx.fill();
}; });
};
/**
* Dynamic chainable wrapper for stroke in the canvas API.
*/
Animation.prototype.stroke = function () {
return this.loggedAffect("stroke", function () { return function (tick) {
return tick.ctx.stroke();
}; });
};
/**
* Dynamic chainable wrapper for moveTo in the canvas API.
*/
Animation.prototype.moveTo = function (xy) {
return this.loggedAffect("moveTo", function () { return function (tick, xy) {
return tick.ctx.moveTo(xy[0], xy[1]);
}; }, xy);
};
/**
* Dynamic chainable wrapper for lineTo in the canvas API.
*/
Animation.prototype.lineTo = function (xy) {
return this.loggedAffect("lineTo", function () { return function (tick, xy) {
return tick.ctx.lineTo(xy[0], xy[1]);
}; }, xy);
};
/**
* Dynamic chainable wrapper for clip in the canvas API.
*/
Animation.prototype.clip = function () {
return this.loggedAffect("clip", function () { return function (tick) {
return tick.ctx.clip();
}; });
};
/**
* Dynamic chainable wrapper for quadraticCurveTo in the canvas API. Use with withinPath.
*/
Animation.prototype.quadraticCurveTo = function (control, end) {
return this.loggedAffect("quadraticCurveTo", function () { return function (tick, arg1, arg2) {
return tick.ctx.quadraticCurveTo(arg1[0], arg1[1], arg2[0], arg2[1]);
}; }, control, end);
};
/**
* Dynamic chainable wrapper for bezierCurveTo in the canvas API. Use with withinPath.
*/
Animation.prototype.bezierCurveTo = function (control1, control2, end) {
return this.loggedAffect("bezierCurveTo", function () { return function (tick, arg1, arg2, arg3) {
return tick.ctx.bezierCurveTo(arg1[0], arg1[1], arg2[0], arg2[1], arg3[0], arg3[1]);
}; }, control1, control2, end);
};
/**
* Dynamic chainable wrapper for arc in the canvas API. Use with withinPath.
*/
Animation.prototype.arcTo = function (tangent1, tangent2, radius) {
return this.loggedAffect("arcTo", function () { return function (tick, arg1, arg2, arg3) {
return tick.ctx.arcTo(arg1[0], arg1[1], arg2[0], arg2[1], arg3);
}; }, tangent1, tangent2, radius);
};
/**
* Dynamic chainable wrapper for scale in the canvas API.
*/
Animation.prototype.scale = function (xy) {
return this.loggedAffect("scale", function () { return function (tick, xy) {
return tick.ctx.scale(xy[0], xy[1]);
}; }, xy);
};
/**
* Dynamic chainable wrapper for rotate in the canvas API.
*/
Animation.prototype.rotate = function (clockwiseRadians) {
return this.loggedAffect("rotate", function () { return function (tick, arg) {
return tick.ctx.rotate(arg);
}; }, clockwiseRadians);
};
/**
* Dynamic chainable wrapper for translate in the canvas API.
*/
Animation.prototype.translate = function (xy) {
return this.loggedAffect("translate", function () { return function (tick, xy) {
tick.ctx.translate(xy[0], xy[1]);
}; }, xy);
};
/**
* Dynamic chainable wrapper for translate in the canvas API.
* [ a c e
* b d f
* 0 0 1 ]
*/
Animation.prototype.transform = function (a, b, c, d, e, f) {
return this.loggedAffect("transform", function () { return function (tick, arg1, arg2, arg3, arg4, arg5, arg6) {
return tick.ctx.transform(arg1, arg2, arg3, arg4, arg5, arg6);
}; }, a, b, c, d, e, f);
};
/**
* Dynamic chainable wrapper for setTransform in the canvas API.
*/
Animation.prototype.setTransform = function (a, b, c, d, e, f) {
return this.loggedAffect("setTransform", function () { return function (tick, arg1, arg2, arg3, arg4, arg5, arg6) {
return tick.ctx.setTransform(arg1, arg2, arg3, arg4, arg5, arg6);
}; }, a, b, c, d, e, f);
};
/**
* Dynamic chainable wrapper for font in the canvas API.
*/
Animation.prototype.font = function (style) {
return this.loggedAffect("font", function () { return function (tick, arg) {
return tick.ctx.font = arg;
}; }, style);
};
/**
* Dynamic chainable wrapper for textAlign in the canvas API.
*/
Animation.prototype.textAlign = function (style) {
return this.loggedAffect("textAlign", function () { return function (tick, arg) {
return tick.ctx.textAlign = arg;
}; }, style);
};
/**
* Dynamic chainable wrapper for textBaseline in the canvas API.
*/
Animation.prototype.textBaseline = function (style) {
return this.loggedAffect("textBaseline", function () { return function (tick, arg) {
return tick.ctx.textBaseline = arg;
}; }, style);
};
/**
* Dynamic chainable wrapper for textBaseline in the canvas API.
*/
Animation.prototype.fillText = function (text, xy, maxWidth) {
if (maxWidth) {
return this.loggedAffect("fillText", function () { return function (tick, text, xy, maxWidth) {
return tick.ctx.fillText(text, xy[0], xy[1], maxWidth);
}; }, text, xy, maxWidth);
}
else {
return this.loggedAffect("fillText", function () { return function (tick, text, xy, maxWidth) {
return tick.ctx.fillText(text, xy[0], xy[1]);
}; }, text, xy);
}
};
/**
* Dynamic chainable wrapper for drawImage in the canvas API.
*/
Animation.prototype.drawImage = function (img, xy) {
return this.loggedAffect("drawImage", function () { return function (tick, img, xy) {
return tick.ctx.drawImage(img, xy[0], xy[1]);
}; }, img, xy);
};
/**
* * Dynamic chainable wrapper for globalCompositeOperation in the canvas API.
*/
Animation.prototype.globalCompositeOperation = function (operation) {
return this.loggedAffect("globalCompositeOperation", function () { return function (tick, arg) {
return tick.ctx.globalCompositeOperation = arg;
}; }, operation);
};
Animation.prototype.arc = function (center, radius, radStartAngle, radEndAngle, counterclockwise) {
if (counterclockwise === void 0) { counterclockwise = false; }
return this.loggedAffect("arc", function () { return function (tick, arg1, arg2, arg3, arg4, counterclockwise) {
return tick.ctx.arc(arg1[0], arg1[1], arg2, arg3, arg4, counterclockwise);
}; }, center, radius, radStartAngle, radEndAngle, counterclockwise);
};
return Animation;
})(OT.SignalPipe);
exports.Animation = Animation;
function create(attach) {
if (attach === void 0) { attach = function (x) { return x; }; }
return new Animation(attach);
}
exports.create = create;
var PathAnimation = (function (_super) {
__extends(PathAnimation, _super);
function PathAnimation() {
_super.apply(this, arguments);
}
return PathAnimation;
})(Animation);
exports.PathAnimation = PathAnimation;
function save(width, height, path) {
var GIFEncoder = require('gifencoder');
var fs = require('fs');
var encoder = new GIFEncoder(width, height);
encoder.createReadStream()
.pipe(encoder.createWriteStream({ repeat: 10000, delay: 100, quality: 1 }))
.pipe(fs.createWriteStream(path));
encoder.start();
return new Animation(function (upstream) {
return upstream.tap(function (tick) {
if (DEBUG)
console.log("save: wrote frame");
encoder.addFrame(tick.ctx);
}, function () { console.error("save: not saved", path); }, function () { console.log("save: saved", path); encoder.finish(); });
});
}
exports.save = save;
| tomlarkworthy/animaxe | dist/src/CanvasAnimation.js | JavaScript | mit | 19,265 | [
30522,
13075,
1035,
1035,
8908,
1027,
1006,
2023,
1004,
1004,
30524,
1006,
13075,
1052,
1999,
1038,
1007,
2065,
1006,
1038,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
1052,
1007,
1007,
1040,
1031,
1052,
1033,
1027,
1038,
1031,
1052,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'spec_helper'
describe "Boot Strap Config" do
it "matches the default ruby version" do
require 'toml-rb'
config = TomlRB.load_file("buildpack.toml")
bootstrap_version = config["buildpack"]["ruby_version"]
expect(bootstrap_version).to eq(LanguagePack::RubyVersion::DEFAULT_VERSION_NUMBER)
urls = config["publish"]["Vendor"].map {|h| h["url"] if h["dir"] != "." }.compact
urls.each do |url|
expect(url.include?(bootstrap_version)).to be_truthy, "expected #{url.inspect} to include #{bootstrap_version.inspect} but it did not"
end
expect(`ruby -v`).to match(Regexp.escape(LanguagePack::RubyVersion::DEFAULT_VERSION_NUMBER))
end
end
| orenyk/heroku-buildpack-ruby | spec/helpers/config_spec.rb | Ruby | mit | 682 | [
30522,
5478,
1005,
28699,
1035,
2393,
2121,
1005,
6235,
1000,
9573,
16195,
9530,
8873,
2290,
1000,
2079,
2009,
1000,
3503,
1996,
12398,
10090,
2544,
1000,
2079,
5478,
1005,
3419,
2140,
1011,
21144,
1005,
9530,
8873,
2290,
1027,
3419,
20974,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* linux/arch/arm/plat-omap/sram.c
*
* OMAP SRAM detection and management
*
* Copyright (C) 2005 Nokia Corporation
* Written by Tony Lindgren <tony@atomide.com>
*
* Copyright (C) 2009-2012 Texas Instruments
* Added OMAP4/5 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#undef DEBUG
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <asm/fncpy.h>
#include <asm/tlb.h>
#include <asm/cacheflush.h>
#include <asm/mach/map.h>
#include <plat/sram.h>
#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))
static void __iomem *omap_sram_base;
static unsigned long omap_sram_skip;
static unsigned long omap_sram_size;
static void __iomem *omap_sram_ceil;
/*
* Memory allocator for SRAM: calculates the new ceiling address
* for pushing a function using the fncpy API.
*
* Note that fncpy requires the returned address to be aligned
* to an 8-byte boundary.
*/
void *omap_sram_push_address(unsigned long size)
{
unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
available = omap_sram_ceil - (omap_sram_base + omap_sram_skip);
if (size > available) {
pr_err("Not enough space in SRAM\n");
return NULL;
}
new_ceil -= size;
new_ceil = ROUND_DOWN(new_ceil, 1 << ARCH_FNCPY_ALIGN);
omap_sram_ceil = IOMEM(new_ceil);
return (void *)omap_sram_ceil;
}
/*
* The SRAM context is lost during off-idle and stack
* needs to be reset.
*/
void omap_sram_reset(void)
{
omap_sram_ceil = omap_sram_base + omap_sram_size;
}
/*
* Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
*/
void __init omap_map_sram(unsigned long start, unsigned long size,
unsigned long skip, int cached)
{
if (size == 0)
return;
start = ROUND_DOWN(start, PAGE_SIZE);
omap_sram_size = size;
omap_sram_skip = skip;
omap_sram_base = __arm_ioremap_exec(start, size, cached);
if (!omap_sram_base) {
pr_err("SRAM: Could not map\n");
return;
}
omap_sram_reset();
/*
* Looks like we need to preserve some bootloader code at the
* beginning of SRAM for jumping to flash for reboot to work...
*/
memset_io(omap_sram_base + omap_sram_skip, 0,
omap_sram_size - omap_sram_skip);
}
| s20121035/rk3288_android5.1_repo | kernel/arch/arm/plat-omap/sram.c | C | gpl-3.0 | 2,410 | [
30522,
1013,
1008,
1008,
11603,
1013,
7905,
1013,
2849,
1013,
20228,
4017,
1011,
18168,
9331,
1013,
5034,
3286,
1012,
1039,
1008,
1008,
18168,
9331,
5034,
3286,
10788,
1998,
2968,
1008,
1008,
9385,
1006,
1039,
1007,
2384,
22098,
3840,
1008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLib {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
#region Autogenerated code
public partial class TimeZone : GLib.Opaque {
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_get_type();
public static GLib.GType GType {
get {
IntPtr raw_ret = g_time_zone_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern int g_time_zone_adjust_time(IntPtr raw, int type, long time_);
public int AdjustTime(int type, long time_) {
int raw_ret = g_time_zone_adjust_time(Handle, type, time_);
int ret = raw_ret;
return ret;
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern int g_time_zone_find_interval(IntPtr raw, int type, long time_);
public int FindInterval(int type, long time_) {
int raw_ret = g_time_zone_find_interval(Handle, type, time_);
int ret = raw_ret;
return ret;
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_get_abbreviation(IntPtr raw, int interval);
public string GetAbbreviation(int interval) {
IntPtr raw_ret = g_time_zone_get_abbreviation(Handle, interval);
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
return ret;
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern int g_time_zone_get_offset(IntPtr raw, int interval);
public int GetOffset(int interval) {
int raw_ret = g_time_zone_get_offset(Handle, interval);
int ret = raw_ret;
return ret;
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern bool g_time_zone_is_dst(IntPtr raw, int interval);
public bool IsDst(int interval) {
bool raw_ret = g_time_zone_is_dst(Handle, interval);
bool ret = raw_ret;
return ret;
}
public TimeZone(IntPtr raw) : base(raw) {}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_new(IntPtr identifier);
public TimeZone (string identifier)
{
IntPtr native_identifier = GLib.Marshaller.StringToPtrGStrdup (identifier);
Raw = g_time_zone_new(native_identifier);
GLib.Marshaller.Free (native_identifier);
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_new_local();
public TimeZone ()
{
Raw = g_time_zone_new_local();
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_new_utc();
public static TimeZone NewUtc()
{
TimeZone result = new TimeZone (g_time_zone_new_utc());
return result;
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_time_zone_ref(IntPtr raw);
protected override void Ref (IntPtr raw)
{
if (!Owned) {
g_time_zone_ref (raw);
Owned = true;
}
}
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern void g_time_zone_unref(IntPtr raw);
protected override void Unref (IntPtr raw)
{
if (Owned) {
g_time_zone_unref (raw);
Owned = false;
}
}
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_time_zone_unref (handle);
return false;
}
}
~TimeZone ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
#endregion
}
} | antoniusriha/gtk-sharp | glib/TimeZone.cs | C# | lgpl-2.1 | 3,935 | [
30522,
1013,
1013,
2023,
5371,
2001,
7013,
2011,
1996,
14181,
2243,
1001,
3642,
13103,
1012,
1013,
1013,
2151,
3431,
2081,
2097,
2022,
2439,
2065,
19723,
24454,
4383,
1012,
3415,
15327,
1043,
29521,
1063,
2478,
2291,
1025,
2478,
2291,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Reconnaissance
==============
Project Reconnaissance is a next generation monitoring tool
| nicholashagen/Reconnaissance | README.md | Markdown | apache-2.0 | 91 | [
30522,
8967,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
2622,
8967,
2003,
1037,
2279,
4245,
8822,
6994,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
const express = require('express');
const mongodb = require('mongodb')
const request = require('request');
const app = express();
const server = require('http').createServer(app)
const io = require('socket.io').listen(server)
const mongo_url = 'mongodb://localhost:27017/rally'
const mongo = mongodb.MongoClient()
app.set("port", process.env.PORT || 3001);
// Express only serves static assets in production
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
let is_live = function(event) {
let today = new Date()
let yesterday = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
if ("start" in event) {
if(event.start >= today) {
let end = event.start
if ("end" in event) {
end = event.end
}
if(end <= yesterday) {
return true
}
}
}
return false
}
let events_data;
let updateEventsData = () => {
try {
mongo.connect(mongo_url, (err, db) => {
if (err) {
console.log('Unable to connect to database server', err);
} else {
let collection = db.collection('ra_events');
let results = collection.find({},{'sort': {'start':-1}});
results.toArray((err, data) => {
if (err) {
console.log('Unable to get events from database', err);
} else if (data) {
let parentEvents = {};
let years = new Set();
for (let event of data) {
if (event['type'] === 'parent') {
if (event.year in parentEvents) {
if (is_live(event)) {
event['live'] = 'LIVE event'
}
parentEvents[event.year].push(event)
} else {
parentEvents[event.year] = [event]
}
years.add(event.year)
}
}
years = Array.from(years).sort(function(a, b){return b-a});
events_data = {
"events": parentEvents,
"years": years
};
}
})
}
});
} catch (e) {
console.log('exception thrown by mongo.connect', e);
}
}
let updateRaEvent = (year, code) => {
let evt = year + code;
console.log(evt);
console.log(evt + ': requesting to start update')
// if (false) {
if (evt in jobs) {
return({
'year': year,
'code': code,
'jobid': jobs[evt]
});
console.log(evt + ': job already exists: ' + jobs[evt])
} else {
// send the request to start the job for scrapyd
request.post(
'http://localhost:6800/schedule.json',
{ form: {
project: 'timecontrol',
spider: 'ra_scores',
year: year,
event_code: code,
} },
function (err, response, data) {
if (!err && response.statusCode == 200) {
data = JSON.parse(data)
jobs[evt] = data.jobid
return({year: year, code: code, 'jobid': data.jobid})
console.log(evt + ': starting the update: ' + jobs[evt])
} else {
return({error: err})
}
}
);
}
}
app.get("/api/events", (req, res) => {
if (!events_data) {
updateEventsData();
}
res.send(events_data);
});
app.get('/api/ra/:year/:code', function(req, res, next) {
try {
var year = req.params.year
var code = req.params.code
mongo.connect(mongo_url, function(err, db) {
if (err) {
res.send({error: err});
console.log('Unable to connect to database server', err)
} else {
var collection = db.collection('ra_scores')
collection.findOne({
'year':year,
'event_code':code
}, function(err, data) {
if (err) {
res.send({error: err});
} else if (data) {
res.send(data);
} else {
res.send({no_data: 'There is no data for this event, please update.'});
}
});
}
});
} catch(e) {
next(e)
}
});
var jobs = {};
app.get('/api/ra/update/:year/:code', function(req, res, next) {
var year = req.params.year
var code = req.params.code
res.send(updateRaEvent(year,code));
});
var latestStatus = {};
var waitingClients = [];
var checkStatus = function() {
let srvSockets = io.sockets.sockets;
if (Object.keys(srvSockets).length > 0) {
request.get(
'http://localhost:6800/listjobs.json?project=timecontrol',
function (err, response, data) {
if (!err && response.statusCode == 200) {
data = JSON.parse(data);
latestStatus = data;
} else {
console.log(err)
}
}
);
}
const findInFinshed = (id, status) => {
for (let i in status.finished) {
if (id === status.finished[i].id) {
return true;
}
}
return false;
}
let finishedJobs = [];
for (let evt in jobs) {
if (jobs.hasOwnProperty(evt)) {
let jobid = jobs[evt];
if (latestStatus.finished && findInFinshed(jobid, latestStatus)) {
finishedJobs.push(evt);
console.log(evt);
}
}
}
for (let i in finishedJobs) {
let evt = finishedJobs[i];
console.log(evt + ': finished, removing from jobs');
delete jobs[evt];
}
}
// poll the status from scrapyd every 1 seconds
setInterval(checkStatus, 1000);
io.on('connection', function(client) {
let srvSockets = io.sockets.sockets;
console.log('number of connected clients: ' + Object.keys(srvSockets).length);
client.on('subscribeToStatus', (interval) => {
console.log('client is subscribing to status with interval ', interval);
setInterval(() => {
client.emit('status', latestStatus);
}, interval);
});
});
server.listen(app.get("port"), () => {
console.log(`Find the server at: http://localhost:${app.get("port")}/`); // eslint-disable-line no-console
});
| tylerjw/rallyscores | rallyboard-v2/server.js | JavaScript | mit | 5,883 | [
30522,
9530,
3367,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
9530,
3367,
12256,
3995,
18939,
1027,
5478,
1006,
1005,
12256,
3995,
18939,
1005,
1007,
9530,
3367,
5227,
1027,
5478,
1006,
1005,
5227,
1005,
1007,
1025,
9530,
3367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import markdownIt from 'markdown-it';
import _ from 'lodash';
import footnotes from 'markdown-it-footnote';
export default function (opts) {
const mergedOpts = _.assign({}, opts, { html: true, linkify: true });
const md = markdownIt(mergedOpts).use(footnotes);
if (mergedOpts.openLinksExternally) {
// Remember old renderer, if overriden, or proxy to default renderer
const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
const aIndex = tokens[idx].attrIndex('target');
if (aIndex < 0) {
tokens[idx].attrPush(['target', '_blank']); // add new attribute
} else {
tokens[idx].attrs[aIndex][1] = '_blank'; // replace value of existing attr
}
// pass token to default renderer.
return defaultRender(tokens, idx, options, env, self);
};
}
return md;
}
| alpha721/WikiEduDashboard | app/assets/javascripts/utils/markdown_it.js | JavaScript | mit | 1,010 | [
30522,
12324,
2928,
7698,
4183,
2013,
1005,
2928,
7698,
1011,
2009,
1005,
1025,
12324,
1035,
2013,
1005,
8840,
8883,
2232,
1005,
1025,
12324,
3329,
20564,
2013,
1005,
2928,
7698,
1011,
2009,
1011,
3329,
22074,
1005,
1025,
9167,
12398,
3853,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2012, Event Store LLP
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Event Store LLP nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
using System;
using EventStore.Core.Data;
using EventStore.Core.Messages;
using EventStore.Core.TransactionLog.LogRecords;
using EventStore.Projections.Core.Services.AwakeReaderService;
using NUnit.Framework;
namespace EventStore.Projections.Core.Tests.Services.awake_reader_service
{
[TestFixture]
public class when_handling_comitted_event
{
private AwakeReaderService _it;
private EventRecord _eventRecord;
private StorageMessage.EventCommited _eventCommited;
private Exception _exception;
[SetUp]
public void SetUp()
{
_exception = null;
Given();
When();
}
private void Given()
{
_it = new AwakeReaderService();
_eventRecord = new EventRecord(
10,
new PrepareLogRecord(
500, Guid.NewGuid(), Guid.NewGuid(), 500, 0, "Stream", 99, DateTime.UtcNow, PrepareFlags.Data,
"event", new byte[0], null));
_eventCommited = new StorageMessage.EventCommited(1000, _eventRecord);
}
private void When()
{
try
{
_it.Handle(_eventCommited);
}
catch (Exception ex)
{
_exception = ex;
}
}
[Test]
public void it_is_handled()
{
Assert.IsNull(_exception, (_exception ?? (object)"").ToString());
}
}
} | ianbattersby/EventStore | src/EventStore/EventStore.Projections.Core.Tests/Services/awake_reader_service/when_handling_comitted_event.cs | C# | bsd-3-clause | 3,067 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2262,
1010,
2724,
3573,
2222,
2361,
1013,
1013,
2035,
2916,
9235,
1012,
1013,
1013,
1013,
1013,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1013,
1013,
14080,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'tempfile'
require 'posix-spawn'
module Grit
class Git
include POSIX::Spawn
class GitTimeout < RuntimeError
attr_accessor :command
attr_accessor :bytes_read
def initialize(command = nil, bytes_read = nil)
@command = command
@bytes_read = bytes_read
end
end
# Raised when a native git command exits with non-zero.
class CommandFailed < StandardError
# The full git command that failed as a String.
attr_reader :command
# The integer exit status.
attr_reader :exitstatus
# Everything output on the command's stderr as a String.
attr_reader :err
def initialize(command, exitstatus=nil, err='')
if exitstatus
@command = command
@exitstatus = exitstatus
@err = err
message = "Command failed [#{exitstatus}]: #{command}"
message << "\n\n" << err unless err.nil? || err.empty?
super message
else
super command
end
end
end
undef_method :clone
include GitRuby
def exist?
File.exist?(self.git_dir)
end
def put_raw_object(content, type)
ruby_git.put_raw_object(content, type)
end
def get_raw_object(object_id)
ruby_git.get_raw_object_by_sha1(object_id).content
end
def get_git_object(object_id)
ruby_git.get_raw_object_by_sha1(object_id).to_hash
end
def object_exists?(object_id)
ruby_git.object_exists?(object_id)
end
def select_existing_objects(object_ids)
object_ids.select do |object_id|
object_exists?(object_id)
end
end
class << self
attr_accessor :git_timeout, :git_max_size
def git_binary
@git_binary ||=
ENV['PATH'].split(':').
map { |p| File.join(p, 'git') }.
find { |p| File.exist?(p) }
end
attr_writer :git_binary
end
self.git_timeout = 10
self.git_max_size = 5242880 # 5.megabytes
def self.with_timeout(timeout = 10)
old_timeout = Grit::Git.git_timeout
Grit::Git.git_timeout = timeout
yield
Grit::Git.git_timeout = old_timeout
end
attr_accessor :git_dir, :bytes_read, :work_tree
def initialize(git_dir)
self.git_dir = git_dir
self.work_tree = git_dir.gsub(/\/\.git$/,'')
self.bytes_read = 0
end
def shell_escape(str)
str.to_s.gsub("'", "\\\\'").gsub(";", '\\;')
end
alias_method :e, :shell_escape
# Check if a normal file exists on the filesystem
# +file+ is the relative path from the Git dir
#
# Returns Boolean
def fs_exist?(file)
File.exist?(File.join(self.git_dir, file))
end
# Read a normal file from the filesystem.
# +file+ is the relative path from the Git dir
#
# Returns the String contents of the file
def fs_read(file)
File.read(File.join(self.git_dir, file))
end
# Write a normal file to the filesystem.
# +file+ is the relative path from the Git dir
# +contents+ is the String content to be written
#
# Returns nothing
def fs_write(file, contents)
path = File.join(self.git_dir, file)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write(contents)
end
end
# Delete a normal file from the filesystem
# +file+ is the relative path from the Git dir
#
# Returns nothing
def fs_delete(file)
FileUtils.rm_rf(File.join(self.git_dir, file))
end
# Move a normal file
# +from+ is the relative path to the current file
# +to+ is the relative path to the destination file
#
# Returns nothing
def fs_move(from, to)
FileUtils.mv(File.join(self.git_dir, from), File.join(self.git_dir, to))
end
# Make a directory
# +dir+ is the relative path to the directory to create
#
# Returns nothing
def fs_mkdir(dir)
FileUtils.mkdir_p(File.join(self.git_dir, dir))
end
# Chmod the the file or dir and everything beneath
# +file+ is the relative path from the Git dir
#
# Returns nothing
def fs_chmod(mode, file = '/')
FileUtils.chmod_R(mode, File.join(self.git_dir, file))
end
def list_remotes
Dir.glob(File.join(self.git_dir, 'refs/remotes/*'))
rescue
[]
end
def create_tempfile(seed, unlink = false)
path = Tempfile.new(seed).path
File.unlink(path) if unlink
return path
end
def commit_from_sha(id)
git_ruby_repo = GitRuby::Repository.new(self.git_dir)
object = git_ruby_repo.get_object_by_sha1(id)
if object.type == :commit
id
elsif object.type == :tag
object.object
else
''
end
end
# Checks if the patch of a commit can be applied to the given head.
#
# options - grit command options hash
# head_sha - String SHA or ref to check the patch against.
# applies_sha - String SHA of the patch. The patch itself is retrieved
# with #get_patch.
#
# Returns 0 if the patch applies cleanly (according to `git apply`), or
# an Integer that is the sum of the failed exit statuses.
def check_applies(options={}, head_sha=nil, applies_sha=nil)
options, head_sha, applies_sha = {}, options, head_sha if !options.is_a?(Hash)
options = options.dup
options[:env] &&= options[:env].dup
git_index = create_tempfile('index', true)
(options[:env] ||= {}).merge!('GIT_INDEX_FILE' => git_index)
options[:raise] = true
status = 0
begin
native(:read_tree, options.dup, head_sha)
stdin = native(:diff, options.dup, "#{applies_sha}^", applies_sha)
native(:apply, options.merge(:check => true, :cached => true, :input => stdin))
rescue CommandFailed => fail
status += fail.exitstatus
end
status
end
# Gets a patch for a given SHA using `git diff`.
#
# options - grit command options hash
# applies_sha - String SHA to get the patch from, using this command:
# `git diff #{applies_sha}^ #{applies_sha}`
#
# Returns the String patch from `git diff`.
def get_patch(options={}, applies_sha=nil)
options, applies_sha = {}, options if !options.is_a?(Hash)
options = options.dup
options[:env] &&= options[:env].dup
git_index = create_tempfile('index', true)
(options[:env] ||= {}).merge!('GIT_INDEX_FILE' => git_index)
native(:diff, options, "#{applies_sha}^", applies_sha)
end
# Applies the given patch against the given SHA of the current repo.
#
# options - grit command hash
# head_sha - String SHA or ref to apply the patch to.
# patch - The String patch to apply. Get this from #get_patch.
#
# Returns the String Tree SHA on a successful patch application, or false.
def apply_patch(options={}, head_sha=nil, patch=nil)
options, head_sha, patch = {}, options, head_sha if !options.is_a?(Hash)
options = options.dup
options[:env] &&= options[:env].dup
options[:raise] = true
git_index = create_tempfile('index', true)
(options[:env] ||= {}).merge!('GIT_INDEX_FILE' => git_index)
begin
native(:read_tree, options.dup, head_sha)
native(:apply, options.merge(:cached => true, :input => patch))
rescue CommandFailed
return false
end
native(:write_tree, :env => options[:env]).to_s.chomp!
end
# Execute a git command, bypassing any library implementation.
#
# cmd - The name of the git command as a Symbol. Underscores are
# converted to dashes as in :rev_parse => 'rev-parse'.
# options - Command line option arguments passed to the git command.
# Single char keys are converted to short options (:a => -a).
# Multi-char keys are converted to long options (:arg => '--arg').
# Underscores in keys are converted to dashes. These special options
# are used to control command execution and are not passed in command
# invocation:
# :timeout - Maximum amount of time the command can run for before
# being aborted. When true, use Grit::Git.git_timeout; when numeric,
# use that number of seconds; when false or 0, disable timeout.
# :base - Set false to avoid passing the --git-dir argument when
# invoking the git command.
# :env - Hash of environment variable key/values that are set on the
# child process.
# :raise - When set true, commands that exit with a non-zero status
# raise a CommandFailed exception. This option is available only on
# platforms that support fork(2).
# :process_info - By default, a single string with output written to
# the process's stdout is returned. Setting this option to true
# results in a [exitstatus, out, err] tuple being returned instead.
# args - Non-option arguments passed on the command line.
#
# Optionally yields to the block an IO object attached to the child
# process's STDIN.
#
# Examples
# git.native(:rev_list, {:max_count => 10, :header => true}, "master")
#
# Returns a String with all output written to the child process's stdout
# when the :process_info option is not set.
# Returns a [exitstatus, out, err] tuple when the :process_info option is
# set. The exitstatus is an small integer that was the process's exit
# status. The out and err elements are the data written to stdout and
# stderr as Strings.
# Raises Grit::Git::GitTimeout when the timeout is exceeded or when more
# than Grit::Git.git_max_size bytes are output.
# Raises Grit::Git::CommandFailed when the :raise option is set true and the
# git command exits with a non-zero exit status. The CommandFailed's #command,
# #exitstatus, and #err attributes can be used to retrieve additional
# detail about the error.
def native(cmd, options = {}, *args, &block)
args = args.first if args.size == 1 && args[0].is_a?(Array)
args.map! { |a| a.to_s }
args.reject! { |a| a.empty? }
# special option arguments
env = options.delete(:env) || {}
raise_errors = options.delete(:raise)
process_info = options.delete(:process_info)
pipeline = options.delete(:pipeline)
# fall back to using a shell when the last argument looks like it wants to
# start a pipeline for compatibility with previous versions of grit.
if args[-1].to_s[0] == ?| && pipeline
return run(prefix, cmd, '', options, args)
end
# more options
input = options.delete(:input)
timeout = options.delete(:timeout); timeout = true if timeout.nil?
base = options.delete(:base); base = true if base.nil?
chdir = options.delete(:chdir)
# build up the git process argv
argv = []
argv << Git.git_binary
argv << "--git-dir=#{git_dir}" if base
argv << cmd.to_s.tr('_', '-')
argv.concat(options_to_argv(options))
argv.concat(args)
# run it and deal with fallout
Grit.log(argv.join(' ')) if Grit.debug
process =
Child.new(env, *(argv + [{
:input => input,
:chdir => chdir,
:timeout => (Grit::Git.git_timeout if timeout == true),
:max => (Grit::Git.git_max_size if timeout == true)
}]))
Grit.log(process.out) if Grit.debug
Grit.log(process.err) if Grit.debug
status = process.status
if raise_errors && !status.success?
raise CommandFailed.new(argv.join(' '), status.exitstatus, process.err)
elsif process_info
[status.exitstatus, process.out, process.err]
else
process.out
end
rescue TimeoutExceeded, MaximumOutputExceeded
raise GitTimeout, argv.join(' ')
end
# Methods not defined by a library implementation execute the git command
# using #native, passing the method name as the git command name.
#
# Examples:
# git.rev_list({:max_count => 10, :header => true}, "master")
def method_missing(cmd, options={}, *args, &block)
native(cmd, options, *args, &block)
end
# Transform a ruby-style options hash to command-line arguments sutiable for
# use with Kernel::exec. No shell escaping is performed.
#
# Returns an Array of String option arguments.
def options_to_argv(options)
argv = []
options.each do |key, val|
if key.to_s.size == 1
if val == true
argv << "-#{key}"
elsif val == false
# ignore
else
argv << "-#{key}"
argv << val.to_s
end
else
if val == true
argv << "--#{key.to_s.tr('_', '-')}"
elsif val == false
# ignore
else
argv << "--#{key.to_s.tr('_', '-')}=#{val}"
end
end
end
argv
end
# Simple wrapper around Timeout::timeout.
#
# seconds - Float number of seconds before a Timeout::Error is raised. When
# true, the Grit::Git.git_timeout value is used. When the timeout is less
# than or equal to 0, no timeout is established.
#
# Raises Timeout::Error when the timeout has elapsed.
def timeout_after(seconds)
seconds = self.class.git_timeout if seconds == true
if seconds && seconds > 0
Timeout.timeout(seconds) { yield }
else
yield
end
end
# DEPRECATED OPEN3-BASED COMMAND EXECUTION
# Used only for pipeline support.
# Ex.
# git log | grep bugfix
#
def run(prefix, cmd, postfix, options, args, &block)
timeout = options.delete(:timeout) rescue nil
timeout = true if timeout.nil?
base = options.delete(:base) rescue nil
base = true if base.nil?
if input = options.delete(:input)
block = lambda { |stdin| stdin.write(input) }
end
opt_args = transform_options(options)
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/
ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|' || Grit.no_quote) ? a : "\"#{e(a)}\"" }
gitdir = base ? "--git-dir=\"#{self.git_dir}\"" : ""
call = "#{prefix}#{Git.git_binary} #{gitdir} #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
else
ext_args = args.reject { |a| a.empty? }.map { |a| (a == '--' || a[0].chr == '|' || Grit.no_quote) ? a : "'#{e(a)}'" }
gitdir = base ? "--git-dir='#{self.git_dir}'" : ""
call = "#{prefix}#{Git.git_binary} #{gitdir} #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}#{e(postfix)}"
end
Grit.log(call) if Grit.debug
response, err = timeout ? sh(call, &block) : wild_sh(call, &block)
Grit.log(response) if Grit.debug
Grit.log(err) if Grit.debug
response
end
def sh(command, &block)
process =
Child.new(
command,
:timeout => Git.git_timeout,
:max => Git.git_max_size
)
[process.out, process.err]
rescue TimeoutExceeded, MaximumOutputExceeded
raise GitTimeout, command
end
def wild_sh(command, &block)
process = Child.new(command)
[process.out, process.err]
end
# Transform Ruby style options into git command line options
# +options+ is a hash of Ruby style options
#
# Returns String[]
# e.g. ["--max-count=10", "--header"]
def transform_options(options)
args = []
options.keys.each do |opt|
if opt.to_s.size == 1
if options[opt] == true
args << "-#{opt}"
elsif options[opt] == false
# ignore
else
val = options.delete(opt)
args << "-#{opt.to_s} '#{e(val)}'"
end
else
if options[opt] == true
args << "--#{opt.to_s.gsub(/_/, '-')}"
elsif options[opt] == false
# ignore
else
val = options.delete(opt)
args << "--#{opt.to_s.gsub(/_/, '-')}='#{e(val)}'"
end
end
end
args
end
end # Git
end # Grit
| gitcafe-dev/grit | lib/grit/git.rb | Ruby | mit | 16,399 | [
30522,
5478,
1005,
8915,
8737,
8873,
2571,
1005,
5478,
1005,
13433,
5332,
2595,
1011,
25645,
1005,
11336,
24842,
2465,
21025,
2102,
2421,
13433,
5332,
2595,
1024,
1024,
25645,
2465,
21025,
6916,
26247,
4904,
1026,
2448,
7292,
2121,
29165,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">ActiveRecord::ConnectionAdapters::PostgreSQLColumn</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/usr/lib/ruby/gems/1_8/gems/activerecord-3_0_0_beta4/lib/active_record/connection_adapters/postgresql_adapter_rb.html">
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/postgresql_adapter.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
<a href="Column.html">
Column
</a>
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
PostgreSQL-specific extensions to column definitions in a table.
</p>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html> | ecoulthard/summitsearch | doc/api/classes/ActiveRecord/ConnectionAdapters/PostgreSQLColumn.html | HTML | mit | 2,752 | [
30522,
1026,
1029,
20950,
2544,
1027,
1000,
1015,
1012,
1014,
1000,
17181,
1027,
1000,
11163,
1011,
6070,
28154,
1011,
1015,
1000,
1029,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/jax/output/HTML-CSS/autoload/ms.js
*
* Implements the HTML-CSS output for <ms> elements.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2010-2015 The MathJax Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "2.6.0";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
MML.ms.Augment({
toHTML: function (span) {
span = this.HTMLhandleSize(this.HTMLcreateSpan(span));
var values = this.getValues("lquote","rquote","mathvariant");
if (!this.hasValue("lquote") || values.lquote === '"') values.lquote = "\u201C";
if (!this.hasValue("rquote") || values.rquote === '"') values.rquote = "\u201D";
if (values.lquote === "\u201C" && values.mathvariant === "monospace") values.lquote = '"';
if (values.rquote === "\u201D" && values.mathvariant === "monospace") values.rquote = '"';
var text = values.lquote+this.data.join("")+values.rquote; // FIXME: handle mglyph?
this.HTMLhandleVariant(span,this.HTMLgetVariant(),text);
this.HTMLhandleSpace(span);
this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span;
}
});
MathJax.Hub.Startup.signal.Post("HTML-CSS ms Ready");
MathJax.Ajax.loadComplete(HTMLCSS.autoloadDir+"/ms.js");
});
| AndrewSyktyvkar/Math | wysivig/MathJax/unpacked/jax/output/HTML-CSS/autoload/ms.js | JavaScript | bsd-3-clause | 2,124 | [
30522,
1013,
1008,
1011,
1008,
1011,
5549,
1024,
9262,
22483,
1025,
27427,
4765,
1011,
21628,
2015,
1011,
5549,
1024,
9152,
2140,
1025,
1046,
2015,
1011,
27427,
4765,
1011,
2504,
1024,
1016,
1011,
1008,
1011,
1008,
1013,
1013,
1008,
6819,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "tensorflow/compiler/xla/service/gpu/ir_emission_utils.h"
#include "tensorflow/compiler/xla/service/hlo_opcode.h"
#include "tensorflow/compiler/xla/service/llvm_ir/llvm_util.h"
#include "tensorflow/compiler/xla/service/llvm_ir/tuple_ops.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
namespace xla {
namespace gpu {
using tensorflow::strings::StrAppend;
using tensorflow::strings::StrCat;
void HloToIrBindings::EmitBasePointersForHlos(
tensorflow::gtl::ArraySlice<const HloInstruction*> io_hlos,
tensorflow::gtl::ArraySlice<const HloInstruction*> non_io_hlos) {
// I/O HLOs are bound to the arguments of the current IR function. I.e.,
//
// void IrFunction(io_0, io_1, ..., io_{m-1}, temp_buffer_base) {
llvm::Function* function = ir_builder_->GetInsertBlock()->getParent();
CHECK_EQ(io_hlos.size() + 1, function->arg_size());
// An HLO can have duplicated operands. This data structure remembers which
// operand HLOs are already bound to avoid rebinding the same HLO.
std::set<const HloInstruction*> already_bound_for_this_function;
auto arg_iter = function->arg_begin();
for (const HloInstruction* io_hlo : io_hlos) {
if (!already_bound_for_this_function.count(io_hlo)) {
if (!is_nested_ && io_hlo->opcode() == HloOpcode::kGetTupleElement) {
BindHloToIrValue(*io_hlo, EmitGetTupleElement(io_hlo, &*arg_iter));
} else {
BindHloToIrValue(*io_hlo, &*arg_iter);
}
already_bound_for_this_function.insert(io_hlo);
}
++arg_iter;
}
temp_buffer_base_ = &*arg_iter;
temp_buffer_base_->setName("temp_buffer");
for (const HloInstruction* non_io_hlo : non_io_hlos) {
if (already_bound_for_this_function.count(non_io_hlo)) {
continue;
}
already_bound_for_this_function.insert(non_io_hlo);
if (non_io_hlo->opcode() == HloOpcode::kGetTupleElement) {
if (!is_nested_) {
// Lookup allocation GetTupleElement operand.
const BufferAllocation::Slice slice =
buffer_assignment_
->GetUniqueTopLevelSlice(non_io_hlo->LatestNonGteAncestor())
.ConsumeValueOrDie();
// We are not in a nested context, so check non-thread-local allocation.
CHECK(!slice.allocation()->is_thread_local());
const int64 offset = slice.offset();
CHECK_NE(nullptr, temp_buffer_base_);
// Emit IR for GetTupleElement instruction and bind to emitted value.
llvm::Value* base_ptr = ir_builder_->CreateInBoundsGEP(
temp_buffer_base_, ir_builder_->getInt64(offset));
BindHloToIrValue(*non_io_hlo,
EmitGetTupleElement(non_io_hlo, base_ptr));
}
continue;
}
if (!buffer_assignment_->HasTopLevelAllocation(non_io_hlo)) {
continue;
}
ShapeUtil::ForEachSubshape(
non_io_hlo->shape(),
[&](const Shape& /*subshape*/, const ShapeIndex& index) {
// A non-IO HLO with a buffer is bound to
// (1) an alloca if it is thread-local, or
// (2) an internal pointer in temp_buffer_base according to its
// offset.
auto slice_result =
buffer_assignment_->GetUniqueSlice(non_io_hlo, index);
if (!slice_result.ok()) {
return;
}
const BufferAllocation::Slice slice =
slice_result.ConsumeValueOrDie();
if (slice.allocation()->is_thread_local()) {
llvm::Type* pointee_type =
llvm_ir::ShapeToIrType(non_io_hlo->shape(), module_);
BindHloToIrValue(*non_io_hlo,
ir_builder_->CreateAlloca(pointee_type), index);
} else {
const int64 offset = slice.offset();
CHECK_NE(nullptr, temp_buffer_base_);
BindHloToIrValue(
*non_io_hlo,
ir_builder_->CreateInBoundsGEP(temp_buffer_base_,
ir_builder_->getInt64(offset)),
index);
}
});
}
}
llvm::Value* HloToIrBindings::EmitGetTupleElement(const HloInstruction* gte,
llvm::Value* base_ptr) {
// TODO(b/26344050): tighten the alignment based on the real element type.
if (gte->operand(0)->opcode() != HloOpcode::kGetTupleElement) {
return llvm_ir::EmitGetTupleElement(
gte->shape(), gte->tuple_index(), /*alignment=*/1,
GetTypedIrValue(*gte->operand(0), {}, base_ptr), ir_builder_, module_);
}
return llvm_ir::EmitGetTupleElement(
gte->shape(), gte->tuple_index(), /*alignment=*/1,
EmitGetTupleElement(gte->operand(0), base_ptr), ir_builder_, module_);
}
llvm::Value* HloToIrBindings::GetTypedIrValue(const HloInstruction& hlo,
ShapeIndexView shape_index,
llvm::Value* ir_value) {
llvm::Type* pointee_type = llvm_ir::ShapeToIrType(
ShapeUtil::GetSubshape(hlo.shape(), shape_index), module_);
llvm::Type* dest_type = pointee_type->getPointerTo();
llvm::Value* typed_ir_value;
if (llvm::isa<llvm::GlobalVariable>(ir_value)) {
typed_ir_value = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
llvm::cast<llvm::GlobalVariable>(ir_value), dest_type);
} else {
typed_ir_value =
ir_builder_->CreateBitCast(ir_value, pointee_type->getPointerTo());
}
ir_value->setName(llvm_ir::AsStringRef(llvm_ir::IrName(&hlo, "raw")));
typed_ir_value->setName(llvm_ir::AsStringRef(llvm_ir::IrName(&hlo, "typed")));
return typed_ir_value;
}
void HloToIrBindings::BindHloToIrValue(const HloInstruction& hlo,
llvm::Value* ir_value,
ShapeIndexView shape_index) {
VLOG(2) << "Binding " << hlo.ToString();
const Shape& hlo_shape = hlo.shape();
llvm::Value* typed_ir_value = GetTypedIrValue(hlo, shape_index, ir_value);
if (!BoundToIrValue(hlo)) {
// Set the root of ShapeTree first before assigning the element ir value.
InsertOrDie(&base_ptrs_, &hlo, ShapeTree<llvm::Value*>(hlo_shape, nullptr));
}
*(base_ptrs_[&hlo].mutable_element(shape_index)) = typed_ir_value;
}
// Determines whether hlo's buffers are never modified within the execution of
// consumer.
static bool BuffersInvariantWithinConsumer(
const HloInstruction& hlo, const HloInstruction& consumer,
const BufferAssignment* buffer_assignment) {
// Check if consumer is inside a fusion node -- if so, "dereference" it until
// we get to a non-fusion node.
const HloInstruction* c = &consumer;
while (c->IsFused()) {
c = c->parent()->FusionInstruction();
}
// If, after dereferencing c, we end up with a node that's not inside our
// module's top-level computation (say our node is inside a while loop), we
// give up on marking array as invariant, because this HLO may be run multiple
// times (e.g. multiple while loop iterations, or multiple invocations of a
// reducer's computation). TODO(jlebar): We could relax this constraint if we
// emitted an llvm.invariant.group.barrier at the end of the computation.
return c->parent() == c->GetModule()->entry_computation() &&
buffer_assignment->HaveDisjointSlices(&hlo, &consumer);
}
llvm_ir::IrArray HloToIrBindings::GetIrArray(const HloInstruction& hlo,
const HloInstruction& consumer,
const ShapeIndex& shape_index) {
llvm::Value* base_ptr = GetBasePointer(hlo, shape_index);
CHECK_NE(base_ptr, nullptr)
<< "Buffer not assigned for shape_index " << shape_index.ToString()
<< " of " << hlo.ToString();
llvm_ir::IrArray ir_array(base_ptr,
ShapeUtil::GetSubshape(hlo.shape(), shape_index));
alias_analysis_.AddAliasingInformationToIrArray(hlo, &ir_array, shape_index);
// The GPU backend emits one kernel per top-level HLO, and LLVM views
// execution of one kernel as the "whole program" executed on the GPU.
// Therefore if hlo's output buffer is not modified within consumer, and if
// consumer runs hlo only once (so that it doesn't create two different
// outputs), then we can mark ir_array as invariant over the whole program.
if (BuffersInvariantWithinConsumer(hlo, consumer, buffer_assignment_)) {
VLOG(2) << "Marking " << hlo.name() << " as invariant within "
<< consumer.name();
ir_array.MarkInvariantOverWholeProgram(&module_->getContext());
}
return ir_array;
}
void HloToIrBindings::UnbindAllLocalIrValues() {
std::vector<const HloInstruction*> hlos_to_unbind;
for (auto& key_value : base_ptrs_) {
if (!llvm::isa<llvm::GlobalVariable>(
(key_value.second.element({}))->stripPointerCasts())) {
hlos_to_unbind.push_back(key_value.first);
}
}
for (const HloInstruction* hlo_to_unbind : hlos_to_unbind) {
VLOG(2) << "Unbinding " << hlo_to_unbind->ToString();
base_ptrs_.erase(hlo_to_unbind);
}
}
string HloToIrBindings::ToString() const {
string s = StrCat("** HloToIrBindings **\n");
StrAppend(&s, " is_nested_=", is_nested_, "\n");
StrAppend(&s,
" temp_buffer_base_=", llvm_ir::DumpToString(*temp_buffer_base_),
"\n");
if (base_ptrs_.empty()) {
return s;
}
// Iterate over all computations in the module in topological order, and print
// out the base pointers we have in each computation in topological order.
for (const HloComputation* computation :
base_ptrs_.begin()->first->GetModule()->MakeComputationPostOrder()) {
bool is_first = true;
for (const HloInstruction* instr :
computation->MakeInstructionPostOrder()) {
auto it = base_ptrs_.find(instr);
if (it == base_ptrs_.end()) {
continue;
}
if (is_first) {
StrAppend(&s, " Base pointers for computation ", computation->name(),
":\n");
is_first = false;
}
StrAppend(&s, " ", instr->ToString());
const ShapeTree<llvm::Value*>& shape_tree = it->second;
if (!ShapeUtil::IsTuple(instr->shape())) {
const llvm::Value* val = shape_tree.begin()->second;
StrAppend(&s, " -> ", llvm_ir::DumpToString(*val), "\n");
continue;
}
StrAppend(&s, "\n");
for (auto shape_it = shape_tree.begin(); shape_it != shape_tree.end();
++shape_it) {
llvm::Value* val = shape_it->second;
StrAppend(&s, " ", shape_it->first.ToString(), " -> ",
(val != nullptr ? llvm_ir::DumpToString(*val) : "null"),
"\n");
}
}
}
return s;
}
} // namespace gpu
} // namespace xla
| jart/tensorflow | tensorflow/compiler/xla/service/gpu/hlo_to_ir_bindings.cc | C++ | apache-2.0 | 11,720 | [
30522,
1013,
1008,
9385,
2418,
1996,
23435,
12314,
6048,
1012,
2035,
2916,
9235,
1012,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.jogamp.opengl;
public interface GLRunnable {
boolean run(GLAutoDrawable drawable);
}
| gama-platform/gama.cloud | ummisco.gama.opengl_web/src/com/jogamp/opengl/GLRunnable.java | Java | agpl-3.0 | 102 | [
30522,
7427,
4012,
1012,
8183,
22864,
2361,
1012,
2330,
23296,
1025,
2270,
8278,
1043,
20974,
4609,
22966,
1063,
22017,
20898,
2448,
1006,
1043,
17298,
3406,
7265,
4213,
3468,
4009,
3085,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/* TwigBundle:Exception:exception_full.html.twig */
class __TwigTemplate_89290451bd40f3bffff5d45f5e190d274d3a6df08458cdf50865fa795afb7625 extends Twig_Template
{
public function __construct(Twig_Environment $env)
{
parent::__construct($env);
$this->parent = $this->env->loadTemplate("TwigBundle::layout.html.twig");
$this->blocks = array(
'head' => array($this, 'block_head'),
'title' => array($this, 'block_title'),
'body' => array($this, 'block_body'),
);
}
protected function doGetParent(array $context)
{
return "TwigBundle::layout.html.twig";
}
protected function doDisplay(array $context, array $blocks = array())
{
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_head($context, array $blocks = array())
{
// line 4
echo " <link href=\"";
echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/framework/css/exception.css"), "html", null, true);
echo "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />
";
}
// line 7
public function block_title($context, array $blocks = array())
{
// line 8
echo " ";
echo twig_escape_filter($this->env, $this->getAttribute((isset($context["exception"]) ? $context["exception"] : $this->getContext($context, "exception")), "message"), "html", null, true);
echo " (";
echo twig_escape_filter($this->env, (isset($context["status_code"]) ? $context["status_code"] : $this->getContext($context, "status_code")), "html", null, true);
echo " ";
echo twig_escape_filter($this->env, (isset($context["status_text"]) ? $context["status_text"] : $this->getContext($context, "status_text")), "html", null, true);
echo ")
";
}
// line 11
public function block_body($context, array $blocks = array())
{
// line 12
echo " ";
$this->env->loadTemplate("TwigBundle:Exception:exception.html.twig")->display($context);
}
public function getTemplateName()
{
return "TwigBundle:Exception:exception_full.html.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 57 => 12, 54 => 11, 43 => 8, 40 => 7, 33 => 4, 30 => 3,);
}
}
| ArtemKiev/trainer | app/cache/dev/twig/89/29/0451bd40f3bffff5d45f5e190d274d3a6df08458cdf50865fa795afb7625.php | PHP | mit | 2,475 | [
30522,
1026,
1029,
25718,
1013,
1008,
1056,
16279,
27265,
2571,
1024,
6453,
1024,
6453,
1035,
2440,
1012,
16129,
1012,
1056,
16279,
1008,
1013,
2465,
1035,
1035,
1056,
16279,
18532,
15725,
1035,
6486,
24594,
2692,
19961,
2487,
2497,
2094,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
@echo off
setlocal
REM Copyright 2006-2010 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the
REM Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the
REM License is located at http://aws.amazon.com/asl or in the "license" file accompanying this file. This file is distributed on an "AS
REM IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
REM language governing permissions and limitations under the License.
REM Set intermediate env vars because the %VAR:x=y% notation below
REM (which replaces the string x with the string y in VAR)
REM doesn't handle undefined environment variables. This way
REM we're always dealing with defined variables in those tests.
set CHK_HOME=_%EC2_HOME%
if %CHK_HOME% == "_" goto HOME_MISSING
"%EC2_HOME:"=%\bin\ec2-cmd" ReplaceNetworkAclAssociation %*
goto DONE
:HOME_MISSING
echo EC2_HOME is not set
exit /b 1
:DONE
| sujoyg/tool | vendor/ec2-api-tools-1.4.2.2/bin/ec2repnaclassoc.cmd | Batchfile | mit | 1,045 | [
30522,
1030,
9052,
2125,
2275,
4135,
9289,
2128,
2213,
9385,
2294,
1011,
2230,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
7000,
2104,
1996,
2128,
2213,
9733,
4007,
6105,
1006,
1996,
1000,
6105,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model;
import hudson.BulkChange;
import hudson.model.listeners.SaveableListener;
import java.io.IOException;
/**
* Object whose state is persisted to XML.
*
* @author Kohsuke Kawaguchi
* @see BulkChange
* @since 1.249
*/
public interface Saveable {
/**
* Persists the state of this object into XML.
*
* <p>
* For making a bulk change efficiently, see {@link BulkChange}.
*
* <p>
* To support listeners monitoring changes to this object, call {@link SaveableListener#fireOnChange}
* @throws IOException
* if the persistence failed.
*/
void save() throws IOException;
/**
* {@link Saveable} that doesn't save anything.
* @since 1.301.
*/
Saveable NOOP = new Saveable() {
public void save() throws IOException {
}
};
}
| lindzh/jenkins | core/src/main/java/hudson/model/Saveable.java | Java | mit | 2,024 | [
30522,
1013,
1008,
1008,
1996,
10210,
6105,
1008,
1008,
9385,
1006,
1039,
1007,
2432,
1011,
2268,
1010,
3103,
12702,
29390,
1010,
4297,
1012,
1010,
12849,
7898,
15851,
10556,
4213,
16918,
1008,
1008,
6656,
2003,
2182,
3762,
4379,
1010,
2489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//-----------------------------------------------------------------------------
// Filename: SilverlightPolicyServer.cs
//
// Description: Listens for requests from Silverlight clients for policy files. Silverlight
// will request the policy file before allowing a socket connection to a host. The code is
// derived from the example provided by Microsoft in the Silverlight 2.2 Beta SDK.
//
// History:
// 23 Sep 2008 Aaron Clauson Created.
//
// License:
// This software is licensed under the BSD License http://www.opensource.org/licenses/bsd-license.php
//
// Copyright (c) 2008 Aaron Clauson (aaron@sipsorcery.com), SIP Sorcery PTY LTD, Hobart, Australia (www.sipsorcery.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
// the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of SIP Sorcery PTY LTD.
// nor the names of its contributors may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using SIPSorcery.Sys;
using log4net;
namespace SIPSorcery.SIP.App
{
public class SilverlightPolicyServer
{
private ILog logger = AppState.logger;
private Socket m_listener;
private string m_policy =
@"<?xml version='1.0' encoding ='utf-8'?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri='*' />
</allow-from>
<grant-to>
<socket-resource port='4502-4534' protocol='tcp' />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>";
public bool m_exit;
public SilverlightPolicyServer()
{
ThreadPool.QueueUserWorkItem(delegate { Listen(); });
}
public void Stop()
{
try
{
m_exit = true;
m_listener.Close();
}
catch (Exception excp)
{
logger.Error("Exception SilverlightPolicyServer. " + excp.Message);
}
}
private void Listen()
{
// Create the Listening Socket
m_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// Put the socket into dual mode to allow a single socket
// to accept both IPv4 and IPv6 connections
// Otherwise, server needs to listen on two sockets,
// one for IPv4 and one for IPv6
// NOTE: dual-mode sockets are supported on Vista and later
//m_listener.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);
m_listener.Bind(new IPEndPoint(IPAddress.Any, 943));
m_listener.Listen(10);
while (!m_exit)
{
Socket clientSocket = m_listener.Accept();
logger.Debug("SilverlightPolicyServer connection from " + clientSocket.RemoteEndPoint + ".");
PolicyConnection pc = new PolicyConnection(clientSocket, Encoding.UTF8.GetBytes(m_policy));
}
}
}
/// <summary>
/// Encapsulate and manage state for a single connection from a client
/// </summary>
class PolicyConnection
{
private Socket m_connection;
private byte[] m_buffer; // buffer to receive the request from the client
private int m_received;
private byte[] m_policy; // the policy to return to the client
private static string s_policyRequestString = "<policy-file-request/>"; // the request that we're expecting from the client
public PolicyConnection(Socket client, byte[] policy)
{
m_connection = client;
m_policy = policy;
m_buffer = new byte[s_policyRequestString.Length];
m_received = 0;
try
{
// receive the request from the client
m_connection.BeginReceive(m_buffer, 0, s_policyRequestString.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
}
catch (SocketException)
{
m_connection.Close();
}
}
// Called when we receive data from the client
private void OnReceive(IAsyncResult res)
{
try
{
m_received += m_connection.EndReceive(res);
// if we haven't gotten enough for a full request yet, receive again
if (m_received < s_policyRequestString.Length)
{
m_connection.BeginReceive(m_buffer, m_received, s_policyRequestString.Length - m_received, SocketFlags.None, new AsyncCallback(OnReceive), null);
return;
}
// make sure the request is valid
string request = System.Text.Encoding.UTF8.GetString(m_buffer, 0, m_received);
if (StringComparer.InvariantCultureIgnoreCase.Compare(request, s_policyRequestString) != 0)
{
m_connection.Close();
return;
}
// send the policy
m_connection.BeginSend(m_policy, 0, m_policy.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
}
catch (SocketException)
{
m_connection.Close();
}
}
// called after sending the policy to the client; close the connection.
public void OnSend(IAsyncResult res)
{
try
{
m_connection.EndSend(res);
}
finally
{
m_connection.Close();
}
}
}
}
| amccool/sipsorcery | sipsorcery-core/SIPSorcery.SIP.App/SilverlightPolicyServer.cs | C# | bsd-3-clause | 7,309 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"44004016","logradouro":"Travessa 28 de Fevereiro","bairro":"Ch\u00e1cara S\u00e3o Cosme","cidade":"Feira de Santana","uf":"BA","estado":"Bahia"});
| lfreneda/cepdb | api/v1/44004016.jsonp.js | JavaScript | cc0-1.0 | 161 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
17422,
2692,
12740,
16048,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
19817,
21055,
3736,
2654,
2139,
9016,
17166,
1000,
1010,
1000,
21790,
18933,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{-# LANGUAGE DataKinds, PolyKinds, TypeOperators, TypeFamilies
, TypeApplications #-}
module DumpTypecheckedAst where
import Data.Kind
data Peano = Zero | Succ Peano
type family Length (as :: [k]) :: Peano where
Length (a : as) = Succ (Length as)
Length '[] = Zero
data T f (a :: k) = MkT (f a)
type family F (a :: k) (f :: k -> Type) :: Type where
F @Peano a f = T @Peano f a
main = putStrLn "hello"
| sdiehl/ghc | testsuite/tests/parser/should_compile/DumpTypecheckedAst.hs | Haskell | bsd-3-clause | 431 | [
30522,
1063,
1011,
1001,
2653,
2951,
18824,
2015,
1010,
26572,
18824,
2015,
1010,
2828,
25918,
18926,
1010,
2828,
7011,
4328,
11983,
1010,
2828,
29098,
19341,
9285,
1001,
1011,
1065,
11336,
15653,
13874,
5403,
18141,
14083,
2073,
12324,
2951,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package net.robobalasko.dfa.gui;
import net.robobalasko.dfa.core.Automaton;
import net.robobalasko.dfa.core.exceptions.NodeConnectionMissingException;
import net.robobalasko.dfa.core.exceptions.StartNodeMissingException;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainFrame extends JFrame {
private final Automaton automaton;
private JButton checkButton;
public MainFrame(final Automaton automaton) throws HeadlessException {
super("DFA Simulator");
this.automaton = automaton;
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel containerPanel = new JPanel();
containerPanel.setLayout(new BoxLayout(containerPanel, BoxLayout.PAGE_AXIS));
containerPanel.setBorder(new EmptyBorder(20, 20, 20, 20));
setContentPane(containerPanel);
CanvasPanel canvasPanel = new CanvasPanel(this, automaton);
containerPanel.add(canvasPanel);
JPanel checkInputPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
containerPanel.add(checkInputPanel);
final JTextField inputText = new JTextField(40);
Document document = inputText.getDocument();
document.addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
checkButton.setEnabled(e.getDocument().getLength() > 0);
}
@Override
public void removeUpdate(DocumentEvent e) {
checkButton.setEnabled(e.getDocument().getLength() > 0);
}
@Override
public void changedUpdate(DocumentEvent e) {
checkButton.setEnabled(e.getDocument().getLength() > 0);
}
});
checkInputPanel.add(inputText);
checkButton = new JButton("Check");
checkButton.setEnabled(false);
checkButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showMessageDialog(MainFrame.this,
automaton.acceptsString(inputText.getText())
? "Input accepted."
: "Input rejected.");
} catch (StartNodeMissingException ex) {
JOptionPane.showMessageDialog(MainFrame.this, "Missing start node.");
} catch (NodeConnectionMissingException ex) {
JOptionPane.showMessageDialog(MainFrame.this, "Not a good string. Automat doesn't accept it.");
}
}
});
checkInputPanel.add(checkButton);
setResizable(false);
setVisible(true);
pack();
}
}
| robobalasko/DFA-Simulator | src/main/java/net/robobalasko/dfa/gui/MainFrame.java | Java | mit | 3,007 | [
30522,
7427,
5658,
1012,
6487,
16429,
7911,
21590,
1012,
1040,
7011,
1012,
26458,
1025,
12324,
5658,
1012,
6487,
16429,
7911,
21590,
1012,
1040,
7011,
1012,
4563,
1012,
8285,
18900,
2239,
1025,
12324,
5658,
1012,
6487,
16429,
7911,
21590,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/****************************************************************************
* xestion/informes/uso_disco.inc.php
*
* Prepara los datos para mostrar el informe de uso de disco para las raíces
* que tengan limitado el espacio en disco
*******************************************************************************/
defined('OK') && defined('XESTION') or die();
$ud_ordenar = trim($PFN_vars->get('ud_ordenar'));
$ud_modo = trim($PFN_vars->get('ud_modo'));
$ud_ordenar = empty($ud_ordenar)?'nome':$ud_ordenar;
$ud_modo = ($ud_modo == 'DESC')?'DESC':'ASC';
$listado['id'] = $listado['nome'] = $listado['actual'] = $listado['limite'] = $listado['libre'] = array();
$PFN_usuarios->init('raices');
for (; $PFN_usuarios->mais(); $PFN_usuarios->seguinte()) {
$listado['id'][] = $PFN_usuarios->get('id');
$listado['nome'][] = $PFN_usuarios->get('nome');
if ($PFN_usuarios->get('peso_maximo') > 0) {
$actual = $PFN_usuarios->get('peso_actual');
$limite = $PFN_usuarios->get('peso_maximo');
$listado['actual'][] = $actual;
$listado['limite'][] = $limite;
$listado['libre'][] = intval((($limite - $actual) / $limite) * 100);
} else {
$listado['actual'][] = $listado['limite'][] = $listado['libre'][] = false;
}
}
if ($ud_modo == 'ASC') {
asort($listado[$ud_ordenar]);
} else {
arsort($listado[$ud_ordenar]);
}
$b = 1;
$txt = '<table class="tabla_informes" summary="">'
.'<tr><th style="text-align: left;">'
.'<a href="'.PFN_cambia_url(array('ud_ordenar','ud_modo','executa'), array('id',($ud_modo == 'ASC'?'DESC':'ASC'),'uso_disco'))
.'">'.PFN___('Xcol_id').'</a></th>'
.'<th style="text-align: left;">'
.'<a href="'.PFN_cambia_url(array('ud_ordenar','ud_modo','executa'), array('nome',($ud_modo == 'ASC'?'DESC':'ASC'),'uso_disco'))
.'">'.PFN___('Xcol_nome').'</a></th>'
.'<th style="text-align: left;">'
.'<a href="'.PFN_cambia_url(array('ud_ordenar','ud_modo','executa'), array('limite',($ud_modo == 'ASC'?'DESC':'ASC'),'uso_disco'))
.'">'.PFN___('Xcol_peso_limite').'</a></th>'
.'<th style="text-align: left;">'
.'<a href="'.PFN_cambia_url(array('ud_ordenar','ud_modo','executa'), array('actual',($ud_modo == 'ASC'?'DESC':'ASC'),'uso_disco'))
.'">'.PFN___('Xcol_peso_actual').'</a></th>'
.'<th style="text-align: left;">'
.'<a href="'.PFN_cambia_url(array('ud_ordenar','ud_modo','executa'), array('libre',($ud_modo == 'ASC'?'DESC':'ASC'),'uso_disco'))
.'">'.PFN___('Xcol_porcent_libre').'</a></th></tr>';
foreach ((array)$listado[$ud_ordenar] as $k => $v) {
$b++;
$txt .= '<tr'.((($b % 2) == 0)?' class="tr_par"':'').'><td>'.$listado['id'][$k].'</td>'
.'<td><a href="../raices/index.php?'
.PFN_cambia_url('id_raiz', $listado['id'][$k], false).'">'.$listado['nome'][$k].'</a></td>';
if ($listado['limite'][$k]) {
$libre = $listado['libre'][$k];
$cor_libre = ($libre > 50)?'0C0':(($libre > 25)?'FC6':(($libre > 10)?'F60':'F00'));
$txt .= '<td>'.PFN_peso($listado['limite'][$k]).'</td>'
.'<td>'.PFN_peso($listado['actual'][$k]).'</td>'
.'<td style="border: 1px solid #000;"><span style="display: block; border: 1px solid #CCC; width: '.$libre.'%; height: 15px; background-color: #'.$cor_libre.'; font-weight: bold;">'.$libre.'%</span></td></tr>';
} else {
$txt .= '<td colspan="3">'.PFN___('sen_limite').'</td></tr>';
}
}
$txt .= '</table>';
?>
| paxku/pfn | xestion/informes/uso_disco.inc.php | PHP | gpl-2.0 | 3,322 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace DbMockLibrary\Test\MockDataManipulation;
use DbMockLibrary\MockDataManipulation;
use DbMockLibrary\Test\TestCase;
class GetAllCollectionsIfEmptyTest extends TestCase
{
/**
* @dataProvider getData
*
* @param array $data
*
* @return void
*/
public function test_function(array $data)
{
// prepare
MockDataManipulation::initDataContainer(['collection1' => [], 'collection2' => []]);
$reflection = new \ReflectionClass('\DbMockLibrary\MockDataManipulation');
$getAllCollectionsIfEmptyMethod = $reflection->getMethod('getAllCollectionsIfEmpty');
$getAllCollectionsIfEmptyMethod->setAccessible(true);
// invoke logic
$result = $getAllCollectionsIfEmptyMethod->invoke(MockDataManipulation::getInstance(), $data['collections']);
// test
$this->assertEquals($data['expected'], $result);
}
/**
* @return array
*/
public function getData()
{
return [
// #0 not empty
[
[
'collections' => ['collection1'],
'expected' => ['collection1']
]
],
// #1 empty
[
[
'collections' => [],
'expected' => ['collection1', 'collection2']
]
]
];
}
} | ajant/DbMockLibrary | test/MockDataManipulation/GetAllCollectionsIfEmptyTest.php | PHP | mit | 1,444 | [
30522,
1026,
1029,
25718,
3415,
15327,
16962,
5302,
3600,
29521,
19848,
2100,
1032,
3231,
1032,
12934,
2850,
28282,
3490,
14289,
13490,
1025,
30524,
1008,
1008,
1008,
1030,
2951,
21572,
17258,
2121,
2131,
2850,
2696,
1008,
1008,
1030,
11498,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[POJ] 1276. Cash Machine — amoshyc's CPsolution 1.0 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/mine.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="amoshyc's CPsolution 1.0 documentation" href="../index.html"/>
<link rel="up" title="3. POJ" href="poj.html"/>
<link rel="next" title="[POJ] 1308. Is It A Tree?" href="p1308.html"/>
<link rel="prev" title="[POJ] 1151. Atlantis" href="p1151.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> amoshyc's CPsolution
</a>
<div class="version">
1.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../tutorials/tutorials.html">1. 常用演算法教學</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cf/cf.html">2. CF</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="poj.html">3. POJ</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="p1151.html">[POJ] 1151. Atlantis</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">[POJ] 1276. Cash Machine</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">題目</a></li>
<li class="toctree-l3"><a class="reference internal" href="#specification">Specification</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">分析</a></li>
<li class="toctree-l3"><a class="reference internal" href="#ac-code">AC Code</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="p1308.html">[POJ] 1308. Is It A Tree?</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1330.html">[POJ] 1330. Nearest Common Ancestors</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1442.html">[POJ] 1442. Black Box</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1769.html">[POJ] 1769. Minimizing maximizer</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1984.html">[POJ] 1984. Navigation Nightmare</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1988.html">[POJ] 1988. Cube Stacking</a></li>
<li class="toctree-l2"><a class="reference internal" href="p1990.html">[POJ] 1990. MooFest</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2104.html">[POJ] 2104. K-th Number</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2135.html">[POJ] 2135. Farm Tour</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2186.html">[POJ] 2186. Popular Cows</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2230.html">[POJ] 2230. Watchcow</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2349.html">[POJ] 2349. Arctic Network</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2441.html">[POJ] 2441. Arrange the Bulls</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2686.html">[POJ] 2686. Traveling by Stagecoach</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2836.html">[POJ] 2836. Rectangular Covering</a></li>
<li class="toctree-l2"><a class="reference internal" href="p2891.html">[POJ] 2891. Strange Way to Express Integers</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3041.html">[POJ] 3041. Asteroids</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3045.html">[POJ] 3045. Cow Acrobats</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3057.html">[POJ] 3057. Evacuation</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3171.html">[POJ] 3171. Cleaning Shifts</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3233.html">[POJ] 3233. Matrix Power Series</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3254.html">[POJ] 3254. Corn Fields</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3258.html">[POJ] 3258. River Hopscotch</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3264.html">[POJ] 3264. Balanced Lineup</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3273.html">[POJ] 3273. Monthly Expense</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3281.html">[POJ] 3281. Dining</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3321.html">[POJ] 3321. Apple Tree</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3368.html">[POJ] 3368. Frequent values</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3420.html">[POJ] 3420. Quad Tiling</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3468.html">[POJ] 3468. A Simple Problem with Integers</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3469.html">[POJ] 3469. Dual Core CPU</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3565.html">[POJ] 3565. Ants</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3580.html">[POJ] 3580. SuperMemo</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3686.html">[POJ] 3686. The Windy’s</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3734.html">[POJ] 3734. Blocks</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3735.html">[POJ] 3735. Training little cats</a></li>
<li class="toctree-l2"><a class="reference internal" href="p3977.html">[POJ] 3977. Subset</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../uva/uva.html">4. UVA</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ptc/ptc.html">5. PTC</a></li>
<li class="toctree-l1"><a class="reference internal" href="../other/other.html">6. Other</a></li>
<li class="toctree-l1"><a class="reference internal" href="../template/template.html">7. Template</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tags.html">8. Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cheatsheet.html">9. Cheatsheet</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">amoshyc's CPsolution</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> »</li>
<li><a href="poj.html">3. POJ</a> »</li>
<li>[POJ] 1276. Cash Machine</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/poj/p1276.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="poj-1276-cash-machine">
<h1><a class="toc-backref" href="#id4">[POJ] 1276. Cash Machine</a><a class="headerlink" href="#poj-1276-cash-machine" title="Permalink to this headline">¶</a></h1>
<div class="sidebar">
<p class="first sidebar-title">Tags</p>
<ul class="last simple">
<li><code class="docutils literal"><span class="pre">tag_dp</span></code></li>
</ul>
</div>
<div class="contents topic" id="toc">
<p class="topic-title first">TOC</p>
<ul class="simple">
<li><a class="reference internal" href="#poj-1276-cash-machine" id="id4">[POJ] 1276. Cash Machine</a><ul>
<li><a class="reference internal" href="#id2" id="id5">題目</a></li>
<li><a class="reference internal" href="#specification" id="id6">Specification</a></li>
<li><a class="reference internal" href="#id3" id="id7">分析</a></li>
<li><a class="reference internal" href="#ac-code" id="id8">AC Code</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="id2">
<h2><a class="reference external" href="http://poj.org/problem?id=1276">題目</a><a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>給定 N 個數字 D[i],第 i 個數字有 n[i] 個。
請問在 M 以下(含 M)所能組出的最大總和是多少?</p>
</div>
<div class="section" id="specification">
<h2><a class="toc-backref" href="#id6">Specification</a><a class="headerlink" href="#specification" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="o"><=</span> <span class="n">N</span> <span class="o"><=</span> <span class="mi">10</span>
<span class="mi">1</span> <span class="o"><=</span> <span class="n">M</span> <span class="o"><=</span> <span class="mi">10</span><span class="o">^</span><span class="mi">5</span>
<span class="mi">1</span> <span class="o"><=</span> <span class="n">n</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o"><=</span> <span class="mi">10</span><span class="o">^</span><span class="mi">3</span>
<span class="mi">1</span> <span class="o"><=</span> <span class="n">D</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o"><=</span> <span class="mi">10</span><span class="o">^</span><span class="mi">3</span>
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id7">分析</a><a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">多重背包轉零一背包</p>
</div>
<p>重量與價值是相同值,多重背包裸題。
須二進制拆解轉零一背包加速。</p>
</div>
<div class="section" id="ac-code">
<h2><a class="toc-backref" href="#id8">AC Code</a><a class="headerlink" href="#ac-code" title="Permalink to this headline">¶</a></h2>
<div class="highlight-cpp"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="c1">// #include <bits/stdc++.h></span>
<span class="cp">#include</span> <span class="cpf"><cstdio></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><vector></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><algorithm></span><span class="cp"></span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="k">typedef</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">ll</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">Item</span> <span class="p">{</span>
<span class="n">ll</span> <span class="n">v</span><span class="p">,</span> <span class="n">w</span><span class="p">;</span>
<span class="p">};</span>
<span class="k">const</span> <span class="kt">int</span> <span class="n">MAX_W</span> <span class="o">=</span> <span class="mi">100000</span><span class="p">;</span>
<span class="n">ll</span> <span class="n">dp</span><span class="p">[</span><span class="n">MAX_W</span> <span class="o">+</span> <span class="mi">1</span><span class="p">];</span>
<span class="n">ll</span> <span class="nf">knapsack01</span><span class="p">(</span><span class="k">const</span> <span class="n">vector</span><span class="o"><</span><span class="n">Item</span><span class="o">>&</span> <span class="n">items</span><span class="p">,</span> <span class="kt">int</span> <span class="n">W</span><span class="p">)</span> <span class="p">{</span>
<span class="n">fill</span><span class="p">(</span><span class="n">dp</span><span class="p">,</span> <span class="n">dp</span> <span class="o">+</span> <span class="n">W</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0ll</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="kt">int</span><span class="p">(</span><span class="n">items</span><span class="p">.</span><span class="n">size</span><span class="p">());</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">j</span> <span class="o">=</span> <span class="n">W</span><span class="p">;</span> <span class="n">j</span> <span class="o">>=</span> <span class="n">items</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">w</span><span class="p">;</span> <span class="n">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
<span class="n">dp</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">max</span><span class="p">(</span><span class="n">dp</span><span class="p">[</span><span class="n">j</span><span class="p">],</span> <span class="n">dp</span><span class="p">[</span><span class="n">j</span> <span class="o">-</span> <span class="n">items</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">w</span><span class="p">]</span> <span class="o">+</span> <span class="n">items</span><span class="p">[</span><span class="n">i</span><span class="p">].</span><span class="n">v</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="n">dp</span><span class="p">[</span><span class="n">W</span><span class="p">];</span>
<span class="p">}</span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
<span class="n">ll</span> <span class="n">W</span><span class="p">;</span> <span class="kt">int</span> <span class="n">N</span><span class="p">;</span>
<span class="k">while</span> <span class="p">(</span><span class="n">scanf</span><span class="p">(</span><span class="s">"%lld %d"</span><span class="p">,</span> <span class="o">&</span><span class="n">W</span><span class="p">,</span> <span class="o">&</span><span class="n">N</span><span class="p">)</span> <span class="o">!=</span> <span class="n">EOF</span><span class="p">)</span> <span class="p">{</span>
<span class="n">vector</span><span class="o"><</span><span class="n">Item</span><span class="o">></span> <span class="n">items</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">N</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ll</span> <span class="n">val</span><span class="p">,</span> <span class="n">num</span><span class="p">;</span>
<span class="n">scanf</span><span class="p">(</span><span class="s">"%lld %lld"</span><span class="p">,</span> <span class="o">&</span><span class="n">num</span><span class="p">,</span> <span class="o">&</span><span class="n">val</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="n">ll</span> <span class="n">k</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">k</span> <span class="o"><=</span> <span class="n">num</span><span class="p">;</span> <span class="n">k</span> <span class="o">*=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
<span class="n">items</span><span class="p">.</span><span class="n">push_back</span><span class="p">((</span><span class="n">Item</span><span class="p">)</span> <span class="p">{</span><span class="n">k</span> <span class="o">*</span> <span class="n">val</span><span class="p">,</span> <span class="n">k</span> <span class="o">*</span> <span class="n">val</span><span class="p">});</span>
<span class="n">num</span> <span class="o">-=</span> <span class="n">k</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">num</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">items</span><span class="p">.</span><span class="n">push_back</span><span class="p">((</span><span class="n">Item</span><span class="p">)</span> <span class="p">{</span><span class="n">num</span> <span class="o">*</span> <span class="n">val</span><span class="p">,</span> <span class="n">num</span> <span class="o">*</span> <span class="n">val</span><span class="p">});</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"%lld</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">knapsack01</span><span class="p">(</span><span class="n">items</span><span class="p">,</span> <span class="n">W</span><span class="p">));</span>
<span class="p">}</span>
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</td></tr></table></div>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="p1308.html" class="btn btn-neutral float-right" title="[POJ] 1308. Is It A Tree?" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="p1151.html" class="btn btn-neutral" title="[POJ] 1151. Atlantis" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2016, amoshyc.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'1.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html> | amoshyc/CPsolution | docs/poj/p1276.html | HTML | mit | 21,542 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
999,
1011,
1011,
1031,
2065,
29464,
1022,
1033,
1028,
1026,
16129,
2465,
1027,
1000,
2053,
1011,
1046,
2015,
8318,
1011,
29464,
2683,
1000,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/***************************************************************************
* Copyright (C) 2013 by Christoph Thelen *
* doc_bacardi@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef __HEADER_H__
#define __HEADER_H__
typedef struct VERSION_HEADER_STRUCT
{
unsigned long ulVersionMajor;
unsigned long ulVersionMinor;
unsigned long ulVersionMicro;
const char acVersionVcs[16];
} VERSION_HEADER_T;
extern const VERSION_HEADER_T tVersionHeader __attribute__ ((section (".header")));
#endif /* __HEADER_H__ */
| muhkuh-sys/blinki | src/header.h | C | gpl-2.0 | 1,809 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
30524,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cmd_drivers/media/video/uvc/uvcvideo.ko := arm-linux-gnueabi-ld -EL -r -T /home/jixinhui/Projects/phoenix/lichee/linux-3.3/scripts/module-common.lds --build-id -o drivers/media/video/uvc/uvcvideo.ko drivers/media/video/uvc/uvcvideo.o drivers/media/video/uvc/uvcvideo.mod.o
| qubir/PhoenixA20_linux_sourcecode | drivers/media/video/uvc/.uvcvideo.ko.cmd | Batchfile | gpl-2.0 | 275 | [
30522,
4642,
2094,
1035,
6853,
1013,
2865,
1013,
2678,
1013,
23068,
2278,
1013,
23068,
2278,
17258,
8780,
1012,
12849,
1024,
1027,
2849,
1011,
11603,
1011,
27004,
5243,
5638,
1011,
25510,
1011,
3449,
1011,
1054,
1011,
1056,
1013,
2188,
1013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Core routines and tables shareable across OS platforms.
*
* Copyright (c) 1994-2002 Justin T. Gibbs.
* Copyright (c) 2000-2003 Adaptec Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#250 $
*/
#ifdef __linux__
#include "aic79xx_osm.h"
#include "aic79xx_inline.h"
#include "aicasm/aicasm_insformat.h"
#else
#include <dev/aic7xxx/aic79xx_osm.h>
#include <dev/aic7xxx/aic79xx_inline.h>
#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
#endif
/***************************** Lookup Tables **********************************/
static char *ahd_chip_names[] =
{
"NONE",
"aic7901",
"aic7902",
"aic7901A"
};
static const u_int num_chip_names = ARRAY_SIZE(ahd_chip_names);
/*
* Hardware error codes.
*/
struct ahd_hard_error_entry {
uint8_t errno;
char *errmesg;
};
static struct ahd_hard_error_entry ahd_hard_errors[] = {
{ DSCTMOUT, "Discard Timer has timed out" },
{ ILLOPCODE, "Illegal Opcode in sequencer program" },
{ SQPARERR, "Sequencer Parity Error" },
{ DPARERR, "Data-path Parity Error" },
{ MPARERR, "Scratch or SCB Memory Parity Error" },
{ CIOPARERR, "CIOBUS Parity Error" },
};
static const u_int num_errors = ARRAY_SIZE(ahd_hard_errors);
static struct ahd_phase_table_entry ahd_phase_table[] =
{
{ P_DATAOUT, MSG_NOOP, "in Data-out phase" },
{ P_DATAIN, MSG_INITIATOR_DET_ERR, "in Data-in phase" },
{ P_DATAOUT_DT, MSG_NOOP, "in DT Data-out phase" },
{ P_DATAIN_DT, MSG_INITIATOR_DET_ERR, "in DT Data-in phase" },
{ P_COMMAND, MSG_NOOP, "in Command phase" },
{ P_MESGOUT, MSG_NOOP, "in Message-out phase" },
{ P_STATUS, MSG_INITIATOR_DET_ERR, "in Status phase" },
{ P_MESGIN, MSG_PARITY_ERROR, "in Message-in phase" },
{ P_BUSFREE, MSG_NOOP, "while idle" },
{ 0, MSG_NOOP, "in unknown phase" }
};
/*
* In most cases we only wish to itterate over real phases, so
* exclude the last element from the count.
*/
static const u_int num_phases = ARRAY_SIZE(ahd_phase_table) - 1;
/* Our Sequencer Program */
#include "aic79xx_seq.h"
/**************************** Function Declarations ***************************/
static void ahd_handle_transmission_error(struct ahd_softc *ahd);
static void ahd_handle_lqiphase_error(struct ahd_softc *ahd,
u_int lqistat1);
static int ahd_handle_pkt_busfree(struct ahd_softc *ahd,
u_int busfreetime);
static int ahd_handle_nonpkt_busfree(struct ahd_softc *ahd);
static void ahd_handle_proto_violation(struct ahd_softc *ahd);
static void ahd_force_renegotiation(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static struct ahd_tmode_tstate*
ahd_alloc_tstate(struct ahd_softc *ahd,
u_int scsi_id, char channel);
#ifdef AHD_TARGET_MODE
static void ahd_free_tstate(struct ahd_softc *ahd,
u_int scsi_id, char channel, int force);
#endif
static void ahd_devlimited_syncrate(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *,
u_int *period,
u_int *ppr_options,
role_t role);
static void ahd_update_neg_table(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct ahd_transinfo *tinfo);
static void ahd_update_pending_scbs(struct ahd_softc *ahd);
static void ahd_fetch_devinfo(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_scb_devinfo(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
static void ahd_setup_initiator_msgout(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
static void ahd_build_transfer_msg(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_construct_sdtr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int period, u_int offset);
static void ahd_construct_wdtr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int bus_width);
static void ahd_construct_ppr(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int period, u_int offset,
u_int bus_width, u_int ppr_options);
static void ahd_clear_msg_state(struct ahd_softc *ahd);
static void ahd_handle_message_phase(struct ahd_softc *ahd);
typedef enum {
AHDMSG_1B,
AHDMSG_2B,
AHDMSG_EXT
} ahd_msgtype;
static int ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type,
u_int msgval, int full);
static int ahd_parse_msg(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static int ahd_handle_msg_reject(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_handle_ign_wide_residue(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo);
static void ahd_reinitialize_dataptrs(struct ahd_softc *ahd);
static void ahd_handle_devreset(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
u_int lun, cam_status status,
char *message, int verbose_level);
#ifdef AHD_TARGET_MODE
static void ahd_setup_target_msgin(struct ahd_softc *ahd,
struct ahd_devinfo *devinfo,
struct scb *scb);
#endif
static u_int ahd_sglist_size(struct ahd_softc *ahd);
static u_int ahd_sglist_allocsize(struct ahd_softc *ahd);
static bus_dmamap_callback_t
ahd_dmamap_cb;
static void ahd_initialize_hscbs(struct ahd_softc *ahd);
static int ahd_init_scbdata(struct ahd_softc *ahd);
static void ahd_fini_scbdata(struct ahd_softc *ahd);
static void ahd_setup_iocell_workaround(struct ahd_softc *ahd);
static void ahd_iocell_first_selection(struct ahd_softc *ahd);
static void ahd_add_col_list(struct ahd_softc *ahd,
struct scb *scb, u_int col_idx);
static void ahd_rem_col_list(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_chip_init(struct ahd_softc *ahd);
static void ahd_qinfifo_requeue(struct ahd_softc *ahd,
struct scb *prev_scb,
struct scb *scb);
static int ahd_qinfifo_count(struct ahd_softc *ahd);
static int ahd_search_scb_list(struct ahd_softc *ahd, int target,
char channel, int lun, u_int tag,
role_t role, uint32_t status,
ahd_search_action action,
u_int *list_head, u_int *list_tail,
u_int tid);
static void ahd_stitch_tid_list(struct ahd_softc *ahd,
u_int tid_prev, u_int tid_cur,
u_int tid_next);
static void ahd_add_scb_to_free_list(struct ahd_softc *ahd,
u_int scbid);
static u_int ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
u_int prev, u_int next, u_int tid);
static void ahd_reset_current_bus(struct ahd_softc *ahd);
static ahd_callback_t ahd_stat_timer;
#ifdef AHD_DUMP_SEQ
static void ahd_dumpseq(struct ahd_softc *ahd);
#endif
static void ahd_loadseq(struct ahd_softc *ahd);
static int ahd_check_patch(struct ahd_softc *ahd,
struct patch **start_patch,
u_int start_instr, u_int *skip_addr);
static u_int ahd_resolve_seqaddr(struct ahd_softc *ahd,
u_int address);
static void ahd_download_instr(struct ahd_softc *ahd,
u_int instrptr, uint8_t *dconsts);
static int ahd_probe_stack_size(struct ahd_softc *ahd);
static int ahd_scb_active_in_fifo(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_run_data_fifo(struct ahd_softc *ahd,
struct scb *scb);
#ifdef AHD_TARGET_MODE
static void ahd_queue_lstate_event(struct ahd_softc *ahd,
struct ahd_tmode_lstate *lstate,
u_int initiator_id,
u_int event_type,
u_int event_arg);
static void ahd_update_scsiid(struct ahd_softc *ahd,
u_int targid_mask);
static int ahd_handle_target_cmd(struct ahd_softc *ahd,
struct target_cmd *cmd);
#endif
static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
char channel, int lun, u_int tag,
role_t role, uint32_t status);
static void ahd_alloc_scbs(struct ahd_softc *ahd);
static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
u_int scbid);
static void ahd_calc_residual(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_clear_critical_section(struct ahd_softc *ahd);
static void ahd_clear_intstat(struct ahd_softc *ahd);
static void ahd_enable_coalescing(struct ahd_softc *ahd,
int enable);
static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
static void ahd_freeze_devq(struct ahd_softc *ahd,
struct scb *scb);
static void ahd_handle_scb_status(struct ahd_softc *ahd,
struct scb *scb);
static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
static void ahd_shutdown(void *arg);
static void ahd_update_coalescing_values(struct ahd_softc *ahd,
u_int timer,
u_int maxcmds,
u_int mincmds);
static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
static int ahd_wait_seeprom(struct ahd_softc *ahd);
static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
int target, char channel, int lun,
u_int tag, role_t role);
/******************************** Private Inlines *****************************/
static __inline void
ahd_assert_atn(struct ahd_softc *ahd)
{
ahd_outb(ahd, SCSISIGO, ATNO);
}
/*
* Determine if the current connection has a packetized
* agreement. This does not necessarily mean that we
* are currently in a packetized transfer. We could
* just as easily be sending or receiving a message.
*/
static __inline int
ahd_currently_packetized(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
int packetized;
saved_modes = ahd_save_modes(ahd);
if ((ahd->bugs & AHD_PKTIZED_STATUS_BUG) != 0) {
/*
* The packetized bit refers to the last
* connection, not the current one. Check
* for non-zero LQISTATE instead.
*/
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
packetized = ahd_inb(ahd, LQISTATE) != 0;
} else {
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
packetized = ahd_inb(ahd, LQISTAT2) & PACKETIZED;
}
ahd_restore_modes(ahd, saved_modes);
return (packetized);
}
static __inline int
ahd_set_active_fifo(struct ahd_softc *ahd)
{
u_int active_fifo;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
active_fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
switch (active_fifo) {
case 0:
case 1:
ahd_set_modes(ahd, active_fifo, active_fifo);
return (1);
default:
return (0);
}
}
static __inline void
ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
{
ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
}
/*
* Determine whether the sequencer reported a residual
* for this SCB/transaction.
*/
static __inline void
ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
{
uint32_t sgptr;
sgptr = ahd_le32toh(scb->hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) != 0)
ahd_calc_residual(ahd, scb);
}
static __inline void
ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
{
uint32_t sgptr;
sgptr = ahd_le32toh(scb->hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) != 0)
ahd_handle_scb_status(ahd, scb);
else
ahd_done(ahd, scb);
}
/************************* Sequencer Execution Control ************************/
/*
* Restart the sequencer program from address zero
*/
static void
ahd_restart(struct ahd_softc *ahd)
{
ahd_pause(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/* No more pending messages */
ahd_clear_msg_state(ahd);
ahd_outb(ahd, SCSISIGO, 0); /* De-assert BSY */
ahd_outb(ahd, MSG_OUT, MSG_NOOP); /* No message to send */
ahd_outb(ahd, SXFRCTL1, ahd_inb(ahd, SXFRCTL1) & ~BITBUCKET);
ahd_outb(ahd, SEQINTCTL, 0);
ahd_outb(ahd, LASTPHASE, P_BUSFREE);
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_outb(ahd, SAVED_SCSIID, 0xFF);
ahd_outb(ahd, SAVED_LUN, 0xFF);
/*
* Ensure that the sequencer's idea of TQINPOS
* matches our own. The sequencer increments TQINPOS
* only after it sees a DMA complete and a reset could
* occur before the increment leaving the kernel to believe
* the command arrived but the sequencer to not.
*/
ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
/* Always allow reselection */
ahd_outb(ahd, SCSISEQ1,
ahd_inb(ahd, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP));
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Clear any pending sequencer interrupt. It is no
* longer relevant since we're resetting the Program
* Counter.
*/
ahd_outb(ahd, CLRINT, CLRSEQINT);
ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
ahd_unpause(ahd);
}
static void
ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
{
ahd_mode_state saved_modes;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_FIFOS) != 0)
printf("%s: Clearing FIFO %d\n", ahd_name(ahd), fifo);
#endif
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, fifo, fifo);
ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
ahd_outb(ahd, CCSGCTL, CCSGRESET);
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SG_STATE, 0);
ahd_restore_modes(ahd, saved_modes);
}
/************************* Input/Output Queues ********************************/
/*
* Flush and completed commands that are sitting in the command
* complete queues down on the chip but have yet to be dma'ed back up.
*/
static void
ahd_flush_qoutfifo(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int saved_scbptr;
u_int ccscbctl;
u_int scbid;
u_int next_scbid;
saved_modes = ahd_save_modes(ahd);
/*
* Flush the good status FIFO for completed packetized commands.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_scbptr = ahd_get_scbptr(ahd);
while ((ahd_inb(ahd, LQISTAT2) & LQIGSAVAIL) != 0) {
u_int fifo_mode;
u_int i;
scbid = ahd_inw(ahd, GSFIFO);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: Warning - GSFIFO SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
/*
* Determine if this transaction is still active in
* any FIFO. If it is, we must flush that FIFO to
* the host before completing the command.
*/
fifo_mode = 0;
rescan_fifos:
for (i = 0; i < 2; i++) {
/* Toggle to the other mode. */
fifo_mode ^= 1;
ahd_set_modes(ahd, fifo_mode, fifo_mode);
if (ahd_scb_active_in_fifo(ahd, scb) == 0)
continue;
ahd_run_data_fifo(ahd, scb);
/*
* Running this FIFO may cause a CFG4DATA for
* this same transaction to assert in the other
* FIFO or a new snapshot SAVEPTRS interrupt
* in this FIFO. Even running a FIFO may not
* clear the transaction if we are still waiting
* for data to drain to the host. We must loop
* until the transaction is not active in either
* FIFO just to be sure. Reset our loop counter
* so we will visit both FIFOs again before
* declaring this transaction finished. We
* also delay a bit so that status has a chance
* to change before we look at this FIFO again.
*/
ahd_delay(200);
goto rescan_fifos;
}
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_set_scbptr(ahd, scbid);
if ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_LIST_NULL) == 0
&& ((ahd_inb_scbram(ahd, SCB_SGPTR) & SG_FULL_RESID) != 0
|| (ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR)
& SG_LIST_NULL) != 0)) {
u_int comp_head;
/*
* The transfer completed with a residual.
* Place this SCB on the complete DMA list
* so that we update our in-core copy of the
* SCB before completing the command.
*/
ahd_outb(ahd, SCB_SCSI_STATUS, 0);
ahd_outb(ahd, SCB_SGPTR,
ahd_inb_scbram(ahd, SCB_SGPTR)
| SG_STATUS_VALID);
ahd_outw(ahd, SCB_TAG, scbid);
ahd_outw(ahd, SCB_NEXT_COMPLETE, SCB_LIST_NULL);
comp_head = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
if (SCBID_IS_NULL(comp_head)) {
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, scbid);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
} else {
u_int tail;
tail = ahd_inw(ahd, COMPLETE_DMA_SCB_TAIL);
ahd_set_scbptr(ahd, tail);
ahd_outw(ahd, SCB_NEXT_COMPLETE, scbid);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, scbid);
ahd_set_scbptr(ahd, scbid);
}
} else
ahd_complete_scb(ahd, scb);
}
ahd_set_scbptr(ahd, saved_scbptr);
/*
* Setup for command channel portion of flush.
*/
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Wait for any inprogress DMA to complete and clear DMA state
* if this if for an SCB in the qinfifo.
*/
while (((ccscbctl = ahd_inb(ahd, CCSCBCTL)) & (CCARREN|CCSCBEN)) != 0) {
if ((ccscbctl & (CCSCBDIR|CCARREN)) == (CCSCBDIR|CCARREN)) {
if ((ccscbctl & ARRDONE) != 0)
break;
} else if ((ccscbctl & CCSCBDONE) != 0)
break;
ahd_delay(200);
}
/*
* We leave the sequencer to cleanup in the case of DMA's to
* update the qoutfifo. In all other cases (DMA's to the
* chip or a push of an SCB from the COMPLETE_DMA_SCB list),
* we disable the DMA engine so that the sequencer will not
* attempt to handle the DMA completion.
*/
if ((ccscbctl & CCSCBDIR) != 0 || (ccscbctl & ARRDONE) != 0)
ahd_outb(ahd, CCSCBCTL, ccscbctl & ~(CCARREN|CCSCBEN));
/*
* Complete any SCBs that just finished
* being DMA'ed into the qoutfifo.
*/
ahd_run_qoutfifo(ahd);
saved_scbptr = ahd_get_scbptr(ahd);
/*
* Manually update/complete any completed SCBs that are waiting to be
* DMA'ed back up to the host.
*/
scbid = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
while (!SCBID_IS_NULL(scbid)) {
uint8_t *hscb_ptr;
u_int i;
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: Warning - DMA-up and complete "
"SCB %d invalid\n", ahd_name(ahd), scbid);
continue;
}
hscb_ptr = (uint8_t *)scb->hscb;
for (i = 0; i < sizeof(struct hardware_scb); i++)
*hscb_ptr++ = ahd_inb_scbram(ahd, SCB_BASE + i);
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
scbid = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
while (!SCBID_IS_NULL(scbid)) {
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: Warning - Complete Qfrz SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
scbid = ahd_inw(ahd, COMPLETE_SCB_HEAD);
while (!SCBID_IS_NULL(scbid)) {
ahd_set_scbptr(ahd, scbid);
next_scbid = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: Warning - Complete SCB %d invalid\n",
ahd_name(ahd), scbid);
continue;
}
ahd_complete_scb(ahd, scb);
scbid = next_scbid;
}
ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
/*
* Restore state.
*/
ahd_set_scbptr(ahd, saved_scbptr);
ahd_restore_modes(ahd, saved_modes);
ahd->flags |= AHD_UPDATE_PEND_CMDS;
}
/*
* Determine if an SCB for a packetized transaction
* is active in a FIFO.
*/
static int
ahd_scb_active_in_fifo(struct ahd_softc *ahd, struct scb *scb)
{
/*
* The FIFO is only active for our transaction if
* the SCBPTR matches the SCB's ID and the firmware
* has installed a handler for the FIFO or we have
* a pending SAVEPTRS or CFG4DATA interrupt.
*/
if (ahd_get_scbptr(ahd) != SCB_GET_TAG(scb)
|| ((ahd_inb(ahd, LONGJMP_ADDR+1) & INVALID_ADDR) != 0
&& (ahd_inb(ahd, SEQINTSRC) & (CFG4DATA|SAVEPTRS)) == 0))
return (0);
return (1);
}
/*
* Run a data fifo to completion for a transaction we know
* has completed across the SCSI bus (good status has been
* received). We are already set to the correct FIFO mode
* on entry to this routine.
*
* This function attempts to operate exactly as the firmware
* would when running this FIFO. Care must be taken to update
* this routine any time the firmware's FIFO algorithm is
* changed.
*/
static void
ahd_run_data_fifo(struct ahd_softc *ahd, struct scb *scb)
{
u_int seqintsrc;
seqintsrc = ahd_inb(ahd, SEQINTSRC);
if ((seqintsrc & CFG4DATA) != 0) {
uint32_t datacnt;
uint32_t sgptr;
/*
* Clear full residual flag.
*/
sgptr = ahd_inl_scbram(ahd, SCB_SGPTR) & ~SG_FULL_RESID;
ahd_outb(ahd, SCB_SGPTR, sgptr);
/*
* Load datacnt and address.
*/
datacnt = ahd_inl_scbram(ahd, SCB_DATACNT);
if ((datacnt & AHD_DMA_LAST_SEG) != 0) {
sgptr |= LAST_SEG;
ahd_outb(ahd, SG_STATE, 0);
} else
ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
ahd_outq(ahd, HADDR, ahd_inq_scbram(ahd, SCB_DATAPTR));
ahd_outl(ahd, HCNT, datacnt & AHD_SG_LEN_MASK);
ahd_outb(ahd, SG_CACHE_PRE, sgptr);
ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
/*
* Initialize Residual Fields.
*/
ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, datacnt >> 24);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr & SG_PTR_MASK);
/*
* Mark the SCB as having a FIFO in use.
*/
ahd_outb(ahd, SCB_FIFO_USE_COUNT,
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) + 1);
/*
* Install a "fake" handler for this FIFO.
*/
ahd_outw(ahd, LONGJMP_ADDR, 0);
/*
* Notify the hardware that we have satisfied
* this sequencer interrupt.
*/
ahd_outb(ahd, CLRSEQINTSRC, CLRCFG4DATA);
} else if ((seqintsrc & SAVEPTRS) != 0) {
uint32_t sgptr;
uint32_t resid;
if ((ahd_inb(ahd, LONGJMP_ADDR+1)&INVALID_ADDR) != 0) {
/*
* Snapshot Save Pointers. All that
* is necessary to clear the snapshot
* is a CLRCHN.
*/
goto clrchn;
}
/*
* Disable S/G fetch so the DMA engine
* is available to future users.
*/
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0)
ahd_outb(ahd, CCSGCTL, 0);
ahd_outb(ahd, SG_STATE, 0);
/*
* Flush the data FIFO. Strickly only
* necessary for Rev A parts.
*/
ahd_outb(ahd, DFCNTRL, ahd_inb(ahd, DFCNTRL) | FIFOFLUSH);
/*
* Calculate residual.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
resid = ahd_inl(ahd, SHCNT);
resid |= ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT+3) << 24;
ahd_outl(ahd, SCB_RESIDUAL_DATACNT, resid);
if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG) == 0) {
/*
* Must back up to the correct S/G element.
* Typically this just means resetting our
* low byte to the offset in the SG_CACHE,
* but if we wrapped, we have to correct
* the other bytes of the sgptr too.
*/
if ((ahd_inb(ahd, SG_CACHE_SHADOW) & 0x80) != 0
&& (sgptr & 0x80) == 0)
sgptr -= 0x100;
sgptr &= ~0xFF;
sgptr |= ahd_inb(ahd, SG_CACHE_SHADOW)
& SG_ADDR_MASK;
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
ahd_outb(ahd, SCB_RESIDUAL_DATACNT + 3, 0);
} else if ((resid & AHD_SG_LEN_MASK) == 0) {
ahd_outb(ahd, SCB_RESIDUAL_SGPTR,
sgptr | SG_LIST_NULL);
}
/*
* Save Pointers.
*/
ahd_outq(ahd, SCB_DATAPTR, ahd_inq(ahd, SHADDR));
ahd_outl(ahd, SCB_DATACNT, resid);
ahd_outl(ahd, SCB_SGPTR, sgptr);
ahd_outb(ahd, CLRSEQINTSRC, CLRSAVEPTRS);
ahd_outb(ahd, SEQIMODE,
ahd_inb(ahd, SEQIMODE) | ENSAVEPTRS);
/*
* If the data is to the SCSI bus, we are
* done, otherwise wait for FIFOEMP.
*/
if ((ahd_inb(ahd, DFCNTRL) & DIRECTION) != 0)
goto clrchn;
} else if ((ahd_inb(ahd, SG_STATE) & LOADING_NEEDED) != 0) {
uint32_t sgptr;
uint64_t data_addr;
uint32_t data_len;
u_int dfcntrl;
/*
* Disable S/G fetch so the DMA engine
* is available to future users. We won't
* be using the DMA engine to load segments.
*/
if ((ahd_inb(ahd, SG_STATE) & FETCH_INPROG) != 0) {
ahd_outb(ahd, CCSGCTL, 0);
ahd_outb(ahd, SG_STATE, LOADING_NEEDED);
}
/*
* Wait for the DMA engine to notice that the
* host transfer is enabled and that there is
* space in the S/G FIFO for new segments before
* loading more segments.
*/
if ((ahd_inb(ahd, DFSTATUS) & PRELOAD_AVAIL) != 0
&& (ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0) {
/*
* Determine the offset of the next S/G
* element to load.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
sgptr &= SG_PTR_MASK;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
data_addr = sg->addr;
data_len = sg->len;
sgptr += sizeof(*sg);
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
data_addr = sg->len & AHD_SG_HIGH_ADDR_MASK;
data_addr <<= 8;
data_addr |= sg->addr;
data_len = sg->len;
sgptr += sizeof(*sg);
}
/*
* Update residual information.
*/
ahd_outb(ahd, SCB_RESIDUAL_DATACNT+3, data_len >> 24);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
/*
* Load the S/G.
*/
if (data_len & AHD_DMA_LAST_SEG) {
sgptr |= LAST_SEG;
ahd_outb(ahd, SG_STATE, 0);
}
ahd_outq(ahd, HADDR, data_addr);
ahd_outl(ahd, HCNT, data_len & AHD_SG_LEN_MASK);
ahd_outb(ahd, SG_CACHE_PRE, sgptr & 0xFF);
/*
* Advertise the segment to the hardware.
*/
dfcntrl = ahd_inb(ahd, DFCNTRL)|PRELOADEN|HDMAEN;
if ((ahd->features & AHD_NEW_DFCNTRL_OPTS) != 0) {
/*
* Use SCSIENWRDIS so that SCSIEN
* is never modified by this
* operation.
*/
dfcntrl |= SCSIENWRDIS;
}
ahd_outb(ahd, DFCNTRL, dfcntrl);
}
} else if ((ahd_inb(ahd, SG_CACHE_SHADOW) & LAST_SEG_DONE) != 0) {
/*
* Transfer completed to the end of SG list
* and has flushed to the host.
*/
ahd_outb(ahd, SCB_SGPTR,
ahd_inb_scbram(ahd, SCB_SGPTR) | SG_LIST_NULL);
goto clrchn;
} else if ((ahd_inb(ahd, DFSTATUS) & FIFOEMP) != 0) {
clrchn:
/*
* Clear any handler for this FIFO, decrement
* the FIFO use count for the SCB, and release
* the FIFO.
*/
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SCB_FIFO_USE_COUNT,
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT) - 1);
ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
}
}
/*
* Look for entries in the QoutFIFO that have completed.
* The valid_tag completion field indicates the validity
* of the entry - the valid value toggles each time through
* the queue. We use the sg_status field in the completion
* entry to avoid referencing the hscb if the completion
* occurred with no errors and no residual. sg_status is
* a copy of the first byte (little endian) of the sgptr
* hscb field.
*/
void
ahd_run_qoutfifo(struct ahd_softc *ahd)
{
struct ahd_completion *completion;
struct scb *scb;
u_int scb_index;
if ((ahd->flags & AHD_RUNNING_QOUTFIFO) != 0)
panic("ahd_run_qoutfifo recursion");
ahd->flags |= AHD_RUNNING_QOUTFIFO;
ahd_sync_qoutfifo(ahd, BUS_DMASYNC_POSTREAD);
for (;;) {
completion = &ahd->qoutfifo[ahd->qoutfifonext];
if (completion->valid_tag != ahd->qoutfifonext_valid_tag)
break;
scb_index = ahd_le16toh(completion->tag);
scb = ahd_lookup_scb(ahd, scb_index);
if (scb == NULL) {
printf("%s: WARNING no command for scb %d "
"(cmdcmplt)\nQOUTPOS = %d\n",
ahd_name(ahd), scb_index,
ahd->qoutfifonext);
ahd_dump_card_state(ahd);
} else if ((completion->sg_status & SG_STATUS_VALID) != 0) {
ahd_handle_scb_status(ahd, scb);
} else {
ahd_done(ahd, scb);
}
ahd->qoutfifonext = (ahd->qoutfifonext+1) & (AHD_QOUT_SIZE-1);
if (ahd->qoutfifonext == 0)
ahd->qoutfifonext_valid_tag ^= QOUTFIFO_ENTRY_VALID;
}
ahd->flags &= ~AHD_RUNNING_QOUTFIFO;
}
/************************* Interrupt Handling *********************************/
void
ahd_handle_hwerrint(struct ahd_softc *ahd)
{
/*
* Some catastrophic hardware error has occurred.
* Print it for the user and disable the controller.
*/
int i;
int error;
error = ahd_inb(ahd, ERROR);
for (i = 0; i < num_errors; i++) {
if ((error & ahd_hard_errors[i].errno) != 0)
printf("%s: hwerrint, %s\n",
ahd_name(ahd), ahd_hard_errors[i].errmesg);
}
ahd_dump_card_state(ahd);
panic("BRKADRINT");
/* Tell everyone that this HBA is no longer available */
ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
CAM_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
CAM_NO_HBA);
/* Tell the system that this controller has gone away. */
ahd_free(ahd);
}
#ifdef AHD_DEBUG
static void
ahd_dump_sglist(struct scb *scb)
{
int i;
if (scb->sg_count > 0) {
if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg_list;
sg_list = (struct ahd_dma64_seg*)scb->sg_list;
for (i = 0; i < scb->sg_count; i++) {
uint64_t addr;
uint32_t len;
addr = ahd_le64toh(sg_list[i].addr);
len = ahd_le32toh(sg_list[i].len);
printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
i,
(uint32_t)((addr >> 32) & 0xFFFFFFFF),
(uint32_t)(addr & 0xFFFFFFFF),
sg_list[i].len & AHD_SG_LEN_MASK,
(sg_list[i].len & AHD_DMA_LAST_SEG)
? " Last" : "");
}
} else {
struct ahd_dma_seg *sg_list;
sg_list = (struct ahd_dma_seg*)scb->sg_list;
for (i = 0; i < scb->sg_count; i++) {
uint32_t len;
len = ahd_le32toh(sg_list[i].len);
printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
i,
(len & AHD_SG_HIGH_ADDR_MASK) >> 24,
ahd_le32toh(sg_list[i].addr),
len & AHD_SG_LEN_MASK,
len & AHD_DMA_LAST_SEG ? " Last" : "");
}
}
}
}
#endif /* AHD_DEBUG */
void
ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
{
u_int seqintcode;
/*
* Save the sequencer interrupt code and clear the SEQINT
* bit. We will unpause the sequencer, if appropriate,
* after servicing the request.
*/
seqintcode = ahd_inb(ahd, SEQINTCODE);
ahd_outb(ahd, CLRINT, CLRSEQINT);
if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {
/*
* Unpause the sequencer and let it clear
* SEQINT by writing NO_SEQINT to it. This
* will cause the sequencer to be paused again,
* which is the expected state of this routine.
*/
ahd_unpause(ahd);
while (!ahd_is_paused(ahd))
;
ahd_outb(ahd, CLRINT, CLRSEQINT);
}
ahd_update_modes(ahd);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: Handle Seqint Called for code %d\n",
ahd_name(ahd), seqintcode);
#endif
switch (seqintcode) {
case ENTERING_NONPACK:
{
struct scb *scb;
u_int scbid;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
/*
* Somehow need to know if this
* is from a selection or reselection.
* From that, we can determine target
* ID so we at least have an I_T nexus.
*/
} else {
ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
ahd_outb(ahd, SAVED_LUN, scb->hscb->lun);
ahd_outb(ahd, SEQ_FLAGS, 0x0);
}
if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0
&& (ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
/*
* Phase change after read stream with
* CRC error with P0 asserted on last
* packet.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
printf("%s: Assuming LQIPHASE_NLQ with "
"P0 assertion\n", ahd_name(ahd));
#endif
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
printf("%s: Entering NONPACK\n", ahd_name(ahd));
#endif
break;
}
case INVALID_SEQINT:
printf("%s: Invalid Sequencer interrupt occurred, "
"resetting channel.\n",
ahd_name(ahd));
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
ahd_dump_card_state(ahd);
#endif
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
break;
case STATUS_OVERRUN:
{
struct scb *scb;
u_int scbid;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL)
ahd_print_path(ahd, scb);
else
printf("%s: ", ahd_name(ahd));
printf("SCB %d Packetized Status Overrun", scbid);
ahd_dump_card_state(ahd);
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
break;
}
case CFG4ISTAT_INTR:
{
struct scb *scb;
u_int scbid;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
ahd_dump_card_state(ahd);
printf("CFG4ISTAT: Free SCB %d referenced", scbid);
panic("For safety");
}
ahd_outq(ahd, HADDR, scb->sense_busaddr);
ahd_outw(ahd, HCNT, AHD_SENSE_BUFSIZE);
ahd_outb(ahd, HCNT + 2, 0);
ahd_outb(ahd, SG_CACHE_PRE, SG_LAST_SEG);
ahd_outb(ahd, DFCNTRL, PRELOADEN|SCSIEN|HDMAEN);
break;
}
case ILLEGAL_PHASE:
{
u_int bus_phase;
bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
printf("%s: ILLEGAL_PHASE 0x%x\n",
ahd_name(ahd), bus_phase);
switch (bus_phase) {
case P_DATAOUT:
case P_DATAIN:
case P_DATAOUT_DT:
case P_DATAIN_DT:
case P_MESGOUT:
case P_STATUS:
case P_MESGIN:
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
printf("%s: Issued Bus Reset.\n", ahd_name(ahd));
break;
case P_COMMAND:
{
struct ahd_devinfo devinfo;
struct scb *scb;
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
struct ahd_transinfo *tinfo;
u_int scbid;
/*
* If a target takes us into the command phase
* assume that it has been externally reset and
* has thus lost our previous packetized negotiation
* agreement. Since we have not sent an identify
* message and may not have fully qualified the
* connection, we change our command to TUR, assert
* ATN and ABORT the task when we go to message in
* phase. The OSM will see the REQUEUE_REQUEST
* status and retry the command.
*/
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("Invalid phase with no valid SCB. "
"Resetting bus.\n");
ahd_reset_channel(ahd, 'A',
/*Initiate Reset*/TRUE);
break;
}
ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb),
SCB_GET_CHANNEL(ahd, scb),
ROLE_INITIATOR);
targ_info = ahd_fetch_transinfo(ahd,
devinfo.channel,
devinfo.our_scsiid,
devinfo.target,
&tstate);
tinfo = &targ_info->curr;
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_ACTIVE, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_ACTIVE, /*paused*/TRUE);
/* Hand-craft TUR command */
ahd_outb(ahd, SCB_CDB_STORE, 0);
ahd_outb(ahd, SCB_CDB_STORE+1, 0);
ahd_outb(ahd, SCB_CDB_STORE+2, 0);
ahd_outb(ahd, SCB_CDB_STORE+3, 0);
ahd_outb(ahd, SCB_CDB_STORE+4, 0);
ahd_outb(ahd, SCB_CDB_STORE+5, 0);
ahd_outb(ahd, SCB_CDB_LEN, 6);
scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
scb->hscb->control |= MK_MESSAGE;
ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
/*
* The lun is 0, regardless of the SCB's lun
* as we have not sent an identify message.
*/
ahd_outb(ahd, SAVED_LUN, 0);
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_assert_atn(ahd);
scb->flags &= ~SCB_PACKETIZED;
scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET;
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
ahd_freeze_scb(scb);
/* Notify XPT */
ahd_send_async(ahd, devinfo.channel, devinfo.target,
CAM_LUN_WILDCARD, AC_SENT_BDR);
/*
* Allow the sequencer to continue with
* non-pack processing.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, CLRLQOINT1, CLRLQOPHACHGINPKT);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
ahd_outb(ahd, CLRLQOINT1, 0);
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
ahd_print_path(ahd, scb);
printf("Unexpected command phase from "
"packetized target\n");
}
#endif
break;
}
}
break;
}
case CFG4OVERRUN:
{
struct scb *scb;
u_int scb_index;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printf("%s: CFG4OVERRUN mode = %x\n", ahd_name(ahd),
ahd_inb(ahd, MODE_PTR));
}
#endif
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
if (scb == NULL) {
/*
* Attempt to transfer to an SCB that is
* not outstanding.
*/
ahd_assert_atn(ahd);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd->msgout_buf[0] = MSG_ABORT_TASK;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
/*
* Clear status received flag to prevent any
* attempt to complete this bogus SCB.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL)
& ~STATUS_RCVD);
}
break;
}
case DUMP_CARD_STATE:
{
ahd_dump_card_state(ahd);
break;
}
case PDATA_REINIT:
{
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printf("%s: PDATA_REINIT - DFCNTRL = 0x%x "
"SG_CACHE_SHADOW = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, DFCNTRL),
ahd_inb(ahd, SG_CACHE_SHADOW));
}
#endif
ahd_reinitialize_dataptrs(ahd);
break;
}
case HOST_MSG_LOOP:
{
struct ahd_devinfo devinfo;
/*
* The sequencer has encountered a message phase
* that requires host assistance for completion.
* While handling the message phase(s), we will be
* notified by the sequencer after each byte is
* transfered so we can track bus phase changes.
*
* If this is the first time we've seen a HOST_MSG_LOOP
* interrupt, initialize the state of the host message
* loop.
*/
ahd_fetch_devinfo(ahd, &devinfo);
if (ahd->msg_type == MSG_TYPE_NONE) {
struct scb *scb;
u_int scb_index;
u_int bus_phase;
bus_phase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
if (bus_phase != P_MESGIN
&& bus_phase != P_MESGOUT) {
printf("ahd_intr: HOST_MSG_LOOP bad "
"phase 0x%x\n", bus_phase);
/*
* Probably transitioned to bus free before
* we got here. Just punt the message.
*/
ahd_dump_card_state(ahd);
ahd_clear_intstat(ahd);
ahd_restart(ahd);
return;
}
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
if (devinfo.role == ROLE_INITIATOR) {
if (bus_phase == P_MESGOUT)
ahd_setup_initiator_msgout(ahd,
&devinfo,
scb);
else {
ahd->msg_type =
MSG_TYPE_INITIATOR_MSGIN;
ahd->msgin_index = 0;
}
}
#ifdef AHD_TARGET_MODE
else {
if (bus_phase == P_MESGOUT) {
ahd->msg_type =
MSG_TYPE_TARGET_MSGOUT;
ahd->msgin_index = 0;
}
else
ahd_setup_target_msgin(ahd,
&devinfo,
scb);
}
#endif
}
ahd_handle_message_phase(ahd);
break;
}
case NO_MATCH:
{
/* Ensure we don't leave the selection hardware on */
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
printf("%s:%c:%d: no active SCB for reconnecting "
"target - issuing BUS DEVICE RESET\n",
ahd_name(ahd), 'A', ahd_inb(ahd, SELID) >> 4);
printf("SAVED_SCSIID == 0x%x, SAVED_LUN == 0x%x, "
"REG0 == 0x%x ACCUM = 0x%x\n",
ahd_inb(ahd, SAVED_SCSIID), ahd_inb(ahd, SAVED_LUN),
ahd_inw(ahd, REG0), ahd_inb(ahd, ACCUM));
printf("SEQ_FLAGS == 0x%x, SCBPTR == 0x%x, BTT == 0x%x, "
"SINDEX == 0x%x\n",
ahd_inb(ahd, SEQ_FLAGS), ahd_get_scbptr(ahd),
ahd_find_busy_tcl(ahd,
BUILD_TCL(ahd_inb(ahd, SAVED_SCSIID),
ahd_inb(ahd, SAVED_LUN))),
ahd_inw(ahd, SINDEX));
printf("SELID == 0x%x, SCB_SCSIID == 0x%x, SCB_LUN == 0x%x, "
"SCB_CONTROL == 0x%x\n",
ahd_inb(ahd, SELID), ahd_inb_scbram(ahd, SCB_SCSIID),
ahd_inb_scbram(ahd, SCB_LUN),
ahd_inb_scbram(ahd, SCB_CONTROL));
printf("SCSIBUS[0] == 0x%x, SCSISIGI == 0x%x\n",
ahd_inb(ahd, SCSIBUS), ahd_inb(ahd, SCSISIGI));
printf("SXFRCTL0 == 0x%x\n", ahd_inb(ahd, SXFRCTL0));
printf("SEQCTL0 == 0x%x\n", ahd_inb(ahd, SEQCTL0));
ahd_dump_card_state(ahd);
ahd->msgout_buf[0] = MSG_BUS_DEV_RESET;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_assert_atn(ahd);
break;
}
case PROTO_VIOLATION:
{
ahd_handle_proto_violation(ahd);
break;
}
case IGN_WIDE_RES:
{
struct ahd_devinfo devinfo;
ahd_fetch_devinfo(ahd, &devinfo);
ahd_handle_ign_wide_residue(ahd, &devinfo);
break;
}
case BAD_PHASE:
{
u_int lastphase;
lastphase = ahd_inb(ahd, LASTPHASE);
printf("%s:%c:%d: unknown scsi bus phase %x, "
"lastphase = 0x%x. Attempting to continue\n",
ahd_name(ahd), 'A',
SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
lastphase, ahd_inb(ahd, SCSISIGI));
break;
}
case MISSED_BUSFREE:
{
u_int lastphase;
lastphase = ahd_inb(ahd, LASTPHASE);
printf("%s:%c:%d: Missed busfree. "
"Lastphase = 0x%x, Curphase = 0x%x\n",
ahd_name(ahd), 'A',
SCSIID_TARGET(ahd, ahd_inb(ahd, SAVED_SCSIID)),
lastphase, ahd_inb(ahd, SCSISIGI));
ahd_restart(ahd);
return;
}
case DATA_OVERRUN:
{
/*
* When the sequencer detects an overrun, it
* places the controller in "BITBUCKET" mode
* and allows the target to complete its transfer.
* Unfortunately, none of the counters get updated
* when the controller is in this mode, so we have
* no way of knowing how large the overrun was.
*/
struct scb *scb;
u_int scbindex;
#ifdef AHD_DEBUG
u_int lastphase;
#endif
scbindex = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbindex);
#ifdef AHD_DEBUG
lastphase = ahd_inb(ahd, LASTPHASE);
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
ahd_print_path(ahd, scb);
printf("data overrun detected %s. Tag == 0x%x.\n",
ahd_lookup_phase_entry(lastphase)->phasemsg,
SCB_GET_TAG(scb));
ahd_print_path(ahd, scb);
printf("%s seen Data Phase. Length = %ld. "
"NumSGs = %d.\n",
ahd_inb(ahd, SEQ_FLAGS) & DPHASE
? "Have" : "Haven't",
ahd_get_transfer_length(scb), scb->sg_count);
ahd_dump_sglist(scb);
}
#endif
/*
* Set this and it will take effect when the
* target does a command complete.
*/
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
ahd_freeze_scb(scb);
break;
}
case MKMSG_FAILED:
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int scbid;
ahd_fetch_devinfo(ahd, &devinfo);
printf("%s:%c:%d:%d: Attempt to issue message failed\n",
ahd_name(ahd), devinfo.channel, devinfo.target,
devinfo.lun);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (scb->flags & SCB_RECOVERY_SCB) != 0)
/*
* Ensure that we didn't put a second instance of this
* SCB into the QINFIFO.
*/
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, /*status*/0,
SEARCH_REMOVE);
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
break;
}
case TASKMGMT_FUNC_COMPLETE:
{
u_int scbid;
struct scb *scb;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL) {
u_int lun;
u_int tag;
cam_status error;
ahd_print_path(ahd, scb);
printf("Task Management Func 0x%x Complete\n",
scb->hscb->task_management);
lun = CAM_LUN_WILDCARD;
tag = SCB_LIST_NULL;
switch (scb->hscb->task_management) {
case SIU_TASKMGMT_ABORT_TASK:
tag = SCB_GET_TAG(scb);
case SIU_TASKMGMT_ABORT_TASK_SET:
case SIU_TASKMGMT_CLEAR_TASK_SET:
lun = scb->hscb->lun;
error = CAM_REQ_ABORTED;
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
'A', lun, tag, ROLE_INITIATOR,
error);
break;
case SIU_TASKMGMT_LUN_RESET:
lun = scb->hscb->lun;
case SIU_TASKMGMT_TARGET_RESET:
{
struct ahd_devinfo devinfo;
ahd_scb_devinfo(ahd, &devinfo, scb);
error = CAM_BDR_SENT;
ahd_handle_devreset(ahd, &devinfo, lun,
CAM_BDR_SENT,
lun != CAM_LUN_WILDCARD
? "Lun Reset"
: "Target Reset",
/*verbose_level*/0);
break;
}
default:
panic("Unexpected TaskMgmt Func\n");
break;
}
}
break;
}
case TASKMGMT_CMD_CMPLT_OKAY:
{
u_int scbid;
struct scb *scb;
/*
* An ABORT TASK TMF failed to be delivered before
* the targeted command completed normally.
*/
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL) {
/*
* Remove the second instance of this SCB from
* the QINFIFO if it is still there.
*/
ahd_print_path(ahd, scb);
printf("SCB completes before TMF\n");
/*
* Handle losing the race. Wait until any
* current selection completes. We will then
* set the TMF back to zero in this SCB so that
* the sequencer doesn't bother to issue another
* sequencer interrupt for its completion.
*/
while ((ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
&& (ahd_inb(ahd, SSTAT0) & SELDO) == 0
&& (ahd_inb(ahd, SSTAT1) & SELTO) == 0)
;
ahd_outb(ahd, SCB_TASK_MANAGEMENT, 0);
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, /*status*/0,
SEARCH_REMOVE);
}
break;
}
case TRACEPOINT0:
case TRACEPOINT1:
case TRACEPOINT2:
case TRACEPOINT3:
printf("%s: Tracepoint %d\n", ahd_name(ahd),
seqintcode - TRACEPOINT0);
break;
case NO_SEQINT:
break;
case SAW_HWERR:
ahd_handle_hwerrint(ahd);
break;
default:
printf("%s: Unexpected SEQINTCODE %d\n", ahd_name(ahd),
seqintcode);
break;
}
/*
* The sequencer is paused immediately on
* a SEQINT, so we should restart it when
* we're done.
*/
ahd_unpause(ahd);
}
void
ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
{
struct scb *scb;
u_int status0;
u_int status3;
u_int status;
u_int lqistat1;
u_int lqostat0;
u_int scbid;
u_int busfreetime;
ahd_update_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
status3 = ahd_inb(ahd, SSTAT3) & (NTRAMPERR|OSRAMPERR);
status0 = ahd_inb(ahd, SSTAT0) & (IOERR|OVERRUN|SELDI|SELDO);
status = ahd_inb(ahd, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR);
lqistat1 = ahd_inb(ahd, LQISTAT1);
lqostat0 = ahd_inb(ahd, LQOSTAT0);
busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
/*
* Ignore external resets after a bus reset.
*/
if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) {
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
return;
}
/*
* Clear bus reset flag
*/
ahd->flags &= ~AHD_BUS_RESET_ACTIVE;
if ((status0 & (SELDI|SELDO)) != 0) {
u_int simode0;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
simode0 = ahd_inb(ahd, SIMODE0);
status0 &= simode0 & (IOERR|OVERRUN|SELDI|SELDO);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
}
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
scb = NULL;
if ((status0 & IOERR) != 0) {
u_int now_lvd;
now_lvd = ahd_inb(ahd, SBLKCTL) & ENAB40;
printf("%s: Transceiver State Has Changed to %s mode\n",
ahd_name(ahd), now_lvd ? "LVD" : "SE");
ahd_outb(ahd, CLRSINT0, CLRIOERR);
/*
* A change in I/O mode is equivalent to a bus reset.
*/
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
ahd_pause(ahd);
ahd_setup_iocell_workaround(ahd);
ahd_unpause(ahd);
} else if ((status0 & OVERRUN) != 0) {
printf("%s: SCSI offset overrun detected. Resetting bus.\n",
ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
} else if ((status & SCSIRSTI) != 0) {
printf("%s: Someone reset channel A\n", ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/FALSE);
} else if ((status & SCSIPERR) != 0) {
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
ahd_handle_transmission_error(ahd);
} else if (lqostat0 != 0) {
printf("%s: lqostat0 == 0x%x!\n", ahd_name(ahd), lqostat0);
ahd_outb(ahd, CLRLQOINT0, lqostat0);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
ahd_outb(ahd, CLRLQOINT1, 0);
} else if ((status & SELTO) != 0) {
u_int scbid;
/* Stop the selection */
ahd_outb(ahd, SCSISEQ0, 0);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/* No more pending messages */
ahd_clear_msg_state(ahd);
/* Clear interrupt state */
ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR);
/*
* Although the driver does not care about the
* 'Selection in Progress' status bit, the busy
* LED does. SELINGO is only cleared by a sucessfull
* selection, so we must manually clear it to insure
* the LED turns off just incase no future successful
* selections occur (e.g. no devices on the bus).
*/
ahd_outb(ahd, CLRSINT0, CLRSELINGO);
scbid = ahd_inw(ahd, WAITING_TID_HEAD);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: ahd_intr - referenced scb not "
"valid during SELTO scb(0x%x)\n",
ahd_name(ahd), scbid);
ahd_dump_card_state(ahd);
} else {
struct ahd_devinfo devinfo;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SELTO) != 0) {
ahd_print_path(ahd, scb);
printf("Saw Selection Timeout for SCB 0x%x\n",
scbid);
}
#endif
ahd_scb_devinfo(ahd, &devinfo, scb);
ahd_set_transaction_status(scb, CAM_SEL_TIMEOUT);
ahd_freeze_devq(ahd, scb);
/*
* Cancel any pending transactions on the device
* now that it seems to be missing. This will
* also revert us to async/narrow transfers until
* we can renegotiate with the device.
*/
ahd_handle_devreset(ahd, &devinfo,
CAM_LUN_WILDCARD,
CAM_SEL_TIMEOUT,
"Selection Timeout",
/*verbose_level*/1);
}
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_iocell_first_selection(ahd);
ahd_unpause(ahd);
} else if ((status0 & (SELDI|SELDO)) != 0) {
ahd_iocell_first_selection(ahd);
ahd_unpause(ahd);
} else if (status3 != 0) {
printf("%s: SCSI Cell parity error SSTAT3 == 0x%x\n",
ahd_name(ahd), status3);
ahd_outb(ahd, CLRSINT3, status3);
} else if ((lqistat1 & (LQIPHASE_LQ|LQIPHASE_NLQ)) != 0) {
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
ahd_handle_lqiphase_error(ahd, lqistat1);
} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
/*
* This status can be delayed during some
* streaming operations. The SCSIPHASE
* handler has already dealt with this case
* so just clear the error.
*/
ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ);
} else if ((status & BUSFREE) != 0
|| (lqistat1 & LQOBUSFREE) != 0) {
u_int lqostat1;
int restart;
int clear_fifo;
int packetized;
u_int mode;
/*
* Clear our selection hardware as soon as possible.
* We may have an entry in the waiting Q for this target,
* that is affected by this busfree and we don't want to
* go about selecting the target while we handle the event.
*/
ahd_outb(ahd, SCSISEQ0, 0);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/*
* Determine what we were up to at the time of
* the busfree.
*/
mode = AHD_MODE_SCSI;
busfreetime = ahd_inb(ahd, SSTAT2) & BUSFREETIME;
lqostat1 = ahd_inb(ahd, LQOSTAT1);
switch (busfreetime) {
case BUSFREE_DFF0:
case BUSFREE_DFF1:
{
u_int scbid;
struct scb *scb;
mode = busfreetime == BUSFREE_DFF0
? AHD_MODE_DFF0 : AHD_MODE_DFF1;
ahd_set_modes(ahd, mode, mode);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: Invalid SCB %d in DFF%d "
"during unexpected busfree\n",
ahd_name(ahd), scbid, mode);
packetized = 0;
} else
packetized = (scb->flags & SCB_PACKETIZED) != 0;
clear_fifo = 1;
break;
}
case BUSFREE_LQO:
clear_fifo = 0;
packetized = 1;
break;
default:
clear_fifo = 0;
packetized = (lqostat1 & LQOBUSFREE) != 0;
if (!packetized
&& ahd_inb(ahd, LASTPHASE) == P_BUSFREE
&& (ahd_inb(ahd, SSTAT0) & SELDI) == 0
&& ((ahd_inb(ahd, SSTAT0) & SELDO) == 0
|| (ahd_inb(ahd, SCSISEQ0) & ENSELO) == 0))
/*
* Assume packetized if we are not
* on the bus in a non-packetized
* capacity and any pending selection
* was a packetized selection.
*/
packetized = 1;
break;
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("Saw Busfree. Busfreetime = 0x%x.\n",
busfreetime);
#endif
/*
* Busfrees that occur in non-packetized phases are
* handled by the nonpkt_busfree handler.
*/
if (packetized && ahd_inb(ahd, LASTPHASE) == P_BUSFREE) {
restart = ahd_handle_pkt_busfree(ahd, busfreetime);
} else {
packetized = 0;
restart = ahd_handle_nonpkt_busfree(ahd);
}
/*
* Clear the busfree interrupt status. The setting of
* the interrupt is a pulse, so in a perfect world, we
* would not need to muck with the ENBUSFREE logic. This
* would ensure that if the bus moves on to another
* connection, busfree protection is still in force. If
* BUSFREEREV is broken, however, we must manually clear
* the ENBUSFREE if the busfree occurred during a non-pack
* connection so that we don't get false positives during
* future, packetized, connections.
*/
ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
if (packetized == 0
&& (ahd->bugs & AHD_BUSFREEREV_BUG) != 0)
ahd_outb(ahd, SIMODE1,
ahd_inb(ahd, SIMODE1) & ~ENBUSFREE);
if (clear_fifo)
ahd_clear_fifo(ahd, mode);
ahd_clear_msg_state(ahd);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
if (restart) {
ahd_restart(ahd);
} else {
ahd_unpause(ahd);
}
} else {
printf("%s: Missing case in ahd_handle_scsiint. status = %x\n",
ahd_name(ahd), status);
ahd_dump_card_state(ahd);
ahd_clear_intstat(ahd);
ahd_unpause(ahd);
}
}
static void
ahd_handle_transmission_error(struct ahd_softc *ahd)
{
struct scb *scb;
u_int scbid;
u_int lqistat1;
u_int lqistat2;
u_int msg_out;
u_int curphase;
u_int lastphase;
u_int perrdiag;
u_int cur_col;
int silent;
scb = NULL;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
lqistat1 = ahd_inb(ahd, LQISTAT1) & ~(LQIPHASE_LQ|LQIPHASE_NLQ);
lqistat2 = ahd_inb(ahd, LQISTAT2);
if ((lqistat1 & (LQICRCI_NLQ|LQICRCI_LQ)) == 0
&& (ahd->bugs & AHD_NLQICRC_DELAYED_BUG) != 0) {
u_int lqistate;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
lqistate = ahd_inb(ahd, LQISTATE);
if ((lqistate >= 0x1E && lqistate <= 0x24)
|| (lqistate == 0x29)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_RECOVERY) != 0) {
printf("%s: NLQCRC found via LQISTATE\n",
ahd_name(ahd));
}
#endif
lqistat1 |= LQICRCI_NLQ;
}
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
}
ahd_outb(ahd, CLRLQIINT1, lqistat1);
lastphase = ahd_inb(ahd, LASTPHASE);
curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
perrdiag = ahd_inb(ahd, PERRDIAG);
msg_out = MSG_INITIATOR_DET_ERR;
ahd_outb(ahd, CLRSINT1, CLRSCSIPERR);
/*
* Try to find the SCB associated with this error.
*/
silent = FALSE;
if (lqistat1 == 0
|| (lqistat1 & LQICRCI_NLQ) != 0) {
if ((lqistat1 & (LQICRCI_NLQ|LQIOVERI_NLQ)) != 0)
ahd_set_active_fifo(ahd);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL && SCB_IS_SILENT(scb))
silent = TRUE;
}
cur_col = 0;
if (silent == FALSE) {
printf("%s: Transmission error detected\n", ahd_name(ahd));
ahd_lqistat1_print(lqistat1, &cur_col, 50);
ahd_lastphase_print(lastphase, &cur_col, 50);
ahd_scsisigi_print(curphase, &cur_col, 50);
ahd_perrdiag_print(perrdiag, &cur_col, 50);
printf("\n");
ahd_dump_card_state(ahd);
}
if ((lqistat1 & (LQIOVERI_LQ|LQIOVERI_NLQ)) != 0) {
if (silent == FALSE) {
printf("%s: Gross protocol error during incoming "
"packet. lqistat1 == 0x%x. Resetting bus.\n",
ahd_name(ahd), lqistat1);
}
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
} else if ((lqistat1 & LQICRCI_LQ) != 0) {
/*
* A CRC error has been detected on an incoming LQ.
* The bus is currently hung on the last ACK.
* Hit LQIRETRY to release the last ack, and
* wait for the sequencer to determine that ATNO
* is asserted while in message out to take us
* to our host message loop. No NONPACKREQ or
* LQIPHASE type errors will occur in this
* scenario. After this first LQIRETRY, the LQI
* manager will be in ISELO where it will
* happily sit until another packet phase begins.
* Unexpected bus free detection is enabled
* through any phases that occur after we release
* this last ack until the LQI manager sees a
* packet phase. This implies we may have to
* ignore a perfectly valid "unexected busfree"
* after our "initiator detected error" message is
* sent. A busfree is the expected response after
* we tell the target that it's L_Q was corrupted.
* (SPI4R09 10.7.3.3.3)
*/
ahd_outb(ahd, LQCTL2, LQIRETRY);
printf("LQIRetry for LQICRCI_LQ to release ACK\n");
} else if ((lqistat1 & LQICRCI_NLQ) != 0) {
/*
* We detected a CRC error in a NON-LQ packet.
* The hardware has varying behavior in this situation
* depending on whether this packet was part of a
* stream or not.
*
* PKT by PKT mode:
* The hardware has already acked the complete packet.
* If the target honors our outstanding ATN condition,
* we should be (or soon will be) in MSGOUT phase.
* This will trigger the LQIPHASE_LQ status bit as the
* hardware was expecting another LQ. Unexpected
* busfree detection is enabled. Once LQIPHASE_LQ is
* true (first entry into host message loop is much
* the same), we must clear LQIPHASE_LQ and hit
* LQIRETRY so the hardware is ready to handle
* a future LQ. NONPACKREQ will not be asserted again
* once we hit LQIRETRY until another packet is
* processed. The target may either go busfree
* or start another packet in response to our message.
*
* Read Streaming P0 asserted:
* If we raise ATN and the target completes the entire
* stream (P0 asserted during the last packet), the
* hardware will ack all data and return to the ISTART
* state. When the target reponds to our ATN condition,
* LQIPHASE_LQ will be asserted. We should respond to
* this with an LQIRETRY to prepare for any future
* packets. NONPACKREQ will not be asserted again
* once we hit LQIRETRY until another packet is
* processed. The target may either go busfree or
* start another packet in response to our message.
* Busfree detection is enabled.
*
* Read Streaming P0 not asserted:
* If we raise ATN and the target transitions to
* MSGOUT in or after a packet where P0 is not
* asserted, the hardware will assert LQIPHASE_NLQ.
* We should respond to the LQIPHASE_NLQ with an
* LQIRETRY. Should the target stay in a non-pkt
* phase after we send our message, the hardware
* will assert LQIPHASE_LQ. Recovery is then just as
* listed above for the read streaming with P0 asserted.
* Busfree detection is enabled.
*/
if (silent == FALSE)
printf("LQICRC_NLQ\n");
if (scb == NULL) {
printf("%s: No SCB valid for LQICRC_NLQ. "
"Resetting bus\n", ahd_name(ahd));
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
}
} else if ((lqistat1 & LQIBADLQI) != 0) {
printf("Need to handle BADLQI!\n");
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
return;
} else if ((perrdiag & (PARITYERR|PREVPHASE)) == PARITYERR) {
if ((curphase & ~P_DATAIN_DT) != 0) {
/* Ack the byte. So we can continue. */
if (silent == FALSE)
printf("Acking %s to clear perror\n",
ahd_lookup_phase_entry(curphase)->phasemsg);
ahd_inb(ahd, SCSIDAT);
}
if (curphase == P_MESGIN)
msg_out = MSG_PARITY_ERROR;
}
/*
* We've set the hardware to assert ATN if we
* get a parity error on "in" phases, so all we
* need to do is stuff the message buffer with
* the appropriate message. "In" phases have set
* mesg_out to something other than MSG_NOP.
*/
ahd->send_msg_perror = msg_out;
if (scb != NULL && msg_out == MSG_INITIATOR_DET_ERR)
scb->flags |= SCB_TRANSMISSION_ERROR;
ahd_outb(ahd, MSG_OUT, HOST_MSG);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_unpause(ahd);
}
static void
ahd_handle_lqiphase_error(struct ahd_softc *ahd, u_int lqistat1)
{
/*
* Clear the sources of the interrupts.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, CLRLQIINT1, lqistat1);
/*
* If the "illegal" phase changes were in response
* to our ATN to flag a CRC error, AND we ended up
* on packet boundaries, clear the error, restart the
* LQI manager as appropriate, and go on our merry
* way toward sending the message. Otherwise, reset
* the bus to clear the error.
*/
ahd_set_active_fifo(ahd);
if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0
&& (ahd_inb(ahd, MDFFSTAT) & DLZERO) != 0) {
if ((lqistat1 & LQIPHASE_LQ) != 0) {
printf("LQIRETRY for LQIPHASE_LQ\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
} else if ((lqistat1 & LQIPHASE_NLQ) != 0) {
printf("LQIRETRY for LQIPHASE_NLQ\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
} else
panic("ahd_handle_lqiphase_error: No phase errors\n");
ahd_dump_card_state(ahd);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_unpause(ahd);
} else {
printf("Reseting Channel for LQI Phase error\n");
ahd_dump_card_state(ahd);
ahd_reset_channel(ahd, 'A', /*Initiate Reset*/TRUE);
}
}
/*
* Packetized unexpected or expected busfree.
* Entered in mode based on busfreetime.
*/
static int
ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime)
{
u_int lqostat1;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
lqostat1 = ahd_inb(ahd, LQOSTAT1);
if ((lqostat1 & LQOBUSFREE) != 0) {
struct scb *scb;
u_int scbid;
u_int saved_scbptr;
u_int waiting_h;
u_int waiting_t;
u_int next;
/*
* The LQO manager detected an unexpected busfree
* either:
*
* 1) During an outgoing LQ.
* 2) After an outgoing LQ but before the first
* REQ of the command packet.
* 3) During an outgoing command packet.
*
* In all cases, CURRSCB is pointing to the
* SCB that encountered the failure. Clean
* up the queue, clear SELDO and LQOBUSFREE,
* and allow the sequencer to restart the select
* out at its lesure.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
scbid = ahd_inw(ahd, CURRSCB);
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL)
panic("SCB not valid during LQOBUSFREE");
/*
* Clear the status.
*/
ahd_outb(ahd, CLRLQOINT1, CLRLQOBUSFREE);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
ahd_outb(ahd, CLRLQOINT1, 0);
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
ahd_flush_device_writes(ahd);
ahd_outb(ahd, CLRSINT0, CLRSELDO);
/*
* Return the LQO manager to its idle loop. It will
* not do this automatically if the busfree occurs
* after the first REQ of either the LQ or command
* packet or between the LQ and command packet.
*/
ahd_outb(ahd, LQCTL2, ahd_inb(ahd, LQCTL2) | LQOTOIDLE);
/*
* Update the waiting for selection queue so
* we restart on the correct SCB.
*/
waiting_h = ahd_inw(ahd, WAITING_TID_HEAD);
saved_scbptr = ahd_get_scbptr(ahd);
if (waiting_h != scbid) {
ahd_outw(ahd, WAITING_TID_HEAD, scbid);
waiting_t = ahd_inw(ahd, WAITING_TID_TAIL);
if (waiting_t == waiting_h) {
ahd_outw(ahd, WAITING_TID_TAIL, scbid);
next = SCB_LIST_NULL;
} else {
ahd_set_scbptr(ahd, waiting_h);
next = ahd_inw_scbram(ahd, SCB_NEXT2);
}
ahd_set_scbptr(ahd, scbid);
ahd_outw(ahd, SCB_NEXT2, next);
}
ahd_set_scbptr(ahd, saved_scbptr);
if (scb->crc_retry_count < AHD_MAX_LQ_CRC_ERRORS) {
if (SCB_IS_SILENT(scb) == FALSE) {
ahd_print_path(ahd, scb);
printf("Probable outgoing LQ CRC error. "
"Retrying command\n");
}
scb->crc_retry_count++;
} else {
ahd_set_transaction_status(scb, CAM_UNCOR_PARITY);
ahd_freeze_scb(scb);
ahd_freeze_devq(ahd, scb);
}
/* Return unpausing the sequencer. */
return (0);
} else if ((ahd_inb(ahd, PERRDIAG) & PARITYERR) != 0) {
/*
* Ignore what are really parity errors that
* occur on the last REQ of a free running
* clock prior to going busfree. Some drives
* do not properly active negate just before
* going busfree resulting in a parity glitch.
*/
ahd_outb(ahd, CLRSINT1, CLRSCSIPERR|CLRBUSFREE);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MASKED_ERRORS) != 0)
printf("%s: Parity on last REQ detected "
"during busfree phase.\n",
ahd_name(ahd));
#endif
/* Return unpausing the sequencer. */
return (0);
}
if (ahd->src_mode != AHD_MODE_SCSI) {
u_int scbid;
struct scb *scb;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
ahd_print_path(ahd, scb);
printf("Unexpected PKT busfree condition\n");
ahd_dump_card_state(ahd);
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb), 'A',
SCB_GET_LUN(scb), SCB_GET_TAG(scb),
ROLE_INITIATOR, CAM_UNEXP_BUSFREE);
/* Return restarting the sequencer. */
return (1);
}
printf("%s: Unexpected PKT busfree condition\n", ahd_name(ahd));
ahd_dump_card_state(ahd);
/* Restart the sequencer. */
return (1);
}
/*
* Non-packetized unexpected or expected busfree.
*/
static int
ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int lastphase;
u_int saved_scsiid;
u_int saved_lun;
u_int target;
u_int initiator_role_id;
u_int scbid;
u_int ppr_busfree;
int printerror;
/*
* Look at what phase we were last in. If its message out,
* chances are pretty good that the busfree was in response
* to one of our abort requests.
*/
lastphase = ahd_inb(ahd, LASTPHASE);
saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
saved_lun = ahd_inb(ahd, SAVED_LUN);
target = SCSIID_TARGET(ahd, saved_scsiid);
initiator_role_id = SCSIID_OUR_ID(saved_scsiid);
ahd_compile_devinfo(&devinfo, initiator_role_id,
target, saved_lun, 'A', ROLE_INITIATOR);
printerror = 1;
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
if (scb != NULL
&& (ahd_inb(ahd, SEQ_FLAGS) & NOT_IDENTIFIED) != 0)
scb = NULL;
ppr_busfree = (ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0;
if (lastphase == P_MESGOUT) {
u_int tag;
tag = SCB_LIST_NULL;
if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT_TAG, TRUE)
|| ahd_sent_msg(ahd, AHDMSG_1B, MSG_ABORT, TRUE)) {
int found;
int sent_msg;
if (scb == NULL) {
ahd_print_devinfo(ahd, &devinfo);
printf("Abort for unidentified "
"connection completed.\n");
/* restart the sequencer. */
return (1);
}
sent_msg = ahd->msgout_buf[ahd->msgout_index - 1];
ahd_print_path(ahd, scb);
printf("SCB %d - Abort%s Completed.\n",
SCB_GET_TAG(scb),
sent_msg == MSG_ABORT_TAG ? "" : " Tag");
if (sent_msg == MSG_ABORT_TAG)
tag = SCB_GET_TAG(scb);
if ((scb->flags & SCB_EXTERNAL_RESET) != 0) {
/*
* This abort is in response to an
* unexpected switch to command phase
* for a packetized connection. Since
* the identify message was never sent,
* "saved lun" is 0. We really want to
* abort only the SCB that encountered
* this error, which could have a different
* lun. The SCB will be retried so the OS
* will see the UA after renegotiating to
* packetized.
*/
tag = SCB_GET_TAG(scb);
saved_lun = scb->hscb->lun;
}
found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
tag, ROLE_INITIATOR,
CAM_REQ_ABORTED);
printf("found == 0x%x\n", found);
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_1B,
MSG_BUS_DEV_RESET, TRUE)) {
#ifdef __FreeBSD__
/*
* Don't mark the user's request for this BDR
* as completing with CAM_BDR_SENT. CAM3
* specifies CAM_REQ_CMP.
*/
if (scb != NULL
&& scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
&& ahd_match_scb(ahd, scb, target, 'A',
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_INITIATOR))
ahd_set_transaction_status(scb, CAM_REQ_CMP);
#endif
ahd_handle_devreset(ahd, &devinfo, CAM_LUN_WILDCARD,
CAM_BDR_SENT, "Bus Device Reset",
/*verbose_level*/0);
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, FALSE)
&& ppr_busfree == 0) {
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
/*
* PPR Rejected.
*
* If the previous negotiation was packetized,
* this could be because the device has been
* reset without our knowledge. Force our
* current negotiation to async and retry the
* negotiation. Otherwise retry the command
* with non-ppr negotiation.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("PPR negotiation rejected busfree.\n");
#endif
tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
devinfo.our_scsiid,
devinfo.target, &tstate);
if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ)!=0) {
ahd_set_width(ahd, &devinfo,
MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR,
/*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo,
/*period*/0, /*offset*/0,
/*ppr_options*/0,
AHD_TRANS_CUR,
/*paused*/TRUE);
/*
* The expect PPR busfree handler below
* will effect the retry and necessary
* abort.
*/
} else {
tinfo->curr.transport_version = 2;
tinfo->goal.transport_version = 2;
tinfo->goal.ppr_options = 0;
/*
* Remove any SCBs in the waiting for selection
* queue that may also be for this target so
* that command ordering is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
printerror = 0;
}
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
&& ppr_busfree == 0) {
/*
* Negotiation Rejected. Go-narrow and
* retry command.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("WDTR negotiation rejected busfree.\n");
#endif
ahd_set_width(ahd, &devinfo,
MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* Remove any SCBs in the waiting for selection
* queue that may also be for this target so that
* command ordering is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
printerror = 0;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE)
&& ppr_busfree == 0) {
/*
* Negotiation Rejected. Go-async and
* retry command.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("SDTR negotiation rejected busfree.\n");
#endif
ahd_set_syncrate(ahd, &devinfo,
/*period*/0, /*offset*/0,
/*ppr_options*/0,
AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* Remove any SCBs in the waiting for selection
* queue that may also be for this target so that
* command ordering is preserved.
*/
ahd_freeze_devq(ahd, scb);
ahd_qinfifo_requeue_tail(ahd, scb);
printerror = 0;
} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
&& ahd_sent_msg(ahd, AHDMSG_1B,
MSG_INITIATOR_DET_ERR, TRUE)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("Expected IDE Busfree\n");
#endif
printerror = 0;
} else if ((ahd->msg_flags & MSG_FLAG_EXPECT_QASREJ_BUSFREE)
&& ahd_sent_msg(ahd, AHDMSG_1B,
MSG_MESSAGE_REJECT, TRUE)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("Expected QAS Reject Busfree\n");
#endif
printerror = 0;
}
}
/*
* The busfree required flag is honored at the end of
* the message phases. We check it last in case we
* had to send some other message that caused a busfree.
*/
if (printerror != 0
&& (lastphase == P_MESGIN || lastphase == P_MESGOUT)
&& ((ahd->msg_flags & MSG_FLAG_EXPECT_PPR_BUSFREE) != 0)) {
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
ahd_freeze_scb(scb);
if ((ahd->msg_flags & MSG_FLAG_IU_REQ_CHANGED) != 0) {
ahd_abort_scbs(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), SCB_LIST_NULL,
ROLE_INITIATOR, CAM_REQ_ABORTED);
} else {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("PPR Negotiation Busfree.\n");
#endif
ahd_done(ahd, scb);
}
printerror = 0;
}
if (printerror != 0) {
int aborted;
aborted = 0;
if (scb != NULL) {
u_int tag;
if ((scb->hscb->control & TAG_ENB) != 0)
tag = SCB_GET_TAG(scb);
else
tag = SCB_LIST_NULL;
ahd_print_path(ahd, scb);
aborted = ahd_abort_scbs(ahd, target, 'A',
SCB_GET_LUN(scb), tag,
ROLE_INITIATOR,
CAM_UNEXP_BUSFREE);
} else {
/*
* We had not fully identified this connection,
* so we cannot abort anything.
*/
printf("%s: ", ahd_name(ahd));
}
printf("Unexpected busfree %s, %d SCBs aborted, "
"PRGMCNT == 0x%x\n",
ahd_lookup_phase_entry(lastphase)->phasemsg,
aborted,
ahd_inw(ahd, PRGMCNT));
ahd_dump_card_state(ahd);
if (lastphase != P_BUSFREE)
ahd_force_renegotiation(ahd, &devinfo);
}
/* Always restart the sequencer. */
return (1);
}
static void
ahd_handle_proto_violation(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
struct scb *scb;
u_int scbid;
u_int seq_flags;
u_int curphase;
u_int lastphase;
int found;
ahd_fetch_devinfo(ahd, &devinfo);
scbid = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scbid);
seq_flags = ahd_inb(ahd, SEQ_FLAGS);
curphase = ahd_inb(ahd, SCSISIGI) & PHASE_MASK;
lastphase = ahd_inb(ahd, LASTPHASE);
if ((seq_flags & NOT_IDENTIFIED) != 0) {
/*
* The reconnecting target either did not send an
* identify message, or did, but we didn't find an SCB
* to match.
*/
ahd_print_devinfo(ahd, &devinfo);
printf("Target did not send an IDENTIFY message. "
"LASTPHASE = 0x%x.\n", lastphase);
scb = NULL;
} else if (scb == NULL) {
/*
* We don't seem to have an SCB active for this
* transaction. Print an error and reset the bus.
*/
ahd_print_devinfo(ahd, &devinfo);
printf("No SCB found during protocol violation\n");
goto proto_violation_reset;
} else {
ahd_set_transaction_status(scb, CAM_SEQUENCE_FAIL);
if ((seq_flags & NO_CDB_SENT) != 0) {
ahd_print_path(ahd, scb);
printf("No or incomplete CDB sent to device.\n");
} else if ((ahd_inb_scbram(ahd, SCB_CONTROL)
& STATUS_RCVD) == 0) {
/*
* The target never bothered to provide status to
* us prior to completing the command. Since we don't
* know the disposition of this command, we must attempt
* to abort it. Assert ATN and prepare to send an abort
* message.
*/
ahd_print_path(ahd, scb);
printf("Completed command without status.\n");
} else {
ahd_print_path(ahd, scb);
printf("Unknown protocol violation.\n");
ahd_dump_card_state(ahd);
}
}
if ((lastphase & ~P_DATAIN_DT) == 0
|| lastphase == P_COMMAND) {
proto_violation_reset:
/*
* Target either went directly to data
* phase or didn't respond to our ATN.
* The only safe thing to do is to blow
* it away with a bus reset.
*/
found = ahd_reset_channel(ahd, 'A', TRUE);
printf("%s: Issued Channel %c Bus Reset. "
"%d SCBs aborted\n", ahd_name(ahd), 'A', found);
} else {
/*
* Leave the selection hardware off in case
* this abort attempt will affect yet to
* be sent commands.
*/
ahd_outb(ahd, SCSISEQ0,
ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
ahd_assert_atn(ahd);
ahd_outb(ahd, MSG_OUT, HOST_MSG);
if (scb == NULL) {
ahd_print_devinfo(ahd, &devinfo);
ahd->msgout_buf[0] = MSG_ABORT_TASK;
ahd->msgout_len = 1;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
} else {
ahd_print_path(ahd, scb);
scb->flags |= SCB_ABORT;
}
printf("Protocol violation %s. Attempting to abort.\n",
ahd_lookup_phase_entry(curphase)->phasemsg);
}
}
/*
* Force renegotiation to occur the next time we initiate
* a command to the current device.
*/
static void
ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, devinfo);
printf("Forcing renegotiation\n");
}
#endif
targ_info = ahd_fetch_transinfo(ahd,
devinfo->channel,
devinfo->our_scsiid,
devinfo->target,
&tstate);
ahd_update_neg_request(ahd, devinfo, tstate,
targ_info, AHD_NEG_IF_NON_ASYNC);
}
#define AHD_MAX_STEPS 2000
static void
ahd_clear_critical_section(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
int stepping;
int steps;
int first_instr;
u_int simode0;
u_int simode1;
u_int simode3;
u_int lqimode0;
u_int lqimode1;
u_int lqomode0;
u_int lqomode1;
if (ahd->num_critical_sections == 0)
return;
stepping = FALSE;
steps = 0;
first_instr = 0;
simode0 = 0;
simode1 = 0;
simode3 = 0;
lqimode0 = 0;
lqimode1 = 0;
lqomode0 = 0;
lqomode1 = 0;
saved_modes = ahd_save_modes(ahd);
for (;;) {
struct cs *cs;
u_int seqaddr;
u_int i;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
seqaddr = ahd_inw(ahd, CURADDR);
cs = ahd->critical_sections;
for (i = 0; i < ahd->num_critical_sections; i++, cs++) {
if (cs->begin < seqaddr && cs->end >= seqaddr)
break;
}
if (i == ahd->num_critical_sections)
break;
if (steps > AHD_MAX_STEPS) {
printf("%s: Infinite loop in critical section\n"
"%s: First Instruction 0x%x now 0x%x\n",
ahd_name(ahd), ahd_name(ahd), first_instr,
seqaddr);
ahd_dump_card_state(ahd);
panic("critical section loop");
}
steps++;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: Single stepping at 0x%x\n", ahd_name(ahd),
seqaddr);
#endif
if (stepping == FALSE) {
first_instr = seqaddr;
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
simode0 = ahd_inb(ahd, SIMODE0);
simode3 = ahd_inb(ahd, SIMODE3);
lqimode0 = ahd_inb(ahd, LQIMODE0);
lqimode1 = ahd_inb(ahd, LQIMODE1);
lqomode0 = ahd_inb(ahd, LQOMODE0);
lqomode1 = ahd_inb(ahd, LQOMODE1);
ahd_outb(ahd, SIMODE0, 0);
ahd_outb(ahd, SIMODE3, 0);
ahd_outb(ahd, LQIMODE0, 0);
ahd_outb(ahd, LQIMODE1, 0);
ahd_outb(ahd, LQOMODE0, 0);
ahd_outb(ahd, LQOMODE1, 0);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
simode1 = ahd_inb(ahd, SIMODE1);
/*
* We don't clear ENBUSFREE. Unfortunately
* we cannot re-enable busfree detection within
* the current connection, so we must leave it
* on while single stepping.
*/
ahd_outb(ahd, SIMODE1, simode1 & ENBUSFREE);
ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) | STEP);
stepping = TRUE;
}
ahd_outb(ahd, CLRSINT1, CLRBUSFREE);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
ahd_outb(ahd, HCNTRL, ahd->unpause);
while (!ahd_is_paused(ahd))
ahd_delay(200);
ahd_update_modes(ahd);
}
if (stepping) {
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, SIMODE0, simode0);
ahd_outb(ahd, SIMODE3, simode3);
ahd_outb(ahd, LQIMODE0, lqimode0);
ahd_outb(ahd, LQIMODE1, lqimode1);
ahd_outb(ahd, LQOMODE0, lqomode0);
ahd_outb(ahd, LQOMODE1, lqomode1);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, SEQCTL0, ahd_inb(ahd, SEQCTL0) & ~STEP);
ahd_outb(ahd, SIMODE1, simode1);
/*
* SCSIINT seems to glitch occassionally when
* the interrupt masks are restored. Clear SCSIINT
* one more time so that only persistent errors
* are seen as a real interrupt.
*/
ahd_outb(ahd, CLRINT, CLRSCSIINT);
}
ahd_restore_modes(ahd, saved_modes);
}
/*
* Clear any pending interrupt status.
*/
static void
ahd_clear_intstat(struct ahd_softc *ahd)
{
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
/* Clear any interrupt conditions this may have caused */
ahd_outb(ahd, CLRLQIINT0, CLRLQIATNQAS|CLRLQICRCT1|CLRLQICRCT2
|CLRLQIBADLQT|CLRLQIATNLQ|CLRLQIATNCMD);
ahd_outb(ahd, CLRLQIINT1, CLRLQIPHASE_LQ|CLRLQIPHASE_NLQ|CLRLIQABORT
|CLRLQICRCI_LQ|CLRLQICRCI_NLQ|CLRLQIBADLQI
|CLRLQIOVERI_LQ|CLRLQIOVERI_NLQ|CLRNONPACKREQ);
ahd_outb(ahd, CLRLQOINT0, CLRLQOTARGSCBPERR|CLRLQOSTOPT2|CLRLQOATNLQ
|CLRLQOATNPKT|CLRLQOTCRC);
ahd_outb(ahd, CLRLQOINT1, CLRLQOINITSCBPERR|CLRLQOSTOPI2|CLRLQOBADQAS
|CLRLQOBUSFREE|CLRLQOPHACHGINPKT);
if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0) {
ahd_outb(ahd, CLRLQOINT0, 0);
ahd_outb(ahd, CLRLQOINT1, 0);
}
ahd_outb(ahd, CLRSINT3, CLRNTRAMPERR|CLROSRAMPERR);
ahd_outb(ahd, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI
|CLRBUSFREE|CLRSCSIPERR|CLRREQINIT);
ahd_outb(ahd, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO
|CLRIOERR|CLROVERRUN);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
}
/**************************** Debugging Routines ******************************/
#ifdef AHD_DEBUG
uint32_t ahd_debug = AHD_DEBUG_OPTS;
#endif
#if 0
void
ahd_print_scb(struct scb *scb)
{
struct hardware_scb *hscb;
int i;
hscb = scb->hscb;
printf("scb:%p control:0x%x scsiid:0x%x lun:%d cdb_len:%d\n",
(void *)scb,
hscb->control,
hscb->scsiid,
hscb->lun,
hscb->cdb_len);
printf("Shared Data: ");
for (i = 0; i < sizeof(hscb->shared_data.idata.cdb); i++)
printf("%#02x", hscb->shared_data.idata.cdb[i]);
printf(" dataptr:%#x%x datacnt:%#x sgptr:%#x tag:%#x\n",
(uint32_t)((ahd_le64toh(hscb->dataptr) >> 32) & 0xFFFFFFFF),
(uint32_t)(ahd_le64toh(hscb->dataptr) & 0xFFFFFFFF),
ahd_le32toh(hscb->datacnt),
ahd_le32toh(hscb->sgptr),
SCB_GET_TAG(scb));
ahd_dump_sglist(scb);
}
#endif /* 0 */
/************************* Transfer Negotiation *******************************/
/*
* Allocate per target mode instance (ID we respond to as a target)
* transfer negotiation data structures.
*/
static struct ahd_tmode_tstate *
ahd_alloc_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel)
{
struct ahd_tmode_tstate *master_tstate;
struct ahd_tmode_tstate *tstate;
int i;
master_tstate = ahd->enabled_targets[ahd->our_id];
if (ahd->enabled_targets[scsi_id] != NULL
&& ahd->enabled_targets[scsi_id] != master_tstate)
panic("%s: ahd_alloc_tstate - Target already allocated",
ahd_name(ahd));
tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
if (tstate == NULL)
return (NULL);
/*
* If we have allocated a master tstate, copy user settings from
* the master tstate (taken from SRAM or the EEPROM) for this
* channel, but reset our current and goal settings to async/narrow
* until an initiator talks to us.
*/
if (master_tstate != NULL) {
memcpy(tstate, master_tstate, sizeof(*tstate));
memset(tstate->enabled_luns, 0, sizeof(tstate->enabled_luns));
for (i = 0; i < 16; i++) {
memset(&tstate->transinfo[i].curr, 0,
sizeof(tstate->transinfo[i].curr));
memset(&tstate->transinfo[i].goal, 0,
sizeof(tstate->transinfo[i].goal));
}
} else
memset(tstate, 0, sizeof(*tstate));
ahd->enabled_targets[scsi_id] = tstate;
return (tstate);
}
#ifdef AHD_TARGET_MODE
/*
* Free per target mode instance (ID we respond to as a target)
* transfer negotiation data structures.
*/
static void
ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
{
struct ahd_tmode_tstate *tstate;
/*
* Don't clean up our "master" tstate.
* It has our default user settings.
*/
if (scsi_id == ahd->our_id
&& force == FALSE)
return;
tstate = ahd->enabled_targets[scsi_id];
if (tstate != NULL)
free(tstate, M_DEVBUF);
ahd->enabled_targets[scsi_id] = NULL;
}
#endif
/*
* Called when we have an active connection to a target on the bus,
* this function finds the nearest period to the input period limited
* by the capabilities of the bus connectivity of and sync settings for
* the target.
*/
void
ahd_devlimited_syncrate(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *tinfo,
u_int *period, u_int *ppr_options, role_t role)
{
struct ahd_transinfo *transinfo;
u_int maxsync;
if ((ahd_inb(ahd, SBLKCTL) & ENAB40) != 0
&& (ahd_inb(ahd, SSTAT2) & EXP_ACTIVE) == 0) {
maxsync = AHD_SYNCRATE_PACED;
} else {
maxsync = AHD_SYNCRATE_ULTRA;
/* Can't do DT related options on an SE bus */
*ppr_options &= MSG_EXT_PPR_QAS_REQ;
}
/*
* Never allow a value higher than our current goal
* period otherwise we may allow a target initiated
* negotiation to go above the limit as set by the
* user. In the case of an initiator initiated
* sync negotiation, we limit based on the user
* setting. This allows the system to still accept
* incoming negotiations even if target initiated
* negotiation is not performed.
*/
if (role == ROLE_TARGET)
transinfo = &tinfo->user;
else
transinfo = &tinfo->goal;
*ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
maxsync = max(maxsync, (u_int)AHD_SYNCRATE_ULTRA2);
*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
}
if (transinfo->period == 0) {
*period = 0;
*ppr_options = 0;
} else {
*period = max(*period, (u_int)transinfo->period);
ahd_find_syncrate(ahd, period, ppr_options, maxsync);
}
}
/*
* Look up the valid period to SCSIRATE conversion in our table.
* Return the period and offset that should be sent to the target
* if this was the beginning of an SDTR.
*/
void
ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
u_int *ppr_options, u_int maxsync)
{
if (*period < maxsync)
*period = maxsync;
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) != 0
&& *period > AHD_SYNCRATE_MIN_DT)
*ppr_options &= ~MSG_EXT_PPR_DT_REQ;
if (*period > AHD_SYNCRATE_MIN)
*period = 0;
/* Honor PPR option conformance rules. */
if (*period > AHD_SYNCRATE_PACED)
*ppr_options &= ~MSG_EXT_PPR_RTI;
if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
*ppr_options &= (MSG_EXT_PPR_DT_REQ|MSG_EXT_PPR_QAS_REQ);
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0)
*ppr_options &= MSG_EXT_PPR_QAS_REQ;
/* Skip all PACED only entries if IU is not available */
if ((*ppr_options & MSG_EXT_PPR_IU_REQ) == 0
&& *period < AHD_SYNCRATE_DT)
*period = AHD_SYNCRATE_DT;
/* Skip all DT only entries if DT is not available */
if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0
&& *period < AHD_SYNCRATE_ULTRA2)
*period = AHD_SYNCRATE_ULTRA2;
}
/*
* Truncate the given synchronous offset to a value the
* current adapter type and syncrate are capable of.
*/
static void
ahd_validate_offset(struct ahd_softc *ahd,
struct ahd_initiator_tinfo *tinfo,
u_int period, u_int *offset, int wide,
role_t role)
{
u_int maxoffset;
/* Limit offset to what we can do */
if (period == 0)
maxoffset = 0;
else if (period <= AHD_SYNCRATE_PACED) {
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0)
maxoffset = MAX_OFFSET_PACED_BUG;
else
maxoffset = MAX_OFFSET_PACED;
} else
maxoffset = MAX_OFFSET_NON_PACED;
*offset = min(*offset, maxoffset);
if (tinfo != NULL) {
if (role == ROLE_TARGET)
*offset = min(*offset, (u_int)tinfo->user.offset);
else
*offset = min(*offset, (u_int)tinfo->goal.offset);
}
}
/*
* Truncate the given transfer width parameter to a value the
* current adapter type is capable of.
*/
static void
ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
u_int *bus_width, role_t role)
{
switch (*bus_width) {
default:
if (ahd->features & AHD_WIDE) {
/* Respond Wide */
*bus_width = MSG_EXT_WDTR_BUS_16_BIT;
break;
}
/* FALLTHROUGH */
case MSG_EXT_WDTR_BUS_8_BIT:
*bus_width = MSG_EXT_WDTR_BUS_8_BIT;
break;
}
if (tinfo != NULL) {
if (role == ROLE_TARGET)
*bus_width = min((u_int)tinfo->user.width, *bus_width);
else
*bus_width = min((u_int)tinfo->goal.width, *bus_width);
}
}
/*
* Update the bitmask of targets for which the controller should
* negotiate with at the next convenient oportunity. This currently
* means the next time we send the initial identify messages for
* a new transaction.
*/
int
ahd_update_neg_request(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct ahd_tmode_tstate *tstate,
struct ahd_initiator_tinfo *tinfo, ahd_neg_type neg_type)
{
u_int auto_negotiate_orig;
auto_negotiate_orig = tstate->auto_negotiate;
if (neg_type == AHD_NEG_ALWAYS) {
/*
* Force our "current" settings to be
* unknown so that unless a bus reset
* occurs the need to renegotiate is
* recorded persistently.
*/
if ((ahd->features & AHD_WIDE) != 0)
tinfo->curr.width = AHD_WIDTH_UNKNOWN;
tinfo->curr.period = AHD_PERIOD_UNKNOWN;
tinfo->curr.offset = AHD_OFFSET_UNKNOWN;
}
if (tinfo->curr.period != tinfo->goal.period
|| tinfo->curr.width != tinfo->goal.width
|| tinfo->curr.offset != tinfo->goal.offset
|| tinfo->curr.ppr_options != tinfo->goal.ppr_options
|| (neg_type == AHD_NEG_IF_NON_ASYNC
&& (tinfo->goal.offset != 0
|| tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT
|| tinfo->goal.ppr_options != 0)))
tstate->auto_negotiate |= devinfo->target_mask;
else
tstate->auto_negotiate &= ~devinfo->target_mask;
return (auto_negotiate_orig != tstate->auto_negotiate);
}
/*
* Update the user/goal/curr tables of synchronous negotiation
* parameters as well as, in the case of a current or active update,
* any data structures on the host controller. In the case of an
* active update, the specified target is currently talking to us on
* the bus, so the transfer parameter update must take effect
* immediately.
*/
void
ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset, u_int ppr_options,
u_int type, int paused)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int old_period;
u_int old_offset;
u_int old_ppr;
int active;
int update_needed;
active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
update_needed = 0;
if (period == 0 || offset == 0) {
period = 0;
offset = 0;
}
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
if ((type & AHD_TRANS_USER) != 0) {
tinfo->user.period = period;
tinfo->user.offset = offset;
tinfo->user.ppr_options = ppr_options;
}
if ((type & AHD_TRANS_GOAL) != 0) {
tinfo->goal.period = period;
tinfo->goal.offset = offset;
tinfo->goal.ppr_options = ppr_options;
}
old_period = tinfo->curr.period;
old_offset = tinfo->curr.offset;
old_ppr = tinfo->curr.ppr_options;
if ((type & AHD_TRANS_CUR) != 0
&& (old_period != period
|| old_offset != offset
|| old_ppr != ppr_options)) {
update_needed++;
tinfo->curr.period = period;
tinfo->curr.offset = offset;
tinfo->curr.ppr_options = ppr_options;
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
if (bootverbose) {
if (offset != 0) {
int options;
printf("%s: target %d synchronous with "
"period = 0x%x, offset = 0x%x",
ahd_name(ahd), devinfo->target,
period, offset);
options = 0;
if ((ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
printf("(RDSTRM");
options++;
}
if ((ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
printf("%s", options ? "|DT" : "(DT");
options++;
}
if ((ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
printf("%s", options ? "|IU" : "(IU");
options++;
}
if ((ppr_options & MSG_EXT_PPR_RTI) != 0) {
printf("%s", options ? "|RTI" : "(RTI");
options++;
}
if ((ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
printf("%s", options ? "|QAS" : "(QAS");
options++;
}
if (options != 0)
printf(")\n");
else
printf("\n");
} else {
printf("%s: target %d using "
"asynchronous transfers%s\n",
ahd_name(ahd), devinfo->target,
(ppr_options & MSG_EXT_PPR_QAS_REQ) != 0
? "(QAS)" : "");
}
}
}
/*
* Always refresh the neg-table to handle the case of the
* sequencer setting the ENATNO bit for a MK_MESSAGE request.
* We will always renegotiate in that case if this is a
* packetized request. Also manage the busfree expected flag
* from this common routine so that we catch changes due to
* WDTR or SDTR messages.
*/
if ((type & AHD_TRANS_CUR) != 0) {
if (!paused)
ahd_pause(ahd);
ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
if (!paused)
ahd_unpause(ahd);
if (ahd->msg_type != MSG_TYPE_NONE) {
if ((old_ppr & MSG_EXT_PPR_IU_REQ)
!= (ppr_options & MSG_EXT_PPR_IU_REQ)) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, devinfo);
printf("Expecting IU Change busfree\n");
}
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
| MSG_FLAG_IU_REQ_CHANGED;
}
if ((old_ppr & MSG_EXT_PPR_IU_REQ) != 0) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("PPR with IU_REQ outstanding\n");
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE;
}
}
}
update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_TO_GOAL);
if (update_needed && active)
ahd_update_pending_scbs(ahd);
}
/*
* Update the user/goal/curr tables of wide negotiation
* parameters as well as, in the case of a current or active update,
* any data structures on the host controller. In the case of an
* active update, the specified target is currently talking to us on
* the bus, so the transfer parameter update must take effect
* immediately.
*/
void
ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int width, u_int type, int paused)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int oldwidth;
int active;
int update_needed;
active = (type & AHD_TRANS_ACTIVE) == AHD_TRANS_ACTIVE;
update_needed = 0;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
if ((type & AHD_TRANS_USER) != 0)
tinfo->user.width = width;
if ((type & AHD_TRANS_GOAL) != 0)
tinfo->goal.width = width;
oldwidth = tinfo->curr.width;
if ((type & AHD_TRANS_CUR) != 0 && oldwidth != width) {
update_needed++;
tinfo->curr.width = width;
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
if (bootverbose) {
printf("%s: target %d using %dbit transfers\n",
ahd_name(ahd), devinfo->target,
8 * (0x01 << width));
}
}
if ((type & AHD_TRANS_CUR) != 0) {
if (!paused)
ahd_pause(ahd);
ahd_update_neg_table(ahd, devinfo, &tinfo->curr);
if (!paused)
ahd_unpause(ahd);
}
update_needed += ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_TO_GOAL);
if (update_needed && active)
ahd_update_pending_scbs(ahd);
}
/*
* Update the current state of tagged queuing for a given target.
*/
static void
ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
struct ahd_devinfo *devinfo, ahd_queue_alg alg)
{
struct scsi_device *sdev = cmd->device;
ahd_platform_set_tags(ahd, sdev, devinfo, alg);
ahd_send_async(ahd, devinfo->channel, devinfo->target,
devinfo->lun, AC_TRANSFER_NEG);
}
static void
ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct ahd_transinfo *tinfo)
{
ahd_mode_state saved_modes;
u_int period;
u_int ppr_opts;
u_int con_opts;
u_int offset;
u_int saved_negoaddr;
uint8_t iocell_opts[sizeof(ahd->iocell_opts)];
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_negoaddr = ahd_inb(ahd, NEGOADDR);
ahd_outb(ahd, NEGOADDR, devinfo->target);
period = tinfo->period;
offset = tinfo->offset;
memcpy(iocell_opts, ahd->iocell_opts, sizeof(ahd->iocell_opts));
ppr_opts = tinfo->ppr_options & (MSG_EXT_PPR_QAS_REQ|MSG_EXT_PPR_DT_REQ
|MSG_EXT_PPR_IU_REQ|MSG_EXT_PPR_RTI);
con_opts = 0;
if (period == 0)
period = AHD_SYNCRATE_ASYNC;
if (period == AHD_SYNCRATE_160) {
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
/*
* When the SPI4 spec was finalized, PACE transfers
* was not made a configurable option in the PPR
* message. Instead it is assumed to be enabled for
* any syncrate faster than 80MHz. Nevertheless,
* Harpoon2A4 allows this to be configurable.
*
* Harpoon2A4 also assumes at most 2 data bytes per
* negotiated REQ/ACK offset. Paced transfers take
* 4, so we must adjust our offset.
*/
ppr_opts |= PPROPT_PACE;
offset *= 2;
/*
* Harpoon2A assumed that there would be a
* fallback rate between 160MHz and 80Mhz,
* so 7 is used as the period factor rather
* than 8 for 160MHz.
*/
period = AHD_SYNCRATE_REVA_160;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_PCOMP_EN) == 0)
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
~AHD_PRECOMP_MASK;
} else {
/*
* Precomp should be disabled for non-paced transfers.
*/
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK;
if ((ahd->features & AHD_NEW_IOCELL_OPTS) != 0
&& (ppr_opts & MSG_EXT_PPR_DT_REQ) != 0
&& (ppr_opts & MSG_EXT_PPR_IU_REQ) == 0) {
/*
* Slow down our CRC interval to be
* compatible with non-packetized
* U160 devices that can't handle a
* CRC at full speed.
*/
con_opts |= ENSLOWCRC;
}
if ((ahd->bugs & AHD_PACED_NEGTABLE_BUG) != 0) {
/*
* On H2A4, revert to a slower slewrate
* on non-paced transfers.
*/
iocell_opts[AHD_PRECOMP_SLEW_INDEX] &=
~AHD_SLEWRATE_MASK;
}
}
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PRECOMP_SLEW);
ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_PRECOMP_SLEW_INDEX]);
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_AMPLITUDE);
ahd_outb(ahd, ANNEXDAT, iocell_opts[AHD_AMPLITUDE_INDEX]);
ahd_outb(ahd, NEGPERIOD, period);
ahd_outb(ahd, NEGPPROPTS, ppr_opts);
ahd_outb(ahd, NEGOFFSET, offset);
if (tinfo->width == MSG_EXT_WDTR_BUS_16_BIT)
con_opts |= WIDEXFER;
/*
* Slow down our CRC interval to be
* compatible with packetized U320 devices
* that can't handle a CRC at full speed
*/
if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
con_opts |= ENSLOWCRC;
}
/*
* During packetized transfers, the target will
* give us the oportunity to send command packets
* without us asserting attention.
*/
if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) == 0)
con_opts |= ENAUTOATNO;
ahd_outb(ahd, NEGCONOPTS, con_opts);
ahd_outb(ahd, NEGOADDR, saved_negoaddr);
ahd_restore_modes(ahd, saved_modes);
}
/*
* When the transfer settings for a connection change, setup for
* negotiation in pending SCBs to effect the change as quickly as
* possible. We also cancel any negotiations that are scheduled
* for inflight SCBs that have not been started yet.
*/
static void
ahd_update_pending_scbs(struct ahd_softc *ahd)
{
struct scb *pending_scb;
int pending_scb_count;
int paused;
u_int saved_scbptr;
ahd_mode_state saved_modes;
/*
* Traverse the pending SCB list and ensure that all of the
* SCBs there have the proper settings. We can only safely
* clear the negotiation required flag (setting requires the
* execution queue to be modified) and this is only possible
* if we are not already attempting to select out for this
* SCB. For this reason, all callers only call this routine
* if we are changing the negotiation settings for the currently
* active transaction on the bus.
*/
pending_scb_count = 0;
LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
ahd_scb_devinfo(ahd, &devinfo, pending_scb);
tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
devinfo.our_scsiid,
devinfo.target, &tstate);
if ((tstate->auto_negotiate & devinfo.target_mask) == 0
&& (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
pending_scb->hscb->control &= ~MK_MESSAGE;
}
ahd_sync_scb(ahd, pending_scb,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
pending_scb_count++;
}
if (pending_scb_count == 0)
return;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
/*
* Force the sequencer to reinitialize the selection for
* the command at the head of the execution queue if it
* has already been setup. The negotiation changes may
* effect whether we select-out with ATN. It is only
* safe to clear ENSELO when the bus is not free and no
* selection is in progres or completed.
*/
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if ((ahd_inb(ahd, SCSISIGI) & BSYI) != 0
&& (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) == 0)
ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
saved_scbptr = ahd_get_scbptr(ahd);
/* Ensure that the hscbs down on the card match the new information */
LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
u_int scb_tag;
u_int control;
scb_tag = SCB_GET_TAG(pending_scb);
ahd_set_scbptr(ahd, scb_tag);
control = ahd_inb_scbram(ahd, SCB_CONTROL);
control &= ~MK_MESSAGE;
control |= pending_scb->hscb->control & MK_MESSAGE;
ahd_outb(ahd, SCB_CONTROL, control);
}
ahd_set_scbptr(ahd, saved_scbptr);
ahd_restore_modes(ahd, saved_modes);
if (paused == 0)
ahd_unpause(ahd);
}
/**************************** Pathing Information *****************************/
static void
ahd_fetch_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
ahd_mode_state saved_modes;
u_int saved_scsiid;
role_t role;
int our_id;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if (ahd_inb(ahd, SSTAT0) & TARGET)
role = ROLE_TARGET;
else
role = ROLE_INITIATOR;
if (role == ROLE_TARGET
&& (ahd_inb(ahd, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
/* We were selected, so pull our id from TARGIDIN */
our_id = ahd_inb(ahd, TARGIDIN) & OID;
} else if (role == ROLE_TARGET)
our_id = ahd_inb(ahd, TOWNID);
else
our_id = ahd_inb(ahd, IOWNID);
saved_scsiid = ahd_inb(ahd, SAVED_SCSIID);
ahd_compile_devinfo(devinfo,
our_id,
SCSIID_TARGET(ahd, saved_scsiid),
ahd_inb(ahd, SAVED_LUN),
SCSIID_CHANNEL(ahd, saved_scsiid),
role);
ahd_restore_modes(ahd, saved_modes);
}
void
ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
printf("%s:%c:%d:%d: ", ahd_name(ahd), 'A',
devinfo->target, devinfo->lun);
}
static struct ahd_phase_table_entry*
ahd_lookup_phase_entry(int phase)
{
struct ahd_phase_table_entry *entry;
struct ahd_phase_table_entry *last_entry;
/*
* num_phases doesn't include the default entry which
* will be returned if the phase doesn't match.
*/
last_entry = &ahd_phase_table[num_phases];
for (entry = ahd_phase_table; entry < last_entry; entry++) {
if (phase == entry->phase)
break;
}
return (entry);
}
void
ahd_compile_devinfo(struct ahd_devinfo *devinfo, u_int our_id, u_int target,
u_int lun, char channel, role_t role)
{
devinfo->our_scsiid = our_id;
devinfo->target = target;
devinfo->lun = lun;
devinfo->target_offset = target;
devinfo->channel = channel;
devinfo->role = role;
if (channel == 'B')
devinfo->target_offset += 8;
devinfo->target_mask = (0x01 << devinfo->target_offset);
}
static void
ahd_scb_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
role_t role;
int our_id;
our_id = SCSIID_OUR_ID(scb->hscb->scsiid);
role = ROLE_INITIATOR;
if ((scb->hscb->control & TARGET_SCB) != 0)
role = ROLE_TARGET;
ahd_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahd, scb), role);
}
/************************ Message Phase Processing ****************************/
/*
* When an initiator transaction with the MK_MESSAGE flag either reconnects
* or enters the initial message out phase, we are interrupted. Fill our
* outgoing message buffer with the appropriate message and beging handing
* the message phase(s) manually.
*/
static void
ahd_setup_initiator_msgout(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
/*
* To facilitate adding multiple messages together,
* each routine should increment the index and len
* variables instead of setting them explicitly.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
if (ahd_currently_packetized(ahd))
ahd->msg_flags |= MSG_FLAG_PACKETIZED;
if (ahd->send_msg_perror
&& ahd_inb(ahd, MSG_OUT) == HOST_MSG) {
ahd->msgout_buf[ahd->msgout_index++] = ahd->send_msg_perror;
ahd->msgout_len++;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("Setting up for Parity Error delivery\n");
#endif
return;
} else if (scb == NULL) {
printf("%s: WARNING. No pending message for "
"I_T msgin. Issuing NO-OP\n", ahd_name(ahd));
ahd->msgout_buf[ahd->msgout_index++] = MSG_NOOP;
ahd->msgout_len++;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
return;
}
if ((scb->flags & SCB_DEVICE_RESET) == 0
&& (scb->flags & SCB_PACKETIZED) == 0
&& ahd_inb(ahd, MSG_OUT) == MSG_IDENTIFYFLAG) {
u_int identify_msg;
identify_msg = MSG_IDENTIFYFLAG | SCB_GET_LUN(scb);
if ((scb->hscb->control & DISCENB) != 0)
identify_msg |= MSG_IDENTIFY_DISCFLAG;
ahd->msgout_buf[ahd->msgout_index++] = identify_msg;
ahd->msgout_len++;
if ((scb->hscb->control & TAG_ENB) != 0) {
ahd->msgout_buf[ahd->msgout_index++] =
scb->hscb->control & (TAG_ENB|SCB_TAG_TYPE);
ahd->msgout_buf[ahd->msgout_index++] = SCB_GET_TAG(scb);
ahd->msgout_len += 2;
}
}
if (scb->flags & SCB_DEVICE_RESET) {
ahd->msgout_buf[ahd->msgout_index++] = MSG_BUS_DEV_RESET;
ahd->msgout_len++;
ahd_print_path(ahd, scb);
printf("Bus Device Reset Message Sent\n");
/*
* Clear our selection hardware in advance of
* the busfree. We may have an entry in the waiting
* Q for this target, and we don't want to go about
* selecting while we handle the busfree and blow it
* away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else if ((scb->flags & SCB_ABORT) != 0) {
if ((scb->hscb->control & TAG_ENB) != 0) {
ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT_TAG;
} else {
ahd->msgout_buf[ahd->msgout_index++] = MSG_ABORT;
}
ahd->msgout_len++;
ahd_print_path(ahd, scb);
printf("Abort%s Message Sent\n",
(scb->hscb->control & TAG_ENB) != 0 ? " Tag" : "");
/*
* Clear our selection hardware in advance of
* the busfree. We may have an entry in the waiting
* Q for this target, and we don't want to go about
* selecting while we handle the busfree and blow it
* away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else if ((scb->flags & (SCB_AUTO_NEGOTIATE|SCB_NEGOTIATE)) != 0) {
ahd_build_transfer_msg(ahd, devinfo);
/*
* Clear our selection hardware in advance of potential
* PPR IU status change busfree. We may have an entry in
* the waiting Q for this target, and we don't want to go
* about selecting while we handle the busfree and blow
* it away.
*/
ahd_outb(ahd, SCSISEQ0, 0);
} else {
printf("ahd_intr: AWAITING_MSG for an SCB that "
"does not have a waiting message\n");
printf("SCSIID = %x, target_mask = %x\n", scb->hscb->scsiid,
devinfo->target_mask);
panic("SCB = %d, SCB Control = %x:%x, MSG_OUT = %x "
"SCB flags = %x", SCB_GET_TAG(scb), scb->hscb->control,
ahd_inb_scbram(ahd, SCB_CONTROL), ahd_inb(ahd, MSG_OUT),
scb->flags);
}
/*
* Clear the MK_MESSAGE flag from the SCB so we aren't
* asked to send this message again.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & ~MK_MESSAGE);
scb->hscb->control &= ~MK_MESSAGE;
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
}
/*
* Build an appropriate transfer negotiation message for the
* currently active target.
*/
static void
ahd_build_transfer_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
/*
* We need to initiate transfer negotiations.
* If our current and goal settings are identical,
* we want to renegotiate due to a check condition.
*/
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
int dowide;
int dosync;
int doppr;
u_int period;
u_int ppr_options;
u_int offset;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
/*
* Filter our period based on the current connection.
* If we can't perform DT transfers on this segment (not in LVD
* mode for instance), then our decision to issue a PPR message
* may change.
*/
period = tinfo->goal.period;
offset = tinfo->goal.offset;
ppr_options = tinfo->goal.ppr_options;
/* Target initiated PPR is not allowed in the SCSI spec */
if (devinfo->role == ROLE_TARGET)
ppr_options = 0;
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
dowide = tinfo->curr.width != tinfo->goal.width;
dosync = tinfo->curr.offset != offset || tinfo->curr.period != period;
/*
* Only use PPR if we have options that need it, even if the device
* claims to support it. There might be an expander in the way
* that doesn't.
*/
doppr = ppr_options != 0;
if (!dowide && !dosync && !doppr) {
dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
dosync = tinfo->goal.offset != 0;
}
if (!dowide && !dosync && !doppr) {
/*
* Force async with a WDTR message if we have a wide bus,
* or just issue an SDTR with a 0 offset.
*/
if ((ahd->features & AHD_WIDE) != 0)
dowide = 1;
else
dosync = 1;
if (bootverbose) {
ahd_print_devinfo(ahd, devinfo);
printf("Ensuring async\n");
}
}
/* Target initiated PPR is not allowed in the SCSI spec */
if (devinfo->role == ROLE_TARGET)
doppr = 0;
/*
* Both the PPR message and SDTR message require the
* goal syncrate to be limited to what the target device
* is capable of handling (based on whether an LVD->SE
* expander is on the bus), so combine these two cases.
* Regardless, guarantee that if we are using WDTR and SDTR
* messages that WDTR comes first.
*/
if (doppr || (dosync && !dowide)) {
offset = tinfo->goal.offset;
ahd_validate_offset(ahd, tinfo, period, &offset,
doppr ? tinfo->goal.width
: tinfo->curr.width,
devinfo->role);
if (doppr) {
ahd_construct_ppr(ahd, devinfo, period, offset,
tinfo->goal.width, ppr_options);
} else {
ahd_construct_sdtr(ahd, devinfo, period, offset);
}
} else {
ahd_construct_wdtr(ahd, devinfo, tinfo->goal.width);
}
}
/*
* Build a synchronous negotiation message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_sdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset)
{
if (offset == 0)
period = AHD_ASYNC_XFER_PERIOD;
ahd->msgout_index += spi_populate_sync_msg(
ahd->msgout_buf + ahd->msgout_index, period, offset);
ahd->msgout_len += 5;
if (bootverbose) {
printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, period, offset);
}
}
/*
* Build a wide negotiateion message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_wdtr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int bus_width)
{
ahd->msgout_index += spi_populate_width_msg(
ahd->msgout_buf + ahd->msgout_index, bus_width);
ahd->msgout_len += 4;
if (bootverbose) {
printf("(%s:%c:%d:%d): Sending WDTR %x\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, bus_width);
}
}
/*
* Build a parallel protocol request message in our message
* buffer based on the input parameters.
*/
static void
ahd_construct_ppr(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int period, u_int offset, u_int bus_width,
u_int ppr_options)
{
/*
* Always request precompensation from
* the other target if we are running
* at paced syncrates.
*/
if (period <= AHD_SYNCRATE_PACED)
ppr_options |= MSG_EXT_PPR_PCOMP_EN;
if (offset == 0)
period = AHD_ASYNC_XFER_PERIOD;
ahd->msgout_index += spi_populate_ppr_msg(
ahd->msgout_buf + ahd->msgout_index, period, offset,
bus_width, ppr_options);
ahd->msgout_len += 8;
if (bootverbose) {
printf("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
"offset %x, ppr_options %x\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun,
bus_width, period, offset, ppr_options);
}
}
/*
* Clear any active message state.
*/
static void
ahd_clear_msg_state(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd->send_msg_perror = 0;
ahd->msg_flags = MSG_FLAG_NONE;
ahd->msgout_len = 0;
ahd->msgin_index = 0;
ahd->msg_type = MSG_TYPE_NONE;
if ((ahd_inb(ahd, SCSISIGO) & ATNO) != 0) {
/*
* The target didn't care to respond to our
* message request, so clear ATN.
*/
ahd_outb(ahd, CLRSINT1, CLRATNO);
}
ahd_outb(ahd, MSG_OUT, MSG_NOOP);
ahd_outb(ahd, SEQ_FLAGS2,
ahd_inb(ahd, SEQ_FLAGS2) & ~TARGET_MSG_PENDING);
ahd_restore_modes(ahd, saved_modes);
}
/*
* Manual message loop handler.
*/
static void
ahd_handle_message_phase(struct ahd_softc *ahd)
{
struct ahd_devinfo devinfo;
u_int bus_phase;
int end_session;
ahd_fetch_devinfo(ahd, &devinfo);
end_session = FALSE;
bus_phase = ahd_inb(ahd, LASTPHASE);
if ((ahd_inb(ahd, LQISTAT2) & LQIPHASE_OUTPKT) != 0) {
printf("LQIRETRY for LQIPHASE_OUTPKT\n");
ahd_outb(ahd, LQCTL2, LQIRETRY);
}
reswitch:
switch (ahd->msg_type) {
case MSG_TYPE_INITIATOR_MSGOUT:
{
int lastbyte;
int phasemis;
int msgdone;
if (ahd->msgout_len == 0 && ahd->send_msg_perror == 0)
panic("HOST_MSG_LOOP interrupt with no active message");
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printf("INITIATOR_MSG_OUT");
}
#endif
phasemis = bus_phase != P_MESGOUT;
if (phasemis) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
printf(" PHASEMIS %s\n",
ahd_lookup_phase_entry(bus_phase)
->phasemsg);
}
#endif
if (bus_phase == P_MESGIN) {
/*
* Change gears and see if
* this messages is of interest to
* us or should be passed back to
* the sequencer.
*/
ahd_outb(ahd, CLRSINT1, CLRATNO);
ahd->send_msg_perror = 0;
ahd->msg_type = MSG_TYPE_INITIATOR_MSGIN;
ahd->msgin_index = 0;
goto reswitch;
}
end_session = TRUE;
break;
}
if (ahd->send_msg_perror) {
ahd_outb(ahd, CLRSINT1, CLRATNO);
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf(" byte 0x%x\n", ahd->send_msg_perror);
#endif
/*
* If we are notifying the target of a CRC error
* during packetized operations, the target is
* within its rights to acknowledge our message
* with a busfree.
*/
if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0
&& ahd->send_msg_perror == MSG_INITIATOR_DET_ERR)
ahd->msg_flags |= MSG_FLAG_EXPECT_IDE_BUSFREE;
ahd_outb(ahd, RETURN_2, ahd->send_msg_perror);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
break;
}
msgdone = ahd->msgout_index == ahd->msgout_len;
if (msgdone) {
/*
* The target has requested a retry.
* Re-assert ATN, reset our message index to
* 0, and try again.
*/
ahd->msgout_index = 0;
ahd_assert_atn(ahd);
}
lastbyte = ahd->msgout_index == (ahd->msgout_len - 1);
if (lastbyte) {
/* Last byte is signified by dropping ATN */
ahd_outb(ahd, CLRSINT1, CLRATNO);
}
/*
* Clear our interrupt status and present
* the next byte on the bus.
*/
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf(" byte 0x%x\n",
ahd->msgout_buf[ahd->msgout_index]);
#endif
ahd_outb(ahd, RETURN_2, ahd->msgout_buf[ahd->msgout_index++]);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_WRITE);
break;
}
case MSG_TYPE_INITIATOR_MSGIN:
{
int phasemis;
int message_done;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printf("INITIATOR_MSG_IN");
}
#endif
phasemis = bus_phase != P_MESGIN;
if (phasemis) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
printf(" PHASEMIS %s\n",
ahd_lookup_phase_entry(bus_phase)
->phasemsg);
}
#endif
ahd->msgin_index = 0;
if (bus_phase == P_MESGOUT
&& (ahd->send_msg_perror != 0
|| (ahd->msgout_len != 0
&& ahd->msgout_index == 0))) {
ahd->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
goto reswitch;
}
end_session = TRUE;
break;
}
/* Pull the byte in without acking it */
ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIBUS);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf(" byte 0x%x\n",
ahd->msgin_buf[ahd->msgin_index]);
#endif
message_done = ahd_parse_msg(ahd, &devinfo);
if (message_done) {
/*
* Clear our incoming message buffer in case there
* is another message following this one.
*/
ahd->msgin_index = 0;
/*
* If this message illicited a response,
* assert ATN so the target takes us to the
* message out phase.
*/
if (ahd->msgout_len != 0) {
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) {
ahd_print_devinfo(ahd, &devinfo);
printf("Asserting ATN for response\n");
}
#endif
ahd_assert_atn(ahd);
}
} else
ahd->msgin_index++;
if (message_done == MSGLOOP_TERMINATED) {
end_session = TRUE;
} else {
/* Ack the byte */
ahd_outb(ahd, CLRSINT1, CLRREQINIT);
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_READ);
}
break;
}
case MSG_TYPE_TARGET_MSGIN:
{
int msgdone;
int msgout_request;
/*
* By default, the message loop will continue.
*/
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
if (ahd->msgout_len == 0)
panic("Target MSGIN with no active message");
/*
* If we interrupted a mesgout session, the initiator
* will not know this until our first REQ. So, we
* only honor mesgout requests after we've sent our
* first byte.
*/
if ((ahd_inb(ahd, SCSISIGI) & ATNI) != 0
&& ahd->msgout_index > 0)
msgout_request = TRUE;
else
msgout_request = FALSE;
if (msgout_request) {
/*
* Change gears and see if
* this messages is of interest to
* us or should be passed back to
* the sequencer.
*/
ahd->msg_type = MSG_TYPE_TARGET_MSGOUT;
ahd_outb(ahd, SCSISIGO, P_MESGOUT | BSYO);
ahd->msgin_index = 0;
/* Dummy read to REQ for first byte */
ahd_inb(ahd, SCSIDAT);
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
break;
}
msgdone = ahd->msgout_index == ahd->msgout_len;
if (msgdone) {
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
end_session = TRUE;
break;
}
/*
* Present the next byte on the bus.
*/
ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) | SPIOEN);
ahd_outb(ahd, SCSIDAT, ahd->msgout_buf[ahd->msgout_index++]);
break;
}
case MSG_TYPE_TARGET_MSGOUT:
{
int lastbyte;
int msgdone;
/*
* By default, the message loop will continue.
*/
ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
/*
* The initiator signals that this is
* the last byte by dropping ATN.
*/
lastbyte = (ahd_inb(ahd, SCSISIGI) & ATNI) == 0;
/*
* Read the latched byte, but turn off SPIOEN first
* so that we don't inadvertently cause a REQ for the
* next byte.
*/
ahd_outb(ahd, SXFRCTL0, ahd_inb(ahd, SXFRCTL0) & ~SPIOEN);
ahd->msgin_buf[ahd->msgin_index] = ahd_inb(ahd, SCSIDAT);
msgdone = ahd_parse_msg(ahd, &devinfo);
if (msgdone == MSGLOOP_TERMINATED) {
/*
* The message is *really* done in that it caused
* us to go to bus free. The sequencer has already
* been reset at this point, so pull the ejection
* handle.
*/
return;
}
ahd->msgin_index++;
/*
* XXX Read spec about initiator dropping ATN too soon
* and use msgdone to detect it.
*/
if (msgdone == MSGLOOP_MSGCOMPLETE) {
ahd->msgin_index = 0;
/*
* If this message illicited a response, transition
* to the Message in phase and send it.
*/
if (ahd->msgout_len != 0) {
ahd_outb(ahd, SCSISIGO, P_MESGIN | BSYO);
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
ahd->msgin_index = 0;
break;
}
}
if (lastbyte)
end_session = TRUE;
else {
/* Ask for the next byte. */
ahd_outb(ahd, SXFRCTL0,
ahd_inb(ahd, SXFRCTL0) | SPIOEN);
}
break;
}
default:
panic("Unknown REQINIT message type");
}
if (end_session) {
if ((ahd->msg_flags & MSG_FLAG_PACKETIZED) != 0) {
printf("%s: Returning to Idle Loop\n",
ahd_name(ahd));
ahd_clear_msg_state(ahd);
/*
* Perform the equivalent of a clear_target_state.
*/
ahd_outb(ahd, LASTPHASE, P_BUSFREE);
ahd_outb(ahd, SEQ_FLAGS, NOT_IDENTIFIED|NO_CDB_SENT);
ahd_outb(ahd, SEQCTL0, FASTMODE|SEQRESET);
} else {
ahd_clear_msg_state(ahd);
ahd_outb(ahd, RETURN_1, EXIT_MSG_LOOP);
}
}
}
/*
* See if we sent a particular extended message to the target.
* If "full" is true, return true only if the target saw the full
* message. If "full" is false, return true if the target saw at
* least the first byte of the message.
*/
static int
ahd_sent_msg(struct ahd_softc *ahd, ahd_msgtype type, u_int msgval, int full)
{
int found;
u_int index;
found = FALSE;
index = 0;
while (index < ahd->msgout_len) {
if (ahd->msgout_buf[index] == MSG_EXTENDED) {
u_int end_index;
end_index = index + 1 + ahd->msgout_buf[index + 1];
if (ahd->msgout_buf[index+2] == msgval
&& type == AHDMSG_EXT) {
if (full) {
if (ahd->msgout_index > end_index)
found = TRUE;
} else if (ahd->msgout_index > index)
found = TRUE;
}
index = end_index;
} else if (ahd->msgout_buf[index] >= MSG_SIMPLE_TASK
&& ahd->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) {
/* Skip tag type and tag id or residue param*/
index += 2;
} else {
/* Single byte message */
if (type == AHDMSG_1B
&& ahd->msgout_index > index
&& (ahd->msgout_buf[index] == msgval
|| ((ahd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0
&& msgval == MSG_IDENTIFYFLAG)))
found = TRUE;
index++;
}
if (found)
break;
}
return (found);
}
/*
* Wait for a complete incoming message, parse it, and respond accordingly.
*/
static int
ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
int reject;
int done;
int response;
done = MSGLOOP_IN_PROG;
response = FALSE;
reject = FALSE;
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel, devinfo->our_scsiid,
devinfo->target, &tstate);
/*
* Parse as much of the message as is available,
* rejecting it if we don't support it. When
* the entire message is available and has been
* handled, return MSGLOOP_MSGCOMPLETE, indicating
* that we have parsed an entire message.
*
* In the case of extended messages, we accept the length
* byte outright and perform more checking once we know the
* extended message type.
*/
switch (ahd->msgin_buf[0]) {
case MSG_DISCONNECT:
case MSG_SAVEDATAPOINTER:
case MSG_CMDCOMPLETE:
case MSG_RESTOREPOINTERS:
case MSG_IGN_WIDE_RESIDUE:
/*
* End our message loop as these are messages
* the sequencer handles on its own.
*/
done = MSGLOOP_TERMINATED;
break;
case MSG_MESSAGE_REJECT:
response = ahd_handle_msg_reject(ahd, devinfo);
/* FALLTHROUGH */
case MSG_NOOP:
done = MSGLOOP_MSGCOMPLETE;
break;
case MSG_EXTENDED:
{
/* Wait for enough of the message to begin validation */
if (ahd->msgin_index < 2)
break;
switch (ahd->msgin_buf[2]) {
case MSG_EXT_SDTR:
{
u_int period;
u_int ppr_options;
u_int offset;
u_int saved_offset;
if (ahd->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have both args before validating
* and acting on this message.
*
* Add one to MSG_EXT_SDTR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_SDTR_LEN + 1))
break;
period = ahd->msgin_buf[3];
ppr_options = 0;
saved_offset = offset = ahd->msgin_buf[4];
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
ahd_validate_offset(ahd, tinfo, period, &offset,
tinfo->curr.width, devinfo->role);
if (bootverbose) {
printf("(%s:%c:%d:%d): Received "
"SDTR period %x, offset %x\n\t"
"Filtered to period %x, offset %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
ahd->msgin_buf[3], saved_offset,
period, offset);
}
ahd_set_syncrate(ahd, devinfo, period,
offset, ppr_options,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* See if we initiated Sync Negotiation
* and didn't have to fall down to async
* transfers.
*/
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, TRUE)) {
/* We started it */
if (saved_offset != offset) {
/* Went too low - force async */
reject = TRUE;
}
} else {
/*
* Send our own SDTR in reply
*/
if (bootverbose
&& devinfo->role == ROLE_INITIATOR) {
printf("(%s:%c:%d:%d): Target "
"Initiated SDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_sdtr(ahd, devinfo,
period, offset);
ahd->msgout_index = 0;
response = TRUE;
}
done = MSGLOOP_MSGCOMPLETE;
break;
}
case MSG_EXT_WDTR:
{
u_int bus_width;
u_int saved_width;
u_int sending_reply;
sending_reply = FALSE;
if (ahd->msgin_buf[1] != MSG_EXT_WDTR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have our arg before validating
* and acting on this message.
*
* Add one to MSG_EXT_WDTR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_WDTR_LEN + 1))
break;
bus_width = ahd->msgin_buf[3];
saved_width = bus_width;
ahd_validate_width(ahd, tinfo, &bus_width,
devinfo->role);
if (bootverbose) {
printf("(%s:%c:%d:%d): Received WDTR "
"%x filtered to %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
saved_width, bus_width);
}
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, TRUE)) {
/*
* Don't send a WDTR back to the
* target, since we asked first.
* If the width went higher than our
* request, reject it.
*/
if (saved_width > bus_width) {
reject = TRUE;
printf("(%s:%c:%d:%d): requested %dBit "
"transfers. Rejecting...\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
8 * (0x01 << bus_width));
bus_width = 0;
}
} else {
/*
* Send our own WDTR in reply
*/
if (bootverbose
&& devinfo->role == ROLE_INITIATOR) {
printf("(%s:%c:%d:%d): Target "
"Initiated WDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_wdtr(ahd, devinfo, bus_width);
ahd->msgout_index = 0;
response = TRUE;
sending_reply = TRUE;
}
/*
* After a wide message, we are async, but
* some devices don't seem to honor this portion
* of the spec. Force a renegotiation of the
* sync component of our transfer agreement even
* if our goal is async. By updating our width
* after forcing the negotiation, we avoid
* renegotiating for width.
*/
ahd_update_neg_request(ahd, devinfo, tstate,
tinfo, AHD_NEG_ALWAYS);
ahd_set_width(ahd, devinfo, bus_width,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
if (sending_reply == FALSE && reject == FALSE) {
/*
* We will always have an SDTR to send.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = TRUE;
}
done = MSGLOOP_MSGCOMPLETE;
break;
}
case MSG_EXT_PPR:
{
u_int period;
u_int offset;
u_int bus_width;
u_int ppr_options;
u_int saved_width;
u_int saved_offset;
u_int saved_ppr_options;
if (ahd->msgin_buf[1] != MSG_EXT_PPR_LEN) {
reject = TRUE;
break;
}
/*
* Wait until we have all args before validating
* and acting on this message.
*
* Add one to MSG_EXT_PPR_LEN to account for
* the extended message preamble.
*/
if (ahd->msgin_index < (MSG_EXT_PPR_LEN + 1))
break;
period = ahd->msgin_buf[3];
offset = ahd->msgin_buf[5];
bus_width = ahd->msgin_buf[6];
saved_width = bus_width;
ppr_options = ahd->msgin_buf[7];
/*
* According to the spec, a DT only
* period factor with no DT option
* set implies async.
*/
if ((ppr_options & MSG_EXT_PPR_DT_REQ) == 0
&& period <= 9)
offset = 0;
saved_ppr_options = ppr_options;
saved_offset = offset;
/*
* Transfer options are only available if we
* are negotiating wide.
*/
if (bus_width == 0)
ppr_options &= MSG_EXT_PPR_QAS_REQ;
ahd_validate_width(ahd, tinfo, &bus_width,
devinfo->role);
ahd_devlimited_syncrate(ahd, tinfo, &period,
&ppr_options, devinfo->role);
ahd_validate_offset(ahd, tinfo, period, &offset,
bus_width, devinfo->role);
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, TRUE)) {
/*
* If we are unable to do any of the
* requested options (we went too low),
* then we'll have to reject the message.
*/
if (saved_width > bus_width
|| saved_offset != offset
|| saved_ppr_options != ppr_options) {
reject = TRUE;
period = 0;
offset = 0;
bus_width = 0;
ppr_options = 0;
}
} else {
if (devinfo->role != ROLE_TARGET)
printf("(%s:%c:%d:%d): Target "
"Initiated PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
else
printf("(%s:%c:%d:%d): Initiator "
"Initiated PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_construct_ppr(ahd, devinfo, period, offset,
bus_width, ppr_options);
ahd->msgout_index = 0;
response = TRUE;
}
if (bootverbose) {
printf("(%s:%c:%d:%d): Received PPR width %x, "
"period %x, offset %x,options %x\n"
"\tFiltered to width %x, period %x, "
"offset %x, options %x\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun,
saved_width, ahd->msgin_buf[3],
saved_offset, saved_ppr_options,
bus_width, period, offset, ppr_options);
}
ahd_set_width(ahd, devinfo, bus_width,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
ahd_set_syncrate(ahd, devinfo, period,
offset, ppr_options,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
done = MSGLOOP_MSGCOMPLETE;
break;
}
default:
/* Unknown extended message. Reject it. */
reject = TRUE;
break;
}
break;
}
#ifdef AHD_TARGET_MODE
case MSG_BUS_DEV_RESET:
ahd_handle_devreset(ahd, devinfo, CAM_LUN_WILDCARD,
CAM_BDR_SENT,
"Bus Device Reset Received",
/*verbose_level*/0);
ahd_restart(ahd);
done = MSGLOOP_TERMINATED;
break;
case MSG_ABORT_TAG:
case MSG_ABORT:
case MSG_CLEAR_QUEUE:
{
int tag;
/* Target mode messages */
if (devinfo->role != ROLE_TARGET) {
reject = TRUE;
break;
}
tag = SCB_LIST_NULL;
if (ahd->msgin_buf[0] == MSG_ABORT_TAG)
tag = ahd_inb(ahd, INITIATOR_TAG);
ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
devinfo->lun, tag, ROLE_TARGET,
CAM_REQ_ABORTED);
tstate = ahd->enabled_targets[devinfo->our_scsiid];
if (tstate != NULL) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[devinfo->lun];
if (lstate != NULL) {
ahd_queue_lstate_event(ahd, lstate,
devinfo->our_scsiid,
ahd->msgin_buf[0],
/*arg*/tag);
ahd_send_lstate_events(ahd, lstate);
}
}
ahd_restart(ahd);
done = MSGLOOP_TERMINATED;
break;
}
#endif
case MSG_QAS_REQUEST:
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
printf("%s: QAS request. SCSISIGI == 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
#endif
ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
/* FALLTHROUGH */
case MSG_TERM_IO_PROC:
default:
reject = TRUE;
break;
}
if (reject) {
/*
* Setup to reject the message.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 1;
ahd->msgout_buf[0] = MSG_MESSAGE_REJECT;
done = MSGLOOP_MSGCOMPLETE;
response = TRUE;
}
if (done != MSGLOOP_IN_PROG && !response)
/* Clear the outgoing message buffer */
ahd->msgout_len = 0;
return (done);
}
/*
* Process a message reject message.
*/
static int
ahd_handle_msg_reject(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
/*
* What we care about here is if we had an
* outstanding SDTR or WDTR message for this
* target. If we did, this is a signal that
* the target is refusing negotiation.
*/
struct scb *scb;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int scb_index;
u_int last_msg;
int response = 0;
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
tinfo = ahd_fetch_transinfo(ahd, devinfo->channel,
devinfo->our_scsiid,
devinfo->target, &tstate);
/* Might be necessary */
last_msg = ahd_inb(ahd, LAST_MSG);
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/FALSE)) {
if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_PPR, /*full*/TRUE)
&& tinfo->goal.period <= AHD_SYNCRATE_PACED) {
/*
* Target may not like our SPI-4 PPR Options.
* Attempt to negotiate 80MHz which will turn
* off these options.
*/
if (bootverbose) {
printf("(%s:%c:%d:%d): PPR Rejected. "
"Trying simple U160 PPR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
tinfo->goal.period = AHD_SYNCRATE_DT;
tinfo->goal.ppr_options &= MSG_EXT_PPR_IU_REQ
| MSG_EXT_PPR_QAS_REQ
| MSG_EXT_PPR_DT_REQ;
} else {
/*
* Target does not support the PPR message.
* Attempt to negotiate SPI-2 style.
*/
if (bootverbose) {
printf("(%s:%c:%d:%d): PPR Rejected. "
"Trying WDTR/SDTR\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
}
tinfo->goal.ppr_options = 0;
tinfo->curr.transport_version = 2;
tinfo->goal.transport_version = 2;
}
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, /*full*/FALSE)) {
/* note 8bit xfers */
printf("(%s:%c:%d:%d): refuses WIDE negotiation. Using "
"8bit transfers\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun);
ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
/*
* No need to clear the sync rate. If the target
* did not accept the command, our syncrate is
* unaffected. If the target started the negotiation,
* but rejected our response, we already cleared the
* sync rate before sending our WDTR.
*/
if (tinfo->goal.offset != tinfo->curr.offset) {
/* Start the sync negotiation */
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
}
} else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, /*full*/FALSE)) {
/* note asynch xfers and clear flag */
ahd_set_syncrate(ahd, devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_ACTIVE|AHD_TRANS_GOAL,
/*paused*/TRUE);
printf("(%s:%c:%d:%d): refuses synchronous negotiation. "
"Using asynchronous transfers\n",
ahd_name(ahd), devinfo->channel,
devinfo->target, devinfo->lun);
} else if ((scb->hscb->control & MSG_SIMPLE_TASK) != 0) {
int tag_type;
int mask;
tag_type = (scb->hscb->control & MSG_SIMPLE_TASK);
if (tag_type == MSG_SIMPLE_TASK) {
printf("(%s:%c:%d:%d): refuses tagged commands. "
"Performing non-tagged I/O\n", ahd_name(ahd),
devinfo->channel, devinfo->target, devinfo->lun);
ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_NONE);
mask = ~0x23;
} else {
printf("(%s:%c:%d:%d): refuses %s tagged commands. "
"Performing simple queue tagged I/O only\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
devinfo->lun, tag_type == MSG_ORDERED_TASK
? "ordered" : "head of queue");
ahd_set_tags(ahd, scb->io_ctx, devinfo, AHD_QUEUE_BASIC);
mask = ~0x03;
}
/*
* Resend the identify for this CCB as the target
* may believe that the selection is invalid otherwise.
*/
ahd_outb(ahd, SCB_CONTROL,
ahd_inb_scbram(ahd, SCB_CONTROL) & mask);
scb->hscb->control &= mask;
ahd_set_transaction_tag(scb, /*enabled*/FALSE,
/*type*/MSG_SIMPLE_TASK);
ahd_outb(ahd, MSG_OUT, MSG_IDENTIFYFLAG);
ahd_assert_atn(ahd);
ahd_busy_tcl(ahd, BUILD_TCL(scb->hscb->scsiid, devinfo->lun),
SCB_GET_TAG(scb));
/*
* Requeue all tagged commands for this target
* currently in our posession so they can be
* converted to untagged commands.
*/
ahd_search_qinfifo(ahd, SCB_GET_TARGET(ahd, scb),
SCB_GET_CHANNEL(ahd, scb),
SCB_GET_LUN(scb), /*tag*/SCB_LIST_NULL,
ROLE_INITIATOR, CAM_REQUEUE_REQ,
SEARCH_COMPLETE);
} else if (ahd_sent_msg(ahd, AHDMSG_1B, MSG_IDENTIFYFLAG, TRUE)) {
/*
* Most likely the device believes that we had
* previously negotiated packetized.
*/
ahd->msg_flags |= MSG_FLAG_EXPECT_PPR_BUSFREE
| MSG_FLAG_IU_REQ_CHANGED;
ahd_force_renegotiation(ahd, devinfo);
ahd->msgout_index = 0;
ahd->msgout_len = 0;
ahd_build_transfer_msg(ahd, devinfo);
ahd->msgout_index = 0;
response = 1;
} else {
/*
* Otherwise, we ignore it.
*/
printf("%s:%c:%d: Message reject for %x -- ignored\n",
ahd_name(ahd), devinfo->channel, devinfo->target,
last_msg);
}
return (response);
}
/*
* Process an ingnore wide residue message.
*/
static void
ahd_handle_ign_wide_residue(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
{
u_int scb_index;
struct scb *scb;
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
/*
* XXX Actually check data direction in the sequencer?
* Perhaps add datadir to some spare bits in the hscb?
*/
if ((ahd_inb(ahd, SEQ_FLAGS) & DPHASE) == 0
|| ahd_get_transfer_dir(scb) != CAM_DIR_IN) {
/*
* Ignore the message if we haven't
* seen an appropriate data phase yet.
*/
} else {
/*
* If the residual occurred on the last
* transfer and the transfer request was
* expected to end on an odd count, do
* nothing. Otherwise, subtract a byte
* and update the residual count accordingly.
*/
uint32_t sgptr;
sgptr = ahd_inb_scbram(ahd, SCB_RESIDUAL_SGPTR);
if ((sgptr & SG_LIST_NULL) != 0
&& (ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE)
& SCB_XFERLEN_ODD) != 0) {
/*
* If the residual occurred on the last
* transfer and the transfer request was
* expected to end on an odd count, do
* nothing.
*/
} else {
uint32_t data_cnt;
uint64_t data_addr;
uint32_t sglen;
/* Pull in the rest of the sgptr */
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
data_cnt = ahd_inl_scbram(ahd, SCB_RESIDUAL_DATACNT);
if ((sgptr & SG_LIST_NULL) != 0) {
/*
* The residual data count is not updated
* for the command run to completion case.
* Explicitly zero the count.
*/
data_cnt &= ~AHD_SG_LEN_MASK;
}
data_addr = ahd_inq(ahd, SHADDR);
data_cnt += 1;
data_addr -= 1;
sgptr &= SG_PTR_MASK;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/*
* The residual sg ptr points to the next S/G
* to load so we must go back one.
*/
sg--;
sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
if (sg != scb->sg_list
&& sglen < (data_cnt & AHD_SG_LEN_MASK)) {
sg--;
sglen = ahd_le32toh(sg->len);
/*
* Preserve High Address and SG_LIST
* bits while setting the count to 1.
*/
data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
data_addr = ahd_le64toh(sg->addr)
+ (sglen & AHD_SG_LEN_MASK)
- 1;
/*
* Increment sg so it points to the
* "next" sg.
*/
sg++;
sgptr = ahd_sg_virt_to_bus(ahd, scb,
sg);
}
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/*
* The residual sg ptr points to the next S/G
* to load so we must go back one.
*/
sg--;
sglen = ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
if (sg != scb->sg_list
&& sglen < (data_cnt & AHD_SG_LEN_MASK)) {
sg--;
sglen = ahd_le32toh(sg->len);
/*
* Preserve High Address and SG_LIST
* bits while setting the count to 1.
*/
data_cnt = 1|(sglen&(~AHD_SG_LEN_MASK));
data_addr = ahd_le32toh(sg->addr)
+ (sglen & AHD_SG_LEN_MASK)
- 1;
/*
* Increment sg so it points to the
* "next" sg.
*/
sg++;
sgptr = ahd_sg_virt_to_bus(ahd, scb,
sg);
}
}
/*
* Toggle the "oddness" of the transfer length
* to handle this mid-transfer ignore wide
* residue. This ensures that the oddness is
* correct for subsequent data transfers.
*/
ahd_outb(ahd, SCB_TASK_ATTRIBUTE,
ahd_inb_scbram(ahd, SCB_TASK_ATTRIBUTE)
^ SCB_XFERLEN_ODD);
ahd_outl(ahd, SCB_RESIDUAL_SGPTR, sgptr);
ahd_outl(ahd, SCB_RESIDUAL_DATACNT, data_cnt);
/*
* The FIFO's pointers will be updated if/when the
* sequencer re-enters a data phase.
*/
}
}
}
/*
* Reinitialize the data pointers for the active transfer
* based on its current residual.
*/
static void
ahd_reinitialize_dataptrs(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int scb_index;
u_int wait;
uint32_t sgptr;
uint32_t resid;
uint64_t dataptr;
AHD_ASSERT_MODES(ahd, AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK,
AHD_MODE_DFF0_MSK|AHD_MODE_DFF1_MSK);
scb_index = ahd_get_scbptr(ahd);
scb = ahd_lookup_scb(ahd, scb_index);
/*
* Release and reacquire the FIFO so we
* have a clean slate.
*/
ahd_outb(ahd, DFFSXFRCTL, CLRCHN);
wait = 1000;
while (--wait && !(ahd_inb(ahd, MDFFSTAT) & FIFOFREE))
ahd_delay(100);
if (wait == 0) {
ahd_print_path(ahd, scb);
printf("ahd_reinitialize_dataptrs: Forcing FIFO free.\n");
ahd_outb(ahd, DFFSXFRCTL, RSTCHN|CLRSHCNT);
}
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, DFFSTAT,
ahd_inb(ahd, DFFSTAT)
| (saved_modes == 0x11 ? CURRFIFO_1 : CURRFIFO_0));
/*
* Determine initial values for data_addr and data_cnt
* for resuming the data phase.
*/
sgptr = ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR);
sgptr &= SG_PTR_MASK;
resid = (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 2) << 16)
| (ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT + 1) << 8)
| ahd_inb_scbram(ahd, SCB_RESIDUAL_DATACNT);
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0) {
struct ahd_dma64_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/* The residual sg_ptr always points to the next sg */
sg--;
dataptr = ahd_le64toh(sg->addr)
+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
- resid;
ahd_outl(ahd, HADDR + 4, dataptr >> 32);
} else {
struct ahd_dma_seg *sg;
sg = ahd_sg_bus_to_virt(ahd, scb, sgptr);
/* The residual sg_ptr always points to the next sg */
sg--;
dataptr = ahd_le32toh(sg->addr)
+ (ahd_le32toh(sg->len) & AHD_SG_LEN_MASK)
- resid;
ahd_outb(ahd, HADDR + 4,
(ahd_le32toh(sg->len) & ~AHD_SG_LEN_MASK) >> 24);
}
ahd_outl(ahd, HADDR, dataptr);
ahd_outb(ahd, HCNT + 2, resid >> 16);
ahd_outb(ahd, HCNT + 1, resid >> 8);
ahd_outb(ahd, HCNT, resid);
}
/*
* Handle the effects of issuing a bus device reset message.
*/
static void
ahd_handle_devreset(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
u_int lun, cam_status status, char *message,
int verbose_level)
{
#ifdef AHD_TARGET_MODE
struct ahd_tmode_tstate* tstate;
#endif
int found;
found = ahd_abort_scbs(ahd, devinfo->target, devinfo->channel,
lun, SCB_LIST_NULL, devinfo->role,
status);
#ifdef AHD_TARGET_MODE
/*
* Send an immediate notify ccb to all target mord peripheral
* drivers affected by this action.
*/
tstate = ahd->enabled_targets[devinfo->our_scsiid];
if (tstate != NULL) {
u_int cur_lun;
u_int max_lun;
if (lun != CAM_LUN_WILDCARD) {
cur_lun = 0;
max_lun = AHD_NUM_LUNS - 1;
} else {
cur_lun = lun;
max_lun = lun;
}
for (cur_lun <= max_lun; cur_lun++) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[cur_lun];
if (lstate == NULL)
continue;
ahd_queue_lstate_event(ahd, lstate, devinfo->our_scsiid,
MSG_BUS_DEV_RESET, /*arg*/0);
ahd_send_lstate_events(ahd, lstate);
}
}
#endif
/*
* Go back to async/narrow transfers and renegotiate.
*/
ahd_set_width(ahd, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR, /*paused*/TRUE);
ahd_set_syncrate(ahd, devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR,
/*paused*/TRUE);
if (status != CAM_SEL_TIMEOUT)
ahd_send_async(ahd, devinfo->channel, devinfo->target,
CAM_LUN_WILDCARD, AC_SENT_BDR);
if (message != NULL && bootverbose)
printf("%s: %s on %c:%d. %d SCBs aborted\n", ahd_name(ahd),
message, devinfo->channel, devinfo->target, found);
}
#ifdef AHD_TARGET_MODE
static void
ahd_setup_target_msgin(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
struct scb *scb)
{
/*
* To facilitate adding multiple messages together,
* each routine should increment the index and len
* variables instead of setting them explicitly.
*/
ahd->msgout_index = 0;
ahd->msgout_len = 0;
if (scb != NULL && (scb->flags & SCB_AUTO_NEGOTIATE) != 0)
ahd_build_transfer_msg(ahd, devinfo);
else
panic("ahd_intr: AWAITING target message with no message");
ahd->msgout_index = 0;
ahd->msg_type = MSG_TYPE_TARGET_MSGIN;
}
#endif
/**************************** Initialization **********************************/
static u_int
ahd_sglist_size(struct ahd_softc *ahd)
{
bus_size_t list_size;
list_size = sizeof(struct ahd_dma_seg) * AHD_NSEG;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
list_size = sizeof(struct ahd_dma64_seg) * AHD_NSEG;
return (list_size);
}
/*
* Calculate the optimum S/G List allocation size. S/G elements used
* for a given transaction must be physically contiguous. Assume the
* OS will allocate full pages to us, so it doesn't make sense to request
* less than a page.
*/
static u_int
ahd_sglist_allocsize(struct ahd_softc *ahd)
{
bus_size_t sg_list_increment;
bus_size_t sg_list_size;
bus_size_t max_list_size;
bus_size_t best_list_size;
/* Start out with the minimum required for AHD_NSEG. */
sg_list_increment = ahd_sglist_size(ahd);
sg_list_size = sg_list_increment;
/* Get us as close as possible to a page in size. */
while ((sg_list_size + sg_list_increment) <= PAGE_SIZE)
sg_list_size += sg_list_increment;
/*
* Try to reduce the amount of wastage by allocating
* multiple pages.
*/
best_list_size = sg_list_size;
max_list_size = roundup(sg_list_increment, PAGE_SIZE);
if (max_list_size < 4 * PAGE_SIZE)
max_list_size = 4 * PAGE_SIZE;
if (max_list_size > (AHD_SCB_MAX_ALLOC * sg_list_increment))
max_list_size = (AHD_SCB_MAX_ALLOC * sg_list_increment);
while ((sg_list_size + sg_list_increment) <= max_list_size
&& (sg_list_size % PAGE_SIZE) != 0) {
bus_size_t new_mod;
bus_size_t best_mod;
sg_list_size += sg_list_increment;
new_mod = sg_list_size % PAGE_SIZE;
best_mod = best_list_size % PAGE_SIZE;
if (new_mod > best_mod || new_mod == 0) {
best_list_size = sg_list_size;
}
}
return (best_list_size);
}
/*
* Allocate a controller structure for a new device
* and perform initial initializion.
*/
struct ahd_softc *
ahd_alloc(void *platform_arg, char *name)
{
struct ahd_softc *ahd;
#ifndef __FreeBSD__
ahd = malloc(sizeof(*ahd), M_DEVBUF, M_NOWAIT);
if (!ahd) {
printf("aic7xxx: cannot malloc softc!\n");
free(name, M_DEVBUF);
return NULL;
}
#else
ahd = device_get_softc((device_t)platform_arg);
#endif
memset(ahd, 0, sizeof(*ahd));
ahd->seep_config = malloc(sizeof(*ahd->seep_config),
M_DEVBUF, M_NOWAIT);
if (ahd->seep_config == NULL) {
#ifndef __FreeBSD__
free(ahd, M_DEVBUF);
#endif
free(name, M_DEVBUF);
return (NULL);
}
LIST_INIT(&ahd->pending_scbs);
/* We don't know our unit number until the OSM sets it */
ahd->name = name;
ahd->unit = -1;
ahd->description = NULL;
ahd->bus_description = NULL;
ahd->channel = 'A';
ahd->chip = AHD_NONE;
ahd->features = AHD_FENONE;
ahd->bugs = AHD_BUGNONE;
ahd->flags = AHD_SPCHK_ENB_A|AHD_RESET_BUS_A|AHD_TERM_ENB_A
| AHD_EXTENDED_TRANS_A|AHD_STPWLEVEL_A;
ahd_timer_init(&ahd->reset_timer);
ahd_timer_init(&ahd->stat_timer);
ahd->int_coalescing_timer = AHD_INT_COALESCING_TIMER_DEFAULT;
ahd->int_coalescing_maxcmds = AHD_INT_COALESCING_MAXCMDS_DEFAULT;
ahd->int_coalescing_mincmds = AHD_INT_COALESCING_MINCMDS_DEFAULT;
ahd->int_coalescing_threshold = AHD_INT_COALESCING_THRESHOLD_DEFAULT;
ahd->int_coalescing_stop_threshold =
AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
if (ahd_platform_alloc(ahd, platform_arg) != 0) {
ahd_free(ahd);
ahd = NULL;
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
printf("%s: scb size = 0x%x, hscb size = 0x%x\n",
ahd_name(ahd), (u_int)sizeof(struct scb),
(u_int)sizeof(struct hardware_scb));
}
#endif
return (ahd);
}
int
ahd_softc_init(struct ahd_softc *ahd)
{
ahd->unpause = 0;
ahd->pause = PAUSE;
return (0);
}
void
ahd_set_unit(struct ahd_softc *ahd, int unit)
{
ahd->unit = unit;
}
void
ahd_set_name(struct ahd_softc *ahd, char *name)
{
if (ahd->name != NULL)
free(ahd->name, M_DEVBUF);
ahd->name = name;
}
void
ahd_free(struct ahd_softc *ahd)
{
int i;
switch (ahd->init_level) {
default:
case 5:
ahd_shutdown(ahd);
/* FALLTHROUGH */
case 4:
ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap);
/* FALLTHROUGH */
case 3:
ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
ahd->shared_data_map.dmamap);
ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap);
/* FALLTHROUGH */
case 2:
ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
case 1:
#ifndef __linux__
ahd_dma_tag_destroy(ahd, ahd->buffer_dmat);
#endif
break;
case 0:
break;
}
#ifndef __linux__
ahd_dma_tag_destroy(ahd, ahd->parent_dmat);
#endif
ahd_platform_free(ahd);
ahd_fini_scbdata(ahd);
for (i = 0; i < AHD_NUM_TARGETS; i++) {
struct ahd_tmode_tstate *tstate;
tstate = ahd->enabled_targets[i];
if (tstate != NULL) {
#ifdef AHD_TARGET_MODE
int j;
for (j = 0; j < AHD_NUM_LUNS; j++) {
struct ahd_tmode_lstate *lstate;
lstate = tstate->enabled_luns[j];
if (lstate != NULL) {
xpt_free_path(lstate->path);
free(lstate, M_DEVBUF);
}
}
#endif
free(tstate, M_DEVBUF);
}
}
#ifdef AHD_TARGET_MODE
if (ahd->black_hole != NULL) {
xpt_free_path(ahd->black_hole->path);
free(ahd->black_hole, M_DEVBUF);
}
#endif
if (ahd->name != NULL)
free(ahd->name, M_DEVBUF);
if (ahd->seep_config != NULL)
free(ahd->seep_config, M_DEVBUF);
if (ahd->saved_stack != NULL)
free(ahd->saved_stack, M_DEVBUF);
#ifndef __FreeBSD__
free(ahd, M_DEVBUF);
#endif
return;
}
static void
ahd_shutdown(void *arg)
{
struct ahd_softc *ahd;
ahd = (struct ahd_softc *)arg;
/*
* Stop periodic timer callbacks.
*/
ahd_timer_stop(&ahd->reset_timer);
ahd_timer_stop(&ahd->stat_timer);
/* This will reset most registers to 0, but not all */
ahd_reset(ahd, /*reinit*/FALSE);
}
/*
* Reset the controller and record some information about it
* that is only available just after a reset. If "reinit" is
* non-zero, this reset occured after initial configuration
* and the caller requests that the chip be fully reinitialized
* to a runable state. Chip interrupts are *not* enabled after
* a reinitialization. The caller must enable interrupts via
* ahd_intr_enable().
*/
int
ahd_reset(struct ahd_softc *ahd, int reinit)
{
u_int sxfrctl1;
int wait;
uint32_t cmd;
/*
* Preserve the value of the SXFRCTL1 register for all channels.
* It contains settings that affect termination and we don't want
* to disturb the integrity of the bus.
*/
ahd_pause(ahd);
ahd_update_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
sxfrctl1 = ahd_inb(ahd, SXFRCTL1);
cmd = ahd_pci_read_config(ahd->dev_softc, PCIR_COMMAND, /*bytes*/2);
if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
uint32_t mod_cmd;
/*
* A4 Razor #632
* During the assertion of CHIPRST, the chip
* does not disable its parity logic prior to
* the start of the reset. This may cause a
* parity error to be detected and thus a
* spurious SERR or PERR assertion. Disble
* PERR and SERR responses during the CHIPRST.
*/
mod_cmd = cmd & ~(PCIM_CMD_PERRESPEN|PCIM_CMD_SERRESPEN);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
mod_cmd, /*bytes*/2);
}
ahd_outb(ahd, HCNTRL, CHIPRST | ahd->pause);
/*
* Ensure that the reset has finished. We delay 1000us
* prior to reading the register to make sure the chip
* has sufficiently completed its reset to handle register
* accesses.
*/
wait = 1000;
do {
ahd_delay(1000);
} while (--wait && !(ahd_inb(ahd, HCNTRL) & CHIPRSTACK));
if (wait == 0) {
printf("%s: WARNING - Failed chip reset! "
"Trying to initialize anyway.\n", ahd_name(ahd));
}
ahd_outb(ahd, HCNTRL, ahd->pause);
if ((ahd->bugs & AHD_PCIX_CHIPRST_BUG) != 0) {
/*
* Clear any latched PCI error status and restore
* previous SERR and PERR response enables.
*/
ahd_pci_write_config(ahd->dev_softc, PCIR_STATUS + 1,
0xFF, /*bytes*/1);
ahd_pci_write_config(ahd->dev_softc, PCIR_COMMAND,
cmd, /*bytes*/2);
}
/*
* Mode should be SCSI after a chip reset, but lets
* set it just to be safe. We touch the MODE_PTR
* register directly so as to bypass the lazy update
* code in ahd_set_modes().
*/
ahd_known_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, MODE_PTR,
ahd_build_mode_state(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI));
/*
* Restore SXFRCTL1.
*
* We must always initialize STPWEN to 1 before we
* restore the saved values. STPWEN is initialized
* to a tri-state condition which can only be cleared
* by turning it on.
*/
ahd_outb(ahd, SXFRCTL1, sxfrctl1|STPWEN);
ahd_outb(ahd, SXFRCTL1, sxfrctl1);
/* Determine chip configuration */
ahd->features &= ~AHD_WIDE;
if ((ahd_inb(ahd, SBLKCTL) & SELWIDE) != 0)
ahd->features |= AHD_WIDE;
/*
* If a recovery action has forced a chip reset,
* re-initialize the chip to our liking.
*/
if (reinit != 0)
ahd_chip_init(ahd);
return (0);
}
/*
* Determine the number of SCBs available on the controller
*/
static int
ahd_probe_scbs(struct ahd_softc *ahd) {
int i;
AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK));
for (i = 0; i < AHD_SCB_MAX; i++) {
int j;
ahd_set_scbptr(ahd, i);
ahd_outw(ahd, SCB_BASE, i);
for (j = 2; j < 64; j++)
ahd_outb(ahd, SCB_BASE+j, 0);
/* Start out life as unallocated (needing an abort) */
ahd_outb(ahd, SCB_CONTROL, MK_MESSAGE);
if (ahd_inw_scbram(ahd, SCB_BASE) != i)
break;
ahd_set_scbptr(ahd, 0);
if (ahd_inw_scbram(ahd, SCB_BASE) != 0)
break;
}
return (i);
}
static void
ahd_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
dma_addr_t *baddr;
baddr = (dma_addr_t *)arg;
*baddr = segs->ds_addr;
}
static void
ahd_initialize_hscbs(struct ahd_softc *ahd)
{
int i;
for (i = 0; i < ahd->scb_data.maxhscbs; i++) {
ahd_set_scbptr(ahd, i);
/* Clear the control byte. */
ahd_outb(ahd, SCB_CONTROL, 0);
/* Set the next pointer */
ahd_outw(ahd, SCB_NEXT, SCB_LIST_NULL);
}
}
static int
ahd_init_scbdata(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
int i;
scb_data = &ahd->scb_data;
TAILQ_INIT(&scb_data->free_scbs);
for (i = 0; i < AHD_NUM_TARGETS * AHD_NUM_LUNS_NONPKT; i++)
LIST_INIT(&scb_data->free_scb_lists[i]);
LIST_INIT(&scb_data->any_dev_free_scb_list);
SLIST_INIT(&scb_data->hscb_maps);
SLIST_INIT(&scb_data->sg_maps);
SLIST_INIT(&scb_data->sense_maps);
/* Determine the number of hardware SCBs and initialize them */
scb_data->maxhscbs = ahd_probe_scbs(ahd);
if (scb_data->maxhscbs == 0) {
printf("%s: No SCB space found\n", ahd_name(ahd));
return (ENXIO);
}
ahd_initialize_hscbs(ahd);
/*
* Create our DMA tags. These tags define the kinds of device
* accessible memory allocations and memory mappings we will
* need to perform during normal operation.
*
* Unless we need to further restrict the allocation, we rely
* on the restrictions of the parent dmat, hence the common
* use of MAXADDR and MAXSIZE.
*/
/* DMA tag for our hardware scb structures */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
PAGE_SIZE, /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->hscb_dmat) != 0) {
goto error_exit;
}
scb_data->init_level++;
/* DMA tag for our S/G structures. */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/8,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
ahd_sglist_allocsize(ahd), /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->sg_dmat) != 0) {
goto error_exit;
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MEMORY) != 0)
printf("%s: ahd_sglist_allocsize = 0x%x\n", ahd_name(ahd),
ahd_sglist_allocsize(ahd));
#endif
scb_data->init_level++;
/* DMA tag for our sense buffers. We allocate in page sized chunks */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
PAGE_SIZE, /*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &scb_data->sense_dmat) != 0) {
goto error_exit;
}
scb_data->init_level++;
/* Perform initial CCB allocation */
ahd_alloc_scbs(ahd);
if (scb_data->numscbs == 0) {
printf("%s: ahd_init_scbdata - "
"Unable to allocate initial scbs\n",
ahd_name(ahd));
goto error_exit;
}
/*
* Note that we were successfull
*/
return (0);
error_exit:
return (ENOMEM);
}
static struct scb *
ahd_find_scb_by_tag(struct ahd_softc *ahd, u_int tag)
{
struct scb *scb;
/*
* Look on the pending list.
*/
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
if (SCB_GET_TAG(scb) == tag)
return (scb);
}
/*
* Then on all of the collision free lists.
*/
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
struct scb *list_scb;
list_scb = scb;
do {
if (SCB_GET_TAG(list_scb) == tag)
return (list_scb);
list_scb = LIST_NEXT(list_scb, collision_links);
} while (list_scb);
}
/*
* And finally on the generic free list.
*/
LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
if (SCB_GET_TAG(scb) == tag)
return (scb);
}
return (NULL);
}
static void
ahd_fini_scbdata(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
scb_data = &ahd->scb_data;
if (scb_data == NULL)
return;
switch (scb_data->init_level) {
default:
case 7:
{
struct map_node *sns_map;
while ((sns_map = SLIST_FIRST(&scb_data->sense_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->sense_maps, links);
ahd_dmamap_unload(ahd, scb_data->sense_dmat,
sns_map->dmamap);
ahd_dmamem_free(ahd, scb_data->sense_dmat,
sns_map->vaddr, sns_map->dmamap);
free(sns_map, M_DEVBUF);
}
ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
/* FALLTHROUGH */
}
case 6:
{
struct map_node *sg_map;
while ((sg_map = SLIST_FIRST(&scb_data->sg_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->sg_maps, links);
ahd_dmamap_unload(ahd, scb_data->sg_dmat,
sg_map->dmamap);
ahd_dmamem_free(ahd, scb_data->sg_dmat,
sg_map->vaddr, sg_map->dmamap);
free(sg_map, M_DEVBUF);
}
ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
/* FALLTHROUGH */
}
case 5:
{
struct map_node *hscb_map;
while ((hscb_map = SLIST_FIRST(&scb_data->hscb_maps)) != NULL) {
SLIST_REMOVE_HEAD(&scb_data->hscb_maps, links);
ahd_dmamap_unload(ahd, scb_data->hscb_dmat,
hscb_map->dmamap);
ahd_dmamem_free(ahd, scb_data->hscb_dmat,
hscb_map->vaddr, hscb_map->dmamap);
free(hscb_map, M_DEVBUF);
}
ahd_dma_tag_destroy(ahd, scb_data->hscb_dmat);
/* FALLTHROUGH */
}
case 4:
case 3:
case 2:
case 1:
case 0:
break;
}
}
/*
* DSP filter Bypass must be enabled until the first selection
* after a change in bus mode (Razor #491 and #493).
*/
static void
ahd_setup_iocell_workaround(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, DSPDATACTL, ahd_inb(ahd, DSPDATACTL)
| BYPASSENAB | RCVROFFSTDIS | XMITOFFSTDIS);
ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) | (ENSELDO|ENSELDI));
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: Setting up iocell workaround\n", ahd_name(ahd));
#endif
ahd_restore_modes(ahd, saved_modes);
ahd->flags &= ~AHD_HAD_FIRST_SEL;
}
static void
ahd_iocell_first_selection(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
u_int sblkctl;
if ((ahd->flags & AHD_HAD_FIRST_SEL) != 0)
return;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
sblkctl = ahd_inb(ahd, SBLKCTL);
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: iocell first selection\n", ahd_name(ahd));
#endif
if ((sblkctl & ENAB40) != 0) {
ahd_outb(ahd, DSPDATACTL,
ahd_inb(ahd, DSPDATACTL) & ~BYPASSENAB);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: BYPASS now disabled\n", ahd_name(ahd));
#endif
}
ahd_outb(ahd, SIMODE0, ahd_inb(ahd, SIMODE0) & ~(ENSELDO|ENSELDI));
ahd_outb(ahd, CLRINT, CLRSCSIINT);
ahd_restore_modes(ahd, saved_modes);
ahd->flags |= AHD_HAD_FIRST_SEL;
}
/*************************** SCB Management ***********************************/
static void
ahd_add_col_list(struct ahd_softc *ahd, struct scb *scb, u_int col_idx)
{
struct scb_list *free_list;
struct scb_tailq *free_tailq;
struct scb *first_scb;
scb->flags |= SCB_ON_COL_LIST;
AHD_SET_SCB_COL_IDX(scb, col_idx);
free_list = &ahd->scb_data.free_scb_lists[col_idx];
free_tailq = &ahd->scb_data.free_scbs;
first_scb = LIST_FIRST(free_list);
if (first_scb != NULL) {
LIST_INSERT_AFTER(first_scb, scb, collision_links);
} else {
LIST_INSERT_HEAD(free_list, scb, collision_links);
TAILQ_INSERT_TAIL(free_tailq, scb, links.tqe);
}
}
static void
ahd_rem_col_list(struct ahd_softc *ahd, struct scb *scb)
{
struct scb_list *free_list;
struct scb_tailq *free_tailq;
struct scb *first_scb;
u_int col_idx;
scb->flags &= ~SCB_ON_COL_LIST;
col_idx = AHD_GET_SCB_COL_IDX(ahd, scb);
free_list = &ahd->scb_data.free_scb_lists[col_idx];
free_tailq = &ahd->scb_data.free_scbs;
first_scb = LIST_FIRST(free_list);
if (first_scb == scb) {
struct scb *next_scb;
/*
* Maintain order in the collision free
* lists for fairness if this device has
* other colliding tags active.
*/
next_scb = LIST_NEXT(scb, collision_links);
if (next_scb != NULL) {
TAILQ_INSERT_AFTER(free_tailq, scb,
next_scb, links.tqe);
}
TAILQ_REMOVE(free_tailq, scb, links.tqe);
}
LIST_REMOVE(scb, collision_links);
}
/*
* Get a free scb. If there are none, see if we can allocate a new SCB.
*/
struct scb *
ahd_get_scb(struct ahd_softc *ahd, u_int col_idx)
{
struct scb *scb;
int tries;
tries = 0;
look_again:
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
if (AHD_GET_SCB_COL_IDX(ahd, scb) != col_idx) {
ahd_rem_col_list(ahd, scb);
goto found;
}
}
if ((scb = LIST_FIRST(&ahd->scb_data.any_dev_free_scb_list)) == NULL) {
if (tries++ != 0)
return (NULL);
ahd_alloc_scbs(ahd);
goto look_again;
}
LIST_REMOVE(scb, links.le);
if (col_idx != AHD_NEVER_COL_IDX
&& (scb->col_scb != NULL)
&& (scb->col_scb->flags & SCB_ACTIVE) == 0) {
LIST_REMOVE(scb->col_scb, links.le);
ahd_add_col_list(ahd, scb->col_scb, col_idx);
}
found:
scb->flags |= SCB_ACTIVE;
return (scb);
}
/*
* Return an SCB resource to the free list.
*/
void
ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
{
/* Clean up for the next user */
scb->flags = SCB_FLAG_NONE;
scb->hscb->control = 0;
ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = NULL;
if (scb->col_scb == NULL) {
/*
* No collision possible. Just free normally.
*/
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
} else if ((scb->col_scb->flags & SCB_ON_COL_LIST) != 0) {
/*
* The SCB we might have collided with is on
* a free collision list. Put both SCBs on
* the generic list.
*/
ahd_rem_col_list(ahd, scb->col_scb);
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb->col_scb, links.le);
} else if ((scb->col_scb->flags
& (SCB_PACKETIZED|SCB_ACTIVE)) == SCB_ACTIVE
&& (scb->col_scb->hscb->control & TAG_ENB) != 0) {
/*
* The SCB we might collide with on the next allocation
* is still active in a non-packetized, tagged, context.
* Put us on the SCB collision list.
*/
ahd_add_col_list(ahd, scb,
AHD_GET_SCB_COL_IDX(ahd, scb->col_scb));
} else {
/*
* The SCB we might collide with on the next allocation
* is either active in a packetized context, or free.
* Since we can't collide, put this SCB on the generic
* free list.
*/
LIST_INSERT_HEAD(&ahd->scb_data.any_dev_free_scb_list,
scb, links.le);
}
ahd_platform_scb_free(ahd, scb);
}
static void
ahd_alloc_scbs(struct ahd_softc *ahd)
{
struct scb_data *scb_data;
struct scb *next_scb;
struct hardware_scb *hscb;
struct map_node *hscb_map;
struct map_node *sg_map;
struct map_node *sense_map;
uint8_t *segs;
uint8_t *sense_data;
dma_addr_t hscb_busaddr;
dma_addr_t sg_busaddr;
dma_addr_t sense_busaddr;
int newcount;
int i;
scb_data = &ahd->scb_data;
if (scb_data->numscbs >= AHD_SCB_MAX_ALLOC)
/* Can't allocate any more */
return;
if (scb_data->scbs_left != 0) {
int offset;
offset = (PAGE_SIZE / sizeof(*hscb)) - scb_data->scbs_left;
hscb_map = SLIST_FIRST(&scb_data->hscb_maps);
hscb = &((struct hardware_scb *)hscb_map->vaddr)[offset];
hscb_busaddr = hscb_map->physaddr + (offset * sizeof(*hscb));
} else {
hscb_map = malloc(sizeof(*hscb_map), M_DEVBUF, M_NOWAIT);
if (hscb_map == NULL)
return;
/* Allocate the next batch of hardware SCBs */
if (ahd_dmamem_alloc(ahd, scb_data->hscb_dmat,
(void **)&hscb_map->vaddr,
BUS_DMA_NOWAIT, &hscb_map->dmamap) != 0) {
free(hscb_map, M_DEVBUF);
return;
}
SLIST_INSERT_HEAD(&scb_data->hscb_maps, hscb_map, links);
ahd_dmamap_load(ahd, scb_data->hscb_dmat, hscb_map->dmamap,
hscb_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
&hscb_map->physaddr, /*flags*/0);
hscb = (struct hardware_scb *)hscb_map->vaddr;
hscb_busaddr = hscb_map->physaddr;
scb_data->scbs_left = PAGE_SIZE / sizeof(*hscb);
}
if (scb_data->sgs_left != 0) {
int offset;
offset = ((ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd))
- scb_data->sgs_left) * ahd_sglist_size(ahd);
sg_map = SLIST_FIRST(&scb_data->sg_maps);
segs = sg_map->vaddr + offset;
sg_busaddr = sg_map->physaddr + offset;
} else {
sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
if (sg_map == NULL)
return;
/* Allocate the next batch of S/G lists */
if (ahd_dmamem_alloc(ahd, scb_data->sg_dmat,
(void **)&sg_map->vaddr,
BUS_DMA_NOWAIT, &sg_map->dmamap) != 0) {
free(sg_map, M_DEVBUF);
return;
}
SLIST_INSERT_HEAD(&scb_data->sg_maps, sg_map, links);
ahd_dmamap_load(ahd, scb_data->sg_dmat, sg_map->dmamap,
sg_map->vaddr, ahd_sglist_allocsize(ahd),
ahd_dmamap_cb, &sg_map->physaddr, /*flags*/0);
segs = sg_map->vaddr;
sg_busaddr = sg_map->physaddr;
scb_data->sgs_left =
ahd_sglist_allocsize(ahd) / ahd_sglist_size(ahd);
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_MEMORY)
printf("Mapped SG data\n");
#endif
}
if (scb_data->sense_left != 0) {
int offset;
offset = PAGE_SIZE - (AHD_SENSE_BUFSIZE * scb_data->sense_left);
sense_map = SLIST_FIRST(&scb_data->sense_maps);
sense_data = sense_map->vaddr + offset;
sense_busaddr = sense_map->physaddr + offset;
} else {
sense_map = malloc(sizeof(*sense_map), M_DEVBUF, M_NOWAIT);
if (sense_map == NULL)
return;
/* Allocate the next batch of sense buffers */
if (ahd_dmamem_alloc(ahd, scb_data->sense_dmat,
(void **)&sense_map->vaddr,
BUS_DMA_NOWAIT, &sense_map->dmamap) != 0) {
free(sense_map, M_DEVBUF);
return;
}
SLIST_INSERT_HEAD(&scb_data->sense_maps, sense_map, links);
ahd_dmamap_load(ahd, scb_data->sense_dmat, sense_map->dmamap,
sense_map->vaddr, PAGE_SIZE, ahd_dmamap_cb,
&sense_map->physaddr, /*flags*/0);
sense_data = sense_map->vaddr;
sense_busaddr = sense_map->physaddr;
scb_data->sense_left = PAGE_SIZE / AHD_SENSE_BUFSIZE;
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_MEMORY)
printf("Mapped sense data\n");
#endif
}
newcount = min(scb_data->sense_left, scb_data->scbs_left);
newcount = min(newcount, scb_data->sgs_left);
newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
for (i = 0; i < newcount; i++) {
struct scb_platform_data *pdata;
u_int col_tag;
#ifndef __linux__
int error;
#endif
next_scb = (struct scb *)malloc(sizeof(*next_scb),
M_DEVBUF, M_NOWAIT);
if (next_scb == NULL)
break;
pdata = (struct scb_platform_data *)malloc(sizeof(*pdata),
M_DEVBUF, M_NOWAIT);
if (pdata == NULL) {
free(next_scb, M_DEVBUF);
break;
}
next_scb->platform_data = pdata;
next_scb->hscb_map = hscb_map;
next_scb->sg_map = sg_map;
next_scb->sense_map = sense_map;
next_scb->sg_list = segs;
next_scb->sense_data = sense_data;
next_scb->sense_busaddr = sense_busaddr;
memset(hscb, 0, sizeof(*hscb));
next_scb->hscb = hscb;
hscb->hscb_busaddr = ahd_htole32(hscb_busaddr);
/*
* The sequencer always starts with the second entry.
* The first entry is embedded in the scb.
*/
next_scb->sg_list_busaddr = sg_busaddr;
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
next_scb->sg_list_busaddr
+= sizeof(struct ahd_dma64_seg);
else
next_scb->sg_list_busaddr += sizeof(struct ahd_dma_seg);
next_scb->ahd_softc = ahd;
next_scb->flags = SCB_FLAG_NONE;
#ifndef __linux__
error = ahd_dmamap_create(ahd, ahd->buffer_dmat, /*flags*/0,
&next_scb->dmamap);
if (error != 0) {
free(next_scb, M_DEVBUF);
free(pdata, M_DEVBUF);
break;
}
#endif
next_scb->hscb->tag = ahd_htole16(scb_data->numscbs);
col_tag = scb_data->numscbs ^ 0x100;
next_scb->col_scb = ahd_find_scb_by_tag(ahd, col_tag);
if (next_scb->col_scb != NULL)
next_scb->col_scb->col_scb = next_scb;
ahd_free_scb(ahd, next_scb);
hscb++;
hscb_busaddr += sizeof(*hscb);
segs += ahd_sglist_size(ahd);
sg_busaddr += ahd_sglist_size(ahd);
sense_data += AHD_SENSE_BUFSIZE;
sense_busaddr += AHD_SENSE_BUFSIZE;
scb_data->numscbs++;
scb_data->sense_left--;
scb_data->scbs_left--;
scb_data->sgs_left--;
}
}
void
ahd_controller_info(struct ahd_softc *ahd, char *buf)
{
const char *speed;
const char *type;
int len;
len = sprintf(buf, "%s: ", ahd_chip_names[ahd->chip & AHD_CHIPID_MASK]);
buf += len;
speed = "Ultra320 ";
if ((ahd->features & AHD_WIDE) != 0) {
type = "Wide ";
} else {
type = "Single ";
}
len = sprintf(buf, "%s%sChannel %c, SCSI Id=%d, ",
speed, type, ahd->channel, ahd->our_id);
buf += len;
sprintf(buf, "%s, %d SCBs", ahd->bus_description,
ahd->scb_data.maxhscbs);
}
static const char *channel_strings[] = {
"Primary Low",
"Primary High",
"Secondary Low",
"Secondary High"
};
static const char *termstat_strings[] = {
"Terminated Correctly",
"Over Terminated",
"Under Terminated",
"Not Configured"
};
/*
* Start the board, ready for normal operation
*/
int
ahd_init(struct ahd_softc *ahd)
{
uint8_t *next_vaddr;
dma_addr_t next_baddr;
size_t driver_data_size;
int i;
int error;
u_int warn_user;
uint8_t current_sensing;
uint8_t fstat;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd->stack_size = ahd_probe_stack_size(ahd);
ahd->saved_stack = malloc(ahd->stack_size * sizeof(uint16_t),
M_DEVBUF, M_NOWAIT);
if (ahd->saved_stack == NULL)
return (ENOMEM);
/*
* Verify that the compiler hasn't over-agressively
* padded important structures.
*/
if (sizeof(struct hardware_scb) != 64)
panic("Hardware SCB size is incorrect");
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_DEBUG_SEQUENCER) != 0)
ahd->flags |= AHD_SEQUENCER_DEBUG;
#endif
/*
* Default to allowing initiator operations.
*/
ahd->flags |= AHD_INITIATORROLE;
/*
* Only allow target mode features if this unit has them enabled.
*/
if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
ahd->features &= ~AHD_TARGETMODE;
#ifndef __linux__
/* DMA tag for mapping buffers into device visible space. */
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/ahd->flags & AHD_39BIT_ADDRESSING
? (dma_addr_t)0x7FFFFFFFFFULL
: BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/(AHD_NSEG - 1) * PAGE_SIZE,
/*nsegments*/AHD_NSEG,
/*maxsegsz*/AHD_MAXTRANSFER_SIZE,
/*flags*/BUS_DMA_ALLOCNOW,
&ahd->buffer_dmat) != 0) {
return (ENOMEM);
}
#endif
ahd->init_level++;
/*
* DMA tag for our command fifos and other data in system memory
* the card's sequencer must be able to access. For initiator
* roles, we need to allocate space for the qoutfifo. When providing
* for the target mode role, we must additionally provide space for
* the incoming target command fifo.
*/
driver_data_size = AHD_SCB_MAX * sizeof(*ahd->qoutfifo)
+ sizeof(struct hardware_scb);
if ((ahd->features & AHD_TARGETMODE) != 0)
driver_data_size += AHD_TMODE_CMDS * sizeof(struct target_cmd);
if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0)
driver_data_size += PKT_OVERRUN_BUFSIZE;
if (ahd_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
/*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
driver_data_size,
/*nsegments*/1,
/*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,
/*flags*/0, &ahd->shared_data_dmat) != 0) {
return (ENOMEM);
}
ahd->init_level++;
/* Allocation of driver data */
if (ahd_dmamem_alloc(ahd, ahd->shared_data_dmat,
(void **)&ahd->shared_data_map.vaddr,
BUS_DMA_NOWAIT,
&ahd->shared_data_map.dmamap) != 0) {
return (ENOMEM);
}
ahd->init_level++;
/* And permanently map it in */
ahd_dmamap_load(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
ahd->shared_data_map.vaddr, driver_data_size,
ahd_dmamap_cb, &ahd->shared_data_map.physaddr,
/*flags*/0);
ahd->qoutfifo = (struct ahd_completion *)ahd->shared_data_map.vaddr;
next_vaddr = (uint8_t *)&ahd->qoutfifo[AHD_QOUT_SIZE];
next_baddr = ahd->shared_data_map.physaddr
+ AHD_QOUT_SIZE*sizeof(struct ahd_completion);
if ((ahd->features & AHD_TARGETMODE) != 0) {
ahd->targetcmds = (struct target_cmd *)next_vaddr;
next_vaddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
next_baddr += AHD_TMODE_CMDS * sizeof(struct target_cmd);
}
if ((ahd->bugs & AHD_PKT_BITBUCKET_BUG) != 0) {
ahd->overrun_buf = next_vaddr;
next_vaddr += PKT_OVERRUN_BUFSIZE;
next_baddr += PKT_OVERRUN_BUFSIZE;
}
/*
* We need one SCB to serve as the "next SCB". Since the
* tag identifier in this SCB will never be used, there is
* no point in using a valid HSCB tag from an SCB pulled from
* the standard free pool. So, we allocate this "sentinel"
* specially from the DMA safe memory chunk used for the QOUTFIFO.
*/
ahd->next_queued_hscb = (struct hardware_scb *)next_vaddr;
ahd->next_queued_hscb_map = &ahd->shared_data_map;
ahd->next_queued_hscb->hscb_busaddr = ahd_htole32(next_baddr);
ahd->init_level++;
/* Allocate SCB data now that buffer_dmat is initialized */
if (ahd_init_scbdata(ahd) != 0)
return (ENOMEM);
if ((ahd->flags & AHD_INITIATORROLE) == 0)
ahd->flags &= ~AHD_RESET_BUS_A;
/*
* Before committing these settings to the chip, give
* the OSM one last chance to modify our configuration.
*/
ahd_platform_init(ahd);
/* Bring up the chip. */
ahd_chip_init(ahd);
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if ((ahd->flags & AHD_CURRENT_SENSING) == 0)
goto init_done;
/*
* Verify termination based on current draw and
* warn user if the bus is over/under terminated.
*/
error = ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL,
CURSENSE_ENB);
if (error != 0) {
printf("%s: current sensing timeout 1\n", ahd_name(ahd));
goto init_done;
}
for (i = 20, fstat = FLX_FSTAT_BUSY;
(fstat & FLX_FSTAT_BUSY) != 0 && i; i--) {
error = ahd_read_flexport(ahd, FLXADDR_FLEXSTAT, &fstat);
if (error != 0) {
printf("%s: current sensing timeout 2\n",
ahd_name(ahd));
goto init_done;
}
}
if (i == 0) {
printf("%s: Timedout during current-sensing test\n",
ahd_name(ahd));
goto init_done;
}
/* Latch Current Sensing status. */
error = ahd_read_flexport(ahd, FLXADDR_CURRENT_STAT, ¤t_sensing);
if (error != 0) {
printf("%s: current sensing timeout 3\n", ahd_name(ahd));
goto init_done;
}
/* Diable current sensing. */
ahd_write_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, 0);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TERMCTL) != 0) {
printf("%s: current_sensing == 0x%x\n",
ahd_name(ahd), current_sensing);
}
#endif
warn_user = 0;
for (i = 0; i < 4; i++, current_sensing >>= FLX_CSTAT_SHIFT) {
u_int term_stat;
term_stat = (current_sensing & FLX_CSTAT_MASK);
switch (term_stat) {
case FLX_CSTAT_OVER:
case FLX_CSTAT_UNDER:
warn_user++;
case FLX_CSTAT_INVALID:
case FLX_CSTAT_OKAY:
if (warn_user == 0 && bootverbose == 0)
break;
printf("%s: %s Channel %s\n", ahd_name(ahd),
channel_strings[i], termstat_strings[term_stat]);
break;
}
}
if (warn_user) {
printf("%s: WARNING. Termination is not configured correctly.\n"
"%s: WARNING. SCSI bus operations may FAIL.\n",
ahd_name(ahd), ahd_name(ahd));
}
init_done:
ahd_restart(ahd);
ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
ahd_stat_timer, ahd);
return (0);
}
/*
* (Re)initialize chip state after a chip reset.
*/
static void
ahd_chip_init(struct ahd_softc *ahd)
{
uint32_t busaddr;
u_int sxfrctl1;
u_int scsiseq_template;
u_int wait;
u_int i;
u_int target;
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/*
* Take the LED out of diagnostic mode
*/
ahd_outb(ahd, SBLKCTL, ahd_inb(ahd, SBLKCTL) & ~(DIAGLEDEN|DIAGLEDON));
/*
* Return HS_MAILBOX to its default value.
*/
ahd->hs_mailbox = 0;
ahd_outb(ahd, HS_MAILBOX, 0);
/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1. */
ahd_outb(ahd, IOWNID, ahd->our_id);
ahd_outb(ahd, TOWNID, ahd->our_id);
sxfrctl1 = (ahd->flags & AHD_TERM_ENB_A) != 0 ? STPWEN : 0;
sxfrctl1 |= (ahd->flags & AHD_SPCHK_ENB_A) != 0 ? ENSPCHK : 0;
if ((ahd->bugs & AHD_LONG_SETIMO_BUG)
&& (ahd->seltime != STIMESEL_MIN)) {
/*
* The selection timer duration is twice as long
* as it should be. Halve it by adding "1" to
* the user specified setting.
*/
sxfrctl1 |= ahd->seltime + STIMESEL_BUG_ADJ;
} else {
sxfrctl1 |= ahd->seltime;
}
ahd_outb(ahd, SXFRCTL0, DFON);
ahd_outb(ahd, SXFRCTL1, sxfrctl1|ahd->seltime|ENSTIMER|ACTNEGEN);
ahd_outb(ahd, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
/*
* Now that termination is set, wait for up
* to 500ms for our transceivers to settle. If
* the adapter does not have a cable attached,
* the transceivers may never settle, so don't
* complain if we fail here.
*/
for (wait = 10000;
(ahd_inb(ahd, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait;
wait--)
ahd_delay(100);
/* Clear any false bus resets due to the transceivers settling */
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
/* Initialize mode specific S/G state. */
for (i = 0; i < 2; i++) {
ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
ahd_outb(ahd, LONGJMP_ADDR + 1, INVALID_ADDR);
ahd_outb(ahd, SG_STATE, 0);
ahd_outb(ahd, CLRSEQINTSRC, 0xFF);
ahd_outb(ahd, SEQIMODE,
ENSAVEPTRS|ENCFG4DATA|ENCFG4ISTAT
|ENCFG4TSTAT|ENCFG4ICMD|ENCFG4TCMD);
}
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
ahd_outb(ahd, DSCOMMAND0, ahd_inb(ahd, DSCOMMAND0)|MPARCKEN|CACHETHEN);
ahd_outb(ahd, DFF_THRSH, RD_DFTHRSH_75|WR_DFTHRSH_75);
ahd_outb(ahd, SIMODE0, ENIOERR|ENOVERRUN);
ahd_outb(ahd, SIMODE3, ENNTRAMPERR|ENOSRAMPERR);
if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
ahd_outb(ahd, OPTIONMODE, AUTOACKEN|AUTO_MSGOUT_DE);
} else {
ahd_outb(ahd, OPTIONMODE, AUTOACKEN|BUSFREEREV|AUTO_MSGOUT_DE);
}
ahd_outb(ahd, SCSCHKN, CURRFIFODEF|WIDERESEN|SHVALIDSTDIS);
if ((ahd->chip & AHD_BUS_MASK) == AHD_PCIX)
/*
* Do not issue a target abort when a split completion
* error occurs. Let our PCIX interrupt handler deal
* with it instead. H2A4 Razor #625
*/
ahd_outb(ahd, PCIXCTL, ahd_inb(ahd, PCIXCTL) | SPLTSTADIS);
if ((ahd->bugs & AHD_LQOOVERRUN_BUG) != 0)
ahd_outb(ahd, LQOSCSCTL, LQONOCHKOVER);
/*
* Tweak IOCELL settings.
*/
if ((ahd->flags & AHD_HP_BOARD) != 0) {
for (i = 0; i < NUMDSPS; i++) {
ahd_outb(ahd, DSPSELECT, i);
ahd_outb(ahd, WRTBIASCTL, WRTBIASCTL_HP_DEFAULT);
}
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("%s: WRTBIASCTL now 0x%x\n", ahd_name(ahd),
WRTBIASCTL_HP_DEFAULT);
#endif
}
ahd_setup_iocell_workaround(ahd);
/*
* Enable LQI Manager interrupts.
*/
ahd_outb(ahd, LQIMODE1, ENLQIPHASE_LQ|ENLQIPHASE_NLQ|ENLIQABORT
| ENLQICRCI_LQ|ENLQICRCI_NLQ|ENLQIBADLQI
| ENLQIOVERI_LQ|ENLQIOVERI_NLQ);
ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC);
/*
* We choose to have the sequencer catch LQOPHCHGINPKT errors
* manually for the command phase at the start of a packetized
* selection case. ENLQOBUSFREE should be made redundant by
* the BUSFREE interrupt, but it seems that some LQOBUSFREE
* events fail to assert the BUSFREE interrupt so we must
* also enable LQOBUSFREE interrupts.
*/
ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE);
/*
* Setup sequencer interrupt handlers.
*/
ahd_outw(ahd, INTVEC1_ADDR, ahd_resolve_seqaddr(ahd, LABEL_seq_isr));
ahd_outw(ahd, INTVEC2_ADDR, ahd_resolve_seqaddr(ahd, LABEL_timer_isr));
/*
* Setup SCB Offset registers.
*/
if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb,
pkt_long_lun));
} else {
ahd_outb(ahd, LUNPTR, offsetof(struct hardware_scb, lun));
}
ahd_outb(ahd, CMDLENPTR, offsetof(struct hardware_scb, cdb_len));
ahd_outb(ahd, ATTRPTR, offsetof(struct hardware_scb, task_attribute));
ahd_outb(ahd, FLAGPTR, offsetof(struct hardware_scb, task_management));
ahd_outb(ahd, CMDPTR, offsetof(struct hardware_scb,
shared_data.idata.cdb));
ahd_outb(ahd, QNEXTPTR,
offsetof(struct hardware_scb, next_hscb_busaddr));
ahd_outb(ahd, ABRTBITPTR, MK_MESSAGE_BIT_OFFSET);
ahd_outb(ahd, ABRTBYTEPTR, offsetof(struct hardware_scb, control));
if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
ahd_outb(ahd, LUNLEN,
sizeof(ahd->next_queued_hscb->pkt_long_lun) - 1);
} else {
ahd_outb(ahd, LUNLEN, LUNLEN_SINGLE_LEVEL_LUN);
}
ahd_outb(ahd, CDBLIMIT, SCB_CDB_LEN_PTR - 1);
ahd_outb(ahd, MAXCMD, 0xFF);
ahd_outb(ahd, SCBAUTOPTR,
AUSCBPTR_EN | offsetof(struct hardware_scb, tag));
/* We haven't been enabled for target mode yet. */
ahd_outb(ahd, MULTARGID, 0);
ahd_outb(ahd, MULTARGID + 1, 0);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/* Initialize the negotiation table. */
if ((ahd->features & AHD_NEW_IOCELL_OPTS) == 0) {
/*
* Clear the spare bytes in the neg table to avoid
* spurious parity errors.
*/
for (target = 0; target < AHD_NUM_TARGETS; target++) {
ahd_outb(ahd, NEGOADDR, target);
ahd_outb(ahd, ANNEXCOL, AHD_ANNEXCOL_PER_DEV0);
for (i = 0; i < AHD_NUM_PER_DEV_ANNEXCOLS; i++)
ahd_outb(ahd, ANNEXDAT, 0);
}
}
for (target = 0; target < AHD_NUM_TARGETS; target++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
target, &tstate);
ahd_compile_devinfo(&devinfo, ahd->our_id,
target, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
ahd_update_neg_table(ahd, &devinfo, &tinfo->curr);
}
ahd_outb(ahd, CLRSINT3, NTRAMPERR|OSRAMPERR);
ahd_outb(ahd, CLRINT, CLRSCSIINT);
#ifdef NEEDS_MORE_TESTING
/*
* Always enable abort on incoming L_Qs if this feature is
* supported. We use this to catch invalid SCB references.
*/
if ((ahd->bugs & AHD_ABORT_LQI_BUG) == 0)
ahd_outb(ahd, LQCTL1, ABORTPENDING);
else
#endif
ahd_outb(ahd, LQCTL1, 0);
/* All of our queues are empty */
ahd->qoutfifonext = 0;
ahd->qoutfifonext_valid_tag = QOUTFIFO_ENTRY_VALID;
ahd_outb(ahd, QOUTFIFO_ENTRY_VALID_TAG, QOUTFIFO_ENTRY_VALID);
for (i = 0; i < AHD_QOUT_SIZE; i++)
ahd->qoutfifo[i].valid_tag = 0;
ahd_sync_qoutfifo(ahd, BUS_DMASYNC_PREREAD);
ahd->qinfifonext = 0;
for (i = 0; i < AHD_QIN_SIZE; i++)
ahd->qinfifo[i] = SCB_LIST_NULL;
if ((ahd->features & AHD_TARGETMODE) != 0) {
/* All target command blocks start out invalid. */
for (i = 0; i < AHD_TMODE_CMDS; i++)
ahd->targetcmds[i].cmd_valid = 0;
ahd_sync_tqinfifo(ahd, BUS_DMASYNC_PREREAD);
ahd->tqinfifonext = 1;
ahd_outb(ahd, KERNEL_TQINPOS, ahd->tqinfifonext - 1);
ahd_outb(ahd, TQINPOS, ahd->tqinfifonext);
}
/* Initialize Scratch Ram. */
ahd_outb(ahd, SEQ_FLAGS, 0);
ahd_outb(ahd, SEQ_FLAGS2, 0);
/* We don't have any waiting selections */
ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL);
ahd_outw(ahd, MK_MESSAGE_SCB, SCB_LIST_NULL);
ahd_outw(ahd, MK_MESSAGE_SCSIID, 0xFF);
for (i = 0; i < AHD_NUM_TARGETS; i++)
ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL);
/*
* Nobody is waiting to be DMAed into the QOUTFIFO.
*/
ahd_outw(ahd, COMPLETE_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_SCB_DMAINPROG_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_HEAD, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_DMA_SCB_TAIL, SCB_LIST_NULL);
ahd_outw(ahd, COMPLETE_ON_QFREEZE_HEAD, SCB_LIST_NULL);
/*
* The Freeze Count is 0.
*/
ahd->qfreeze_cnt = 0;
ahd_outw(ahd, QFREEZE_COUNT, 0);
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, 0);
/*
* Tell the sequencer where it can find our arrays in memory.
*/
busaddr = ahd->shared_data_map.physaddr;
ahd_outl(ahd, SHARED_DATA_ADDR, busaddr);
ahd_outl(ahd, QOUTFIFO_NEXT_ADDR, busaddr);
/*
* Setup the allowed SCSI Sequences based on operational mode.
* If we are a target, we'll enable select in operations once
* we've had a lun enabled.
*/
scsiseq_template = ENAUTOATNP;
if ((ahd->flags & AHD_INITIATORROLE) != 0)
scsiseq_template |= ENRSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq_template);
/* There are no busy SCBs yet. */
for (target = 0; target < AHD_NUM_TARGETS; target++) {
int lun;
for (lun = 0; lun < AHD_NUM_LUNS_NONPKT; lun++)
ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(target, 'A', lun));
}
/*
* Initialize the group code to command length table.
* Vendor Unique codes are set to 0 so we only capture
* the first byte of the cdb. These can be overridden
* when target mode is enabled.
*/
ahd_outb(ahd, CMDSIZE_TABLE, 5);
ahd_outb(ahd, CMDSIZE_TABLE + 1, 9);
ahd_outb(ahd, CMDSIZE_TABLE + 2, 9);
ahd_outb(ahd, CMDSIZE_TABLE + 3, 0);
ahd_outb(ahd, CMDSIZE_TABLE + 4, 15);
ahd_outb(ahd, CMDSIZE_TABLE + 5, 11);
ahd_outb(ahd, CMDSIZE_TABLE + 6, 0);
ahd_outb(ahd, CMDSIZE_TABLE + 7, 0);
/* Tell the sequencer of our initial queue positions */
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
ahd_outb(ahd, QOFF_CTLSTA, SCB_QSIZE_512);
ahd->qinfifonext = 0;
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
ahd_set_hescb_qoff(ahd, 0);
ahd_set_snscb_qoff(ahd, 0);
ahd_set_sescb_qoff(ahd, 0);
ahd_set_sdscb_qoff(ahd, 0);
/*
* Tell the sequencer which SCB will be the next one it receives.
*/
busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
/*
* Default to coalescing disabled.
*/
ahd_outw(ahd, INT_COALESCING_CMDCOUNT, 0);
ahd_outw(ahd, CMDS_PENDING, 0);
ahd_update_coalescing_values(ahd, ahd->int_coalescing_timer,
ahd->int_coalescing_maxcmds,
ahd->int_coalescing_mincmds);
ahd_enable_coalescing(ahd, FALSE);
ahd_loadseq(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
u_int negodat3 = ahd_inb(ahd, NEGCONOPTS);
negodat3 |= ENSLOWCRC;
ahd_outb(ahd, NEGCONOPTS, negodat3);
negodat3 = ahd_inb(ahd, NEGCONOPTS);
if (!(negodat3 & ENSLOWCRC))
printf("aic79xx: failed to set the SLOWCRC bit\n");
else
printf("aic79xx: SLOWCRC bit set\n");
}
}
/*
* Setup default device and controller settings.
* This should only be called if our probe has
* determined that no configuration data is available.
*/
int
ahd_default_config(struct ahd_softc *ahd)
{
int targ;
ahd->our_id = 7;
/*
* Allocate a tstate to house information for our
* initiator presence on the bus as well as the user
* data for any target mode initiator.
*/
if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
printf("%s: unable to allocate ahd_tmode_tstate. "
"Failing attach\n", ahd_name(ahd));
return (ENOMEM);
}
for (targ = 0; targ < AHD_NUM_TARGETS; targ++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
uint16_t target_mask;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
targ, &tstate);
/*
* We support SPC2 and SPI4.
*/
tinfo->user.protocol_version = 4;
tinfo->user.transport_version = 4;
target_mask = 0x01 << targ;
ahd->user_discenable |= target_mask;
tstate->discenable |= target_mask;
ahd->user_tagenable |= target_mask;
#ifdef AHD_FORCE_160
tinfo->user.period = AHD_SYNCRATE_DT;
#else
tinfo->user.period = AHD_SYNCRATE_160;
#endif
tinfo->user.offset = MAX_OFFSET;
tinfo->user.ppr_options = MSG_EXT_PPR_RD_STRM
| MSG_EXT_PPR_WR_FLOW
| MSG_EXT_PPR_HOLD_MCS
| MSG_EXT_PPR_IU_REQ
| MSG_EXT_PPR_QAS_REQ
| MSG_EXT_PPR_DT_REQ;
if ((ahd->features & AHD_RTI) != 0)
tinfo->user.ppr_options |= MSG_EXT_PPR_RTI;
tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
/*
* Start out Async/Narrow/Untagged and with
* conservative protocol support.
*/
tinfo->goal.protocol_version = 2;
tinfo->goal.transport_version = 2;
tinfo->curr.protocol_version = 2;
tinfo->curr.transport_version = 2;
ahd_compile_devinfo(&devinfo, ahd->our_id,
targ, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
tstate->tagenable &= ~target_mask;
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
}
return (0);
}
/*
* Parse device configuration information.
*/
int
ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc)
{
int targ;
int max_targ;
max_targ = sc->max_targets & CFMAXTARG;
ahd->our_id = sc->brtime_id & CFSCSIID;
/*
* Allocate a tstate to house information for our
* initiator presence on the bus as well as the user
* data for any target mode initiator.
*/
if (ahd_alloc_tstate(ahd, ahd->our_id, 'A') == NULL) {
printf("%s: unable to allocate ahd_tmode_tstate. "
"Failing attach\n", ahd_name(ahd));
return (ENOMEM);
}
for (targ = 0; targ < max_targ; targ++) {
struct ahd_devinfo devinfo;
struct ahd_initiator_tinfo *tinfo;
struct ahd_transinfo *user_tinfo;
struct ahd_tmode_tstate *tstate;
uint16_t target_mask;
tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
targ, &tstate);
user_tinfo = &tinfo->user;
/*
* We support SPC2 and SPI4.
*/
tinfo->user.protocol_version = 4;
tinfo->user.transport_version = 4;
target_mask = 0x01 << targ;
ahd->user_discenable &= ~target_mask;
tstate->discenable &= ~target_mask;
ahd->user_tagenable &= ~target_mask;
if (sc->device_flags[targ] & CFDISC) {
tstate->discenable |= target_mask;
ahd->user_discenable |= target_mask;
ahd->user_tagenable |= target_mask;
} else {
/*
* Cannot be packetized without disconnection.
*/
sc->device_flags[targ] &= ~CFPACKETIZED;
}
user_tinfo->ppr_options = 0;
user_tinfo->period = (sc->device_flags[targ] & CFXFER);
if (user_tinfo->period < CFXFER_ASYNC) {
if (user_tinfo->period <= AHD_PERIOD_10MHz)
user_tinfo->ppr_options |= MSG_EXT_PPR_DT_REQ;
user_tinfo->offset = MAX_OFFSET;
} else {
user_tinfo->offset = 0;
user_tinfo->period = AHD_ASYNC_XFER_PERIOD;
}
#ifdef AHD_FORCE_160
if (user_tinfo->period <= AHD_SYNCRATE_160)
user_tinfo->period = AHD_SYNCRATE_DT;
#endif
if ((sc->device_flags[targ] & CFPACKETIZED) != 0) {
user_tinfo->ppr_options |= MSG_EXT_PPR_RD_STRM
| MSG_EXT_PPR_WR_FLOW
| MSG_EXT_PPR_HOLD_MCS
| MSG_EXT_PPR_IU_REQ;
if ((ahd->features & AHD_RTI) != 0)
user_tinfo->ppr_options |= MSG_EXT_PPR_RTI;
}
if ((sc->device_flags[targ] & CFQAS) != 0)
user_tinfo->ppr_options |= MSG_EXT_PPR_QAS_REQ;
if ((sc->device_flags[targ] & CFWIDEB) != 0)
user_tinfo->width = MSG_EXT_WDTR_BUS_16_BIT;
else
user_tinfo->width = MSG_EXT_WDTR_BUS_8_BIT;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0)
printf("(%d): %x:%x:%x:%x\n", targ, user_tinfo->width,
user_tinfo->period, user_tinfo->offset,
user_tinfo->ppr_options);
#endif
/*
* Start out Async/Narrow/Untagged and with
* conservative protocol support.
*/
tstate->tagenable &= ~target_mask;
tinfo->goal.protocol_version = 2;
tinfo->goal.transport_version = 2;
tinfo->curr.protocol_version = 2;
tinfo->curr.transport_version = 2;
ahd_compile_devinfo(&devinfo, ahd->our_id,
targ, CAM_LUN_WILDCARD,
'A', ROLE_INITIATOR);
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR|AHD_TRANS_GOAL, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_CUR|AHD_TRANS_GOAL,
/*paused*/TRUE);
}
ahd->flags &= ~AHD_SPCHK_ENB_A;
if (sc->bios_control & CFSPARITY)
ahd->flags |= AHD_SPCHK_ENB_A;
ahd->flags &= ~AHD_RESET_BUS_A;
if (sc->bios_control & CFRESETB)
ahd->flags |= AHD_RESET_BUS_A;
ahd->flags &= ~AHD_EXTENDED_TRANS_A;
if (sc->bios_control & CFEXTEND)
ahd->flags |= AHD_EXTENDED_TRANS_A;
ahd->flags &= ~AHD_BIOS_ENABLED;
if ((sc->bios_control & CFBIOSSTATE) == CFBS_ENABLED)
ahd->flags |= AHD_BIOS_ENABLED;
ahd->flags &= ~AHD_STPWLEVEL_A;
if ((sc->adapter_control & CFSTPWLEVEL) != 0)
ahd->flags |= AHD_STPWLEVEL_A;
return (0);
}
/*
* Parse device configuration information.
*/
int
ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd)
{
int error;
error = ahd_verify_vpd_cksum(vpd);
if (error == 0)
return (EINVAL);
if ((vpd->bios_flags & VPDBOOTHOST) != 0)
ahd->flags |= AHD_BOOT_CHANNEL;
return (0);
}
void
ahd_intr_enable(struct ahd_softc *ahd, int enable)
{
u_int hcntrl;
hcntrl = ahd_inb(ahd, HCNTRL);
hcntrl &= ~INTEN;
ahd->pause &= ~INTEN;
ahd->unpause &= ~INTEN;
if (enable) {
hcntrl |= INTEN;
ahd->pause |= INTEN;
ahd->unpause |= INTEN;
}
ahd_outb(ahd, HCNTRL, hcntrl);
}
static void
ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
u_int mincmds)
{
if (timer > AHD_TIMER_MAX_US)
timer = AHD_TIMER_MAX_US;
ahd->int_coalescing_timer = timer;
if (maxcmds > AHD_INT_COALESCING_MAXCMDS_MAX)
maxcmds = AHD_INT_COALESCING_MAXCMDS_MAX;
if (mincmds > AHD_INT_COALESCING_MINCMDS_MAX)
mincmds = AHD_INT_COALESCING_MINCMDS_MAX;
ahd->int_coalescing_maxcmds = maxcmds;
ahd_outw(ahd, INT_COALESCING_TIMER, timer / AHD_TIMER_US_PER_TICK);
ahd_outb(ahd, INT_COALESCING_MAXCMDS, -maxcmds);
ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
}
static void
ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
{
ahd->hs_mailbox &= ~ENINT_COALESCE;
if (enable)
ahd->hs_mailbox |= ENINT_COALESCE;
ahd_outb(ahd, HS_MAILBOX, ahd->hs_mailbox);
ahd_flush_device_writes(ahd);
ahd_run_qoutfifo(ahd);
}
/*
* Ensure that the card is paused in a location
* outside of all critical sections and that all
* pending work is completed prior to returning.
* This routine should only be called from outside
* an interrupt context.
*/
void
ahd_pause_and_flushwork(struct ahd_softc *ahd)
{
u_int intstat;
u_int maxloops;
maxloops = 1000;
ahd->flags |= AHD_ALL_INTERRUPTS;
ahd_pause(ahd);
/*
* Freeze the outgoing selections. We do this only
* until we are safely paused without further selections
* pending.
*/
ahd->qfreeze_cnt--;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
ahd_outb(ahd, SEQ_FLAGS2, ahd_inb(ahd, SEQ_FLAGS2) | SELECTOUT_QFROZEN);
do {
ahd_unpause(ahd);
/*
* Give the sequencer some time to service
* any active selections.
*/
ahd_delay(500);
ahd_intr(ahd);
ahd_pause(ahd);
intstat = ahd_inb(ahd, INTSTAT);
if ((intstat & INT_PEND) == 0) {
ahd_clear_critical_section(ahd);
intstat = ahd_inb(ahd, INTSTAT);
}
} while (--maxloops
&& (intstat != 0xFF || (ahd->features & AHD_REMOVABLE) == 0)
&& ((intstat & INT_PEND) != 0
|| (ahd_inb(ahd, SCSISEQ0) & ENSELO) != 0
|| (ahd_inb(ahd, SSTAT0) & (SELDO|SELINGO)) != 0));
if (maxloops == 0) {
printf("Infinite interrupt loop, INTSTAT = %x",
ahd_inb(ahd, INTSTAT));
}
ahd->qfreeze_cnt++;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
ahd_flush_qoutfifo(ahd);
ahd->flags &= ~AHD_ALL_INTERRUPTS;
}
#if 0
int
ahd_suspend(struct ahd_softc *ahd)
{
ahd_pause_and_flushwork(ahd);
if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
ahd_unpause(ahd);
return (EBUSY);
}
ahd_shutdown(ahd);
return (0);
}
#endif /* 0 */
#if 0
int
ahd_resume(struct ahd_softc *ahd)
{
ahd_reset(ahd, /*reinit*/TRUE);
ahd_intr_enable(ahd, TRUE);
ahd_restart(ahd);
return (0);
}
#endif /* 0 */
/************************** Busy Target Table *********************************/
/*
* Set SCBPTR to the SCB that contains the busy
* table entry for TCL. Return the offset into
* the SCB that contains the entry for TCL.
* saved_scbid is dereferenced and set to the
* scbid that should be restored once manipualtion
* of the TCL entry is complete.
*/
static __inline u_int
ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
{
/*
* Index to the SCB that contains the busy entry.
*/
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
*saved_scbid = ahd_get_scbptr(ahd);
ahd_set_scbptr(ahd, TCL_LUN(tcl)
| ((TCL_TARGET_OFFSET(tcl) & 0xC) << 4));
/*
* And now calculate the SCB offset to the entry.
* Each entry is 2 bytes wide, hence the
* multiplication by 2.
*/
return (((TCL_TARGET_OFFSET(tcl) & 0x3) << 1) + SCB_DISCONNECTED_LISTS);
}
/*
* Return the untagged transaction id for a given target/channel lun.
*/
static u_int
ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
{
u_int scbid;
u_int scb_offset;
u_int saved_scbptr;
scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
scbid = ahd_inw_scbram(ahd, scb_offset);
ahd_set_scbptr(ahd, saved_scbptr);
return (scbid);
}
static void
ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
{
u_int scb_offset;
u_int saved_scbptr;
scb_offset = ahd_index_busy_tcl(ahd, &saved_scbptr, tcl);
ahd_outw(ahd, scb_offset, scbid);
ahd_set_scbptr(ahd, saved_scbptr);
}
/************************** SCB and SCB queue management **********************/
static int
ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
char channel, int lun, u_int tag, role_t role)
{
int targ = SCB_GET_TARGET(ahd, scb);
char chan = SCB_GET_CHANNEL(ahd, scb);
int slun = SCB_GET_LUN(scb);
int match;
match = ((chan == channel) || (channel == ALL_CHANNELS));
if (match != 0)
match = ((targ == target) || (target == CAM_TARGET_WILDCARD));
if (match != 0)
match = ((lun == slun) || (lun == CAM_LUN_WILDCARD));
if (match != 0) {
#ifdef AHD_TARGET_MODE
int group;
group = XPT_FC_GROUP(scb->io_ctx->ccb_h.func_code);
if (role == ROLE_INITIATOR) {
match = (group != XPT_FC_GROUP_TMODE)
&& ((tag == SCB_GET_TAG(scb))
|| (tag == SCB_LIST_NULL));
} else if (role == ROLE_TARGET) {
match = (group == XPT_FC_GROUP_TMODE)
&& ((tag == scb->io_ctx->csio.tag_id)
|| (tag == SCB_LIST_NULL));
}
#else /* !AHD_TARGET_MODE */
match = ((tag == SCB_GET_TAG(scb)) || (tag == SCB_LIST_NULL));
#endif /* AHD_TARGET_MODE */
}
return match;
}
static void
ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
{
int target;
char channel;
int lun;
target = SCB_GET_TARGET(ahd, scb);
lun = SCB_GET_LUN(scb);
channel = SCB_GET_CHANNEL(ahd, scb);
ahd_search_qinfifo(ahd, target, channel, lun,
/*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
CAM_REQUEUE_REQ, SEARCH_COMPLETE);
ahd_platform_freeze_devq(ahd, scb);
}
void
ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb)
{
struct scb *prev_scb;
ahd_mode_state saved_modes;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
prev_scb = NULL;
if (ahd_qinfifo_count(ahd) != 0) {
u_int prev_tag;
u_int prev_pos;
prev_pos = AHD_QIN_WRAP(ahd->qinfifonext - 1);
prev_tag = ahd->qinfifo[prev_pos];
prev_scb = ahd_lookup_scb(ahd, prev_tag);
}
ahd_qinfifo_requeue(ahd, prev_scb, scb);
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
ahd_restore_modes(ahd, saved_modes);
}
static void
ahd_qinfifo_requeue(struct ahd_softc *ahd, struct scb *prev_scb,
struct scb *scb)
{
if (prev_scb == NULL) {
uint32_t busaddr;
busaddr = ahd_le32toh(scb->hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
} else {
prev_scb->hscb->next_hscb_busaddr = scb->hscb->hscb_busaddr;
ahd_sync_scb(ahd, prev_scb,
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
}
ahd->qinfifo[AHD_QIN_WRAP(ahd->qinfifonext)] = SCB_GET_TAG(scb);
ahd->qinfifonext++;
scb->hscb->next_hscb_busaddr = ahd->next_queued_hscb->hscb_busaddr;
ahd_sync_scb(ahd, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
}
static int
ahd_qinfifo_count(struct ahd_softc *ahd)
{
u_int qinpos;
u_int wrap_qinpos;
u_int wrap_qinfifonext;
AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
qinpos = ahd_get_snscb_qoff(ahd);
wrap_qinpos = AHD_QIN_WRAP(qinpos);
wrap_qinfifonext = AHD_QIN_WRAP(ahd->qinfifonext);
if (wrap_qinfifonext >= wrap_qinpos)
return (wrap_qinfifonext - wrap_qinpos);
else
return (wrap_qinfifonext
+ ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
}
void
ahd_reset_cmds_pending(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int pending_cmds;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Don't count any commands as outstanding that the
* sequencer has already marked for completion.
*/
ahd_flush_qoutfifo(ahd);
pending_cmds = 0;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
pending_cmds++;
}
ahd_outw(ahd, CMDS_PENDING, pending_cmds - ahd_qinfifo_count(ahd));
ahd_restore_modes(ahd, saved_modes);
ahd->flags &= ~AHD_UPDATE_PEND_CMDS;
}
static void
ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status)
{
cam_status ostat;
cam_status cstat;
ostat = ahd_get_transaction_status(scb);
if (ostat == CAM_REQ_INPROG)
ahd_set_transaction_status(scb, status);
cstat = ahd_get_transaction_status(scb);
if (cstat != CAM_REQ_CMP)
ahd_freeze_scb(scb);
ahd_done(ahd, scb);
}
int
ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status,
ahd_search_action action)
{
struct scb *scb;
struct scb *mk_msg_scb;
struct scb *prev_scb;
ahd_mode_state saved_modes;
u_int qinstart;
u_int qinpos;
u_int qintail;
u_int tid_next;
u_int tid_prev;
u_int scbid;
u_int seq_flags2;
u_int savedscbptr;
uint32_t busaddr;
int found;
int targets;
/* Must be in CCHAN mode */
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
/*
* Halt any pending SCB DMA. The sequencer will reinitiate
* this dma if the qinfifo is not empty once we unpause.
*/
if ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN|CCSCBDIR))
== (CCARREN|CCSCBEN|CCSCBDIR)) {
ahd_outb(ahd, CCSCBCTL,
ahd_inb(ahd, CCSCBCTL) & ~(CCARREN|CCSCBEN));
while ((ahd_inb(ahd, CCSCBCTL) & (CCARREN|CCSCBEN)) != 0)
;
}
/* Determine sequencer's position in the qinfifo. */
qintail = AHD_QIN_WRAP(ahd->qinfifonext);
qinstart = ahd_get_snscb_qoff(ahd);
qinpos = AHD_QIN_WRAP(qinstart);
found = 0;
prev_scb = NULL;
if (action == SEARCH_PRINT) {
printf("qinstart = %d qinfifonext = %d\nQINFIFO:",
qinstart, ahd->qinfifonext);
}
/*
* Start with an empty queue. Entries that are not chosen
* for removal will be re-added to the queue as we go.
*/
ahd->qinfifonext = qinstart;
busaddr = ahd_le32toh(ahd->next_queued_hscb->hscb_busaddr);
ahd_outl(ahd, NEXT_QUEUED_SCB_ADDR, busaddr);
while (qinpos != qintail) {
scb = ahd_lookup_scb(ahd, ahd->qinfifo[qinpos]);
if (scb == NULL) {
printf("qinpos = %d, SCB index = %d\n",
qinpos, ahd->qinfifo[qinpos]);
panic("Loop 1\n");
}
if (ahd_match_scb(ahd, scb, target, channel, lun, tag, role)) {
/*
* We found an scb that needs to be acted on.
*/
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((scb->flags & SCB_ACTIVE) == 0)
printf("Inactive SCB in qinfifo\n");
ahd_done_with_status(ahd, scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
break;
case SEARCH_PRINT:
printf(" 0x%x", ahd->qinfifo[qinpos]);
/* FALLTHROUGH */
case SEARCH_COUNT:
ahd_qinfifo_requeue(ahd, prev_scb, scb);
prev_scb = scb;
break;
}
} else {
ahd_qinfifo_requeue(ahd, prev_scb, scb);
prev_scb = scb;
}
qinpos = AHD_QIN_WRAP(qinpos+1);
}
ahd_set_hnscb_qoff(ahd, ahd->qinfifonext);
if (action == SEARCH_PRINT)
printf("\nWAITING_TID_QUEUES:\n");
/*
* Search waiting for selection lists. We traverse the
* list of "their ids" waiting for selection and, if
* appropriate, traverse the SCBs of each "their id"
* looking for matches.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
seq_flags2 = ahd_inb(ahd, SEQ_FLAGS2);
if ((seq_flags2 & PENDING_MK_MESSAGE) != 0) {
scbid = ahd_inw(ahd, MK_MESSAGE_SCB);
mk_msg_scb = ahd_lookup_scb(ahd, scbid);
} else
mk_msg_scb = NULL;
savedscbptr = ahd_get_scbptr(ahd);
tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
tid_prev = SCB_LIST_NULL;
targets = 0;
for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) {
u_int tid_head;
u_int tid_tail;
targets++;
if (targets > AHD_NUM_TARGETS)
panic("TID LIST LOOP");
if (scbid >= ahd->scb_data.numscbs) {
printf("%s: Waiting TID List inconsistency. "
"SCB index == 0x%x, yet numscbs == 0x%x.",
ahd_name(ahd), scbid, ahd->scb_data.numscbs);
ahd_dump_card_state(ahd);
panic("for safety");
}
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: SCB = 0x%x Not Active!\n",
ahd_name(ahd), scbid);
panic("Waiting TID List traversal\n");
}
ahd_set_scbptr(ahd, scbid);
tid_next = ahd_inw_scbram(ahd, SCB_NEXT2);
if (ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_UNKNOWN) == 0) {
tid_prev = scbid;
continue;
}
/*
* We found a list of scbs that needs to be searched.
*/
if (action == SEARCH_PRINT)
printf(" %d ( ", SCB_GET_TARGET(ahd, scb));
tid_head = scbid;
found += ahd_search_scb_list(ahd, target, channel,
lun, tag, role, status,
action, &tid_head, &tid_tail,
SCB_GET_TARGET(ahd, scb));
/*
* Check any MK_MESSAGE SCB that is still waiting to
* enter this target's waiting for selection queue.
*/
if (mk_msg_scb != NULL
&& ahd_match_scb(ahd, mk_msg_scb, target, channel,
lun, tag, role)) {
/*
* We found an scb that needs to be acted on.
*/
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
printf("Inactive SCB pending MK_MSG\n");
ahd_done_with_status(ahd, mk_msg_scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
{
u_int tail_offset;
printf("Removing MK_MSG scb\n");
/*
* Reset our tail to the tail of the
* main per-target list.
*/
tail_offset = WAITING_SCB_TAILS
+ (2 * SCB_GET_TARGET(ahd, mk_msg_scb));
ahd_outw(ahd, tail_offset, tid_tail);
seq_flags2 &= ~PENDING_MK_MESSAGE;
ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
ahd_outw(ahd, CMDS_PENDING,
ahd_inw(ahd, CMDS_PENDING)-1);
mk_msg_scb = NULL;
break;
}
case SEARCH_PRINT:
printf(" 0x%x", SCB_GET_TAG(scb));
/* FALLTHROUGH */
case SEARCH_COUNT:
break;
}
}
if (mk_msg_scb != NULL
&& SCBID_IS_NULL(tid_head)
&& ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
SCB_LIST_NULL, ROLE_UNKNOWN)) {
/*
* When removing the last SCB for a target
* queue with a pending MK_MESSAGE scb, we
* must queue the MK_MESSAGE scb.
*/
printf("Queueing mk_msg_scb\n");
tid_head = ahd_inw(ahd, MK_MESSAGE_SCB);
seq_flags2 &= ~PENDING_MK_MESSAGE;
ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
mk_msg_scb = NULL;
}
if (tid_head != scbid)
ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next);
if (!SCBID_IS_NULL(tid_head))
tid_prev = tid_head;
if (action == SEARCH_PRINT)
printf(")\n");
}
/* Restore saved state. */
ahd_set_scbptr(ahd, savedscbptr);
ahd_restore_modes(ahd, saved_modes);
return (found);
}
static int
ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status,
ahd_search_action action, u_int *list_head,
u_int *list_tail, u_int tid)
{
struct scb *scb;
u_int scbid;
u_int next;
u_int prev;
int found;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
found = 0;
prev = SCB_LIST_NULL;
next = *list_head;
*list_tail = SCB_LIST_NULL;
for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
if (scbid >= ahd->scb_data.numscbs) {
printf("%s:SCB List inconsistency. "
"SCB == 0x%x, yet numscbs == 0x%x.",
ahd_name(ahd), scbid, ahd->scb_data.numscbs);
ahd_dump_card_state(ahd);
panic("for safety");
}
scb = ahd_lookup_scb(ahd, scbid);
if (scb == NULL) {
printf("%s: SCB = %d Not Active!\n",
ahd_name(ahd), scbid);
panic("Waiting List traversal\n");
}
ahd_set_scbptr(ahd, scbid);
*list_tail = scbid;
next = ahd_inw_scbram(ahd, SCB_NEXT);
if (ahd_match_scb(ahd, scb, target, channel,
lun, SCB_LIST_NULL, role) == 0) {
prev = scbid;
continue;
}
found++;
switch (action) {
case SEARCH_COMPLETE:
if ((scb->flags & SCB_ACTIVE) == 0)
printf("Inactive SCB in Waiting List\n");
ahd_done_with_status(ahd, scb, status);
/* FALLTHROUGH */
case SEARCH_REMOVE:
ahd_rem_wscb(ahd, scbid, prev, next, tid);
*list_tail = prev;
if (SCBID_IS_NULL(prev))
*list_head = next;
break;
case SEARCH_PRINT:
printf("0x%x ", scbid);
case SEARCH_COUNT:
prev = scbid;
break;
}
if (found > AHD_SCB_MAX)
panic("SCB LIST LOOP");
}
if (action == SEARCH_COMPLETE
|| action == SEARCH_REMOVE)
ahd_outw(ahd, CMDS_PENDING, ahd_inw(ahd, CMDS_PENDING) - found);
return (found);
}
static void
ahd_stitch_tid_list(struct ahd_softc *ahd, u_int tid_prev,
u_int tid_cur, u_int tid_next)
{
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (SCBID_IS_NULL(tid_cur)) {
/* Bypass current TID list */
if (SCBID_IS_NULL(tid_prev)) {
ahd_outw(ahd, WAITING_TID_HEAD, tid_next);
} else {
ahd_set_scbptr(ahd, tid_prev);
ahd_outw(ahd, SCB_NEXT2, tid_next);
}
if (SCBID_IS_NULL(tid_next))
ahd_outw(ahd, WAITING_TID_TAIL, tid_prev);
} else {
/* Stitch through tid_cur */
if (SCBID_IS_NULL(tid_prev)) {
ahd_outw(ahd, WAITING_TID_HEAD, tid_cur);
} else {
ahd_set_scbptr(ahd, tid_prev);
ahd_outw(ahd, SCB_NEXT2, tid_cur);
}
ahd_set_scbptr(ahd, tid_cur);
ahd_outw(ahd, SCB_NEXT2, tid_next);
if (SCBID_IS_NULL(tid_next))
ahd_outw(ahd, WAITING_TID_TAIL, tid_cur);
}
}
/*
* Manipulate the waiting for selection list and return the
* scb that follows the one that we remove.
*/
static u_int
ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
u_int prev, u_int next, u_int tid)
{
u_int tail_offset;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (!SCBID_IS_NULL(prev)) {
ahd_set_scbptr(ahd, prev);
ahd_outw(ahd, SCB_NEXT, next);
}
/*
* SCBs that have MK_MESSAGE set in them may
* cause the tail pointer to be updated without
* setting the next pointer of the previous tail.
* Only clear the tail if the removed SCB was
* the tail.
*/
tail_offset = WAITING_SCB_TAILS + (2 * tid);
if (SCBID_IS_NULL(next)
&& ahd_inw(ahd, tail_offset) == scbid)
ahd_outw(ahd, tail_offset, prev);
ahd_add_scb_to_free_list(ahd, scbid);
return (next);
}
/*
* Add the SCB as selected by SCBPTR onto the on chip list of
* free hardware SCBs. This list is empty/unused if we are not
* performing SCB paging.
*/
static void
ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
{
/* XXX Need some other mechanism to designate "free". */
/*
* Invalidate the tag so that our abort
* routines don't think it's active.
ahd_outb(ahd, SCB_TAG, SCB_LIST_NULL);
*/
}
/******************************** Error Handling ******************************/
/*
* Abort all SCBs that match the given description (target/channel/lun/tag),
* setting their status to the passed in status if the status has not already
* been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
* is paused before it is called.
*/
static int
ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
int lun, u_int tag, role_t role, uint32_t status)
{
struct scb *scbp;
struct scb *scbp_next;
u_int i, j;
u_int maxtarget;
u_int minlun;
u_int maxlun;
int found;
ahd_mode_state saved_modes;
/* restore this when we're done */
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
found = ahd_search_qinfifo(ahd, target, channel, lun, SCB_LIST_NULL,
role, CAM_REQUEUE_REQ, SEARCH_COMPLETE);
/*
* Clean out the busy target table for any untagged commands.
*/
i = 0;
maxtarget = 16;
if (target != CAM_TARGET_WILDCARD) {
i = target;
if (channel == 'B')
i += 8;
maxtarget = i + 1;
}
if (lun == CAM_LUN_WILDCARD) {
minlun = 0;
maxlun = AHD_NUM_LUNS_NONPKT;
} else if (lun >= AHD_NUM_LUNS_NONPKT) {
minlun = maxlun = 0;
} else {
minlun = lun;
maxlun = lun + 1;
}
if (role != ROLE_TARGET) {
for (;i < maxtarget; i++) {
for (j = minlun;j < maxlun; j++) {
u_int scbid;
u_int tcl;
tcl = BUILD_TCL_RAW(i, 'A', j);
scbid = ahd_find_busy_tcl(ahd, tcl);
scbp = ahd_lookup_scb(ahd, scbid);
if (scbp == NULL
|| ahd_match_scb(ahd, scbp, target, channel,
lun, tag, role) == 0)
continue;
ahd_unbusy_tcl(ahd, BUILD_TCL_RAW(i, 'A', j));
}
}
}
/*
* Don't abort commands that have already completed,
* but haven't quite made it up to the host yet.
*/
ahd_flush_qoutfifo(ahd);
/*
* Go through the pending CCB list and look for
* commands for this target that are still active.
* These are other tagged commands that were
* disconnected when the reset occurred.
*/
scbp_next = LIST_FIRST(&ahd->pending_scbs);
while (scbp_next != NULL) {
scbp = scbp_next;
scbp_next = LIST_NEXT(scbp, pending_links);
if (ahd_match_scb(ahd, scbp, target, channel, lun, tag, role)) {
cam_status ostat;
ostat = ahd_get_transaction_status(scbp);
if (ostat == CAM_REQ_INPROG)
ahd_set_transaction_status(scbp, status);
if (ahd_get_transaction_status(scbp) != CAM_REQ_CMP)
ahd_freeze_scb(scbp);
if ((scbp->flags & SCB_ACTIVE) == 0)
printf("Inactive SCB on pending list\n");
ahd_done(ahd, scbp);
found++;
}
}
ahd_restore_modes(ahd, saved_modes);
ahd_platform_abort_scbs(ahd, target, channel, lun, tag, role, status);
ahd->flags |= AHD_UPDATE_PEND_CMDS;
return found;
}
static void
ahd_reset_current_bus(struct ahd_softc *ahd)
{
uint8_t scsiseq;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) & ~ENSCSIRST);
scsiseq = ahd_inb(ahd, SCSISEQ0) & ~(ENSELO|ENARBO|SCSIRSTO);
ahd_outb(ahd, SCSISEQ0, scsiseq | SCSIRSTO);
ahd_flush_device_writes(ahd);
ahd_delay(AHD_BUSRESET_DELAY);
/* Turn off the bus reset */
ahd_outb(ahd, SCSISEQ0, scsiseq);
ahd_flush_device_writes(ahd);
ahd_delay(AHD_BUSRESET_DELAY);
if ((ahd->bugs & AHD_SCSIRST_BUG) != 0) {
/*
* 2A Razor #474
* Certain chip state is not cleared for
* SCSI bus resets that we initiate, so
* we must reset the chip.
*/
ahd_reset(ahd, /*reinit*/TRUE);
ahd_intr_enable(ahd, /*enable*/TRUE);
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
}
ahd_clear_intstat(ahd);
}
int
ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
{
struct ahd_devinfo devinfo;
u_int initiator;
u_int target;
u_int max_scsiid;
int found;
u_int fifo;
u_int next_fifo;
uint8_t scsiseq;
/*
* Check if the last bus reset is cleared
*/
if (ahd->flags & AHD_BUS_RESET_ACTIVE) {
printf("%s: bus reset still active\n",
ahd_name(ahd));
return 0;
}
ahd->flags |= AHD_BUS_RESET_ACTIVE;
ahd->pending_device = NULL;
ahd_compile_devinfo(&devinfo,
CAM_TARGET_WILDCARD,
CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD,
channel, ROLE_UNKNOWN);
ahd_pause(ahd);
/* Make sure the sequencer is in a safe location. */
ahd_clear_critical_section(ahd);
/*
* Run our command complete fifos to ensure that we perform
* completion processing on any commands that 'completed'
* before the reset occurred.
*/
ahd_run_qoutfifo(ahd);
#ifdef AHD_TARGET_MODE
if ((ahd->flags & AHD_TARGETROLE) != 0) {
ahd_run_tqinfifo(ahd, /*paused*/TRUE);
}
#endif
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
/*
* Disable selections so no automatic hardware
* functions will modify chip state.
*/
ahd_outb(ahd, SCSISEQ0, 0);
ahd_outb(ahd, SCSISEQ1, 0);
/*
* Safely shut down our DMA engines. Always start with
* the FIFO that is not currently active (if any are
* actively connected).
*/
next_fifo = fifo = ahd_inb(ahd, DFFSTAT) & CURRFIFO;
if (next_fifo > CURRFIFO_1)
/* If disconneced, arbitrarily start with FIFO1. */
next_fifo = fifo = 0;
do {
next_fifo ^= CURRFIFO_1;
ahd_set_modes(ahd, next_fifo, next_fifo);
ahd_outb(ahd, DFCNTRL,
ahd_inb(ahd, DFCNTRL) & ~(SCSIEN|HDMAEN));
while ((ahd_inb(ahd, DFCNTRL) & HDMAENACK) != 0)
ahd_delay(10);
/*
* Set CURRFIFO to the now inactive channel.
*/
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, DFFSTAT, next_fifo);
} while (next_fifo != fifo);
/*
* Reset the bus if we are initiating this reset
*/
ahd_clear_msg_state(ahd);
ahd_outb(ahd, SIMODE1,
ahd_inb(ahd, SIMODE1) & ~(ENBUSFREE|ENSCSIRST));
if (initiate_reset)
ahd_reset_current_bus(ahd);
ahd_clear_intstat(ahd);
/*
* Clean up all the state information for the
* pending transactions on this bus.
*/
found = ahd_abort_scbs(ahd, CAM_TARGET_WILDCARD, channel,
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_UNKNOWN, CAM_SCSI_BUS_RESET);
/*
* Cleanup anything left in the FIFOs.
*/
ahd_clear_fifo(ahd, 0);
ahd_clear_fifo(ahd, 1);
/*
* Clear SCSI interrupt status
*/
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
/*
* Reenable selections
*/
ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
scsiseq = ahd_inb(ahd, SCSISEQ_TEMPLATE);
ahd_outb(ahd, SCSISEQ1, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP));
max_scsiid = (ahd->features & AHD_WIDE) ? 15 : 7;
#ifdef AHD_TARGET_MODE
/*
* Send an immediate notify ccb to all target more peripheral
* drivers affected by this action.
*/
for (target = 0; target <= max_scsiid; target++) {
struct ahd_tmode_tstate* tstate;
u_int lun;
tstate = ahd->enabled_targets[target];
if (tstate == NULL)
continue;
for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
struct ahd_tmode_lstate* lstate;
lstate = tstate->enabled_luns[lun];
if (lstate == NULL)
continue;
ahd_queue_lstate_event(ahd, lstate, CAM_TARGET_WILDCARD,
EVENT_TYPE_BUS_RESET, /*arg*/0);
ahd_send_lstate_events(ahd, lstate);
}
}
#endif
/*
* Revert to async/narrow transfers until we renegotiate.
*/
for (target = 0; target <= max_scsiid; target++) {
if (ahd->enabled_targets[target] == NULL)
continue;
for (initiator = 0; initiator <= max_scsiid; initiator++) {
struct ahd_devinfo devinfo;
ahd_compile_devinfo(&devinfo, target, initiator,
CAM_LUN_WILDCARD,
'A', ROLE_UNKNOWN);
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_CUR, /*paused*/TRUE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0,
/*offset*/0, /*ppr_options*/0,
AHD_TRANS_CUR, /*paused*/TRUE);
}
}
/* Notify the XPT that a bus reset occurred */
ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD, AC_BUS_RESET);
ahd_restart(ahd);
return (found);
}
/**************************** Statistics Processing ***************************/
static void
ahd_stat_timer(void *arg)
{
struct ahd_softc *ahd = arg;
u_long s;
int enint_coal;
ahd_lock(ahd, &s);
enint_coal = ahd->hs_mailbox & ENINT_COALESCE;
if (ahd->cmdcmplt_total > ahd->int_coalescing_threshold)
enint_coal |= ENINT_COALESCE;
else if (ahd->cmdcmplt_total < ahd->int_coalescing_stop_threshold)
enint_coal &= ~ENINT_COALESCE;
if (enint_coal != (ahd->hs_mailbox & ENINT_COALESCE)) {
ahd_enable_coalescing(ahd, enint_coal);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_INT_COALESCING) != 0)
printf("%s: Interrupt coalescing "
"now %sabled. Cmds %d\n",
ahd_name(ahd),
(enint_coal & ENINT_COALESCE) ? "en" : "dis",
ahd->cmdcmplt_total);
#endif
}
ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
ahd_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
ahd_stat_timer, ahd);
ahd_unlock(ahd, &s);
}
/****************************** Status Processing *****************************/
static void
ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
{
struct hardware_scb *hscb;
int paused;
/*
* The sequencer freezes its select-out queue
* anytime a SCSI status error occurs. We must
* handle the error and increment our qfreeze count
* to allow the sequencer to continue. We don't
* bother clearing critical sections here since all
* operations are on data structures that the sequencer
* is not touching once the queue is frozen.
*/
hscb = scb->hscb;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
/* Freeze the queue until the client sees the error. */
ahd_freeze_devq(ahd, scb);
ahd_freeze_scb(scb);
ahd->qfreeze_cnt++;
ahd_outw(ahd, KERNEL_QFREEZE_COUNT, ahd->qfreeze_cnt);
if (paused == 0)
ahd_unpause(ahd);
/* Don't want to clobber the original sense code */
if ((scb->flags & SCB_SENSE) != 0) {
/*
* Clear the SCB_SENSE Flag and perform
* a normal command completion.
*/
scb->flags &= ~SCB_SENSE;
ahd_set_transaction_status(scb, CAM_AUTOSENSE_FAIL);
ahd_done(ahd, scb);
return;
}
ahd_set_transaction_status(scb, CAM_SCSI_STATUS_ERROR);
ahd_set_scsi_status(scb, hscb->shared_data.istatus.scsi_status);
switch (hscb->shared_data.istatus.scsi_status) {
case STATUS_PKT_SENSE:
{
struct scsi_status_iu_header *siu;
ahd_sync_sense(ahd, scb, BUS_DMASYNC_POSTREAD);
siu = (struct scsi_status_iu_header *)scb->sense_data;
ahd_set_scsi_status(scb, siu->status);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
ahd_print_path(ahd, scb);
printf("SCB 0x%x Received PKT Status of 0x%x\n",
SCB_GET_TAG(scb), siu->status);
printf("\tflags = 0x%x, sense len = 0x%x, "
"pktfail = 0x%x\n",
siu->flags, scsi_4btoul(siu->sense_length),
scsi_4btoul(siu->pkt_failures_length));
}
#endif
if ((siu->flags & SIU_RSPVALID) != 0) {
ahd_print_path(ahd, scb);
if (scsi_4btoul(siu->pkt_failures_length) < 4) {
printf("Unable to parse pkt_failures\n");
} else {
switch (SIU_PKTFAIL_CODE(siu)) {
case SIU_PFC_NONE:
printf("No packet failure found\n");
break;
case SIU_PFC_CIU_FIELDS_INVALID:
printf("Invalid Command IU Field\n");
break;
case SIU_PFC_TMF_NOT_SUPPORTED:
printf("TMF not supportd\n");
break;
case SIU_PFC_TMF_FAILED:
printf("TMF failed\n");
break;
case SIU_PFC_INVALID_TYPE_CODE:
printf("Invalid L_Q Type code\n");
break;
case SIU_PFC_ILLEGAL_REQUEST:
printf("Illegal request\n");
default:
break;
}
}
if (siu->status == SCSI_STATUS_OK)
ahd_set_transaction_status(scb,
CAM_REQ_CMP_ERR);
}
if ((siu->flags & SIU_SNSVALID) != 0) {
scb->flags |= SCB_PKT_SENSE;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SENSE) != 0)
printf("Sense data available\n");
#endif
}
ahd_done(ahd, scb);
break;
}
case SCSI_STATUS_CMD_TERMINATED:
case SCSI_STATUS_CHECK_COND:
{
struct ahd_devinfo devinfo;
struct ahd_dma_seg *sg;
struct scsi_sense *sc;
struct ahd_initiator_tinfo *targ_info;
struct ahd_tmode_tstate *tstate;
struct ahd_transinfo *tinfo;
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_SENSE) {
ahd_print_path(ahd, scb);
printf("SCB %d: requests Check Status\n",
SCB_GET_TAG(scb));
}
#endif
if (ahd_perform_autosense(scb) == 0)
break;
ahd_compile_devinfo(&devinfo, SCB_GET_OUR_ID(scb),
SCB_GET_TARGET(ahd, scb),
SCB_GET_LUN(scb),
SCB_GET_CHANNEL(ahd, scb),
ROLE_INITIATOR);
targ_info = ahd_fetch_transinfo(ahd,
devinfo.channel,
devinfo.our_scsiid,
devinfo.target,
&tstate);
tinfo = &targ_info->curr;
sg = scb->sg_list;
sc = (struct scsi_sense *)hscb->shared_data.idata.cdb;
/*
* Save off the residual if there is one.
*/
ahd_update_residual(ahd, scb);
#ifdef AHD_DEBUG
if (ahd_debug & AHD_SHOW_SENSE) {
ahd_print_path(ahd, scb);
printf("Sending Sense\n");
}
#endif
scb->sg_count = 0;
sg = ahd_sg_setup(ahd, scb, sg, ahd_get_sense_bufaddr(ahd, scb),
ahd_get_sense_bufsize(ahd, scb),
/*last*/TRUE);
sc->opcode = REQUEST_SENSE;
sc->byte2 = 0;
if (tinfo->protocol_version <= SCSI_REV_2
&& SCB_GET_LUN(scb) < 8)
sc->byte2 = SCB_GET_LUN(scb) << 5;
sc->unused[0] = 0;
sc->unused[1] = 0;
sc->length = ahd_get_sense_bufsize(ahd, scb);
sc->control = 0;
/*
* We can't allow the target to disconnect.
* This will be an untagged transaction and
* having the target disconnect will make this
* transaction indestinguishable from outstanding
* tagged transactions.
*/
hscb->control = 0;
/*
* This request sense could be because the
* the device lost power or in some other
* way has lost our transfer negotiations.
* Renegotiate if appropriate. Unit attention
* errors will be reported before any data
* phases occur.
*/
if (ahd_get_residual(scb) == ahd_get_transfer_length(scb)) {
ahd_update_neg_request(ahd, &devinfo,
tstate, targ_info,
AHD_NEG_IF_NON_ASYNC);
}
if (tstate->auto_negotiate & devinfo.target_mask) {
hscb->control |= MK_MESSAGE;
scb->flags &=
~(SCB_NEGOTIATE|SCB_ABORT|SCB_DEVICE_RESET);
scb->flags |= SCB_AUTO_NEGOTIATE;
}
hscb->cdb_len = sizeof(*sc);
ahd_setup_data_scb(ahd, scb);
scb->flags |= SCB_SENSE;
ahd_queue_scb(ahd, scb);
break;
}
case SCSI_STATUS_OK:
printf("%s: Interrupted for staus of 0???\n",
ahd_name(ahd));
/* FALLTHROUGH */
default:
ahd_done(ahd, scb);
break;
}
}
static void
ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
{
if (scb->hscb->shared_data.istatus.scsi_status != 0) {
ahd_handle_scsi_status(ahd, scb);
} else {
ahd_calc_residual(ahd, scb);
ahd_done(ahd, scb);
}
}
/*
* Calculate the residual for a just completed SCB.
*/
static void
ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
{
struct hardware_scb *hscb;
struct initiator_status *spkt;
uint32_t sgptr;
uint32_t resid_sgptr;
uint32_t resid;
/*
* 5 cases.
* 1) No residual.
* SG_STATUS_VALID clear in sgptr.
* 2) Transferless command
* 3) Never performed any transfers.
* sgptr has SG_FULL_RESID set.
* 4) No residual but target did not
* save data pointers after the
* last transfer, so sgptr was
* never updated.
* 5) We have a partial residual.
* Use residual_sgptr to determine
* where we are.
*/
hscb = scb->hscb;
sgptr = ahd_le32toh(hscb->sgptr);
if ((sgptr & SG_STATUS_VALID) == 0)
/* Case 1 */
return;
sgptr &= ~SG_STATUS_VALID;
if ((sgptr & SG_LIST_NULL) != 0)
/* Case 2 */
return;
/*
* Residual fields are the same in both
* target and initiator status packets,
* so we can always use the initiator fields
* regardless of the role for this SCB.
*/
spkt = &hscb->shared_data.istatus;
resid_sgptr = ahd_le32toh(spkt->residual_sgptr);
if ((sgptr & SG_FULL_RESID) != 0) {
/* Case 3 */
resid = ahd_get_transfer_length(scb);
} else if ((resid_sgptr & SG_LIST_NULL) != 0) {
/* Case 4 */
return;
} else if ((resid_sgptr & SG_OVERRUN_RESID) != 0) {
ahd_print_path(ahd, scb);
printf("data overrun detected Tag == 0x%x.\n",
SCB_GET_TAG(scb));
ahd_freeze_devq(ahd, scb);
ahd_set_transaction_status(scb, CAM_DATA_RUN_ERR);
ahd_freeze_scb(scb);
return;
} else if ((resid_sgptr & ~SG_PTR_MASK) != 0) {
panic("Bogus resid sgptr value 0x%x\n", resid_sgptr);
/* NOTREACHED */
} else {
struct ahd_dma_seg *sg;
/*
* Remainder of the SG where the transfer
* stopped.
*/
resid = ahd_le32toh(spkt->residual_datacnt) & AHD_SG_LEN_MASK;
sg = ahd_sg_bus_to_virt(ahd, scb, resid_sgptr & SG_PTR_MASK);
/* The residual sg_ptr always points to the next sg */
sg--;
/*
* Add up the contents of all residual
* SG segments that are after the SG where
* the transfer stopped.
*/
while ((ahd_le32toh(sg->len) & AHD_DMA_LAST_SEG) == 0) {
sg++;
resid += ahd_le32toh(sg->len) & AHD_SG_LEN_MASK;
}
}
if ((scb->flags & SCB_SENSE) == 0)
ahd_set_residual(scb, resid);
else
ahd_set_sense_residual(scb, resid);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MISC) != 0) {
ahd_print_path(ahd, scb);
printf("Handled %sResidual of %d bytes\n",
(scb->flags & SCB_SENSE) ? "Sense " : "", resid);
}
#endif
}
/******************************* Target Mode **********************************/
#ifdef AHD_TARGET_MODE
/*
* Add a target mode event to this lun's queue
*/
static void
ahd_queue_lstate_event(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate,
u_int initiator_id, u_int event_type, u_int event_arg)
{
struct ahd_tmode_event *event;
int pending;
xpt_freeze_devq(lstate->path, /*count*/1);
if (lstate->event_w_idx >= lstate->event_r_idx)
pending = lstate->event_w_idx - lstate->event_r_idx;
else
pending = AHD_TMODE_EVENT_BUFFER_SIZE + 1
- (lstate->event_r_idx - lstate->event_w_idx);
if (event_type == EVENT_TYPE_BUS_RESET
|| event_type == MSG_BUS_DEV_RESET) {
/*
* Any earlier events are irrelevant, so reset our buffer.
* This has the effect of allowing us to deal with reset
* floods (an external device holding down the reset line)
* without losing the event that is really interesting.
*/
lstate->event_r_idx = 0;
lstate->event_w_idx = 0;
xpt_release_devq(lstate->path, pending, /*runqueue*/FALSE);
}
if (pending == AHD_TMODE_EVENT_BUFFER_SIZE) {
xpt_print_path(lstate->path);
printf("immediate event %x:%x lost\n",
lstate->event_buffer[lstate->event_r_idx].event_type,
lstate->event_buffer[lstate->event_r_idx].event_arg);
lstate->event_r_idx++;
if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_r_idx = 0;
xpt_release_devq(lstate->path, /*count*/1, /*runqueue*/FALSE);
}
event = &lstate->event_buffer[lstate->event_w_idx];
event->initiator_id = initiator_id;
event->event_type = event_type;
event->event_arg = event_arg;
lstate->event_w_idx++;
if (lstate->event_w_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_w_idx = 0;
}
/*
* Send any target mode events queued up waiting
* for immediate notify resources.
*/
void
ahd_send_lstate_events(struct ahd_softc *ahd, struct ahd_tmode_lstate *lstate)
{
struct ccb_hdr *ccbh;
struct ccb_immed_notify *inot;
while (lstate->event_r_idx != lstate->event_w_idx
&& (ccbh = SLIST_FIRST(&lstate->immed_notifies)) != NULL) {
struct ahd_tmode_event *event;
event = &lstate->event_buffer[lstate->event_r_idx];
SLIST_REMOVE_HEAD(&lstate->immed_notifies, sim_links.sle);
inot = (struct ccb_immed_notify *)ccbh;
switch (event->event_type) {
case EVENT_TYPE_BUS_RESET:
ccbh->status = CAM_SCSI_BUS_RESET|CAM_DEV_QFRZN;
break;
default:
ccbh->status = CAM_MESSAGE_RECV|CAM_DEV_QFRZN;
inot->message_args[0] = event->event_type;
inot->message_args[1] = event->event_arg;
break;
}
inot->initiator_id = event->initiator_id;
inot->sense_len = 0;
xpt_done((union ccb *)inot);
lstate->event_r_idx++;
if (lstate->event_r_idx == AHD_TMODE_EVENT_BUFFER_SIZE)
lstate->event_r_idx = 0;
}
}
#endif
/******************** Sequencer Program Patching/Download *********************/
#ifdef AHD_DUMP_SEQ
void
ahd_dumpseq(struct ahd_softc* ahd)
{
int i;
int max_prog;
max_prog = 2048;
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
ahd_outw(ahd, PRGMCNT, 0);
for (i = 0; i < max_prog; i++) {
uint8_t ins_bytes[4];
ahd_insb(ahd, SEQRAM, ins_bytes, 4);
printf("0x%08x\n", ins_bytes[0] << 24
| ins_bytes[1] << 16
| ins_bytes[2] << 8
| ins_bytes[3]);
}
}
#endif
static void
ahd_loadseq(struct ahd_softc *ahd)
{
struct cs cs_table[num_critical_sections];
u_int begin_set[num_critical_sections];
u_int end_set[num_critical_sections];
struct patch *cur_patch;
u_int cs_count;
u_int cur_cs;
u_int i;
int downloaded;
u_int skip_addr;
u_int sg_prefetch_cnt;
u_int sg_prefetch_cnt_limit;
u_int sg_prefetch_align;
u_int sg_size;
u_int cacheline_mask;
uint8_t download_consts[DOWNLOAD_CONST_COUNT];
if (bootverbose)
printf("%s: Downloading Sequencer Program...",
ahd_name(ahd));
#if DOWNLOAD_CONST_COUNT != 8
#error "Download Const Mismatch"
#endif
/*
* Start out with 0 critical sections
* that apply to this firmware load.
*/
cs_count = 0;
cur_cs = 0;
memset(begin_set, 0, sizeof(begin_set));
memset(end_set, 0, sizeof(end_set));
/*
* Setup downloadable constant table.
*
* The computation for the S/G prefetch variables is
* a bit complicated. We would like to always fetch
* in terms of cachelined sized increments. However,
* if the cacheline is not an even multiple of the
* SG element size or is larger than our SG RAM, using
* just the cache size might leave us with only a portion
* of an SG element at the tail of a prefetch. If the
* cacheline is larger than our S/G prefetch buffer less
* the size of an SG element, we may round down to a cacheline
* that doesn't contain any or all of the S/G of interest
* within the bounds of our S/G ram. Provide variables to
* the sequencer that will allow it to handle these edge
* cases.
*/
/* Start by aligning to the nearest cacheline. */
sg_prefetch_align = ahd->pci_cachesize;
if (sg_prefetch_align == 0)
sg_prefetch_align = 8;
/* Round down to the nearest power of 2. */
while (powerof2(sg_prefetch_align) == 0)
sg_prefetch_align--;
cacheline_mask = sg_prefetch_align - 1;
/*
* If the cacheline boundary is greater than half our prefetch RAM
* we risk not being able to fetch even a single complete S/G
* segment if we align to that boundary.
*/
if (sg_prefetch_align > CCSGADDR_MAX/2)
sg_prefetch_align = CCSGADDR_MAX/2;
/* Start by fetching a single cacheline. */
sg_prefetch_cnt = sg_prefetch_align;
/*
* Increment the prefetch count by cachelines until
* at least one S/G element will fit.
*/
sg_size = sizeof(struct ahd_dma_seg);
if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
sg_size = sizeof(struct ahd_dma64_seg);
while (sg_prefetch_cnt < sg_size)
sg_prefetch_cnt += sg_prefetch_align;
/*
* If the cacheline is not an even multiple of
* the S/G size, we may only get a partial S/G when
* we align. Add a cacheline if this is the case.
*/
if ((sg_prefetch_align % sg_size) != 0
&& (sg_prefetch_cnt < CCSGADDR_MAX))
sg_prefetch_cnt += sg_prefetch_align;
/*
* Lastly, compute a value that the sequencer can use
* to determine if the remainder of the CCSGRAM buffer
* has a full S/G element in it.
*/
sg_prefetch_cnt_limit = -(sg_prefetch_cnt - sg_size + 1);
download_consts[SG_PREFETCH_CNT] = sg_prefetch_cnt;
download_consts[SG_PREFETCH_CNT_LIMIT] = sg_prefetch_cnt_limit;
download_consts[SG_PREFETCH_ALIGN_MASK] = ~(sg_prefetch_align - 1);
download_consts[SG_PREFETCH_ADDR_MASK] = (sg_prefetch_align - 1);
download_consts[SG_SIZEOF] = sg_size;
download_consts[PKT_OVERRUN_BUFOFFSET] =
(ahd->overrun_buf - (uint8_t *)ahd->qoutfifo) / 256;
download_consts[SCB_TRANSFER_SIZE] = SCB_TRANSFER_SIZE_1BYTE_LUN;
download_consts[CACHELINE_MASK] = cacheline_mask;
cur_patch = patches;
downloaded = 0;
skip_addr = 0;
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
ahd_outw(ahd, PRGMCNT, 0);
for (i = 0; i < sizeof(seqprog)/4; i++) {
if (ahd_check_patch(ahd, &cur_patch, i, &skip_addr) == 0) {
/*
* Don't download this instruction as it
* is in a patch that was removed.
*/
continue;
}
/*
* Move through the CS table until we find a CS
* that might apply to this instruction.
*/
for (; cur_cs < num_critical_sections; cur_cs++) {
if (critical_sections[cur_cs].end <= i) {
if (begin_set[cs_count] == TRUE
&& end_set[cs_count] == FALSE) {
cs_table[cs_count].end = downloaded;
end_set[cs_count] = TRUE;
cs_count++;
}
continue;
}
if (critical_sections[cur_cs].begin <= i
&& begin_set[cs_count] == FALSE) {
cs_table[cs_count].begin = downloaded;
begin_set[cs_count] = TRUE;
}
break;
}
ahd_download_instr(ahd, i, download_consts);
downloaded++;
}
ahd->num_critical_sections = cs_count;
if (cs_count != 0) {
cs_count *= sizeof(struct cs);
ahd->critical_sections = malloc(cs_count, M_DEVBUF, M_NOWAIT);
if (ahd->critical_sections == NULL)
panic("ahd_loadseq: Could not malloc");
memcpy(ahd->critical_sections, cs_table, cs_count);
}
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
if (bootverbose) {
printf(" %d instructions downloaded\n", downloaded);
printf("%s: Features 0x%x, Bugs 0x%x, Flags 0x%x\n",
ahd_name(ahd), ahd->features, ahd->bugs, ahd->flags);
}
}
static int
ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
u_int start_instr, u_int *skip_addr)
{
struct patch *cur_patch;
struct patch *last_patch;
u_int num_patches;
num_patches = ARRAY_SIZE(patches);
last_patch = &patches[num_patches];
cur_patch = *start_patch;
while (cur_patch < last_patch && start_instr == cur_patch->begin) {
if (cur_patch->patch_func(ahd) == 0) {
/* Start rejecting code */
*skip_addr = start_instr + cur_patch->skip_instr;
cur_patch += cur_patch->skip_patch;
} else {
/* Accepted this patch. Advance to the next
* one and wait for our intruction pointer to
* hit this point.
*/
cur_patch++;
}
}
*start_patch = cur_patch;
if (start_instr < *skip_addr)
/* Still skipping */
return (0);
return (1);
}
static u_int
ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
{
struct patch *cur_patch;
int address_offset;
u_int skip_addr;
u_int i;
address_offset = 0;
cur_patch = patches;
skip_addr = 0;
for (i = 0; i < address;) {
ahd_check_patch(ahd, &cur_patch, i, &skip_addr);
if (skip_addr > i) {
int end_addr;
end_addr = min(address, skip_addr);
address_offset += end_addr - i;
i = skip_addr;
} else {
i++;
}
}
return (address - address_offset);
}
static void
ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
{
union ins_formats instr;
struct ins_format1 *fmt1_ins;
struct ins_format3 *fmt3_ins;
u_int opcode;
/*
* The firmware is always compiled into a little endian format.
*/
instr.integer = ahd_le32toh(*(uint32_t*)&seqprog[instrptr * 4]);
fmt1_ins = &instr.format1;
fmt3_ins = NULL;
/* Pull the opcode */
opcode = instr.format1.opcode;
switch (opcode) {
case AIC_OP_JMP:
case AIC_OP_JC:
case AIC_OP_JNC:
case AIC_OP_CALL:
case AIC_OP_JNE:
case AIC_OP_JNZ:
case AIC_OP_JE:
case AIC_OP_JZ:
{
fmt3_ins = &instr.format3;
fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
/* FALLTHROUGH */
}
case AIC_OP_OR:
case AIC_OP_AND:
case AIC_OP_XOR:
case AIC_OP_ADD:
case AIC_OP_ADC:
case AIC_OP_BMOV:
if (fmt1_ins->parity != 0) {
fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
}
fmt1_ins->parity = 0;
/* FALLTHROUGH */
case AIC_OP_ROL:
{
int i, count;
/* Calculate odd parity for the instruction */
for (i = 0, count = 0; i < 31; i++) {
uint32_t mask;
mask = 0x01 << i;
if ((instr.integer & mask) != 0)
count++;
}
if ((count & 0x01) == 0)
instr.format1.parity = 1;
/* The sequencer is a little endian cpu */
instr.integer = ahd_htole32(instr.integer);
ahd_outsb(ahd, SEQRAM, instr.bytes, 4);
break;
}
default:
panic("Unknown opcode encountered in seq program");
break;
}
}
static int
ahd_probe_stack_size(struct ahd_softc *ahd)
{
int last_probe;
last_probe = 0;
while (1) {
int i;
/*
* We avoid using 0 as a pattern to avoid
* confusion if the stack implementation
* "back-fills" with zeros when "poping'
* entries.
*/
for (i = 1; i <= last_probe+1; i++) {
ahd_outb(ahd, STACK, i & 0xFF);
ahd_outb(ahd, STACK, (i >> 8) & 0xFF);
}
/* Verify */
for (i = last_probe+1; i > 0; i--) {
u_int stack_entry;
stack_entry = ahd_inb(ahd, STACK)
|(ahd_inb(ahd, STACK) << 8);
if (stack_entry != i)
goto sized;
}
last_probe++;
}
sized:
return (last_probe);
}
int
ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries,
const char *name, u_int address, u_int value,
u_int *cur_column, u_int wrap_point)
{
int printed;
u_int printed_mask;
if (cur_column != NULL && *cur_column >= wrap_point) {
printf("\n");
*cur_column = 0;
}
printed = printf("%s[0x%x]", name, value);
if (table == NULL) {
printed += printf(" ");
*cur_column += printed;
return (printed);
}
printed_mask = 0;
while (printed_mask != 0xFF) {
int entry;
for (entry = 0; entry < num_entries; entry++) {
if (((value & table[entry].mask)
!= table[entry].value)
|| ((printed_mask & table[entry].mask)
== table[entry].mask))
continue;
printed += printf("%s%s",
printed_mask == 0 ? ":(" : "|",
table[entry].name);
printed_mask |= table[entry].mask;
break;
}
if (entry >= num_entries)
break;
}
if (printed_mask != 0)
printed += printf(") ");
else
printed += printf(" ");
if (cur_column != NULL)
*cur_column += printed;
return (printed);
}
void
ahd_dump_card_state(struct ahd_softc *ahd)
{
struct scb *scb;
ahd_mode_state saved_modes;
u_int dffstat;
int paused;
u_int scb_index;
u_int saved_scb_index;
u_int cur_col;
int i;
if (ahd_is_paused(ahd)) {
paused = 1;
} else {
paused = 0;
ahd_pause(ahd);
}
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
printf(">>>>>>>>>>>>>>>>>> Dump Card State Begins <<<<<<<<<<<<<<<<<\n"
"%s: Dumping Card State at program address 0x%x Mode 0x%x\n",
ahd_name(ahd),
ahd_inw(ahd, CURADDR),
ahd_build_mode_state(ahd, ahd->saved_src_mode,
ahd->saved_dst_mode));
if (paused)
printf("Card was paused\n");
if (ahd_check_cmdcmpltqueues(ahd))
printf("Completions are pending\n");
/*
* Mode independent registers.
*/
cur_col = 0;
ahd_intstat_print(ahd_inb(ahd, INTSTAT), &cur_col, 50);
ahd_seloid_print(ahd_inb(ahd, SELOID), &cur_col, 50);
ahd_selid_print(ahd_inb(ahd, SELID), &cur_col, 50);
ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50);
ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50);
ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50);
ahd_saved_mode_print(ahd_inb(ahd, SAVED_MODE), &cur_col, 50);
ahd_dffstat_print(ahd_inb(ahd, DFFSTAT), &cur_col, 50);
ahd_scsisigi_print(ahd_inb(ahd, SCSISIGI), &cur_col, 50);
ahd_scsiphase_print(ahd_inb(ahd, SCSIPHASE), &cur_col, 50);
ahd_scsibus_print(ahd_inb(ahd, SCSIBUS), &cur_col, 50);
ahd_lastphase_print(ahd_inb(ahd, LASTPHASE), &cur_col, 50);
ahd_scsiseq0_print(ahd_inb(ahd, SCSISEQ0), &cur_col, 50);
ahd_scsiseq1_print(ahd_inb(ahd, SCSISEQ1), &cur_col, 50);
ahd_seqctl0_print(ahd_inb(ahd, SEQCTL0), &cur_col, 50);
ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50);
ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50);
ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50);
ahd_qfreeze_count_print(ahd_inw(ahd, QFREEZE_COUNT), &cur_col, 50);
ahd_kernel_qfreeze_count_print(ahd_inw(ahd, KERNEL_QFREEZE_COUNT),
&cur_col, 50);
ahd_mk_message_scb_print(ahd_inw(ahd, MK_MESSAGE_SCB), &cur_col, 50);
ahd_mk_message_scsiid_print(ahd_inb(ahd, MK_MESSAGE_SCSIID),
&cur_col, 50);
ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50);
ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50);
ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50);
ahd_sstat3_print(ahd_inb(ahd, SSTAT3), &cur_col, 50);
ahd_perrdiag_print(ahd_inb(ahd, PERRDIAG), &cur_col, 50);
ahd_simode1_print(ahd_inb(ahd, SIMODE1), &cur_col, 50);
ahd_lqistat0_print(ahd_inb(ahd, LQISTAT0), &cur_col, 50);
ahd_lqistat1_print(ahd_inb(ahd, LQISTAT1), &cur_col, 50);
ahd_lqistat2_print(ahd_inb(ahd, LQISTAT2), &cur_col, 50);
ahd_lqostat0_print(ahd_inb(ahd, LQOSTAT0), &cur_col, 50);
ahd_lqostat1_print(ahd_inb(ahd, LQOSTAT1), &cur_col, 50);
ahd_lqostat2_print(ahd_inb(ahd, LQOSTAT2), &cur_col, 50);
printf("\n");
printf("\nSCB Count = %d CMDS_PENDING = %d LASTSCB 0x%x "
"CURRSCB 0x%x NEXTSCB 0x%x\n",
ahd->scb_data.numscbs, ahd_inw(ahd, CMDS_PENDING),
ahd_inw(ahd, LASTSCB), ahd_inw(ahd, CURRSCB),
ahd_inw(ahd, NEXTSCB));
cur_col = 0;
/* QINFIFO */
ahd_search_qinfifo(ahd, CAM_TARGET_WILDCARD, ALL_CHANNELS,
CAM_LUN_WILDCARD, SCB_LIST_NULL,
ROLE_UNKNOWN, /*status*/0, SEARCH_PRINT);
saved_scb_index = ahd_get_scbptr(ahd);
printf("Pending list:");
i = 0;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
if (i++ > AHD_SCB_MAX)
break;
cur_col = printf("\n%3d FIFO_USE[0x%x] ", SCB_GET_TAG(scb),
ahd_inb_scbram(ahd, SCB_FIFO_USE_COUNT));
ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
ahd_scb_control_print(ahd_inb_scbram(ahd, SCB_CONTROL),
&cur_col, 60);
ahd_scb_scsiid_print(ahd_inb_scbram(ahd, SCB_SCSIID),
&cur_col, 60);
}
printf("\nTotal %d\n", i);
printf("Kernel Free SCB list: ");
i = 0;
TAILQ_FOREACH(scb, &ahd->scb_data.free_scbs, links.tqe) {
struct scb *list_scb;
list_scb = scb;
do {
printf("%d ", SCB_GET_TAG(list_scb));
list_scb = LIST_NEXT(list_scb, collision_links);
} while (list_scb && i++ < AHD_SCB_MAX);
}
LIST_FOREACH(scb, &ahd->scb_data.any_dev_free_scb_list, links.le) {
if (i++ > AHD_SCB_MAX)
break;
printf("%d ", SCB_GET_TAG(scb));
}
printf("\n");
printf("Sequencer Complete DMA-inprog list: ");
scb_index = ahd_inw(ahd, COMPLETE_SCB_DMAINPROG_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printf("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printf("\n");
printf("Sequencer Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_SCB_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printf("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printf("\n");
printf("Sequencer DMA-Up and Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_DMA_SCB_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printf("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printf("\n");
printf("Sequencer On QFreeze and Complete list: ");
scb_index = ahd_inw(ahd, COMPLETE_ON_QFREEZE_HEAD);
i = 0;
while (!SCBID_IS_NULL(scb_index) && i++ < AHD_SCB_MAX) {
ahd_set_scbptr(ahd, scb_index);
printf("%d ", scb_index);
scb_index = ahd_inw_scbram(ahd, SCB_NEXT_COMPLETE);
}
printf("\n");
ahd_set_scbptr(ahd, saved_scb_index);
dffstat = ahd_inb(ahd, DFFSTAT);
for (i = 0; i < 2; i++) {
#ifdef AHD_DEBUG
struct scb *fifo_scb;
#endif
u_int fifo_scbptr;
ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
fifo_scbptr = ahd_get_scbptr(ahd);
printf("\n\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
ahd_name(ahd), i,
(dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
cur_col = 0;
ahd_seqimode_print(ahd_inb(ahd, SEQIMODE), &cur_col, 50);
ahd_seqintsrc_print(ahd_inb(ahd, SEQINTSRC), &cur_col, 50);
ahd_dfcntrl_print(ahd_inb(ahd, DFCNTRL), &cur_col, 50);
ahd_dfstatus_print(ahd_inb(ahd, DFSTATUS), &cur_col, 50);
ahd_sg_cache_shadow_print(ahd_inb(ahd, SG_CACHE_SHADOW),
&cur_col, 50);
ahd_sg_state_print(ahd_inb(ahd, SG_STATE), &cur_col, 50);
ahd_dffsxfrctl_print(ahd_inb(ahd, DFFSXFRCTL), &cur_col, 50);
ahd_soffcnt_print(ahd_inb(ahd, SOFFCNT), &cur_col, 50);
ahd_mdffstat_print(ahd_inb(ahd, MDFFSTAT), &cur_col, 50);
if (cur_col > 50) {
printf("\n");
cur_col = 0;
}
cur_col += printf("SHADDR = 0x%x%x, SHCNT = 0x%x ",
ahd_inl(ahd, SHADDR+4),
ahd_inl(ahd, SHADDR),
(ahd_inb(ahd, SHCNT)
| (ahd_inb(ahd, SHCNT + 1) << 8)
| (ahd_inb(ahd, SHCNT + 2) << 16)));
if (cur_col > 50) {
printf("\n");
cur_col = 0;
}
cur_col += printf("HADDR = 0x%x%x, HCNT = 0x%x ",
ahd_inl(ahd, HADDR+4),
ahd_inl(ahd, HADDR),
(ahd_inb(ahd, HCNT)
| (ahd_inb(ahd, HCNT + 1) << 8)
| (ahd_inb(ahd, HCNT + 2) << 16)));
ahd_ccsgctl_print(ahd_inb(ahd, CCSGCTL), &cur_col, 50);
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_SG) != 0) {
fifo_scb = ahd_lookup_scb(ahd, fifo_scbptr);
if (fifo_scb != NULL)
ahd_dump_sglist(fifo_scb);
}
#endif
}
printf("\nLQIN: ");
for (i = 0; i < 20; i++)
printf("0x%x ", ahd_inb(ahd, LQIN + i));
printf("\n");
ahd_set_modes(ahd, AHD_MODE_CFG, AHD_MODE_CFG);
printf("%s: LQISTATE = 0x%x, LQOSTATE = 0x%x, OPTIONMODE = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, LQISTATE), ahd_inb(ahd, LQOSTATE),
ahd_inb(ahd, OPTIONMODE));
printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
ahd_inb(ahd, MAXCMDCNT));
printf("%s: SAVED_SCSIID = 0x%x SAVED_LUN = 0x%x\n",
ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID),
ahd_inb(ahd, SAVED_LUN));
ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
printf("\n");
ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
cur_col = 0;
ahd_ccscbctl_print(ahd_inb(ahd, CCSCBCTL), &cur_col, 50);
printf("\n");
ahd_set_modes(ahd, ahd->saved_src_mode, ahd->saved_dst_mode);
printf("%s: REG0 == 0x%x, SINDEX = 0x%x, DINDEX = 0x%x\n",
ahd_name(ahd), ahd_inw(ahd, REG0), ahd_inw(ahd, SINDEX),
ahd_inw(ahd, DINDEX));
printf("%s: SCBPTR == 0x%x, SCB_NEXT == 0x%x, SCB_NEXT2 == 0x%x\n",
ahd_name(ahd), ahd_get_scbptr(ahd),
ahd_inw_scbram(ahd, SCB_NEXT),
ahd_inw_scbram(ahd, SCB_NEXT2));
printf("CDB %x %x %x %x %x %x\n",
ahd_inb_scbram(ahd, SCB_CDB_STORE),
ahd_inb_scbram(ahd, SCB_CDB_STORE+1),
ahd_inb_scbram(ahd, SCB_CDB_STORE+2),
ahd_inb_scbram(ahd, SCB_CDB_STORE+3),
ahd_inb_scbram(ahd, SCB_CDB_STORE+4),
ahd_inb_scbram(ahd, SCB_CDB_STORE+5));
printf("STACK:");
for (i = 0; i < ahd->stack_size; i++) {
ahd->saved_stack[i] =
ahd_inb(ahd, STACK)|(ahd_inb(ahd, STACK) << 8);
printf(" 0x%x", ahd->saved_stack[i]);
}
for (i = ahd->stack_size-1; i >= 0; i--) {
ahd_outb(ahd, STACK, ahd->saved_stack[i] & 0xFF);
ahd_outb(ahd, STACK, (ahd->saved_stack[i] >> 8) & 0xFF);
}
printf("\n<<<<<<<<<<<<<<<<< Dump Card State Ends >>>>>>>>>>>>>>>>>>\n");
ahd_restore_modes(ahd, saved_modes);
if (paused == 0)
ahd_unpause(ahd);
}
#if 0
void
ahd_dump_scbs(struct ahd_softc *ahd)
{
ahd_mode_state saved_modes;
u_int saved_scb_index;
int i;
saved_modes = ahd_save_modes(ahd);
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
saved_scb_index = ahd_get_scbptr(ahd);
for (i = 0; i < AHD_SCB_MAX; i++) {
ahd_set_scbptr(ahd, i);
printf("%3d", i);
printf("(CTRL 0x%x ID 0x%x N 0x%x N2 0x%x SG 0x%x, RSG 0x%x)\n",
ahd_inb_scbram(ahd, SCB_CONTROL),
ahd_inb_scbram(ahd, SCB_SCSIID),
ahd_inw_scbram(ahd, SCB_NEXT),
ahd_inw_scbram(ahd, SCB_NEXT2),
ahd_inl_scbram(ahd, SCB_SGPTR),
ahd_inl_scbram(ahd, SCB_RESIDUAL_SGPTR));
}
printf("\n");
ahd_set_scbptr(ahd, saved_scb_index);
ahd_restore_modes(ahd, saved_modes);
}
#endif /* 0 */
/**************************** Flexport Logic **********************************/
/*
* Read count 16bit words from 16bit word address start_addr from the
* SEEPROM attached to the controller, into buf, using the controller's
* SEEPROM reading state machine. Optionally treat the data as a byte
* stream in terms of byte order.
*/
int
ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
u_int start_addr, u_int count, int bytestream)
{
u_int cur_addr;
u_int end_addr;
int error;
/*
* If we never make it through the loop even once,
* we were passed invalid arguments.
*/
error = EINVAL;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
end_addr = start_addr + count;
for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
ahd_outb(ahd, SEEADR, cur_addr);
ahd_outb(ahd, SEECTL, SEEOP_READ | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
break;
if (bytestream != 0) {
uint8_t *bytestream_ptr;
bytestream_ptr = (uint8_t *)buf;
*bytestream_ptr++ = ahd_inb(ahd, SEEDAT);
*bytestream_ptr = ahd_inb(ahd, SEEDAT+1);
} else {
/*
* ahd_inw() already handles machine byte order.
*/
*buf = ahd_inw(ahd, SEEDAT);
}
buf++;
}
return (error);
}
/*
* Write count 16bit words from buf, into SEEPROM attache to the
* controller starting at 16bit word address start_addr, using the
* controller's SEEPROM writing state machine.
*/
int
ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
u_int start_addr, u_int count)
{
u_int cur_addr;
u_int end_addr;
int error;
int retval;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
error = ENOENT;
/* Place the chip into write-enable mode */
ahd_outb(ahd, SEEADR, SEEOP_EWEN_ADDR);
ahd_outb(ahd, SEECTL, SEEOP_EWEN | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
return (error);
/*
* Write the data. If we don't get throught the loop at
* least once, the arguments were invalid.
*/
retval = EINVAL;
end_addr = start_addr + count;
for (cur_addr = start_addr; cur_addr < end_addr; cur_addr++) {
ahd_outw(ahd, SEEDAT, *buf++);
ahd_outb(ahd, SEEADR, cur_addr);
ahd_outb(ahd, SEECTL, SEEOP_WRITE | SEESTART);
retval = ahd_wait_seeprom(ahd);
if (retval)
break;
}
/*
* Disable writes.
*/
ahd_outb(ahd, SEEADR, SEEOP_EWDS_ADDR);
ahd_outb(ahd, SEECTL, SEEOP_EWDS | SEESTART);
error = ahd_wait_seeprom(ahd);
if (error)
return (error);
return (retval);
}
/*
* Wait ~100us for the serial eeprom to satisfy our request.
*/
static int
ahd_wait_seeprom(struct ahd_softc *ahd)
{
int cnt;
cnt = 5000;
while ((ahd_inb(ahd, SEESTAT) & (SEEARBACK|SEEBUSY)) != 0 && --cnt)
ahd_delay(5);
if (cnt == 0)
return (ETIMEDOUT);
return (0);
}
/*
* Validate the two checksums in the per_channel
* vital product data struct.
*/
static int
ahd_verify_vpd_cksum(struct vpd_config *vpd)
{
int i;
int maxaddr;
uint32_t checksum;
uint8_t *vpdarray;
vpdarray = (uint8_t *)vpd;
maxaddr = offsetof(struct vpd_config, vpd_checksum);
checksum = 0;
for (i = offsetof(struct vpd_config, resource_type); i < maxaddr; i++)
checksum = checksum + vpdarray[i];
if (checksum == 0
|| (-checksum & 0xFF) != vpd->vpd_checksum)
return (0);
checksum = 0;
maxaddr = offsetof(struct vpd_config, checksum);
for (i = offsetof(struct vpd_config, default_target_flags);
i < maxaddr; i++)
checksum = checksum + vpdarray[i];
if (checksum == 0
|| (-checksum & 0xFF) != vpd->checksum)
return (0);
return (1);
}
int
ahd_verify_cksum(struct seeprom_config *sc)
{
int i;
int maxaddr;
uint32_t checksum;
uint16_t *scarray;
maxaddr = (sizeof(*sc)/2) - 1;
checksum = 0;
scarray = (uint16_t *)sc;
for (i = 0; i < maxaddr; i++)
checksum = checksum + scarray[i];
if (checksum == 0
|| (checksum & 0xFFFF) != sc->checksum) {
return (0);
} else {
return (1);
}
}
int
ahd_acquire_seeprom(struct ahd_softc *ahd)
{
/*
* We should be able to determine the SEEPROM type
* from the flexport logic, but unfortunately not
* all implementations have this logic and there is
* no programatic method for determining if the logic
* is present.
*/
return (1);
#if 0
uint8_t seetype;
int error;
error = ahd_read_flexport(ahd, FLXADDR_ROMSTAT_CURSENSECTL, &seetype);
if (error != 0
|| ((seetype & FLX_ROMSTAT_SEECFG) == FLX_ROMSTAT_SEE_NONE))
return (0);
return (1);
#endif
}
void
ahd_release_seeprom(struct ahd_softc *ahd)
{
/* Currently a no-op */
}
/*
* Wait at most 2 seconds for flexport arbitration to succeed.
*/
static int
ahd_wait_flexport(struct ahd_softc *ahd)
{
int cnt;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
cnt = 1000000 * 2 / 5;
while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
ahd_delay(5);
if (cnt == 0)
return (ETIMEDOUT);
return (0);
}
int
ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
{
int error;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (addr > 7)
panic("ahd_write_flexport: address out of range");
ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
error = ahd_wait_flexport(ahd);
if (error != 0)
return (error);
ahd_outb(ahd, BRDDAT, value);
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, BRDSTB|BRDEN|(addr << 3));
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, BRDEN|(addr << 3));
ahd_flush_device_writes(ahd);
ahd_outb(ahd, BRDCTL, 0);
ahd_flush_device_writes(ahd);
return (0);
}
int
ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
{
int error;
AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
if (addr > 7)
panic("ahd_read_flexport: address out of range");
ahd_outb(ahd, BRDCTL, BRDRW|BRDEN|(addr << 3));
error = ahd_wait_flexport(ahd);
if (error != 0)
return (error);
*value = ahd_inb(ahd, BRDDAT);
ahd_outb(ahd, BRDCTL, 0);
ahd_flush_device_writes(ahd);
return (0);
}
/************************* Target Mode ****************************************/
#ifdef AHD_TARGET_MODE
cam_status
ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb,
struct ahd_tmode_tstate **tstate,
struct ahd_tmode_lstate **lstate,
int notfound_failure)
{
if ((ahd->features & AHD_TARGETMODE) == 0)
return (CAM_REQ_INVALID);
/*
* Handle the 'black hole' device that sucks up
* requests to unattached luns on enabled targets.
*/
if (ccb->ccb_h.target_id == CAM_TARGET_WILDCARD
&& ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) {
*tstate = NULL;
*lstate = ahd->black_hole;
} else {
u_int max_id;
max_id = (ahd->features & AHD_WIDE) ? 16 : 8;
if (ccb->ccb_h.target_id >= max_id)
return (CAM_TID_INVALID);
if (ccb->ccb_h.target_lun >= AHD_NUM_LUNS)
return (CAM_LUN_INVALID);
*tstate = ahd->enabled_targets[ccb->ccb_h.target_id];
*lstate = NULL;
if (*tstate != NULL)
*lstate =
(*tstate)->enabled_luns[ccb->ccb_h.target_lun];
}
if (notfound_failure != 0 && *lstate == NULL)
return (CAM_PATH_INVALID);
return (CAM_REQ_CMP);
}
void
ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
{
#if NOT_YET
struct ahd_tmode_tstate *tstate;
struct ahd_tmode_lstate *lstate;
struct ccb_en_lun *cel;
cam_status status;
u_int target;
u_int lun;
u_int target_mask;
u_long s;
char channel;
status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate, &lstate,
/*notfound_failure*/FALSE);
if (status != CAM_REQ_CMP) {
ccb->ccb_h.status = status;
return;
}
if ((ahd->features & AHD_MULTIROLE) != 0) {
u_int our_id;
our_id = ahd->our_id;
if (ccb->ccb_h.target_id != our_id) {
if ((ahd->features & AHD_MULTI_TID) != 0
&& (ahd->flags & AHD_INITIATORROLE) != 0) {
/*
* Only allow additional targets if
* the initiator role is disabled.
* The hardware cannot handle a re-select-in
* on the initiator id during a re-select-out
* on a different target id.
*/
status = CAM_TID_INVALID;
} else if ((ahd->flags & AHD_INITIATORROLE) != 0
|| ahd->enabled_luns > 0) {
/*
* Only allow our target id to change
* if the initiator role is not configured
* and there are no enabled luns which
* are attached to the currently registered
* scsi id.
*/
status = CAM_TID_INVALID;
}
}
}
if (status != CAM_REQ_CMP) {
ccb->ccb_h.status = status;
return;
}
/*
* We now have an id that is valid.
* If we aren't in target mode, switch modes.
*/
if ((ahd->flags & AHD_TARGETROLE) == 0
&& ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
u_long s;
printf("Configuring Target Mode\n");
ahd_lock(ahd, &s);
if (LIST_FIRST(&ahd->pending_scbs) != NULL) {
ccb->ccb_h.status = CAM_BUSY;
ahd_unlock(ahd, &s);
return;
}
ahd->flags |= AHD_TARGETROLE;
if ((ahd->features & AHD_MULTIROLE) == 0)
ahd->flags &= ~AHD_INITIATORROLE;
ahd_pause(ahd);
ahd_loadseq(ahd);
ahd_restart(ahd);
ahd_unlock(ahd, &s);
}
cel = &ccb->cel;
target = ccb->ccb_h.target_id;
lun = ccb->ccb_h.target_lun;
channel = SIM_CHANNEL(ahd, sim);
target_mask = 0x01 << target;
if (channel == 'B')
target_mask <<= 8;
if (cel->enable != 0) {
u_int scsiseq1;
/* Are we already enabled?? */
if (lstate != NULL) {
xpt_print_path(ccb->ccb_h.path);
printf("Lun already enabled\n");
ccb->ccb_h.status = CAM_LUN_ALRDY_ENA;
return;
}
if (cel->grp6_len != 0
|| cel->grp7_len != 0) {
/*
* Don't (yet?) support vendor
* specific commands.
*/
ccb->ccb_h.status = CAM_REQ_INVALID;
printf("Non-zero Group Codes\n");
return;
}
/*
* Seems to be okay.
* Setup our data structures.
*/
if (target != CAM_TARGET_WILDCARD && tstate == NULL) {
tstate = ahd_alloc_tstate(ahd, target, channel);
if (tstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printf("Couldn't allocate tstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
}
lstate = malloc(sizeof(*lstate), M_DEVBUF, M_NOWAIT);
if (lstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printf("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(&lstate->path, /*periph*/NULL,
xpt_path_path_id(ccb->ccb_h.path),
xpt_path_target_id(ccb->ccb_h.path),
xpt_path_lun_id(ccb->ccb_h.path));
if (status != CAM_REQ_CMP) {
free(lstate, M_DEVBUF);
xpt_print_path(ccb->ccb_h.path);
printf("Couldn't allocate path\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
SLIST_INIT(&lstate->accept_tios);
SLIST_INIT(&lstate->immed_notifies);
ahd_lock(ahd, &s);
ahd_pause(ahd);
if (target != CAM_TARGET_WILDCARD) {
tstate->enabled_luns[lun] = lstate;
ahd->enabled_luns++;
if ((ahd->features & AHD_MULTI_TID) != 0) {
u_int targid_mask;
targid_mask = ahd_inw(ahd, TARGID);
targid_mask |= target_mask;
ahd_outw(ahd, TARGID, targid_mask);
ahd_update_scsiid(ahd, targid_mask);
} else {
u_int our_id;
char channel;
channel = SIM_CHANNEL(ahd, sim);
our_id = SIM_SCSI_ID(ahd, sim);
/*
* This can only happen if selections
* are not enabled
*/
if (target != our_id) {
u_int sblkctl;
char cur_channel;
int swap;
sblkctl = ahd_inb(ahd, SBLKCTL);
cur_channel = (sblkctl & SELBUSB)
? 'B' : 'A';
if ((ahd->features & AHD_TWIN) == 0)
cur_channel = 'A';
swap = cur_channel != channel;
ahd->our_id = target;
if (swap)
ahd_outb(ahd, SBLKCTL,
sblkctl ^ SELBUSB);
ahd_outb(ahd, SCSIID, target);
if (swap)
ahd_outb(ahd, SBLKCTL, sblkctl);
}
}
} else
ahd->black_hole = lstate;
/* Allow select-in operations */
if (ahd->black_hole != NULL && ahd->enabled_luns > 0) {
scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
scsiseq1 |= ENSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
scsiseq1 = ahd_inb(ahd, SCSISEQ1);
scsiseq1 |= ENSELI;
ahd_outb(ahd, SCSISEQ1, scsiseq1);
}
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_print_path(ccb->ccb_h.path);
printf("Lun now enabled for target mode\n");
} else {
struct scb *scb;
int i, empty;
if (lstate == NULL) {
ccb->ccb_h.status = CAM_LUN_INVALID;
return;
}
ahd_lock(ahd, &s);
ccb->ccb_h.status = CAM_REQ_CMP;
LIST_FOREACH(scb, &ahd->pending_scbs, pending_links) {
struct ccb_hdr *ccbh;
ccbh = &scb->io_ctx->ccb_h;
if (ccbh->func_code == XPT_CONT_TARGET_IO
&& !xpt_path_comp(ccbh->path, ccb->ccb_h.path)){
printf("CTIO pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
ahd_unlock(ahd, &s);
return;
}
}
if (SLIST_FIRST(&lstate->accept_tios) != NULL) {
printf("ATIOs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
}
if (SLIST_FIRST(&lstate->immed_notifies) != NULL) {
printf("INOTs pending\n");
ccb->ccb_h.status = CAM_REQ_INVALID;
}
if (ccb->ccb_h.status != CAM_REQ_CMP) {
ahd_unlock(ahd, &s);
return;
}
xpt_print_path(ccb->ccb_h.path);
printf("Target mode disabled\n");
xpt_free_path(lstate->path);
free(lstate, M_DEVBUF);
ahd_pause(ahd);
/* Can we clean up the target too? */
if (target != CAM_TARGET_WILDCARD) {
tstate->enabled_luns[lun] = NULL;
ahd->enabled_luns--;
for (empty = 1, i = 0; i < 8; i++)
if (tstate->enabled_luns[i] != NULL) {
empty = 0;
break;
}
if (empty) {
ahd_free_tstate(ahd, target, channel,
/*force*/FALSE);
if (ahd->features & AHD_MULTI_TID) {
u_int targid_mask;
targid_mask = ahd_inw(ahd, TARGID);
targid_mask &= ~target_mask;
ahd_outw(ahd, TARGID, targid_mask);
ahd_update_scsiid(ahd, targid_mask);
}
}
} else {
ahd->black_hole = NULL;
/*
* We can't allow selections without
* our black hole device.
*/
empty = TRUE;
}
if (ahd->enabled_luns == 0) {
/* Disallow select-in */
u_int scsiseq1;
scsiseq1 = ahd_inb(ahd, SCSISEQ_TEMPLATE);
scsiseq1 &= ~ENSELI;
ahd_outb(ahd, SCSISEQ_TEMPLATE, scsiseq1);
scsiseq1 = ahd_inb(ahd, SCSISEQ1);
scsiseq1 &= ~ENSELI;
ahd_outb(ahd, SCSISEQ1, scsiseq1);
if ((ahd->features & AHD_MULTIROLE) == 0) {
printf("Configuring Initiator Mode\n");
ahd->flags &= ~AHD_TARGETROLE;
ahd->flags |= AHD_INITIATORROLE;
ahd_pause(ahd);
ahd_loadseq(ahd);
ahd_restart(ahd);
/*
* Unpaused. The extra unpause
* that follows is harmless.
*/
}
}
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
}
#endif
}
static void
ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
{
#if NOT_YET
u_int scsiid_mask;
u_int scsiid;
if ((ahd->features & AHD_MULTI_TID) == 0)
panic("ahd_update_scsiid called on non-multitid unit\n");
/*
* Since we will rely on the TARGID mask
* for selection enables, ensure that OID
* in SCSIID is not set to some other ID
* that we don't want to allow selections on.
*/
if ((ahd->features & AHD_ULTRA2) != 0)
scsiid = ahd_inb(ahd, SCSIID_ULTRA2);
else
scsiid = ahd_inb(ahd, SCSIID);
scsiid_mask = 0x1 << (scsiid & OID);
if ((targid_mask & scsiid_mask) == 0) {
u_int our_id;
/* ffs counts from 1 */
our_id = ffs(targid_mask);
if (our_id == 0)
our_id = ahd->our_id;
else
our_id--;
scsiid &= TID;
scsiid |= our_id;
}
if ((ahd->features & AHD_ULTRA2) != 0)
ahd_outb(ahd, SCSIID_ULTRA2, scsiid);
else
ahd_outb(ahd, SCSIID, scsiid);
#endif
}
void
ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
{
struct target_cmd *cmd;
ahd_sync_tqinfifo(ahd, BUS_DMASYNC_POSTREAD);
while ((cmd = &ahd->targetcmds[ahd->tqinfifonext])->cmd_valid != 0) {
/*
* Only advance through the queue if we
* have the resources to process the command.
*/
if (ahd_handle_target_cmd(ahd, cmd) != 0)
break;
cmd->cmd_valid = 0;
ahd_dmamap_sync(ahd, ahd->shared_data_dmat,
ahd->shared_data_map.dmamap,
ahd_targetcmd_offset(ahd, ahd->tqinfifonext),
sizeof(struct target_cmd),
BUS_DMASYNC_PREREAD);
ahd->tqinfifonext++;
/*
* Lazily update our position in the target mode incoming
* command queue as seen by the sequencer.
*/
if ((ahd->tqinfifonext & (HOST_TQINPOS - 1)) == 1) {
u_int hs_mailbox;
hs_mailbox = ahd_inb(ahd, HS_MAILBOX);
hs_mailbox &= ~HOST_TQINPOS;
hs_mailbox |= ahd->tqinfifonext & HOST_TQINPOS;
ahd_outb(ahd, HS_MAILBOX, hs_mailbox);
}
}
}
static int
ahd_handle_target_cmd(struct ahd_softc *ahd, struct target_cmd *cmd)
{
struct ahd_tmode_tstate *tstate;
struct ahd_tmode_lstate *lstate;
struct ccb_accept_tio *atio;
uint8_t *byte;
int initiator;
int target;
int lun;
initiator = SCSIID_TARGET(ahd, cmd->scsiid);
target = SCSIID_OUR_ID(cmd->scsiid);
lun = (cmd->identify & MSG_IDENTIFY_LUNMASK);
byte = cmd->bytes;
tstate = ahd->enabled_targets[target];
lstate = NULL;
if (tstate != NULL)
lstate = tstate->enabled_luns[lun];
/*
* Commands for disabled luns go to the black hole driver.
*/
if (lstate == NULL)
lstate = ahd->black_hole;
atio = (struct ccb_accept_tio*)SLIST_FIRST(&lstate->accept_tios);
if (atio == NULL) {
ahd->flags |= AHD_TQINFIFO_BLOCKED;
/*
* Wait for more ATIOs from the peripheral driver for this lun.
*/
return (1);
} else
ahd->flags &= ~AHD_TQINFIFO_BLOCKED;
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TQIN) != 0)
printf("Incoming command from %d for %d:%d%s\n",
initiator, target, lun,
lstate == ahd->black_hole ? "(Black Holed)" : "");
#endif
SLIST_REMOVE_HEAD(&lstate->accept_tios, sim_links.sle);
if (lstate == ahd->black_hole) {
/* Fill in the wildcards */
atio->ccb_h.target_id = target;
atio->ccb_h.target_lun = lun;
}
/*
* Package it up and send it off to
* whomever has this lun enabled.
*/
atio->sense_len = 0;
atio->init_id = initiator;
if (byte[0] != 0xFF) {
/* Tag was included */
atio->tag_action = *byte++;
atio->tag_id = *byte++;
atio->ccb_h.flags = CAM_TAG_ACTION_VALID;
} else {
atio->ccb_h.flags = 0;
}
byte++;
/* Okay. Now determine the cdb size based on the command code */
switch (*byte >> CMD_GROUP_CODE_SHIFT) {
case 0:
atio->cdb_len = 6;
break;
case 1:
case 2:
atio->cdb_len = 10;
break;
case 4:
atio->cdb_len = 16;
break;
case 5:
atio->cdb_len = 12;
break;
case 3:
default:
/* Only copy the opcode. */
atio->cdb_len = 1;
printf("Reserved or VU command code type encountered\n");
break;
}
memcpy(atio->cdb_io.cdb_bytes, byte, atio->cdb_len);
atio->ccb_h.status |= CAM_CDB_RECVD;
if ((cmd->identify & MSG_IDENTIFY_DISCFLAG) == 0) {
/*
* We weren't allowed to disconnect.
* We're hanging on the bus until a
* continue target I/O comes in response
* to this accept tio.
*/
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_TQIN) != 0)
printf("Received Immediate Command %d:%d:%d - %p\n",
initiator, target, lun, ahd->pending_device);
#endif
ahd->pending_device = lstate;
ahd_freeze_ccb((union ccb *)atio);
atio->ccb_h.flags |= CAM_DIS_DISCONNECT;
}
xpt_done((union ccb*)atio);
return (0);
}
#endif
| impedimentToProgress/UCI-BlueChip | snapgear_linux/linux-2.6.21.1/drivers/scsi/aic7xxx/aic79xx_core.c | C | mit | 278,803 | [
30522,
1013,
1008,
1008,
4563,
23964,
1998,
7251,
3745,
3085,
2408,
9808,
7248,
1012,
1008,
1008,
9385,
1006,
1039,
1007,
2807,
1011,
2526,
6796,
1056,
1012,
15659,
1012,
1008,
9385,
1006,
1039,
1007,
2456,
1011,
2494,
15581,
8586,
4297,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.yakami.light.view.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.yakami.light.BuildConfig;
import com.yakami.light.R;
import com.yakami.light.view.fragment.base.BaseFragment;
import butterknife.Bind;
import butterknife.ButterKnife;
/**
* Created by Yakami on 2016/8/5, enjoying it!
*/
public class AboutFragment extends BaseFragment {
@Bind(R.id.tv_about) TextView mAbout;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_about, container, false);
ButterKnife.bind(this,view);
mAbout.setText("版本: " + BuildConfig.VERSION_NAME + "\n" + mRes.getString(R.string.author));
mAbout.append("\ngithub地址:https://github.com/hanFengSan/light");
return view;
}
}
| hanFengSan/light | app/src/main/java/com/yakami/light/view/fragment/AboutFragment.java | Java | apache-2.0 | 958 | [
30522,
7427,
4012,
1012,
8038,
27052,
2072,
1012,
2422,
1012,
3193,
1012,
15778,
1025,
12324,
11924,
1012,
9808,
1012,
14012,
1025,
12324,
11924,
1012,
3193,
1012,
9621,
2378,
10258,
24932,
1025,
12324,
11924,
1012,
3193,
1012,
3193,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.generation;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static com.intellij.codeInsight.AnnotationUtil.CHECK_EXTERNAL;
import static com.intellij.codeInsight.AnnotationUtil.CHECK_TYPE;
/**
* @author anna
*/
public interface OverrideImplementsAnnotationsHandler {
ExtensionPointName<OverrideImplementsAnnotationsHandler> EP_NAME = ExtensionPointName.create("com.intellij.overrideImplementsAnnotationsHandler");
/**
* Returns annotations which should be copied from a source to an implementation (by default, no annotations are copied).
*/
default String[] getAnnotations(@NotNull PsiFile file) {
//noinspection deprecation
return getAnnotations(file.getProject());
}
/**
* @deprecated Use {@link #getAnnotations(PsiFile)}
*/
@Deprecated
String[] getAnnotations(Project project);
@Deprecated
@NotNull
default String[] annotationsToRemove(Project project, @NotNull String fqName) {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
/** Perform post processing on the annotations, such as deleting or renaming or otherwise updating annotations in the override */
default void cleanup(PsiModifierListOwner source, @Nullable PsiElement targetClass, PsiModifierListOwner target) {
}
static void repeatAnnotationsFromSource(PsiModifierListOwner source, @Nullable PsiElement targetClass, PsiModifierListOwner target) {
Module module = ModuleUtilCore.findModuleForPsiElement(targetClass != null ? targetClass : target);
GlobalSearchScope moduleScope = module != null ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) : null;
Project project = target.getProject();
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
for (OverrideImplementsAnnotationsHandler each : EP_NAME.getExtensionList()) {
for (String annotation : each.getAnnotations(target.getContainingFile())) {
if (moduleScope != null && facade.findClass(annotation, moduleScope) == null) continue;
int flags = CHECK_EXTERNAL | CHECK_TYPE;
if (AnnotationUtil.isAnnotated(source, annotation, flags) && !AnnotationUtil.isAnnotated(target, annotation, flags)) {
each.transferToTarget(annotation, source, target);
}
}
}
for (OverrideImplementsAnnotationsHandler each : EP_NAME.getExtensionList()) {
each.cleanup(source, targetClass, target);
}
}
default void transferToTarget(String annotation, PsiModifierListOwner source, PsiModifierListOwner target) {
PsiModifierList modifierList = target.getModifierList();
assert modifierList != null : target;
PsiAnnotation srcAnnotation = AnnotationUtil.findAnnotation(source, annotation);
PsiNameValuePair[] valuePairs = srcAnnotation != null ? srcAnnotation.getParameterList().getAttributes() : PsiNameValuePair.EMPTY_ARRAY;
AddAnnotationPsiFix.addPhysicalAnnotation(annotation, valuePairs, modifierList);
}
} | paplorinc/intellij-community | java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementsAnnotationsHandler.java | Java | apache-2.0 | 3,542 | [
30522,
1013,
1013,
9385,
2456,
1011,
2760,
6892,
10024,
7076,
1055,
1012,
1054,
1012,
1051,
1012,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1996,
15895,
1016,
1012,
1014,
6105,
2008,
2064,
2022,
2179,
1999,
1996,
6105,
5371,
1012,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef _DEV_SETUP_H_
#define _DEV_SETUP_H_
#include<stdlib.h>
#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#define exe_length 10
#define ip_route "10.0.0.0/24"
int run_ip_set(char *arg[]);
int set_up_dev(char *dev);
#endif /*_DEV_SETUP_H_*/
| XingGaoY/tcp-ip | src/include/dev_setup.h | C | gpl-3.0 | 261 | [
30522,
1001,
2065,
13629,
2546,
1035,
16475,
1035,
16437,
1035,
1044,
1035,
1001,
9375,
1035,
16475,
1035,
16437,
1035,
1044,
1035,
1001,
2421,
1026,
2358,
19422,
12322,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
## 1.8.0 (September 2015)
- New MATERIAL DESIGN theme
- Updated FILE TYPE ICONS
- Preview TXT files within the app
- COPY files & folders
- Preview the full file/folder name from the long press menu
- Set a file as FAVORITE (kept-in-sync) from the CONTEXT MENU
- Updated CONFLICT RESOLUTION dialog (wording)
- Images with TRANSPARENT background are previewed correctly
- Hidden files are not taken into account for enforcing or not the list VIEW
- Several bugs fixed
## 1.7.2 (July 2015)
- New navigation drawer
- Improved Passcode
- Automatic grid view just for folders full of images
- More characters allowed in file names
- Support for servers in same domain, different path
- Bugs fixed:
+ Frequent crashes in folder with several images
+ Sync error in servers with huge quota and external storage enable
+ Share by link error
+ Some other crashes and minor bugs
## 1.7.1 (April 2015)
- Share link even with password enforced by server
- Get the app ready for oc 8.1 servers
- Added option to create new folder in uploads from external apps
- Improved management of deleted users
- Bugs fixed
+ Fixed crash on Android 2.x devices
+ Improvements on uploads
## 1.7.0 (February 2015)
- Download full folders
- Grid view for images
- Remote thumbnails (OC Server 8.0+)
- Added number of files and folders at the end of the list
- "Open with" in contextual menu
- Downloads added to Media Provider
- Uploads:
+ Local thumbnails in section "Files"
+ Multiple selection in "Content from other apps" (Android 4.3+)
- Gallery:
+ proper handling of EXIF
+ obey sorting in the list of files
- Settings view updated
- Improved subjects in e-mails
- Bugs fixed
| maduhu/android | CHANGELOG.md | Markdown | gpl-2.0 | 1,684 | [
30522,
1001,
1001,
1015,
1012,
1022,
1012,
1014,
1006,
2244,
2325,
1007,
1011,
2047,
3430,
2640,
4323,
1011,
7172,
5371,
2828,
18407,
1011,
19236,
19067,
2102,
6764,
2306,
1996,
10439,
1011,
6100,
6764,
1004,
19622,
2015,
1011,
19236,
1996,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <cassert>
#include <cmath>
#include <omp.h>
#define INTEGER_MAX 3000000
#include "../util.h"
using namespace std;
typedef struct {
int nWords;
int nVocs;
int nDocs;
vector< pair<int,int> >* doc_lookup;
vector< pair<int,int> >* word_lookup;
vector< vector<int> >* voc_lookup;
} Lookups ;
void get_doc_lookup (vector< Instance* > & data, vector<pair<int,int> >& doc_lookup) {
// validate the input
doc_lookup.clear();
int N = data.size();
for (int i = 1; i < N; i ++)
assert(data[i-1]->label <= data[i]->label);
// compute list of document info
int doc_begin = 0;
int doc_end = 0;
int last_doc = data[0]->label;
for (int i = 0; i < N ; i++) {
int curr_doc = data[i]->label;
if (curr_doc != last_doc) {
doc_end = i;
//cerr << "(" << doc_begin << ", " << doc_end << ")" <<endl;
doc_lookup.push_back(make_pair(doc_begin, doc_end));
doc_begin = i;
last_doc = curr_doc;
}
}
// cerr << "(" << doc_begin << ", " << doc_end << ")" <<endl;
doc_lookup.push_back(make_pair(doc_begin, N));
}
| JimmyLin192/ConvexLatentVariable | TOTURNIN/codes/HDP_MEDOIDS/HDP_MEDOIDS.h | C | bsd-3-clause | 1,156 | [
30522,
1001,
2421,
1026,
16220,
8743,
1028,
1001,
2421,
1026,
4642,
8988,
1028,
1001,
2421,
1026,
18168,
2361,
1012,
1044,
1028,
1001,
9375,
16109,
1035,
4098,
11910,
8889,
2692,
1001,
2421,
1000,
1012,
1012,
1013,
21183,
4014,
1012,
1044,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<meta charset=utf-8>
<title>invalid cite: userinfo-backslash</title>
<q cite="http://a\b:c\d@foo.com"></q>
| youtube/cobalt | third_party/web_platform_tests/conformance-checkers/html/elements/q/cite/userinfo-backslash-novalid.html | HTML | bsd-3-clause | 123 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
18804,
25869,
13462,
1027,
21183,
2546,
1011,
1022,
1028,
1026,
2516,
1028,
19528,
21893,
1024,
5310,
2378,
14876,
1011,
10457,
27067,
1026,
1013,
2516,
1028,
1026,
1053,
21893,
1027,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef KALAH_BOARD_H
#define KALAH_BOARD_H
#include <vector>
#include "houseContainer.hpp"
#include "storeContainer.hpp"
using namespace std;
class kalahBoard
{
public:
kalahBoard(unsigned int numberOfHousesIn);
void fillHouses(vector<unsigned int> homeHouseInitialSeedCount,
vector<unsigned int> awayHouseInitialSeedCount);
unsigned int getNumberOfHouses();
vector<houseContainer> homeHouses;
vector<houseContainer> awayHouses;
storeContainer homeStore;
storeContainer awayStore;
private:
void assignContainerRefs();
unsigned int numberOfHouses;
};
#endif
| chadvoegele/kalah-ncurses | src/kalahBoard.hpp | C++ | mit | 590 | [
30522,
1001,
2065,
13629,
2546,
26209,
2232,
1035,
2604,
1035,
1044,
1001,
9375,
26209,
2232,
1035,
2604,
1035,
1044,
1001,
2421,
1026,
9207,
1028,
1001,
2421,
1000,
2160,
8663,
18249,
2121,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
3573,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//! xz-decom
//!
//! XZ Decompression using xz-embedded
//!
//! This crate provides XZ decompression using the xz-embedded library.
//! This means that compression and perhaps some advanced features are not supported.
//!
extern crate xz_embedded_sys as raw;
use std::error::Error;
use std::fmt;
/// Error type for problems during decompression
#[derive(Debug)]
pub struct XZError {
msg: &'static str,
code: Option<raw::XZRawError>
}
impl Error for XZError {
fn description(&self) -> &str { self.msg }
fn cause<'a>(&'a self) -> Option<&'a Error> {
if let Some(ref e) = self.code {
Some(e)
} else {
None
}
}
}
impl fmt::Display for XZError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
/// Decompress some data
///
/// The input slice should contain the full chunk of data to decompress. There is no support for
/// partial decompression
///
/// # Example
///
/// Pretty simple:
///
/// ```ignore
/// let data = include_bytes!("data/hello.xz");
///
/// let result = decompress(data).unwrap();
/// assert_eq!(result, "hello".as_bytes());
/// ```
///
pub fn decompress(compressed_data: &[u8]) -> Result<Vec<u8>, XZError> {
unsafe {
// Note that these return void, and can't fail
raw::xz_crc32_init();
raw::xz_crc64_init();
}
let state = unsafe {
raw::xz_dec_init(raw::xz_mode::XZ_DYNALLOC, 1 << 26)
};
if state.is_null() {
return Err(XZError{msg: "Failed to initialize", code: None});
}
let mut out_vec = Vec::new();
let out_size = 4096;
let mut out_buf = Vec::with_capacity(out_size);
out_buf.resize(out_size, 0);
let mut buf = raw::xz_buf {
_in: compressed_data.as_ptr(),
in_size: compressed_data.len() as u64,
in_pos:0,
out: out_buf.as_mut_ptr(),
out_pos: 0,
out_size: out_size as u64,
};
loop {
let ret = unsafe { raw::xz_dec_run(state, &mut buf) };
//println!("Decomp returned {:?}", ret);
if ret == raw::xz_ret::XZ_OK {
out_vec.extend(&out_buf[0..(buf.out_pos as usize)]);
buf.out_pos = 0;
} else if ret == raw::xz_ret::XZ_STREAM_END {
out_vec.extend(&out_buf[0..(buf.out_pos as usize)]);
break;
} else {
return Err(XZError{msg: "Decompressing error", code: Some(raw::XZRawError::from(ret))})
}
if buf.in_pos == buf.in_size {
// if we're reached the end of out input buffer, but we didn't hit
// XZ_STREAM_END, i think this is an error
return Err(XZError{msg: "Reached end of input buffer", code: None})
}
}
unsafe { raw::xz_dec_end(state) };
Ok(out_vec)
}
| eminence/xz-decom | src/lib.rs | Rust | apache-2.0 | 2,820 | [
30522,
1013,
1013,
999,
1060,
2480,
1011,
21933,
2213,
1013,
1013,
999,
1013,
1013,
999,
1060,
2480,
21933,
8737,
8303,
3258,
2478,
1060,
2480,
1011,
11157,
1013,
1013,
999,
1013,
1013,
999,
2023,
27297,
3640,
1060,
2480,
21933,
8737,
830... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from PIL import Image
from treemap.images import save_uploaded_image
from treemap.tests import LocalMediaTestCase, media_dir
class SaveImageTest(LocalMediaTestCase):
@media_dir
def test_rotates_image(self):
sideways_file = self.load_resource('tree_sideways.jpg')
img_file, _ = save_uploaded_image(sideways_file, 'test')
expected_width, expected_height = Image.open(sideways_file).size
actual_width, actual_height = Image.open(img_file).size
self.assertEquals(expected_width, actual_height)
self.assertEquals(expected_height, actual_width)
| ctaylo37/OTM2 | opentreemap/treemap/tests/test_images.py | Python | gpl-3.0 | 735 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
6140,
1035,
3853,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
27260,
1035,
18204,
2015,
2013,
1035,
1035,
2925,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
The MIT License (MIT)
Copyright (c) 2016 Adrian Tsumanu Woźniak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Eraden/axon | License.md | Markdown | mit | 1,090 | [
30522,
1996,
10210,
6105,
1006,
10210,
1007,
9385,
1006,
1039,
1007,
2355,
7918,
24529,
19042,
2226,
24185,
2480,
6200,
2243,
6656,
2003,
2182,
3762,
4379,
1010,
2489,
1997,
3715,
1010,
2000,
2151,
2711,
11381,
1037,
6100,
1997,
2023,
4007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
export {foo, bar};
| sebmck/espree | tests/fixtures/ecma-features/modules/export-named-specifiers.src.js | JavaScript | bsd-2-clause | 19 | [
30522,
9167,
1063,
29379,
1010,
3347,
1065,
1025,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
local PLUGIN = exsto.CreatePlugin()
PLUGIN:SetInfo({
Name = "Logs",
ID = "logs",
Desc = "A plugin that logs all Exsto events.",
Owner = "Prefanatic",
} )
function PLUGIN:Init()
self.Types = { "all", "commands", "player", "errors", "chat", "spawns", "debug" }
file.CreateDir( "exsto/logs" )
for _, type in ipairs( self.Types ) do
file.CreateDir( "exsto/logs/" .. type )
end
-- Create variables for console printing per request of Mors Quaedam
exsto.CreateFlag( "printlogs", "Prints logs specified by 'ExPrintLogs' to the console." )
self.Printing = exsto.CreateVariable( "ExPrintLogs", "Print to Console", "none", "Selects the possible logs to print to the console." )
self.Printing:SetMultiChoice()
self.Printing:SetCategory( "Logging" )
local pos = self.Types
table.insert( pos, "none" )
self.Printing:SetPossible( unpack( pos ) )
self.SaveDebug = exsto.CreateVariable( "ExSaveDebugLogs", "Save Debug", 0, "Saves debugging information as a log." )
self.SaveDebug:SetBoolean()
self.SaveDebug:SetCategory( "Debug" )
end
function PLUGIN:ShutDown()
self:SaveEvent( "The server is shutting down/switching maps!", "server" )
end
function PLUGIN:ExInitialized()
self:SaveEvent( "Exsto has finished loading.", "server" )
end
function PLUGIN:FormatEntity( ent )
if ent:GetClass() == "worldspawn" then
return game.GetMap()
elseif ent:GetClass() == "prop_physics" then
return ent:GetModel()
end
return ent:GetClass()
end
function PLUGIN:CanTool( ply, tr, tool )
self:SaveEvent( self:Player( ply ) .. " has attempted to use tool (" .. tostring( tool ) .. ") on " .. ( tr.Entity and self:FormatEntity( tr.Entity ) ) or "Unknown", "player" )
end
function PLUGIN:ShutDown()
self:SaveEvent( "The server is shutting down/switching maps!", "server" )
end
function PLUGIN:ExInitialized()
self:SaveEvent( "Exsto has finished loading.", "server" )
end
function PLUGIN:CanTool( ply, tr, tool )
local ent = IsValid( tr.Entity ) and tr.Entity:GetClass() or "Unknown"
self:SaveEvent( self:Player( ply ) .. " has attempted to use tool (" .. tool .. ") on " .. ent, "player" )
end
function PLUGIN:PlayerSpawnProp( ply, mdl )
self:SaveEvent( self:Player( ply ) .. " has spawned prop (" .. mdl .. ")", "spawns" )
end
function PLUGIN:PlayerSpawnSENT( ply, class )
self:SaveEvent( self:Player( ply ) .. " has spawned sent (" .. class .. ")", "spawns" )
end
function PLUGIN:PlayerSpawnSWEP( ply, class )
self:SaveEvent( self:Player( ply ) .. " has spawned swep (" .. class .. ")", "spawns" )
end
function PLUGIN:PlayerSpawnNPC( ply, npc )
self:SaveEvent( self:Player( ply ) .. " has spawned npc (" .. npc .. ")", "spawns" )
end
function PLUGIN:PlayerSpawnVehicle( ply, class )
self:SaveEvent( self:Player( ply ) .. " has spawned vehicle (" .. class .. ")", "spawns" )
end
function PLUGIN:PlayerSpawnRagdoll( ply, mdl )
self:SaveEvent( self:Player( ply ) .. " has spawned ragdoll (" .. mdl .. ")", "spawns" )
end
function PLUGIN:PlayerSay( ply, text )
self:SaveEvent( self:Player( ply ) .. ": " .. text, "chat" )
end
function PLUGIN:ExPrintCalled( enum, data )
if enum == exsto_ERROR or enum == exsto_ERRORNOHALT then
local trace = debug.getinfo( 5, "Sln" )
local construct = ""
--PrintTable( data )
for _, obj in ipairs( data ) do
construct = construct .. obj
end
--construct .. "[" .. trace.source .. ", N:" .. trace.name .. ", " .. trace.linedefined .. "-" .. trace.currentline .. "-" .. trace.lastlinedefined .. "]"
self:SaveEvent( construct, "errors" )
elseif enum == exsto_DEBUG and self.SaveDebug:GetValue() == 1 then
-- Clean out colors.
if data[ 2 ] == 0 then -- This is coming from FEL.
data = data[1]
end
local tbl = {}
for _, v in ipairs( data ) do
if type( v ) == "string" then table.insert( tbl, v ) end
end
self:SaveEvent( table.concat( tbl, " " ), "debug" )
end
end
function PLUGIN:PlayerSpawn( ply )
self:SaveEvent( self:Player( ply ) .. " has spawned.", "player" )
end
function PLUGIN:PlayerDeath( ply )
self:SaveEvent( self:Player( ply ) .. " has died.", "player" )
end
function PLUGIN:player_connect( data )
exsto.Print( exsto_CONSOLE_LOGO, COLOR.NAME, data.name, COLOR.NORM, "(" .. data.networkid .. ") has joined." )
self:SaveEvent( data.name .. "(" .. data.networkid .. ") has joined the game.", "player" )
end
function PLUGIN:ExPlayerAuthed( ply )
self:SaveEvent( self:Player( ply ) .. " has been authed.", "player" )
end
function PLUGIN:PlayerDisconnected( ply )
exsto.Print( exsto_CONSOLE_LOGO, COLOR.NAME, ply:Nick(), COLOR.NORM, "(" .. ply:SteamID() .. ") has disconnected." )
self:SaveEvent( self:Player( ply ) .. " has disconnected!", "player" )
end
function PLUGIN:ExCommandCalled( id, plug, caller, ... )
local arg = {...}
if type( plug ) == "Player" then caller = plug end
local text = self:Player( caller ) .. " has run command '" .. id .. "'"
local index = 1
if arg[1] then
if type( arg[1] ) == "Player" then
text = text .. " on player " .. self:Player( arg[1] )
index = 2
end
if arg[ index ] then
text = text .. " with args: "
for I = index, #arg do
text = text .. tostring( arg[I] )
end
end
end
self:SaveEvent( text, "commands" )
end
function PLUGIN:Player( ply )
if not IsValid( ply ) or ply:EntIndex() == 0 then
return "CONSOLE"
else
return ply:Nick() .. "(" .. ply:SteamID() .. ")"
end
end
function PLUGIN:SaveEvent( text, type )
if text == "" then return end
local date = os.date( "%m-%d-%y" )
local time = tostring( os.date( "%H:%M:%S" ) )
local obj = { type }
if type != "all" then obj = { type, "all" } end
for _, type in ipairs( obj ) do
if !file.Exists( "exsto/logs/" .. type .. "/" .. date .. ".txt", "DATA" ) then
file.Write( "exsto/logs/" .. type .. "/" .. date .. ".txt", "[" .. time .. "] " .. text:gsub( "\n", "" ) .. "\n" )
else
local data = file.Read( "exsto/logs/" .. type .. "/" .. date .. ".txt", "DATA" )
file.Write( "exsto/logs/" .. type .. "/" .. date .. ".txt", data .. "[" .. time .. "] " .. text:gsub( "\n", "" ) .. "\n" )
end
end
-- Print these logs to the console.
local printTypes = self.Printing:GetValue()
for _, ply in ipairs( player.GetAll() ) do
if ply:IsAllowed( "printlogs" ) then -- If we're allowed to do it.
if table.HasValue( printTypes, "all" ) or table.HasValue( printTypes, type ) then
ply:Print( exsto_CLIENT, "[LOG] " .. "[" .. time .. "] " .. text:gsub( "\n", "" ) .. "\n" )
end
end
end
end
PLUGIN:Register() | prefanatic/exsto | lua/exsto/plugins/server/logging.lua | Lua | gpl-3.0 | 6,516 | [
30522,
2334,
13354,
2378,
1027,
4654,
16033,
1012,
3443,
24759,
15916,
2378,
1006,
1007,
13354,
2378,
1024,
2275,
2378,
14876,
1006,
1063,
2171,
1027,
1000,
15664,
1000,
1010,
8909,
1027,
1000,
15664,
1000,
1010,
4078,
2278,
1027,
1000,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var struct_l_p_c___r_t_c___type_def =
[
[ "ALDOM", "struct_l_p_c___r_t_c___type_def.html#aae1199a3f1f40f90aba18aee4d6325fd", null ],
[ "ALDOW", "struct_l_p_c___r_t_c___type_def.html#a5f56710f005f96878defbdb8ef1333c2", null ],
[ "ALDOY", "struct_l_p_c___r_t_c___type_def.html#a4c7ceb477c4a865ae51f5052dd558667", null ],
[ "ALHOUR", "struct_l_p_c___r_t_c___type_def.html#ac56690c26258c2cf9d28d09cc3447c1d", null ],
[ "ALMIN", "struct_l_p_c___r_t_c___type_def.html#a7e45902fca36066b22f41d0ef60d3c36", null ],
[ "ALMON", "struct_l_p_c___r_t_c___type_def.html#ad22f635b8c8b51dad2956e797a4dd9d3", null ],
[ "ALSEC", "struct_l_p_c___r_t_c___type_def.html#af3ff64ab3671109971425a05194acc7c", null ],
[ "ALYEAR", "struct_l_p_c___r_t_c___type_def.html#ab7f49ad885a354164adc263629d3a555", null ],
[ "AMR", "struct_l_p_c___r_t_c___type_def.html#a13f4e9721184b326043e6c6596f87790", null ],
[ "CALIBRATION", "struct_l_p_c___r_t_c___type_def.html#abe224f8608ae3d2c5b1036bf943b6c27", null ],
[ "CCR", "struct_l_p_c___r_t_c___type_def.html#af959ddb88caef28108c2926e310a72bd", null ],
[ "CIIR", "struct_l_p_c___r_t_c___type_def.html#a0df12e53986b72fbfcdceb537f7bf20e", null ],
[ "CTIME0", "struct_l_p_c___r_t_c___type_def.html#a97fa06b91b698236cb770d9618707bef", null ],
[ "CTIME1", "struct_l_p_c___r_t_c___type_def.html#a5b1a1b981a72c6d1cd482e75f1d44de4", null ],
[ "CTIME2", "struct_l_p_c___r_t_c___type_def.html#a411e06dfdcddd3fc19170231aa3a98be", null ],
[ "DOM", "struct_l_p_c___r_t_c___type_def.html#a7c70513eabbefbc5c5dd865a01ecc487", null ],
[ "DOW", "struct_l_p_c___r_t_c___type_def.html#a61f22d3ccb1c82db258f66d7d930db35", null ],
[ "DOY", "struct_l_p_c___r_t_c___type_def.html#a7b4a3d5692df3c5062ec927cedd16734", null ],
[ "GPREG0", "struct_l_p_c___r_t_c___type_def.html#ac42f0d8452c678fa007f0e0b862fb0c6", null ],
[ "GPREG1", "struct_l_p_c___r_t_c___type_def.html#abee4ae6eab2c33bdf38985d3b8a439f1", null ],
[ "GPREG2", "struct_l_p_c___r_t_c___type_def.html#a75f852bb2980febd2af7cc583e1445ec", null ],
[ "GPREG3", "struct_l_p_c___r_t_c___type_def.html#aad058be0cc120fffbbc66ad6f7c0c731", null ],
[ "GPREG4", "struct_l_p_c___r_t_c___type_def.html#afcc8f7898dce77fdb1082ff681387692", null ],
[ "HOUR", "struct_l_p_c___r_t_c___type_def.html#a76b8d6a8b13febe4289797f34ba73998", null ],
[ "ILR", "struct_l_p_c___r_t_c___type_def.html#aba869620e961b6eb9280229dad81e458", null ],
[ "MIN", "struct_l_p_c___r_t_c___type_def.html#a7a07167f54a5412387ee581fcd6dd2e0", null ],
[ "MONTH", "struct_l_p_c___r_t_c___type_def.html#a28fb9798e07b54b1098e9efe96ac244a", null ],
[ "RESERVED0", "struct_l_p_c___r_t_c___type_def.html#ad539ffa4484980685ca2da36b54fe61d", null ],
[ "RESERVED1", "struct_l_p_c___r_t_c___type_def.html#ad9fb3ef44fb733b524dcad0dfe34290e", null ],
[ "RESERVED10", "struct_l_p_c___r_t_c___type_def.html#a2d9caf1d8be9f2169521470b6ccd0377", null ],
[ "RESERVED11", "struct_l_p_c___r_t_c___type_def.html#a11e504ee49142f46dcc67740ae9235e5", null ],
[ "RESERVED12", "struct_l_p_c___r_t_c___type_def.html#a06137f06d699f26661c55209218bcada", null ],
[ "RESERVED13", "struct_l_p_c___r_t_c___type_def.html#a17672e7a5546cef19ee778266224c193", null ],
[ "RESERVED14", "struct_l_p_c___r_t_c___type_def.html#a1b9781efee5466ce7886eae907f24e60", null ],
[ "RESERVED15", "struct_l_p_c___r_t_c___type_def.html#a781148146471db4cd7d04029e383d115", null ],
[ "RESERVED16", "struct_l_p_c___r_t_c___type_def.html#af3ff60ce094e476f447a8046d873acb0", null ],
[ "RESERVED17", "struct_l_p_c___r_t_c___type_def.html#ae98d0c41e0bb8aef875fa8b53b25af54", null ],
[ "RESERVED18", "struct_l_p_c___r_t_c___type_def.html#aae0a4a7536dc03a352e8c48436b10263", null ],
[ "RESERVED19", "struct_l_p_c___r_t_c___type_def.html#a5552e97d80fc1a5bd195a9c81b270ffc", null ],
[ "RESERVED2", "struct_l_p_c___r_t_c___type_def.html#aff8b921ce3122ac6c22dc654a4f1b7ca", null ],
[ "RESERVED20", "struct_l_p_c___r_t_c___type_def.html#af7fcad34b88077879694c020956bf69b", null ],
[ "RESERVED21", "struct_l_p_c___r_t_c___type_def.html#ae26a65f4079b1f3af0490c463e6f6e90", null ],
[ "RESERVED3", "struct_l_p_c___r_t_c___type_def.html#a1936698394c9e65033538255b609f5d5", null ],
[ "RESERVED4", "struct_l_p_c___r_t_c___type_def.html#a23568af560875ec74b660f1860e06d3b", null ],
[ "RESERVED5", "struct_l_p_c___r_t_c___type_def.html#a17b8ef27f4663f5d6b0fe9c46ab9bc3d", null ],
[ "RESERVED6", "struct_l_p_c___r_t_c___type_def.html#a585b017c54971fb297a30e3927437015", null ],
[ "RESERVED7", "struct_l_p_c___r_t_c___type_def.html#af2e6e355909e4223f7665881b0514716", null ],
[ "RESERVED8", "struct_l_p_c___r_t_c___type_def.html#a8cb0d97b1d31d1921acc7aa587d1c60b", null ],
[ "RESERVED9", "struct_l_p_c___r_t_c___type_def.html#ad8b1fadb520f7a200ee0046e110edc79", null ],
[ "RTC_AUX", "struct_l_p_c___r_t_c___type_def.html#a8a91a5b909fbba65b28d972c3164a4ed", null ],
[ "RTC_AUXEN", "struct_l_p_c___r_t_c___type_def.html#a4f807cc73e86fa24a247e0dce31512a4", null ],
[ "SEC", "struct_l_p_c___r_t_c___type_def.html#a77f4a78b486ec068e5ced41419805802", null ],
[ "YEAR", "struct_l_p_c___r_t_c___type_def.html#aaf0ddcf6e202e34e9cf7b35c584f9849", null ]
]; | NicoLingg/TemperatureSensor_DS1621 | html/struct_l_p_c___r_t_c___type_def.js | JavaScript | mit | 5,285 | [
30522,
13075,
2358,
6820,
6593,
1035,
1048,
1035,
1052,
1035,
1039,
1035,
1035,
1035,
1054,
1035,
1056,
1035,
1039,
1035,
1035,
1035,
2828,
1035,
13366,
1027,
1031,
1031,
1000,
28163,
2213,
1000,
1010,
1000,
2358,
6820,
6593,
1035,
1048,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.stratos.common.beans.topology;
import org.apache.stratos.common.beans.PropertyBean;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "clusters")
public class ClusterBean {
private String alias;
private String serviceName;
private String clusterId;
private List<MemberBean> member;
private String tenantRange;
private List<String> hostNames;
private boolean isLbCluster;
private List<PropertyBean> property;
private List<InstanceBean> instances;
public List<InstanceBean> getInstances() {
return instances;
}
public void setInstances(List<InstanceBean> instances) {
this.instances = instances;
}
@Override
public String toString() {
return "Cluster [serviceName=" + getServiceName() + ", clusterId=" + getClusterId() + ", member=" + getMember()
+ ", tenantRange=" + getTenantRange() + ", hostNames=" + getHostNames() + ", isLbCluster=" + isLbCluster()
+ ", property=" + getProperty() + "]";
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getClusterId() {
return clusterId;
}
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}
public List<MemberBean> getMember() {
return member;
}
public void setMember(List<MemberBean> member) {
this.member = member;
}
public String getTenantRange() {
return tenantRange;
}
public void setTenantRange(String tenantRange) {
this.tenantRange = tenantRange;
}
public List<String> getHostNames() {
return hostNames;
}
public void setHostNames(List<String> hostNames) {
this.hostNames = hostNames;
}
public boolean isLbCluster() {
return isLbCluster;
}
public void setLbCluster(boolean isLbCluster) {
this.isLbCluster = isLbCluster;
}
public List<PropertyBean> getProperty() {
return property;
}
public void setProperty(List<PropertyBean> property) {
this.property = property;
}
}
| pkdevbox/stratos | components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/topology/ClusterBean.java | Java | apache-2.0 | 3,225 | [
30522,
1013,
1008,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* MeetMeTalkingRequestEvent.cpp
*
* Created on: Mar 14, 2012
* Author: augcampos
*/
#include "asteriskcpp/manager/events/MeetMeTalkingRequestEvent.h"
namespace asteriskcpp {
MeetMeTalkingRequestEvent::MeetMeTalkingRequestEvent(const std::string & values) :
AbstractMeetMeEvent(values) {
}
MeetMeTalkingRequestEvent::~MeetMeTalkingRequestEvent() {
}
bool MeetMeTalkingRequestEvent::getStatus() const {
return (getProperty<bool>("Status"));
}
} /* namespace asteriskcpp */
| tiijima/asterisk-cpp | asterisk-cpp/src/manager/events/MeetMeTalkingRequestEvent.cpp | C++ | apache-2.0 | 526 | [
30522,
1013,
1008,
1008,
3113,
11368,
2389,
6834,
2890,
15500,
18697,
3372,
1012,
18133,
2361,
1008,
1008,
2580,
2006,
1024,
9388,
2403,
1010,
2262,
1008,
3166,
1024,
15476,
26468,
2891,
1008,
1013,
1001,
2421,
1000,
2004,
3334,
20573,
2190... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* This file is part of "SnipSnap Radeox Rendering Engine".
*
* Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
* All Rights Reserved.
*
* Please visit http://radeox.org/ for updates and contact.
*
* --LICENSE NOTICE--
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --LICENSE NOTICE--
*/
package org.snipsnap.test.render.macro.list;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.snipsnap.render.macro.list.ExampleListFormatter;
public class ExampleListFormatterTest extends ListFormatterSupport {
public ExampleListFormatterTest(String name) {
super(name);
}
public static Test suite() {
return new TestSuite(ExampleListFormatterTest.class);
}
protected void setUp() throws Exception {
super.setUp();
formatter = new ExampleListFormatter();
}
public void testSize() {
Collection c = Arrays.asList(new String[]{"test"});
try {
formatter.format(writer, emptyLinkable, "", c, "", true);
} catch (IOException e) {
e.printStackTrace();
}
assertEquals("Size is rendered",
"<div class=\"list\"><div class=\"list-title\"> (1)</div><ol><li>test</li></ol></div>",
writer.toString());
}
public void testSingeItem() {
Collection c = Arrays.asList(new String[]{"test"});
try {
formatter.format(writer, emptyLinkable, "", c, "", false);
} catch (IOException e) {
e.printStackTrace();
}
assertEquals("Single item is rendered",
"<div class=\"list\"><div class=\"list-title\"></div><ol><li>test</li></ol></div>",
writer.toString());
}
}
| thinkberg/snipsnap | src/org/snipsnap/test/render/macro/list/ExampleListFormatterTest.java | Java | gpl-2.0 | 2,383 | [
30522,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1000,
1055,
3490,
4523,
2532,
2361,
10958,
3207,
11636,
14259,
3194,
1000,
1012,
1008,
1008,
9385,
1006,
1039,
1007,
2526,
15963,
1046,
1012,
12940,
1010,
17885,
1048,
1012,
26536,
2884... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"use strict";
exports.__esModule = true;
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _createElement = _interopRequireDefault(require("../createElement"));
var _useMergeRefs = _interopRequireDefault(require("../../modules/useMergeRefs"));
var _usePlatformMethods = _interopRequireDefault(require("../../modules/usePlatformMethods"));
var _PickerItem = _interopRequireDefault(require("./PickerItem"));
var _StyleSheet = _interopRequireDefault(require("../StyleSheet"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var Picker = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
var children = props.children,
enabled = props.enabled,
onValueChange = props.onValueChange,
selectedValue = props.selectedValue,
style = props.style,
testID = props.testID,
itemStyle = props.itemStyle,
mode = props.mode,
prompt = props.prompt,
other = _objectWithoutPropertiesLoose(props, ["children", "enabled", "onValueChange", "selectedValue", "style", "testID", "itemStyle", "mode", "prompt"]);
var hostRef = React.useRef(null);
function handleChange(e) {
var _e$target = e.target,
selectedIndex = _e$target.selectedIndex,
value = _e$target.value;
if (onValueChange) {
onValueChange(value, selectedIndex);
}
} // $FlowFixMe
var supportedProps = _objectSpread({
children: children,
disabled: enabled === false ? true : undefined,
onChange: handleChange,
style: [styles.initial, style],
testID: testID,
value: selectedValue
}, other);
var platformMethodsRef = (0, _usePlatformMethods.default)(supportedProps);
var setRef = (0, _useMergeRefs.default)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
return (0, _createElement.default)('select', supportedProps);
}); // $FlowFixMe
Picker.Item = _PickerItem.default;
var styles = _StyleSheet.default.create({
initial: {
fontFamily: 'System',
fontSize: 'inherit',
margin: 0
}
});
var _default = Picker;
exports.default = _default;
module.exports = exports.default; | cdnjs/cdnjs | ajax/libs/react-native-web/0.17.7/cjs/exports/Picker/index.js | JavaScript | mit | 4,540 | [
30522,
1000,
2224,
9384,
1000,
1025,
14338,
1012,
1035,
1035,
9686,
5302,
8566,
2571,
1027,
2995,
1025,
14338,
1012,
12398,
1027,
11675,
1014,
1025,
13075,
10509,
1027,
1035,
30524,
4232,
1006,
5478,
1006,
1000,
10509,
1000,
1007,
1007,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var fnObj = {};
var ACTIONS = axboot.actionExtend(fnObj, {
PAGE_SEARCH: function (caller, act, data) {
axboot.ajax({
type: "GET",
url: ["samples", "parent"],
data: caller.searchView.getData(),
callback: function (res) {
caller.gridView01.setData(res);
},
options: {
// axboot.ajax 함수에 2번째 인자는 필수가 아닙니다. ajax의 옵션을 전달하고자 할때 사용합니다.
onError: function (err) {
console.log(err);
}
}
});
return false;
},
PAGE_SAVE: function (caller, act, data) {
var saveList = [].concat(caller.gridView01.getData("modified"));
saveList = saveList.concat(caller.gridView01.getData("deleted"));
axboot.ajax({
type: "PUT",
url: ["samples", "parent"],
data: JSON.stringify(saveList),
callback: function (res) {
ACTIONS.dispatch(ACTIONS.PAGE_SEARCH);
axToast.push("저장 되었습니다");
}
});
},
ITEM_CLICK: function (caller, act, data) {
},
ITEM_ADD: function (caller, act, data) {
caller.gridView01.addRow();
},
ITEM_DEL: function (caller, act, data) {
caller.gridView01.delRow("selected");
}
});
// fnObj 기본 함수 스타트와 리사이즈
fnObj.pageStart = function () {
this.pageButtonView.initView();
this.searchView.initView();
this.gridView01.initView();
ACTIONS.dispatch(ACTIONS.PAGE_SEARCH);
};
fnObj.pageResize = function () {
};
fnObj.pageButtonView = axboot.viewExtend({
initView: function () {
axboot.buttonClick(this, "data-page-btn", {
"search": function () {
ACTIONS.dispatch(ACTIONS.PAGE_SEARCH);
},
"save": function () {
ACTIONS.dispatch(ACTIONS.PAGE_SAVE);
},
"excel": function () {
}
});
}
});
//== view 시작
/**
* searchView
*/
fnObj.searchView = axboot.viewExtend(axboot.searchView, {
initView: function () {
this.target = $(document["searchView0"]);
this.target.attr("onsubmit", "return ACTIONS.dispatch(ACTIONS.PAGE_SEARCH);");
this.filter = $("#filter");
},
getData: function () {
return {
pageNumber: this.pageNumber,
pageSize: this.pageSize,
filter: this.filter.val()
}
}
});
/**
* gridView
*/
fnObj.gridView01 = axboot.viewExtend(axboot.gridView, {
initView: function () {
var _this = this;
this.target = axboot.gridBuilder({
showRowSelector: true,
frozenColumnIndex: 0,
multipleSelect: true,
target: $('[data-ax5grid="grid-view-01"]'),
columns: [
{key: "key", label: "KEY", width: 160, align: "left", editor: "text"},
{key: "value", label: "VALUE", width: 350, align: "left", editor: "text"},
{key: "etc1", label: "ETC1", width: 100, align: "center", editor: "text"},
{key: "etc2", label: "ETC2", width: 100, align: "center", editor: "text"},
{key: "etc3", label: "ETC3", width: 100, align: "center", editor: "text"},
{key: "etc4", label: "ETC4", width: 100, align: "center", editor: "text"}
],
body: {
onClick: function () {
this.self.select(this.dindex, {selectedClear: true});
}
}
});
axboot.buttonClick(this, "data-grid-view-01-btn", {
"add": function () {
ACTIONS.dispatch(ACTIONS.ITEM_ADD);
},
"delete": function () {
ACTIONS.dispatch(ACTIONS.ITEM_DEL);
}
});
},
getData: function (_type) {
var list = [];
var _list = this.target.getList(_type);
if (_type == "modified" || _type == "deleted") {
list = ax5.util.filter(_list, function () {
delete this.deleted;
return this.key;
});
} else {
list = _list;
}
return list;
},
addRow: function () {
this.target.addRow({__created__: true}, "last");
}
}); | axboot/ax-boot-framework | ax-boot-initialzr/src/main/resources/templates/webapp/assets/js/view/login.js | JavaScript | mit | 4,420 | [
30522,
13075,
1042,
25083,
3501,
1027,
1063,
1065,
1025,
13075,
4506,
1027,
22260,
27927,
1012,
2895,
10288,
6528,
2094,
1006,
1042,
25083,
3501,
1010,
1063,
3931,
1035,
3945,
1024,
3853,
1006,
20587,
1010,
2552,
1010,
2951,
1007,
1063,
222... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.phoenix.util.csv;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Base64;
import java.util.List;
import java.util.Properties;
import javax.annotation.Nullable;
import org.apache.commons.csv.CSVRecord;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.expression.function.EncodeFormat;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
import org.apache.phoenix.schema.IllegalDataException;
import org.apache.phoenix.schema.types.PBinary;
import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.types.PDataType.PDataCodec;
import org.apache.phoenix.schema.types.PTimestamp;
import org.apache.phoenix.schema.types.PVarbinary;
import org.apache.phoenix.util.ColumnInfo;
import org.apache.phoenix.util.DateUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.UpsertExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
/** {@link UpsertExecutor} over {@link CSVRecord}s. */
public class CsvUpsertExecutor extends UpsertExecutor<CSVRecord, String> {
private static final Logger LOG = LoggerFactory.getLogger(CsvUpsertExecutor.class);
protected final String arrayElementSeparator;
/** Testing constructor. Do not use in prod. */
@VisibleForTesting
protected CsvUpsertExecutor(Connection conn, List<ColumnInfo> columnInfoList,
PreparedStatement stmt, UpsertListener<CSVRecord> upsertListener,
String arrayElementSeparator) {
super(conn, columnInfoList, stmt, upsertListener);
this.arrayElementSeparator = arrayElementSeparator;
finishInit();
}
public CsvUpsertExecutor(Connection conn, String tableName,
List<ColumnInfo> columnInfoList, UpsertListener<CSVRecord> upsertListener,
String arrayElementSeparator) {
super(conn, tableName, columnInfoList, upsertListener);
this.arrayElementSeparator = arrayElementSeparator;
finishInit();
}
@Override
protected void execute(CSVRecord csvRecord) {
try {
if (csvRecord.size() < conversionFunctions.size()) {
String message = String.format("CSV record does not have enough values (has %d, but needs %d)",
csvRecord.size(), conversionFunctions.size());
throw new IllegalArgumentException(message);
}
for (int fieldIndex = 0; fieldIndex < conversionFunctions.size(); fieldIndex++) {
Object sqlValue = conversionFunctions.get(fieldIndex).apply(csvRecord.get(fieldIndex));
if (sqlValue != null) {
preparedStatement.setObject(fieldIndex + 1, sqlValue);
} else {
preparedStatement.setNull(fieldIndex + 1, dataTypes.get(fieldIndex).getSqlType());
}
}
preparedStatement.execute();
upsertListener.upsertDone(++upsertCount);
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
// Even though this is an error we only log it with debug logging because we're notifying the
// listener, and it can do its own logging if needed
LOG.debug("Error on CSVRecord " + csvRecord, e);
}
upsertListener.errorOnRecord(csvRecord, e);
}
}
@Override
protected Function<String, Object> createConversionFunction(PDataType dataType) {
if (dataType.isArrayType()) {
return new ArrayDatatypeConversionFunction(
new StringToArrayConverter(
conn,
arrayElementSeparator,
PDataType.fromTypeId(dataType.getSqlType() - PDataType.ARRAY_TYPE_BASE)));
} else {
return new SimpleDatatypeConversionFunction(dataType, this.conn);
}
}
/**
* Performs typed conversion from String values to a given column value type.
*/
static class SimpleDatatypeConversionFunction implements Function<String, Object> {
private final PDataType dataType;
private final PDataCodec codec;
private final DateUtil.DateTimeParser dateTimeParser;
private final String binaryEncoding;
SimpleDatatypeConversionFunction(PDataType dataType, Connection conn) {
ReadOnlyProps props;
try {
props = conn.unwrap(PhoenixConnection.class).getQueryServices().getProps();
} catch (SQLException e) {
throw new RuntimeException(e);
}
this.dataType = dataType;
PDataCodec codec = dataType.getCodec();
if(dataType.isCoercibleTo(PTimestamp.INSTANCE)) {
codec = DateUtil.getCodecFor(dataType);
// TODO: move to DateUtil
String dateFormat;
int dateSqlType = dataType.getResultSetSqlType();
if (dateSqlType == Types.DATE) {
dateFormat = props.get(QueryServices.DATE_FORMAT_ATTRIB,
DateUtil.DEFAULT_DATE_FORMAT);
} else if (dateSqlType == Types.TIME) {
dateFormat = props.get(QueryServices.TIME_FORMAT_ATTRIB,
DateUtil.DEFAULT_TIME_FORMAT);
} else {
dateFormat = props.get(QueryServices.TIMESTAMP_FORMAT_ATTRIB,
DateUtil.DEFAULT_TIMESTAMP_FORMAT);
}
String timeZoneId = props.get(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB,
QueryServicesOptions.DEFAULT_DATE_FORMAT_TIMEZONE);
this.dateTimeParser = DateUtil.getDateTimeParser(dateFormat, dataType, timeZoneId);
} else {
this.dateTimeParser = null;
}
this.codec = codec;
this.binaryEncoding = props.get(QueryServices.UPLOAD_BINARY_DATA_TYPE_ENCODING,
QueryServicesOptions.DEFAULT_UPLOAD_BINARY_DATA_TYPE_ENCODING);
}
@Nullable
@Override
public Object apply(@Nullable String input) {
if (input == null || input.isEmpty()) {
return null;
}
if (dataType == PTimestamp.INSTANCE) {
return DateUtil.parseTimestamp(input);
}
if (dateTimeParser != null) {
long epochTime = dateTimeParser.parseDateTime(input);
byte[] byteValue = new byte[dataType.getByteSize()];
codec.encodeLong(epochTime, byteValue, 0);
return dataType.toObject(byteValue);
} else if (dataType == PBoolean.INSTANCE) {
switch (input.toLowerCase()) {
case "true":
case "t":
case "1":
return Boolean.TRUE;
case "false":
case "f":
case "0":
return Boolean.FALSE;
default:
throw new RuntimeException("Invalid boolean value: '" + input
+ "', must be one of ['true','t','1','false','f','0']");
}
}else if (dataType == PVarbinary.INSTANCE || dataType == PBinary.INSTANCE){
EncodeFormat format = EncodeFormat.valueOf(binaryEncoding.toUpperCase());
Object object = null;
switch (format) {
case BASE64:
object = Base64.getDecoder().decode(input);
if (object == null) { throw new IllegalDataException(
"Input: [" + input + "] is not base64 encoded"); }
break;
case ASCII:
object = Bytes.toBytes(input);
break;
default:
throw new IllegalDataException("Unsupported encoding \"" + binaryEncoding + "\"");
}
return object;
}
return dataType.toObject(input);
}
}
/**
* Converts string representations of arrays into Phoenix arrays of the correct type.
*/
private static class ArrayDatatypeConversionFunction implements Function<String, Object> {
private final StringToArrayConverter arrayConverter;
private ArrayDatatypeConversionFunction(StringToArrayConverter arrayConverter) {
this.arrayConverter = arrayConverter;
}
@Nullable
@Override
public Object apply(@Nullable String input) {
try {
return arrayConverter.toArray(input);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
| ohadshacham/phoenix | phoenix-core/src/main/java/org/apache/phoenix/util/csv/CsvUpsertExecutor.java | Java | apache-2.0 | 10,075 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python3
#
# Copyright (c) 2017 Nick Douma
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from argparse import ArgumentParser, ArgumentTypeError
import datetime
import json
import re
import urllib.error
import urllib.parse
import urllib.request
import sys
ISO8601 = r"^(\d{4})-?(\d{2})-?(\d{2})?[T ]?(\d{2}):?(\d{2}):?(\d{2})"
def iso8601_to_unix_timestamp(value):
try:
return int(value)
except ValueError:
pass
matches = re.match(ISO8601, value)
if not matches:
raise ArgumentTypeError("Argument is not a valid UNIX or ISO8601 "
"timestamp.")
return int(datetime.datetime(
*[int(m) for m in matches.groups()])).timestamp()
def hex_value(value):
value = value.replace("#", "")
if not re.match(r"^[a-f0-9]{6}$", value):
raise ArgumentTypeError("Argument is not a valid hex value.")
return value
parser = ArgumentParser(description="Send notifications using Slack")
parser.add_argument("--webhook-url", help="Webhook URL.", required=True)
parser.add_argument("--channel", help="Channel to post to (prefixed with #), "
"or a specific user (prefixed with @).")
parser.add_argument("--username", help="Username to post as")
parser.add_argument("--title", help="Notification title.")
parser.add_argument("--title_link", help="Notification title link.")
parser.add_argument("--color", help="Sidebar color (as a hex value).",
type=hex_value)
parser.add_argument("--ts", help="Unix timestamp or ISO8601 timestamp "
"(will be converted to Unix timestamp).",
type=iso8601_to_unix_timestamp)
parser.add_argument("message", help="Notification message.")
args = parser.parse_args()
message = {}
for param in ["channel", "username"]:
value = getattr(args, param)
if value:
message[param] = value
attachment = {}
for param in ["title", "title_link", "color", "ts", "message"]:
value = getattr(args, param)
if value:
attachment[param] = value
attachment['fallback'] = attachment['message']
attachment['text'] = attachment['message']
del attachment['message']
message['attachments'] = [attachment]
payload = {"payload": json.dumps(message)}
try:
parameters = urllib.parse.urlencode(payload).encode('UTF-8')
url = urllib.request.Request(args.webhook_url, parameters)
responseData = urllib.request.urlopen(url).read()
except urllib.error.HTTPError as he:
print("Sending message to Slack failed: {}".format(he))
sys.exit(1)
| LordGaav/notification-scripts | slack.py | Python | mit | 3,578 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
2509,
1001,
1001,
9385,
1006,
1039,
1007,
2418,
4172,
2079,
12248,
1001,
1001,
6656,
2003,
2182,
3762,
4379,
1010,
2489,
1997,
3715,
1010,
2000,
2151,
2711,
11381,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.elasticsearch;
import java.util.HashMap;
import java.util.Map;
import org.apache.camel.Component;
import org.apache.camel.component.extension.ComponentVerifierExtension;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Assert;
import org.junit.Test;
public class ElasticsearchRestComponentVerifierExtensionTest extends CamelTestSupport {
// *************************************************
// Tests (parameters)
// *************************************************
@Override
public boolean isUseRouteBuilder() {
return false;
}
@Test
public void testParameters() throws Exception {
Component component = context().getComponent("elasticsearch-rest");
ComponentVerifierExtension verifier = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new);
Map<String, Object> parameters = new HashMap<>();
parameters.put("hostAddresses", "http://localhost:9000");
parameters.put("clusterName", "es-test");
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus());
}
@Test
public void testConnectivity() throws Exception {
Component component = context().getComponent("elasticsearch-rest");
ComponentVerifierExtension verifier = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new);
Map<String, Object> parameters = new HashMap<>();
parameters.put("hostAddresses", "http://localhost:9000");
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus());
}
}
| objectiser/camel | components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchRestComponentVerifierExtensionTest.java | Java | apache-2.0 | 2,756 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
Copyright (c) 2009 Andras Mantia <amantia@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef AKONADI_IMAPSTREAMPARSER_P_H
#define AKONADI_IMAPSTREAMPARSER_P_H
#include "imapset_p.h"
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QVarLengthArray>
#include <QtCore/QObject>
#include <QtCore/QDateTime>
#include "exception.h"
AKONADI_EXCEPTION_MAKE_INSTANCE( ImapParserException );
class QIODevice;
class ImapStreamParserTest;
namespace Akonadi {
namespace Server {
/**
Parser for IMAP messages that operates on a local socket stream.
*/
class ImapStreamParser
{
friend class ::ImapStreamParserTest;
public:
/**
* Construct the parser.
* @param socket the local socket to work with.
*/
ImapStreamParser( QIODevice *socket );
/**
* Destructor.
*/
~ImapStreamParser();
/**
* Sets how long the parser should wait for socket to provide more data before
* aborting with error.
*
* Default value is 30 seconds. This method is used mainly to speed up
* unittests.
*/
void setWaitTimeout(int msecs);
/**
* Get a string from the message. If the upcoming data is not a quoted string, unquoted string or a literal,
* the behavior is undefined. Use @ref hasString to be sure a string comes. This call might block.
* @return the next string from the message as an utf8 string
*/
QString readUtf8String();
/**
* Same as above, but without decoding it to utf8.
* @return the next string from the message
*/
QByteArray readString();
/**
* Same as above, but without actually moving the stream position forward.
* @return the next string from the stream, without modifying the stream.
*/
QByteArray peekString();
/**
* Get he next IMAP sequence set. If the upcoming data is not an IMAP sequence set,
* the behavior is undefined. Use @ref hasSequenceSet to be sure a sequence set comes. This call might block.
* @return the next IMAP sequence set.
*/
ImapSet readSequenceSet();
/**
* Get he next parenthesized list. If the upcoming data is not a parenthesized list,
* the behavior is undefined. Use @ref hasList to be sure a string comes. This call might block.
* @return the next parenthesized list.
*/
QList<QByteArray> readParenthesizedList();
/**
* Read a single character. This call might block.
* @return the read character
*/
QByteRef readChar();
/**
* Get the next data as a number. This call might block.
* @param ok true if the data found was a number
* @return the number
*/
qint64 readNumber( bool *ok = 0 );
/**
* Check if the next data is a string or not. This call might block.
* @return true if a string follows
*/
bool hasString();
/**
* Check if the next data is a literal data or not. If a literal is found, the
* internal position pointer is set to the beginning of the literal data.
* This call might block.
* @return true if a literal follows
*/
bool hasLiteral( bool requestData = true);
/**
* Read the next literal sequence. This might or might not be the full data. Example code to read a literal would be:
* @code
* ImapStreamParser parser;
* ...
* if (parser.hasLiteral())
* {
* while (!parser.atLiteralEnd())
* {
* QByteArray data = parser.readLiteralPart();
* // do something with the data
* }
* }
* @endcode
*
* This call might block.
*
* @return part of a literal data
*/
QByteArray readLiteralPart();
/**
* Check if the literal data end was reached. See @ref hasLiteral and @ref readLiteralPart .
* @return true if the literal was completely read.
*/
bool atLiteralEnd() const;
/**
* Get the amount of data that needs to be read for the last literal. If this is called right after hasLiteral, the actual size of the literal data
* is returned.
* @return the remaining literal size
*/
qint64 remainingLiteralSize();
/**
* Check if the next data is an IMAP sequence set. This call might block.
* @return true if an IMAP sequence set comes.
*/
bool hasSequenceSet();
/**
* Check if the next data is a parenthesized list. This call might block.
* @return true if a parenthesized list comes.
*/
bool hasList();
/**
* Begin reading a parenthesized list. This call might block.
* This call will throw an exception if the parser is not at a beginning of a list,
* that is hasList() returns false.
* @see hasList(), atListEnd
*/
void beginList();
/**
* Check if the next data is a parenthesized list end. This call might block.
* @return true if a parenthesized list end. In this case the closing parenthesis
* is read from the stream.
*/
bool atListEnd();
/**
* Read a date/time.
* @return the date and time or a null QDateTime, if no valid date/time was found
*/
QDateTime readDateTime();
/**
* Check if the next element in the data stream is a date or not.
* @return true, if a valid date follows
*/
bool hasDateTime();
/**
* Check if the command end was reached
* @return true if the end of command is reached
*/
bool atCommandEnd();
/**
* Return everything that remained from the command, <em>including not yet
* requested</em> literal parts.
* @return the remaining command data
* @see skipCurrentCommand
*/
QByteArray readUntilCommandEnd();
/**
* This reads until the end of the <em>already sent</em> command and does not
* request not yet sent literal parts.
* @see readUntilCommandEnd
*/
void skipCurrentCommand();
/**
* Return all the data that was read from the socket, but not processed yet.
* @return the remaining unprocessed data
*/
QByteArray readRemainingData();
void setData( const QByteArray &data );
/**
* Inserts some data back into the parse buffer at the current position.
* @param data data to be inserted
*/
void insertData( const QByteArray &data );
/**
* Appends some data to the end of the parse buffer.
* @param data data to be appended
*/
void appendData( const QByteArray &data );
/**
* Skips everything until the first character that isn't a space.
*/
void stripLeadingSpaces();
/**
* Set the identification used for Tracer calls.
*/
void setTracerIdentifier( const QString &id );
/**
* Inform the client to send more literal data.
* @param size size of the requested literal in bytes
*/
void sendContinuationResponse( qint64 size );
private:
QByteArray parseQuotedString();
/**
* If the condition is true, wait for more data to be available from the socket.
* If no data comes after a timeout (30000ms), it aborts and returns false.
* @param wait the condition
* @return true if more data is available
*/
bool waitForMoreData( bool wait );
QIODevice *m_socket;
QByteArray m_data;
QByteArray m_tag;
QString m_tracerId;
int m_position;
qint64 m_literalSize;
bool m_peeking;
int m_timeout;
};
} // namespace Server
} // namespace Akonadi
#endif
| kolab-groupware/akonadi | server/src/imapstreamparser.h | C | lgpl-2.1 | 8,295 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2294,
1011,
2289,
5285,
5484,
30524,
3207,
1012,
8917,
1028,
9385,
1006,
1039,
1007,
2268,
1998,
8180,
2158,
10711,
1026,
25933,
16778,
2050,
1030,
1047,
3207,
1012,
8917,
1028,
2023,
3075,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
get_header();
$show_default_title = get_post_meta( get_the_ID(), '_et_pb_show_title', true );
$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
?>
<div id="main-content">
<div class="breadcrumbs">
<a href="/">CRGC Home</a> > <a href="/news/">News</a> >
</div>
<div class="container">
<div id="content-area" class="clearfix">
<div id="left-area">
<?php while ( have_posts() ) : the_post(); ?>
<?php if (et_get_option('divi_integration_single_top') <> '' && et_get_option('divi_integrate_singletop_enable') == 'on') echo(et_get_option('divi_integration_single_top')); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
<?php if ( ( 'off' !== $show_default_title && $is_page_builder_used ) || ! $is_page_builder_used ) { ?>
<div class="et_post_meta_wrapper">
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php
if ( ! post_password_required() ) :
et_divi_post_meta();
$thumb = '';
$width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );
$height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
$classtext = 'et_featured_image';
$titletext = get_the_title();
$thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
$thumb = $thumbnail["thumb"];
$post_format = et_pb_post_format();
if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) {
printf(
'<div class="et_main_video_container">
%1$s
</div>',
$first_video
);
} else if ( ! in_array( $post_format, array( 'gallery', 'link', 'quote' ) ) && 'on' === et_get_option( 'divi_thumbnails', 'on' ) && '' !== $thumb ) {
print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
} else if ( 'gallery' === $post_format ) {
et_pb_gallery_images();
}
?>
<?php
$text_color_class = et_divi_get_post_text_color();
$inline_style = et_divi_get_post_bg_inline_style();
switch ( $post_format ) {
case 'audio' :
printf(
'<div class="et_audio_content%1$s"%2$s>
%3$s
</div>',
esc_attr( $text_color_class ),
$inline_style,
et_pb_get_audio_player()
);
break;
case 'quote' :
printf(
'<div class="et_quote_content%2$s"%3$s>
%1$s
</div> <!-- .et_quote_content -->',
et_get_blockquote_in_content(),
esc_attr( $text_color_class ),
$inline_style
);
break;
case 'link' :
printf(
'<div class="et_link_content%3$s"%4$s>
<a href="%1$s" class="et_link_main_url">%2$s</a>
</div> <!-- .et_link_content -->',
esc_url( et_get_link_url() ),
esc_html( et_get_link_url() ),
esc_attr( $text_color_class ),
$inline_style
);
break;
}
endif;
?>
</div> <!-- .et_post_meta_wrapper -->
<?php } ?>
<div class="entry-content">
<?php
the_content();
wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'Divi' ), 'after' => '</div>' ) );
?>
</div> <!-- .entry-content -->
<div class="et_post_meta_wrapper">
<?php
if ( et_get_option('divi_468_enable') == 'on' ){
echo '<div class="et-single-post-ad">';
if ( et_get_option('divi_468_adsense') <> '' ) echo( et_get_option('divi_468_adsense') );
else { ?>
<a href="<?php echo esc_url(et_get_option('divi_468_url')); ?>"><img src="<?php echo esc_attr(et_get_option('divi_468_image')); ?>" alt="468" class="foursixeight" /></a>
<?php }
echo '</div> <!-- .et-single-post-ad -->';
}
?>
<?php
if ( ( comments_open() || get_comments_number() ) && 'on' == et_get_option( 'divi_show_postcomments', 'on' ) )
comments_template( '', true );
?>
</div> <!-- .et_post_meta_wrapper -->
</article> <!-- .et_pb_post -->
<?php if (et_get_option('divi_integration_single_bottom') <> '' && et_get_option('divi_integrate_singlebottom_enable') == 'on') echo(et_get_option('divi_integration_single_bottom')); ?>
<?php endwhile; ?>
</div> <!-- #left-area -->
<?php /* get_sidebar(); */ ?>
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->
<?php get_footer(); ?> | tcheektulane/DiviRAND | single.php | PHP | gpl-3.0 | 4,624 | [
30522,
1026,
1029,
25718,
2131,
1035,
20346,
1006,
1007,
1025,
1002,
2265,
1035,
12398,
1035,
2516,
1027,
2131,
1035,
2695,
1035,
18804,
1006,
2131,
1035,
1996,
1035,
8909,
1006,
1007,
1010,
1005,
1035,
3802,
1035,
1052,
2497,
1035,
2265,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
/**
* appDevUrlMatcher
*
* This class has been auto-generated
* by the Symfony Routing Component.
*/
class appDevUrlMatcher extends Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher
{
/**
* Constructor.
*/
public function __construct(RequestContext $context)
{
$this->context = $context;
}
public function match($pathinfo)
{
$allow = array();
$pathinfo = rawurldecode($pathinfo);
if (0 === strpos($pathinfo, '/_')) {
// _wdt
if (0 === strpos($pathinfo, '/_wdt') && preg_match('#^/_wdt/(?P<token>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_wdt')), array ( '_controller' => 'web_profiler.controller.profiler:toolbarAction',));
}
if (0 === strpos($pathinfo, '/_profiler')) {
// _profiler_home
if (rtrim($pathinfo, '/') === '/_profiler') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', '_profiler_home');
}
return array ( '_controller' => 'web_profiler.controller.profiler:homeAction', '_route' => '_profiler_home',);
}
if (0 === strpos($pathinfo, '/_profiler/search')) {
// _profiler_search
if ($pathinfo === '/_profiler/search') {
return array ( '_controller' => 'web_profiler.controller.profiler:searchAction', '_route' => '_profiler_search',);
}
// _profiler_search_bar
if ($pathinfo === '/_profiler/search_bar') {
return array ( '_controller' => 'web_profiler.controller.profiler:searchBarAction', '_route' => '_profiler_search_bar',);
}
}
// _profiler_purge
if ($pathinfo === '/_profiler/purge') {
return array ( '_controller' => 'web_profiler.controller.profiler:purgeAction', '_route' => '_profiler_purge',);
}
if (0 === strpos($pathinfo, '/_profiler/i')) {
// _profiler_info
if (0 === strpos($pathinfo, '/_profiler/info') && preg_match('#^/_profiler/info/(?P<about>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_info')), array ( '_controller' => 'web_profiler.controller.profiler:infoAction',));
}
// _profiler_import
if ($pathinfo === '/_profiler/import') {
return array ( '_controller' => 'web_profiler.controller.profiler:importAction', '_route' => '_profiler_import',);
}
}
// _profiler_export
if (0 === strpos($pathinfo, '/_profiler/export') && preg_match('#^/_profiler/export/(?P<token>[^/\\.]++)\\.txt$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_export')), array ( '_controller' => 'web_profiler.controller.profiler:exportAction',));
}
// _profiler_phpinfo
if ($pathinfo === '/_profiler/phpinfo') {
return array ( '_controller' => 'web_profiler.controller.profiler:phpinfoAction', '_route' => '_profiler_phpinfo',);
}
// _profiler_search_results
if (preg_match('#^/_profiler/(?P<token>[^/]++)/search/results$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_search_results')), array ( '_controller' => 'web_profiler.controller.profiler:searchResultsAction',));
}
// _profiler
if (preg_match('#^/_profiler/(?P<token>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler')), array ( '_controller' => 'web_profiler.controller.profiler:panelAction',));
}
// _profiler_router
if (preg_match('#^/_profiler/(?P<token>[^/]++)/router$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_router')), array ( '_controller' => 'web_profiler.controller.router:panelAction',));
}
// _profiler_exception
if (preg_match('#^/_profiler/(?P<token>[^/]++)/exception$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_exception')), array ( '_controller' => 'web_profiler.controller.exception:showAction',));
}
// _profiler_exception_css
if (preg_match('#^/_profiler/(?P<token>[^/]++)/exception\\.css$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_profiler_exception_css')), array ( '_controller' => 'web_profiler.controller.exception:cssAction',));
}
}
if (0 === strpos($pathinfo, '/_configurator')) {
// _configurator_home
if (rtrim($pathinfo, '/') === '/_configurator') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', '_configurator_home');
}
return array ( '_controller' => 'Sensio\\Bundle\\DistributionBundle\\Controller\\ConfiguratorController::checkAction', '_route' => '_configurator_home',);
}
// _configurator_step
if (0 === strpos($pathinfo, '/_configurator/step') && preg_match('#^/_configurator/step/(?P<index>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_configurator_step')), array ( '_controller' => 'Sensio\\Bundle\\DistributionBundle\\Controller\\ConfiguratorController::stepAction',));
}
// _configurator_final
if ($pathinfo === '/_configurator/final') {
return array ( '_controller' => 'Sensio\\Bundle\\DistributionBundle\\Controller\\ConfiguratorController::finalAction', '_route' => '_configurator_final',);
}
}
}
if (0 === strpos($pathinfo, '/collection')) {
// lien_collection
if (rtrim($pathinfo, '/') === '/collection') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_collection');
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::indexAction', '_route' => 'lien_collection',);
}
// lien_collection_show
if (preg_match('#^/collection/(?P<id>[^/]++)/(?P<slug>[^/]++)(?:/(?P<page>[^/]++))?$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_collection_show')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::showAction', 'page' => 1,));
}
// lien_collection_new
if ($pathinfo === '/collection/new') {
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::newAction', '_route' => 'lien_collection_new',);
}
// lien_collection_create
if ($pathinfo === '/collection/create') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_collection_create;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::createAction', '_route' => 'lien_collection_create',);
}
not_lien_collection_create:
// lien_collection_edit
if (0 === strpos($pathinfo, '/collection/edit') && preg_match('#^/collection/edit/(?P<id>[^/]++)/?$#s', $pathinfo, $matches)) {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_collection_edit');
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_collection_edit')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::editAction',));
}
// lien_collection_update
if (preg_match('#^/collection/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
$allow = array_merge($allow, array('POST', 'PUT'));
goto not_lien_collection_update;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_collection_update')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::updateAction',));
}
not_lien_collection_update:
// lien_collection_delete
if (preg_match('#^/collection/(?P<id>[^/]++)/delete$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'DELETE'))) {
$allow = array_merge($allow, array('POST', 'DELETE'));
goto not_lien_collection_delete;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_collection_delete')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\CollectionController::deleteAction',));
}
not_lien_collection_delete:
}
if (0 === strpos($pathinfo, '/avis')) {
// lien_avis
if (rtrim($pathinfo, '/') === '/avis') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_avis');
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::indexAction', '_route' => 'lien_avis',);
}
// lien_avis_show
if (preg_match('#^/avis/(?P<id>[^/]++)/show$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_avis_show')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::showAction',));
}
// lien_avis_new
if ($pathinfo === '/avis/new') {
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::newAction', '_route' => 'lien_avis_new',);
}
// lien_avis_create
if ($pathinfo === '/avis/create') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_avis_create;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::createAction', '_route' => 'lien_avis_create',);
}
not_lien_avis_create:
// lien_avis_edit
if (preg_match('#^/avis/(?P<id>[^/]++)/edit$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_avis_edit')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::editAction',));
}
// lien_avis_update
if (preg_match('#^/avis/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
$allow = array_merge($allow, array('POST', 'PUT'));
goto not_lien_avis_update;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_avis_update')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::updateAction',));
}
not_lien_avis_update:
// lien_avis_delete
if (preg_match('#^/avis/(?P<id>[^/]++)/delete$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'DELETE'))) {
$allow = array_merge($allow, array('POST', 'DELETE'));
goto not_lien_avis_delete;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_avis_delete')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\AvisUserLivreController::deleteAction',));
}
not_lien_avis_delete:
}
if (0 === strpos($pathinfo, '/livre')) {
// lien_livre
if (rtrim($pathinfo, '/') === '/livre') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_livre');
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::indexAction', '_route' => 'lien_livre',);
}
// lien_livre_read
if (0 === strpos($pathinfo, '/livre/read') && preg_match('#^/livre/read/(?P<collection>[^/]++)/(?P<auteur>[^/]++)/(?P<id>\\d+)/(?P<titre>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_read')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::readAction',));
}
// lien_livre_show
if (preg_match('#^/livre/(?P<collection>[^/]++)/(?P<auteur>[^/]++)/(?P<id>\\d+)/(?P<titre>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_show')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::showAction',));
}
// lien_livre_all
if (0 === strpos($pathinfo, '/livre/liste') && preg_match('#^/livre/liste(?:/(?P<page>[^/]++))?$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_all')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::allAction', 'page' => 1,));
}
// lien_livre_show_all
if (0 === strpos($pathinfo, '/livre/catalogue') && preg_match('#^/livre/catalogue(?:/(?P<page>[^/]++))?$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_show_all')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::showAllAction', 'page' => 1,));
}
// lien_livre_find
if ($pathinfo === '/livre/recherche') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_livre_find;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::findAction', '_route' => 'lien_livre_find',);
}
not_lien_livre_find:
// lien_livre_new
if ($pathinfo === '/livre/new') {
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::newAction', '_route' => 'lien_livre_new',);
}
// lien_livre_create
if ($pathinfo === '/livre/create') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_livre_create;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::createAction', '_route' => 'lien_livre_create',);
}
not_lien_livre_create:
// lien_livre_edit
if (preg_match('#^/livre/(?P<id>[^/]++)/edit$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_edit')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::editAction',));
}
// lien_livre_update
if (preg_match('#^/livre/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
$allow = array_merge($allow, array('POST', 'PUT'));
goto not_lien_livre_update;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_update')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::updateAction',));
}
not_lien_livre_update:
// lien_livre_delete
if (preg_match('#^/livre/(?P<id>[^/]++)/delete$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'DELETE'))) {
$allow = array_merge($allow, array('POST', 'DELETE'));
goto not_lien_livre_delete;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_livre_delete')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\LivreController::deleteAction',));
}
not_lien_livre_delete:
}
if (0 === strpos($pathinfo, '/user')) {
// lien_user
if (rtrim($pathinfo, '/') === '/user') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_user');
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::indexAction', '_route' => 'lien_user',);
}
// lien_user_show
if (preg_match('#^/user/(?P<id>[^/]++)/show$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_show')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::showAction',));
}
// lien_user_new
if ($pathinfo === '/user/new') {
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::newAction', '_route' => 'lien_user_new',);
}
// lien_user_create
if ($pathinfo === '/user/create') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_user_create;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::createAction', '_route' => 'lien_user_create',);
}
not_lien_user_create:
// lien_user_modif
if ($pathinfo === '/user/modif') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_user_modif;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::modifAction', '_route' => 'lien_user_modif',);
}
not_lien_user_modif:
// lien_user_edit
if (0 === strpos($pathinfo, '/user/edit') && preg_match('#^/user/edit/(?P<id>[^/]++)/?$#s', $pathinfo, $matches)) {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'lien_user_edit');
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_edit')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::editAction',));
}
// lien_user_edit_admin
if (preg_match('#^/user/(?P<id>[^/]++)/edit$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_edit_admin')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::editAdminAction',));
}
// lien_user_update
if (preg_match('#^/user/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
$allow = array_merge($allow, array('POST', 'PUT'));
goto not_lien_user_update;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_update')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::updateAction',));
}
not_lien_user_update:
// lien_user_update_admin
if (preg_match('#^/user/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
$allow = array_merge($allow, array('POST', 'PUT'));
goto not_lien_user_update_admin;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_update_admin')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::updateAdminAction',));
}
not_lien_user_update_admin:
// lien_user_delete
if (preg_match('#^/user/(?P<id>[^/]++)/delete$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('POST', 'DELETE'))) {
$allow = array_merge($allow, array('POST', 'DELETE'));
goto not_lien_user_delete;
}
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lien_user_delete')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::deleteAction',));
}
not_lien_user_delete:
if (0 === strpos($pathinfo, '/user/log')) {
// lien_user_login
if ($pathinfo === '/user/login') {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_lien_user_login;
}
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::loginAction', '_route' => 'lien_user_login',);
}
not_lien_user_login:
// lien_user_logout
if ($pathinfo === '/user/logout') {
return array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\UserController::logoutAction', '_route' => 'lien_user_logout',);
}
}
}
// lsi_biblio_homepage
if (0 === strpos($pathinfo, '/hello') && preg_match('#^/hello/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'lsi_biblio_homepage')), array ( '_controller' => 'Lsi\\BiblioBundle\\Controller\\DefaultController::indexAction',));
}
// _welcome
if (rtrim($pathinfo, '/') === '') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', '_welcome');
}
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\WelcomeController::indexAction', '_route' => '_welcome',);
}
if (0 === strpos($pathinfo, '/demo')) {
if (0 === strpos($pathinfo, '/demo/secured')) {
if (0 === strpos($pathinfo, '/demo/secured/log')) {
if (0 === strpos($pathinfo, '/demo/secured/login')) {
// _demo_login
if ($pathinfo === '/demo/secured/login') {
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::loginAction', '_route' => '_demo_login',);
}
// _security_check
if ($pathinfo === '/demo/secured/login_check') {
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::securityCheckAction', '_route' => '_security_check',);
}
}
// _demo_logout
if ($pathinfo === '/demo/secured/logout') {
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::logoutAction', '_route' => '_demo_logout',);
}
}
if (0 === strpos($pathinfo, '/demo/secured/hello')) {
// acme_demo_secured_hello
if ($pathinfo === '/demo/secured/hello') {
return array ( 'name' => 'World', '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::helloAction', '_route' => 'acme_demo_secured_hello',);
}
// _demo_secured_hello
if (preg_match('#^/demo/secured/hello/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_demo_secured_hello')), array ( '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::helloAction',));
}
// _demo_secured_hello_admin
if (0 === strpos($pathinfo, '/demo/secured/hello/admin') && preg_match('#^/demo/secured/hello/admin/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_demo_secured_hello_admin')), array ( '_controller' => 'Acme\\DemoBundle\\Controller\\SecuredController::helloadminAction',));
}
}
}
// _demo
if (rtrim($pathinfo, '/') === '/demo') {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', '_demo');
}
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\DemoController::indexAction', '_route' => '_demo',);
}
// _demo_hello
if (0 === strpos($pathinfo, '/demo/hello') && preg_match('#^/demo/hello/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => '_demo_hello')), array ( '_controller' => 'Acme\\DemoBundle\\Controller\\DemoController::helloAction',));
}
// _demo_contact
if ($pathinfo === '/demo/contact') {
return array ( '_controller' => 'Acme\\DemoBundle\\Controller\\DemoController::contactAction', '_route' => '_demo_contact',);
}
}
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}
}
| sekouzed/Libraire-biblioth-ques-en-ligne-avec-Symfony | app/cache/dev/appDevUrlMatcher.php | PHP | mit | 27,519 | [
30522,
1026,
1029,
25718,
2224,
25353,
2213,
14876,
4890,
1032,
6922,
1032,
16972,
1032,
6453,
1032,
4118,
17048,
8095,
15096,
10288,
24422,
1025,
2224,
25353,
2213,
14876,
4890,
1032,
6922,
1032,
16972,
1032,
6453,
1032,
7692,
17048,
14876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Get more info at : www.jrebirth.org .
* Copyright JRebirth.org © 2011-2013
* Contact : sebastien.bordes@jrebirth.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jrebirth.af.core.ui.adapter;
import javafx.scene.input.KeyEvent;
import org.jrebirth.af.core.ui.AbstractBaseController;
/**
* The class <strong>DefaultKeyAdapter</strong>.
*
* @author Sébastien Bordes
*
* @param <C> The controller class which manage this event adapter
*/
public class DefaultKeyAdapter<C extends AbstractBaseController<?, ?>> extends AbstractDefaultAdapter<C> implements KeyAdapter {
/**
* {@inheritDoc}
*/
@Override
public void key(final KeyEvent keyEvent) {
// Nothing to do yet
}
/**
* {@inheritDoc}
*/
@Override
public void keyPressed(final KeyEvent keyEvent) {
// Nothing to do yet
}
/**
* {@inheritDoc}
*/
@Override
public void keyReleased(final KeyEvent keyEvent) {
// Nothing to do yet
}
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent keyEvent) {
// Nothing to do yet
}
}
| JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/adapter/DefaultKeyAdapter.java | Java | apache-2.0 | 1,671 | [
30522,
1013,
1008,
1008,
1008,
2131,
2062,
18558,
2012,
1024,
7479,
1012,
3781,
15878,
4313,
2705,
1012,
8917,
1012,
1008,
9385,
3781,
15878,
4313,
2705,
1012,
8917,
1075,
2249,
1011,
2286,
1008,
3967,
1024,
28328,
1012,
8945,
26371,
1030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
'use strict';
exports.__esModule = true;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
require('./loading-mask.css!');
var _locale = require('../locale');
var LoadingMask = (function () {
function LoadingMask(resources) {
_classCallCheck(this, LoadingMask);
this.loadingMask = undefined;
this.dimScreen = undefined;
this.dialog = undefined;
this.loadingTitle = undefined;
this.title = undefined;
this.locale = _locale.Locale.Repository['default'];
this._createLoadingMask();
}
LoadingMask.prototype._createLoadingMask = function _createLoadingMask() {
this.title = this.locale.translate('loading');
this.dimScreen = '<div id="loadingMask" class="spinner"><div class="loadingTitle">' + this.title + '</div><div class="mask"></div></div>';
(0, _jquery2['default'])('body').append(this.dimScreen);
this.loadingMask = (0, _jquery2['default'])('#loadingMask');
this.loadingTitle = (0, _jquery2['default'])('.loadingTitle').css({
color: '#ffffff',
opacity: 1,
fontSize: '2.5em',
fontFamily: 'Roboto'
});
};
LoadingMask.prototype.show = function show() {
this.loadingMask.show();
};
LoadingMask.prototype.hide = function hide() {
this.loadingMask.hide();
};
return LoadingMask;
})();
exports.LoadingMask = LoadingMask; | lubo-gadjev/aurelia-auth-session | dist/commonjs/loading-mask/loading-mask.js | JavaScript | mit | 1,618 | [
30522,
1005,
2224,
9384,
1005,
1025,
14338,
1012,
1035,
1035,
9686,
5302,
8566,
2571,
1027,
2995,
1025,
3853,
1035,
6970,
7361,
2890,
15549,
5596,
12879,
23505,
1006,
27885,
3501,
1007,
1063,
2709,
27885,
3501,
1004,
1004,
27885,
3501,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/test.css">
<style>
div{
width: 238px;
height: 248px;
overflow: auto;
}
</style>
</head>
<body>
<div>
字多自动出现滚动条。<br>
div{ <br>
width:100px; <br>
height:100px; <br>
overflow:auto; <br>
} <br>
字多隐藏多余的 <br>
div{ <br>
width:100px; <br>
height:100px; <br>
overflow:hidden; <br>
}
</div>
</body>
</html> | wangyongtan/H5 | 2017/pro/test3.html | HTML | mit | 467 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
6254,
1026,
1013,
2516,
1028,
1026... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright 2009-2015 EPFL, Lausanne */
package leon
package grammars
import purescala.Types._
case class Label(tpe: TypeTree, aspects: List[Aspect] = Nil) extends Typed {
val getType = tpe
def asString(implicit ctx: LeonContext): String = {
val ts = tpe.asString
ts + aspects.map(_.asString).mkString
}
def withAspect(a: Aspect) = Label(tpe, aspects :+ a)
}
| regb/leon | src/main/scala/leon/grammars/Label.scala | Scala | gpl-3.0 | 382 | [
30522,
1013,
1008,
9385,
2268,
1011,
2325,
4958,
10258,
1010,
22256,
1008,
1013,
7427,
6506,
7427,
8035,
2015,
12324,
5760,
15782,
2721,
1012,
4127,
1012,
1035,
2553,
2465,
3830,
1006,
1056,
5051,
1024,
2828,
13334,
1010,
5919,
1024,
2862,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
/**
* Explains a computed value by displaying a hierarchy of its inputs.
*/
(function($) {
/** @constructor */
function DepGraphViewer(_$container, _parentGridName, rowId, colId, _liveResultsClient, _userConfig) {
var self = this;
var _logger = new Logger("DepGraphViewer", "debug");
var _grid;
var _gridHelper;
var _dataView;
var _columns;
var _fullRows
function init() {
_dataView = new Slick.Data.DataView();
var targetColumn = {
id : "target",
name : "Target",
field : "target",
width : 300,
formatter : formatTargetName
};
_columns = [
{
colId: 'targetType',
header: "Type",
typeFormatter: PrimitiveFormatter,
width: 40
},
{
colId: 'valueName',
header: "Value Name",
typeFormatter: PrimitiveFormatter
},
{
colId: 0,
header: "Value",
typeFormatter: PrimitiveFormatter,
nullValue: "null",
dynamic: true,
width: 250
},
{
colId: 'function',
header: "Function",
typeFormatter: PrimitiveFormatter,
nullValue: "null",
width: 200
},
{
colId: 'properties',
header: "Properties",
typeFormatter: PrimitiveFormatter,
nullValue: "",
width: 400
}
];
var gridColumns = SlickGridHelper.makeGridColumns(self, [targetColumn], _columns, 150, _userConfig);
var gridOptions = {
editable: false,
enableAddRow: false,
enableCellNavigation: false,
asyncEditorLoading: false,
};
var $depGraphGridContainer = $("<div class='grid'></div>").appendTo(_$container);
_grid = new Slick.Grid($depGraphGridContainer, _dataView.rows, gridColumns, gridOptions);
_grid.onClick = onGridClicked;
_gridHelper = new SlickGridHelper(_grid, _dataView, _liveResultsClient.triggerImmediateUpdate, false);
_gridHelper.afterViewportStable.subscribe(afterGridViewportStable);
_liveResultsClient.beforeUpdateRequested.subscribe(beforeUpdateRequested);
_userConfig.onSparklinesToggled.subscribe(onSparklinesToggled);
}
function formatValue(row, cell, value, columnDef, dataContext) {
return "<span class='cell-value'>" + value + "</span>";
}
//-----------------------------------------------------------------------
// Event handling
function beforeUpdateRequested(updateMetadata) {
var gridId = _parentGridName + "-" + rowId + "-" + colId;
updateMetadata.depGraphViewport[gridId] = {};
_gridHelper.populateViewportData(updateMetadata.depGraphViewport[gridId]);
}
function onGridClicked(e, row, cell) {
if ($(e.target).hasClass("toggle")) {
var item = _dataView.rows[row];
if (item) {
if (!item._collapsed) {
item._collapsed = true;
} else {
item._collapsed = false;
}
_dataView.updateItem(item.rowId, item);
_grid.removeAllRows();
_grid.render();
_liveResultsClient.triggerImmediateUpdate();
}
return true;
}
return false;
}
function afterGridViewportStable() {
_liveResultsClient.triggerImmediateUpdate();
}
function onSparklinesToggled(sparklinesEnabled) {
_grid.reprocessAllRows();
}
//-----------------------------------------------------------------------
function dataViewFilter(item) {
var idx = _dataView.getIdxById(item.rowId);
if (item.parentRowId != null) {
var parent = _dataView.getItemById(item.parentRowId);
while (parent) {
if (parent._collapsed) {
return false;
}
parent = _dataView.getItemById(parent.parentRowId);
}
}
return true;
}
function formatTargetName(row, cell, value, columnDef, dataContext) {
var rowIndex = _dataView.getIdxById(dataContext.rowId);
if (!_fullRows) {
return null;
} else {
return SlickGridHelper.formatCellWithToggle(_fullRows, rowIndex, dataContext, value);
}
}
//-----------------------------------------------------------------------
// Public API
this.updateValue = function(update) {
if (!update) {
return;
}
if (!_fullRows) {
if (!update['grid']) {
// Cannot do anything with the update
_logger.warn("Dependency graph update received without grid structure");
return;
}
self.popupManager = new PopupManager(null, null, null, update['grid']['name'], _dataView, _liveResultsClient, _userConfig);
_fullRows = update['grid']['rows'];
$.each(_fullRows, function(idx, row) {
if (row.indent >= 2) {
row._collapsed = true;
}
});
_dataView.beginUpdate();
_dataView.setItems(_fullRows, 'rowId');
_dataView.setFilter(dataViewFilter);
_dataView.endUpdate();
_gridHelper.handleUpdate(update['update'], _columns);
} else {
_gridHelper.handleUpdate(update, _columns);
}
}
this.resize = function() {
_grid.resizeCanvas();
}
this.destroy = function() {
_userConfig.onSparklinesToggled.unsubscribe(onSparklinesToggled);
_liveResultsClient.beforeUpdateRequested.unsubscribe(beforeUpdateRequested);
_gridHelper.destroy();
_grid.onClick = null;
_grid.destroy();
}
//-----------------------------------------------------------------------
init();
}
$.extend(true, window, {
DepGraphViewer : DepGraphViewer
});
}(jQuery)); | McLeodMoores/starling | projects/web/web-engine/analytics/js/depGraphViewer.js | JavaScript | apache-2.0 | 6,149 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2556,
2011,
2330,
22864,
2863,
4297,
1012,
1998,
1996,
2330,
22864,
2863,
2177,
1997,
3316,
1008,
1008,
3531,
2156,
4353,
2005,
6105,
1012,
1008,
1013,
1013,
1008,
1008,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package app.logic.activity.search;
import java.util.ArrayList;
import java.util.List;
import org.QLConstant;
import org.ql.activity.customtitle.ActActivity;
import org.ql.utils.QLToastUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.squareup.picasso.Picasso;
import android.R.integer;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import app.config.http.HttpConfig;
import app.logic.activity.notice.DefaultNoticeActivity;
import app.logic.activity.org.DPMListActivity;
import app.logic.activity.user.PreviewFriendsInfoActivity;
import app.logic.adapter.YYBaseListAdapter;
import app.logic.controller.AnnounceController;
import app.logic.controller.OrganizationController;
import app.logic.controller.UserManagerController;
import app.logic.pojo.NoticeInfo;
import app.logic.pojo.OrganizationInfo;
import app.logic.pojo.SearchInfo;
import app.logic.pojo.SearchItemInfo;
import app.logic.pojo.UserInfo;
import app.logic.pojo.YYChatSessionInfo;
import app.utils.common.FrescoImageShowThumb;
import app.utils.common.Listener;
import app.utils.helpers.ChartHelper;
import app.view.YYListView;
import app.yy.geju.R;
/*
* GZYY 2016-12-6 下午6:05:07
* author: zsz
*/
public class SearchActivity extends ActActivity {
private UserInfo userInfo;
private EditText search_edt;
private RelativeLayout search_default_rl;
private YYListView listView;
private LayoutInflater inflater;
private List<SearchItemInfo> datas = new ArrayList<SearchItemInfo>();
private YYBaseListAdapter<SearchItemInfo> mAdapter = new YYBaseListAdapter<SearchItemInfo>(this) {
@Override
public View createView(int position, View convertView, ViewGroup parent) {
if (getItemViewType(position) == 2) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_search_listview_org, null);
saveView("item_iv", R.id.item_iv, convertView);
saveView("item_name_tv", R.id.item_name_tv, convertView);
saveView("item_title", R.id.item_title, convertView);
}
SearchItemInfo info = getItem(position);
if (info != null) {
SimpleDraweeView imageView = getViewForName("item_iv", convertView);
// imageView.setImageURI(HttpConfig.getUrl(info.getOrgDatas().getOrg_logo_url()));
FrescoImageShowThumb.showThrumb(Uri.parse(HttpConfig.getUrl(info.getOrgDatas().getOrg_logo_url())),imageView);
// Picasso.with(SearchActivity.this).load(HttpConfig.getUrl(info.getOrgDatas().getOrg_logo_url())).fit().centerCrop().into(imageView);
setTextToViewText(info.getOrgDatas().getOrg_name(), "item_name_tv", convertView);
TextView titleTv = getViewForName("item_title", convertView);
titleTv.setText("格局");
titleTv.setVisibility(info.isTitleStatus() ? View.VISIBLE : View.GONE);
}
} else if (getItemViewType(position) == 1) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_search_listview_org, null);
saveView("item_iv", R.id.item_iv, convertView);
saveView("item_name_tv", R.id.item_name_tv, convertView);
saveView("item_title", R.id.item_title, convertView);
}
SearchItemInfo info = getItem(position);
if (info != null) {
setImageToImageViewCenterCrop(HttpConfig.getUrl(info.getNoticeDatas().getMsg_cover()), "item_iv", -1, convertView);
setTextToViewText(info.getNoticeDatas().getMsg_title(), "item_name_tv", convertView);
TextView titleTv = getViewForName("item_title", convertView);
titleTv.setText("公告");
titleTv.setVisibility(info.isTitleStatus() ? View.VISIBLE : View.GONE);
}
} else {
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_search_listview_message, null);
saveView("item_iv", R.id.item_iv, convertView);
saveView("item_name_tv", R.id.item_name_tv, convertView);
saveView("item_title", R.id.item_title, convertView);
saveView("item_centent_tv", R.id.item_centent_tv, convertView);
}
SearchItemInfo info = getItem(position);
if (info != null) {
setImageToImageViewCenterCrop(HttpConfig.getUrl(info.getChatDatas().getPicture_url()), "item_iv", -1, convertView);
if(info.getChatDatas().getFriend_name()!=null && !TextUtils.isEmpty(info.getChatDatas().getFriend_name())){
setTextToViewText(info.getChatDatas().getFriend_name(), "item_name_tv", convertView);
}else{
setTextToViewText(info.getChatDatas().getNickName(), "item_name_tv", convertView);
}
TextView titleTv = getViewForName("item_title", convertView);
titleTv.setText("联系人");
titleTv.setVisibility(info.isTitleStatus() ? View.VISIBLE : View.GONE);
}
}
return convertView;
}
/**
* 0是对话消息,1是公告,2是组织
*/
public int getItemViewType(int position) {
SearchItemInfo info = getItem(position);
if (info.getOrgDatas() != null) {
return 2;
}
if (info.getNoticeDatas() != null) {
return 1;
}
return 0;
}
public int getViewTypeCount() {
return 3;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_search);
userInfo = UserManagerController.getCurrUserInfo();
inflater = LayoutInflater.from(this);
findViewById(R.id.left_iv).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
initView();
addListener();
}
private void initView() {
search_edt = (EditText) findViewById(R.id.search_edt);
search_default_rl = (RelativeLayout) findViewById(R.id.search_default_rl);
listView = (YYListView) findViewById(R.id.listView);
listView.setPullLoadEnable(false, true);
listView.setPullRefreshEnable(false);
listView.setAdapter(mAdapter);
}
private void addListener() {
search_edt.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!TextUtils.isEmpty(s.toString())) {
getData(s.toString());
} else {
search_default_rl.setVisibility(View.VISIBLE);
listView.setVisibility(View.GONE);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SearchItemInfo info = datas.get(position - 1);
if (info == null) {
return;
}
if (info.getOrgDatas() != null) {
Intent intent = new Intent(SearchActivity.this, DPMListActivity.class);
intent.putExtra(DPMListActivity.kORG_ID, info.getOrgDatas().getOrg_id());
intent.putExtra(DPMListActivity.kORG_NAME, info.getOrgDatas().getOrg_name());
startActivity(intent);
} else if (info.getNoticeDatas() != null) {
startActivity(new Intent(SearchActivity.this, DefaultNoticeActivity.class).putExtra(DefaultNoticeActivity.NOTICE_ID, info.getNoticeDatas().getMsg_id()));
} else {
String tagerIdString = info.getChatDatas().getWp_other_info_id();
if (QLConstant.client_id.equals(tagerIdString)) {
QLToastUtils.showToast(SearchActivity.this, "该用户是自己");
return;
}
// ChartHelper.startChart(SearchActivity.this, info.getChatDatas().getWp_other_info_id(), "");
Intent openFriendDetailsIntent = new Intent(SearchActivity.this, PreviewFriendsInfoActivity.class);
openFriendDetailsIntent.putExtra(PreviewFriendsInfoActivity.kFROM_CHART_ACTIVITY, false);
openFriendDetailsIntent.putExtra(PreviewFriendsInfoActivity.kUSER_MEMBER_ID, info.getChatDatas().getWp_other_info_id());
startActivity(openFriendDetailsIntent);
}
}
});
}
private synchronized void getData(String keyword) {
UserManagerController.getSearchAllMessage(this, keyword, new Listener<Integer, SearchInfo>() {
@Override
public void onCallBack(Integer status, SearchInfo reply) {
if (reply != null) {
datas.clear();
int titleStatus = 0;
if (reply.getAssociation() != null) {
for (OrganizationInfo info : reply.getAssociation()) {
SearchItemInfo itemInfo = new SearchItemInfo();
itemInfo.setOrgDatas(info);
datas.add(itemInfo);
itemInfo.setTitleStatus(titleStatus == 0 ? true : false);
titleStatus = 1;
}
}
titleStatus = 0;
if (reply.getMessage() != null) {
for (NoticeInfo info : reply.getMessage()) {
SearchItemInfo itemInfo = new SearchItemInfo();
itemInfo.setNoticeDatas(info);
datas.add(itemInfo);
itemInfo.setTitleStatus(titleStatus == 0 ? true : false);
titleStatus = 1;
}
}
titleStatus = 0;
if (reply.getMember() != null) {
for (YYChatSessionInfo info : reply.getMember()) {
SearchItemInfo itemInfo = new SearchItemInfo();
itemInfo.setChatDatas(info);
datas.add(itemInfo);
itemInfo.setTitleStatus(titleStatus == 0 ? true : false);
titleStatus = 1;
}
}
mAdapter.setDatas(datas);
if (datas.size() > 0) {
search_default_rl.setVisibility(View.GONE);
listView.setVisibility(View.VISIBLE);
} else {
search_default_rl.setVisibility(View.VISIBLE);
listView.setVisibility(View.GONE);
}
}
}
});
}
}
| Zhangsongsong/GraduationPro | 毕业设计/code/android/YYFramework/src/app/logic/activity/search/SearchActivity.java | Java | apache-2.0 | 12,596 | [
30522,
7427,
10439,
1012,
7961,
1012,
4023,
1012,
3945,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
1025,
12324,
8917,
1012,
1053,
22499,
23808,
4630,
1025,
12324,
8917,
1012,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
/* global FormData */
import app from "../../../app";
import FauxtonAPI from "../../../core/api";
import ActionTypes from "./actiontypes";
var xhr;
function initDocEditor (params) {
var doc = params.doc;
// ensure a clean slate
FauxtonAPI.dispatch({ type: ActionTypes.RESET_DOC });
doc.fetch().then(function () {
FauxtonAPI.dispatch({
type: ActionTypes.DOC_LOADED,
options: {
doc: doc
}
});
if (params.onLoaded) {
params.onLoaded();
}
}, function (xhr) {
if (xhr.status === 404) {
errorNotification('The document does not exist.');
}
FauxtonAPI.navigate(FauxtonAPI.urls('allDocs', 'app', params.database.id, ''));
});
}
function saveDoc (doc, isValidDoc, onSave) {
if (isValidDoc) {
FauxtonAPI.addNotification({
msg: 'Saving document.',
clear: true
});
doc.save().then(function () {
onSave(doc.prettyJSON());
FauxtonAPI.navigate('#/' + FauxtonAPI.urls('allDocs', 'app', FauxtonAPI.url.encode(doc.database.id)), {trigger: true});
}).fail(function (xhr) {
FauxtonAPI.addNotification({
msg: 'Save failed: ' + JSON.parse(xhr.responseText).reason,
type: 'error',
fade: false,
clear: true
});
});
} else if (doc.validationError && doc.validationError === 'Cannot change a documents id.') {
errorNotification('You cannot edit the _id of an existing document. Try this: Click \'Clone Document\', then change the _id on the clone before saving.');
delete doc.validationError;
} else {
errorNotification('Please fix the JSON errors and try saving again.');
}
}
function showDeleteDocModal () {
FauxtonAPI.dispatch({ type: ActionTypes.SHOW_DELETE_DOC_CONFIRMATION_MODAL });
}
function hideDeleteDocModal () {
FauxtonAPI.dispatch({ type: ActionTypes.HIDE_DELETE_DOC_CONFIRMATION_MODAL });
}
function deleteDoc (doc) {
var databaseName = doc.database.safeID();
var query = '?rev=' + doc.get('_rev');
$.ajax({
url: FauxtonAPI.urls('document', 'server', databaseName, doc.safeID(), query),
type: 'DELETE',
contentType: 'application/json; charset=UTF-8',
xhrFields: {
withCredentials: true
},
success: function () {
FauxtonAPI.addNotification({
msg: 'Your document has been successfully deleted.',
clear: true
});
FauxtonAPI.navigate(FauxtonAPI.urls('allDocs', 'app', databaseName, ''));
},
error: function () {
FauxtonAPI.addNotification({
msg: 'Failed to delete your document!',
type: 'error',
clear: true
});
}
});
}
function showCloneDocModal () {
FauxtonAPI.dispatch({ type: ActionTypes.SHOW_CLONE_DOC_MODAL });
}
function hideCloneDocModal () {
FauxtonAPI.dispatch({ type: ActionTypes.HIDE_CLONE_DOC_MODAL });
}
function cloneDoc (database, doc, newId) {
const docId = app.utils.getSafeIdForDoc(newId);
hideCloneDocModal();
doc.copy(docId).then(() => {
doc.set({ _id: docId });
FauxtonAPI.navigate('/database/' + database.safeID() + '/' + docId, { trigger: true });
FauxtonAPI.addNotification({
msg: 'Document has been duplicated.'
});
}, (error) => {
const errorMsg = `Could not duplicate document, reason: ${error.responseText}.`;
FauxtonAPI.addNotification({
msg: errorMsg,
type: 'error'
});
});
}
function showUploadModal () {
FauxtonAPI.dispatch({ type: ActionTypes.SHOW_UPLOAD_MODAL });
}
function hideUploadModal () {
FauxtonAPI.dispatch({ type: ActionTypes.HIDE_UPLOAD_MODAL });
}
function uploadAttachment (params) {
if (params.files.length === 0) {
FauxtonAPI.dispatch({
type: ActionTypes.FILE_UPLOAD_ERROR,
options: {
error: 'Please select a file to be uploaded.'
}
});
return;
}
FauxtonAPI.dispatch({ type: ActionTypes.START_FILE_UPLOAD });
// store the xhr in parent scope to allow us to cancel any uploads if the user closes the modal
xhr = $.ajaxSettings.xhr();
var query = '?rev=' + params.rev;
var db = params.doc.getDatabase().safeID();
var docId = params.doc.safeID();
var file = params.files[0];
$.ajax({
url: FauxtonAPI.urls('document', 'attachment', db, docId, file.name, query),
type: 'PUT',
data: file,
contentType: file.type,
processData: false,
xhrFields: {
withCredentials: true
},
xhr: function () {
xhr.upload.onprogress = function (evt) {
var percentComplete = evt.loaded / evt.total * 100;
FauxtonAPI.dispatch({
type: ActionTypes.SET_FILE_UPLOAD_PERCENTAGE,
options: {
percent: percentComplete
}
});
};
return xhr;
},
success: function () {
// re-initialize the document editor. Only announce it's been updated when
initDocEditor({
doc: params.doc,
onLoaded: function () {
FauxtonAPI.dispatch({ type: ActionTypes.FILE_UPLOAD_SUCCESS });
FauxtonAPI.addNotification({
msg: 'Document saved successfully.',
type: 'success',
clear: true
});
}.bind(this)
});
},
error: function (resp) {
// cancelled uploads throw an ajax error but they don't contain a response. We don't want to publish an error
// event in those cases
if (_.isEmpty(resp.responseText)) {
return;
}
FauxtonAPI.dispatch({
type: ActionTypes.FILE_UPLOAD_ERROR,
options: {
error: JSON.parse(resp.responseText).reason
}
});
}
});
}
function cancelUpload () {
xhr.abort();
}
function resetUploadModal () {
FauxtonAPI.dispatch({ type: ActionTypes.RESET_UPLOAD_MODAL });
}
// helpers
function errorNotification (msg) {
FauxtonAPI.addNotification({
msg: msg,
type: 'error',
clear: true
});
}
export default {
initDocEditor: initDocEditor,
saveDoc: saveDoc,
// clone doc
showCloneDocModal: showCloneDocModal,
hideCloneDocModal: hideCloneDocModal,
cloneDoc: cloneDoc,
// delete doc
showDeleteDocModal: showDeleteDocModal,
hideDeleteDocModal: hideDeleteDocModal,
deleteDoc: deleteDoc,
// upload modal
showUploadModal: showUploadModal,
hideUploadModal: hideUploadModal,
uploadAttachment: uploadAttachment,
cancelUpload: cancelUpload,
resetUploadModal: resetUploadModal
};
| garrensmith/couchdb-fauxton | app/addons/documents/doc-editor/actions.js | JavaScript | apache-2.0 | 6,952 | [
30522,
1013,
1013,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
1013,
1013,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
2017,
2089,
6855,
1037,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.datapipeline.model.transform;
import java.util.Map;
import java.util.Map.Entry;
import java.math.*;
import java.nio.ByteBuffer;
import com.amazonaws.services.datapipeline.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* Field JSON Unmarshaller
*/
public class FieldJsonUnmarshaller implements
Unmarshaller<Field, JsonUnmarshallerContext> {
public Field unmarshall(JsonUnmarshallerContext context) throws Exception {
Field field = new Field();
int originalDepth = context.getCurrentDepth();
String currentParentElement = context.getCurrentParentElement();
int targetDepth = originalDepth + 1;
JsonToken token = context.getCurrentToken();
if (token == null)
token = context.nextToken();
if (token == VALUE_NULL)
return null;
while (true) {
if (token == null)
break;
if (token == FIELD_NAME || token == START_OBJECT) {
if (context.testExpression("key", targetDepth)) {
context.nextToken();
field.setKey(context.getUnmarshaller(String.class)
.unmarshall(context));
}
if (context.testExpression("stringValue", targetDepth)) {
context.nextToken();
field.setStringValue(context.getUnmarshaller(String.class)
.unmarshall(context));
}
if (context.testExpression("refValue", targetDepth)) {
context.nextToken();
field.setRefValue(context.getUnmarshaller(String.class)
.unmarshall(context));
}
} else if (token == END_ARRAY || token == END_OBJECT) {
if (context.getLastParsedParentElement() == null
|| context.getLastParsedParentElement().equals(
currentParentElement)) {
if (context.getCurrentDepth() <= originalDepth)
break;
}
}
token = context.nextToken();
}
return field;
}
private static FieldJsonUnmarshaller instance;
public static FieldJsonUnmarshaller getInstance() {
if (instance == null)
instance = new FieldJsonUnmarshaller();
return instance;
}
}
| mhurne/aws-sdk-java | aws-java-sdk-datapipeline/src/main/java/com/amazonaws/services/datapipeline/model/transform/FieldJsonUnmarshaller.java | Java | apache-2.0 | 3,212 | [
30522,
1013,
1008,
1008,
9385,
2230,
1011,
2355,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
1008,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
*
* Copyright (C) 2005-2022 MaNGOS <https://getmangos.eu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#include "Object.h"
#include "Player.h"
#include "BattleGround.h"
#include "BattleGroundBE.h"
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "Language.h"
BattleGroundBE::BattleGroundBE()
{
m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M;
m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S;
m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S;
m_StartDelayTimes[BG_STARTING_EVENT_FOURTH] = BG_START_DELAY_NONE;
// we must set messageIds
m_StartMessageIds[BG_STARTING_EVENT_FIRST] = LANG_ARENA_ONE_MINUTE;
m_StartMessageIds[BG_STARTING_EVENT_SECOND] = LANG_ARENA_THIRTY_SECONDS;
m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_ARENA_FIFTEEN_SECONDS;
m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_ARENA_HAS_BEGUN;
}
void BattleGroundBE::StartingEventOpenDoors()
{
OpenDoorEvent(BG_EVENT_DOOR);
}
void BattleGroundBE::AddPlayer(Player* plr)
{
BattleGround::AddPlayer(plr);
// create score and add it to map, default values are set in constructor
BattleGroundBEScore* sc = new BattleGroundBEScore;
m_PlayerScores[plr->GetObjectGuid()] = sc;
UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
}
void BattleGroundBE::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/)
{
if (GetStatus() == STATUS_WAIT_LEAVE)
{
return;
}
UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
CheckArenaWinConditions();
}
void BattleGroundBE::HandleKillPlayer(Player* player, Player* killer)
{
if (GetStatus() != STATUS_IN_PROGRESS)
{
return;
}
if (!killer)
{
sLog.outError("Killer player not found");
return;
}
BattleGround::HandleKillPlayer(player, killer);
UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE));
CheckArenaWinConditions();
}
bool BattleGroundBE::HandlePlayerUnderMap(Player* player)
{
player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation(), false);
return true;
}
void BattleGroundBE::FillInitialWorldStates(WorldPacket& data, uint32& count)
{
FillInitialWorldState(data, count, 0x9f1, GetAlivePlayersCountByTeam(ALLIANCE));
FillInitialWorldState(data, count, 0x9f0, GetAlivePlayersCountByTeam(HORDE));
FillInitialWorldState(data, count, 0x9f3, 1);
}
void BattleGroundBE::UpdatePlayerScore(Player* source, uint32 type, uint32 value)
{
BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid());
if (itr == m_PlayerScores.end()) // player not found...
{
return;
}
// there is nothing special in this score
BattleGround::UpdatePlayerScore(source, type, value);
}
| mangosone/server | src/game/BattleGround/BattleGroundBE.cpp | C++ | gpl-2.0 | 3,997 | [
30522,
1013,
1008,
1008,
1008,
24792,
2015,
2003,
1037,
2440,
2956,
8241,
2005,
2088,
1997,
2162,
10419,
1010,
4637,
1008,
1996,
2206,
7846,
1024,
1015,
1012,
2260,
1012,
1060,
1010,
1016,
1012,
1018,
1012,
1017,
1010,
1017,
1012,
1017,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { FieldErrorProcessor } from "./processors/field-error-processor";
import { RuleResolver } from "./rulesets/rule-resolver";
import { ValidationGroupBuilder } from "./builders/validation-group-builder";
import { ruleRegistry } from "./rule-registry-setup";
import { RulesetBuilder } from "./builders/ruleset-builder";
import { DefaultLocaleHandler } from "./localization/default-locale-handler";
import { locale as defaultLocale } from "./locales/en-us";
import { Ruleset } from "./rulesets/ruleset";
const defaultLocaleCode = "en-us";
const defaultLocaleHandler = new DefaultLocaleHandler();
defaultLocaleHandler.registerLocale(defaultLocaleCode, defaultLocale);
defaultLocaleHandler.useLocale(defaultLocaleCode);
const fieldErrorProcessor = new FieldErrorProcessor(ruleRegistry, defaultLocaleHandler);
const ruleResolver = new RuleResolver();
export function createRuleset(basedUpon, withRuleVerification = false) {
const rulesetBuilder = withRuleVerification ? new RulesetBuilder(ruleRegistry) : new RulesetBuilder();
return rulesetBuilder.create(basedUpon);
}
export function mergeRulesets(rulesetA, rulesetB) {
const newRuleset = new Ruleset();
newRuleset.rules = Object.assign({}, rulesetA.rules, rulesetB.rules);
newRuleset.compositeRules = Object.assign({}, rulesetA.compositeRules, rulesetB.compositeRules);
newRuleset.propertyDisplayNames = Object.assign({}, rulesetA.propertyDisplayNames, rulesetB.propertyDisplayNames);
return newRuleset;
}
export function createGroup() { return new ValidationGroupBuilder(fieldErrorProcessor, ruleResolver, defaultLocaleHandler).create(); }
export const localeHandler = defaultLocaleHandler;
export function supplementLocale(localeCode, localeResource) {
defaultLocaleHandler.supplementLocaleFrom(localeCode, localeResource);
}
| grofit/treacherous | dist/es2015/exposer.js | JavaScript | mit | 1,813 | [
30522,
12324,
1063,
25000,
29165,
21572,
9623,
21748,
1065,
2013,
1000,
1012,
1013,
18017,
1013,
2492,
1011,
7561,
1011,
13151,
1000,
1025,
12324,
1063,
7786,
2229,
4747,
6299,
1065,
2013,
1000,
1012,
1013,
3513,
8454,
1013,
3627,
1011,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"88702780","logradouro":"Rua Pedro Esmeraldino Menezes","bairro":"F\u00e1bio Silva","cidade":"Tubar\u00e3o","uf":"SC","estado":"Santa Catarina"});
| lfreneda/cepdb | api/v1/88702780.jsonp.js | JavaScript | cc0-1.0 | 160 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6070,
19841,
22907,
17914,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
7707,
9686,
28990,
8718,
2080,
2273,
9351,
2229,
1000,
1010,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.gradle.test.performance.mediummonolithicjavaproject.p253;
public class Production5063 {
private String property0;
public String getProperty0() {
return property0;
}
public void setProperty0(String value) {
property0 = value;
}
private String property1;
public String getProperty1() {
return property1;
}
public void setProperty1(String value) {
property1 = value;
}
private String property2;
public String getProperty2() {
return property2;
}
public void setProperty2(String value) {
property2 = value;
}
private String property3;
public String getProperty3() {
return property3;
}
public void setProperty3(String value) {
property3 = value;
}
private String property4;
public String getProperty4() {
return property4;
}
public void setProperty4(String value) {
property4 = value;
}
private String property5;
public String getProperty5() {
return property5;
}
public void setProperty5(String value) {
property5 = value;
}
private String property6;
public String getProperty6() {
return property6;
}
public void setProperty6(String value) {
property6 = value;
}
private String property7;
public String getProperty7() {
return property7;
}
public void setProperty7(String value) {
property7 = value;
}
private String property8;
public String getProperty8() {
return property8;
}
public void setProperty8(String value) {
property8 = value;
}
private String property9;
public String getProperty9() {
return property9;
}
public void setProperty9(String value) {
property9 = value;
}
} | oehme/analysing-gradle-performance | my-app/src/main/java/org/gradle/test/performance/mediummonolithicjavaproject/p253/Production5063.java | Java | apache-2.0 | 1,891 | [
30522,
7427,
8917,
1012,
24665,
4215,
2571,
1012,
3231,
1012,
2836,
1012,
5396,
8202,
10893,
23048,
3900,
3567,
21572,
20614,
1012,
1052,
17788,
2509,
1025,
2270,
2465,
2537,
12376,
2575,
2509,
1063,
2797,
5164,
3200,
2692,
1025,
2270,
5164... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* OAuth2 Controller
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Koauth
* @copyright Ushahidi - http://www.ushahidi.com
* @license MIT License http://opensource.org/licenses/MIT
*/
abstract class Koauth_Controller_OAuth extends Controller {
protected $_oauth2_server;
protected $_skip_oauth_response = FALSE;
/**
* @var array Map of HTTP methods -> actions
*/
protected $_action_map = array
(
Http_Request::POST => 'post', // Typically Create..
Http_Request::GET => 'get',
Http_Request::PUT => 'put', // Typically Update..
Http_Request::DELETE => 'delete',
);
public function before()
{
parent::before();
// Get the basic verb based action..
$action = $this->_action_map[$this->request->method()];
// If this is a custom action, lets make sure we use it.
if ($this->request->action() != '_none')
{
$action .= '_'.$this->request->action();
}
// Override the action
$this->request->action($action);
// Set up OAuth2 objects
$this->_oauth2_server = new Koauth_OAuth2_Server();
}
public function after()
{
if (! $this->_skip_oauth_response)
{
$this->_oauth2_server->processResponse($this->response);
}
}
/**
* Authorize Requests
*/
public function action_get_authorize()
{
if (! ($params = $this->_oauth2_server->validateAuthorizeRequest(Koauth_OAuth2_Request::createFromRequest($this->request), new OAuth2_Response())) ) {
return;
}
// Show authorize yes/no
$this->_skip_oauth_response = TRUE;
$view = View::factory('oauth/authorize');
$view->scopes = explode(',', $params['scope']);
$view->params = $params;
$this->response->body($view->render());
}
/**
* Authorize Requests
*/
public function action_post_authorize()
{
$authorized = (bool) $this->request->post('authorize');
$this->_oauth2_server->handleAuthorizeRequest(Koauth_OAuth2_Request::createFromRequest($this->request), new OAuth2_Response(), $authorized);
}
/**
* Token Requests
*/
public function action_get_token()
{
$this->_oauth2_server->handleTokenRequest(Koauth_OAuth2_Request::createFromRequest($this->request), new OAuth2_Response());
}
/**
* Token Requests
*/
public function action_post_token()
{
$this->_oauth2_server->handleTokenRequest(Koauth_OAuth2_Request::createFromRequest($this->request), new OAuth2_Response());
}
}
| ushahidi/koauth | classes/Koauth/Controller/OAuth.php | PHP | mit | 2,457 | [
30522,
1026,
1029,
25718,
4225,
1006,
1005,
25353,
13102,
8988,
1005,
1007,
2030,
3280,
1006,
1005,
2053,
3622,
3229,
3039,
1012,
1005,
1007,
1025,
1013,
1008,
1008,
1008,
1051,
4887,
2705,
2475,
11486,
1008,
1008,
1030,
3166,
2149,
3270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Oro\Bundle\EntityBundle\Tests\Unit\Form\Guesser;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;
use Oro\Bundle\EntityBundle\Form\Guesser\FormConfigGuesser;
use Oro\Bundle\EntityConfigBundle\Config\Config;
class FormConfigGuesserTest extends \PHPUnit_Framework_TestCase
{
/**
* @var FormConfigGuesser
*/
protected $guesser;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $managerRegistry;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $entityConfigProvider;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $formConfigProvider;
protected function setUp()
{
$this->managerRegistry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->entityConfigProvider = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider')
->disableOriginalConstructor()
->getMock();
$this->formConfigProvider = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider')
->disableOriginalConstructor()
->getMock();
$this->guesser = new FormConfigGuesser(
$this->managerRegistry,
$this->entityConfigProvider,
$this->formConfigProvider
);
}
protected function tearDown()
{
unset($this->managerRegistry);
unset($this->entityConfigProvider);
unset($this->formConfigProvider);
unset($this->guesser);
}
public function testGuessRequired()
{
$guess = $this->guesser->guessRequired('Test/Entity', 'testProperty');
$this->assertValueGuess($guess, false, ValueGuess::LOW_CONFIDENCE);
}
public function testGuessMaxLength()
{
$guess = $this->guesser->guessMaxLength('Test/Entity', 'testProperty');
$this->assertValueGuess($guess, null, ValueGuess::LOW_CONFIDENCE);
}
public function testGuessPattern()
{
$guess = $this->guesser->guessMaxLength('Test/Entity', 'testProperty');
$this->assertValueGuess($guess, null, ValueGuess::LOW_CONFIDENCE);
}
public function testGuessNoEntityManager()
{
$class = 'Test/Entity';
$property = 'testProperty';
$this->managerRegistry->expects($this->any())->method('getManagerForClass')->with($class)
->will($this->returnValue(null));
$this->assertDefaultTypeGuess($this->guesser->guessType($class, $property));
}
public function testGuessNoMetadata()
{
$class = 'Test/Entity';
$property = 'testProperty';
$this->setEntityMetadata($class, null);
$this->assertDefaultTypeGuess($this->guesser->guessType($class, $property));
}
public function testGuessNoFormConfig()
{
$class = 'Test/Entity';
$property = 'testProperty';
$metadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$this->setEntityMetadata($class, $metadata);
$this->formConfigProvider->expects($this->any())
->method('hasConfig')
->with($class, $property)
->will($this->returnValue(false));
$this->assertDefaultTypeGuess($this->guesser->guessType($class, $property));
}
public function testGuessNoFormType()
{
$class = 'Test/Entity';
$property = 'testProperty';
$metadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$this->setEntityMetadata($class, $metadata);
$this->setFormConfig($class, $property, array());
$this->assertDefaultTypeGuess($this->guesser->guessType($class, $property));
}
public function testGuessOnlyFormType()
{
$class = 'Test/Entity';
$property = 'testProperty';
$formType = 'test_form_type';
$metadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$this->setEntityMetadata($class, $metadata);
$this->setFormConfig($class, $property, array('form_type' => $formType));
$guess = $this->guesser->guessType($class, $property);
$this->assertTypeGuess($guess, $formType, array(), TypeGuess::HIGH_CONFIDENCE);
}
public function testGuessOnlyFormTypeWithLabel()
{
$class = 'Test/Entity';
$property = 'testProperty';
$formType = 'test_form_type';
$label = 'Test Field';
$metadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$this->setEntityMetadata($class, $metadata);
$this->setFormConfig($class, $property, array('form_type' => $formType));
$this->setEntityConfig($class, $property, array('label' => $label));
$guess = $this->guesser->guessType($class, $property);
$this->assertTypeGuess($guess, $formType, array('label' => $label), TypeGuess::HIGH_CONFIDENCE);
}
public function testGuessFormTypeWithOptions()
{
$class = 'Test/Entity';
$property = 'testProperty';
$formType = 'test_form_type';
$formOptions = array(
'required' => false,
'label' => 'Test Field'
);
$metadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$this->setEntityMetadata($class, $metadata);
$this->setFormConfig($class, $property, array('form_type' => $formType, 'form_options' => $formOptions));
$this->setEntityConfig($class, $property, array('label' => 'Not used label'));
$guess = $this->guesser->guessType($class, $property);
$this->assertTypeGuess($guess, $formType, $formOptions, TypeGuess::HIGH_CONFIDENCE);
}
public function testGuessByAssociationClass()
{
$class = 'Test/Entity';
$property = 'testProperty';
$associationClass = 'Test/Association/Entity';
$associationFormType = 'test_form_type';
$associationFormOptions = array(
'required' => false,
'label' => 'Test Field'
);
$sourceClassMetadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$sourceClassMetadata->expects($this->once())
->method('hasAssociation')
->with($property)
->will($this->returnValue(true));
$sourceClassMetadata->expects($this->any())
->method('isSingleValuedAssociation')
->with($property)
->will($this->returnValue(true));
$sourceClassMetadata->expects($this->any())
->method('getAssociationTargetClass')
->with($property)
->will($this->returnValue($associationClass));
$sourceEntityManager = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
$sourceEntityManager->expects($this->any())
->method('getClassMetadata')
->with($class)
->will($this->returnValue($sourceClassMetadata));
$associationClassMetadata = $this->getMockForAbstractClass('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$associationEntityManager = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
$associationEntityManager->expects($this->any())
->method('getClassMetadata')
->with($associationClass)
->will($this->returnValue($associationClassMetadata));
$this->managerRegistry->expects($this->at(0))->method('getManagerForClass')->with($class)
->will($this->returnValue($sourceEntityManager));
$this->managerRegistry->expects($this->at(1))->method('getManagerForClass')->with($associationClass)
->will($this->returnValue($associationEntityManager));
/** @var \PHPUnit_Framework_MockObject_MockObject|Config $sourceEntityConfig */
$sourceEntityConfig = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Config\Config')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
$sourceEntityConfig->setValues(array());
/** @var \PHPUnit_Framework_MockObject_MockObject|Config $associationEntityConfig */
$associationEntityConfig = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Config\Config')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
$associationEntityConfig->setValues(
array('form_type' => $associationFormType, 'form_options' => $associationFormOptions)
);
$this->formConfigProvider->expects($this->at(0))
->method('hasConfig')
->with($class, $property)
->will($this->returnValue(true));
$this->formConfigProvider->expects($this->at(1))
->method('getConfig')
->with($class, $property)
->will($this->returnValue($sourceEntityConfig));
$this->formConfigProvider->expects($this->at(2))
->method('hasConfig')
->with($associationClass, null)
->will($this->returnValue(true));
$this->formConfigProvider->expects($this->at(3))
->method('getConfig')
->with($associationClass, null)
->will($this->returnValue($associationEntityConfig));
$guess = $this->guesser->guessType($class, $property);
$this->assertTypeGuess($guess, $associationFormType, $associationFormOptions, TypeGuess::LOW_CONFIDENCE);
}
/**
* @param string $class
* @param mixed $metadata
*/
protected function setEntityMetadata($class, $metadata)
{
$entityManager = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
->getMock();
$entityManager->expects($this->any())
->method('getClassMetadata')
->with($class)
->will($this->returnValue($metadata));
$this->managerRegistry->expects($this->any())->method('getManagerForClass')->with($class)
->will($this->returnValue($entityManager));
}
/**
* @param string $class
* @param string $property
* @param array $parameters
*/
protected function setFormConfig($class, $property, array $parameters)
{
/** @var \PHPUnit_Framework_MockObject_MockObject|Config $config */
$config = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Config\Config')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
$config->setValues($parameters);
$this->formConfigProvider->expects($this->any())
->method('hasConfig')
->with($class, $property)
->will($this->returnValue(true));
$this->formConfigProvider->expects($this->any())
->method('getConfig')
->with($class, $property)
->will($this->returnValue($config));
}
/**
* @param string $class
* @param string $property
* @param array $parameters
*/
protected function setEntityConfig($class, $property, array $parameters)
{
/** @var \PHPUnit_Framework_MockObject_MockObject|Config $config */
$config = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Config\Config')
->disableOriginalConstructor()
->setMethods(null)
->getMock();
$config->setValues($parameters);
$this->entityConfigProvider->expects($this->any())
->method('hasConfig')
->with($class, $property)
->will($this->returnValue(true));
$this->entityConfigProvider->expects($this->any())
->method('getConfig')
->with($class, $property)
->will($this->returnValue($config));
}
/**
* @param TypeGuess $guess
* @param string $type
* @param array $options
* @param $confidence
*/
protected function assertTypeGuess($guess, $type, array $options, $confidence)
{
$this->assertInstanceOf('Symfony\Component\Form\Guess\TypeGuess', $guess);
$this->assertEquals($type, $guess->getType());
$this->assertEquals($options, $guess->getOptions());
$this->assertEquals($confidence, $guess->getConfidence());
}
/**
* @param TypeGuess $guess
*/
protected function assertDefaultTypeGuess($guess)
{
$this->assertTypeGuess($guess, 'text', array(), TypeGuess::LOW_CONFIDENCE);
}
/**
* @param ValueGuess $guess
* @param mixed $value
* @param $confidence
*/
protected function assertValueGuess($guess, $value, $confidence)
{
$this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $guess);
$this->assertEquals($value, $guess->getValue());
$this->assertEquals($confidence, $guess->getConfidence());
}
}
| ramunasd/platform | src/Oro/Bundle/EntityBundle/Tests/Unit/Form/Guesser/FormConfigGuesserTest.php | PHP | mit | 13,229 | [
30522,
1026,
1029,
25718,
3415,
15327,
20298,
1032,
14012,
1032,
9178,
27265,
2571,
1032,
5852,
1032,
3131,
1032,
2433,
1032,
3984,
2121,
1025,
2224,
25353,
2213,
14876,
4890,
1032,
6922,
1032,
2433,
1032,
3984,
1032,
2828,
22967,
2015,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// GENERATED CODE --- DO NOT EDIT ---
// Code is produced by sasmodels.gen from sasmodels/models/MODEL.c
#ifdef __OPENCL_VERSION__
# define USE_OPENCL
#endif
#define USE_KAHAN_SUMMATION 0
// If opencl is not available, then we are compiling a C function
// Note: if using a C++ compiler, then define kernel as extern "C"
#ifndef USE_OPENCL
# ifdef __cplusplus
#include <cstdio>
#include <cmath>
using namespace std;
#if defined(_MSC_VER)
# define kernel extern "C" __declspec( dllexport )
inline float trunc(float x) { return x>=0?floor(x):-floor(-x); }
inline float fmin(float x, float y) { return x>y ? y : x; }
inline float fmax(float x, float y) { return x<y ? y : x; }
#else
# define kernel extern "C"
#endif
inline void SINCOS(float angle, float &svar, float &cvar) { svar=sin(angle); cvar=cos(angle); }
# else
#include <stdio.h>
#include <tgmath.h> // C99 type-generic math, so sin(float) => sinf
// MSVC doesn't support C99, so no need for dllexport on C99 branch
#define kernel
#define SINCOS(angle,svar,cvar) do {const float _t_=angle; svar=sin(_t_);cvar=cos(_t_);} while (0)
# endif
# define global
# define local
# define constant const
// OpenCL powr(a,b) = C99 pow(a,b), b >= 0
// OpenCL pown(a,b) = C99 pow(a,b), b integer
# define powr(a,b) pow(a,b)
# define pown(a,b) pow(a,b)
#else
# ifdef USE_SINCOS
# define SINCOS(angle,svar,cvar) svar=sincos(angle,&cvar)
# else
# define SINCOS(angle,svar,cvar) do {const float _t_=angle; svar=sin(_t_);cvar=cos(_t_);} while (0)
# endif
#endif
// Standard mathematical constants:
// M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_PI, M_PI_2=pi/2, M_PI_4=pi/4,
// M_1_PI=1/pi, M_2_PI=2/pi, M_2_SQRTPI=2/sqrt(pi), SQRT2, SQRT1_2=sqrt(1/2)
// OpenCL defines M_constant_F for float constants, and nothing if float
// is not enabled on the card, which is why these constants may be missing
#ifndef M_PI
# define M_PI 3.141592653589793f
#endif
#ifndef M_PI_2
# define M_PI_2 1.570796326794897f
#endif
#ifndef M_PI_4
# define M_PI_4 0.7853981633974483f
#endif
// Non-standard pi/180, used for converting between degrees and radians
#ifndef M_PI_180
# define M_PI_180 0.017453292519943295f
#endif
#define VOLUME_PARAMETERS effect_radius
#define VOLUME_WEIGHT_PRODUCT effect_radius_w
#define VOLUME_PARAMETER_DECLARATIONS float effect_radius
#define IQ_KERNEL_NAME stickyhardsphere_Iq
#define IQ_PARAMETERS effect_radius, volfraction, perturb, stickiness
#define IQ_FIXED_PARAMETER_DECLARATIONS const float scale, \
const float background, \
const float volfraction, \
const float perturb, \
const float stickiness
#define IQ_WEIGHT_PRODUCT effect_radius_w
#define IQ_DISPERSION_LENGTH_DECLARATIONS const int Neffect_radius
#define IQ_DISPERSION_LENGTH_SUM Neffect_radius
#define IQ_OPEN_LOOPS for (int effect_radius_i=0; effect_radius_i < Neffect_radius; effect_radius_i++) { \
const float effect_radius = loops[2*(effect_radius_i)]; \
const float effect_radius_w = loops[2*(effect_radius_i)+1];
#define IQ_CLOSE_LOOPS }
#define IQ_PARAMETER_DECLARATIONS float effect_radius, float volfraction, float perturb, float stickiness
#define IQXY_KERNEL_NAME stickyhardsphere_Iqxy
#define IQXY_PARAMETERS effect_radius, volfraction, perturb, stickiness
#define IQXY_FIXED_PARAMETER_DECLARATIONS const float scale, \
const float background, \
const float volfraction, \
const float perturb, \
const float stickiness
#define IQXY_WEIGHT_PRODUCT effect_radius_w
#define IQXY_DISPERSION_LENGTH_DECLARATIONS const int Neffect_radius
#define IQXY_DISPERSION_LENGTH_SUM Neffect_radius
#define IQXY_OPEN_LOOPS for (int effect_radius_i=0; effect_radius_i < Neffect_radius; effect_radius_i++) { \
const float effect_radius = loops[2*(effect_radius_i)]; \
const float effect_radius_w = loops[2*(effect_radius_i)+1];
#define IQXY_CLOSE_LOOPS }
#define IQXY_PARAMETER_DECLARATIONS float effect_radius, float volfraction, float perturb, float stickiness
float form_volume(VOLUME_PARAMETER_DECLARATIONS);
float form_volume(VOLUME_PARAMETER_DECLARATIONS) {
return 1.0f;
}
float Iq(float q, IQ_PARAMETER_DECLARATIONS);
float Iq(float q, IQ_PARAMETER_DECLARATIONS) {
float onemineps,eta;
float sig,aa,etam1,etam1sq,qa,qb,qc,radic;
float lam,lam2,test,mu,alpha,beta;
float kk,k2,k3,ds,dc,aq1,aq2,aq3,aq,bq1,bq2,bq3,bq,sq;
onemineps = 1.0f-perturb;
eta = volfraction/onemineps/onemineps/onemineps;
sig = 2.0f * effect_radius;
aa = sig/onemineps;
etam1 = 1.0f - eta;
etam1sq=etam1*etam1;
//C
//C SOLVE QUADRATIC FOR LAMBDA
//C
qa = eta/12.0f;
qb = -1.0f*(stickiness + eta/etam1);
qc = (1.0f + eta/2.0f)/etam1sq;
radic = qb*qb - 4.0f*qa*qc;
if(radic<0) {
//if(x>0.01f && x<0.015f)
// Print "Lambda unphysical - both roots imaginary"
//endif
return(-1.0f);
}
//C KEEP THE SMALLER ROOT, THE LARGER ONE IS UNPHYSICAL
lam = (-1.0f*qb-sqrt(radic))/(2.0f*qa);
lam2 = (-1.0f*qb+sqrt(radic))/(2.0f*qa);
if(lam2<lam) {
lam = lam2;
}
test = 1.0f + 2.0f*eta;
mu = lam*eta*etam1;
if(mu>test) {
//if(x>0.01f && x<0.015f)
// Print "Lambda unphysical mu>test"
//endif
return(-1.0f);
}
alpha = (1.0f + 2.0f*eta - mu)/etam1sq;
beta = (mu - 3.0f*eta)/(2.0f*etam1sq);
//C
//C CALCULATE THE STRUCTURE FACTOR
//C
kk = q*aa;
k2 = kk*kk;
k3 = kk*k2;
SINCOS(kk,ds,dc);
//ds = sin(kk);
//dc = cos(kk);
aq1 = ((ds - kk*dc)*alpha)/k3;
aq2 = (beta*(1.0f-dc))/k2;
aq3 = (lam*ds)/(12.0f*kk);
aq = 1.0f + 12.0f*eta*(aq1+aq2-aq3);
//
bq1 = alpha*(0.5f/kk - ds/k2 + (1.0f - dc)/k3);
bq2 = beta*(1.0f/kk - ds/k2);
bq3 = (lam/12.0f)*((1.0f - dc)/kk);
bq = 12.0f*eta*(bq1+bq2-bq3);
//
sq = 1.0f/(aq*aq +bq*bq);
return(sq);
}
float Iqxy(float qx, float qy, IQXY_PARAMETER_DECLARATIONS);
float Iqxy(float qx, float qy, IQXY_PARAMETER_DECLARATIONS) {
return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
}
/*
##########################################################
# #
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# !! !! #
# !! KEEP THIS CODE CONSISTENT WITH KERNELPY.PY !! #
# !! !! #
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# #
##########################################################
*/
#ifdef IQ_KERNEL_NAME
kernel void IQ_KERNEL_NAME(
global const float *q,
global float *result,
const int Nq,
#ifdef IQ_OPEN_LOOPS
#ifdef USE_OPENCL
global float *loops_g,
#endif
local float *loops,
const float cutoff,
IQ_DISPERSION_LENGTH_DECLARATIONS,
#endif
IQ_FIXED_PARAMETER_DECLARATIONS
)
{
#ifdef USE_OPENCL
#ifdef IQ_OPEN_LOOPS
// copy loops info to local memory
event_t e = async_work_group_copy(loops, loops_g, (IQ_DISPERSION_LENGTH_SUM)*2, 0);
wait_group_events(1, &e);
#endif
int i = get_global_id(0);
if (i < Nq)
#else
#pragma omp parallel for
for (int i=0; i < Nq; i++)
#endif
{
const float qi = q[i];
#ifdef IQ_OPEN_LOOPS
float ret=0.0f, norm=0.0f;
#ifdef VOLUME_PARAMETERS
float vol=0.0f, norm_vol=0.0f;
#endif
IQ_OPEN_LOOPS
//for (int radius_i=0; radius_i < Nradius; radius_i++) {
// const float radius = loops[2*(radius_i)];
// const float radius_w = loops[2*(radius_i)+1];
const float weight = IQ_WEIGHT_PRODUCT;
if (weight > cutoff) {
const float scattering = Iq(qi, IQ_PARAMETERS);
// allow kernels to exclude invalid regions by returning NaN
if (!isnan(scattering)) {
ret += weight*scattering;
norm += weight;
#ifdef VOLUME_PARAMETERS
const float vol_weight = VOLUME_WEIGHT_PRODUCT;
vol += vol_weight*form_volume(VOLUME_PARAMETERS);
norm_vol += vol_weight;
#endif
}
//else { printf("exclude qx,qy,I:%g,%g,%g\n",qi,scattering); }
}
IQ_CLOSE_LOOPS
#ifdef VOLUME_PARAMETERS
if (vol*norm_vol != 0.0f) {
ret *= norm_vol/vol;
}
#endif
result[i] = scale*ret/norm+background;
#else
result[i] = scale*Iq(qi, IQ_PARAMETERS) + background;
#endif
}
}
#endif
#ifdef IQXY_KERNEL_NAME
kernel void IQXY_KERNEL_NAME(
global const float *qx,
global const float *qy,
global float *result,
const int Nq,
#ifdef IQXY_OPEN_LOOPS
#ifdef USE_OPENCL
global float *loops_g,
#endif
local float *loops,
const float cutoff,
IQXY_DISPERSION_LENGTH_DECLARATIONS,
#endif
IQXY_FIXED_PARAMETER_DECLARATIONS
)
{
#ifdef USE_OPENCL
#ifdef IQXY_OPEN_LOOPS
// copy loops info to local memory
event_t e = async_work_group_copy(loops, loops_g, (IQXY_DISPERSION_LENGTH_SUM)*2, 0);
wait_group_events(1, &e);
#endif
int i = get_global_id(0);
if (i < Nq)
#else
#pragma omp parallel for
for (int i=0; i < Nq; i++)
#endif
{
const float qxi = qx[i];
const float qyi = qy[i];
#if USE_KAHAN_SUMMATION
float accumulated_error = 0.0f;
#endif
#ifdef IQXY_OPEN_LOOPS
float ret=0.0f, norm=0.0f;
#ifdef VOLUME_PARAMETERS
float vol=0.0f, norm_vol=0.0f;
#endif
IQXY_OPEN_LOOPS
//for (int radius_i=0; radius_i < Nradius; radius_i++) {
// const float radius = loops[2*(radius_i)];
// const float radius_w = loops[2*(radius_i)+1];
const float weight = IQXY_WEIGHT_PRODUCT;
if (weight > cutoff) {
const float scattering = Iqxy(qxi, qyi, IQXY_PARAMETERS);
if (!isnan(scattering)) { // if scattering is bad, exclude it from sum
//if (scattering >= 0.0f) { // scattering cannot be negative
// TODO: use correct angle for spherical correction
// Definition of theta and phi are probably reversed relative to the
// equation which gave rise to this correction, leading to an
// attenuation of the pattern as theta moves through pi/2.f Either
// reverse the meanings of phi and theta in the forms, or use phi
// rather than theta in this correction. Current code uses cos(theta)
// so that values match those of sasview.
#if defined(IQXY_HAS_THETA) // && 0
const float spherical_correction
= (Ntheta>1 ? fabs(cos(M_PI_180*theta))*M_PI_2:1.0f);
const float next = spherical_correction * weight * scattering;
#else
const float next = weight * scattering;
#endif
#if USE_KAHAN_SUMMATION
const float y = next - accumulated_error;
const float t = ret + y;
accumulated_error = (t - ret) - y;
ret = t;
#else
ret += next;
#endif
norm += weight;
#ifdef VOLUME_PARAMETERS
const float vol_weight = VOLUME_WEIGHT_PRODUCT;
vol += vol_weight*form_volume(VOLUME_PARAMETERS);
#endif
norm_vol += vol_weight;
}
//else { printf("exclude qx,qy,I:%g,%g,%g\n",qi,scattering); }
}
IQXY_CLOSE_LOOPS
#ifdef VOLUME_PARAMETERS
if (vol*norm_vol != 0.0f) {
ret *= norm_vol/vol;
}
#endif
result[i] = scale*ret/norm+background;
#else
result[i] = scale*Iqxy(qxi, qyi, IQXY_PARAMETERS) + background;
#endif
}
}
#endif
| mads-bertelsen/McCode | mcxtrace-comps/share/sas_stickyhardsphere.c | C | gpl-2.0 | 11,531 | [
30522,
1013,
1013,
7013,
3642,
1011,
1011,
1011,
2079,
2025,
10086,
1011,
1011,
1011,
1013,
1013,
3642,
2003,
2550,
2011,
21871,
5302,
9247,
2015,
1012,
8991,
2013,
21871,
5302,
9247,
2015,
1013,
4275,
1013,
2944,
1012,
1039,
1001,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.